/* Switchcraft — layout: a reading column (~68ch) with full-bleed "lab bench" sims that break wider.
   Palette: cool wafer-blue neutrals, copper for conductors & accents, cyan for electrons, amber for logic HIGH. */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #e9edf4;
  --ink: #131a2b;
  --muted: #586379;
  --line: #d6dce7;
  --copper: #b45a22;
  --copper-soft: #f6e3d5;
  --electron: #0b84c6;
  --hole: #c2367a;
  --high: #e58a12;
  --high-glow: rgba(229, 138, 18, .35);
  --low: #8b95a8;
  --good: #1d8a4e;
  --good-soft: #dcf2e5;
  --bad: #c7353b;
  --bad-soft: #fbe2e3;
  --focus: #2b62d9;
  --shadow: 0 1px 2px rgba(19, 26, 43, .06), 0 6px 24px rgba(19, 26, 43, .06);

  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --step--1: .875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: 2.2rem;
  --step-4: clamp(2.4rem, 6vw, 3.8rem);

  --radius: 10px;
  --col: 44rem;
  --wide: 62rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1220; --surface: #151c2d; --surface-2: #1c2539; --ink: #e7ebf3; --muted: #95a1b9; --line: #29334b;
    --copper: #e5915a; --copper-soft: #3a2619; --electron: #4cc3f5; --hole: #f07ab3; --high: #ffb13d; --high-glow: rgba(255, 177, 61, .35);
    --low: #56617a; --good: #4cc884; --good-soft: #15301f; --bad: #ff6b70; --bad-soft: #3a1a1d; --focus: #7aa5ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1220; --surface: #151c2d; --surface-2: #1c2539; --ink: #e7ebf3; --muted: #95a1b9; --line: #29334b;
  --copper: #e5915a; --copper-soft: #3a2619; --electron: #4cc3f5; --hole: #f07ab3; --high: #ffb13d; --high-glow: rgba(255, 177, 61, .35);
  --low: #56617a; --good: #4cc884; --good-soft: #15301f; --bad: #ff6b70; --bad-soft: #3a1a1d; --focus: #7aa5ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 30px rgba(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(--f-body); font-size: var(--step-0); line-height: 1.6;
}
a { color: var(--copper); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
code, .mono, kbd { font-family: var(--f-mono); font-size: .9em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: var(--wide); margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; }
.brand-mark { display: inline-grid; grid-template-columns: repeat(2, 7px); gap: 3px; }
.brand-mark i { width: 7px; height: 7px; border-radius: 2px; background: var(--low); }
.brand-mark i.on { background: var(--high); box-shadow: 0 0 6px var(--high-glow); }
.topbar .spacer { flex: 1; }
.xp-pill { font-family: var(--f-mono); font-size: var(--step--1); padding: .25rem .6rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); white-space: nowrap; }
.icon-btn { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; cursor: pointer; font-size: var(--step--1); white-space: nowrap; }
.icon-btn:hover { border-color: var(--copper); }
.nav-link { text-decoration: none; color: var(--muted); font-size: var(--step--1); font-weight: 700; }
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--ink); }
@media (max-width: 520px) { .hide-sm { display: none; } }

main { padding-inline: 16px; padding-block: 0 5rem; }
.col { max-width: var(--col); margin-inline: auto; }
.wide { max-width: var(--wide); margin-inline: auto; }

/* ---------- Home ---------- */
.hero { max-width: var(--wide); margin: 0 auto; padding-block: 3rem 2rem; display: grid; grid-template-columns: 1.1fr .9fr; gap: 2.5rem; align-items: center; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; padding-block: 2rem 1rem; gap: 1.5rem; } }
.hero h1 { font-size: var(--step-4); font-weight: 800; letter-spacing: -.03em; }
.hero h1 em { font-style: normal; color: var(--copper); }
.hero p.lede { font-size: var(--step-1); color: var(--muted); max-width: 34rem; margin: 1rem 0 1.5rem; }
.eyebrow { font-family: var(--f-mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--copper); font-weight: 600; }
.cta-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: .4rem; border-radius: 8px; padding: .65rem 1.1rem; font-weight: 700; cursor: pointer; text-decoration: none; border: 1px solid transparent; font-size: var(--step-0); }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--copper); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--copper); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: var(--step--1); }

