/* Schaffa Foundation Academy
   One committed look: a space station at night. Hazard orange is the only accent; plasma blue marks skills and lessons. */
:root {
  color-scheme: dark;
  --void: #0d1322;
  --hull: #151d33;
  --hull-2: #1c2642;
  --rivet: #2b3858;
  --ink: #e9edf7;
  --ink-dim: #9aa5c3;
  --signal: #ff8a3d;
  --signal-soft: rgba(255, 138, 61, .14);
  --plasma: #82a8ff;
  --ok: #4cc9a0;
  --warn: #f2c14e;
  --bad: #ff6178;
  --code-bg: #0a0f1c;
  --gutter-ink: #56648a;
  --display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--void); color: var(--ink); }
body { font-family: var(--body); font-size: 15px; line-height: 1.5; min-height: 100vh; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; margin: 0; text-wrap: balance; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--plasma); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
[hidden] { display: none !important; }
code, pre, textarea.code, .walk-code, .hunt-line, .opt, .console, .gutter { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--rivet); padding: 1px 5px; border-radius: 5px; }
.label { font-family: var(--display); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); font-weight: 600; }
.label.plasma { color: var(--plasma); }
.label.signal { color: var(--signal); }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-dim); }
.small { font-size: .85rem; }
.tiny { font-size: .78rem; }
.stack { display: grid; gap: 12px; }
.stack-lg { display: grid; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
main.wrap { padding-block: 20px 56px; }

/* Top bar */
.topbar { border-bottom: 1px solid var(--rivet); background: var(--void); position: sticky; top: 0; z-index: 20; }
.topbar .wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: space-between; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand svg { flex: none; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; display: block; }
.brand-sub { font-size: .76rem; color: var(--ink-dim); display: block; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.nav a, .nav button.linkish { text-decoration: none; color: var(--ink-dim); font-family: var(--display); font-weight: 600; letter-spacing: .03em; padding: 8px 12px; border-radius: 8px; border: 1px solid transparent; background: none; }
.nav a:hover, .nav button.linkish:hover { color: var(--ink); background: var(--hull); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--hull-2); border-color: var(--rivet); }
.nav form { margin: 0; }
.whoami { font-size: .8rem; color: var(--ink-dim); padding-inline: 8px; }

/* Panels, buttons, chips */
.panel { background: var(--hull); border: 1px solid var(--rivet); border-radius: 14px; padding: 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head.tight { margin-bottom: 0; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rivet); background: var(--hull-2); padding: 9px 16px; border-radius: 8px; font-family: var(--display); font-weight: 600; letter-spacing: .03em; color: var(--ink); text-decoration: none; }
.btn:hover { border-color: var(--ink-dim); }
.btn.go { background: var(--signal); color: #1a1004; border-color: var(--signal); }
.btn.go:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(255, 97, 120, .5); color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 6px 10px; font-size: .82rem; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-family: var(--display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--rivet); color: var(--ink-dim); white-space: nowrap; }
.chip.done { color: var(--ok); border-color: rgba(76, 201, 160, .45); }
.chip.open { color: var(--signal); border-color: rgba(255, 138, 61, .5); }
.chip.boss { color: var(--bad); border-color: rgba(255, 97, 120, .5); }
.chip.plasma { color: var(--plasma); border-color: rgba(130, 168, 255, .45); }
.flash { border: 1px solid var(--rivet); border-radius: var(--r); padding: 10px 14px; background: var(--hull-2); }
.flash.ok { border-color: rgba(76, 201, 160, .5); }
.flash.err { border-color: rgba(255, 97, 120, .5); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Bars (width set from data-pct by app.js) */
.bar { height: 8px; background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--plasma); border-radius: inherit; transition: width .6s ease; }
.bar.xp { height: 10px; }
.bar.xp > i { background: linear-gradient(90deg, var(--signal), #ffb37a); }
.bar.boss { height: 14px; border-color: rgba(255, 97, 120, .5); }
.bar.boss > i { background: linear-gradient(90deg, var(--bad), #ff9aa9); }

/* Auth */
.auth { max-width: 460px; margin: 8vh auto 0; display: grid; gap: 18px; }
.auth .panel { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field label { font-size: .85rem; font-weight: 700; }
.field .hint { font-size: .78rem; color: var(--ink-dim); }
.field input, .field textarea, .field select { background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 8px; padding: 9px 11px; width: 100%; min-width: 0; }
.field textarea { resize: vertical; min-height: 80px; font-family: var(--mono); font-size: .86rem; }
.field .error { color: var(--bad); font-size: .8rem; }
.check-line { display: flex; gap: 10px; align-items: center; font-size: .92rem; }
.check-line input { width: 18px; height: 18px; accent-color: var(--signal); }

/* Station */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; background: linear-gradient(120deg, var(--hull-2), var(--hull)); }
.rank { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--signal); font-family: var(--display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: .85rem; }
.xpmeta { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-dim); margin-top: 6px; }
.streak { display: grid; gap: 8px; justify-items: end; }
.streak-days { display: flex; gap: 5px; }
.streak-days span { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--rivet); display: grid; place-items: center; font-size: .65rem; color: var(--ink-dim); font-family: var(--display); }
.streak-days span.on { background: var(--signal-soft); border-color: var(--signal); color: var(--ink); }
.streak-days span.today { outline: 1px solid var(--ink); outline-offset: 1px; }
.mission { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.map svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--ink-dim); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend .l-signal { background: var(--signal); }
.legend .l-rivet { background: var(--rivet); }
.legend .l-plasma { background: var(--plasma); }
.radar svg { width: 100%; max-width: 420px; display: block; margin: 0 auto; }
.tracks { display: grid; gap: 8px; margin-top: 8px; }
.track { display: grid; grid-template-columns: 116px minmax(0, 1fr) 48px; gap: 10px; align-items: center; font-size: .85rem; }
.track .bar { height: 6px; border: 0; }
.track .num { text-align: right; color: var(--ink-dim); }

/* Quest list */
.week-group { display: grid; gap: 8px; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.qitem { text-align: left; border: 1px solid var(--rivet); background: var(--hull); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 6px; text-decoration: none; color: var(--ink); }
a.qitem:hover { border-color: var(--ink-dim); }
.qitem .qtop { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.qitem .qname { font-family: var(--display); font-weight: 600; }
.qitem .qmeta { font-size: .78rem; color: var(--ink-dim); }
.qitem.locked { opacity: .5; }
.qitem.next { border-color: var(--signal); background: var(--hull-2); }
.qitem.boss { border-color: rgba(255, 97, 120, .5); }
.sector-future { opacity: .55; }

/* Quest page */
.quest-shell { display: grid; gap: 16px; max-width: 980px; }
.mission-head { display: grid; gap: 10px; }
.story { color: var(--ink-dim); font-style: italic; }
.stepper { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.step { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rivet); background: var(--code-bg); border-radius: 99px; padding: 6px 14px 6px 6px; font-family: var(--display); font-weight: 600; font-size: .88rem; color: var(--ink-dim); }
.step .step-n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--hull-2); border: 1px solid var(--rivet); font-size: .75rem; }
.step.past { color: var(--ok); border-color: rgba(76, 201, 160, .45); }
.step.past .step-n { background: rgba(76, 201, 160, .18); border-color: transparent; }
.step.now { color: var(--ink); border-color: var(--signal); background: var(--signal-soft); }
.step.now .step-n { background: var(--signal); color: #1a1004; border-color: transparent; }
.step:disabled { opacity: .5; cursor: not-allowed; }
.step-line { width: 18px; height: 1px; background: var(--rivet); }
.lesson { display: grid; gap: 12px; border-color: rgba(130, 168, 255, .45); }
.lesson-body { display: grid; gap: 10px; max-width: 70ch; }
.walk { border: 1px solid var(--rivet); border-radius: 10px; overflow-x: auto; background: var(--code-bg); }
.walk-row { display: grid; grid-template-columns: 34px minmax(max-content, 1fr) minmax(220px, 1.1fr); align-items: stretch; border-bottom: 1px solid rgba(43, 56, 88, .6); }
.walk-row:last-child { border-bottom: 0; }
.walk-ln { font-family: var(--mono); font-size: .8rem; color: var(--gutter-ink); text-align: right; padding: 6px 8px 6px 0; }
.walk-code { font-family: var(--mono); font-size: .85rem; white-space: pre; padding: 6px 16px 6px 4px; color: var(--ink); background: none; border: 0; border-radius: 0; }
.walk-note { font-size: .82rem; color: var(--plasma); padding: 6px 12px; border-left: 1px solid var(--rivet); }
.mistakes { border-left: 3px solid var(--warn); padding: 4px 0 4px 14px; display: grid; gap: 6px; }
.mistakes ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: .9rem; }
.quiz { display: grid; gap: 12px; }
.quiz-code { font-family: var(--mono); font-size: .9rem; background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 10px; padding: 12px 14px; margin: 0; white-space: pre; overflow-x: auto; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.opt { border: 1px solid var(--rivet); background: var(--hull-2); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: .95rem; text-align: center; }
.opt:hover:not(:disabled) { border-color: var(--plasma); }
.opt.wrong { border-color: rgba(255, 97, 120, .5); color: var(--bad); text-decoration: line-through; opacity: .7; }
.opt.right { border-color: var(--ok); color: var(--ok); background: rgba(76, 201, 160, .12); }
.opt:disabled { cursor: default; }
.verdict { border-radius: 12px; padding: 14px; border: 1px solid var(--rivet); background: var(--hull-2); display: grid; gap: 8px; }
.verdict.good { border-color: rgba(76, 201, 160, .5); }
.verdict.miss { border-color: rgba(255, 97, 120, .5); }
.brief ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.spec { border: 1px solid var(--signal); background: var(--signal-soft); border-radius: 12px; padding: 16px; display: grid; gap: 12px; }
.spec.locked { border-color: var(--rivet); background: var(--hull); }
.spec-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.check-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; }
.check-row > span::before { content: "○ "; color: var(--ink-dim); }
.check-row > span.met { color: var(--ok); }
.check-row > span.met::before { content: "● "; color: var(--ok); }
.editor { border: 1px solid var(--rivet); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--rivet); background: var(--hull); }
.editor-bar .file { font-family: var(--mono); font-size: .8rem; color: var(--ink-dim); }
.code-area { display: grid; grid-template-columns: 42px minmax(0, 1fr); max-height: 440px; overflow: auto; }
.gutter { font-family: var(--mono); font-size: .85rem; line-height: 1.6; color: var(--gutter-ink); text-align: right; padding: 12px 8px 12px 0; user-select: none; white-space: pre; border-right: 1px solid var(--rivet); }
textarea.code { font-family: var(--mono); font-size: .85rem; line-height: 1.6; background: transparent; border: 0; resize: none; padding: 12px; color: var(--ink); min-height: 200px; outline: none; white-space: pre; overflow-x: auto; overflow-y: hidden; tab-size: 4; width: 100%; }
textarea.code:focus-visible { box-shadow: inset 0 0 0 1px var(--signal); }
.console { font-family: var(--mono); font-size: .82rem; background: #070b15; border-top: 1px solid var(--rivet); padding: 12px; white-space: pre-wrap; word-break: break-word; min-height: 52px; max-height: 240px; overflow: auto; color: #c7d0e8; }
.console .err { color: var(--bad); }
.console .sys { color: var(--ink-dim); }
.console .help { color: var(--warn); font-family: var(--body); display: block; margin-top: 6px; }
.tests { display: grid; gap: 6px; }
.test { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; align-items: start; font-size: .88rem; padding: 8px 10px; border-radius: 8px; background: var(--hull-2); border: 1px solid var(--rivet); }
.test .ic { font-family: var(--display); font-weight: 700; }
.test.pass { border-color: rgba(76, 201, 160, .4); }
.test.pass .ic { color: var(--ok); }
.test.fail { border-color: rgba(255, 97, 120, .45); }
.test.fail .ic { color: var(--bad); }
.test .msg { color: var(--ink-dim); font-family: var(--mono); font-size: .78rem; }
.test .help { color: var(--warn); font-size: .82rem; }
.hints { display: grid; gap: 10px; }
.bubble { background: var(--hull-2); border: 1px solid var(--rivet); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.bubble .who { font-size: .72rem; font-family: var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--plasma); margin-bottom: 3px; font-weight: 600; }
.win { border: 1px solid rgba(76, 201, 160, .55); background: rgba(76, 201, 160, .08); border-radius: 14px; padding: 18px; display: grid; gap: 10px; }
.win h2 { color: var(--ok); }

/* Closed */
.closed { max-width: 560px; margin: 10vh auto 0; text-align: center; display: grid; gap: 14px; justify-items: center; }

/* Parent */
.parent-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--hull); border: 1px solid var(--rivet); border-radius: 12px; padding: 14px; display: grid; gap: 2px; }
.stat b { font-family: var(--display); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--ink-dim); }
.stat.on { border-color: rgba(76, 201, 160, .5); }
.stat.off { border-color: rgba(242, 193, 78, .5); }
.parent-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.parent-col { display: grid; gap: 20px; min-width: 0; }
.callout { border-left: 3px solid var(--signal); padding: 8px 12px; background: var(--signal-soft); border-radius: 0 8px 8px 0; }
.callout.warn { border-left-color: var(--warn); background: rgba(242, 193, 78, .1); }
.scroll-x { overflow-x: auto; }
.heat table { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 420px; font-size: .82rem; }
.heat th { font-weight: 600; color: var(--ink-dim); text-align: left; font-family: var(--display); letter-spacing: .04em; }
.heat th.code { font-family: var(--mono); font-size: .76rem; color: var(--ink); white-space: nowrap; }
.heat td { height: 30px; border-radius: 6px; text-align: center; font-variant-numeric: tabular-nums; min-width: 46px; }
.heat .l0 { background: var(--code-bg); color: var(--gutter-ink); }
.heat .l1 { background: rgba(130, 168, 255, .2); }
.heat .l2 { background: rgba(130, 168, 255, .42); }
.heat .l3 { background: rgba(130, 168, 255, .7); color: #0d1322; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.timeline li { display: grid; grid-template-columns: 70px 14px minmax(0, 1fr); gap: 10px; padding: 7px 0; font-size: .86rem; }
.timeline .t { color: var(--ink-dim); font-variant-numeric: tabular-nums; font-size: .78rem; padding-top: 1px; }
.pip { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--rivet); }
.pip.ok { background: var(--ok); } .pip.warn { background: var(--warn); } .pip.bad { background: var(--bad); } .pip.sig { background: var(--signal); } .pip.info { background: var(--plasma); }
.timeline li.day-sep { display: block; font-family: var(--display); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); padding: 12px 0 2px; border-top: 1px solid var(--rivet); }
.timeline li.day-sep:first-child { border-top: 0; padding-top: 0; }
table.list { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.list th, table.list td { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--rivet); vertical-align: top; }
table.list th { font-family: var(--display); font-weight: 600; font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }
table.list td.num { text-align: right; }
.linkbox { display: grid; gap: 10px; border: 1px solid var(--signal); background: var(--signal-soft); border-radius: 12px; padding: 14px; }
.linkbox .url { font-family: var(--mono); font-size: .78rem; word-break: break-all; background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 8px; padding: 8px 10px; user-select: all; }
.linkbox .qr { background: #fff; padding: 8px; border-radius: 8px; justify-self: start; }
.linkbox .qr img { display: block; width: 150px; height: 150px; image-rendering: pixelated; }
.codeview { font-family: var(--mono); font-size: .85rem; background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 10px; padding: 12px 14px; white-space: pre; overflow-x: auto; margin: 0; }
.settings-form { display: grid; gap: 16px; max-width: 640px; }
.settings-form .pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Record of learning: screen + print */
.record table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
.record th, .record td { border: 1px solid var(--rivet); padding: 8px 10px; vertical-align: top; text-align: left; }
.record th { background: var(--hull-2); font-family: var(--display); font-weight: 600; }
.record td:first-child { width: 28%; }
.record td:first-child b { font-family: var(--mono); font-size: .82rem; display: block; }
.record ul { margin: 0; padding-left: 16px; display: grid; gap: 3px; }
.record .empty { color: var(--ink-dim); font-style: italic; }
.filters { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filters .field { min-width: 150px; }

/* Quest map: finished sectors fold away */
.sector-block { display: grid; gap: 12px; }
.sector-block > summary { cursor: pointer; list-style: none; }
.sector-block > summary::-webkit-details-marker { display: none; }
.sector-block > summary h1::after { content: " ▾"; color: var(--ink-dim); font-size: .7em; }
.sector-block:not([open]) > summary h1::after { content: " ▸"; }
.legend .l-ok { background: var(--ok); }

/* Quest kinds */
.kind-banner { font-size: .9rem; background: var(--hull-2); border: 1px solid var(--rivet); border-left: 3px solid var(--plasma); border-radius: 8px; padding: 9px 12px; margin: 0; }
.kind-banner b { color: var(--plasma); font-family: var(--display); letter-spacing: .02em; }
.ai-draft { border-color: rgba(130, 168, 255, .45); display: grid; gap: 8px; }
.ai-draft .prompt { margin: 0; padding: 10px 14px; border-left: 3px solid var(--plasma); background: var(--code-bg); border-radius: 0 8px 8px 0; font-family: var(--mono); font-size: .85rem; white-space: pre-wrap; }
.card-view { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: .9rem; }
.card-view dt { color: var(--ink-dim); }
.card-view dd { margin: 0; white-space: pre-wrap; }
.test .msg.ok { color: var(--ok); }
.carried { margin: 0 0 -6px; }
.web-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--rivet); }
.web-split .code-area { border-right: 1px solid var(--rivet); }
.preview { background: #fff; min-height: 320px; display: grid; }
.preview-frame { width: 100%; height: 100%; min-height: 320px; border: 0; background: #fff; display: block; }
.publish { border-color: rgba(76, 201, 160, .45); }
/* ---------- Explorers theme: brighter, bigger, friendlier ---------- */
body.theme-explorers {
  --void: #0f2c4c; --hull: #15395f; --hull-2: #1c4671; --rivet: #2d5c8c;
  --ink: #f5f9ff; --ink-dim: #bdd0ea; --signal: #ffb547; --signal-soft: rgba(255, 181, 71, .16);
  --plasma: #7fe3c6; --ok: #7be495; --code-bg: #0c2440; --gutter-ink: #6f8fb8;
  --display: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  background: radial-gradient(ellipse 80% 50% at 85% -10%, rgba(127, 227, 198, .18), transparent 60%), radial-gradient(ellipse 60% 40% at 0% 0%, rgba(255, 181, 71, .14), transparent 60%), var(--void);
}
body.theme-explorers h1, body.theme-explorers h2, body.theme-explorers h3 { font-weight: 700; letter-spacing: 0; }
body.theme-explorers .label { letter-spacing: .08em; }
body.theme-explorers .panel, body.theme-explorers .editor { border-radius: 18px; }
body.theme-explorers .btn { border-radius: 999px; }
body.theme-explorers .lesson-body p { font-size: 1.08rem; line-height: 1.6; }
.read-aloud svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

body.theme-explorers .opt { font-family: var(--body); font-size: 1rem; font-weight: 600; }
body.theme-explorers .radar polygon[fill="none"], body.theme-explorers .radar line, body.theme-explorers .map path[stroke="#2b3858"] { stroke: #3d6c9e; }

/* ---------- Rover lab (block coding) ---------- */
.rover-panel { display: grid; gap: 14px; }
.rover-lab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.coder { min-width: 0; }
.board-wrap { display: grid; gap: 10px; justify-items: center; min-width: 0; container-type: inline-size; overflow-x: auto; }
/* Cells size to the board's own column, so a wide map never covers the blocks */
.board { --cell: min(56px, calc((100vw - 72px) / var(--cols))); --cell: min(56px, calc((100cqw - 8px) / var(--cols))); position: relative; display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-template-rows: repeat(var(--rows), var(--cell));
  border-radius: 14px; overflow: hidden; border: 3px solid #e7c58f; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.cell { background: #f3d7a6; border: 1px solid rgba(160, 110, 50, .12); display: grid; place-items: center; }
.cell:nth-child(odd) { background: #efcf99; }
.cell svg, .piece svg { width: 86%; height: 86%; }
.cell.base { background: #d9f2df; }
.piece { display: grid; place-items: center; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 1; }
.piece.crystal.gone { opacity: 0; transform: scale(.3) translateY(-10px); }
.rover { position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); z-index: 2;
  transform: translate(calc(var(--x) * var(--cell)), calc(var(--y) * var(--cell))) rotate(var(--turn)); transition: transform .3s ease; }
.rover.bump { animation: bump .35s; }
.rover.win svg { animation: hop .6s ease 2; }
@keyframes bump { 30% { filter: drop-shadow(0 0 6px #ff6178); } }
@keyframes hop { 50% { transform: translateY(-18%) scale(1.08); } }
.board-status { margin: 0; font-weight: 600; text-align: center; min-height: 1.5em; color: var(--ink); }
.coder { display: grid; gap: 10px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; }
.pblock, .pb { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 12px; padding: 10px 14px; font: 700 .95rem var(--body); color: #0d2238; cursor: pointer; box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.pblock svg, .pb svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pblock:active, .pb:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0, 0, 0, .25); }
.op-forward { background: #7cc8ff; } .op-left, .op-right { background: #b9a4ff; } .op-collect { background: #7fe3c6; }
.op-repeat { background: #ffb547; } .op-if { background: #9be37f; } .op-until { background: #ff9bc2; }
.program-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.program-head .used { font-size: .85rem; color: var(--ink-dim); }
.program-head .used.over { color: var(--signal); font-weight: 700; }
.program { background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 14px; padding: 12px; min-height: 120px; max-height: 420px; overflow: auto; }
.program .empty { margin: 0 0 8px; color: var(--ink-dim); font-size: .95rem; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plist.nested { margin: 6px 0 2px 14px; padding-left: 12px; border-left: 3px solid rgba(255, 255, 255, .18); }
.pitem { display: grid; gap: 2px; }
.phead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pb.sel { outline: 3px solid #fff; outline-offset: 2px; }
.pb.running { outline: 3px solid var(--signal); outline-offset: 2px; transform: scale(1.04); }
.knob { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.knob button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--rivet); background: var(--hull-2); color: var(--ink); font: 700 1.1rem var(--body); cursor: pointer; }
.knob b { min-width: 1.2em; text-align: center; font-size: 1.1rem; }
.phead select { padding: 7px 10px; border-radius: 10px; border: 1px solid var(--rivet); background: var(--hull-2); color: var(--ink); font: inherit; font-size: .9rem; }
.else-label { font-size: .8rem; font-weight: 700; color: #9be37f; margin: 4px 0 0 14px; }
.add-else, .slot-btn { justify-self: start; border: 1px dashed rgba(255, 255, 255, .35); background: transparent; color: var(--ink-dim); border-radius: 10px; padding: 6px 10px; font: 600 .82rem var(--body); cursor: pointer; }
.add-else { margin-left: 14px; }
.slot-btn.on { border-style: solid; border-color: var(--signal); color: var(--signal); }
.tools { gap: 6px; }
.lab-actions { gap: 10px; }
.running-now .palette, .running-now .program { opacity: .6; pointer-events: none; }
/* Quiz */
.kid-quiz .qdots { display: flex; gap: 6px; flex-wrap: wrap; }
.qdot { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--rivet); background: var(--hull-2); color: var(--ink); font: 700 .9rem var(--body); cursor: pointer; }
.qdot.done { background: var(--ok); border-color: var(--ok); color: #0d2238; }
.qdot.now { outline: 3px solid var(--signal); outline-offset: 2px; }
@media (max-width: 860px) {
  .rover-lab { grid-template-columns: minmax(0, 1fr); }
  .pblock span { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) { .rover { transition: none; } .rover.win svg { animation: none; } }

@media (max-width: 860px) {
  .web-split { grid-template-columns: minmax(0, 1fr); }
  .web-split .code-area { border-right: 0; border-bottom: 1px solid var(--rivet); max-height: 320px; }
  .card-view { grid-template-columns: minmax(0, 1fr); }
  .card-view dd { margin-bottom: 6px; }
}

@media (max-width: 860px) {
  .grid-2, .parent-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec-grid, .settings-form .pair { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .streak { justify-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  :root { color-scheme: light; }
  html, body { background: #fff; color: #111; font-size: 11pt; }
  .topbar, .no-print, .filters { display: none !important; }
  main.wrap { padding: 0; max-width: none; }
  .panel { background: #fff; border: 0; padding: 0; }
  .record th, .record td { border: 1px solid #999; color: #111; }
  .record th { background: #eee; }
  .record .empty, .dim { color: #555; }
  .record table { min-width: 0; }
  a { color: #111; text-decoration: none; }
}

/* ---------- AI practice: check the AI (spot) and build the ask (prompt) ---------- */
.practice { display: grid; gap: 14px; }
.practice .qdots { display: flex; gap: 6px; flex-wrap: wrap; }
.chat { display: grid; gap: 10px; }
.msg { border-radius: 14px; padding: 12px 14px; border: 1px solid var(--rivet); display: grid; gap: 8px; max-width: 100%; }
.msg .who { font-size: .78rem; font-weight: 700; color: var(--ink-dim); }
.msg p { line-height: 1.6; }
.msg.you { background: var(--hull-2); justify-self: end; width: min(100%, 620px); border-bottom-right-radius: 4px; }
.msg.you.draft { justify-self: stretch; width: auto; border-style: dashed; }
/* The AI's reply reads like a document handed to you for review */
.msg.ai { background: #f6f3ea; color: #18222e; border-color: #e3dcc8; border-bottom-left-radius: 4px; width: min(100%, 680px); }
.msg.ai .who { color: #5a6676; }
.parts { line-height: 1.9; }
.part { display: inline; font: inherit; color: inherit; background: none; border: 0; padding: 1px 2px; margin: 0; text-align: left; border-radius: 3px; cursor: pointer;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; border-bottom: 1px dotted rgba(24, 34, 46, .35); }
@media (hover: hover) { .part:hover:not(:disabled) { background: rgba(227, 168, 87, .18); } }
.part.picked { background: rgba(227, 168, 87, .42); border-bottom: 2px solid #b8791f; }
.part.flagged { background: rgba(255, 196, 92, .55); border-bottom: 2px solid #b8791f; cursor: default; }
.part:disabled { cursor: default; }
.part:not(.flagged):disabled { border-bottom-color: transparent; }
.part:focus-visible { outline: 2px solid #b8791f; outline-offset: 1px; }
.spot-notes { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.task { font-size: 1.02rem; }
.goal { font-size: 1.02rem; padding: 12px 14px; border-radius: 12px; background: var(--signal-soft); border: 1px solid rgba(255, 138, 61, .35); }
.pieces { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-piece { border: 1px solid var(--rivet); background: var(--hull); color: var(--ink); border-radius: 12px; padding: 10px 12px; text-align: left; font: inherit; line-height: 1.35; max-width: 100%; }
@media (hover: hover) { .ask-piece:hover:not(:disabled) { border-color: var(--plasma); } }
.ask-piece.picked { background: var(--hull-2); border-color: var(--plasma); box-shadow: inset 4px 0 0 var(--plasma); }
.ask-piece:disabled { cursor: default; opacity: .75; }
.ask-piece.picked:disabled { opacity: 1; }
.verdict.stop { border-color: rgba(255, 97, 120, .7); background: rgba(255, 97, 120, .1); }
.verdict ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.cert-note { border: 1px solid rgba(227, 168, 87, .6); background: rgba(227, 168, 87, .12); border-radius: 12px; padding: 12px 14px; }

/* ---------- Adult courses (AI at Work, Pathways): the Academy's own night-and-gold, calm and plain-spoken ---------- */
body.theme-work {
  --void: #031527; --hull: #072742; --hull-2: #0c3557; --rivet: #1b4366;
  --ink: #eef4f9; --ink-dim: #a9c0d4; --signal: #E3A857; --signal-soft: rgba(227, 168, 87, .14);
  --plasma: #5cc8ff; --ok: #5fd19b; --bad: #ff7a8c; --code-bg: #021120; --gutter-ink: #5d7d99;
  --display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --body: "Public Sans", "Segoe UI", system-ui, Arial, sans-serif;
  font-size: 16.5px;
  background: linear-gradient(180deg, #052038 0, var(--void) 420px);
}
body.theme-work h1 { font-weight: 500; letter-spacing: -.02em; }
body.theme-work h2, body.theme-work h3 { font-family: var(--body); font-weight: 700; letter-spacing: -.005em; }
body.theme-work .label { font-family: var(--body); text-transform: none; letter-spacing: 0; font-size: .85rem; font-weight: 600; }
body.theme-work .btn { font-family: var(--body); letter-spacing: 0; border-radius: 10px; }
body.theme-work .btn.go { color: #031527; }
body.theme-work .opt { font-family: var(--body); font-size: 1rem; font-weight: 600; }
body.theme-work .brand-name, body.theme-work .chip, body.theme-work .rank { font-family: var(--body); letter-spacing: 0; }
body.theme-work .lesson-body p { font-size: 1.04rem; line-height: 1.65; max-width: 68ch; }
body.theme-work .map path[stroke="#ff8a3d"], body.theme-work .map circle[stroke="#ff8a3d"] { stroke: #E3A857; }
body.theme-work .map text[fill="#ff8a3d"] { fill: #E3A857; }
body.theme-work .map path[stroke="#2b3858"], body.theme-work .radar polygon[fill="none"], body.theme-work .radar line { stroke: #1f4a70; }
body.theme-work .map text, body.theme-work .radar text { font-family: "Public Sans", system-ui, sans-serif; }
body.theme-work .goal { border-color: rgba(227, 168, 87, .4); }

/* ---------- An adult learner's own page ---------- */
.me-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.cert-status { display: grid; gap: 12px; }
.cert-status .bar { height: 10px; }
.record-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.record-table th, .record-table td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--rivet); }
.record-table th { color: var(--ink-dim); font-weight: 600; }
.record-table td b { display: block; color: var(--signal); }
.record-table ul { margin: 0; padding-left: 16px; display: grid; gap: 3px; }
.form { display: grid; gap: 12px; }
.form .field { display: grid; gap: 5px; }
.form label { font-weight: 600; font-size: .92rem; }
.form input[type=text], .form input[type=password], .form input:not([type]) { background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 8px; padding: 10px 12px; width: 100%; }
.form .hint { font-size: .8rem; color: var(--ink-dim); font-weight: 400; }
.form .error { color: var(--bad); font-size: .85rem; }
.consent-row { display: flex; gap: 10px; align-items: flex-start; font-weight: 400 !important; }
.consent-row input { margin-top: 4px; flex: none; }
@media (max-width: 860px) { .me-grid { grid-template-columns: minmax(0, 1fr); } }
body.theme-work .walk.text .walk-code { font-family: var(--body); white-space: pre-wrap; }
body.theme-work .opt { font-variant-ligatures: normal; }
.msg.source { background: var(--hull); border-style: solid; border-left: 4px solid var(--plasma); font-size: .95rem; }
.msg.ai.review { width: 100%; }
body.theme-work .nav a, body.theme-work .nav button.linkish, body.theme-work .step, body.theme-work .qitem .qname { font-family: var(--body); letter-spacing: 0; }
body.theme-work .nav a, body.theme-work .nav button.linkish { font-weight: 600; }
body.theme-work .qitem .qname { font-weight: 700; font-size: 1.02rem; }
body.theme-work .rank { font-family: var(--body); text-transform: none; letter-spacing: 0; font-size: .95rem; }
body.theme-work .sector-block h1 { font-size: clamp(1.35rem, 3vw, 1.75rem); }
body.theme-work .brand img { flex: none; }
body.theme-work .kind-banner b { font-family: var(--body); letter-spacing: 0; }
/* On phones the header scrolls away, so lessons get the whole screen */
@media (max-width: 600px) { .topbar { position: static; } .nav .whoami { display: none; } .nav a, .nav button.linkish { padding: 8px 10px; } }

/* Thai help notes under a lesson, and reading passages in quizzes */
:lang(th), .thai-help { font-family: var(--body), "Noto Sans Thai", "Leelawadee UI", "Thonburi", "Sukhumvit Set", Tahoma, sans-serif; }
.thai-help { border: 1px solid var(--rivet); border-left: 4px solid var(--plasma); border-radius: 12px; padding: 4px 14px; background: var(--hull); margin: 14px 0; }
.thai-help summary { cursor: pointer; font-weight: 700; padding: 8px 0; color: var(--plasma); }
.thai-help p { margin: 0 0 10px; line-height: 1.75; }
.thai-help .terms { display: grid; gap: 6px; margin: 4px 0 12px; }
.thai-help .terms div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 10px; border-top: 1px solid var(--rivet); padding-top: 6px; }
.thai-help .terms dt { font-weight: 700; }
.thai-help .terms dd { margin: 0; color: var(--ink-dim); }
.passage { background: #f6f3ea; color: #18222e; border-radius: 12px; padding: 14px 16px; border: 1px solid #e3dcc8; line-height: 1.65; max-height: 52vh; overflow: auto; }
.passage p { margin: 0 0 10px; }
.passage p:last-child { margin-bottom: 0; }
body.theme-explorers .passage { max-height: none; font-size: 1.04rem; } /* younger readers: show the whole story, no box to scroll inside */

/* Adult courses and payments (v1.17) */
.form select { background: var(--code-bg); border: 1px solid var(--rivet); border-radius: 8px; padding: 10px 12px; width: 100%; color: inherit; font: inherit; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding-bottom: 10px; border-bottom: 1px solid var(--rivet); }
.plain-list li:last-child { border-bottom: 0; }
/* Course switcher on the home page for learners with more than one course */
.course-switch { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.course-switch form { display: inline; }
.course-switch a, .course-switch button { font: 600 .86rem var(--sans, inherit); padding: 7px 12px; border-radius: 999px; border: 1px solid var(--rivet); background: transparent; color: inherit; cursor: pointer; text-decoration: none; }
.course-switch a[aria-current="page"], .course-switch button[aria-pressed="true"] { background: var(--signal); border-color: var(--signal); color: var(--bg, #fff); }

/* First-day welcome (v1.19) */
.first-day { display: grid; gap: 14px; border-color: var(--signal); }
.first-day h2 { margin: 0; }
.fd-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; counter-reset: fd; }
.fd-steps li { display: grid; gap: 4px; padding: 14px; border-radius: 10px; background: var(--hull-2); border: 1px solid var(--rivet); counter-increment: fd; }
.fd-steps li b::before { content: counter(fd) ". "; color: var(--signal); }
.fd-steps li span { color: var(--ink-dim); font-size: .92rem; }
.fd-notes { margin: 0; padding-left: 1.2rem; display: grid; gap: 4px; color: var(--ink-dim); }
.first-day .row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) { .fd-steps { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Learners with more than one course ---------- */
.tone-teal { --tone: #16a37f; }
.tone-orange { --tone: #f07a2e; }
.tone-violet { --tone: #7c5cd8; }
.tone-blue { --tone: #3d6be0; }
.tone-rose { --tone: #d6467a; }
.tone-gold { --tone: #d99a2b; }
.tone-plum { --tone: #9b3fb5; }
.tone-eucalypt { --tone: #4f8a3c; }
.tone-sky { --tone: #1e9ad6; }
.tone-ocean { --tone: #0e6f8f; }
.tone-indigo { --tone: #4f46c8; } .tone-coral { --tone: #e0603f; } .tone-forest { --tone: #2f7d4f; } .tone-clay { --tone: #b0643a; } .tone-navy { --tone: #1f4e79; } .tone-ruby { --tone: #b3263e; }
.my-courses { display: grid; gap: 12px; }
.my-courses-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.mc { display: grid; gap: 10px; align-content: start; padding: 16px 18px; border-radius: 14px; background: var(--hull); border: 1px solid var(--rivet); border-top: 4px solid var(--tone, var(--plasma)); }
.mc.current { border-color: var(--signal); border-top-color: var(--tone, var(--signal)); box-shadow: 0 0 0 1px var(--signal) inset; }
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mc-top h3 { margin: 0; font-size: 1.1rem; }
.mc p { margin: 0; }
.mc form { margin: 0; }
.mc .bar { height: 8px; }
.mc .bar i { background: var(--tone, var(--plasma)); }
.mc .btn { justify-self: start; }
.mc-actions { align-items: center; gap: 14px; margin-top: auto; }
.mc-actions .btn { margin: 0; }
.flash + .my-courses, .flash + .course-switch { margin-top: 6px; }

/* iPhone and iPad (Safari) */
@media (hover: none) and (pointer: coarse) {
  /* Fields under 16 px make Safari zoom in when tapped, and the page stays zoomed */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: max(16px, 1em) !important; }
}
@supports (-webkit-touch-callout: none) {
  input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-height: 2.9em; }
  input::-webkit-date-and-time-value { text-align: left; }
}
/* The visible height on phones, not the height behind Safari's toolbars */
@supports (min-height: 100dvh) { body { min-height: 100dvh; } }
@media (hover: none) and (pointer: coarse) {
  /* The code editor grows to 16 px with the other fields, so its line numbers must too */
  .gutter { font-size: 16px; }
}
/* Worked examples on a phone: the note sits under its line of code instead of off the side */
@media (max-width: 560px) {
  .walk-row { grid-template-columns: 30px minmax(0, 1fr); }
  .walk-code { white-space: pre-wrap; overflow-wrap: anywhere; }
  .walk-note { grid-column: 2; border-left: 0; padding: 0 12px 8px 4px; }
}

/* Tutoring: an adult learner's sessions */
.sessions { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.session { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 6px 18px; align-items: start; padding: 14px 16px; border: 1px solid var(--rivet); border-radius: var(--r); background: var(--hull-2); border-left: 4px solid var(--signal); }
.session.cancelled, .session.expired { opacity: .7; border-left-color: var(--rivet); }
.s-when { display: grid; line-height: 1.25; }
.s-when span { opacity: .75; font-size: .9rem; }
.s-what { display: grid; gap: 2px; min-width: 0; }
.s-act { display: grid; gap: 6px; justify-items: end; text-align: right; }
.s-notes { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--rivet); white-space: pre-line; }
.s-cancel summary { cursor: pointer; font-size: .9rem; }
.s-cancel form { margin-top: 8px; text-align: left; }
.warn-text { font-weight: 600; }
@media (max-width: 640px) {
  .session { grid-template-columns: minmax(0, 1fr); }
  .s-act { justify-items: start; text-align: left; }
}
.tut-next { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; border-left: 4px solid var(--signal); }
.tut-next > div { display: grid; gap: 2px; }

/* Listening practice */
.listen { display: grid; gap: 10px; padding: 12px 14px; border: 1px dashed var(--rivet); border-radius: var(--r); margin: 6px 0 12px; }
.listen .btn svg { width: 16px; height: 16px; fill: currentColor; }
.listen .btn.playing { filter: brightness(.9); }
.listen.off { border-style: solid; }
.script summary { cursor: pointer; font-size: .9rem; opacity: .85; }
.transcript { display: grid; gap: 4px; margin-top: 8px; font-size: .95rem; }
.transcript p { margin: 0; }
.opts.letters { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
.opts.letters .opt { font-size: 1.2rem; font-weight: 700; text-align: center; }
.tm-note { font-size: .78rem; opacity: .75; padding-top: 18px; padding-bottom: 24px; }
.passage-table { border-collapse: collapse; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.passage-table th, .passage-table td { border: 1px solid rgba(13, 27, 42, .25); padding: 6px 12px; text-align: left; }
.passage-table th { font-weight: 700; background: rgba(13, 27, 42, .06); }
.gap-answer { display: grid; gap: 8px; margin-top: 4px; }
.gap-input { font: 600 1.1rem var(--mono, monospace); padding: 12px 14px; min-width: 0; flex: 1 1 220px; max-width: 360px; border-radius: var(--r); }
.gap-input.right { border-color: rgba(76, 201, 160, .8); }
.speak-timer { margin: 0; font-size: .95rem; }
.speak-timer b { font-family: var(--mono, monospace); margin-right: 6px; }
.speak-timer.talking b { color: var(--signal); }
/* Text examples wrap instead of scrolling sideways */
.walk.text .walk-row { grid-template-columns: 34px minmax(0, 1.5fr) minmax(160px, 1fr); }
.walk.text .walk-code { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) { .walk.text .walk-row { grid-template-columns: 30px minmax(0, 1fr); } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A parent or staff member looking at a learner's lessons */
.viewing-bar { background: #ffd166; color: #1b1b1b; position: sticky; top: 0; z-index: 30; }
.viewing-bar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px 18px; flex-wrap: wrap; padding-block: 10px; font-size: .92rem; }
.viewing-bar form { margin: 0; }
.viewing-bar .btn { background: #1b1b1b; color: #fff; border-color: #1b1b1b; }
.viewing-bar + .topbar { top: 0; position: relative; }

/* Help and support: conversation and lists */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.msg { border-radius: 12px; padding: 12px 14px; border: 1px solid var(--rivet); background: var(--hull-2); max-width: 760px; }
.msg.from-staff { border-left: 4px solid var(--plasma); }
.msg.mine { margin-left: auto; width: min(100%, 680px); }
.msg-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .82rem; margin-bottom: 6px; }
.msg-head span { opacity: .7; }
.msg-body { white-space: pre-line; overflow-wrap: anywhere; }
.help-form { margin-top: 16px; }
.ticket-list { list-style: none; margin: 0; padding: 0; display: grid; }
.ticket-list a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--rivet); color: inherit; text-decoration: none; flex-wrap: wrap; }
.ticket-list a:hover b { text-decoration: underline; }
.ticket-list .tk-main { display: grid; gap: 2px; min-width: 0; }
.ticket-list a { display: grid; grid-template-columns: 1fr auto; }
.ticket-list a .tiny { grid-column: 1; }
.ticket-list a .chip { grid-row: 1 / span 2; grid-column: 2; }
.help-strip { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-top: 18px; }
.help-strip p { margin: 0; max-width: 70ch; }
.help-answer { border-color: var(--ok, #4cc9a0); }

/* Help: screenshots, files and context */
.msg-files { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.msg-files li { display: grid; gap: 4px; max-width: 240px; }
.msg-shot { display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--rivet); background: #fff; }
.msg-shot img { display: block; max-width: 240px; max-height: 180px; width: auto; height: auto; }
.msg-doc { display: inline-block; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--rivet); font-weight: 600; overflow-wrap: anywhere; }
.msg-body a { overflow-wrap: anywhere; }
.field label .opt { border: 0; background: none; padding: 0; border-radius: 0; font: inherit; font-weight: 400; opacity: .7; text-align: left; }
.field input[type="file"] { padding: 8px; cursor: pointer; font-size: .9rem; }
.field input[type="file"]::file-selector-button { margin-right: 10px; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--rivet); background: var(--hull-2); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.help-context { display: grid; gap: 4px; padding: 12px 14px; margin: 0 0 14px; border-radius: 10px; border: 1px dashed var(--rivet); }
.help-context summary { cursor: pointer; margin-top: 4px; }
.help-context .work-snap { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font: .82rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f3f6fa; border-radius: 8px; padding: 10px; max-height: 320px; overflow: auto; }
.field.choice { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.field.choice legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
.field .opt { font-weight: 400; opacity: .7; }
.msg.from-parent { border-left: 4px solid #e3a857; }

/* ---------- Hands-on tasks: match, order, sort, tap (interact.js) ---------- */
.ia { display: grid; gap: 14px; margin-top: 8px; }
.ia-how { margin: 0; color: var(--ink-dim); font-size: .95rem; }
.ia-hint { color: var(--ink-dim); font-size: .9rem; font-style: italic; }
.ia-card { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--rivet); background: var(--hull-2); color: var(--ink); font: 600 1rem/1.3 var(--body); text-align: left; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 2px 0 var(--rivet); transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease; }
.ia-card:hover:not(:disabled) { border-color: var(--plasma); transform: translateY(-1px); }
.ia-card.sel { border-color: var(--signal); background: var(--signal-soft); box-shadow: 0 0 0 3px var(--signal-soft); }
.ia-card.ok, .ia-card:disabled.ok { border-color: var(--ok); background: rgba(76, 201, 160, .14); color: var(--ink); cursor: default; box-shadow: none; }
.ia-card.lifting { opacity: .35; }
.ia-card:disabled { cursor: default; }
.ia-ghost { position: fixed; left: 0; top: 0; z-index: 1000; pointer-events: none; margin: 0; border-color: var(--signal); box-shadow: 0 14px 30px rgba(0, 0, 0, .35); transform-origin: center; rotate: -2deg; }
.ia-bank { display: flex; flex-wrap: wrap; gap: 10px; min-height: 64px; padding: 12px; border-radius: 14px; border: 2px dashed var(--rivet); background: var(--hull); }
.ia-bank.over, .ia-slot.over, .ia-bin.over, .ia-row.over { border-color: var(--signal); background: var(--signal-soft); }
.ia-foot { align-items: center; gap: 12px; }

/* match */
.ia-match { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ia-pair { display: grid; grid-template-columns: minmax(110px, .9fr) minmax(0, 2fr); gap: 12px; align-items: center; }
.ia-term { font: 700 1.08rem/1.25 var(--display); padding: 10px 14px; border-radius: 12px; background: var(--hull); border: 2px solid var(--rivet); }
.ia-pair.ok .ia-term { border-color: var(--ok); }
.ia-slot { min-height: 56px; padding: 5px; border-radius: 14px; border: 2px dashed var(--rivet); display: flex; align-items: center; }
.ia-slot .ia-hint { padding-left: 10px; }
.ia-slot.filled { border-style: solid; }
.ia-slot .ia-card { width: 100%; }

/* order */
.ia-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: none; }
.ia-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 4px; border-radius: 14px; border: 2px solid transparent; }
.ia-row .ia-card { width: 100%; }
.ia-num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 700 .95rem/1 var(--display); background: var(--hull); border: 2px solid var(--rivet); }
.ia-row.ok .ia-num { border-color: var(--ok); color: var(--ok); }
.ia-move { display: flex; gap: 4px; }
.ia-arrow { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 2px solid var(--rivet); background: var(--hull); color: var(--ink); cursor: pointer; }
.ia-arrow:disabled { opacity: .35; cursor: default; }
.ia-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* sort */
.ia-bins { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ia-bins-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ia-bins-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ia-bin { min-height: 140px; padding: 12px; border-radius: 14px; border: 2px solid var(--rivet); background: var(--hull); display: grid; align-content: start; gap: 10px; }
.ia-bin h3 { font-size: 1.02rem; padding-bottom: 8px; border-bottom: 2px solid var(--rivet); }
.ia-bin-cards { display: flex; flex-wrap: wrap; gap: 8px; }

/* tap */
.ia-tap { margin: 0; font-size: 1.25rem; line-height: 2.3; }
.ia-word { font: inherit; color: inherit; background: none; border: 0; padding: 2px 4px; margin: 0; border-radius: 6px; border-bottom: 3px solid transparent; cursor: pointer; }
.ia-word:hover:not(:disabled) { background: var(--hull-2); }
.ia-word.on { background: var(--signal-soft); border-bottom-color: var(--signal); }
.ia-word.ok { background: rgba(76, 201, 160, .18); border-bottom-color: var(--ok); cursor: default; }
.ia-word.bad { border-bottom-color: var(--bad); color: var(--bad); text-decoration: line-through; }

.ia.is-done .ia-card { cursor: default; }
@media (max-width: 640px) {
  .ia-pair { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .ia-bins, .ia-bins-3, .ia-bins-4 { grid-template-columns: minmax(0, 1fr); }
  .ia-bin { min-height: 96px; }
  .ia-tap { font-size: 1.12rem; }
}
@media (prefers-reduced-motion: reduce) { .ia-card { transition: none; } .ia-ghost { rotate: 0deg; } }

/* Pictures in lessons and quiz questions (v1.44) */
.pic { margin: 18px 0; }
.pic img { display: block; width: 100%; max-width: 720px; height: auto; aspect-ratio: 16 / 10; object-fit: contain; border-radius: 16px; border: 2px solid var(--rivet); background: var(--hull-2); }
.pic figcaption { margin-top: 8px; color: var(--ink-dim); font-size: .95rem; line-height: 1.45; max-width: 68ch; }
.pic-say { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.quiz-pic { margin: 6px 0 14px; }
.quiz-pic img { max-width: 560px; }

/* Short written answers (v1.46) */
.write-from { margin: 4px 0 12px; padding: 12px 14px; border-radius: 12px; background: #f6f3ea; color: #18222e; border: 1px solid #e3dcc8; font-size: 1.05rem; line-height: 1.5; }
.write-from .label { display: block; margin-bottom: 4px; color: #6b5d3f; }
.write-answer { display: grid; gap: 8px; margin-top: 6px; }
.write-answer textarea { width: 100%; min-height: 96px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--rivet); background: var(--hull-2); color: var(--ink); font: 500 1.05rem/1.5 var(--body); resize: vertical; }
.write-answer textarea:focus { outline: 3px solid var(--signal); outline-offset: 2px; }
.write-answer textarea:disabled { opacity: 1; border-color: var(--ok); }
.write-answer .row { justify-content: space-between; align-items: center; }
.write-model { margin: 8px 0; padding: 10px 12px; border-left: 4px solid var(--ok); background: rgba(123, 228, 149, .08); border-radius: 0 10px 10px 0; }
.write-model .label { display: block; margin-bottom: 2px; }
.verdict ul { margin: 6px 0 0 1.1em; padding: 0; }
.verdict li { margin: 2px 0; }

/* My certificates */
.cert-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cert-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }

/* Exams: answers are saved without showing right or wrong until the end */
.ia-exam .ia-card.ok, .ia-exam .ia-card:disabled.ok { border-color: var(--plasma); background: rgba(124, 140, 255, .12); }
.ia-exam .ia-pair.ok .ia-term, .ia-exam .ia-row.ok .ia-num { border-color: var(--plasma); color: inherit; }
.ia-exam .ia-word.ok { background: rgba(124, 140, 255, .16); border-bottom-color: var(--plasma); }
.opt.picked { border-color: var(--plasma); background: rgba(124, 140, 255, .16); }
.verdict.saved { border-color: var(--plasma); }
.exam-results .exam-mark { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.exam-results .exam-mark .num { font-size: clamp(2.6rem, 8vw, 3.6rem); line-height: 1; }
.exam-review { display: grid; gap: .8rem; padding-left: 1.2rem; }
.exam-review li { padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--rivet); }
.exam-review li.miss { border-color: rgba(255, 122, 122, .45); }
.exam-review .label { display: block; margin-bottom: .1rem; }
.exam-mark-line b { font-size: 1.4rem; }
.qdot.answered { background: rgba(124, 140, 255, .28); border-color: var(--plasma); }

/* ---- Brand v1.57: the learning halo ---- */
.halo { flex: none; display: block; }
.topbar .brand .halo { width: 44px; height: 44px; }
.mc-top { align-items: center; justify-content: flex-start; }
.mc-top h3 { flex: 1; min-width: 0; }
.exam-results .exam-mark { position: relative; }
.exam-seal { display: flex; align-items: center; gap: 16px; margin: 0 0 14px; }
.exam-seal .seal { flex: none; width: 112px; height: 112px; }
.exam-seal p { margin: 0; }
.cert-list .cert-note { display: flex; align-items: center; justify-content: flex-start; gap: 16px; flex-wrap: wrap; }
.cert-list .cert-note .cert-text { flex: 1; min-width: 0; }

/* v1.62: new replies to a learner's help questions */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.nav-help { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.nav-badge { font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--signal); color: #1a0d03; font: 700 .72rem/20px var(--body, sans-serif); text-align: center; letter-spacing: 0; }
.nav-badge[hidden] { display: none; }
.nav-badge.pop { animation: badge-pop .5s ease-out 2; }
@keyframes badge-pop { 50% { transform: scale(1.3); } }
@media (prefers-reduced-motion: reduce) { .nav-badge.pop { animation: none; } }
.new-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--signal); margin-right: 8px; vertical-align: middle; }
.chip.new { color: #1a0d03; background: var(--signal); border-color: var(--signal); }
.ticket-list li.unread b { color: var(--ink); }
.ticket-list li.unread a { border-left: 3px solid var(--signal); padding-left: 10px; }
.help-page.has-new .help-list { order: -1; }
.help-toast { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-color: rgba(255, 138, 61, .6); margin: 14px 0 20px; }

/* v1.65.2: a help form that's sending */
.help-form button.is-sending { opacity: .65; cursor: progress; }
