/* ---------- tokens ---------- */
:root {
  --paper: #F3F5F6; --panel: #FFFFFF; --ink: #13203A; --ink-2: #44506A; --ink-3: #6B7690;
  --rule: #D6DDE2; --grid: #E3E8EC; --cobalt: #2451B7; --cobalt-2: #E4EBFA; --orange: #E0561F;
  --orange-2: #FCE9E1; --green: #2F8F5B; --green-2: #E2F2E9; --obstacle: #2B3752; --code-bg: #FBFCFD;
  --shadow: 0 1px 0 rgba(19, 32, 58, .04);
  --font: 'Archivo', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111A2B; --panel: #16213A; --ink: #E8EDF4; --ink-2: #B6C0D2; --ink-3: #8A96AD;
    --rule: #2A3752; --grid: #1D2942; --cobalt: #7FA3F0; --cobalt-2: #1E2D52; --orange: #FF7A45;
    --orange-2: #3A2320; --green: #5BC48A; --green-2: #17342A; --obstacle: #8491AA; --code-bg: #131D33;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #111A2B; --panel: #16213A; --ink: #E8EDF4; --ink-2: #B6C0D2; --ink-3: #8A96AD;
  --rule: #2A3752; --grid: #1D2942; --cobalt: #7FA3F0; --cobalt-2: #1E2D52; --orange: #FF7A45;
  --orange-2: #3A2320; --green: #5BC48A; --green-2: #17342A; --obstacle: #8491AA; --code-bg: #131D33;
  color-scheme: dark;
}
:root { box-sizing: border-box; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: inherit; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
img, svg, canvas { max-width: 100%; }
a { color: var(--cobalt); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: .45em; font: 600 15px/1 var(--font); padding: .72em 1.05em; border-radius: var(--r); border: 1px solid var(--rule); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--cobalt); }
:root[data-theme="dark"] .btn-primary { color: #0F1729; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #0F1729; } }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); padding-left: .6em; padding-right: .6em; }
.btn-quiet:hover { color: var(--ink); border-color: var(--rule); }
.btn-sm { font-size: 13px; padding: .55em .8em; }
kbd { font: 12px var(--mono); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--ink-2); }
.email-form { display: flex; flex-wrap: wrap; gap: 8px; }
.email-form input { flex: 1 1 200px; min-width: 0; font: 15px var(--font); padding: .65em .8em; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--ink); }
.form-msg { flex-basis: 100%; font-size: 14px; min-height: 1.3em; margin: 0; color: var(--ink-2); }
.form-msg[data-state="ok"] { color: var(--green); }
.form-msg[data-state="error"] { color: var(--orange); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 12px 24px; border-bottom: 1px solid var(--rule); background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 18px/1 var(--font); font-stretch: 85%; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.crumbs { font-size: 14px; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.topbar .spacer { flex: 1; }
.topbar nav a { font-size: 14px; color: var(--ink-2); text-decoration: none; margin-left: 16px; }
.topbar nav a:hover { color: var(--ink); }

/* ---------- landing ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 48px; align-items: center; max-width: 1240px; margin: 0 auto; padding: 72px 32px 56px; }
.hero h1 { font-size: clamp(38px, 5.2vw, 64px); line-height: 1.02; font-weight: 800; font-stretch: 78%; letter-spacing: -.02em; margin: 0 0 20px; max-width: 13ch; }
.hero p.lede { font-size: 19px; color: var(--ink-2); max-width: 36ch; margin: 0 0 28px; }
.hero .ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-sim { position: relative; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.hero-sim canvas { display: block; width: 100%; height: auto; aspect-ratio: 10 / 7; }
.hero-sim figcaption { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); padding: 10px 14px; border-top: 1px solid var(--rule); }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--cobalt); }
.key i.dash { border-top: 2px dashed var(--ink-3); }
.key i.boundary { border-top: 2px dashed var(--orange); }
.section { max-width: 1240px; margin: 0 auto; padding: 48px 32px; }
.section h2 { font-size: 30px; font-weight: 800; font-stretch: 82%; letter-spacing: -.01em; margin: 0 0 8px; }
.section > p.sub { color: var(--ink-2); margin: 0 0 28px; max-width: 60ch; }
.loop { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--rule); border-radius: 10px; background: var(--panel); margin: 0; padding: 0; list-style: none; counter-reset: loop; }
.loop li { padding: 18px 18px 20px; border-left: 1px solid var(--rule); counter-increment: loop; }
.loop li:first-child { border-left: 0; }
.loop li::before { content: counter(loop); display: block; font: 800 28px/1 var(--font); font-stretch: 75%; color: var(--cobalt); margin-bottom: 10px; }
.loop strong { display: block; font-size: 16px; margin-bottom: 4px; }
.loop span { font-size: 14px; color: var(--ink-2); }
.catalog { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--rule); }
.track { padding: 20px 24px 8px 0; }
.track h3 { font-size: 15px; font-weight: 700; color: var(--ink-3); margin: 0 0 10px; }
.labitem { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); color: var(--ink-3); }
.labitem a { font-weight: 700; color: var(--ink); font-size: 17px; }
.labitem .tag { font-size: 13px; white-space: nowrap; }
.labitem .tag.free { color: var(--green); font-weight: 700; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; }
.readlist a { display: block; padding: 14px 0; border-bottom: 1px solid var(--rule); font-weight: 700; color: var(--ink); text-decoration: none; }
.readlist a span { display: block; font-weight: 400; color: var(--ink-2); font-size: 15px; }
.readlist a:hover { color: var(--cobalt); }
.footer { border-top: 1px solid var(--rule); padding: 28px 32px 40px; color: var(--ink-3); font-size: 14px; }
.footer .inner { max-width: 1240px; margin: 0 auto; display: flex; gap: 24px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--ink-2); }
.footer-links { display: inline-flex; gap: 18px; }

/* ---------- lab workspace ---------- */
body.lab-page { background: var(--paper); }
.lab { display: grid; grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(360px, 460px); gap: 0; min-height: calc(100vh - 57px); border-bottom: 1px solid var(--rule); }
.pane { min-width: 0; }
.pane-brief { border-right: 1px solid var(--rule); background: var(--panel); padding: 20px 22px 28px; overflow: auto; max-height: calc(100vh - 57px); position: sticky; top: 0; }
.pane-sim { padding: 16px 18px 22px; overflow: hidden; }
.pane-code { border-left: 1px solid var(--rule); background: var(--panel); display: flex; flex-direction: column; max-height: calc(100vh - 57px); position: sticky; top: 0; }
.pane-brief h1 { font-size: 26px; line-height: 1.12; font-weight: 800; font-stretch: 82%; letter-spacing: -.01em; margin: 4px 0 12px; }
.pane-brief h2 { font-size: 15px; margin: 22px 0 6px; }
.pane-brief p, .pane-brief li { font-size: 15px; color: var(--ink-2); }
.pane-brief ol { padding-left: 1.2em; margin: 6px 0; }
.stages { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; margin: 6px 0 4px; }
.stages button { font: 600 14px var(--font); padding: .5em .9em; border: 0; border-left: 1px solid var(--rule); background: var(--panel); color: var(--ink-2); cursor: pointer; }
.stages button:first-child { border-left: 0; }
.stages button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.stages button .done { color: var(--green); margin-left: 4px; }
.stages button[aria-pressed="true"] .done { color: #8FE0B2; }
.stage-summary { margin: 6px 0 0; }
details.theory { border-top: 1px solid var(--rule); padding: 10px 0; }
details.theory:last-of-type { border-bottom: 1px solid var(--rule); }
details.theory summary { cursor: pointer; font-weight: 700; font-size: 15px; list-style: none; display: flex; justify-content: space-between; gap: 8px; }
details.theory summary::-webkit-details-marker { display: none; }
details.theory summary::after { content: '+'; color: var(--ink-3); font-weight: 400; }
details.theory[open] summary::after { content: '−'; }
details.theory p { margin: 8px 0 4px; }
.math { font-family: var(--mono); font-size: 13.5px; background: var(--code-bg); border: 1px solid var(--rule); border-radius: 4px; padding: 8px 10px; margin: 8px 0; overflow-x: auto; white-space: pre; color: var(--ink); }
table.api { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
table.api td { border-top: 1px solid var(--rule); padding: 6px 4px; vertical-align: top; color: var(--ink-2); }
table.api td:first-child { font-family: var(--mono); color: var(--ink); white-space: nowrap; padding-right: 10px; }

.simbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.simbar .title { font-weight: 700; font-size: 15px; }
.simbar .spacer { flex: 1; }
.viewport { position: relative; background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.viewport canvas { display: block; width: 100%; height: auto; aspect-ratio: 10 / 7; }
.overlay-msg { position: absolute; left: 12px; top: 12px; right: 12px; display: flex; gap: 8px; pointer-events: none; }
.pill { pointer-events: auto; font-size: 13px; font-weight: 600; padding: 5px 9px; border-radius: 999px; background: var(--panel); border: 1px solid var(--rule); color: var(--ink-2); }
.pill.bad { color: var(--orange); border-color: var(--orange); background: var(--orange-2); }
.pill.good { color: var(--green); border-color: var(--green); background: var(--green-2); }
.playback { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.playback input[type=range] { flex: 1; accent-color: var(--cobalt); }
.playback .time { font-size: 13px; color: var(--ink-2); min-width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.speed { font: 600 13px var(--font); border: 1px solid var(--rule); background: var(--panel); color: var(--ink-2); border-radius: var(--r); padding: .35em .6em; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin: 6px 0 12px; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--cobalt); margin-right: 2px; vertical-align: 0; }
.plots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.plot { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px 6px; }
.plot h3 { font-size: 13px; margin: 0 0 4px; color: var(--ink-2); font-weight: 600; }
.plot canvas { width: 100%; height: 110px; display: block; }

.results { margin-top: 14px; background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; }
.results[hidden] { display: none; }
.score-row { display: grid; grid-template-columns: auto repeat(5, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); }
.score-row > div { padding: 12px 14px; border-left: 1px solid var(--rule); }
.score-row > div:first-child { border-left: 0; }
.score-total { font: 800 38px/1 var(--font); font-stretch: 78%; font-variant-numeric: tabular-nums; }
.score-total small { font-size: 16px; color: var(--ink-3); font-weight: 600; }
.verdict { font-weight: 700; font-size: 14px; margin-top: 4px; }
.verdict.pass { color: var(--green); } .verdict.fail { color: var(--orange); }
.metric b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric b small { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.metric span { font-size: 12.5px; color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--rule); align-items: center; }
.chips .lbl { font-size: 13px; color: var(--ink-2); margin-right: 6px; }
.chip { width: 30px; height: 30px; border-radius: 5px; border: 1px solid var(--rule); background: var(--panel); font: 600 12px var(--font); color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.chip.pass { background: var(--green-2); border-color: var(--green); color: var(--green); }
.chip.unsafe { background: var(--orange-2); border-color: var(--orange); color: var(--orange); }
.chip.nogoal { background: var(--paper); border-color: var(--ink-3); border-style: dashed; }
.chip[aria-current="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.feedback { padding: 14px 16px 16px; }
.feedback h3 { font-size: 16px; margin: 0 0 8px; }
.feedback p, .feedback li { font-size: 15px; color: var(--ink-2); margin: 4px 0; }
.feedback ul { padding-left: 1.1em; margin: 6px 0; }
.feedback .next { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.share { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.progress { height: 3px; background: var(--grid); border-radius: 2px; overflow: hidden; margin: 8px 0 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--cobalt); transition: width .15s linear; }

.codebar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.codebar .file { font: 600 13px var(--mono); color: var(--ink-2); }
.codebar .spacer { flex: 1; }
.pystatus { font-size: 12.5px; color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.pystatus::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.pystatus[data-state="ready"]::before { background: var(--green); }
.pystatus[data-state="error"]::before { background: var(--orange); }
.editor-wrap { flex: 1; min-height: 320px; overflow: hidden; display: flex; }
.actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--rule); flex-wrap: wrap; align-items: center; }
.actions .hint-k { font-size: 12.5px; color: var(--ink-3); margin-left: auto; }
.errbox { margin: 0 12px 10px; padding: 10px 12px; border: 1px solid var(--orange); background: var(--orange-2); border-radius: 6px; font: 13px/1.45 var(--mono); color: var(--ink); white-space: pre-wrap; }
.errbox[hidden] { display: none; }
.helpzone { border-top: 1px solid var(--rule); padding: 10px 12px 14px; max-height: 38vh; overflow: auto; }
.helpzone h3 { font-size: 14px; margin: 4px 0 8px; display: flex; justify-content: space-between; align-items: center; }
.hint { border-left: 3px solid var(--cobalt); padding: 6px 10px; margin: 8px 0; background: var(--cobalt-2); border-radius: 0 4px 4px 0; font-size: 14px; color: var(--ink); white-space: pre-wrap; }
.hint b { display: block; font-size: 12.5px; color: var(--cobalt); margin-bottom: 2px; }
.solution p { font-size: 14px; color: var(--ink-2); }
.solution pre { font: 12.5px/1.5 var(--mono); background: var(--code-bg); border: 1px solid var(--rule); border-radius: 6px; padding: 10px; overflow: auto; max-height: 340px; }

/* editor */
.ed { display: flex; width: 100%; font: 13.5px/1.6 var(--mono); background: var(--code-bg); position: relative; }
.ed-gutter { flex: 0 0 auto; padding: 12px 8px 12px 10px; text-align: right; color: var(--ink-3); user-select: none; overflow: hidden; border-right: 1px solid var(--rule); min-width: 42px; font-variant-numeric: tabular-nums; }
.ed-gutter .err { color: var(--orange); font-weight: 700; }
.ed-body { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-ta { margin: 0; padding: 12px 14px; font: inherit; tab-size: 4; white-space: pre; overflow: auto; position: absolute; inset: 0; border: 0; }
.ed-hl { color: var(--ink); pointer-events: none; overflow: hidden; }
.ed-ta { background: transparent; color: transparent; caret-color: var(--ink); resize: none; outline: none; }
.ed-ta::selection { background: rgba(36, 81, 183, .22); color: transparent; }
.tk-kw { color: #8A2BB9; font-weight: 600; } .tk-str { color: #1B7F4B; } .tk-com { color: #7A8499; font-style: italic; }
.tk-num { color: #B4520F; } .tk-def { color: var(--cobalt); font-weight: 600; } .tk-bi { color: #0F7C8C; }
.tk-todo { background: var(--orange-2); color: var(--orange); font-weight: 700; border-radius: 3px; }
.ed-errline { background: var(--orange-2); display: inline-block; width: 100%; }
:root[data-theme="dark"] .tk-kw { color: #D39BF5; } :root[data-theme="dark"] .tk-str { color: #7FD6A4; } :root[data-theme="dark"] .tk-num { color: #F5A76B; } :root[data-theme="dark"] .tk-bi { color: #6FD3E0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tk-kw { color: #D39BF5; } :root:not([data-theme="light"]) .tk-str { color: #7FD6A4; } :root:not([data-theme="light"]) .tk-num { color: #F5A76B; } :root:not([data-theme="light"]) .tk-bi { color: #6FD3E0; } }

.lab-about { max-width: 820px; margin: 0 auto; padding: 44px 32px 20px; }
.lab-about h2 { font-size: 24px; font-weight: 800; font-stretch: 85%; margin: 28px 0 8px; }
.lab-about p, .lab-about li { color: var(--ink-2); }
.subscribe { border: 1px solid var(--rule); background: var(--panel); border-radius: 8px; padding: 18px 20px; margin: 28px 0; }
.subscribe h3 { margin: 0 0 4px; font-size: 18px; }
.subscribe p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.mobile-note { margin: 0; display: none; font-size: 14px; color: var(--ink-2); background: var(--cobalt-2); padding: 10px 14px; border-bottom: 1px solid var(--rule); }

.debug-box { position: fixed; right: 12px; bottom: 12px; width: min(420px, 90vw); max-height: 40vh; overflow: auto; background: var(--panel); border: 1px solid var(--ink); border-radius: 8px; font: 12px var(--mono); padding: 10px; z-index: 50; }
.debug-box ol { padding-left: 1.4em; margin: 6px 0 0; }

/* ---------- articles ---------- */
.article { max-width: 720px; margin: 0 auto; padding: 48px 28px 32px; }
.article h1 { font-size: clamp(32px, 4.4vw, 46px); line-height: 1.06; font-weight: 800; font-stretch: 80%; letter-spacing: -.015em; margin: 8px 0 14px; }
.article .dek { font-size: 19px; color: var(--ink-2); margin: 0 0 28px; }
.article h2 { font-size: 24px; font-weight: 800; font-stretch: 85%; margin: 40px 0 10px; }
.article p, .article li { font-size: 17.5px; line-height: 1.65; color: var(--ink); }
.article figure { margin: 28px 0; }
.article figure svg { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; }
.article figcaption { font-size: 14px; color: var(--ink-2); margin-top: 8px; }
.article .math { font-size: 14px; }
.cta-box { display: flex; gap: 18px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--cobalt); background: var(--cobalt-2); border-radius: 8px; padding: 18px 20px; margin: 32px 0; }
.cta-box p { margin: 0; font-size: 16px; max-width: 42ch; }
.article table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 18px 0; display: block; overflow-x: auto; }
.article th, .article td { border-top: 1px solid var(--rule); padding: 9px 10px 9px 0; text-align: left; vertical-align: top; }
.article th { font-size: 14px; color: var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 1279px) {
  .lab { grid-template-columns: minmax(0, 1fr) minmax(340px, 440px); }
  .pane-brief { grid-column: 1 / -1; position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); }
  .pane-brief .brief-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; }
}
@media (max-width: 900px) {
  .lab { grid-template-columns: minmax(0, 1fr); }
  .pane-code { position: static; max-height: none; border-left: 0; border-top: 1px solid var(--rule); }
  .editor-wrap { min-height: 420px; }
  .pane-brief .brief-cols { display: block; }
  .plots { grid-template-columns: 1fr; }
  .score-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .score-row > div:nth-child(4) { border-left: 0; }
  .score-row > div:nth-child(n+4) { border-top: 1px solid var(--rule); }
  .mobile-note { display: block; }
  .hero { grid-template-columns: 1fr; padding: 40px 20px 32px; gap: 28px; }
  .section { padding: 36px 20px; }
  .loop { grid-template-columns: 1fr 1fr; }
  .loop li:nth-child(odd) { border-left: 0; }
  .loop li:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .catalog, .split { grid-template-columns: 1fr; gap: 0; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar nav a { margin-left: 10px; }
  .crumbs { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- lab 02: PID tuning (scoped to .pid-page / new classes only) ---------- */
.level-tag { font-size: 13px; font-weight: 700; color: var(--green); margin: 0; }
.loop-diagram { width: 100%; max-width: 330px; height: auto; color: var(--ink-2); display: block; margin: 6px 0 4px; }
.pid-viewport canvas { aspect-ratio: 16 / 9; }
.pid-viewport .overlay-msg { left: auto; justify-content: flex-end; }
.key i.target { border-top: 2px dashed var(--green); }
.key i.band { height: 8px; border: 0; background: var(--green-2); outline: 1px solid var(--green); }
.pid-plots { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 4px; }
.pid-metrics { margin-top: 12px; }
.pid-metrics .score-row { grid-template-columns: repeat(5, minmax(0, 1fr)); border-bottom: 0; }
.pid-metrics .metric b { font-size: 21px; }
.pid-metrics .metric em { display: block; font-style: normal; font-size: 12px; color: var(--ink-3); min-height: 1.2em; }
.pid-controls .pid-scroll { flex: 1; overflow: auto; }
.gains { padding: 14px 14px 4px; border-bottom: 1px solid var(--rule); }
.gain { display: grid; grid-template-columns: 118px minmax(0, 1fr) 72px; gap: 10px; align-items: center; margin-bottom: 12px; }
.gain label { font-size: 13px; color: var(--ink-3); line-height: 1.2; }
.gain label b { display: block; font-size: 17px; color: var(--ink); }
.gain input[type=range] { width: 100%; accent-color: var(--cobalt); height: 28px; }
.gain input[type=text] { width: 100%; font: 600 15px var(--font); font-variant-numeric: tabular-nums; padding: .45em .5em; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--ink); text-align: right; }
.gain input[aria-invalid="true"] { border-color: var(--orange); background: var(--orange-2); }
.gain-msg { font-size: 13.5px; color: var(--ink-2); min-height: 1.2em; margin: 0 0 4px; }
.gain-msg[data-state="error"] { color: var(--orange); font-weight: 600; }
.pid-actions { border-top: 0; padding: 4px 0 12px; }
.autorun { flex-basis: 100%; font-size: 13px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; }
.stage-panel { padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.stage-panel h3, .pid-feedback h3 { font-size: 15px; margin: 2px 0 6px; }
.stage-panel p { font-size: 14.5px; color: var(--ink-2); margin: 6px 0; }
.muted { color: var(--ink-3) !important; }
.checklist { list-style: none; padding: 0; margin: 8px 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; color: var(--ink-2); padding: 6px 0; border-top: 1px solid var(--rule); }
.checklist .box { flex: 0 0 16px; height: 16px; margin-top: 3px; border: 1.5px solid var(--ink-3); border-radius: 4px; }
.checklist li[data-done="true"] { color: var(--ink); }
.checklist li[data-done="true"] .box { background: var(--green); border-color: var(--green); box-shadow: inset 0 0 0 3px var(--panel); }
.case-tabs { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; margin-bottom: 8px; }
.case-tabs button { font: 600 13.5px var(--font); padding: .45em .8em; border: 0; border-left: 1px solid var(--rule); background: var(--panel); color: var(--ink-2); cursor: pointer; }
.case-tabs button:first-child { border-left: 0; }
.case-tabs button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.options { display: grid; gap: 6px; margin: 6px 0; }
.option { text-align: left; font: 14px/1.35 var(--font); padding: .6em .75em; border: 1px solid var(--rule); border-radius: var(--r); background: var(--panel); color: var(--ink); cursor: pointer; }
.option:hover { border-color: var(--ink-3); }
.option[aria-pressed="true"] { border-color: var(--cobalt); background: var(--cobalt-2); }
.verdict-text { font-size: 14px !important; }
.ok { color: var(--green); font-weight: 700; }
.no { color: var(--orange); font-weight: 700; }
.stage-done { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 600; color: var(--green) !important; }
table.checks { width: 100%; border-collapse: collapse; font-size: 14px; margin: 4px 0 8px; }
table.checks th { text-align: left; font-size: 12.5px; color: var(--ink-3); font-weight: 600; padding: 4px 6px 4px 0; }
table.checks td { border-top: 1px solid var(--rule); padding: 7px 6px 7px 0; font-variant-numeric: tabular-nums; color: var(--ink-2); }
table.checks td:first-child { color: var(--ink); font-weight: 600; }
.success { border: 1px solid var(--green); background: var(--green-2); border-radius: 8px; padding: 12px 14px; margin-top: 8px; }
.success b { color: var(--green); font-size: 16px; }
.pid-feedback { border-bottom: 1px solid var(--rule); }
.pid-feedback ul { list-style: none; padding: 0; }
.pid-feedback li { border-left: 3px solid var(--ink-3); padding: 4px 10px; margin: 6px 0; font-size: 14.5px; }
.pid-feedback li.fb-warn { border-left-color: var(--orange); }
.pid-feedback li.fb-good { border-left-color: var(--green); color: var(--ink); }
.pid-feedback li.fb-info { border-left-color: var(--cobalt); }
.what-changed { font-size: 14px !important; background: var(--paper); border-radius: 6px; padding: 8px 10px; }
.what-changed b { color: var(--ink); }
.pid-page .helpzone { max-height: none; }
.pid-page .helpzone .hint { white-space: normal; }
.pid-page .helpzone .hint b { display: block; }
@media (max-width: 900px) {
  .pid-plots { grid-template-columns: 1fr; }
  .pid-metrics .score-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pid-viewport canvas { aspect-ratio: 4 / 3; }
  .gain { grid-template-columns: 84px minmax(0, 1fr) 64px; }
  .pid-controls .pid-scroll { overflow: visible; }
}

/* landing: live labs */
.live-labs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0 0 28px; }
.live-lab { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; text-decoration: none; color: var(--ink); }
.live-lab:hover { border-color: var(--cobalt); }
.live-lab .lab-no { font-size: 13px; font-weight: 700; color: var(--cobalt); }
.live-lab strong { font-size: 21px; font-weight: 800; font-stretch: 85%; }
.live-lab .lab-level { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.live-lab .lab-level.beginner { color: var(--green); }
.live-lab .lab-desc { font-size: 15px; color: var(--ink-2); margin-top: 4px; }
@media (max-width: 900px) { .live-labs { grid-template-columns: 1fr; } }

/* ---------- lab 03: fix the oscillating robot (new classes only) ---------- */
.osc-viewport canvas { aspect-ratio: 16 / 8; }
.osc-viewport .overlay-msg { left: auto; justify-content: flex-end; }
.key i.path { border-top: 3px solid var(--ink-2); }
.osc-metrics { margin-top: 12px; }
.osc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.osc-grid .metric { font: inherit; text-align: left; background: none; border: 0; border-left: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 10px 12px; cursor: help; color: var(--ink); }
.osc-grid .metric:nth-child(4n+1) { border-left: 0; }
.osc-grid .metric b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.osc-grid .metric b small { font-size: 12.5px; color: var(--ink-3); }
.osc-grid .metric span { font-size: 12.5px; color: var(--ink-3); text-decoration: underline dotted; text-underline-offset: 3px; }
.osc-grid .metric[aria-pressed="true"] { background: var(--cobalt-2); }
.metric-help { margin: 0; padding: 10px 14px; font-size: 14px; color: var(--ink-2); min-height: 2.6em; }
.advanced { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-2); }
.advanced summary { cursor: pointer; margin-bottom: 8px; }
.gain input:disabled { opacity: .55; cursor: not-allowed; }
.question-d { border-top: 1px solid var(--rule); padding: 7px 0; }
.question-d summary { cursor: pointer; font-weight: 600; font-size: 14.5px; }
.question-d p { margin: 6px 0 0; }
.hyp { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.hyp .option { text-align: center; font-weight: 600; }
.why { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--rule); }
.why h3 { font-size: 15px; margin: 0 0 8px; }
.chain { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.chain li { font-size: 13px; font-weight: 600; background: var(--orange-2); color: var(--ink); border-radius: 4px; padding: 3px 8px; }
.chain li.arr { background: none; color: var(--ink-3); font-weight: 400; padding: 0 0 0 14px; line-height: 1.1; }
.why p { font-size: 14px !important; }
table.checks .small { font-size: 12.5px; color: var(--ink-3); }
table.checks .num { text-align: right; font-variant-numeric: tabular-nums; }
table.checks tr.total td { font-weight: 800; color: var(--ink); border-top: 2px solid var(--ink); }
.link-btn { font: 600 12.5px var(--font); color: var(--cobalt); background: none; border: 0; padding: 0 2px; cursor: pointer; text-decoration: underline; }
.note-ok { color: var(--green) !important; font-weight: 600; }
#ba-canvas { width: 100%; height: 180px; display: block; border: 1px solid var(--rule); border-radius: 6px; margin: 6px 0 8px; background: var(--panel); }
.pid-feedback li.fb-change { border-left-color: var(--ink); background: var(--paper); }
@media (max-width: 900px) {
  .osc-viewport canvas { aspect-ratio: 5 / 4; }
  .osc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .osc-grid .metric:nth-child(4n+1) { border-left: 1px solid var(--rule); }
  .osc-grid .metric:nth-child(2n+1) { border-left: 0; }
  table.robust .small { display: none; }
}

/* landing: Explore Robotics track cards */
.tracks { list-style: none; margin: 0 0 36px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.tracks li { display: flex; min-width: 0; }
.track-card { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.track-card:hover { border-color: var(--cobalt); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(19, 32, 58, .08); }
.track-card:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.track-icon svg { width: 30px; height: 30px; fill: none; stroke: var(--cobalt); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.track-icon svg .fill { fill: var(--cobalt); stroke: none; }
.track-name { font-size: 18px; font-weight: 800; font-stretch: 88%; margin-top: 4px; }
.track-desc { font-size: 14.5px; color: var(--ink-2); line-height: 1.45; flex: 1; }
.track-cta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 13.5px; font-weight: 700; color: var(--ink-3); }
.track-cta .go { color: var(--cobalt); white-space: nowrap; }
.track-card:hover .go span { display: inline-block; transform: translateX(3px); transition: transform .15s; }
.track-card.soon .track-icon svg { stroke: var(--ink-3); }
.track-card.soon .track-icon svg .fill { fill: var(--ink-3); }
.track-card.soon .go { color: var(--ink-3); font-weight: 600; }
.track-card.soon:hover { border-color: var(--ink-3); box-shadow: none; }
.soon-tag { font-size: 12px; font-weight: 700; color: var(--ink-2); background: var(--paper); border: 1px solid var(--rule); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.track-labs { scroll-margin-top: 16px; }
.track-labs h3 { font-size: 22px; font-weight: 800; font-stretch: 85%; margin: 0 0 4px; }
.coming-next { font-size: 14px; color: var(--ink-3); margin: -12px 0 0; }
.track-labs p.sub { color: var(--ink-2); margin: 0 0 18px; max-width: 60ch; }
@media (max-width: 1100px) { .tracks { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .tracks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  .tracks { grid-template-columns: 1fr; gap: 10px; }
  .track-card { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 14px; row-gap: 2px; padding: 13px 16px; }
  .track-icon { grid-row: 1 / span 3; padding-top: 2px; }
  .track-name { margin-top: 0; font-size: 17px; }
  .track-desc { font-size: 14px; }
  .track-cta { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { .track-card, .track-card:hover { transform: none; } }
