/* ===== Theme ===== */
:root {
  color-scheme: dark;
  --bg: #0d1017;
  --bg-2: #141924;
  --panel: rgba(24, 30, 43, 0.82);
  --card: #1b2130;
  --card-hover: #232b3d;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #7c8cff;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  /* Theme tokens: --fg-rgb is used for translucent overlays/borders. */
  --fg-rgb: 255 255 255;
  --glow-1: #1b2140;
  --glow-2: #2a1630;
  --placeholder: #2a3142;
  --popover: #1a2030;
  --sticky-bg: rgba(13, 16, 23, 0.86);
  --rail-bg: rgba(16, 20, 30, 0.94);
  --inset-bg: rgba(0, 0, 0, 0.25);
  --role-text: #c4cbe0;
  --gold-text: #e9cf7a;
  --gold-strong: #ffd43b;
  --blue-text: #8cc8ff;
  --ok-text: #8ce99a;
  --bad-text: #ffa8a8;
  --toast-bg: #3a1d24;
  --toast-border: #8a3a48;
}

/* Light theme (toggle in the side menu; see js/theme.js). */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-2: #ffffff;
  --panel: rgba(255, 255, 255, 0.88);
  --card: #ffffff;
  --card-hover: #f1f3f9;
  --border: rgba(20, 28, 45, 0.12);
  --text: #182031;
  --muted: #5d687d;
  --accent: #5463d6;
  --shadow: 0 8px 28px rgba(30, 40, 70, 0.12);
  --fg-rgb: 20 28 45;
  --glow-1: #dde3ff;
  --glow-2: #f6e0ee;
  --placeholder: #dfe4ee;
  --popover: #ffffff;
  --sticky-bg: rgba(244, 246, 251, 0.9);
  --rail-bg: rgba(255, 255, 255, 0.95);
  --inset-bg: rgba(20, 28, 45, 0.06);
  --role-text: #39435a;
  --gold-text: #8a6200;
  --gold-strong: #a87800;
  --blue-text: #1b6cc2;
  --ok-text: #2b8a3e;
  --bad-text: #c92a2a;
  --toast-bg: #fff1f1;
  --toast-border: #e3a0a8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 10% -10%, var(--glow-1) 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 0%, var(--glow-2) 0%, transparent 55%),
              var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

