/* =========================================================
   Behind the Feed — styles
   Themes: VidSpark (light, red) and WaveRoom (dark, green/purple)
   ========================================================= */

:root {
  --font: Roboto, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  --top-h: 56px;
  --side-w: 240px;
  --np-h: 0px;
  --radius: 12px;

  /* VidSpark (default) */
  --bg: #ffffff;
  --page-bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --surface-3: #e5e5e5;
  --text: #0f0f0f;
  --muted: #606060;
  --border: #e5e5e5;
  --accent: #ff1f3d;
  --accent-ink: #ffffff;
  --accent-soft: #ffe8eb;
  --accent-2: #065fd4;
  --good: #188038;
  --good-soft: #e6f4ea;
  --bad: #d93025;
  --bad-soft: #fce8e6;
  --warn: #c26401;
  --warn-soft: #fef3e0;
  --lit: #fff4c2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 18px rgba(0, 0, 0, .07);
  --topbar-bg: rgba(255, 255, 255, .96);

  /* Spot–Think–Notice–Choose routine colors */
  --r-spot: #1a63d6;
  --r-think: #6b3cff;
  --r-notice: #b25c00;
  --r-choose: #188038;
}

body[data-theme="waveroom"] {
  --bg: #0d0a14;
  --page-bg:
    radial-gradient(1100px 520px at 15% -10%, rgba(160, 107, 255, .28), transparent 70%),
    radial-gradient(900px 420px at 105% 0%, rgba(31, 223, 135, .16), transparent 70%),
    #0d0a14;
  --surface: #17121f;
  --surface-2: #221a2f;
  --surface-3: #2f2542;
  --text: #f4f1fb;
  --muted: #aaa1c2;
  --border: #2b2339;
  --accent: #1fdf87;
  --accent-ink: #052012;
  --accent-soft: rgba(31, 223, 135, .14);
  --accent-2: #a06bff;
  --good: #3ddc84;
  --good-soft: rgba(61, 220, 132, .15);
  --bad: #ff7272;
  --bad-soft: rgba(255, 114, 114, .15);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, .15);
  --lit: rgba(160, 107, 255, .28);
  --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  --topbar-bg: rgba(13, 10, 20, .88);
  --r-spot: #6ea8ff;
  --r-think: #b99bff;
  --r-notice: #ffb547;
  --r-choose: #3ddc84;
}
body.has-np { --np-h: 72px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--page-bg);
  background-attachment: fixed;
  padding-bottom: var(--np-h);
  transition: background-color .3s, color .3s;
}
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.accent { color: var(--accent); }
.noscript { padding: 40px; text-align: center; }

:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px;
  padding: 10px 18px; font-weight: 600; font-size: 15px;
  cursor: pointer; transition: transform .12s, background-color .2s, opacity .2s, box-shadow .2s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn.big { padding: 14px 28px; font-size: 17px; }
.btn.block { width: 100%; }
.btn:disabled { cursor: not-allowed; opacity: .5; box-shadow: none; }
.btn.locked { background: var(--surface-3); color: var(--muted); opacity: 1; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
}
.top-left { display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.logo-mark { height: 26px; width: auto; display: block; }
.wordmark { font-weight: 800; font-size: 20px; letter-spacing: -.6px; }
.wordmark b { color: var(--accent); }
body[data-theme="waveroom"] .wordmark b { color: var(--accent); }
.wordmark.game b { color: #5b3cff; }

.search {
  justify-self: center; width: 100%; max-width: 560px;
  display: flex; align-items: stretch; height: 40px;
}
.search input {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-right: 0;
  border-radius: 999px 0 0 999px;
  padding: 0 16px; font: inherit; font-size: 15px;
  background: var(--surface); color: var(--text);
  cursor: default;
}
.search input:focus { outline: none; }
.search-btn {
  width: 64px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 0 999px 999px 0;
  background: var(--surface-2); color: var(--text);
}
.search-btn svg { width: 20px; height: 20px; }
body[data-theme="waveroom"] .search input { border-radius: 999px; border-right: 1px solid var(--border); background: var(--surface-2); padding-left: 44px; }
body[data-theme="waveroom"] .search { position: relative; }
body[data-theme="waveroom"] .search-btn { position: absolute; left: 4px; top: 0; bottom: 0; width: 36px; border: 0; background: transparent; color: var(--muted); }

.top-right { display: flex; align-items: center; gap: 10px; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.who:empty { display: none; }
.who .av { width: 32px; height: 32px; }
.topprogress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--surface-2); }
.topprogress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .6s ease; }

