:root,
[data-theme="aurora"] {
  --bg: #0c1020;
  --bg-elevated: #141a2e;
  --bg-soft: #1a2240;
  --border: rgba(167, 139, 250, 0.14);
  --border-strong: rgba(167, 139, 250, 0.28);
  --text: #f4f1ff;
  --muted: #a9b0d0;
  --primary: #a78bfa;
  --primary-hover: #c4b5fd;
  --primary-soft: rgba(167, 139, 250, 0.2);
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --ok: #34d399;
  --glow: rgba(167, 139, 250, 0.35);
  --grad-a: #7c3aed;
  --grad-b: #06b6d4;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 20px 60px rgba(8, 6, 30, 0.55);
  --sidebar-w: 280px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

[data-theme="sunset"] {
  --bg: #140c0a;
  --bg-elevated: #221410;
  --bg-soft: #2c1a14;
  --border: rgba(251, 146, 60, 0.16);
  --border-strong: rgba(251, 146, 60, 0.3);
  --text: #fff7ed;
  --muted: #c4a99a;
  --primary: #fb923c;
  --primary-hover: #fdba74;
  --primary-soft: rgba(251, 146, 60, 0.2);
  --accent: #f472b6;
  --accent-soft: rgba(244, 114, 182, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --ok: #fbbf24;
  --glow: rgba(251, 146, 60, 0.4);
  --grad-a: #ea580c;
  --grad-b: #db2777;
}

[data-theme="ocean"] {
  --bg: #06141c;
  --bg-elevated: #0c2230;
  --bg-soft: #123040;
  --border: rgba(56, 189, 248, 0.16);
  --border-strong: rgba(56, 189, 248, 0.3);
  --text: #e0f2fe;
  --muted: #8bb4c9;
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-soft: rgba(56, 189, 248, 0.2);
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --ok: #4ade80;
  --glow: rgba(56, 189, 248, 0.35);
  --grad-a: #0284c7;
  --grad-b: #14b8a6;
}

[data-theme="candy"] {
  --bg: #150a18;
  --bg-elevated: #24122c;
  --bg-soft: #32183c;
  --border: rgba(244, 114, 182, 0.18);
  --border-strong: rgba(244, 114, 182, 0.32);
  --text: #fdf2f8;
  --muted: #c9a3bd;
  --primary: #f472b6;
  --primary-hover: #f9a8d4;
  --primary-soft: rgba(244, 114, 182, 0.22);
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.18);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --ok: #c084fc;
  --glow: rgba(244, 114, 182, 0.4);
  --grad-a: #db2777;
  --grad-b: #7c3aed;
}

[data-theme="neon"] {
  --bg: #05080a;
  --bg-elevated: #0c1410;
  --bg-soft: #122018;
  --border: rgba(163, 230, 53, 0.16);
  --border-strong: rgba(163, 230, 53, 0.32);
  --text: #f0fdf4;
  --muted: #94b8a0;
  --primary: #a3e635;
  --primary-hover: #bef264;
  --primary-soft: rgba(163, 230, 53, 0.18);
  --accent: #22d3ee;
  --accent-soft: rgba(34, 211, 238, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --ok: #4ade80;
  --glow: rgba(163, 230, 53, 0.35);
  --grad-a: #65a30d;
  --grad-b: #0891b2;
}

[data-theme="forest"] {
  --bg: #08140e;
  --bg-elevated: #10241a;
  --bg-soft: #163024;
  --border: rgba(74, 222, 128, 0.14);
  --border-strong: rgba(74, 222, 128, 0.28);
  --text: #ecfdf5;
  --muted: #93b5a4;
  --primary: #4ade80;
  --primary-hover: #86efac;
  --primary-soft: rgba(74, 222, 128, 0.18);
  --accent: #fbbf24;
  --accent-soft: rgba(251, 191, 36, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --ok: #34d399;
  --glow: rgba(74, 222, 128, 0.3);
  --grad-a: #15803d;
  --grad-b: #d97706;
}

[data-theme="midnight"] {
  --bg: #0b0c10;
  --bg-elevated: #12141c;
  --bg-soft: #181b26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f2f3f7;
  --muted: #9aa0b4;
  --primary: #8b7cff;
  --primary-hover: #a094ff;
  --primary-soft: rgba(139, 124, 255, 0.16);
  --accent: #5ddea8;
  --accent-soft: rgba(93, 222, 168, 0.14);
  --danger: #ff6b7a;
  --danger-soft: rgba(255, 107, 122, 0.14);
  --ok: #5ddea8;
  --glow: rgba(139, 124, 255, 0.28);
  --grad-a: #6d5df0;
  --grad-b: #8b7cff;
}

[data-theme="celestial"] {
  --bg: #03060f;
  --bg-elevated: #0b1224;
  --bg-soft: #121a32;
  --border: rgba(125, 211, 252, 0.14);
  --border-strong: rgba(125, 211, 252, 0.28);
  --text: #eef6ff;
  --muted: #9bb0d0;
  --primary: #7dd3fc;
  --primary-hover: #bae6fd;
  --primary-soft: rgba(125, 211, 252, 0.18);
  --accent: #fbbf24;
  --accent-soft: rgba(251, 191, 36, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --ok: #4ade80;
  --glow: rgba(56, 189, 248, 0.32);
  --grad-a: #1d4ed8;
  --grad-b: #f59e0b;
}

html {
  color-scheme: dark;
}

/* ---- Animated theme scenery ---- */
.theme-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.theme-bg-photo {
  position: absolute;
  inset: -8%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transform: scale(1.08);
  transition: opacity 0.6s ease;
  will-change: transform, opacity;
}

.theme-bg-aurora,
.theme-bg-celestial {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.5s ease;
  overflow: hidden;
}

.theme-bg-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.25) 0%, transparent 30%, rgba(0, 0, 0, 0.35) 100%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.2), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.25));
  z-index: 5;
}

