/* UNSW Brain Gym — shared styles for every page.
   Order: tokens (light) → dark overrides → base → lesson (focus mode) → home/course → phones. */

:root {
  color-scheme: light;
  --ground: #F2F5F2;
  --surface: #FFFFFF;
  --surface-2: #EAF0EC;
  --ink: #17202A;
  --muted: #56626D;
  --line: #D7DFDA;
  --accent: #0E6B74;
  --accent-ink: #FFFFFF;
  --accent-soft: #DCEFEE;
  --sun-soft: #FFF5DE;
  --flip: #A4500A;
  --flip-soft: #FBEAD6;
  --good: #1D7A3B;
  --good-soft: #E0F2E5;
  --bad: #B42318;
  --bad-soft: #FCE6E2;
  --shadow: 0 1px 2px rgba(20, 30, 40, .05), 0 8px 24px rgba(20, 30, 40, .05);
  --radius: 16px;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #10151A; --surface: #182027; --surface-2: #1F2931; --ink: #E6EBEE; --muted: #9AA7B2; --line: #2A343C;
    --accent: #5CC3CB; --accent-ink: #0B1418; --accent-soft: #15353A; --sun-soft: #2E2815;
    --flip: #F0A65C; --flip-soft: #3A2A17; --good: #6BD08C; --good-soft: #173424; --bad: #FF8A7E; --bad-soft: #3D1C19;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #10151A; --surface: #182027; --surface-2: #1F2931; --ink: #E6EBEE; --muted: #9AA7B2; --line: #2A343C;
  --accent: #5CC3CB; --accent-ink: #0B1418; --accent-soft: #15353A; --sun-soft: #2E2815;
  --flip: #F0A65C; --flip-soft: #3A2A17; --good: #6BD08C; --good-soft: #173424; --bad: #FF8A7E; --bad-soft: #3D1C19;
  --shadow: none;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.6; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border-radius: 6px; padding: .08em .38em; white-space: nowrap; }
