/* ==========================================================================
   Picset Design System & Modern Aesthetics
   ========================================================================== */

:root {
  --font: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;

  /* Colors - Light Theme */
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-subtle: #f1f3f5;
  --ink: #111418;
  --ink-secondary: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-subtle: #f3f4f6;

  --accent: #e60023;
  --accent-hover: #c9001f;
  --accent-soft: #ffebee;
  --accent-glow: rgba(230, 0, 35, 0.22);

  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #10b981;
  --success-soft: #d1fae5;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --media-chip: rgba(18, 18, 20, 0.75);
  --media-chip-ink: #ffffff;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 6px 20px -3px rgba(0, 0, 0, 0.08), 0 2px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.12), 0 6px 12px -3px rgba(0, 0, 0, 0.05);

  /* Dimensions & Radius */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  --topbar-h: 68px;
  color-scheme: light;
}

/* Dark theme overrides via data-theme or system media query */
[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #171920;
  --surface-elevated: #20232c;
  --surface-subtle: #1e2028;
  --ink: #f9fafb;
  --ink-secondary: #9ca3af;
  --muted: #6b7280;
  --line: #262932;
  --line-subtle: #1c1e26;

  --accent: #ff334b;
  --accent-hover: #ff4d62;
  --accent-soft: rgba(255, 51, 75, 0.15);
  --accent-glow: rgba(255, 51, 75, 0.35);

  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.16);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);
  --media-chip: rgba(10, 12, 16, 0.72);
  --media-chip-ink: #ffffff;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px -2px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px -6px rgba(0, 0, 0, 0.7), 0 8px 16px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #171920;
    --surface-elevated: #20232c;
    --surface-subtle: #1e2028;
    --ink: #f9fafb;
    --ink-secondary: #9ca3af;
    --muted: #6b7280;
    --line: #262932;
    --line-subtle: #1c1e26;

    --accent: #ff334b;
    --accent-hover: #ff4d62;
    --accent-soft: rgba(255, 51, 75, 0.15);
    --accent-glow: rgba(255, 51, 75, 0.35);

    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.16);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.16);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, 0.16);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.16);
    --media-chip: rgba(10, 12, 16, 0.72);
    --media-chip-ink: #ffffff;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 24px -2px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px -6px rgba(0, 0, 0, 0.7), 0 8px 16px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ==========================================================================
   Base & Resets
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  user-select: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--ink) 30%, transparent);
}

/* ==========================================================================
   Topbar (Sticky Header)
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 clamp(14px, 1.6vw, 36px);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--line);
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  width: 100%;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: var(--radius-md);
  transition: transform 0.15s ease, background 0.15s ease;
}
.brand:hover {
  background: var(--surface-subtle);
}
.brand:active {
  transform: scale(0.97);
}
.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 3px 8px var(--accent-glow));
}
.logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Search input */
.search-wrap {
  flex: 1;
  max-width: min(680px, 42vw);
  position: relative;
  display: flex;
  align-items: center;
}
@media (min-width: 1920px) {
  .search-wrap { max-width: min(820px, 40vw); }
}
@media (min-width: 2560px) {
  .search-wrap { max-width: min(920px, 36vw); }
}

.search-icon {
  position: absolute;
  left: 16px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.15s ease;
}

#searchInput {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-pill);
  border: 1.5px solid transparent;
  background: var(--surface-subtle);
  color: var(--ink);
  padding: 0 46px 0 48px;
  outline: none;
  font-size: 0.95rem;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
#searchInput:hover {
  background: color-mix(in srgb, var(--surface-subtle) 80%, var(--surface));
}
#searchInput:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
#searchInput:focus ~ .search-icon {
  color: var(--accent);
}

.search-kbd {
  position: absolute;
  right: 14px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#searchInput:focus ~ .search-kbd,
#searchInput:not(:placeholder-shown) ~ .search-kbd {
  opacity: 0;
  pointer-events: none;
}

#clearSearch {
  position: absolute;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
}
#clearSearch:hover {
  background: var(--line);
  color: var(--ink);
}

/* Topbar Actions */
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.primary-btn, .ghost-btn, .danger-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  transition: all 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.primary-btn:active, .ghost-btn:active, .icon-btn:active, .danger-btn:active {
  transform: scale(0.96);
}

.primary-btn {
  height: 42px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}