/* Aurora: photo + flowing light bands */
html[data-theme='aurora'] .theme-bg-photo {
  opacity: 0.72;
  background-image: url('/assets/themes/aurora.jpg');
  animation: theme-kenburns 28s ease-in-out infinite alternate;
}

html[data-theme='aurora'] .theme-bg-aurora {
  opacity: 1;
  mix-blend-mode: screen;
}

.aurora-band {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 42%;
  filter: blur(28px);
  opacity: 0.55;
  border-radius: 40% 60% 50% 50%;
  transform-origin: center;
}

.aurora-band.a1 {
  top: 8%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(52, 211, 153, 0.55),
    rgba(167, 139, 250, 0.45),
    rgba(34, 211, 238, 0.4),
    transparent
  );
  animation: aurora-drift 14s ease-in-out infinite alternate;
}

.aurora-band.a2 {
  top: 22%;
  height: 36%;
  background: linear-gradient(
    100deg,
    transparent,
    rgba(16, 185, 129, 0.5),
    rgba(99, 102, 241, 0.4),
    transparent
  );
  animation: aurora-drift 18s ease-in-out infinite alternate-reverse;
  animation-delay: -3s;
}

.aurora-band.a3 {
  top: 38%;
  height: 30%;
  background: linear-gradient(
    80deg,
    transparent,
    rgba(244, 114, 182, 0.28),
    rgba(52, 211, 153, 0.45),
    transparent
  );
  animation: aurora-drift 16s ease-in-out infinite alternate;
  animation-delay: -6s;
}

.aurora-band.a4 {
  top: 12%;
  height: 50%;
  opacity: 0.3;
  background: radial-gradient(
    ellipse at 40% 40%,
    rgba(167, 139, 250, 0.45),
    transparent 60%
  );
  animation: aurora-pulse 10s ease-in-out infinite;
}

/* Celestial: space photo + orbiting planets */
html[data-theme='celestial'] .theme-bg-photo {
  opacity: 0.78;
  background-image: url('/assets/themes/celestial.jpg');
  animation: theme-kenburns 36s ease-in-out infinite alternate;
}

html[data-theme='celestial'] .theme-bg-celestial {
  opacity: 1;
}