a { color: var(--accent); }
code, kbd {
  background: rgb(var(--fg-rgb) / 0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 12px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ===== Buttons ===== */
button { font-family: inherit; color: inherit; cursor: pointer; }
.icon-btn, .text-btn, .pill-btn, .chip-btn, .primary-btn {
  border: 1px solid var(--border);
  background: rgb(var(--fg-rgb) / 0.04);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.icon-btn { width: 32px; height: 32px; font-size: 16px; line-height: 1; }
.text-btn { height: 32px; padding: 0 12px; }
.pill-btn { height: 32px; padding: 0 14px; border-radius: 999px; }
.chip-btn { padding: 5px 12px; border-radius: 999px; font-size: 13px; }
.primary-btn { height: 34px; padding: 0 18px; background: var(--accent); border-color: transparent; color: #0d1017; font-weight: 600; }
.icon-btn:hover, .text-btn:hover, .pill-btn:hover, .chip-btn:hover { background: rgb(var(--fg-rgb) / 0.1); border-color: rgb(var(--fg-rgb) / 0.18); }
.primary-btn:hover { filter: brightness(1.1); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.4; cursor: default; }

/* ===== Hero / actor pickers ===== */
.hero { max-width: 1400px; margin: 0 auto; padding: 28px 24px 18px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand > div { flex: 1; }
.logo { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 4px 14px rgba(77, 171, 247, 0.25)); }
h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.brand-accent {
  background: linear-gradient(90deg, #ff6b6b, #4dabf7 55%, #51cf66);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin: 2px 0 0; color: var(--muted); }

.actor-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 22px;
}
.slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--c);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
/* backdrop-filter makes each slot its own stacking context, so the slot being
   searched must sit above its siblings for the suggestion list to show. */
.slot:focus-within { z-index: 60; }
.slot input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.slot input::placeholder { color: var(--muted); }
.slot .num {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--c);
  color: #0d1017;
  font-weight: 700;
  font-size: 12px;
}
.slot .remove { width: 26px; height: 26px; font-size: 12px; flex: none; }
.slot { flex-wrap: wrap; }

/* Director slot: gold accent and glow so the "master" is obvious. */
.slot.director {
  background: linear-gradient(90deg, rgba(255, 212, 59, 0.14), rgba(255, 212, 59, 0.03) 70%), var(--panel);
  border-color: rgba(255, 212, 59, 0.35);
  border-left-color: var(--c);
  box-shadow: 0 0 0 1px rgba(255, 212, 59, 0.12), 0 6px 24px rgba(255, 212, 59, 0.08);
}
.slot.director .sub { color: var(--gold-text); }

/* Directed / Acted / Both switch for people who do both. */
.role-toggle {
  flex-basis: 100%;
  display: flex;
  gap: 2px;
  padding: 2px;
  margin-top: 2px;
  background: var(--inset-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.role-toggle button {
  flex: 1;
  height: 24px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.role-toggle button:hover { color: var(--text); background: rgb(var(--fg-rgb) / 0.06); }
.role-toggle button.active { background: var(--c); color: #0d1017; font-weight: 600; }

/* Department badge in search results. */
.dept {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
  background: rgb(var(--fg-rgb) / 0.08);
  color: var(--muted);
}
.dept-actor { background: rgba(77, 171, 247, 0.16); color: var(--blue-text); }
.dept-director { background: rgba(255, 212, 59, 0.18); color: var(--gold-strong); }

.dir-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #ffd43b;
  color: #0d1017;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: 2px;
}
.slot.add {
  justify-content: center;
  border: 1px dashed rgb(var(--fg-rgb) / 0.18);
  border-left-width: 1px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.slot.add:hover { color: var(--text); border-color: rgb(var(--fg-rgb) / 0.35); }

.person { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--placeholder);
  border: 2px solid var(--c, transparent);
  display: grid; place-items: center;
  font-weight: 700; color: var(--muted);
}
.person .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person > div { min-width: 0; }

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  z-index: 50;
  margin: 0; padding: 6px;
  list-style: none;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 380px;
  overflow-y: auto;
}
.suggestions li { padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.suggestions li.active, .suggestions li:hover { background: rgb(var(--fg-rgb) / 0.07); }
.suggestions li.empty { color: var(--muted); cursor: default; }
.suggestions .avatar { width: 36px; height: 36px; }

.examples { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--muted); flex-wrap: wrap; }

/* ===== Sticky bar ===== */
.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--sticky-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.toolbar {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
  justify-content: space-between;
}
.toolbar .group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.zoom-label { width: 44px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 140px; accent-color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }
.toggle:hover { color: var(--text); }

.lane-headers {
  max-width: 1400px;
  margin: 0 auto;
  padding: 6px 24px 8px;
  display: grid;
  gap: 0;
}
.lane-head {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  margin-right: 8px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 22%, transparent), transparent);
  border-left: 3px solid var(--c);
  min-width: 0;
}
.lane-head .avatar { width: 34px; height: 34px; }
.lane-head.director {
  position: relative;
  background: linear-gradient(90deg, rgba(255, 212, 59, 0.3), rgba(255, 212, 59, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 212, 59, 0.25);
}
.dir-badge.corner { position: absolute; top: -7px; right: 10px; margin: 0; }
.lane-head.director .sub { color: var(--gold-text); }
.director-toggle span { color: var(--gold-text); }
.director-chip { border-color: rgba(255, 212, 59, 0.35); color: var(--gold-text); }

/* ===== Timeline ===== */
.timeline-wrap { max-width: 1400px; margin: 0 auto; padding: 0 24px 40px; position: relative; min-height: 50vh; }
.timeline { position: relative; }

.band-shade { position: absolute; left: 0; right: 0; background: rgb(var(--fg-rgb) / 0.022); pointer-events: none; }
.year-line { position: absolute; right: 0; height: 1px; background: rgb(var(--fg-rgb) / 0.045); pointer-events: none; }
.year-line.decade { background: rgb(var(--fg-rgb) / 0.12); }
.year-label {
  position: absolute;
  left: 0;
  width: 60px;
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transform: translateY(-1px);
  pointer-events: none;
}
.year-label.decade { color: var(--text); font-weight: 700; font-size: 13px; }
.year-label.tba { color: var(--accent); font-weight: 700; }

.spine {
  position: absolute;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 3px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--c) 70%, transparent), color-mix(in srgb, var(--c) 25%, transparent));
  pointer-events: none;
}
.dot {
  position: absolute;
  width: 11px; height: 11px;
  margin: -5.5px 0 0 -5.5px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px var(--bg);
  z-index: 3;
  pointer-events: none;
}
.dot.small { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; box-shadow: 0 0 0 2px var(--bg); }
.dot.shared { box-shadow: 0 0 0 3px var(--bg), 0 0 10px var(--c); }

/* Director lane: tinted column, thicker glowing spine, gold-tinted cards. */
.director-col {
  position: absolute;
  top: 0;
  background: linear-gradient(90deg, rgba(255, 212, 59, 0.09), rgba(255, 212, 59, 0.025));
  border-left: 1px solid rgba(255, 212, 59, 0.22);
  border-right: 1px solid rgba(255, 212, 59, 0.1);
  pointer-events: none;
}
.spine.director {
  width: 5px;
  margin-left: -2.5px;
  background: var(--c);
  box-shadow: 0 0 14px rgba(255, 212, 59, 0.45);
}
.dot.director { box-shadow: 0 0 0 3px var(--bg), 0 0 10px var(--c); }
.item.by-director:not(.shared) {
  background: linear-gradient(90deg, rgba(255, 212, 59, 0.1), transparent 65%), var(--card);
}
.lvl-dots .item.by-director:not(.shared) { background: var(--c); }
.role.dir { color: var(--gold-strong); font-weight: 600; }
.bridge {
  position: absolute;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 3px;
  z-index: 1;
  pointer-events: none;
  opacity: 0.9;
}

.item {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--c);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, transform 0.12s, box-shadow 0.12s;
}
.item:hover { background: var(--card-hover); box-shadow: var(--shadow); z-index: 4; }
.item.shared {
  border: 2px solid transparent;
  background: linear-gradient(var(--card), var(--card)) padding-box, var(--grad) border-box;
}
.item.shared:hover { background: linear-gradient(var(--card-hover), var(--card-hover)) padding-box, var(--grad) border-box; }
.item.upcoming { opacity: 0.75; border-style: dashed; }
.item.flash { animation: flash 1.6s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 4px var(--accent), var(--shadow); transform: scale(1.03); }
  100% { box-shadow: none; transform: none; }
}