.primary-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
}

.ghost-btn {
  height: 40px;
  padding: 0 16px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 0.92rem;
}
.ghost-btn:hover {
  background: color-mix(in srgb, var(--ink) 10%, var(--surface-subtle));
}

.token-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.token-btn.hidden,
.ghost-btn.hidden,
.primary-btn.hidden {
  display: none !important;
}
.token-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.token-dot.active {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

/* Login identity chip (main site + admin) */
.user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.auth-who {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 4px 8px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-size: 0.75rem;
  line-height: 1.15;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.auth-who.hidden { display: none !important; }
.auth-who:hover { background: var(--surface); border-color: color-mix(in srgb, var(--ink) 18%, var(--line)); }
.auth-who[data-mode="user"] {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--success) 40%, var(--line));
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
}
.auth-who[data-mode="token"] {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--warn) 40%, var(--line));
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
}
.auth-who[data-mode="open"],
.auth-who[data-mode="guest"] {
  color: var(--ink-secondary);
  border-color: var(--line);
}
.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: block;
  object-fit: cover;
  background: var(--muted);
}
.auth-who-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}
.auth-who-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.78rem;
}
.auth-who-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.65rem;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
input.readonly,
input[readonly] {
  opacity: 0.65;
  cursor: not-allowed;
}
.auth-who-caret {
  flex-shrink: 0;
  opacity: 0.45;
  margin-left: 2px;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 60;
  min-width: 260px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-elevated, var(--surface));
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,.18));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-menu-panel.hidden { display: none !important; }
.user-menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--line);
}
.user-menu-head .auth-avatar { width: 36px; height: 36px; }
.user-menu-head-meta { min-width: 0; }
.user-menu-name {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-email {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-menu-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 4px;
}
.user-menu-row .label {
  font-size: 0.72rem;
  color: var(--muted);
}
.user-menu-row .uid {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  word-break: break-all;
  line-height: 1.4;
  cursor: copy;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.user-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
  border-top: 1px solid var(--line);
}
.user-menu-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.user-menu-link:hover { background: var(--surface-subtle); }
.user-menu-link.danger { color: var(--danger); }
.user-menu-link.danger:hover { background: var(--danger-soft); }

@media (max-width: 720px) {
  /* Keep avatar + menu; hide only the text so logout stays reachable */
  .auth-who .auth-who-meta { display: none; }
  .auth-who { padding: 4px; max-width: none; gap: 4px; }
  .user-menu-panel { right: -8px; min-width: min(280px, calc(100vw - 24px)); }
}

.danger-btn {
  height: 40px;
  padding: 0 16px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.92rem;
}
.danger-btn:hover {
  background: color-mix(in srgb, var(--danger) 22%, transparent);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-secondary);
}
.icon-btn svg {
  stroke: currentColor;
  fill: none;
}
.icon-btn:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}

.icon-btn-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.3s ease;
}
.icon-btn-sm:hover {
  background: var(--surface-subtle);
  color: var(--ink);
}
.icon-btn-sm.spinning svg {
  animation: spin 0.7s linear infinite;
}

/* ==========================================================================
   Toolbar (Stats, Media Tabs, Tag Chips)
   ========================================================================== */

.toolbar {
  padding: 16px clamp(14px, 1.6vw, 36px) 8px;
  max-width: none;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 1920px) {
  .toolbar { padding-top: 18px; gap: 14px; }
  .tag-chip { height: 40px; padding: 0 18px; font-size: 0.92rem; }
}
@media (min-width: 2560px) {
  .toolbar { padding-top: 20px; }
  .stats { font-size: 0.95rem; }
  .media-tab { height: 36px; padding: 0 16px; font-size: 0.9rem; }
}

.toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.stats-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stats {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
}

/* Media Type Filter Tabs */
.media-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-subtle);
  padding: 4px;
  border-radius: var(--radius-pill);
}

