/* Study site v2 · "phòng chiếu" (screening room).
   Layout: home = two full-bleed film panels (real frames from each series); series = banner + film strip of episodes + clue board;
   lesson = player + concept reel + lab on the left, a quiet rail (transcript / code / memory / quiz) on the right; review = one card under a lamp.
   One bold element: the films' own frames and their lamplight. Everything else is quiet.
   Palettes come from the series' style guides: Voss = night blue + neon + lamp amber; NLP = snow night + brass + aurora. Dark by default (night films); light only when the viewer picks it. */
/* Palette: neutral light for reading and focus (no tinted page backgrounds); film frames and the player stay dark.
   Series colour appears only as accents: Voss = neon blue + lamp amber, NLP = brass + aurora. Dark mode = neutral graphite, by choice only. */
:root {
  --bg: #f4f4f2; --surface: #ffffff; --surface2: #ececea; --ink: #1c1d20; --muted: #63666d; --line: #e0e0dc;
  --accent: #2f55d4; --accent-ink: #ffffff; --accent2: #9a6400; --glow: rgba(47, 85, 212, .09); --good: #1d7a4b; --bad: #b8432c;
  --f-head: "Bricolage Grotesque", "Be Vietnam Pro", system-ui, sans-serif; --f-body: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --f-pixel: "VT323", "Courier New", monospace; --f-code: "JetBrains Mono", Consolas, monospace;
  color-scheme: light;
}
[data-series="voss"] { --accent: #2f55d4; --accent-ink: #ffffff; --accent2: #9a6400; --glow: rgba(47, 85, 212, .09); }
[data-series="nlp"] { --accent: #95590c; --accent-ink: #ffffff; --accent2: #1f7d6d; --glow: rgba(149, 89, 12, .09); }
:root[data-theme="dark"] {
  --bg: #17171a; --surface: #202024; --surface2: #29292e; --ink: #ececee; --muted: #9fa0a7; --line: #323238;
  --accent: #ffc247; --accent-ink: #1a1405; --accent2: #7ea2ff; --glow: rgba(255, 194, 71, .12); --good: #5fc48a; --bad: #ef7a62; color-scheme: dark }
:root[data-theme="dark"] [data-series="voss"], :root[data-theme="dark"][data-series="voss"] { --accent: #ffc247; --accent-ink: #1a1405; --accent2: #7ea2ff; --glow: rgba(255, 194, 71, .12); }
:root[data-theme="dark"] [data-series="nlp"], :root[data-theme="dark"][data-series="nlp"] { --accent: #ffb347; --accent-ink: #1b1206; --accent2: #4fc2b1; --glow: rgba(255, 179, 71, .12); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.6 var(--f-body); -webkit-font-smoothing: antialiased; }
#app { min-height: 100vh; background: var(--bg); color: var(--ink); }
button { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--f-head); font-weight: 700; margin: 0; line-height: 1.08; letter-spacing: -.015em; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.muted { color: var(--muted); }
.num { font-family: var(--f-pixel); font-size: 1.35em; line-height: 1; letter-spacing: .02em; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink); text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.meter { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--ink) 14%, transparent); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); }

/* ---------- top bar ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; display: flex; gap: 22px; align-items: center; padding: 12px max(20px, env(safe-area-inset-right, 0px)) 12px max(20px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .brand { font: 700 18px var(--f-head); text-decoration: none; color: var(--ink); white-space: nowrap; letter-spacing: -.01em; }
.top nav { display: flex; gap: 18px; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--muted); font-size: 15px; font-weight: 500; padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a:hover { color: var(--ink); }
.top nav a.on { color: var(--ink); border-bottom-color: var(--accent); }
.top .sp { flex: 1; }
.top .due { display: inline-grid; place-items: center; min-width: 20px; height: 20px; background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: 12px; font-weight: 700; margin-left: 6px; padding: 0 6px; }
.icon-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.page { padding: 28px max(20px, env(safe-area-inset-right, 0px)) 96px max(20px, env(safe-area-inset-left, 0px)); max-width: 1480px; margin: 0 auto; }

/* ---------- home: two film panels ---------- */
.screens { display: grid; grid-template-columns: 1fr 1fr; min-height: calc(100vh - 62px); }
.screen { position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 18px; padding: 48px clamp(24px, 4vw, 64px); color: #f3f5fb; text-decoration: none; overflow: hidden; isolation: isolate; min-height: 520px; }
.screen::before { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--img) center 70% / cover no-repeat; transform: scale(1.02); transition: transform 1.2s ease; }
.screen::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(8, 10, 18, .1) 0%, rgba(8, 10, 18, .35) 45%, rgba(8, 10, 18, .92) 100%); }
.screen:hover::before { transform: scale(1.06); }
.screen + .screen { border-left: 1px solid rgba(255,255,255,.08); }
.screen h2 { font-size: clamp(38px, 4.6vw, 68px); letter-spacing: -.03em; max-width: 12ch; color: #fff; }
.screen p { margin: 0; max-width: 46ch; color: rgba(243, 245, 251, .82); font-size: 17px; }
.screen .row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.screen .btn { color: #fff; border-color: rgba(255,255,255,.35); }
.screen .btn.primary { background: var(--lamp); border-color: var(--lamp); color: #1a1206; }
.screen .meter { max-width: 420px; background: rgba(255,255,255,.18); }
.screen .meter > i { background: var(--lamp); }
.screen .count { font-size: 14px; color: rgba(243, 245, 251, .75); }
.screen .count .num { color: #fff; font-size: 26px; margin-right: 4px; }
.home-note { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 18px max(20px, env(safe-area-inset-right, 0px)) 18px max(20px, env(safe-area-inset-left, 0px)); border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

/* ---------- series page ---------- */
.banner { position: relative; min-height: clamp(240px, 34vh, 360px); display: flex; align-items: flex-end; padding: 40px max(20px, env(safe-area-inset-right, 0px)) 28px max(20px, env(safe-area-inset-left, 0px)); isolation: isolate; }
.banner::before { content: ""; position: absolute; inset: 0; z-index: -2; background: var(--img) center 65% / cover; }
.banner::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(10,11,14,.15) 0%, rgba(10,11,14,.82) 100%); }
.banner .in { max-width: 1480px; width: 100%; margin: 0 auto; display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.banner h1 { font-size: clamp(34px, 4.4vw, 60px); letter-spacing: -.03em; color: #fff; }
.banner p { margin: 6px 0 0; color: rgba(255,255,255,.82); max-width: 60ch; }
.section-title { display: flex; gap: 14px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; margin: 34px 0 14px; }
.section-title h2 { font-size: 24px; }
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x proximity; }
.ep { scroll-snap-align: start; text-decoration: none; color: var(--ink); display: grid; gap: 10px; align-content: start; min-width: 0; }
.ep .shot { position: relative; aspect-ratio: 16 / 7.2; border-radius: 10px; overflow: hidden; background: var(--surface2) center / cover; border: 1px solid var(--line); }
.ep .shot .num { position: absolute; left: 10px; top: 8px; color: #fff; font-size: 26px; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.ep .shot .seen { position: absolute; right: 10px; top: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.ep:hover .shot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.ep b { font: 600 15.5px/1.3 var(--f-head); }
.ep span { color: var(--muted); font-size: 13.5px; }
.ep.next .shot { box-shadow: 0 0 0 2px var(--accent); }

/* transit map: topics = coloured lines, episodes = stations, interchanges = episodes on several topics */
.metro-wrap { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: 'legend' 'map' 'panel'; gap: 14px 24px; align-items: start; }
.metro-legend { grid-area: legend; display: flex; gap: 8px 20px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.metro-legend span { display: inline-flex; gap: 8px; align-items: center; }
.metro-legend i { width: 22px; height: 6px; border-radius: 3px; display: inline-block; }
.metro { grid-area: map; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px; }
.metro svg { display: block; margin: 0 auto; height: auto; }
.m-st { cursor: pointer; outline: none; }
.m-dot { stroke-width: 3.5; transition: r .15s; }
.m-num { font: 600 11px var(--f-body); pointer-events: none; }
.m-lbl { font: 500 12px var(--f-body); fill: var(--muted); pointer-events: none; }
.m-st:hover .m-lbl, .m-st.sel .m-lbl, .m-st:focus-visible .m-lbl { fill: var(--ink); font-weight: 600; }
.m-st.sel .m-dot { stroke-width: 5; }
.m-st:focus-visible .m-dot { stroke: var(--accent); }
.m-st.dim { opacity: .28; }
.m-hit { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 3 3; }
.m-next { fill: none; stroke-width: 2; opacity: .55; animation: mpulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes mpulse { 0%, 100% { transform: scale(1); opacity: .55; } 50% { transform: scale(1.18); opacity: .15; } }
.station { grid-area: panel; position: sticky; top: 84px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 10px; align-content: start; }
.station h3 { font-size: 19px; } .station h3 a { color: var(--ink); text-decoration: none; } .station p { margin: 0; font-size: 14px; }
.st-shot { position: relative; display: block; aspect-ratio: 16 / 7.2; border-radius: 10px; background: var(--surface2) center / cover; }
.st-shot .num { position: absolute; left: 10px; top: 8px; color: #fff; font-size: 26px; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
.st-shot .seen { position: absolute; right: 10px; top: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.st-lines { display: grid; gap: 6px; }
.st-line { display: flex; gap: 8px; align-items: center; font-size: 13.5px; flex-wrap: wrap; }
.st-line i { width: 16px; height: 6px; border-radius: 3px; flex: none; }
.st-line span { flex: 1; color: var(--muted); }
.st-go { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; cursor: pointer; }
.st-go:hover { border-color: var(--accent); color: var(--accent); }
.st-cs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.st-cs a { display: flex; justify-content: space-between; gap: 10px; text-decoration: none; color: var(--ink); padding: 5px 8px; border-radius: 8px; font-size: 14px; }
.st-cs a:hover { background: var(--surface2); }
.st-cs time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
@media (min-width: 1500px) { .metro-wrap { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: 'legend legend' 'map panel'; } }
@media (max-width: 1499px) { .station { position: static; grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: 'shot head' 'shot vi' 'shot lines' 'cs cs' 'btn btn'; column-gap: 18px; } .station .st-shot { grid-area: shot; } .station > h3 { grid-area: head; align-self: end; } .station > p { grid-area: vi; } .station .st-lines { grid-area: lines; align-self: start; } .station .st-cs { grid-area: cs; columns: 2 220px; display: block; } .station .st-cs li { break-inside: avoid; } .station > .btn { grid-area: btn; justify-self: start; } }
@media (max-width: 640px) { .station { grid-template-columns: 1fr; grid-template-areas: none; } .station > * { grid-area: auto !important; } }
@media (prefers-reduced-motion: reduce) { .m-next { animation: none; } }

/* concept index styles (unused now) */
.search { font: 15px var(--f-body); padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); width: min(360px, 100%); }
.cindex { columns: 3 300px; column-gap: 28px; }
.cgroup { break-inside: avoid; margin: 0 0 26px; }
.cg-head { display: flex; gap: 10px; align-items: baseline; text-decoration: none; color: var(--ink); margin-bottom: 8px; }
.cg-head .num { color: var(--accent); font-size: 24px; }
.cg-head b { font: 600 15.5px/1.3 var(--f-head); }
.cg-head .seen { margin-left: auto; font-size: 12px; color: var(--good); white-space: nowrap; }
.cg-head:hover b { color: var(--accent); }
.cgroup ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cgroup li { border-radius: 8px; padding: 6px 10px; }
.cgroup li:hover { background: var(--surface); }
.cname { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; text-decoration: none; color: var(--ink); }
.cname b { font-weight: 600; font-size: 15px; }
.cname span { grid-column: 1; color: var(--muted); font-size: 13.5px; }
.cname time { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pre { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pre a { text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; color: var(--ink); }
.pre a:hover { border-color: var(--accent); color: var(--accent); }

/* (old clue board styles, unused) */
.board-wrap { overflow-x: auto; border-radius: 14px; background: radial-gradient(ellipse at 30% 0%, var(--glow), transparent 60%), var(--surface); border: 1px solid var(--line); }
.board { position: relative; }
.board svg { position: absolute; left: 0; top: 0; pointer-events: none; }
.col-head { position: absolute; text-decoration: none; display: grid; gap: 2px; color: var(--muted); font-size: 13px; }
.col-head .num { color: var(--accent); font-size: 24px; }
.col-head b { font: 600 14px/1.25 var(--f-head); color: var(--ink); }
.col-head:hover b { color: var(--accent); }
.clue { position: absolute; width: 172px; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px 10px; text-decoration: none; color: var(--ink); font-size: 14px; line-height: 1.3; }
.clue:hover, .clue:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); z-index: 2; }
.clue .nm { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; }
.clue small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.clue.done { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.clue.done small::before { content: "✓ "; color: var(--good); }

/* ---------- lesson ---------- */
.crumb { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.lesson { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(360px, 1fr); gap: 28px; align-items: start; }
.lesson-head { grid-column: 1 / -1; display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.lesson-head h1 { font-size: clamp(28px, 3.2vw, 42px); letter-spacing: -.025em; margin-top: 6px; }
.lesson-head .vi { color: var(--muted); margin: 6px 0 0; font-size: 17px; }
.lesson-head .facts { display: flex; gap: 18px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.lesson-head .facts b { color: var(--ink); font-weight: 600; }
.stage { display: grid; gap: 16px; min-width: 0; }
.player { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 16 / 9; box-shadow: 0 18px 40px -24px rgba(0,0,0,.45); }
.player video, .vid-host, .vid-host iframe { width: 100%; height: 100%; display: block; border: 0; }
.pausecard { position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); color: var(--ink); border: 1px solid var(--accent); border-radius: 14px; padding: 16px 18px; display: grid; gap: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.45); }
.pausecard .k { color: var(--accent); font-weight: 600; font-size: 14px; }
.pausecard .row { display: flex; gap: 8px; flex-wrap: wrap; }
.timeline { position: relative; height: 64px; cursor: pointer; user-select: none; }
.timeline .track { position: absolute; left: 0; right: 0; top: 28px; height: 6px; border-radius: 3px; background: var(--surface2); }
.timeline .seg { position: absolute; top: 28px; height: 6px; background: color-mix(in srgb, var(--accent2) 70%, transparent); border-radius: 3px; }
.timeline .seg span { position: absolute; left: 0; top: -22px; font-size: 12.5px; color: var(--muted); white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.timeline .seg:nth-of-type(even) span { top: 12px; }
.timeline .seg:hover span { color: var(--ink); }
.timeline .pin { position: absolute; top: 25px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--glow), 0 0 14px var(--accent); }
.timeline .head { position: absolute; top: 20px; width: 2px; height: 22px; margin-left: -1px; background: var(--ink); }
.lab { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; display: grid; gap: 12px; scroll-margin-top: 80px; }
.lab.flash { border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
.lab-head { display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.lab-head h3 { font-size: 21px; }
.lab .goal { border-left: 3px solid var(--accent); background: var(--surface2); border-radius: 0 10px 10px 0; padding: 10px 14px; font-size: 15px; }
.lab .goal label { display: flex; gap: 8px; align-items: center; cursor: pointer; margin-top: 6px; color: var(--muted); }
.lede-text { color: var(--muted); font-size: 15.5px; max-width: 75ch; margin: 0; }

.rail { position: sticky; top: calc(76px + env(safe-area-inset-top, 0px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: grid; grid-template-rows: auto minmax(0, 1fr); max-height: calc(100vh - 100px); min-width: 0; }
.tabs { display: flex; gap: 20px; padding: 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 14px 0 12px; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.pane { overflow-y: auto; padding: 14px 18px 22px; min-height: 0; }
.pane h3 { font-size: 18px; }
.tl { display: grid; gap: 1px; }
.tl p { margin: 0; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 15px; line-height: 1.55; color: var(--muted); display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.tl p:hover { background: var(--surface2); color: var(--ink); }
.tl p.on { background: var(--glow); color: var(--ink); }
.tl p b { grid-column: 1; font-size: 12.5px; font-weight: 600; color: var(--accent2); }
.tl p time { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl p .tx { grid-column: 1 / -1; }
.term { color: var(--ink); text-decoration: underline 1.5px color-mix(in srgb, var(--accent) 70%, transparent); text-underline-offset: 4px; cursor: help; }
.code { font: 13px/1.7 var(--f-code); border-radius: 10px; background: var(--bg); overflow-x: auto; padding: 8px 0; }
.code .ln { display: grid; grid-template-columns: 3.6em 1fr; gap: 6px; padding: 1px 12px; white-space: pre; border-left: 2px solid transparent; }
.code .ln[data-t] { cursor: pointer; }
.code .ln[data-t]:hover { background: var(--surface2); }
.code .ln.on { background: var(--glow); border-left-color: var(--accent); }
.code .ln time { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.code .ln.key { color: var(--ink); }
.code .ln:not(.key) { color: color-mix(in srgb, var(--ink) 65%, var(--muted)); }
.code .ln.key time { color: var(--accent); }
.cue { font: italic 13.5px var(--f-body); color: var(--muted); padding: 0 12px 8px calc(3.6em + 18px); white-space: normal; }
.block { display: grid; gap: 10px; margin-bottom: 26px; }
.block > p { margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.runner textarea, .write textarea { width: 100%; min-height: 220px; font: 12.5px/1.6 var(--f-code); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 12px; resize: vertical; }
.out { font: 12.5px/1.55 var(--f-code); white-space: pre-wrap; background: var(--bg); border-left: 3px solid var(--good); border-radius: 0 10px 10px 0; padding: 12px; max-height: 300px; overflow: auto; }
.out.err { border-left-color: var(--bad); }
.predict { background: var(--surface2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.predict pre { margin: 0; font: 12.5px/1.5 var(--f-code); white-space: pre-wrap; }
.predict input, .blank-in { font: 13px var(--f-code); background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-bottom: 2px solid var(--accent); border-radius: 6px; padding: 6px 8px; }
.fb { font-size: 14.5px; min-height: 1.4em; }
.fb.ok { color: var(--good); } .fb.no { color: var(--bad); }
.ladder { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ladder button { border: 0; border-left: 1px solid var(--line); background: transparent; padding: 8px 4px 9px; font-size: 12.5px; cursor: pointer; line-height: 1.25; color: var(--muted); display: grid; gap: 2px; justify-items: center; text-align: center; }
.ladder button:first-child { border-left: 0; }
.ladder button .num { font-size: 22px; color: var(--muted); }
.ladder button.on { background: var(--surface2); color: var(--ink); }
.ladder button.done .num { color: var(--good); }
.parsons { display: grid; gap: 6px; }
.parsons .pc { display: flex; gap: 8px; align-items: center; justify-content: space-between; font: 12.5px var(--f-code); background: var(--surface2); border-radius: 8px; padding: 7px 10px; }
.parsons .pc .mv { display: flex; gap: 4px; flex: none; }
.parsons .pc .mv button { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 1px 9px; cursor: pointer; }
.q { border-top: 1px solid var(--line); padding: 16px 0; display: grid; gap: 8px; }
.q:first-of-type { border-top: 0; }
.q b { font-weight: 600; }
.q .opt { text-align: left; border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 9px 12px; cursor: pointer; font-size: 14.5px; }
.q .opt:hover:not(:disabled) { border-color: var(--accent); }
.q .opt.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.q .opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.q .ex { font-size: 14.5px; color: var(--muted); border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; }

/* case file: sections, wrapped code, notes under lines (no sideways scrolling) */
.lesson.wide { grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr); }
.casefile { display: grid; gap: 14px; }
.cf-sec { border-radius: 12px; background: var(--bg); padding: 12px 14px 8px; border: 1px solid transparent; }
.cf-sec.on { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.cf-sec header { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.cf-title { font: 600 15px/1.35 var(--f-head); }
.cf-seek { flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 2px 10px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.cf-seek:hover { color: var(--ink); border-color: var(--accent); }
.cf-ln { padding: 5px 8px; margin: 0 -8px; border-radius: 8px; }
.cf-ln[data-t] { cursor: pointer; }
.cf-ln[data-t]:hover { background: var(--surface2); }
.cf-ln code { display: block; font: 13px/1.6 var(--f-code); white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 2ch; text-indent: -2ch; color: color-mix(in srgb, var(--ink) 72%, var(--muted)); }
.cf-ln.key { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.cf-ln.key code { color: var(--ink); }
.cf-ln.on { background: var(--glow); box-shadow: inset 3px 0 0 var(--accent); }
.cf-note { margin: 2px 0 0 2ch; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.cf-ln.key .cf-note { color: var(--accent); }
.predict pre, .runner textarea { white-space: pre-wrap; overflow-wrap: anywhere; }

/* account + sign-in */
.acct { font-size: 14px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signin { border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(440px, 92vw); background: var(--surface); color: var(--ink); }
.signin::backdrop { background: rgba(10, 11, 14, .55); }
.signin form { display: grid; gap: 12px; }
.signin h2 { font-size: 24px; }
.signin p { margin: 0; }
.signin input { font: 16px var(--f-body); padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
.signin .row { display: flex; gap: 8px; flex-wrap: wrap; }
/* class dashboard */
.cls-table { display: grid; gap: 6px; margin-top: 14px; }
.cls-row { display: grid; grid-template-columns: minmax(140px, 1.2fr) 1.4fr 1.4fr 70px 150px; gap: 14px; align-items: center; padding: 10px 14px; }
.cls-row.head { font-size: 13px; color: var(--muted); }
.cls-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.cls-item summary { cursor: pointer; list-style: none; }
.cls-item summary::-webkit-details-marker { display: none; }
.cls-bar { display: grid; gap: 4px; } .cls-bar small { color: var(--muted); font-size: 12.5px; }
.cls-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; padding: 4px 14px 14px; }
.cls-detail ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 2px; font-size: 13.5px; }
.cls-detail li { display: grid; grid-template-columns: 1fr 60px 44px 60px; gap: 8px; color: var(--muted); }
.cls-detail li.w { color: var(--ink); }
@media (max-width: 760px) { .cls-row { grid-template-columns: 1fr; } .cls-row.head { display: none; } .acct { display: none; } }

/* ---------- review ---------- */
.review { max-width: 760px; margin: 0 auto; display: grid; gap: 20px; padding-top: 24px; }
.review h1 { font-size: clamp(30px, 4vw, 44px); letter-spacing: -.025em; }
.review-meta { display: flex; gap: 18px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.review-meta b { color: var(--ink); }
.flash-card { position: relative; background: radial-gradient(ellipse at 50% -20%, var(--glow), transparent 65%), var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 34px 34px 28px; display: grid; gap: 16px; min-height: 280px; align-content: start; }
.flash-card .side { color: var(--muted); font-size: 13px; }
.flash-card .front { font: 600 clamp(20px, 2.4vw, 26px)/1.35 var(--f-head); letter-spacing: -.01em; }
.flash-card .back { font: 15px/1.6 var(--f-code); background: var(--bg); border-radius: 10px; padding: 14px 16px; white-space: pre-wrap; border-left: 3px solid var(--accent); }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rate button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 6px; cursor: pointer; display: grid; gap: 2px; font-weight: 600; }
.rate button:hover { border-color: var(--accent); }
.rate button small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.empty { display: grid; gap: 14px; justify-items: start; }


/* ---------- interactive figures (viz/core.js reads these names from :root) ---------- */
:root { --panel: var(--surface); --panel2: var(--surface2); --text: var(--ink); --ok: var(--good); }
.viz-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.viz-head small { color: var(--muted); }
.viz-body { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 10px; }
.viz-stage { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.viz-stage svg { width: 100%; height: auto; display: block; aspect-ratio: 16/9; font-family: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif; user-select: none; touch-action: none; }
.viz-stage .viz-mono { font-variant-numeric: tabular-nums; }
.viz-stage .viz-cell, .viz-stage .viz-move { transition: fill .35s ease, x .25s ease, y .25s ease, width .35s ease, height .35s ease, opacity .3s; }
.viz-stage svg.dragging .viz-move { transition: none; }
.viz-stage .viz-drag:hover { filter: brightness(1.12); }
.viz-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; max-width: 260px; opacity: 0; transition: opacity .15s; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.viz-tip.show { opacity: 1; }
.viz-side { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-areas: 'step controls' 'step readout' 'nav dots' 'bridge bridge'; gap: 12px 24px; align-items: start; }
.viz-step { grid-area: step; } .viz-controls { grid-area: controls; } .viz-readout { grid-area: readout; } .viz-nav { grid-area: nav; } .viz-dots { grid-area: dots; align-self: center; } .viz-bridge { grid-area: bridge; }
.viz-count { color: var(--accent); font-size: 13px; font-weight: 600; }
.viz-step h4 { margin: 4px 0 6px; font-size: 17px; }
.viz-step p { margin: 0; font-size: 15px; line-height: 1.6; }
.viz-step code, .viz-readout code { background: var(--panel2); padding: 1px 6px; border-radius: 4px; font-size: 13.5px; }
.viz-controls { display: flex; flex-direction: column; gap: 10px; }
.viz-controls:empty { display: none; }
.viz-slider { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.viz-slider .l { color: var(--muted); }
.viz-slider input { accent-color: var(--accent); width: 100%; }
.viz-slider output { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.viz-btn { align-self: flex-start; padding: 7px 14px; }
.viz-choice { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; align-self: flex-start; }
.viz-choice button { background: none; border: 0; padding: 7px 13px; cursor: pointer; font-size: 14px; color: var(--muted); }
.viz-choice button + button { border-left: 1px solid var(--line); }
.viz-choice button.on { background: var(--accent); color: #1b1d27; font-weight: 600; }
.viz-hint2 { font-size: 13px; color: var(--muted); }
.viz-readout { background: var(--panel2); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; padding: 10px 14px; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.viz-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.viz-nav .btn { padding: 7px 13px; }
.viz-nav .btn:disabled { opacity: .4; cursor: default; }
.viz-dots { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.viz-dots button { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel2); padding: 0; cursor: pointer; }
.viz-dots button.seen { background: var(--muted); }
.viz-dots button.on { background: var(--accent); border-color: var(--accent); }
.viz-bridge { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; }
.viz-bridge div { display: flex; gap: 8px; align-items: center; background: var(--panel2); border-radius: 999px; padding: 5px 12px; }
.viz-bridge span { color: var(--muted); }
.viz-bridge b { color: var(--accent); }
@media (max-width: 860px) { .viz-side { grid-template-columns: 1fr; grid-template-areas: 'step' 'controls' 'readout' 'nav' 'dots' 'bridge'; } .viz-dots { justify-content: flex-start; } }

@media (max-width: 1080px) {
  .lesson, .lesson.wide { grid-template-columns: 1fr; }
  .rail { position: static; max-height: none; }
  .pane { max-height: 72vh; }
}
@media (max-width: 760px) {
  .screens { grid-template-columns: 1fr; min-height: 0; }
  .screen { min-height: 460px; }
  .screen + .screen { border-left: 0; border-top: 1px solid rgba(255,255,255,.08); }
  .top { gap: 12px; } .top nav { gap: 12px; } .top nav a { font-size: 14px; }
  .rate { grid-template-columns: repeat(2, 1fr); }
  .ladder button { font-size: 11px; }
  .flash-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } .screen:hover::before { transform: scale(1.02); } }