html[data-theme='celestial'] .theme-bg-veil {
  background:
    radial-gradient(ellipse at 18% 45%, rgba(251, 191, 36, 0.12), transparent 35%),
    linear-gradient(180deg, rgba(3, 6, 15, 0.35) 0%, transparent 40%, rgba(3, 6, 15, 0.55) 100%);
}

.stars {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
  opacity: 0.7;
}

.stars-a {
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff, transparent),
    radial-gradient(1px 1px at 30% 70%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 55% 30%, #cce7ff, transparent),
    radial-gradient(1px 1px at 75% 55%, #fff, transparent),
    radial-gradient(1.4px 1.4px at 90% 15%, #fff, transparent),
    radial-gradient(1px 1px at 20% 90%, #bae6fd, transparent),
    radial-gradient(1px 1px at 45% 45%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 65% 85%, #fff, transparent);
  background-size: 320px 320px;
  animation: stars-twinkle 4s ease-in-out infinite alternate;
}

.stars-b {
  background-image:
    radial-gradient(1px 1px at 15% 40%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40% 10%, #fff, transparent),
    radial-gradient(1px 1px at 60% 60%, #e0f2fe, transparent),
    radial-gradient(1.2px 1.2px at 80% 35%, #fff, transparent),
    radial-gradient(1px 1px at 25% 75%, #fff, transparent),
    radial-gradient(1px 1px at 85% 80%, #bae6fd, transparent);
  background-size: 420px 420px;
  opacity: 0.45;
  animation: stars-twinkle 6s ease-in-out infinite alternate-reverse;
}

.solar-system {
  position: absolute;
  left: 8%;
  top: 50%;
  width: min(70vw, 720px);
  height: min(70vw, 720px);
  transform: translateY(-50%);
  opacity: 0.55;
}

.sun {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff7cc, #fbbf24 45%, #f59e0b 70%, transparent 72%);
  box-shadow:
    0 0 40px 12px rgba(251, 191, 36, 0.45),
    0 0 90px 30px rgba(251, 191, 36, 0.2);
  animation: sun-pulse 5s ease-in-out infinite;
  z-index: 2;
}

.orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  border: 1px solid rgba(125, 211, 252, 0.12);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.orbit .planet {
  position: absolute;
  top: 50%;
  left: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px currentColor;
}

.o1 { width: 18%; height: 18%; animation: orbit-spin 12s linear infinite; }
.o2 { width: 28%; height: 28%; animation: orbit-spin 18s linear infinite; }
.o3 { width: 40%; height: 40%; animation: orbit-spin 28s linear infinite; }
.o4 { width: 54%; height: 54%; animation: orbit-spin 40s linear infinite; }
.o5 { width: 70%; height: 70%; animation: orbit-spin 56s linear infinite; }
.o6 { width: 88%; height: 88%; animation: orbit-spin 76s linear infinite; }

.p1 { width: 6px; height: 6px; background: #cbd5e1; color: #cbd5e1; }
.p2 { width: 8px; height: 8px; background: #fbbf24; color: #fbbf24; }
.p3 { width: 9px; height: 9px; background: #38bdf8; color: #38bdf8; }
.p4 { width: 7px; height: 7px; background: #fb7185; color: #fb7185; }
.p5 { width: 14px; height: 14px; background: #fdba74; color: #fdba74; }
.p6 {
  width: 12px;
  height: 12px;
  background: #fde68a;
  color: #fde68a;
  box-shadow:
    0 0 0 3px rgba(253, 230, 138, 0.15),
    0 0 12px #fde68a;
}

@keyframes theme-kenburns {
  0% { transform: scale(1.05) translate3d(0, 0, 0); }
  100% { transform: scale(1.14) translate3d(-2%, 1.5%, 0); }
}

@keyframes aurora-drift {
  0% { transform: translate3d(-3%, 0, 0) skewX(-4deg) scaleY(1); opacity: 0.4; }
  50% { opacity: 0.7; }
  100% { transform: translate3d(4%, 3%, 0) skewX(5deg) scaleY(1.15); opacity: 0.5; }
}

@keyframes aurora-pulse {
  0%, 100% { opacity: 0.2; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.08); }
}

@keyframes stars-twinkle {
  0% { opacity: 0.35; }
  100% { opacity: 0.85; }
}

@keyframes orbit-spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes sun-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); filter: brightness(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); filter: brightness(1.15); }
}

@media (prefers-reduced-motion: reduce) {
  .theme-bg-photo,
  .aurora-band,
  .stars,
  .orbit,
  .sun {
    animation: none !important;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.25s ease, color 0.2s ease;
}

/* App chrome sits above animated scenery */
.app,
.login-body .login-card {
  position: relative;
  z-index: 1;
}

.app {
  min-height: 100vh;
}

/* Let scenery show through chrome a little */
.main,
.content {
  background: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary);
}

/* ---- Login ---- */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, var(--glow), transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 70%, color-mix(in srgb, var(--accent) 25%, transparent), transparent 50%),
    var(--bg);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: min(400px, 100%);
  background: rgba(18, 20, 28, 0.85);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  text-align: center;
}

.login-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  border: 1px solid rgba(139, 124, 255, 0.3);
}

.lock-icon {
  font-size: 28px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* ---- Layout ---- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 18px 12px;
  gap: 8px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  font-size: 20px;
}

.brand strong {
  display: block;
  font-size: 0.95rem;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.account-line {
  color: var(--primary-hover) !important;
  font-weight: 560;
  margin-top: 2px;
}

.accounts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
}

.account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.account-row .meta {
  flex: 1;
  min-width: 120px;
}

.account-row .meta strong {
  display: block;
  font-size: 0.9rem;
}

.account-row .role-pill {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #cfc8ff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-row input[type='password'] {
  width: 120px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.85rem;
}

.sidebar-section {
  padding: 8px 12px;
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 6px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  background: var(--primary-soft);
  color: #fff;
}

.badge {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--muted);
}

.nav-item.active .badge {
  background: rgba(139, 124, 255, 0.28);
  color: #fff;
}

.people-list {
  max-height: calc(100vh - 360px);
  overflow: auto;
  padding-bottom: 8px;
}

.person-block {
  margin-bottom: 4px;
}

.person-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
}

.person-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.person-row.active {
  background: var(--primary-soft);
}

.person-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.person-avatar-sm {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

/* Person DP picker in modal */
.dp-picker {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.dp-preview {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #7c6af7, #1a1c28);
  border: 2px solid var(--border-strong);
  position: relative;
}

.dp-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.dp-preview span {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}

.dp-controls {
  flex: 1;
  min-width: 0;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.dp-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.person-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.person-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.person-row:hover .person-actions,
.person-row:focus-within .person-actions {
  opacity: 1;
}

.cat-list {
  padding: 0 0 4px 20px;
}

.cat-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: left;
}

.cat-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.cat-item.active {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  flex: 1;
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.topbar-title .muted {
  margin: 2px 0 0;
  font-size: 0.85rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-wrap input {
  width: min(240px, 30vw);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  outline: none;
}

.search-wrap input:focus {
  border-color: rgba(139, 124, 255, 0.5);
}

.filters {
  padding: 12px 24px 0;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.chip.active {
  background: var(--primary-soft);
  border-color: rgba(139, 124, 255, 0.4);
  color: #fff;
}

.content {
  padding: 20px 24px 40px;
  flex: 1;
}

/* ---- People dashboard ---- */
.people-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.people-dashboard[hidden] {
  display: none !important;
}

.person-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  min-height: 260px;
  display: flex;
  flex-direction: column;
}

.person-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.person-card-cover {
  position: relative;
  height: 160px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.06), transparent 50%),
    var(--bg-soft);
  overflow: hidden;
  display: grid;
  place-items: center;
}

/* DP shown as a circle — never stretched to the card */
.person-card-cover .dp {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  display: block;
  border: 3px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  background: #111;
}

.person-card-cover .cover-fallback {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.2rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: -0.02em;
  border: 3px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.person-card-body {
  padding: 14px 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.person-card-body h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.person-card-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.person-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 2;
}

.person-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

.person-card-actions .btn {
  flex: 1;
}

.dashboard-add-card {
  border-style: dashed;
  border-width: 1.5px;
  background: transparent;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
}

.dashboard-add-card:hover {
  border-color: var(--primary);
  color: var(--text);
  background: var(--primary-soft);
}

.dashboard-add-card .plus {
  font-size: 2rem;
  line-height: 1;
  color: var(--primary);
}

/* ---- Gallery ---- */
.gallery {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.gallery[hidden] {
  display: none !important;
}

.gallery-section-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.gallery-section-title .count {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.85rem;
}

/* True multi-column grid — images and videos are not mixed in one pile */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #0a0b10;
  border: 1px solid var(--border);
  cursor: pointer;
  aspect-ratio: 1;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

/* Fill the tile as a clean thumbnail (lightbox still uses contain) */
.card img,
.card video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  background: #000;
}

.card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  color: #fff;
}

.card-type {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.75rem;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
}

.card-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 28px 10px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  font-size: 0.8rem;
}

.card-foot strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-foot span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.72rem;
}

.empty {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty h2 {
  margin: 0 0 8px;
  color: var(--text);
}

.empty p {
  margin: 0 0 20px;
}

/* ---- Buttons & forms ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 560;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 28%, transparent);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-block {
  width: 100%;
}

.btn.sm {
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.icon-btn.sm {
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  border-radius: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  text-align: left;
}

.field > span {
  font-size: 0.85rem;
  color: var(--muted);
}

.field em {
  color: var(--danger);
  font-style: normal;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  outline: none;
}

.field input[type="color"] {
  width: 56px;
  height: 40px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(139, 124, 255, 0.55);
}

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.form-ok {
  color: var(--ok);
  font-size: 0.9rem;
  margin: 0 0 10px;
}

.muted {
  color: var(--muted);
}

.sm {
  font-size: 0.85rem;
}

.h3 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.spacer {
  flex: 1;
}

/* ---- Modals ---- */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: calc(100vw - 32px);
  color: var(--text);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-card.sm {
  width: min(420px, 100%);
}

.modal-card.wide {
  width: min(920px, 100%);
  max-height: min(90vh, 900px);
  display: flex;
  flex-direction: column;
}

.modal-card.wide .modal-body {
  overflow: auto;
  flex: 1;
}

/* Fullscreen stitch studio */
#stitch-dialog.modal,
.modal:has(.modal-card.fullscreen) {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none;
  inset: 0;
}

#stitch-dialog.modal::backdrop {
  background: #05060a;
}

.modal-card.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-card.fullscreen .modal-body.stitch-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 18px 8px;
}

.modal-card.fullscreen .stitch-layout {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.modal-card.fullscreen .stitch-pool,
.modal-card.fullscreen .stitch-timeline,
.modal-card.fullscreen .stitch-preview-panel {
  max-height: none;
  min-height: 0;
  height: 100%;
}

.modal-card.fullscreen .stitch-preview-stage {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  margin: 0 10px;
}

.modal-card.fullscreen .stitch-preview-stage img,
.modal-card.fullscreen .stitch-preview-stage video {
  /* Fill the entire preview stage */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center;
  background: #000;
}

.modal-card.fullscreen .stitch-pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  grid-auto-rows: minmax(110px, auto);
  gap: 10px;
  align-content: start;
}

.modal-card.fullscreen .stitch-options {
  flex-shrink: 0;
}

.modal-card.fullscreen .stitch-options .field {
  margin-bottom: 8px;
}

.modal-card.fullscreen .stitch-intro {
  margin: 0;
  flex-shrink: 0;
}

/* ---- Slideshow bar ---- */
.slideshow-bar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(12, 14, 20, 0.82);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  max-width: calc(100vw - 120px);
}

.ss-interval {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.ss-interval select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  color: var(--text);
}

.ss-progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -2px;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.ss-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b7cff, #5ddea8);
  transition: width 0.1s linear;
}

/* ---- Similar clusters ---- */
.checkbox-field {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
}

.checkbox-field input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.checkbox-field span {
  color: var(--text) !important;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.92rem;
}

.similar-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin: 14px 0;
}

.similar-clusters {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(55vh, 520px);
  overflow: auto;
}

.similar-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  padding: 12px;
}