.media-tab {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s ease;
}
.media-tab:hover {
  color: var(--ink);
}
.media-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Tag Row */
.tag-row-wrapper {
  position: relative;
  overflow: hidden;
  margin: 0 calc(-1 * clamp(14px, 1.6vw, 36px));
  padding: 0 clamp(14px, 1.6vw, 36px);
  mask-image: linear-gradient(to right, transparent 0, black 24px, black calc(100% - 24px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, black 24px, black calc(100% - 24px), transparent 100%);
}

.tag-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.tag-row::-webkit-scrollbar {
  display: none;
}

.tag-chip {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  box-shadow: var(--shadow-xs);
}
.tag-chip:hover {
  background: var(--surface-subtle);
  border-color: color-mix(in srgb, var(--ink) 20%, var(--line));
}
.tag-chip:active {
  transform: scale(0.96);
}
.tag-chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.tag-chip .count {
  margin-left: 6px;
  font-size: 0.78rem;
  opacity: 0.65;
  background: color-mix(in srgb, currentColor 12%, transparent);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Masonry Feed & Cards 閳?immersive image-wall
   ========================================================================== */

.masonry {
  position: relative;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 8px 12px 96px;
}

@media (min-width: 640px) { .masonry { padding: 10px 16px 96px; } }
@media (min-width: 960px) { .masonry { padding: 12px 18px 96px; } }
@media (min-width: 1280px) { .masonry { padding: 12px 18px 96px; } }
@media (min-width: 1640px) { .masonry { padding: 12px 20px 96px; } }
@media (min-width: 1920px) { .masonry { padding: 14px 24px 100px; } }
@media (min-width: 2560px) { .masonry { padding: 16px 28px 110px; } }
@media (min-width: 3200px) { .masonry { padding: 18px 32px 120px; } }
@media (min-width: 3840px) { .masonry { padding: 20px 36px 140px; } }

.card {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(90deg, var(--surface-subtle) 0%, var(--surface-elevated) 50%, var(--surface-subtle) 100%);
  background-size: 200% 100%;
  opacity: 0;
  transform-origin: center top;
  /* Opacity-only entrance: masonry sets inline transform translate() 閳?
     animating transform here would override layout (all cards stack at 0,0). */
  animation: rise 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: 100%;
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
  will-change: opacity;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Lightbox View Transition Support */
::view-transition-group(*) {
  animation-duration: 0.35s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes rise {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.card .thumb {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--surface-subtle);
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  cursor: zoom-in;
  /* No will-change / translateZ here 閳?both flicker in Edge 4K + CSS columns */
}

.card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* No transform/filter hover animation 閳?Edge 4K repaints these in columns */
}

/* Optional gentle zoom only on modest resolutions / lower DPI */
@media (max-width: 1919px) and (max-resolution: 1.4dppx) {
  .card img {
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .card:hover img {
    transform: scale(1.025);
  }
}

.card .ratio {
  width: 100%;
  overflow: hidden;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ink) 4%, transparent),
    color-mix(in srgb, var(--ink) 9%, transparent),
    color-mix(in srgb, var(--ink) 4%, transparent));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
/* Once an <img> has a src, stop the infinite shimmer */
.card .ratio:has(img[src]) {
  animation: none;
  background: var(--surface-subtle);
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Card Hover Overlay 閳?opacity-only feedback (Edge@4K safe) */
.card .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(0, 0, 0, 0.02) 38%,
    rgba(0, 0, 0, 0.78) 100%);
  opacity: 0;
  transition: opacity 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
  border-radius: var(--radius-md);
}
.card:hover .overlay {
  opacity: 1;
}

.overlay-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  opacity: 0;
  transition: opacity 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}
.card:hover .overlay-content {
  opacity: 1;
  pointer-events: auto;
}

.overlay-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.overlay-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}
.overlay-info .title {
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: left;
  line-height: 1.3;
}
.overlay-info .meta {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.72rem;
  text-align: left;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overlay-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.pin-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  color: #111418;
  display: grid;
  place-items: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease, transform 0.12s ease, color 0.15s ease;
  pointer-events: auto;
}
.pin-icon-btn:hover {
  background: #ffffff;
  transform: scale(1.06);
  color: var(--accent);
}
.pin-icon-btn:active {
  transform: scale(0.94);
}
.pin-icon-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

/* Badges */
.raw-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--media-chip);
  backdrop-filter: blur(8px);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

.video-badge {
  color: var(--info);
  border-color: color-mix(in srgb, var(--info) 45%, transparent);
}

.play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
  color: #ffffff;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.play-badge svg {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  border-radius: 50%;
  padding: 12px;
  width: 50px;
  height: 50px;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease, background 0.2s ease;
}
.card:hover .play-badge svg {
  transform: scale(1.1);
  background: var(--accent);
}