/* ---------- Layout & sidebar ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--top-h);
  width: var(--side-w); flex: 0 0 var(--side-w);
  height: calc(100vh - var(--top-h) - var(--np-h));
  overflow-y: auto; padding: 12px;
  background: transparent;
  transition: width .2s, flex-basis .2s;
}
.side-head { font-size: 13px; font-weight: 700; color: var(--muted); padding: 14px 12px 6px; text-transform: uppercase; letter-spacing: .5px; }
.side-divider { height: 1px; background: var(--border); margin: 10px 4px; }
.side-item {
  width: 100%; display: flex; align-items: center; gap: 14px;
  border: 0; background: transparent; text-align: left;
  padding: 8px 12px; border-radius: 10px; cursor: pointer; min-height: 44px;
}
.side-item:hover:not(.locked) { background: var(--surface-2); }
.side-item.active { background: var(--surface-2); font-weight: 700; }
body[data-theme="waveroom"] .side-item.active { background: var(--surface-3); }
.side-item.locked { cursor: not-allowed; opacity: .55; }
.side-icon { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; font-size: 20px; font-family: var(--emoji); }
.side-icon .av { width: 28px; height: 28px; }
.side-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-label { font-size: 14px; }
.side-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.side-status { font-size: 13px; display: flex; gap: 3px; align-items: center; color: var(--good); font-weight: 700; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.dot.on { background: var(--accent); }
.side-foot { padding: 12px; font-size: 12px; color: var(--muted); }

body.side-mini { --side-w: 76px; }
body.side-mini .sidebar { padding: 8px 4px; }
body.side-mini .side-item { flex-direction: column; gap: 4px; padding: 10px 2px; text-align: center; }
body.side-mini .side-sub, body.side-mini .side-status, body.side-mini .side-head, body.side-mini .side-foot { display: none; }
body.side-mini .side-label { font-size: 10px; }

.scrim { display: none; }

main {
  flex: 1; min-width: 0;
  padding: 20px 24px 0;
  outline: none;
}
.page { max-width: 1240px; margin: 0 auto; padding-bottom: 28px; }

/* ---------- Bottom nav bar ---------- */
.navbar {
  position: sticky; bottom: var(--np-h); z-index: 10;
  max-width: 1240px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0 16px;
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}
body[data-theme="waveroom"] .navbar { background: linear-gradient(to bottom, transparent, #0d0a14 30%); }
.nav-hint { flex: 1; text-align: right; font-size: 14px; color: var(--muted); }
.nav-hint.nudge { animation: nudge .5s; color: var(--bad); }

/* ---------- Cards & shared bits ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.pill.done { background: var(--good-soft); color: var(--good); }
.section-title { font-size: 20px; font-weight: 700; margin: 4px 0 4px; }
.av { display: block; flex: 0 0 auto; }

/* ---------- Case header & stepper ---------- */
.case-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.case-title { display: flex; align-items: center; gap: 12px; }
.case-title .av { width: 48px; height: 48px; }
.case-kicker { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.case-title h1 { font-size: 24px; }
.app-tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; vertical-align: middle; }
body[data-theme="vidspark"] .app-tag { color: #c4001d; }

.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0; flex-wrap: wrap; }
.stepper li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 14px; font-weight: 600;
}
.stepper .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 13px; color: var(--text); }
.stepper li.current { background: var(--text); color: var(--bg); }
.stepper li.current .num { background: var(--accent); color: var(--accent-ink); }
body[data-theme="waveroom"] .stepper li.current { background: var(--accent); color: var(--accent-ink); }
body[data-theme="waveroom"] .stepper li.current .num { background: var(--accent-ink); color: var(--accent); }
.stepper li.done .num { background: var(--good); color: #fff; }

/* ---------- Spot–Think–Notice–Choose routine ---------- */
.r-bg { --r: var(--r-spot); }
.r-ai { --r: var(--r-think); }
.r-story { --r: var(--r-notice); }
.r-choose { --r: var(--r-choose); }
.routine-prompt {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  margin: -4px 0 18px; padding: 12px 16px; border-radius: 12px;
  background: color-mix(in srgb, var(--r) 10%, var(--surface)); border-left: 6px solid var(--r);
  font-size: 16px; font-weight: 600;
}
.rp-word { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; color: var(--r); }
.rp-word .e, .rtile .e { font-family: var(--emoji); }
.routine { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; counter-reset: r; }
.rtile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--r) 9%, var(--surface)); border-top: 5px solid var(--r);
}
.rtile .e { font-size: 28px; line-height: 1.1; }
.rtile b { font-size: 20px; color: var(--r); }
.rtile b::before { counter-increment: r; content: counter(r) ". "; }
.routine-remind { margin-bottom: 22px; }
.routine-remind h2 { font-size: 22px; }
.choose-grid { display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: 18px; align-items: start; }
.choose-grid .quiz { margin-top: 0; }
.routine-card h3 { font-size: 18px; margin-bottom: 12px; }

