/* Layout: one narrow story column (image, then words, then choices, stacked like a phone screen).
   Projector mode widens to image-left / story-right. The teacher view is a wide two-pane grid. */
:root {
  --bg: #f1eef4;          /* lilac-grey, like the basement walls in daylight */
  --surface: #ffffff;
  --surface-2: #e8e3ee;
  --ink: #221a2b;         /* plum-black */
  --muted: #645b70;
  --line: #d9d1e1;
  --lamp: #e6a535;        /* lamp-light amber: the one accent */
  --lamp-soft: #f7e6c3;
  --on-lamp: #1f1726;
  --up: #4c7633;          /* Maya's hoodie green */
  --down: #b0435a;
  --focus: #6c4bb3;
  --sp-maya: #4c7633;
  --sp-tyler: #3e5fa3;
  --sp-devin: #2b7682;
  --sp-sam: #7a55a6;
  --shadow: 0 1px 2px rgb(34 26 43 / .06), 0 6px 18px rgb(34 26 43 / .06);

  --font-display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --font-body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --step--1: .875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.1rem;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #18131e; --surface: #231c2b; --surface-2: #2d2537; --ink: #f1ecf5; --muted: #a99fb5; --line: #3b3246;
    --lamp: #f0b44a; --lamp-soft: #3b2f1f; --on-lamp: #1f1726; --up: #8fbe6c; --down: #e57c90; --focus: #b49af0;
    --sp-maya: #9dca7a; --sp-tyler: #93acec; --sp-devin: #7ccbd4; --sp-sam: #c3a3ec;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #18131e; --surface: #231c2b; --surface-2: #2d2537; --ink: #f1ecf5; --muted: #a99fb5; --line: #3b3246;
  --lamp: #f0b44a; --lamp-soft: #3b2f1f; --on-lamp: #1f1726; --up: #8fbe6c; --down: #e57c90; --focus: #b49af0;
  --sp-maya: #9dca7a; --sp-tyler: #93acec; --sp-devin: #7ccbd4; --sp-sam: #c3a3ec;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.eyebrow { font-family: var(--font-mono); font-size: var(--step--1); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---- shell ---- */
.shell {
  max-width: 720px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 12px 40px;
  display: grid;
  gap: 20px;
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 44px; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.wordmark .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 0 4px var(--lamp-soft); }
.topbar .who { font-size: var(--step--1); color: var(--muted); }
.banner { font-size: var(--step--1); background: var(--surface-2); border-radius: 10px; padding: 8px 12px; color: var(--muted); }
.banner strong { color: var(--ink); }
.footer { font-size: var(--step--1); color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--lamp); border-color: var(--lamp); color: var(--on-lamp); }
.btn.primary:hover { filter: brightness(1.05); border-color: var(--lamp); }
.btn.quiet { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; padding-inline: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---- forms ---- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; }
.field .hint { font-size: var(--step--1); color: var(--muted); }
.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface);
}
.input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input.code { font-family: var(--font-mono); font-size: 1.4rem; letter-spacing: .25em; text-transform: uppercase; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.error { color: var(--down); font-weight: 700; font-size: var(--step--1); }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 16px; }

/* ---- join ---- */
.join-hero { display: grid; gap: 12px; padding-top: 12px; }
.join-hero h1 { font-size: clamp(1.9rem, 7vw, 2.8rem); }
.join-hero .lede { font-size: var(--step-1); color: var(--muted); max-width: 34ch; }

/* ---- home ---- */
.scn-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: grid; }
.scn-card img { aspect-ratio: 1200 / 670; object-fit: cover; width: 100%; }
.scn-card .body { padding: 18px 20px 20px; display: grid; gap: 12px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: center; }
.steps .box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; flex: none; }
.steps li.done .box { background: var(--up); border-color: var(--up); color: var(--surface); }
.steps li.done span:last-child { color: var(--muted); }
.toolkit-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: var(--step--1); font-weight: 700; }
.chip.on { background: var(--lamp-soft); color: var(--ink); }
.chip.off { color: var(--muted); font-weight: 400; }

/* ---- play ---- */
.meters { display: flex; gap: 6px; flex-wrap: wrap; }
.meter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: var(--step--1); }
.arrow { font-weight: 700; font-family: var(--font-mono); font-size: 1.15em; line-height: 1; }
.arrow.up { color: var(--up); }
.arrow.down { color: var(--down); }
.arrow.same { color: var(--muted); }

.scene { display: grid; gap: 18px; }
.scene-art { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 1200 / 670; max-width: 100%; }
.scene-art img { width: 100%; height: 100%; object-fit: cover; }
.scene-head { display: grid; gap: 6px; }
.setting { font-style: italic; color: var(--muted); }
.lines { display: grid; gap: 12px; }
.narration { max-width: 62ch; }
.say { display: grid; gap: 4px; justify-items: start; }
.say .who { font-family: var(--font-mono); font-size: var(--step--1); font-weight: 500; letter-spacing: .04em; color: var(--sp, var(--muted)); }
.say .bubble { background: var(--surface); border-radius: 18px 18px 18px 4px; padding: 10px 16px; box-shadow: var(--shadow); max-width: 52ch; font-size: var(--step-1); line-height: 1.4; }
.say[data-speaker="Maya"] { --sp: var(--sp-maya); }
.say[data-speaker="Tyler"] { --sp: var(--sp-tyler); }
.say[data-speaker="Devin"] { --sp: var(--sp-devin); }
.say[data-speaker="Sam"] { --sp: var(--sp-sam); }
.note { background: var(--lamp-soft); border-radius: 12px; padding: 10px 14px; font-weight: 700; }