.feed-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b0c0e;
}

/* Card Bottom Meta 閳?quiet caption so images dominate */
.card-caption {
  padding: 6px 4px 2px;
  transition: opacity 0.2s ease;
}
.card-caption-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ink-secondary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.72;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.card:hover .card-caption-title {
  opacity: 1;
  color: var(--ink);
}
.card-caption-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0.55;
}

.card .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease, margin 0.2s ease;
}
.card:hover .card-tags {
  max-height: 48px;
  opacity: 1;
}
.mini-tag {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-subtle));
  color: color-mix(in srgb, var(--accent) 70%, var(--ink));
  border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
}

/* Sentinel & Loader */
.sentinel {
  height: 1px;
}
.loader {
  display: flex;
  justify-content: center;
  padding: 20px 0 60px;
}
.loader span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.65s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.empty {
  text-align: center;
  padding: 80px 20px 120px;
  color: var(--muted);
}
.empty-illustration {
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface-subtle));
  border: 2px dashed color-mix(in srgb, var(--accent) 35%, transparent);
  box-shadow: var(--shadow-sm);
  position: relative;
  display: grid;
  place-items: center;
}
.empty-illustration::before {
  content: "棣冩煠閿?;
  font-size: 2.4rem;
}
.empty p {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 16px;
  color: var(--ink-secondary);
}
.empty-btn {
  margin: 0 auto;
}

/* ==========================================================================
   Modals & Dialogs
   ========================================================================== */

.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(640px, calc(100vw - 32px));
  width: 100%;
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: min(90vh, 880px);
  overflow: auto;
  border: 1px solid var(--line);
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-card.narrow {
  max-width: 440px;
  margin: 0 auto;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.modal-title-wrap h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-sub {
  margin-top: 2px;
  display: block;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius-lg);
  min-height: 140px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--surface-subtle);
  transition: all 0.2s ease;
  padding: 20px;
  text-align: center;
}
.dropzone.dragover, .dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 18%, var(--surface)), var(--surface));
  position: relative;
  box-shadow: var(--shadow-sm);
}
.drop-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 13px;
  width: 10px;
  height: 10px;
  border-left: 2.2px solid var(--accent);
  border-top: 2.2px solid var(--accent);
  transform: translateX(-50%) rotate(45deg);
}
.drop-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 19px;
  width: 2.2px;
  height: 14px;
  background: var(--accent);
  transform: translateX(-50%);
}

/* File list in upload modal */
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.file-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--line-subtle);
}
.pending-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: var(--surface-subtle);
  flex-shrink: 0;
}
.pending-thumb.ph {
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--line);
}
.pending-thumb.ph-video {
  background: var(--surface-elevated);
  color: var(--info);
}
.pending-thumb.ph-raw {
  background: color-mix(in srgb, var(--warn) 12%, var(--surface-subtle));
  color: var(--warn);
}
.pending-thumb.ph-image {
  background: var(--surface-subtle);
  color: var(--muted);
}
.file-list .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.file-list .bar {
  width: 80px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--line);
  overflow: hidden;
  flex-shrink: 0;
}
.file-list .bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    var(--accent),
    color-mix(in srgb, var(--accent) 45%, white)
  );
  transition: width 0.2s ease;
}
.file-list .status {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 3.5em;
  text-align: right;
  flex-shrink: 0;
}
.file-remove-btn {
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.file-remove-btn:hover {
  background: var(--line);
  color: var(--danger);
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-secondary);
}
.field input {
  height: 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  padding: 0 14px;
  outline: none;
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--surface);
}

/* ==========================================================================
   Lightbox / Fullview Experience 閳?immersive cinema mode
   ========================================================================== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(4, 5, 8, 0.97);
  backdrop-filter: blur(28px) saturate(120%);
  -webkit-backdrop-filter: blur(28px) saturate(120%);
  display: grid;
  grid-template-columns: 1fr;
  animation: fadeIn 0.22s ease;
}

/* Side panel becomes a floating glass drawer (toggleable) */
.lightbox-side {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 92vw);
  z-index: 12;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--ink);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  padding: 72px 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.lightbox.show-info .lightbox-side {
  transform: translateX(0);
}