.item .info { min-width: 0; flex: 1; }
.item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.item .meta .role { color: var(--role-text); }
.item .year { color: var(--muted); font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }
.item .poster { width: 52px; height: 78px; flex: none; border-radius: 5px; object-fit: cover; background: var(--placeholder); }
.item .rating { color: var(--gold-strong); }
.item .faces { display: flex; flex: none; }
.item .faces .avatar { width: 26px; height: 26px; margin-left: -8px; font-size: 10px; }
.item .faces .avatar:first-child { margin-left: 0; }

/* Compact / dots levels */
.lvl-compact .item { padding: 0 8px; gap: 6px; font-size: 12.5px; border-radius: 6px; }
.lvl-compact .item.shared { border-width: 1.5px; }
.lvl-dots .item { padding: 0; border-radius: 999px; border: none; background: color-mix(in srgb, var(--c) 70%, transparent); }
.lvl-dots .item.shared { background: var(--grad); }
.lvl-dots .item:hover { background: var(--c); }
.lvl-dots .item.shared:hover { background: var(--grad); filter: brightness(1.25); }

/* ===== Empty / loading ===== */
.empty-state { text-align: center; padding: 70px 20px; color: var(--muted); max-width: 560px; margin: 0 auto; }
.empty-state h2 { color: var(--text); margin: 18px 0 8px; }
.empty-state .hint { font-size: 13px; }
.empty-art { display: flex; justify-content: center; gap: 22px; height: 90px; }
.empty-art span { width: 4px; border-radius: 4px; background: linear-gradient(var(--c), transparent); position: relative; }
.empty-art span::after { content: ""; position: absolute; top: 30px; left: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c); }