.similar-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.similar-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.similar-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.similar-thumbs img,
.similar-thumbs video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  display: block;
}

/* ---- Gallery toolbar ---- */
.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 24px 0;
}

.gallery-toolbar[hidden] {
  display: none !important;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.toolbar-field select {
  min-width: 130px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  font-size: 0.88rem;
}

/* ---- Stitch studio ---- */
.stitch-intro {
  margin: 0 0 12px;
  line-height: 1.45;
}

.stitch-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  min-height: 280px;
}

.stitch-layout-3 {
  grid-template-columns: 1.1fr 1.2fr 0.95fr;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

.stitch-pool-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stitch-pool-filters select {
  max-width: 120px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}

.stitch-preview-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.stitch-preview-stage {
  flex: 1 1 auto;
  min-height: 200px;
  display: block;
  background: #05060a;
  margin: 0 10px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.stitch-preview-stage img,
.stitch-preview-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #000;
}

/* Native video controls sit on top of full-bleed video */
.stitch-preview-stage video {
  z-index: 1;
}

.stitch-preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  margin: 0;
  z-index: 0;
}

.stitch-preview-meta {
  padding: 10px 12px 12px;
  flex-shrink: 0;
}

.stitch-preview-meta strong {
  display: block;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stitch-preview-meta p {
  margin: 4px 0 0;
}

.stitch-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.stitch-thumb.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(139, 124, 255, 0.35);
}