/* When info is open, give stage a little right breathing room on wide screens */
@media (min-width: 900px) {
  .lightbox.show-info .lightbox-stage {
    padding-right: min(400px, 28vw);
  }
  .lightbox.show-info .lb-next {
    right: calc(min(380px, 92vw) + 20px);
  }
}

/* Large / 4K lightbox: bigger stage, larger hit targets */
@media (min-width: 1920px) {
  .lightbox-stage {
    padding: 72px 72px 36px;
  }
  .lightbox-stage img,
  .lightbox-stage video {
    max-height: calc(100vh - 108px);
    border-radius: 8px;
  }
  .lightbox-nav {
    width: 54px;
    height: 54px;
  }
  .lb-prev { left: 28px; }
  .lb-next { right: 28px; }
  .lightbox-header { top: 20px; left: 28px; right: 28px; }
  .lb-tool-btn { width: 40px; height: 40px; }
  .lb-tool-btn svg { width: 20px; height: 20px; }
}

@media (min-width: 2560px) {
  .lightbox-stage {
    padding: 80px 96px 48px;
  }
  .lightbox-stage img,
  .lightbox-stage video {
    max-height: calc(100vh - 128px);
  }
  .lightbox-side {
    width: min(420px, 90vw);
    padding: 80px 28px 28px;
    gap: 22px;
  }
  .side-header h2 { font-size: 1.4rem; }
  .lb-prev { left: 36px; }
  .lb-next { right: 36px; }
  .lightbox.show-info .lb-next {
    right: calc(min(420px, 90vw) + 28px);
  }
  .lightbox.show-info .lightbox-stage {
    padding-right: min(440px, 26vw);
  }
}

@media (min-width: 3840px) {
  .lightbox-stage {
    padding: 96px 120px 56px;
  }
  .lightbox-stage img,
  .lightbox-stage video {
    max-height: calc(100vh - 152px);
    box-shadow: 0 28px 100px rgba(0, 0, 0, 0.8);
  }
  .lightbox-counter { font-size: 0.95rem; padding: 8px 18px; }
}

.lightbox-header {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.lightbox-counter {
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: auto;
  letter-spacing: 0.02em;
}

.lightbox-top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.lb-tool-btn {
  width: 36px;
  height: 36px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}
.lb-tool-btn svg {
  width: 18px;
  height: 18px;
}
.lb-tool-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}
.lb-tool-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.lb-close-btn {
  margin-left: 4px;
  background: rgba(255, 255, 255, 0.14);
}
.lb-close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Navigation Arrows */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 11;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  opacity: 0.55;
}
.lightbox:hover .lightbox-nav,
.lightbox-nav:focus-visible {
  opacity: 1;
}
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: translateY(-50%) scale(1.08);
}
.lightbox-nav:active {
  transform: translateY(-50%) scale(0.95);
}
.lb-prev { left: 16px; }
.lb-next { right: 16px; }