.byte-toy { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; box-shadow: var(--shadow); }
.byte-toy .label { font-size: var(--step--1); color: var(--muted); }
.switch-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: .4rem; margin: .8rem 0; }
.bit-switch { aspect-ratio: 1 / 1.6; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; position: relative; display: grid; place-items: center; font-family: var(--f-mono); font-weight: 700; font-size: 1.1rem; color: var(--low); transition: background .15s, color .15s, box-shadow .15s; max-width: 100%; }
.bit-switch.on { background: var(--high); color: #1d1300; box-shadow: 0 0 18px var(--high-glow); border-color: var(--high); }
.bit-switch small { position: absolute; bottom: 4px; font-size: .62rem; font-weight: 500; color: inherit; opacity: .75; }
.readouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.readout { background: var(--surface-2); border-radius: 8px; padding: .5rem .6rem; min-width: 0; }
.readout b { display: block; font-family: var(--f-mono); font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.readout span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 2.5rem 0 1rem; }
.section-head h2 { font-size: var(--step-2); }
.section-head p { margin: 0; color: var(--muted); }

/* ---------- Course map ---------- */
.map { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
@media (max-width: 820px) { .map { grid-template-columns: 1fr; } }
.track-title { font-family: var(--f-mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
.trunk { position: relative; display: grid; gap: .5rem; }
.trunk::before { content: ""; position: absolute; left: 19px; top: 10px; bottom: 10px; width: 2px; background: repeating-linear-gradient(var(--copper) 0 6px, transparent 6px 10px); opacity: .5; }
.node { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: .75rem; align-items: center; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem .6rem .5rem; transition: border-color .15s, transform .15s; }
.node:hover { border-color: var(--copper); transform: translateX(2px); }
.node .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-mono); font-weight: 700; font-size: .85rem; background: var(--surface-2); border: 2px solid var(--line); margin-left: 4px; z-index: 1; }
.node.done .num { background: var(--high); border-color: var(--high); color: #1d1300; box-shadow: 0 0 10px var(--high-glow); }
.node.started .num { border-color: var(--high); }
.node h3 { font-size: 1.02rem; font-weight: 700; }
.node p { margin: 0; color: var(--muted); font-size: var(--step--1); line-height: 1.4; }
.node .meta { font-family: var(--f-mono); font-size: .72rem; color: var(--muted); white-space: nowrap; }
.node.soon { opacity: .55; pointer-events: none; }
.node.soon .meta { color: var(--copper); }
.branches { display: grid; gap: .75rem; align-content: start; }
.branch { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.branch h3 { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.branch .from { font-family: var(--f-mono); font-size: .72rem; color: var(--copper); }
.branch ul { margin: .4rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: var(--step--1); }
.branch .node { margin-top: .5rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--copper); display: inline-block; flex: none; }

/* ---------- Lesson page ---------- */
.lesson-head { max-width: var(--col); margin: 0 auto; padding-block: 2.5rem 1rem; }
.lesson-head h1 { font-size: var(--step-3); font-weight: 800; letter-spacing: -.02em; margin: .3rem 0 .6rem; }
.lesson-head .tagline { color: var(--muted); font-size: var(--step-1); margin: 0; }
.progress-track { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 1.25rem; }
.progress-track i { display: block; height: 100%; background: var(--high); width: 0; transition: width .4s; }
.lesson-tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .9rem; font-size: var(--step--1); color: var(--muted); }
.toggle { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--copper); width: 1rem; height: 1rem; }

.step { max-width: var(--col); margin: 0 auto; padding-block: 1.5rem; border-top: 1px solid var(--line); animation: rise .45s ease both; }
.step:first-of-type { border-top: 0; }
.step h2 { font-size: var(--step-2); margin-bottom: .75rem; display: flex; gap: .6rem; align-items: baseline; }
.step h2 .sn { font-family: var(--f-mono); font-size: .8rem; color: var(--copper); font-weight: 600; }
.step p { margin: .7rem 0; }
.step ul, .step ol { padding-left: 1.3rem; }
.step li { margin: .3rem 0; }
@keyframes rise { from { opacity: .001; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .step { animation: none; } * { transition: none !important; } }

.callout { border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1rem 0; background: var(--surface); border: 1px solid var(--line); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .tag { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; display: block; margin-bottom: .3rem; }
.callout.key { background: var(--copper-soft); border-color: transparent; }
.callout.key .tag { color: var(--copper); }
.callout.analogy .tag { color: var(--electron); }
.callout.myth .tag { color: var(--hole); }
details.deeper { border: 1px dashed var(--line); border-radius: var(--radius); margin: 1rem 0; background: var(--surface); }
details.deeper summary { cursor: pointer; padding: .7rem 1rem; font-weight: 700; font-size: var(--step--1); list-style: none; display: flex; align-items: center; gap: .5rem; color: var(--muted); }
details.deeper summary::-webkit-details-marker { display: none; }
details.deeper summary::before { content: "+"; font-family: var(--f-mono); width: 1.2rem; height: 1.2rem; display: grid; place-items: center; border-radius: 4px; background: var(--surface-2); color: var(--copper); }
details.deeper[open] summary::before { content: "−"; }
details.deeper .body { padding: 0 1rem .8rem; }
details.deeper .body > :first-child { margin-top: 0; }

/* Lab bench: sims break out wider than the text column */
.bench { max-width: var(--wide); margin: 1.25rem auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.step .bench { margin-inline: calc((min(var(--wide), 100vw - 32px) - min(var(--col), 100vw - 32px)) / -2); }
.bench-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.bench-head .title { font-family: var(--f-mono); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.bench-body { padding: 1rem; }
.bench canvas { display: block; width: 100%; border-radius: 8px; touch-action: pan-x pan-y; }
.canvas-scroll { overflow-x: auto; max-width: 100%; }
@media (max-width: 640px) { .canvas-scroll canvas { min-width: 580px; } }
.task { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem 1rem; border-top: 1px solid var(--line); font-size: var(--step--1); background: var(--surface); }
.task .badge { flex: none; font-family: var(--f-mono); font-size: .7rem; font-weight: 700; padding: .15rem .45rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); letter-spacing: .06em; }
.task.done .badge { background: var(--good); color: #fff; }
.task.done { background: var(--good-soft); }

.controls { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-top: .8rem; }
.ctrl { display: grid; gap: .15rem; min-width: 10rem; flex: 1 1 10rem; }
.ctrl label { font-size: .78rem; color: var(--muted); display: flex; justify-content: space-between; gap: .5rem; }
.ctrl label b { font-family: var(--f-mono); color: var(--ink); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--copper); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--surface); border: 0; border-right: 1px solid var(--line); padding: .4rem .75rem; cursor: pointer; font-size: var(--step--1); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.stats { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.stat { background: var(--surface-2); border-radius: 8px; padding: .35rem .7rem; font-size: .8rem; color: var(--muted); }
.stat b { font-family: var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; margin-left: .3rem; }
.two-up { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 700px) { .two-up { grid-template-columns: 1fr; } }
.hint { font-size: .8rem; color: var(--muted); margin-top: .4rem; }

/* ---------- Quiz ---------- */
.quiz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin: 1.25rem 0; }
.quiz .qtag { font-family: var(--f-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--copper); font-weight: 700; }
.quiz .q { font-weight: 700; margin: .25rem 0 .7rem; }
.choices { display: grid; gap: .45rem; }
.choice { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .8rem; cursor: pointer; display: flex; gap: .6rem; align-items: flex-start; line-height: 1.4; }
.choice:hover:not(:disabled) { border-color: var(--copper); }
.choice .k { font-family: var(--f-mono); font-size: .8rem; color: var(--muted); flex: none; padding-top: .1rem; }
.choice.right { border-color: var(--good); background: var(--good-soft); }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }
.feedback { margin-top: .7rem; font-size: var(--step--1); padding: .6rem .8rem; border-radius: 8px; }
.feedback.ok { background: var(--good-soft); }
.feedback.no { background: var(--bad-soft); }
.num-input { display: flex; gap: .5rem; flex-wrap: wrap; }
.num-input input { font: inherit; font-family: var(--f-mono); padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); width: 12rem; max-width: 100%; }

.continue-row { max-width: var(--col); margin: 0 auto; padding-block: 1rem 2rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.continue-row .why { color: var(--muted); font-size: var(--step--1); }

/* Checkpoint */
.checkpoint { max-width: var(--col); margin: 1rem auto; border: 2px solid var(--ink); border-radius: 14px; padding: 1.25rem; background: var(--surface); }
.checkpoint h2 { font-size: var(--step-2); }
.score { font-family: var(--f-display); font-size: var(--step-3); font-weight: 800; }
.chapter-nav { max-width: var(--col); margin: 2rem auto 0; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-weight: 700; z-index: 50; transition: transform .3s; max-width: calc(100vw - 32px); }
.toast.show { transform: translateX(-50%) translateY(0); }

/* Tables */
.tbl-wrap { overflow-x: auto; margin: 1rem 0; }
table.tt { border-collapse: collapse; font-family: var(--f-mono); font-size: .9rem; }
table.tt th, table.tt td { border: 1px solid var(--line); padding: .3rem .7rem; text-align: center; }
table.tt th { background: var(--surface-2); font-weight: 700; }
table.tt tr.hl td { background: var(--copper-soft); }
table.tt td.v1 { color: var(--high); font-weight: 700; }
table.tt tr.pass td:last-child { color: var(--good); }
table.tt tr.fail td:last-child { color: var(--bad); }

.footer { max-width: var(--wide); margin: 4rem auto 0; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--step--1); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- Circuit sandbox ---------- */
.sbx { display: grid; grid-template-columns: 9rem minmax(0, 1fr); }
@media (max-width: 640px) { .sbx { grid-template-columns: 1fr; } }
.sbx-palette { border-right: 1px solid var(--line); padding: .6rem; display: flex; flex-direction: column; gap: .35rem; background: var(--surface-2); }
@media (max-width: 640px) { .sbx-palette { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); } .sbx-palette .howto { display: none; } }
.sbx-palette button { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: .35rem .5rem; cursor: pointer; font-family: var(--f-mono); font-size: .78rem; font-weight: 700; text-align: left; }
.sbx-palette button:hover { border-color: var(--copper); }
.sbx-palette .sep { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: .35rem; }
.sbx-stage { position: relative; min-width: 0; }
.sbx-stage svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.sbx-bar { display: flex; gap: .4rem; flex-wrap: wrap; padding: .5rem .75rem; border-top: 1px solid var(--line); align-items: center; }
.sbx-bar .grow { flex: 1; }
.sbx .wire { fill: none; stroke: var(--low); stroke-width: 3; stroke-linecap: round; }
.sbx .wire.on { stroke: var(--high); }
.sbx .wire.sel { stroke-dasharray: 6 4; }
.sbx .wire-hit { fill: none; stroke: transparent; stroke-width: 14; cursor: pointer; }
.sbx .pin { fill: var(--surface); stroke: var(--muted); stroke-width: 2; cursor: crosshair; }
.sbx .pin:hover, .sbx .pin.armed { fill: var(--copper); stroke: var(--copper); }
.sbx .pin.on { fill: var(--high); stroke: var(--high); }
.sbx .body { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.sbx .part.sel .body { stroke: var(--copper); stroke-width: 3; }
.sbx .part { cursor: grab; }
.sbx .lbl { font-family: var(--f-mono); font-size: 12px; font-weight: 700; fill: var(--ink); pointer-events: none; }
.sbx .sub { font-family: var(--f-mono); font-size: 10px; fill: var(--muted); pointer-events: none; }
.sbx .lamp { fill: var(--surface-2); stroke: var(--ink); stroke-width: 2; }
.sbx .lamp.on { fill: var(--high); filter: drop-shadow(0 0 6px var(--high-glow)); }
.sbx .sw { fill: var(--surface-2); stroke: var(--ink); stroke-width: 2; cursor: pointer; }
.sbx .sw.on { fill: var(--high); }
.sbx .grid-dot { fill: var(--line); }
.sbx .ghost { stroke: var(--copper); stroke-width: 2; stroke-dasharray: 4 4; fill: none; pointer-events: none; }

/* misc sim bits */
.lamp-big { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--ink); transition: background .15s, box-shadow .15s; }
.lamp-big.on { background: var(--high); box-shadow: 0 0 30px var(--high-glow); }
.kbd-bytes { font-family: var(--f-mono); font-size: .85rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.kbd-bytes .cell { background: var(--surface-2); border-radius: 6px; padding: .3rem .45rem; text-align: center; min-width: 4.4rem; }
.kbd-bytes .cell b { display: block; font-size: 1.05rem; color: var(--ink); }
.kbd-bytes .cell span { color: var(--muted); font-size: .72rem; display: block; }
.text-input { font: inherit; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); width: 100%; }
.text-input.mono { font-family: var(--f-mono); }

/* ---------- Zoom dive ---------- */
.zoom-cap { margin-top: .7rem; display: grid; gap: .25rem; min-height: 5.6rem; }
.zoom-cap-top { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.zoom-cap b { font-family: var(--f-display); font-size: 1.35rem; letter-spacing: -.01em; }
.zoom-scale { font-family: var(--f-mono); font-size: .78rem; color: var(--copper); background: var(--copper-soft); padding: .1rem .5rem; border-radius: 99px; }
.zoom-ch { font-family: var(--f-mono); font-size: .75rem; color: var(--muted); }
.zoom-cap.swap { animation: capIn .45s ease both; }
@keyframes capIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.zoom-ctrl { align-items: center; }
.zoom-dots { display: flex; gap: 6px; margin-left: auto; }
.zoom-dots button { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); background: transparent; padding: 0; cursor: pointer; transition: transform .2s, background .2s, border-color .2s; }
.zoom-dots button.on { background: var(--copper); border-color: var(--copper); transform: scale(1.25); }
.dive { margin-block: 1rem 3rem; }
.dive .bench { margin-inline: 0; }

/* ---------- Motion ---------- */
.rv { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1); }
.rv.in { opacity: 1; transform: none; }
.choice.right { animation: pop .38s cubic-bezier(.3,1.6,.5,1); }
.choice.wrong { animation: shake .35s ease; }
.feedback { animation: rise .3s ease both; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.035); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.task.just { animation: taskdone .9s ease; }
.task.just .badge { animation: pop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes taskdone { 0% { background: var(--surface); } 30% { background: var(--good-soft); box-shadow: inset 0 0 0 2px var(--good); } 100% { box-shadow: inset 0 0 0 0 transparent; } }
.continue-row .btn-primary:not(:disabled) { animation: ready 1.6s ease-in-out 3; }
@keyframes ready { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 6px var(--copper-soft); } }
.xp-pill.bump { animation: xpbump .6s cubic-bezier(.3,1.6,.5,1); border-color: var(--high); }
@keyframes xpbump { 0% { transform: scale(1); } 35% { transform: scale(1.22); background: var(--high); color: #1d1300; } 100% { transform: scale(1); } }
.trunk .node, .branch { animation: rise .5s ease both; }
.trunk .node:nth-child(2) { animation-delay: .04s } .trunk .node:nth-child(3) { animation-delay: .08s } .trunk .node:nth-child(4) { animation-delay: .12s } .trunk .node:nth-child(5) { animation-delay: .16s } .trunk .node:nth-child(6) { animation-delay: .2s } .trunk .node:nth-child(7) { animation-delay: .24s } .trunk .node:nth-child(8) { animation-delay: .28s } .trunk .node:nth-child(9) { animation-delay: .32s } .trunk .node:nth-child(10) { animation-delay: .36s } .trunk .node:nth-child(11) { animation-delay: .4s }
.branch:nth-child(2) { animation-delay: .1s } .branch:nth-child(3) { animation-delay: .2s } .branch:nth-child(4) { animation-delay: .3s } .branch:nth-child(5) { animation-delay: .4s }
.score.count { font-variant-numeric: tabular-nums; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; width: 100%; height: 100%; }
.hero h1 em { background: linear-gradient(90deg, var(--copper), var(--high), var(--copper)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 6s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .rv { opacity: 1; transform: none; }
  .choice.right, .choice.wrong, .feedback, .task.just, .task.just .badge, .continue-row .btn-primary, .xp-pill.bump, .trunk .node, .branch, .hero h1 em, .zoom-cap.swap { animation: none !important; }
}
.swipe-hint { font-size: .75rem; color: var(--copper); font-weight: 700; margin-bottom: .35rem; transition: opacity .4s; }
.swipe-hint.seen { opacity: .35; }
.canvas-scroll { scroll-snap-type: x proximity; }

/* ---------- Voice journey ---------- */
.vj-row { display: flex; gap: .4rem; overflow-x: auto; padding: .3rem .1rem .7rem; scroll-snap-type: x proximity; }
.vj-pill { flex: none; display: grid; justify-items: center; gap: .15rem; min-width: 84px; padding: .5rem .4rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: .72rem; font-weight: 700; color: var(--muted); text-align: center; transition: transform .3s cubic-bezier(.3,1.5,.5,1), background .3s, border-color .3s, color .3s; scroll-snap-align: center; }
.vj-pill .vj-e { font-size: 1.4rem; filter: grayscale(1); opacity: .6; transition: filter .3s, opacity .3s; }
.vj-pill.past { color: var(--ink); border-color: var(--copper); }
.vj-pill.past .vj-e { filter: none; opacity: .9; }
.vj-pill.on { color: var(--ink); background: var(--copper-soft); border-color: var(--copper); transform: translateY(-4px) scale(1.06); }
.vj-pill.on .vj-e { filter: none; opacity: 1; }

/* ---------- Accounts ---------- */
.topbar-inner { position: relative; }
.acct-btn.in { width: 2rem; height: 2rem; padding: 0; border-radius: 50%; background: var(--copper); color: #fff; border-color: var(--copper); font-weight: 800; }
.acct-menu { position: absolute; right: 16px; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: .8rem; display: grid; gap: .5rem; min-width: 240px; max-width: calc(100vw - 32px); z-index: 40; animation: rise .2s ease both; }
.acct-email { font-weight: 700; overflow-wrap: anywhere; }
dialog.signin { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); padding: 1.5rem; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.signin::backdrop { background: rgba(10, 14, 24, .55); }
dialog.signin h2 { font-size: var(--step-2); margin-bottom: .3rem; }
dialog.signin form { display: grid; gap: .6rem; margin-top: 1rem; }
dialog.signin .or { text-align: center; color: var(--muted); font-size: var(--step--1); margin: .6rem 0; }
dialog.signin .btn { justify-content: center; }
dialog.signin .dlg-links { margin: .8rem 0 0; font-size: var(--step--1); color: var(--muted); text-align: center; }
.linkish { border: 0; background: none; padding: 0; color: var(--copper); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.dlg-x { position: absolute; right: .8rem; top: .7rem; border: 0; background: none; color: var(--muted); font-size: 1rem; cursor: pointer; }
.locked { max-width: var(--col); margin: 0 auto; padding-block: 4rem 3rem; display: grid; gap: .8rem; }
.locked h1 { font-size: var(--step-4); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .8rem; margin: 1rem 0 1.5rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; display: grid; gap: .3rem; }
.stat-tile span { color: var(--muted); font-size: var(--step--1); }
.stat-tile b { font-family: var(--f-display); font-size: var(--step-3); font-variant-numeric: tabular-nums; }
.admin-table td { font-variant-numeric: tabular-nums; }
.meter { display: inline-block; width: 70px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; vertical-align: middle; margin-right: .4rem; }
.meter i { display: block; height: 100%; background: var(--good); }