strong, b { font-weight: 700; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; text-wrap: balance; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 980px; margin: 0 auto; padding-inline: 16px; }
.wrap.narrow { max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.eyebrow { font-size: 12.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.lab { display: block; font-size: 12.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
/* grid/flex children may shrink below their content (wide tables scroll inside .scroll) */
.stack > *, .step > *, .learn > *, .turn > *, .items > *, .cards > *, .card-grid > *, .card-watch > *, .plan > *, .scorecard > *, .item > * { min-width: 0; }
.scroll { max-width: 100%; }

/* ---------- top bar ---------- */
.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .wrap { display: flex; align-items: center; gap: 10px; min-height: 50px; flex-wrap: wrap; padding-block: 6px; }
.brand { font-family: var(--display); font-weight: 800; font-size: 18px; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
.crumbs { color: var(--muted); font-size: 14px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

/* =====================================================================
   LESSON — focus mode
   ===================================================================== */
.lessonbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--ground); border-bottom: 1px solid var(--line); }
.lessonbar .wrap { padding-block: 8px 12px; display: grid; gap: 8px; }
.lessonbar .wrap > * { min-width: 0; }
.lb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lb-step { flex: 1 1 auto; font-size: 14.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.lb-step b { color: var(--ink); }
.lb-count { font-family: var(--mono); font-size: 12.5px; font-weight: 700; background: var(--surface-2); padding: 2px 7px; border-radius: 6px; margin-right: 4px; }
.lb-kind { color: var(--accent); font-weight: 700; margin-right: 2px; }
.segbar { display: flex; gap: 4px; }
.sg { flex: 1; height: 8px; border-radius: 999px; background: var(--line); position: relative; }
.sg::after { content: ""; position: absolute; inset: -8px 0; }   /* bigger tap target */
.sg.part { background: linear-gradient(90deg, var(--accent) 50%, var(--line) 50%); }
.sg.done { background: var(--accent); }
.sg.cur { outline: 2px solid var(--accent); outline-offset: 2px; }

.menu { position: relative; flex: none; }
.menu summary { list-style: none; cursor: pointer; font-size: 14px; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { border-color: var(--accent); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); width: 270px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .12); padding: 8px; display: grid; gap: 4px; }
.menu .tog { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; cursor: pointer; }
.menu .tog:hover, .menu-btn:hover { background: var(--surface-2); }
.menu .tog input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); }
.menu .tog span { display: grid; font-size: 15px; }
.menu .tog small { color: var(--muted); font-size: 13px; }
.menu-btn { text-align: left; border: 0; background: none; padding: 10px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; }
.menu-btn.subtle { font-weight: 400; color: var(--muted); font-size: 14px; }

.step { display: grid; gap: 18px; padding-block: 26px 10px; }
.step-head { display: grid; gap: 6px; }
.step-head h2 { font-size: clamp(26px, 4.6vw, 34px); font-weight: 800; }
.step-head .eyebrow { color: var(--accent); }
.step-sub { color: var(--muted); max-width: 62ch; }

/* learn part */
.learn { display: grid; gap: 14px; }
.card-picture { background: var(--sun-soft); border-radius: var(--radius); padding: 16px 18px; font-size: 18px; line-height: 1.6; }
.card-official { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 12px; padding: 14px 16px; }
.card-grid { display: grid; gap: 4px; }
.card-watch { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.card-watch .wq { font-weight: 700; }
.wsteps { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; }
.card-watch .final { font-weight: 700; background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; }
.card-trap { display: grid; gap: 4px; }
.trap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trap > div { border-radius: 12px; padding: 12px 14px; }
.trap .tempt { background: var(--bad-soft); }
.trap .right { background: var(--good-soft); }
.t-lab { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.tempt .t-lab { color: var(--bad); }
.right .t-lab { color: var(--good); }
.trap-test { font-size: 15px; color: var(--muted); margin-top: 6px; }
.remember { background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; }
.remember p { font-weight: 700; font-size: 18px; }
.callout { border-radius: 12px; padding: 12px 16px; display: grid; gap: 4px; background: var(--sun-soft); }
.callout h3 { font-size: 17px; }

/* try part */
.turn { display: grid; gap: 12px; padding-top: 6px; }
.turn-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-top: 2px solid var(--line); padding-top: 16px; }
.step-practice .turn-head, .step-table .turn-head { border-top: 0; padding-top: 0; }
.turn-head h3 { font-size: 22px; font-weight: 800; }
.turn-head p { color: var(--muted); font-size: 15px; margin-top: 2px; }
.cnt { display: inline-block; font-family: var(--body); font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 9px; vertical-align: middle; }
.mini-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); flex: none; }
.mini-seg button { border: 0; background: none; padding: 5px 12px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.mini-seg button:hover { background: var(--surface-2); color: var(--ink); }
.items { display: grid; gap: 12px; }

.item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.item.is-got { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.item.is-miss { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.item-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: var(--surface); font-weight: 700; font-size: 13.5px; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; }
.lchip { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.lchip code { background: transparent; padding: 0; color: var(--ink); font-weight: 700; }
.badge { margin-left: auto; font-size: 14px; }
.q { font-size: 17.5px; }
.hint, .pickall { font-size: 14.5px; color: var(--muted); }
.hint::before { content: "💡 "; }
body.hard .hint { display: none; }
body.hard td[data-hideable] > * { visibility: hidden; }
body.hard td[data-hideable] { position: relative; }
body.hard td[data-hideable]::after { content: "hidden in hard mode"; position: absolute; left: 10px; top: 10px; font-size: 12px; color: var(--muted); font-style: italic; }

.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 1.5px dashed var(--accent); color: var(--accent); background: transparent; border-radius: 10px; padding: 7px 14px; font-size: 14.5px; font-weight: 700; cursor: pointer; }
.btn[aria-expanded="true"] { border-style: solid; }
.btn.solid { background: var(--accent); color: var(--accent-ink); border-style: solid; }
.btn.small { padding: 3px 10px; font-size: 13px; }

.opts { display: grid; gap: 7px; }
.opt { text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 11px; padding: 8px 12px; cursor: pointer; font-size: 16px; display: flex; gap: 10px; align-items: center; }
.opt:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.opt .ol { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 7px; background: var(--surface-2); font-family: var(--mono); font-weight: 700; font-size: 12.5px; color: var(--muted); flex: none; }
.opt.mono .ot { font-family: var(--mono); font-size: 15px; }
.opt.mono .ot code { background: none; padding: 0; font-size: 1em; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .ol { background: var(--accent); color: var(--accent-ink); }
.opt.ok { border-color: var(--good); background: var(--good-soft); }
.opt.ok .ol { background: var(--good); color: var(--surface); }
.opt.no { border-color: var(--bad); background: var(--bad-soft); }
.opt.no .ol { background: var(--bad); color: var(--surface); }
.opt.missed { border-color: var(--good); border-style: dashed; }
.opt.missed::after { content: "← also right"; margin-left: auto; color: var(--good); font-weight: 700; font-size: 13px; }

.ans { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; padding: 10px 14px; display: grid; gap: 6px; }
.ans .a { font-weight: 700; }
.ans .a::before { content: "✅ "; }
.ans .why::before { content: "Why: "; font-weight: 700; }
.ans .wrong { background: var(--flip-soft); border-radius: 8px; padding: 6px 10px; font-size: 15px; }
.ans .wrong::before { content: "🪤 "; }
.ans ol { margin: 0; padding-left: 1.3em; }
.markrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.mk { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 11px; cursor: pointer; font-size: 13px; font-weight: 700; }
.mk[aria-pressed="true"][data-m="got"] { background: var(--good); color: var(--surface); border-color: var(--good); }
.mk[aria-pressed="true"][data-m="miss"] { background: var(--bad); color: var(--surface); border-color: var(--bad); }

/* visible tables */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.grid { border-collapse: collapse; width: 100%; font-size: 15.5px; }
table.grid th, table.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.hl { font-weight: 700; color: var(--bad); background: var(--bad-soft); }

/* reveal table (the Decoder) */
table.rtable { border-collapse: collapse; width: 100%; min-width: 720px; font-size: 15.5px; }
table.rtable th, table.rtable td { padding: 10px 12px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); text-align: left; vertical-align: top; }
table.rtable th:first-child, table.rtable td:first-child { border-left: 0; }
table.rtable th { font-size: 12.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); }
table.rtable tr:last-child td { border-bottom: 0; }
.cell { display: grid; gap: 7px; position: relative; }
.cell .rv { justify-self: start; }
.cell .badge { position: absolute; right: 0; top: 0; }
.cans { display: grid; gap: 5px; }
.cans .logic code { font-size: 1em; font-weight: 700; }
.tag { justify-self: start; font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.tag.same { background: var(--accent-soft); color: var(--accent); }
.tag.rev { background: var(--flip-soft); color: var(--flip); }
.mini { display: flex; gap: 4px; }
.mini .mk { padding: 1px 8px; font-size: 12px; }

/* step footer */
.stepfoot { display: grid; gap: 14px; padding-block: 18px 50px; border-top: 1px solid var(--line); margin-top: 10px; }
.stepscore { color: var(--muted); font-size: 15px; text-align: center; }
.navrow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.navbtn { display: grid; gap: 2px; text-decoration: none; border-radius: 14px; padding: 12px 16px; font-weight: 700; font-size: 16px; line-height: 1.3; color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.navbtn small { font-size: 12.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.navbtn.next { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.navrow .navbtn.next { text-align: right; grid-column: 2; }
.navbtn.next small { color: var(--accent-ink); opacity: .8; }
.navbtn:hover { filter: brightness(1.06); }

/* start step */
.start-hero { display: grid; gap: 12px; padding-top: 6px; }
.start-hero h1 { font-size: clamp(32px, 6vw, 46px); font-weight: 800; }
.goal { font-size: 18.5px; max-width: 62ch; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; }
.cta { display: grid; gap: 8px; justify-items: start; margin-top: 6px; }
.navbtn.big { min-width: min(100%, 360px); text-align: left; font-size: 18px; padding: 14px 20px; }
.linkish { font-size: 14px; color: var(--muted); }
.plan, .summary-card, .links-card, .scorecard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.plan h2, .summary-card h2, .links-card h2 { font-size: 21px; }
.plan-label { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.path { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.prow { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); padding: 8px 10px; border-radius: 12px; }
.prow:hover { background: var(--surface-2); }
.pnum { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-family: var(--display); }
.ptxt { display: grid; }
.ptxt small { color: var(--muted); font-size: 14px; line-height: 1.45; }
.pst { display: flex; gap: 6px; font-size: 13px; white-space: nowrap; }
.st-got { color: var(--good); font-weight: 700; }
.st-miss { color: var(--bad); font-weight: 700; }
.st-of, .st-none { color: var(--muted); }
.summary-card ul { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.summary-card li { padding-left: 30px; position: relative; }
.summary-card li::before { content: "🔑"; position: absolute; left: 0; }
.summary-card.recap { background: var(--good-soft); border-color: transparent; }
.summary-card.recap li::before { content: "✓"; color: var(--good); font-weight: 800; left: 8px; }
.howto { color: var(--muted); font-size: 15px; text-align: center; padding-bottom: 40px; }

/* finish step */
.bigscore { display: flex; align-items: center; gap: 18px; }
.ring { --p: 0; width: 88px; height: 88px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring span { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: var(--surface); font-family: var(--display); font-weight: 800; font-size: 19px; }
.scorecard > .navbtn { justify-self: start; text-align: left; }
.links-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.links-card li { display: grid; gap: 2px; }
.links-card .src { font-size: 13.5px; color: var(--muted); }
.sources { color: var(--muted); font-size: 14px; }

/* review mode: only ❌ questions, across all steps */
.review-banner { background: var(--flip-soft); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 8px; margin-top: 24px; }
.review-banner .navbtn { justify-self: start; text-align: left; }
body.misses .teach, body.misses .stepfoot, body.misses .step-sub { display: none !important; }
body.misses .step:not(.has-miss) { display: none; }
body.misses .block:not(.has-miss) { display: none; }
body.misses .item:not(.is-miss), body.misses tr.rrow:not(.has-miss) { display: none; }
body.misses .cell-item:not(.is-miss) { display: none; }

/* =====================================================================
   HOME + COURSE
   ===================================================================== */
.home-hero { padding-block: 34px 8px; display: grid; gap: 10px; }
.home-hero h1 { font-size: clamp(34px, 6.4vw, 52px); font-weight: 800; }
.home-hero h1 span { color: var(--accent); }
.stack { display: grid; gap: 28px; padding-block: 16px 20px; }
.sec-title { font-size: 20px; margin-bottom: 12px; }
.cards { display: grid; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: grid; gap: 8px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
.card h3 { font-size: 21px; }
.card .sub { color: var(--muted); font-size: 15px; }
.bar { display: block; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.continue { display: grid; gap: 2px; text-decoration: none; color: var(--accent-ink); background: var(--accent); border-radius: var(--radius); padding: 14px 18px; }
.continue .eyebrow { color: var(--accent-ink); opacity: .8; }
.continue b { font-family: var(--display); font-size: 20px; }
.how { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.how li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 4px; font-size: 14.5px; align-content: start; }
.how b { font-family: var(--display); font-size: 16.5px; }
.how span { color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 25px; top: 20px; bottom: 20px; width: 2px; background: var(--line); }
.tl-card { position: relative; display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: start; text-decoration: none; color: var(--ink); }
.tl-code { position: relative; z-index: 1; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; font-family: var(--display); font-weight: 800; font-size: 16px; background: var(--accent); color: var(--accent-ink); }
.tl-body { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); min-width: 0; }
a.tl-card:hover .tl-body { border-color: var(--accent); }
.tl-title { font-weight: 700; font-size: 18px; font-family: var(--display); }
.tl-sum { color: var(--muted); font-size: 14.5px; }
.tl-prog { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.tl-st { display: flex; gap: 6px; font-size: 13px; }
.timeline li.soon .tl-code { background: var(--surface-2); color: var(--muted); }
.timeline li.soon .tl-body { box-shadow: none; background: transparent; border-style: dashed; }
.tl-soon { font-size: 13px; font-weight: 700; color: var(--muted); }
.kind { font-family: var(--body); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; padding: 2px 8px; border-radius: 999px; background: var(--flip-soft); color: var(--flip); margin-left: 8px; vertical-align: middle; }
.later { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.later summary { cursor: pointer; font-weight: 700; font-family: var(--display); font-size: 17px; }
.later ul { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.later li { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.later li .tl-code { width: 40px; height: 40px; border-radius: 12px; font-size: 13.5px; background: var(--surface-2); color: var(--muted); }
.later li > span:last-child { display: grid; }
.later small { color: var(--muted); font-size: 14px; }
.sitefoot { padding-block: 10px 50px; }
.err { padding: 30px 0; }

/* =====================================================================
   PHONES
   ===================================================================== */
@media (max-width: 640px) {
  body { font-size: 16.5px; }
  .trap { grid-template-columns: 1fr; }
  .card-picture { font-size: 17px; }
  .how { grid-template-columns: 1fr 1fr; }
  .navbtn { font-size: 15px; padding: 10px 12px; }
  .prow { grid-template-columns: 32px 1fr; }
  .pst { grid-column: 2; }
  .lb-kind { display: none; }
  /* the Decoder table becomes one card per row */
  .scroll:has(table.rtable) { overflow: visible; border: 0; background: transparent; }
  table.rtable { min-width: 0; }
  table.rtable, table.rtable tbody, table.rtable tr, table.rtable td { display: block; width: 100%; }
  table.rtable thead { display: none; }
  table.rtable tr { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin-bottom: 10px; overflow: hidden; }
  table.rtable td { border-left: 0; border-bottom: 1px dashed var(--line); }
  table.rtable td:first-child { display: none; }
  table.rtable td::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
  body.hard table.rtable td[data-hideable] { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .step:not([hidden]) { animation: rise .22s ease-out; }
  .ans, .cans, .wsteps li:not([hidden]), .final:not([hidden]) { animation: pop .18s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  @keyframes pop { from { opacity: .3; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
}

/* a grid inside a question (K-maps, truth tables) */
.q-grid { margin: 4px 0 12px; }
.q-grid .lab { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted, #5b6770); margin-bottom: 6px; }
.q-grid table.grid td, .q-grid table.grid th { text-align: center; }

/* group headings on the course path */
.timeline li.tl-group { position: relative; z-index: 1; margin: 10px 0 0 64px; }
.timeline li.tl-group:first-child { margin-top: 0; }
.timeline li.tl-group span { font-size: 12.5px; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
@media (max-width: 420px) { .timeline li.tl-group { margin-left: 60px; } }

/* long formula chips wrap at spaces (short ones stay on one line) */
code.long { white-space: normal; overflow-wrap: anywhere; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.q-grid table.grid th { text-transform: none; letter-spacing: 0; }