/* Stage 閳?media owns the viewport */
.lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 64px 28px;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.lightbox-media-box {
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.lightbox-stage img {
  max-width: 100%;
  max-height: calc(100vh - 88px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.75);
  user-select: none;
  transition: opacity 0.2s ease, transform 0.25s ease;
  animation: lbIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.lightbox-stage video {
  max-width: 100%;
  max-height: calc(100vh - 88px);
  width: auto;
  height: auto;
  /* Reserve box before metadata loads so play size does not jump */
  aspect-ratio: 16 / 9;
  min-width: min(420px, 100%);
  min-height: min(240px, calc(100vh - 120px));
  object-fit: contain;
  border-radius: 6px;
  background: #000;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.75);
  animation: lbIn 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes lbIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.side-header h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35;
  word-break: break-word;
}

.meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.meta-chip {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  color: var(--muted);
  border: 1px solid var(--line-subtle);
}

.side-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.lb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lb-tags .mini-tag {
  font-size: 0.82rem;
  padding: 4px 10px;
}

.edit-section {
  background: var(--surface-subtle);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-subtle);
}

.side-actions {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Responsive Lightbox */
@media (max-width: 860px) {
  .lightbox-side {
    width: 100%;
    top: auto;
    height: min(52vh, 420px);
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(105%);
    padding: 20px 18px;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  }
  .lightbox.show-info .lightbox-side {
    transform: translateY(0);
  }
  .lightbox-stage {
    padding: 56px 12px 12px;
  }
  .lightbox-stage img,
  .lightbox-stage video {
    max-height: 56vh;
  }
  .lightbox.show-info .lightbox-stage {
    padding-right: 12px;
  }
  .lightbox.show-info .lb-next {
    right: 16px;
  }
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
  .lightbox-nav {
    width: 42px;
    height: 42px;
  }
  .topbar {
    gap: 8px;
    padding: 0 14px;
  }
  .brand h1 {
    display: none;
  }
  #tokenBtn span:not(.token-dot) {
    display: none;
  }
  .tag-row-wrapper {
    margin: 0 -14px;
    padding: 0 14px;
  }
}

/* Auto-hide topbar while scrolling down (more image real estate) */
.topbar {
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1),
    background 0.25s ease, border-color 0.25s ease;
}
body.chrome-hidden .topbar {
  transform: translateY(-110%);
}
body.chrome-hidden .toolbar {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.toolbar {
  transition: opacity 0.25s ease;
}

/* Slightly larger chrome on big displays so UI doesn't feel tiny */
@media (min-width: 2560px) {
  :root { --topbar-h: 76px; }
  .brand h1 { font-size: 1.4rem; }
  .logo { width: 36px; height: 36px; }
  .primary-btn { height: 46px; padding: 0 20px; font-size: 0.98rem; }
  .ghost-btn, .danger-btn { height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  #searchInput { height: 48px; font-size: 1rem; }
  .back-to-top { width: 52px; height: 52px; right: 28px; bottom: 28px; }
}
@media (min-width: 3840px) {
  :root { --topbar-h: 80px; }
  .overlay-info .title { font-size: 0.98rem; }
  .pin-icon-btn { width: 36px; height: 36px; }
  .pin-icon-btn svg { width: 17px; height: 17px; }
}

/* Soft ambient glow behind feed on dark theme for gallery feel */
@media (prefers-color-scheme: dark) {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
      radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 51, 75, 0.06), transparent 55%),
      radial-gradient(ellipse 60% 40% at 100% 100%, rgba(96, 165, 250, 0.04), transparent 50%);
  }
}
[data-theme="dark"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 51, 75, 0.06), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(96, 165, 250, 0.04), transparent 50%);
}

/* ==========================================================================
   Global Drag & Drop Fullscreen Overlay
   ========================================================================== */

.global-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 12, 16, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

.drop-overlay-box {
  background: var(--surface);
  border: 2.5px dashed var(--accent);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  text-align: center;
  color: var(--ink);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  max-width: 480px;
  width: 100%;
}
.drop-overlay-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  animation: pulse 1.8s infinite ease-in-out;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
.drop-overlay-box h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 700;
}
.drop-overlay-box p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ==========================================================================
   Back to top floating button
   ========================================================================== */

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 45;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.15s, opacity 0.2s;
}
.back-to-top:hover {
  transform: translateY(-3px);
  background: var(--surface-subtle);
  border-color: var(--accent);
  color: var(--accent);
}
.back-to-top:active {
  transform: scale(0.95);
}
.back-to-top svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  max-width: min(90vw, 440px);
  text-align: center;
  pointer-events: none;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.error {
  background: var(--danger);
  color: #ffffff;
}
.toast.success {
  background: var(--success);
  color: #ffffff;
}

/* ==========================================================================
   Series (collections)
   ========================================================================== */

.view-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  margin-right: 10px;
}
.view-seg-btn {
  border: 0;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.view-seg-btn.active {
  background: var(--ink);
  color: var(--bg);
}

.series-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding: 8px 4px 40px;
  max-width: 1400px;
  margin: 0 auto;
}
.series-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
}
.series-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.series-card-cover {
  aspect-ratio: 3/4;
  background: var(--surface-subtle);
  position: relative;
  overflow: hidden;
}
.series-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.series-card-cover .placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--surface-subtle);
}
.series-card-body {
  padding: 12px 14px 14px;
}
.series-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.series-card-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.card-series-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  background: rgba(17, 20, 24, 0.62);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: pointer;
}