.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 3px solid rgb(var(--fg-rgb) / 0.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Tooltip / toast ===== */
.tooltip {
  position: fixed;
  z-index: 100;
  max-width: 300px;
  padding: 8px 10px;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: 12.5px;
}
.tooltip strong { display: block; font-size: 13.5px; margin-bottom: 4px; }
.tooltip .r { display: flex; gap: 6px; align-items: baseline; }
.tooltip .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 16px;
  background: var(--toast-bg);
  border: 1px solid var(--toast-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

/* ===== Dialogs ===== */
.dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--text);
  padding: 22px;
  box-shadow: var(--shadow);
  max-width: min(720px, 94vw);
}
.dialog::backdrop { background: rgba(5, 7, 12, 0.65); backdrop-filter: blur(3px); }
.dialog .close { position: absolute; top: 12px; right: 12px; }
.dialog h3 { margin: 0 0 12px; }

.movie-dialog { width: 720px; }
.movie { display: flex; gap: 20px; }
.movie img { width: 185px; border-radius: 10px; align-self: flex-start; background: var(--placeholder); }
.movie h2 { margin: 0 32px 4px 0; }
.movie .facts { color: var(--muted); margin-bottom: 12px; }
.movie .overview { line-height: 1.5; }
.movie .roles { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; }
.movie .roles li { display: flex; align-items: center; gap: 10px; }
.movie .roles .avatar { width: 32px; height: 32px; }

.shared-dialog { width: 560px; }
.shared-list { list-style: none; margin: 0; padding: 0; max-height: 65vh; overflow-y: auto; }
.shared-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.shared-list li:hover { background: rgb(var(--fg-rgb) / 0.06); }
.shared-list .y { color: var(--muted); width: 42px; font-variant-numeric: tabular-nums; }
.shared-list .t { flex: 1; font-weight: 600; }
.shared-list .faces { display: flex; }
.shared-list .faces .avatar { width: 26px; height: 26px; margin-left: -8px; font-size: 10px; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }
.footer p { margin: 6px 0 0; }
.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:active { transform: none; }