.stitch-thumb .preview-hint {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 2;
  padding: 4px;
  font-size: 0.65rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
}

.stitch-pool,
.stitch-timeline {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.stitch-pool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stitch-pool-head select {
  max-width: 160px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

/* Multi-column thumbnail grid (not a stacked card list) */
.stitch-pool-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: min-content;
  gap: 10px;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  width: 100%;
  box-sizing: border-box;
}

.stitch-pool-section {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stitch-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a0b10;
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: block;
  flex: none;
}

.stitch-thumb img,
.stitch-thumb video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  background: #000;
}

.stitch-thumb:hover {
  border-color: var(--primary);
}

.stitch-thumb .kind {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  font-size: 0.65rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 1px 5px;
  border-radius: 6px;
}

.stitch-timeline-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow: auto;
  flex: 1;
}

.stitch-timeline-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-bottom: 6px;
}

.stitch-timeline-list li .mini {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
  background: #000;
  flex-shrink: 0;
}

.stitch-timeline-list li .meta {
  flex: 1;
  min-width: 0;
}

.stitch-timeline-list li .meta strong {
  display: block;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stitch-timeline-list .clip-actions {
  display: flex;
  gap: 2px;
}

#stitch-empty-hint {
  padding: 0 12px 12px;
  margin: 0;
}