.prompt-label { font-family: var(--font-display); font-size: var(--step-0); font-weight: 500; }
.choices { display: grid; gap: 10px; }
.choice {
  display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; text-align: left;
  width: 100%; min-height: 60px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line); cursor: pointer; font-size: var(--step-0);
  transition: border-color .12s ease, transform .12s ease, background .12s ease;
}
.choice:hover { border-color: var(--lamp); }
.choice:active { transform: scale(.995); }
.choice .key { font-family: var(--font-mono); font-weight: 500; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); }
.choice:hover .key { background: var(--lamp); color: var(--on-lamp); }
.choice .txt { min-width: 0; }

.feedback { display: grid; gap: 14px; background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); animation: rise .25s ease-out; }
.feedback .picked { font-size: var(--step-1); line-height: 1.4; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; align-items: baseline; }
.kv dt { font-family: var(--font-mono); font-size: var(--step--1); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }
.delta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.unlock { display: grid; gap: 4px; background: var(--lamp-soft); border-radius: 12px; padding: 12px 14px; }
.unlock .t { font-weight: 700; }
.discuss { border: 2px dashed var(--lamp); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 6px; }
.discuss p { font-size: var(--step-1); font-weight: 700; line-height: 1.35; }
@keyframes rise { from { transform: translateY(6px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---- ending ---- */
.ending-head { display: grid; gap: 8px; }
.takeaway { background: var(--lamp-soft); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 4px; }
.takeaway p { font-size: var(--step-1); font-weight: 700; line-height: 1.35; }
.results { display: grid; gap: 14px; }
.result { display: grid; gap: 6px; }
.result .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.result .name { font-weight: 700; }
.result .reading { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); }
.track { position: relative; height: 14px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: var(--line); transform: translateX(-1px); }
.track .fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.track .fill.pos { left: 50%; background: var(--up); }
.track .fill.neg { right: 50%; background: var(--down); }
.scale { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: .75rem; color: var(--muted); }
.path { margin: 0; padding-left: 1.4em; display: grid; gap: 4px; }
.path li::marker { font-family: var(--font-mono); color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.tcard { border-radius: 12px; padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line); display: grid; gap: 4px; align-content: start; font-size: var(--step--1); }
.tcard .n { font-family: var(--font-display); font-weight: 500; font-size: var(--step-0); }
.tcard.new { border-color: var(--lamp); }
.tcard.locked { background: transparent; border-style: dashed; color: var(--muted); }
.tcard .tag { font-family: var(--font-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.section { display: grid; gap: 12px; }

/* ---- reflection ---- */
.reflect-q { display: grid; gap: 8px; }
.reflect-q label { font-weight: 700; font-size: var(--step-0); }

/* ---- present (projector) mode ---- */
body.present { --step-0: 1.25rem; --step-1: 1.5rem; --step-2: 2rem; --step-3: 2.6rem; }
body.present .shell { max-width: 1400px; }
@media (min-width: 1000px) {
  body.present .scene { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; column-gap: 32px; }
  body.present .scene > .scene-art { grid-row: span 4; position: sticky; top: 16px; }
}
body.present .choice .key { width: 44px; height: 44px; font-size: 1.3rem; }

/* ---- teacher ---- */
.t-shell { max-width: 1240px; }
.t-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .t-grid { grid-template-columns: 280px minmax(0, 1fr); align-items: start; } }
.class-list { display: grid; gap: 6px; }
.class-btn { text-align: left; padding: 10px 14px; border-radius: 12px; border: 1.5px solid transparent; background: transparent; cursor: pointer; display: grid; gap: 2px; }
.class-btn:hover { background: var(--surface); }
.class-btn[aria-current="true"] { background: var(--surface); border-color: var(--lamp); }
.class-btn .c { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); letter-spacing: .1em; }
.code-big { font-family: var(--font-mono); font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: .2em; font-weight: 500; }
.class-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: end; }
.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: transparent; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1.5px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--lamp); }
.table-wrap { overflow-x: auto; }
table.roster { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.roster th, .roster td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.roster th { font-family: var(--font-mono); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; color: var(--muted); }
.roster td.num { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: .8rem; white-space: nowrap; }
.pill.s0 { background: var(--surface-2); color: var(--muted); }
.pill.s1 { background: color-mix(in srgb, var(--lamp) 25%, transparent); }
.pill.s2 { background: color-mix(in srgb, var(--lamp) 45%, transparent); }
.pill.s3 { background: var(--up); color: var(--surface); }
.reflection-box { display: grid; gap: 10px; padding: 12px 0 4px; }
.reflection-box .q { font-weight: 700; }
.reflection-box .a { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.stat-scene { display: grid; gap: 10px; padding-block: 8px 16px; border-bottom: 1px solid var(--line); }
.stat-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(90px, 30%) 3.5em; gap: 10px; align-items: center; font-size: var(--step--1); }
.stat-bar { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.stat-bar span { display: block; height: 100%; background: var(--lamp); border-radius: 999px; }
.stat-row .pct { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.check-row input { width: 22px; height: 22px; margin-top: 3px; accent-color: var(--lamp); flex: none; }
.check-row .grow { flex: 1; min-width: 0; display: grid; gap: 4px; }
.example-tag { font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 20; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