/* ===== About ===== */
.about-dialog { width: 520px; line-height: 1.55; }
.about-dialog h3 { font-size: 20px; margin-right: 36px; }
.about-dialog p { margin: 0 0 12px; }
.about-author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 12px 14px;
  background: rgb(var(--fg-rgb) / 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.about-author strong { font-size: 15px; }
.about-avatar {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff6b6b, #4dabf7 55%, #51cf66);
  color: #0d1017;
  font-weight: 800;
  font-size: 20px;
}
.about-small { font-size: 12px; margin-bottom: 0 !important; }
/* TMDB logo is required attribution; it must stay less prominent than ours. */
.tmdb-logo { display: inline-block; opacity: 0.85; }
.tmdb-logo:hover { opacity: 1; }
.tmdb-logo img { display: block; height: 12px; width: auto; }

@media (max-width: 700px) {
  .hero, .toolbar, .lane-headers, .timeline-wrap { padding-left: 10px; padding-right: 10px; }
  .movie { flex-direction: column; }
  .lane-head .sub { display: none; }
}
/* =====================================================================
   Side menu. Collapsed: a rail of category icons (click → small pop-out
   menu with that category's pages). Expanded (☰): every category with its
   pages, page behind dimmed.
   ===================================================================== */
:root { --rail-w: 64px; --rail-open-w: 280px; }
body { padding-left: var(--rail-w); }

.rail {
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 90;
  width: var(--rail-w);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  overflow: hidden;
  background: var(--rail-bg);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  transition: width 0.22s ease, box-shadow 0.22s ease;
}
body.nav-open .rail { width: var(--rail-open-w); box-shadow: 10px 0 40px rgba(0, 0, 0, 0.35); overflow-y: auto; }

.rail-top { display: flex; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 6px; }
.rail-btn {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgb(var(--fg-rgb) / 0.04);
}
.rail-btn:hover { background: rgb(var(--fg-rgb) / 0.1); }
.rail-brand { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; opacity: 0; transition: opacity 0.15s; }

/* Category: icon button (collapsed) / heading (expanded) + its pages. */
.nav-cat { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border); }
.cat-btn, .rail-action {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 46px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: inherit; text-align: left; white-space: nowrap;
}
.cat-btn svg, .rail-action svg { flex: none; }
.cat-btn:hover, .cat-btn[aria-expanded="true"], .rail-action:hover { background: rgb(var(--fg-rgb) / 0.07); color: var(--text); }
.cat-btn.active {
  background: linear-gradient(90deg, rgba(124, 140, 255, 0.24), rgba(124, 140, 255, 0.06));
  border-color: rgba(124, 140, 255, 0.32);
  color: var(--text);
}
.cat-label { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.rail-action-label { font-size: 14px; font-weight: 600; }
.cat-label, .rail-action-label { opacity: 0; transition: opacity 0.15s; }
.cat-items { display: none; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex; align-items: center;
  min-height: 46px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none; white-space: nowrap;
}
.nav-link:hover { background: rgb(var(--fg-rgb) / 0.06); color: var(--text); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(124, 140, 255, 0.24), rgba(124, 140, 255, 0.06));
  border-color: rgba(124, 140, 255, 0.32);
  color: var(--text);
}
.nav-link:focus-visible, .rail-btn:focus-visible, .cat-btn:focus-visible, .rail-action:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.nav-text { display: flex; flex-direction: column; min-width: 0; }
.nav-label { font-size: 14px; font-weight: 600; }
.nav-desc { font-size: 12px; color: var(--muted); }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border); }
/* Theme toggle shows where it will take you: sun in dark mode, moon in light. */
:root[data-theme="light"] .icon-sun,
:root:not([data-theme="light"]) .icon-moon { display: none; }