@media (max-width: 1100px) {
  .stitch-layout-3 {
    grid-template-columns: 1fr 1.1fr 0.9fr;
  }
  .modal-card.fullscreen .stitch-pool-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

@media (max-width: 900px) {
  .stitch-layout-3 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(240px, 1fr) minmax(200px, 0.8fr);
  }
  .stitch-timeline {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .stitch-layout,
  .stitch-layout-3 {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .gallery-toolbar {
    padding: 10px 16px 0;
  }
  .modal-card.fullscreen .stitch-pool-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  padding: 18px;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: var(--bg-soft);
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone p {
  margin: 0 0 4px;
}

.dropzone-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.dropzone-actions .btn {
  pointer-events: auto;
}

.file-summary {
  margin: 12px 0 0;
  text-align: left;
}

.file-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  text-align: left;
  max-height: 160px;
  overflow: auto;
}

.file-list li {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-list li .file-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
}

.file-list li .prompt-preview {
  font-size: 0.75rem;
  color: var(--primary-hover);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-hint {
  margin: 0 0 4px;
  line-height: 1.4;
}

.upload-hint code {
  font-size: 0.8em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.lb-prompt {
  margin: 8px 0 0;
  max-width: min(720px, 70vw);
  font-size: 0.85rem;
  color: #c8c4ff;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-prompt-dot {
  position: absolute;
  bottom: 42px;
  right: 8px;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--primary) 55%, transparent);
  color: #fff;
}

.card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft), 0 12px 28px var(--glow);
}