.series-detail {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.series-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 2;
}
.series-detail-title-wrap {
  flex: 1;
  min-width: 140px;
}
.series-detail-title-wrap h2 {
  margin: 0;
  font-size: 1.1rem;
}
.series-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.series-detail-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: 20px;
  padding: 16px 18px 20px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  align-items: stretch;
  min-height: 0;
}
@media (max-width: 900px) {
  .series-detail-body {
    grid-template-columns: 1fr;
  }
}
.series-stage {
  min-width: 0;
}
.series-empty-stage {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 280px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.series-empty-stage p {
  margin: 0;
  font-size: 0.95rem;
}
.series-player {
  background: #111;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
}
.series-player-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  /* Keep player and episode rail visually aligned */
  max-height: min(62vh, calc(100vh - 180px));
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.series-player-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}
.series-player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 8px 10px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.series-player-bar .ghost-btn,
.series-player-bar .primary-btn {
  height: 34px;
  padding: 0 12px;
  font-size: 0.84rem;
}
#seriesPlayerLabel {
  flex: 1;
  min-width: 120px;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}
.series-autonext {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
  cursor: pointer;
  user-select: none;
}
.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.series-grid-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-subtle);
  border: 2px solid transparent;
  cursor: pointer;
  aspect-ratio: 3/4;
}
.series-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.series-grid-item.current {
  border-color: var(--accent);
}
.series-grid-item .pos {
  position: absolute;
  left: 6px;
  top: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  z-index: 1;
}
.series-grid-item .play-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  z-index: 1;
}
.series-grid-item.dragging {
  opacity: 0.45;
}
.series-video-ph {
  width: 100%;
  height: 100%;
  min-height: 80px;
  display: grid;
  place-items: center;
  background: var(--surface-elevated);
  color: var(--muted);
  font-size: 1.4rem;
}
.series-video-ph span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
  font-size: 0.85rem;
}
.series-list-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(62vh, calc(100vh - 180px));
  position: sticky;
  top: 72px;
}
.series-list-head {
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0 0 8px;
  padding: 0 4px;
  color: var(--ink-secondary);
  letter-spacing: 0.04em;
}
.series-list {
  list-style: none;
  margin: 0;
  padding: 0 2px 0 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent;
}
.series-list::-webkit-scrollbar {
  width: 6px;
}
.series-list::-webkit-scrollbar-track {
  background: transparent;
}
.series-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--ink) 20%, transparent);
  border-radius: 999px;
}
.series-list::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}
.series-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.35;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.series-list li:hover {
  background: var(--surface-subtle);
  border-color: var(--line);
}
.series-list li .ep {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--accent);
  min-width: 2.4em;
  padding-top: 1px;
  font-variant-numeric: tabular-nums;
}
.series-list li .title {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.series-list li.current {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.series-list li.current .ep {
  color: var(--accent);
}
.series-list li.dragging {
  opacity: 0.4;
}
.series-list li .grip {
  color: var(--muted);
  cursor: grab;
  user-select: none;
}
.series-list li .ep {
  font-weight: 700;
  color: var(--accent);
  min-width: 3.2em;
}
.series-list.reordering li {
  cursor: grab;
}
.series-reorder-hint {
  font-size: 0.75rem;
  margin: 8px 0 0;
}
body.series-reorder-mode .series-reorder-hint {
  color: var(--accent);
}

#uploadSeriesSelect {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
#uploadSeriesSelect:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}



/* Series cover card (immersive) in masonry feed */
.series-cover-card .ratio {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.series-cover {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--surface-subtle);
}
.series-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.series-cover-grad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.35) 45%, transparent 100%);
  pointer-events: none;
}
.series-cover-ph {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  color: var(--muted);
  background: var(--surface-subtle);
}
.series-cover-ph span {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.series-cover-info {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
}
.series-cover-info h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}
.series-cover-info p {
  margin: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
}
.series-cover-bar {
  margin-top: 8px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}
.series-cover-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.stack-count {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.series-type-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Media cards share immersive cover chrome with series cards */
.series-cover img,
.series-cover video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.card-quick-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.series-cover-card:hover .card-quick-actions {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.card-quick-actions .pin-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(10, 12, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  text-decoration: none;
}
.card-quick-actions .pin-icon-btn svg {
  width: 14px;
  height: 14px;
}
/* Keep type badge from colliding with hover actions */
.series-cover-card > .thumb > .raw-badge,
.series-cover-card > .thumb > .video-badge {
  left: 10px;
  top: 10px;
  z-index: 3;
  background: rgba(10, 12, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