/* Expanded: categories become headings, their pages are listed below. */
body.nav-open .rail-brand,
body.nav-open .cat-label,
body.nav-open .rail-action-label { opacity: 1; transition-delay: 0.06s; }
body.nav-open .cat-btn { min-height: 36px; pointer-events: none; background: none; border-color: transparent; color: var(--muted); }
body.nav-open .cat-items { display: flex; padding-left: 26px; animation: fade-in 0.2s ease-out 0.05s both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Collapsed: small pop-out menu for one category (filled by shell.js). */
.nav-flyout {
  position: fixed;
  z-index: 95;
  left: calc(var(--rail-w) + 8px);
  min-width: 250px;
  padding: 6px;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: flyout-in 0.14s ease-out;
}
.nav-flyout-title { padding: 6px 12px 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
@keyframes flyout-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.nav-overlay {
  position: fixed; inset: 0;
  z-index: 85;
  background: rgba(5, 7, 12, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
body.nav-open .nav-overlay { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }

/* =====================================================================
   Cast Call (game)
   ===================================================================== */
.cc-root { max-width: 880px; margin: 0 auto; padding: 32px 24px 24px; }
.cc-hero h1 { font-size: 34px; margin: 0; }
.cc-hero p { margin: 6px 0 22px; color: var(--muted); font-size: 15px; }
.cc-kicker { color: var(--gold-text); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.cc-section { margin: 26px 0 10px; font-size: 13px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

.cc-daily {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  padding: 20px 22px;
  border: 1px solid rgba(255, 212, 59, 0.35);
  border-radius: 14px;
  background: linear-gradient(110deg, rgba(255, 212, 59, 0.14), rgba(255, 212, 59, 0.02) 60%), var(--panel);
}
.cc-daily h2 { margin: 6px 0 2px; font-size: 20px; }
.cc-daily p { margin: 0; }
.cc-play { height: 42px; padding: 0 22px; font-size: 15px; }
.cc-daily-done { text-align: right; }
.cc-daily-done b { font-size: 18px; }
.cc-daily-done small { display: block; color: var(--muted); }
.cc-check { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #51cf66; color: #0d1017; font-weight: 800; }

.cc-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.cc-mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--c);
  border-radius: 12px;
  background: var(--card);
  text-align: left;
  transition: background 0.15s, transform 0.15s;
}
.cc-mode:hover { background: var(--card-hover); transform: translateY(-2px); }
.cc-mode-easy { --c: #51cf66; } .cc-mode-medium { --c: #4dabf7; } .cc-mode-hard { --c: #ff6b6b; }
.cc-mode-name { font-size: 18px; font-weight: 700; }
.cc-mode-blurb { color: var(--muted); font-size: 13px; line-height: 1.4; }
.cc-best { margin-top: 4px; font-size: 12px; color: var(--c); font-weight: 600; }

.cc-how { margin-top: 22px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; background: rgb(var(--fg-rgb) / 0.02); color: var(--muted); }
.cc-how summary { cursor: pointer; color: var(--text); font-weight: 600; }
.cc-how ul { margin: 10px 0 0; padding-left: 20px; line-height: 1.6; }

.cc-loading { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 90px 20px; }

/* In-game */
.cc-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cc-tag { padding: 3px 10px; border-radius: 999px; background: rgba(77, 171, 247, 0.16); color: var(--blue-text); font-size: 12px; font-weight: 600; }
.cc-tag.daily { background: rgba(255, 212, 59, 0.18); color: var(--gold-strong); }
.cc-score { margin-left: auto; color: var(--muted); }
.cc-score b { color: var(--text); font-size: 18px; }
.cc-progress { display: flex; gap: 6px; }
.cc-dot {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgb(var(--fg-rgb) / 0.08);
  font-size: 11px; font-weight: 700; color: #0d1017;
}
.cc-dot.current { box-shadow: inset 0 0 0 2px var(--accent); background: transparent; }
.cc-dot.ok { background: #51cf66; }
.cc-dot.bad { background: #ff6b6b; }
.cc-progress.big { justify-content: center; margin: 14px 0 10px; }
.cc-progress.big .cc-dot { width: 26px; height: 26px; font-size: 13px; }

.cc-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.cc-round { color: var(--muted); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.cc-question { margin: 4px 0 16px; font-size: 22px; }

.cc-clues { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cc-clue {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid #4dabf7;
  border-radius: 12px;
  background: var(--card);
  animation: cc-pop 0.25s ease-out;
}
.cc-clue.director { border-left-color: var(--gold-strong); background: linear-gradient(90deg, rgba(255, 212, 59, 0.1), transparent 70%), var(--card); }
.cc-clue.locked { border-style: dashed; border-left-width: 1px; background: transparent; color: var(--muted); animation: none; }
.cc-clue.extra { opacity: 0.7; }
.cc-role { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.cc-clue.director .cc-role { color: var(--gold-strong); }
.cc-name { font-size: 18px; font-weight: 700; }
.cc-clue.locked .cc-name { font-weight: 500; font-size: 15px; }
.cc-character { font-size: 12px; color: var(--muted); }
@keyframes cc-pop { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

.cc-message { margin-top: 12px; color: var(--bad-text); }
.cc-reveal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 18px; }
.cc-worth { color: var(--muted); }
.cc-worth b { color: var(--gold-strong); font-size: 17px; }

.cc-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cc-choice {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgb(var(--fg-rgb) / 0.04);
  text-align: left; font-size: 15px;
  transition: background 0.12s, border-color 0.12s;
}
.cc-choice:hover:not(:disabled) { background: rgba(124, 140, 255, 0.14); border-color: rgba(124, 140, 255, 0.4); }
.cc-choice:disabled { cursor: default; opacity: 0.55; }
.cc-choice.right { opacity: 1; background: rgba(81, 207, 102, 0.16); border-color: #51cf66; }
.cc-choice.wrong { opacity: 1; background: rgba(255, 107, 107, 0.14); border-color: #ff6b6b; }
.cc-key { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 6px; background: rgb(var(--fg-rgb) / 0.08); color: var(--muted); font-size: 12px; font-weight: 700; }
.cc-choice-title { flex: 1; font-weight: 600; }
.cc-year { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.cc-typing { display: flex; gap: 10px; align-items: flex-start; }
.cc-input-wrap { position: relative; flex: 1; }
.cc-input-wrap input {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid rgba(124, 140, 255, 0.4);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit; font-size: 16px;
  outline: none;
}
.cc-input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.2); }
.cc-typing .text-btn { height: 46px; }
.cc-thumb { width: 32px; height: 48px; flex: none; border-radius: 4px; object-fit: cover; background: var(--placeholder); }

.cc-feedback {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 18px; padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgb(var(--fg-rgb) / 0.03);
  animation: cc-pop 0.25s ease-out;
}
.cc-feedback.ok { border-color: rgba(81, 207, 102, 0.5); }
.cc-feedback.bad { border-color: rgba(255, 107, 107, 0.45); }
.cc-feedback img, .cc-noposter { width: 70px; height: 105px; border-radius: 8px; object-fit: cover; background: var(--placeholder); flex: none; }
.cc-feedback-text { flex: 1; min-width: 180px; display: grid; gap: 4px; }
.cc-verdict { font-weight: 700; font-size: 17px; }
.cc-feedback.ok .cc-verdict { color: var(--ok-text); }
.cc-feedback.bad .cc-verdict { color: var(--bad-text); }
.cc-answer { font-size: 19px; font-weight: 700; }
.cc-next { height: 42px; padding: 0 20px; }

/* Summary */
.cc-summary { text-align: center; padding: 28px 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); }
.cc-final { margin-top: 6px; font-size: 20px; color: var(--muted); }
.cc-final b {
  font-size: 64px; line-height: 1;
  background: linear-gradient(90deg, #ff6b6b, #4dabf7 55%, #51cf66);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cc-rating { font-size: 20px; font-weight: 700; margin-top: 4px; }
.cc-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.cc-actions .primary-btn { height: 40px; }
.cc-recap { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cc-recap li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-left: 4px solid #51cf66; border-radius: 10px; background: var(--card); }
.cc-recap li.bad { border-left-color: #ff6b6b; }
.cc-recap img, .cc-recap .cc-noposter { width: 40px; height: 60px; border-radius: 5px; }
.cc-recap-n { width: 18px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.cc-recap-text { flex: 1; min-width: 0; font-size: 13px; }
.cc-recap-title { font-size: 15px; font-weight: 600; }
.cc-recap-pts { font-weight: 800; font-size: 16px; color: var(--ok-text); }
.cc-recap li.bad .cc-recap-pts { color: var(--bad-text); }

/* =====================================================================
   Small screens: the rail shrinks to a floating ☰ button
   ===================================================================== */
@media (max-width: 700px) {
  body { padding-left: 0; }
  .rail { bottom: auto; height: 64px; background: transparent; border-right: none; backdrop-filter: none; }
  .rail .nav-cat, .rail .rail-bottom { display: none; }
  body.nav-open .rail { bottom: 0; height: auto; width: min(var(--rail-open-w), 86vw); background: var(--rail-bg); border-right: 1px solid var(--border); }
  body.nav-open .rail .nav-cat, body.nav-open .rail .rail-bottom { display: flex; }
  .rail-btn { background: var(--rail-bg); }
  .hero .brand { padding-left: 52px; }
  .sticky-bar .toolbar { padding-left: 64px; }
  .cc-root { padding: 70px 12px 20px; }
  .cc-clues, .cc-choices { grid-template-columns: 1fr; }
  .cc-score { margin-left: 0; }
}