.card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.35);
  display: none;
  place-items: center;
  color: #fff;
  font-size: 0.75rem;
  pointer-events: none;
}

body.select-mode .card-check {
  display: grid;
}

.card.selected .card-check {
  background: var(--primary);
  border-color: var(--primary);
}

.card-fav {
  position: absolute;
  top: 8px;
  right: 40px;
  z-index: 4;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.card-fav.on {
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
}

.card .card-type {
  right: 8px;
}

/* Bulk action bar */
.bulk-bar {
  position: sticky;
  bottom: 16px;
  z-index: 30;
  margin: 0 24px 16px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.bulk-bar[hidden] {
  display: none !important;
}

.bulk-bar .bulk-count {
  font-weight: 600;
  margin-right: 4px;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin: 8px 0 16px;
}

.theme-swatch {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s;
}

.theme-swatch:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.theme-swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.theme-swatch .swatch-bar {
  height: 28px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, var(--sw-a), var(--sw-b));
}

.theme-swatch strong {
  display: block;
  font-size: 0.85rem;
}

.theme-swatch span {
  font-size: 0.72rem;
  color: var(--muted);
}

.collection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Similar picture group stack in person gallery */
.card.group-card {
  cursor: pointer;
}

.card.group-card .stack-layers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card.group-card .stack-layer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #111;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.card.group-card .stack-layer img,
.card.group-card .stack-layer video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card.group-card .stack-layer:nth-child(1) {
  transform: rotate(-4deg) scale(0.92) translate(-4%, 2%);
  opacity: 0.55;
  z-index: 1;
}

.card.group-card .stack-layer:nth-child(2) {
  transform: rotate(3deg) scale(0.96) translate(3%, -1%);
  opacity: 0.75;
  z-index: 2;
}

.card.group-card .stack-layer:nth-child(3) {
  transform: none;
  opacity: 1;
  z-index: 3;
}

.card.group-card .group-count {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 6;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: #fff;
  box-shadow: 0 4px 12px var(--glow);
}

.card.group-card .group-label {
  position: absolute;
  bottom: 42px;
  left: 8px;
  z-index: 6;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.group-dialog-grid {
  max-height: min(55vh, 480px);
  overflow: auto;
  margin: 12px 0;
}

.group-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#btn-group-similar.active {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  color: var(--text);
}

.progress {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8b7cff, #5ddea8);
  transition: width 0.2s;
}

/* ---- Lightbox ---- */
.lightbox {
  border: none;
  padding: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: rgba(5, 6, 10, 0.94);
  color: var(--text);
}

.lightbox::backdrop {
  background: #000;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
}

.lightbox-nav.prev {
  left: 16px;
}

.lightbox-nav.next {
  right: 16px;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.16);
}

.lightbox-stage {
  height: calc(100vh - 100px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 72px 16px;
  overflow: hidden;
  box-sizing: border-box;
}

/* Full preview: scale to fit window, never stretch */
.lightbox-stage img,
.lightbox-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  background: #000;
}

.lightbox-meta {
  min-height: 88px;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lightbox-meta p {
  margin: 4px 0 0;
}

.lightbox-actions {
  display: flex;
  gap: 8px;
}

.mobile-only {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .mobile-only {
    display: grid;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }

  .topbar {
    padding: 14px 16px;
  }

  .content {
    padding: 16px;
  }

  .search-wrap input {
    width: 120px;
  }

  .lightbox-stage {
    padding: 56px 12px 12px;
  }

  .lightbox-nav {
    display: none;
  }
}