/* ---------- Intro ---------- */
.hero { text-align: center; padding: 28px 12px 12px; }
.hero .logo-big { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.hero .logo-big .logo-mark { height: 46px; }
.hero .logo-big .wordmark { font-size: 36px; }
.kicker { display: inline-block; font-size: 13px; font-weight: 800; letter-spacing: 2px; color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; margin-bottom: 14px; }
.hero h1 { font-size: clamp(28px, 4vw, 44px); font-weight: 800; letter-spacing: -1px; max-width: 820px; margin: 0 auto 12px; }
.hl { background: linear-gradient(transparent 60%, #ffd84d 60%); padding: 0 4px; }
.hero .lede { font-size: 18px; color: var(--muted); max-width: 600px; margin: 0 auto; }

.sees { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 26px 0; }
.sees-col h3 { font-size: 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.sees-col .big-e { font-size: 28px; font-family: var(--emoji); }
.sees-col.can { border-top: 5px solid var(--accent); }
.sees-col.cant { border-top: 5px solid var(--muted); background: var(--surface-2); }
.tagcloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; font-size: 14px;
}
.sees-col.cant .tag { background: var(--surface); border: 1px dashed var(--muted); color: var(--muted); }
.tag .e { font-family: var(--emoji); font-size: 18px; }

.mission h2 { font-size: 22px; margin-bottom: 14px; }
.mission-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.mstep { display: flex; gap: 12px; align-items: flex-start; }
.mstep .e { font-size: 30px; font-family: var(--emoji); line-height: 1; }
.mstep b { display: block; margin-bottom: 2px; }
.people { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 16px 8px 8px; border-radius: 999px; background: var(--surface-2); }
.person .av { width: 40px; height: 40px; }
.person b { display: block; }

/* ---------- Background phase ---------- */
.bg-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 18px; align-items: start; }
.profile-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.av-lg { width: 84px; height: 84px; }
.profile h2 { font-size: 26px; }
.profile p { margin-bottom: 12px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.fact { font-size: 13px; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); }
.ai-blind { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; padding: 12px; border-radius: 10px; background: var(--warn-soft); color: var(--text); }
.ai-blind .e { font-size: 22px; font-family: var(--emoji); line-height: 1; }

.log-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.log-head h3 { font-size: 19px; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 14px; }

.sig { border: 0; padding: 0; background: none; cursor: pointer; perspective: 800px; text-align: left; }
.sig-inner { display: grid; transition: transform .55s cubic-bezier(.3, 1.4, .5, 1); transform-style: preserve-3d; }
.sig.revealed .sig-inner { transform: rotateY(180deg); }
.sig-front, .sig-back {
  grid-area: 1 / 1;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 12px; padding: 12px 14px; min-height: 68px;
  display: flex; align-items: center; gap: 12px;
}
.sig-front {
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface-3) 10px 20px);
  border: 2px dashed var(--muted); color: var(--muted); font-weight: 700;
}
.sig:hover .sig-front { border-color: var(--accent); color: var(--accent); }
.sig-front .q { width: 32px; height: 32px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 18px; }
.sig-back {
  transform: rotateY(180deg);
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 18%, transparent);
}
.sig-icon { font-size: 26px; font-family: var(--emoji); line-height: 1; width: 34px; text-align: center; }
.sig-text { font-size: 14px; }
.sig-text b { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.sig.revealed { cursor: default; }

/* ---------- Quiz / checks ---------- */
.quiz { margin-top: 18px; background: var(--surface); border: 2px solid var(--border); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); }
.quiz-q { font-size: 18px; font-weight: 600; margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.quiz-badge { font-size: 12px; font-weight: 800; letter-spacing: .5px; padding: 4px 10px; border-radius: 999px; background: var(--accent-2); color: #fff; text-transform: uppercase; }
.quiz-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.opt {
  border: 2px solid var(--border); background: var(--surface-2);
  border-radius: 12px; padding: 12px 14px; text-align: left; font-size: 15px; cursor: pointer;
  transition: border-color .15s, background-color .15s, transform .1s;
}
.opt:hover:not(:disabled) { border-color: var(--accent-2); }
.opt.correct { border-color: var(--good); background: var(--good-soft); font-weight: 600; }
.opt.correct::before { content: "✓ "; color: var(--good); font-weight: 800; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .4s; }
.opt:disabled { cursor: default; }
.opt:disabled:not(.correct) { opacity: .55; }
.quiz-fb { min-height: 0; margin-top: 0; font-size: 15px; border-radius: 10px; }
.quiz-fb.good, .quiz-fb.bad { margin-top: 12px; padding: 10px 14px; }
.quiz-fb.good { background: var(--good-soft); }
.quiz-fb.bad { background: var(--bad-soft); }
.quiz.done { border-color: var(--good); }
.gate-locked {
  margin-top: 18px; padding: 18px; border-radius: 16px; text-align: center;
  border: 2px dashed var(--border); color: var(--muted); font-weight: 600;
}

/* ---------- Engine (You Are the AI) ---------- */
.engine { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.engine-panel { padding: 16px; }
@media (min-height: 940px) and (min-width: 900px) {
  .engine-panel { position: sticky; top: calc(var(--top-h) + 16px); }
}
.ep-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.bot { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 26px; font-family: var(--emoji); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.ep-title { font-weight: 800; font-size: 16px; }
.ep-guess { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 2px; }
.ep-label { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.ep-signals { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ep-signals li {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.3;
  padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; transition: background-color .25s, border-color .25s;
}
.ep-signals li > span:first-child { font-family: var(--emoji); font-size: 16px; line-height: 1.1; }
.ep-signals b { font-weight: 600; }
.ep-signals li.lit { background: var(--lit); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.ep-signals li.lit-neg { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.ep-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.slot { height: 34px; border-radius: 8px; border: 2px dashed var(--border); display: grid; place-items: center; font-weight: 800; color: var(--muted); font-size: 13px; overflow: hidden; }
.slot.full { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-family: var(--emoji); font-size: 18px; }
.ep-avg { font-size: 13px; color: var(--muted); margin-bottom: 10px; min-height: 18px; }
.ep-avg b { color: var(--text); }
.engine-end { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 22px; }
.ep-avg.nudge { animation: nudge .5s; color: var(--bad); }

.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px 14px; margin-top: 12px; }
.vgrid.feed { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.vcard {
  display: flex; flex-direction: column; gap: 8px;
  border: 2px solid transparent; border-radius: 14px; padding: 6px; margin: -6px;
  background: transparent; text-align: left; cursor: pointer; position: relative;
  transition: border-color .15s, background-color .15s, opacity .2s, transform .15s;
}
div.vcard { cursor: default; }
button.vcard:hover { background: var(--surface-2); }
.vcard.picked { border-color: var(--accent); background: var(--accent-soft); }
.vcard.dim { opacity: .5; }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb svg { width: 100%; height: 100%; display: block; }
.dur { position: absolute; right: 6px; bottom: 6px; font-size: 12px; font-weight: 600; background: rgba(0, 0, 0, .78); color: #fff; padding: 1px 5px; border-radius: 4px; }
.pick-badge {
  position: absolute; left: 6px; top: 6px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; display: grid; place-items: center;
  transform: scale(0); transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.vcard.picked .pick-badge { transform: scale(1); }
.vmeta { display: flex; gap: 10px; align-items: flex-start; }
.chan-av { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.vtext { display: flex; flex-direction: column; min-width: 0; }
.vtitle { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vsub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* "Why" tag: shown on the built feed only */
.whybox { display: flex; flex-direction: column; font-size: 12px; animation: pop .3s ease; }
.why { align-self: flex-start; font-weight: 600; padding: 3px 8px; border-radius: 6px; line-height: 1.3; }
.why.match { background: var(--good-soft); color: var(--good); }
.why.weak { background: var(--warn-soft); color: var(--warn); }
.why.none { background: var(--surface-2); color: var(--muted); }
.why.against { background: var(--bad-soft); color: var(--bad); }

/* Song rows (WaveRoom) */
.songlist { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.srow {
  display: grid; grid-template-columns: 28px 52px minmax(0, 1fr) 60px 36px;
  align-items: center; gap: 12px;
  width: 100%; padding: 8px 10px; border-radius: 10px; border: 2px solid transparent;
  background: transparent; text-align: left; cursor: pointer;
  transition: background-color .15s, border-color .15s, opacity .2s;
}
div.srow { cursor: default; grid-template-columns: 28px 52px minmax(0, 1fr) minmax(170px, 260px) 60px; }
button.srow:hover { background: var(--surface-2); }
.srow.picked { background: var(--accent-soft); border-color: var(--accent); }
.srow.dim { opacity: .45; }
.snum { color: var(--muted); text-align: center; font-weight: 600; }
.srow.picked .snum { color: var(--accent); font-weight: 800; }
.art { width: 52px; height: 52px; border-radius: 6px; overflow: hidden; display: block; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.art svg { width: 100%; height: 100%; display: block; }
.sinfo { display: flex; flex-direction: column; min-width: 0; }
.stitle { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow.picked .stitle { color: var(--accent); }
.sartist { font-size: 13px; color: var(--muted); }
.sdur { color: var(--muted); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.sadd { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.sadd::before { content: "+"; font-size: 18px; line-height: 1; }
.srow.picked .sadd { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.srow.picked .sadd::before { content: "✓"; font-size: 15px; }

/* Feed view */
.feed-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.feed-head h2 { font-size: 22px; }
.feed-head .pill { background: var(--accent-soft); color: var(--accent); }
.feed-foot { display: flex; align-items: center; gap: 20px; margin-top: 26px; flex-wrap: wrap; }
.feed-foot h3 { font-size: 20px; margin-bottom: 4px; }
.feed-foot p { margin-bottom: 10px; }
.feed-bot { width: 84px; height: 84px; flex: 0 0 84px; border-radius: 22px; display: grid; place-items: center; font-size: 48px; font-family: var(--emoji); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.feed-foot > div { flex: 1 1 260px; }
.mix-head { display: flex; gap: 20px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; }
.mix-cover { width: 150px; height: 150px; display: grid; grid-template-columns: 1fr 1fr; border-radius: 10px; overflow: hidden; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.mix-cover svg { width: 100%; height: 100%; display: block; }
.mix-head h2 { font-size: clamp(24px, 3.4vw, 40px); font-weight: 800; letter-spacing: -1px; margin: 4px 0 6px; }
.overline { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* ---------- Story phase ---------- */
.tease { text-align: center; padding: 40px 24px; }
.tease-emoji { font-size: 64px; font-family: var(--emoji); animation: bob 2s ease-in-out infinite; }
.tease h2 { font-size: 26px; margin: 12px 0 8px; }
.tease p { max-width: 560px; margin: 0 auto 22px; }

.story { display: flex; flex-direction: column; gap: 18px; }
.twist { text-align: center; position: relative; overflow: hidden; border: 2px solid var(--accent); }
.twist::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px 200px at 50% 0, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.twist > * { position: relative; }
.twist-label { display: inline-block; font-weight: 900; letter-spacing: 3px; font-size: 13px; color: var(--accent-ink); background: var(--accent); padding: 5px 14px; border-radius: 6px; transform: rotate(-2deg); }
.scene { display: flex; justify-content: center; gap: 22px; margin: 18px 0 10px; flex-wrap: wrap; }
.scene-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.scene-e { font-size: 58px; font-family: var(--emoji); line-height: 1.1; }
.scene-l { font-size: 13px; font-weight: 700; color: var(--muted); }
.twist h2 { font-size: 26px; margin-bottom: 6px; }
.twist p { font-size: 17px; max-width: 640px; margin: 0 auto; }

.explain-head, .explain-row { display: grid; grid-template-columns: 1fr 28px 1fr; gap: 10px; align-items: center; }
.explain-head { font-weight: 800; font-size: 14px; margin-bottom: 8px; }
.explain-head span:last-child { grid-column: 3; }
.explain-row { padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.ex-saw { color: var(--muted); }
.ex-saw b { color: var(--text); font-weight: 600; }
.ex-arrow { text-align: center; font-weight: 800; color: var(--accent); font-size: 18px; }
.ex-real { font-weight: 600; background: var(--warn-soft); padding: 6px 10px; border-radius: 8px; }

.flip-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 10px; }
.flip { perspective: 1000px; }
.flip-inner { display: grid; transform-style: preserve-3d; transform: rotateY(180deg); }
.flip-face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow);
}
.flip-face.back { transform: rotateY(180deg); border-color: var(--good); }
.face-label { font-size: 12px; font-weight: 800; color: var(--muted); }
.face-label.good { color: var(--good); }
.fthumb { display: block; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; }
.flip.square .fthumb { aspect-ratio: 1; }
.fthumb svg { width: 100%; height: 100%; display: block; }
.ftitle { font-weight: 700; font-size: 14px; line-height: 1.3; }
.fmeta { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.fmeta.hit { color: var(--good); }

.pnf { position: relative; overflow: hidden; }
.pnf-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pnf-head h3 { font-size: 20px; }
.stamp {
  font-weight: 900; letter-spacing: 2px; font-size: 18px; color: var(--bad);
  border: 4px solid var(--bad); border-radius: 10px; padding: 4px 12px;
  transform: rotate(-6deg); text-transform: uppercase; white-space: nowrap;
  mix-blend-mode: normal;
}
.pnf-compare { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: stretch; }
.pnf-box { padding: 12px 14px; border-radius: 12px; font-size: 16px; }
.pnf-box .lbl { display: block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 4px; }
.pnf-box.pred { background: var(--surface-2); }
.pnf-box.fact { background: var(--warn-soft); }
.pnf-neq { align-self: center; font-size: 40px; font-weight: 900; color: var(--bad); line-height: 1; }
.pnf-note { margin-top: 6px; font-size: 15px; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); }

/* Story entry animations (first reveal only) */
.story.animate > * { animation: rise .55s ease both; }
.story.animate > :nth-child(2) { animation-delay: .35s; }
.story.animate > :nth-child(3) { animation-delay: .7s; }
.story.animate > :nth-child(4) { animation-delay: 1.1s; }
.story.animate > :nth-child(5) { animation-delay: 1.4s; }
.story.animate .scene-item { animation: popin .5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d); }
.story.animate .flip-inner { animation: flip .8s ease both; animation-delay: var(--d); }
.story.animate .pnf-neq { animation: popin .5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: .9s; }
.story.animate .stamp { animation: stamp .45s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: 1.3s; }
/* Hold these until the student scrolls them into view */
.story.animate .wait:not(.inview) .flip-inner,
.story.animate .wait:not(.inview) .pnf-neq,
.story.animate .wait:not(.inview) .stamp { animation-play-state: paused; }

/* ---------- Finale ---------- */
.finale-hero { text-align: center; padding: 20px 12px 6px; }
.finale-hero .e { font-size: 60px; font-family: var(--emoji); }
.finale-hero h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; letter-spacing: -1px; margin: 6px 0; }
.recap-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 22px 0; }
.recap .rc-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.recap .av { width: 46px; height: 46px; }
.recap h3 { font-size: 18px; }
.rc-line { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; }
.rc-line .lbl { display: block; font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.rc-line[class*="r-"] { background: color-mix(in srgb, var(--r) 9%, var(--surface)); border-left: 4px solid var(--r); }
.rc-line[class*="r-"] .lbl { color: var(--r); }

.takeaways { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px; }
.takeaway {
  display: flex; align-items: center; gap: 16px; padding: 22px; border-radius: 18px;
  color: #fff; font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; letter-spacing: -.4px; line-height: 1.2;
}
.takeaway .e { font-size: 44px; font-family: var(--emoji); }
.takeaway.t1 { background: linear-gradient(135deg, #ff1f3d, #ff7a45); }
.takeaway.t2 { background: linear-gradient(135deg, #5b3cff, #a06bff); }
.exit h2, .discuss h2 { font-size: 22px; margin-bottom: 4px; }
.complete {
  margin: 18px 0; padding: 18px 20px; border-radius: 16px; text-align: center;
  background: var(--good-soft); border: 2px solid var(--good); font-size: 18px; font-weight: 700;
  animation: popin .5s cubic-bezier(.3, 1.6, .5, 1);
}
.complete .e { font-size: 36px; font-family: var(--emoji); display: block; }
.discuss { margin-top: 22px; border-left: 6px solid var(--accent-2); }
.discuss ol { margin: 10px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 16px; }
.teacher-tag { font-size: 12px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--accent-2); }
.end-actions { display: flex; justify-content: center; margin: 24px 0 8px; }

/* ---------- Now playing (WaveRoom) ---------- */
.nowplaying {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: 72px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
  padding: 0 18px; background: #07050b; border-top: 1px solid var(--border); color: var(--text);
}
.np-song { display: flex; align-items: center; gap: 12px; min-width: 0; }
.np-song .art { width: 48px; height: 48px; flex: 0 0 48px; }
.np-text { min-width: 0; }
.np-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 12px; color: var(--muted); }
.np-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; width: min(420px, 40vw); }
.np-controls { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 16px; }
.np-play { width: 34px; height: 34px; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; font-size: 13px; }
.np-track { width: 100%; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.np-track i { display: block; height: 100%; background: var(--accent); animation: track 30s linear infinite; }
.np-right { justify-self: end; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.eq { display: flex; align-items: flex-end; gap: 2px; height: 16px; }
.eq span { width: 3px; background: var(--accent); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq span:nth-child(2) { animation-delay: .2s; }
.eq span:nth-child(3) { animation-delay: .4s; }
.eq span:nth-child(4) { animation-delay: .1s; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; }
.modal-card { background: var(--surface); color: var(--text); border-radius: 18px; padding: 24px; width: min(380px, 100%); text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: popin .3s ease; }
.modal-emoji { font-size: 34px; width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.modal-card h2 { margin-bottom: 6px; }
.modal-card p { color: var(--muted); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- Animations ---------- */
@keyframes grow { from { width: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
@keyframes popin { from { opacity: 0; transform: scale(.6); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes flip { from { transform: rotateY(0deg); } to { transform: rotateY(180deg); } }
@keyframes stamp { from { opacity: 0; transform: rotate(-6deg) scale(2.2); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes nudge { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 70% { transform: translateX(5px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes track { from { width: 0; } to { width: 100%; } }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 16px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .engine { grid-template-columns: 260px minmax(0, 1fr); }
  .srow { grid-template-columns: 24px 48px minmax(0, 1fr) 36px; row-gap: 6px; }
  div.srow { grid-template-columns: 24px 48px minmax(0, 1fr) 60px; }
  .srow .art { width: 48px; height: 48px; }
  .srow .whybox { grid-column: 3 / -1; grid-row: 2; }
  button.srow .sdur { display: none; }
}

@media (max-width: 899px) {
  :root { --side-w: 260px; }
  .sidebar {
    position: fixed; left: 0; top: var(--top-h); z-index: 50; bottom: var(--np-h); height: auto;
    background: var(--surface); box-shadow: var(--shadow);
    transform: translateX(-105%); transition: transform .25s;
  }
  body.side-open .sidebar { transform: none; }
  body.side-open .scrim { display: block; position: fixed; inset: var(--top-h) 0 0 0; background: rgba(0, 0, 0, .35); z-index: 45; }
  body.side-mini { --side-w: 260px; }
  main { padding: 16px 16px 0; }
  .engine { grid-template-columns: 1fr; }
  .engine-panel { position: static; }
  .bg-grid { grid-template-columns: 1fr; }
  .sees, .takeaways { grid-template-columns: 1fr; }
  .routine { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choose-grid { grid-template-columns: 1fr; }
  .recap-grid { grid-template-columns: 1fr; }
  .flip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .who span { display: none; }
}

@media (max-width: 640px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .wordmark { font-size: 17px; }
  .search { display: none; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .top-right { grid-column: 3; }
  .stepper li { font-size: 12px; padding: 5px 10px 5px 5px; }
  .stepper .lbl { display: none; }
  .stepper li.current .lbl { display: inline; }
  .pnf-compare { grid-template-columns: 1fr; gap: 6px; }
  .pnf-neq { justify-self: center; font-size: 30px; }
  .explain-head { display: none; }
  .explain-row { grid-template-columns: 1fr; gap: 4px; }
  .ex-arrow { display: none; }
  .nowplaying { grid-template-columns: minmax(0, 1fr) auto; }
  .np-mid { width: auto; }
  .np-track, .np-right { display: none; }
  .navbar .btn { padding: 10px 14px; }
  .nav-hint { font-size: 12px; }
}
