:root{
  color-scheme:light;
  /* Indigo Ink, light */
  --bg:#f6f7fb;--surface:#ffffff;--surface-2:#eceefa;--ink:#181d2b;--muted:#566075;--line:#e1e4ef;--line-strong:#7d849e; /* --line divides; --line-strong outlines a control (3:1) */
  --accent:#5143cb;--accent-ink:#ffffff;--accent-soft:#e9e6ff;
  --good:#13795b;--good-soft:#dcf3ea;--warn:#b3261e;--bad-soft:#fbe3e0;--gold:#c98a1a;
  --plot-bg:#f9faff;--grid:#e1e4ef;--shadow:#181d2b22;
  --k0:#5143cb;--k1:#d6457a;--k2:#0b8a78;--k3:#b87a0f;--k4:#1a82c0;--k5:#a24fb0;--k6:#5f8a1a;--noise:#6e7b8f; /* marks: 3:1 on the plot */
  --k0-ink:#5143cb;--k1-ink:#b8325f;--k2-ink:#0a6f60;--k3-ink:#8a5a00;--k4-ink:#14699f;--k5-ink:#8a3a98;--k6-ink:#486a10; /* the same hues as text (4.5:1) */
  --serif:"Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
  --sans:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;
}
/* Dark follows the system unless the learner picked a theme with the header toggle. */
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  color-scheme:dark;
  --bg:#12141f;--surface:#1a1d2c;--surface-2:#242840;--ink:#e8eaf6;--muted:#9aa1c0;--line:#2c3150;--line-strong:#6a7196;
  --accent:#9a8cff;--accent-ink:#12141f;--accent-soft:#2a2650;
  --good:#5fd3a6;--good-soft:#143328;--warn:#ff8f85;--bad-soft:#3b1b1f;--gold:#e6b04a;
  --plot-bg:#161828;--grid:#2c3150;--shadow:#0008;
  --k0:#9a8cff;--k1:#ff6f9f;--k2:#3fcfb4;--k3:#e6b04a;--k4:#4db0ff;--k5:#cf7fe0;--k6:#a9d15a;--noise:#98a3b8;
  --k0-ink:var(--k0);--k1-ink:var(--k1);--k2-ink:var(--k2);--k3-ink:var(--k3);--k4-ink:var(--k4);--k5-ink:var(--k5);--k6-ink:var(--k6);
}}
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#12141f;--surface:#1a1d2c;--surface-2:#242840;--ink:#e8eaf6;--muted:#9aa1c0;--line:#2c3150;--line-strong:#6a7196;
  --accent:#9a8cff;--accent-ink:#12141f;--accent-soft:#2a2650;
  --good:#5fd3a6;--good-soft:#143328;--warn:#ff8f85;--bad-soft:#3b1b1f;--gold:#e6b04a;
  --plot-bg:#161828;--grid:#2c3150;--shadow:#0008;
  --k0:#9a8cff;--k1:#ff6f9f;--k2:#3fcfb4;--k3:#e6b04a;--k4:#4db0ff;--k5:#cf7fe0;--k6:#a9d15a;--noise:#98a3b8;
  --k0-ink:var(--k0);--k1-ink:var(--k1);--k2-ink:var(--k2);--k3-ink:var(--k3);--k4-ink:var(--k4);--k5-ink:var(--k5);--k6-ink:var(--k6);
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.6 var(--sans);-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}
button,select,input{font:inherit;color:inherit}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
.skip{position:absolute;left:-999px;top:8px;background:var(--surface);padding:8px 12px;border-radius:8px;z-index:30}
.skip:focus{left:8px}
.wrap{width:min(1120px,calc(100% - 48px));margin-inline:auto}
main.wrap{padding-block:28px 56px;outline:none}
.muted{color:var(--muted)}
.error{color:var(--warn)}
h1,h2,h3{line-height:1.15;margin:0}
h1{font:600 clamp(32px,5vw,52px)/1.08 var(--serif);letter-spacing:-.02em;text-wrap:balance}
h2{font:600 24px/1.2 var(--serif);letter-spacing:-.01em}
h3{font-size:17px}

.top{background:var(--surface);border-bottom:1px solid var(--line)}
.bar{height:64px;display:flex;align-items:center;justify-content:space-between}
.brand{display:flex;align-items:center;gap:10px;font:600 21px var(--serif);letter-spacing:-.01em}
.logo{width:30px;height:30px;border-radius:9px;background:var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Ccircle cx='11' cy='12' r='3' fill='%23fff'/%3E%3Ccircle cx='21' cy='11' r='3' fill='%23fff' opacity='.7'/%3E%3Ccircle cx='16' cy='22' r='3' fill='%23fff' opacity='.85'/%3E%3C/svg%3E") center/cover}
.bar nav{display:flex;gap:20px;font-size:14px;font-weight:600;color:var(--muted)}
.bar nav a:hover{color:var(--ink)}
footer.site{margin-top:56px;padding-block:32px 28px;border-top:1px solid var(--line);color:var(--muted);font-size:14px;line-height:1.55}

.eyebrow{margin:0 0 10px;display:flex;align-items:center;gap:8px;color:var(--accent);font-size:11px;font-weight:700;letter-spacing:.14em}
.eyebrow span{width:7px;height:7px;border-radius:50%;background:var(--accent)}
.lede{font-size:18px;color:var(--muted);max-width:60ch;margin:14px 0 0}
.hero{padding:36px 0 40px}
.hero-actions{display:flex;flex-wrap:wrap;align-items:center;gap:14px;margin-top:22px}
.section-title{margin-bottom:16px}
.crumbs{font-size:13px;color:var(--muted);margin-bottom:18px}
.crumbbar{display:flex;align-items:center;flex-wrap:wrap;gap:6px 14px;margin-bottom:18px}
.crumbbar .crumbs{margin:0;min-width:0}
.back-btn{display:inline-grid;place-items:center;width:34px;height:34px;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--ink);text-decoration:none !important;flex:none}
.back-btn:hover{border-color:var(--accent);color:var(--accent)}
.crumbs a:hover{color:var(--accent);text-decoration:underline}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 16px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface);font-weight:600;font-size:14px;cursor:pointer;transition:background .15s,border-color .15s}
.btn:hover:not(:disabled){border-color:var(--accent);background:var(--accent-soft)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.primary:hover:not(:disabled){filter:brightness(1.08);background:var(--accent)}
.btn:disabled{opacity:.7;cursor:default}

.card{background:var(--surface);border:1px solid var(--line);border-radius:16px}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(310px,100%),1fr));gap:16px}
.course-card{display:flex;flex-direction:column;gap:10px;padding:22px;transition:border-color .15s,transform .15s}
.course-card:hover{border-color:var(--accent);transform:translateY(-2px)}
.course-card h3{font:600 22px/1.2 var(--serif)}
.course-card p{margin:0;color:var(--muted);font-size:15px}
.card-foot{margin-top:auto;padding-top:8px;display:grid;gap:8px;font-size:13px}
.tags{display:flex;gap:8px;flex-wrap:wrap}
.tag{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;padding:3px 9px;border-radius:999px;background:var(--surface-2);color:var(--muted)}
.tag.level-beginner{background:var(--good-soft);color:var(--good)}
.tag.level-intermediate{background:var(--accent-soft);color:var(--accent)}
.meter{height:8px;border-radius:99px;background:var(--surface-2);overflow:hidden;box-shadow:inset 0 0 0 1px var(--line-strong)}
.meter span{display:block;height:100%;background:var(--accent);border-radius:99px;transition:width .3s}
.course-head{display:grid;gap:12px;margin-bottom:28px}
.course-head .meter{max-width:none}

.lesson-list{list-style:none;margin:0;padding:0;display:grid;gap:10px}
.lesson-row{display:grid;grid-template-columns:40px minmax(0,1fr) auto;gap:16px;align-items:center;padding:16px 18px;transition:border-color .15s}
.lesson-row:hover{border-color:var(--accent)}
.step{display:grid;place-items:center;width:36px;height:36px;border-radius:50%;background:var(--surface-2);font-weight:700;font-size:14px}
.step.done{background:var(--accent);color:var(--accent-ink)}
.lesson-main{display:grid;grid-template-columns:minmax(0,1fr);gap:2px}
.lesson-main .muted{font-size:13px}
.status-text{font-size:13px;white-space:nowrap}
.status-inline{display:none}

.lesson-head{margin-bottom:22px}
.prose{max-width:68ch;margin-top:28px}
.prose h2{margin:30px 0 8px}
.prose p,.prose li{font-size:17px}
.prose p{margin:0 0 14px}
.prose ul,.prose ol{padding-left:22px;margin:0 0 14px}
.prose code{font:.9em ui-monospace,SFMono-Regular,Menlo,monospace;background:var(--surface-2);padding:1px 6px;border-radius:5px}
.callout{margin:18px 0;padding:14px 18px;border-left:4px solid var(--accent);background:var(--accent-soft);border-radius:0 12px 12px 0}

.quiz{margin-top:36px;padding:24px;max-width:760px}
.quiz fieldset{border:0;padding:0;margin:20px 0 0}
.quiz legend{font-weight:650;padding:0;margin-bottom:8px}
.opt{display:flex;gap:10px;align-items:flex-start;padding:9px 12px;border:1px solid var(--line-strong);border-radius:10px;margin-top:6px;cursor:pointer}
.opt:hover{border-color:var(--accent)}
.opt:has(input:checked){border-color:var(--accent);background:var(--accent-soft)}
.opt input{margin-top:5px;accent-color:var(--accent)}
.feedback{margin:8px 0 0;padding:10px 12px;border-radius:10px;font-size:14px}
.feedback.good{background:var(--good-soft)}
.feedback.bad{background:var(--bad-soft)}
.quiz-actions{display:flex;align-items:center;gap:14px;margin-top:20px;flex-wrap:wrap}
.quiz-result{margin:0;font-weight:650}
.pager[hidden]{display:none}
.pager{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:36px;padding-top:20px;border-top:1px solid var(--line)}
.empty{padding:60px 0;display:grid;gap:12px;justify-items:start}

/* simulators */
.sim-host{margin-top:6px}
/* While a lab loads, its place is held (as far as one screen), so the guide below it does not jump when the lab arrives. */
.sim-host:has(>[role=status]){min-height:max(80vh,480px)}
.sim{display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:18px;align-items:start}
/* Fullscreen (the browser's, or .expanded where it is missing): the stage holds the plot, its parameters and the charts below, scrolls,
   and sizes the plot to the room the toolbar leaves, so the legend and the controls stay reachable. */
.sim:is(:fullscreen,.expanded),.lab-stage:is(:fullscreen,.expanded){background:var(--bg);padding:clamp(12px,2vw,24px);overflow:auto}
.sim:is(:fullscreen,.expanded),.lab-stage:is(:fullscreen,.expanded) .sim{--plot-h:max(280px,calc(100dvh - 290px))}
/* The square is as wide as the card on a phone, so a taller canvas would only leave empty space under it. */
@media (max-width:860px){.sim:is(:fullscreen,.expanded),.lab-stage:is(:fullscreen,.expanded) .sim{--plot-h:min(max(260px,calc(100dvh - 340px)),max(300px,82vw))}}
.sim.expanded,.lab-stage.expanded{position:fixed;inset:0;z-index:20}
.sim:is(:fullscreen,.expanded),.lab-stage:is(:fullscreen,.expanded){overscroll-behavior:contain}
body:has(:is(.sim,.lab-stage).expanded){overflow:hidden}
.lab-stage:is(:fullscreen,.expanded) .table-card{margin-top:18px}
/* On a phone there is no Escape key and the overlay scrolls, so the Exit button floats at the corner and is always in reach. */
@media (max-width:860px),(pointer:coarse){
  .sim:is(:fullscreen,.expanded),.lab-stage:is(:fullscreen,.expanded){padding-bottom:76px}
  .sim:is(:fullscreen,.expanded) [data-act=fullscreen],.lab-stage:is(:fullscreen,.expanded) [data-act=fullscreen]{position:fixed;right:14px;bottom:14px;z-index:30;min-height:44px;padding-inline:14px;background:var(--surface);border-color:var(--accent);color:var(--ink);box-shadow:0 4px 16px var(--shadow)}
}
.plot-card,.settings,.table-card{padding:20px}
.table-card{margin-top:18px}
.card-head{display:flex;justify-content:space-between;align-items:start;gap:12px;flex-wrap:nowrap}
.card-head>:first-child{flex:1 1 0;min-width:0}
.card-head .sim-actions{flex:none}
@media (max-width:640px){.card-head{flex-wrap:wrap}.card-head>:first-child{flex:1 1 100%}}
.card-head p,.hint{margin:4px 0 0;font-size:13px;color:var(--muted)}
.sim-actions{display:flex;gap:8px;flex-wrap:wrap}
.sim button:not(.btn){cursor:pointer;background:var(--surface);border:1px solid var(--line-strong);border-radius:8px;padding:7px 11px;font-size:13px;font-weight:600;color:var(--muted);white-space:nowrap}
.sim button:not(.btn):hover:not(:disabled){background:var(--accent-soft);color:var(--ink)}
.sim button:disabled{opacity:.55;cursor:default}
.playback{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin-top:14px}
.playback button.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.playback button.primary:hover{background:var(--accent);filter:brightness(1.1);color:var(--accent-ink)}
.speed-control{display:inline-flex;align-items:center;gap:8px}
.speed-control label{font-size:13px;font-weight:650;color:var(--muted)}
.speed-control input[type=range]{width:clamp(72px,16vw,120px);accent-color:var(--accent)}
.speed-control input[type=number]{width:76px;padding:5px 6px;border:1px solid var(--line-strong);border-radius:6px;background:var(--surface);font-size:13px}
.speed-control .speed-suffix{color:var(--muted);font-size:13px}
.speed-control.is-instant .speed-suffix{visibility:hidden}
.plot-progress{display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:8px 16px;margin-top:14px;padding:10px 12px;border:1px solid var(--line);border-radius:10px;background:var(--surface-2)}
.status{font-weight:700;font-size:15px}
.plot-progress .hint{margin:2px 0 0}
.metrics{display:flex;gap:4px 16px;flex-wrap:wrap;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.chart{margin:14px 0 6px}
/* A plot grows with the screen: tall screens get a bigger square. Swiping across a canvas scrolls the page, except on a
   canvas that is dragged (.drag-surface: sims/common.js marks canvases that listen for pointermove). */
canvas{display:block;width:100%;height:var(--plot-h,clamp(360px,calc(100dvh - 330px),700px));cursor:default;touch-action:pan-y;border-radius:10px}
canvas.interactive{cursor:crosshair}
canvas.drag-surface{touch-action:none}
@media (max-width:860px){canvas{height:var(--plot-h,clamp(300px,82vw,560px))}}
.settings label{display:block;margin-top:14px;font-size:13px;font-weight:650}
.settings select,.settings input[type=number]{display:block;width:100%;margin-top:6px;padding:8px;border:1px solid var(--line-strong);border-radius:8px;background:var(--surface);font-size:13px}
.settings .row{display:flex;gap:8px;margin-top:6px}
.settings .row input{margin-top:0;min-width:0}
.settings .toggle{display:flex;gap:8px;align-items:center;cursor:pointer;font-weight:600}
.settings .toggle input{accent-color:var(--accent);width:16px;height:16px;flex:none}
.slider-label{display:block}
.slider-label output{float:right;background:var(--accent-soft);color:var(--accent);border-radius:6px;padding:1px 8px;font-weight:800}
.slider-label input[type=range]{width:100%;margin-top:8px;accent-color:var(--accent)}
/* the panel's slider: a label for the input, the value readout beside it */
.settings div.slider-label{margin-top:14px;font-size:13px;font-weight:650}
.settings div.slider-label label{display:inline;margin:0}
.panel{display:block}
.panel .button-group{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,118px),1fr));gap:8px;margin-top:16px}
.panel .button-group .panel-button{margin:0!important;white-space:normal;line-height:1.25}
.panel .group-label{margin:16px 0 -8px;font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.panel .hint+.button-group,.panel .toggle+.button-group{margin-top:16px}
.inspector{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:8px;font-size:13px}
.inspector select{padding:5px 8px;border:1px solid var(--line-strong);border-radius:7px;background:var(--surface)}
.counts{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:18px 0 0}
.counts div{padding:8px 10px;background:var(--surface-2);border-radius:8px}
.counts dt{font-size:12px;color:var(--muted)}
.counts dd{margin:2px 0 0;font-weight:750;font-size:18px}
.vote-track{display:flex;height:8px;border-radius:8px;overflow:hidden;background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--line-strong);margin-top:14px}
.vote-track span{display:block;height:100%}
.vote-labels{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);margin-top:6px}
.table-scroll{overflow:auto}
table{width:100%;border-collapse:collapse;margin-top:12px;font-size:13px;text-align:left;font-variant-numeric:tabular-nums}
/* a lab's table is as wide as its content (up to the card), so a number sits next to its label */
.table-card table{width:auto;min-width:min(100%,22rem)}
.table-card td+td,.table-card th+th{text-align:right}
th,td{padding:9px 12px;border-bottom:1px solid var(--line);white-space:nowrap}
th{background:var(--surface-2);color:var(--muted)}
tbody tr:last-child :is(td,th){border-bottom:0}
.dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:8px}
@media (max-width:860px){.sim{grid-template-columns:minmax(0,1fr)}}
@media (max-width:560px){.wrap{width:calc(100% - 28px)}.lesson-row{grid-template-columns:36px minmax(0,1fr)}.status-text{display:none}.status-inline{display:inline}.bar nav{font-size:13px;gap:12px}}
/* Narrow phones (320px): the brand already links home, so the Courses link makes room for the toggles. */
@media (max-width:420px){.bar nav a[data-nav=home]{display:none}.brand{font-size:19px}}
@media (prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important;scroll-behavior:auto!important}.course-card:hover{transform:none}}

/* k-means: centroid context menu */
.chart{position:relative}
.ctx-menu{position:absolute;z-index:12;width:min(260px,100%);padding:10px;background:var(--surface);border:1px solid var(--line);border-radius:10px;box-shadow:0 8px 24px var(--shadow)}
.ctx-menu[hidden]{display:none}
.coord-fields{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:8px}
.ctx-menu label{margin:0;font-size:12px}
.ctx-menu input{display:block;width:100%;margin-top:4px;padding:6px;border:1px solid var(--line-strong);border-radius:6px;background:var(--surface);font-size:13px}
.sim .ctx-menu button{display:block;width:100%;text-align:left;border:0;border-radius:6px;padding:8px 10px;font-size:13px;font-weight:600;cursor:pointer}
.sim .ctx-menu .menu-primary{background:var(--accent);color:var(--accent-ink);text-align:center}
.sim .ctx-menu .menu-danger{background:transparent;color:var(--warn);margin-top:4px}
.sim .ctx-menu .menu-danger:hover{background:var(--bad-soft);color:var(--warn)}
.settings .two{display:grid;grid-template-columns:1fr 1fr;gap:8px}
[hidden]{display:none!important}
.legend{display:flex;gap:16px;align-items:center;flex-wrap:wrap;font-size:12px;color:var(--muted);min-height:22px;max-height:72px;overflow:auto}
.legend span{display:inline-flex;align-items:center;gap:7px}
.diamond{display:inline-block;width:9px;height:9px;background:var(--ink);transform:rotate(45deg);border-radius:1px}
.legend .dot{margin:0;background:var(--glyph,var(--muted))}
/* legend glyphs drawn like the marks: filled diamond with an ink outline, ring, cross, solid or dashed line */
.legend .diamond{width:11px;height:11px;margin:0 1px;background:var(--glyph,var(--ink));border:2px solid var(--ink);box-sizing:border-box}
.legend .ring{display:inline-block;width:11px;height:11px;border-radius:50%;border:2.5px solid var(--glyph,var(--muted));box-sizing:border-box}
.legend .glyph-cross{position:relative;display:inline-block;width:11px;height:11px;color:var(--glyph,var(--muted))}
.legend .glyph-cross::before,.legend .glyph-cross::after{content:"";position:absolute;left:-1px;right:-1px;top:calc(50% - 1px);height:2.4px;border-radius:2px;background:currentColor;transform:rotate(45deg)}
.legend .glyph-cross::after{transform:rotate(-45deg)}
.legend .glyph-line{display:inline-block;width:18px;height:0;border-top:3px solid var(--glyph,var(--muted));border-radius:2px}
.legend .glyph-line.dashed{border-top-style:dashed}
.side{display:grid;gap:16px}
.legend .db-marker,.db-marker{display:inline-grid;width:10px;height:10px;place-items:center;border-radius:50%;color:var(--accent);font-style:normal}
.db-marker.core{background:var(--accent)}
.db-marker.border{border:2px solid var(--accent)}
.db-marker.noise{color:var(--muted);font-size:16px;line-height:10px}
.db-marker.unvisited{width:7px;height:7px;background:var(--muted)}
.db-marker.radius{width:13px;height:13px;border:1px dashed var(--accent);background:var(--accent-soft)}
.sim canvas.pointer{cursor:pointer}

/* lesson views: Learn / Simulate / Quiz */
.lesson-head{margin-bottom:20px}
.tabs{display:flex;gap:4px;margin-top:18px;border-bottom:1px solid var(--line);overflow-x:auto}
.tab{display:inline-flex;align-items:center;gap:8px;padding:10px 16px;font-weight:650;font-size:15px;color:var(--muted);border-bottom:3px solid transparent;margin-bottom:-1px;white-space:nowrap}
.tab:hover{color:var(--ink)}
.tab[aria-current=page]{color:var(--accent);border-bottom-color:var(--accent)}
.badge{font-size:11px;font-weight:700;padding:1px 7px;border-radius:99px;background:var(--surface-2);color:var(--muted)}
.badge.done{background:var(--good-soft);color:var(--good)}
.badge.todo{background:var(--bad-soft);color:var(--ink);box-shadow:inset 0 0 0 1px var(--warn)}
.view{min-height:260px}
.learn{display:grid;grid-template-columns:220px minmax(0,1fr);gap:40px;align-items:start}
.learn:not(:has(.toc)){grid-template-columns:minmax(0,1fr)}
.toc{position:sticky;top:16px;font-size:14px;padding:4px 0}
.toc ol{margin:10px 0 0;padding-left:20px;display:grid;gap:8px;color:var(--muted)}
.toc button.link{padding:0;border:0;background:none;text-align:left;color:var(--muted);font-size:14px;cursor:pointer}
.toc button.link:hover{color:var(--accent);text-decoration:underline}
.next-hint{margin-top:28px}
.prose{margin-top:0}
.prose h2{margin:36px 0 10px;padding-top:6px}
.prose h2:first-child{margin-top:0}
.prose h3{margin:24px 0 6px;font-size:18px}
.prose pre{margin:14px 0;padding:14px 16px;overflow:auto;background:var(--surface-2);border:1px solid var(--line);border-radius:12px;font-size:14px;line-height:1.5}
.prose pre code{background:none;padding:0}
.prose .table-scroll{margin:0;border:1px solid var(--line);border-radius:12px}
.scroll-shell:has(>.table-scroll){margin:14px 0}
.prose table{margin:0;font-size:14px}
.prose td,.prose th{white-space:normal}
.callout{margin:18px 0;padding:14px 18px;border-left:4px solid var(--accent);background:var(--accent-soft);border-radius:0 12px 12px 0;font-size:16px}
.callout-label{margin-right:0}
.callout.warn .callout-label{color:var(--warn)}
.callout.warn{border-left-color:var(--warn);background:var(--bad-soft)}
.callout.example{border-left-color:var(--gold);background:var(--surface-2)}
.callout.try{border-left-color:var(--good);background:var(--good-soft)}
.lab-guide{margin-top:28px;padding:24px 26px;max-width:none;background:var(--surface);border:1px solid var(--line);border-radius:16px}
.lab-guide p,.lab-guide li{font-size:16px}

.quiz-view{display:grid;gap:16px;max-width:780px}
.quiz-intro{display:block;padding:18px 22px}
.quiz-intro-head{display:flex;justify-content:space-between;align-items:baseline;gap:6px 16px;flex-wrap:wrap}
.quiz-intro h2{font-size:22px}
.quiz-intro p{margin:4px 0 0}
.best{margin:0;text-align:right;color:var(--muted);font-size:14px;white-space:nowrap}
.best[hidden]{display:none}
.best strong{display:inline;margin-right:4px;font-size:26px;line-height:1;color:var(--ink);font-family:var(--serif)}
.quiz{display:grid;gap:14px;margin:0;padding:0;max-width:none;background:none;border:0}
.quiz .q{margin:0;padding:20px 22px;min-width:0}
.quiz .q legend{padding:0;float:left;width:100%;margin:0 0 12px}
.quiz .q legend+*{clear:both}
.qn{display:block;font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);margin-bottom:4px}
.qt{display:block;font-weight:650;font-size:17px;line-height:1.4}
.opt.right{border-color:var(--good);background:var(--good-soft)}
.opt.wrong{border-color:var(--warn);background:var(--bad-soft)}
.quiz-actions{position:sticky;bottom:0;display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:14px 0;background:var(--bg);border-top:1px solid var(--line);margin-top:4px}
@media (max-width:860px){.learn{grid-template-columns:minmax(0,1fr);gap:16px}.toc{position:static}.toc ol{grid-template-columns:1fr 1fr}.lab-guide{padding:18px}}
@media (max-width:560px){.toc ol{grid-template-columns:1fr}.tab{padding:10px 12px}}
.tabs{overflow-y:hidden;scrollbar-width:none}

/* theme toggle */
.theme-toggle{display:inline-grid;place-items:center;width:36px;height:36px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface);color:var(--muted);cursor:pointer;font-size:16px;line-height:1;padding:0}
.theme-toggle:hover{border-color:var(--accent);color:var(--ink)}
.bar nav{align-items:center}
tbody th{background:none;color:var(--ink);font-weight:600}

/* toolbar icons */
.sim button:has(.icon){display:inline-flex;align-items:center;gap:7px}
.playback .primary{min-width:0}
.icon{flex:none;display:block}

/* Learn tab: structure */
.learn .prose h2{display:flex;gap:12px;align-items:baseline;margin:44px 0 4px;padding-top:0}
.learn .prose h2::before{content:attr(data-n);flex:none;display:inline-grid;place-items:center;width:30px;height:30px;border-radius:9px;background:var(--accent-soft);color:var(--accent);font:700 15px var(--sans)}
.learn .prose h2:first-child,.learn .prose .intro-card+h2{margin-top:36px}
.lead{margin:0 0 14px 42px;color:var(--muted);font-size:16px;font-style:italic}
.learn .prose h2+.lead{margin-top:2px}
.prose h3{margin:22px 0 6px;font-size:17px}

.intro-card{margin:0 0 8px;padding:20px 24px;background:var(--surface);border:1px solid var(--line);border-left:4px solid var(--accent);border-radius:14px}
.intro-card .card-title{margin:0 0 8px;font:700 12px var(--sans);letter-spacing:.1em;text-transform:uppercase;color:var(--accent)}
.intro-card ul{margin:0 0 10px;padding-left:20px}
.intro-card li{font-size:16px;margin-bottom:2px}
.intro-card p{margin:0;font-size:14px;color:var(--muted)}

.figure{margin:20px 0;padding:14px 16px 12px;background:var(--surface);border:1px solid var(--line);border-radius:14px}
.figure-art{display:flex;justify-content:center}
.fig-svg{width:100%;max-width:720px;height:auto;font-family:var(--sans);overflow:visible}
.figure figcaption{margin-top:8px;text-align:center;font-size:13px;color:var(--muted)}

.deeper{margin:16px 0;border:1px solid var(--line);border-radius:12px;background:var(--surface)}
.deeper summary{display:flex;align-items:center;gap:10px;padding:12px 16px;cursor:pointer;font-weight:650;font-size:15px;list-style:none}
.deeper summary::-webkit-details-marker{display:none}
.deeper summary::after{content:"";margin-left:auto;width:8px;height:8px;border-right:2px solid var(--muted);border-bottom:2px solid var(--muted);transform:rotate(45deg);transition:transform .15s}
.deeper[open] summary::after{transform:rotate(-135deg)}
.deeper summary:hover{background:var(--surface-2);border-radius:12px}
.deeper[open] summary{border-bottom:1px solid var(--line);border-radius:12px 12px 0 0}
.deeper-tag{flex:none;font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;padding:2px 8px;border-radius:99px;background:var(--accent-soft);color:var(--accent)}
.deeper-body{padding:6px 18px 14px}
.deeper-body>:first-child{margin-top:12px}

.remember{margin:40px 0 8px;padding:20px 24px;border-radius:14px;background:var(--accent);color:var(--accent-ink)}
.remember h3{margin:0 0 8px;font:700 12px var(--sans);letter-spacing:.1em;text-transform:uppercase;opacity:.85}
.remember ul{margin:0;padding-left:20px}
.remember li{font-size:16px;margin-bottom:4px}
.remember code{background:#ffffff26;color:inherit}
.remember strong{color:inherit}

/* quieter callouts: only Key idea and Watch out stay loud */
.callout.example{background:var(--surface);border:1px solid var(--line);border-left:4px solid var(--gold);border-radius:12px}
.callout.try{background:var(--surface);border:1px solid var(--line);border-left:4px solid var(--good);border-radius:12px}

/* compact tables */
.prose .table-scroll{border-radius:12px;background:var(--surface)}
.prose table{margin:0;font-size:14px}
.prose th{padding:8px 12px;font-size:12px;letter-spacing:.03em;text-transform:uppercase}
.prose td{padding:8px 12px}
.prose tbody tr:nth-child(even){background:var(--surface-2)}
.prose tbody tr:nth-child(even) th{background:none}

/* table of contents with scroll position */
.toc{font-size:14px}
.toc-count{font-size:12px;color:var(--muted)}
.toc-head{display:flex;justify-content:space-between;align-items:baseline;gap:8px;margin-bottom:6px}
.toc ol{list-style:none;margin:0;padding:0;display:grid;gap:2px;border-left:2px solid var(--line)}
.toc li{margin:0}
.toc button.link{display:block;width:100%;padding:5px 10px;border:0;border-left:2px solid transparent;margin-left:-2px;background:none;text-align:left;color:var(--muted);font-size:14px;line-height:1.35;cursor:pointer}
.toc button.link:hover{color:var(--ink);text-decoration:none}
.toc button.link[aria-current=true]{color:var(--accent);border-left-color:var(--accent);font-weight:650}
.next-steps{display:flex;gap:10px;flex-wrap:wrap;margin-top:16px}
@media (max-width:860px){.toc ol{grid-template-columns:1fr 1fr;gap:0 12px}.lead{margin-left:0}}
@media (max-width:560px){.toc ol{grid-template-columns:1fr}}

/* wider reading column for figures and tables, with paragraph lines kept short */
.learn{grid-template-columns:200px minmax(0,1fr);gap:36px}
.learn .prose{max-width:780px}
.learn .prose>p,.learn .prose>ul,.learn .prose>ol{max-width:68ch}
/* one block width: callouts, figures, tables and the previous/next row share the prose column */
.learn .prose>.callout,.learn .prose>.figure,.learn .prose>.scroll-shell,.learn .prose>.deeper,.learn .prose>.intro-card,.learn .prose>.remember{max-width:780px}
.fig-svg{max-width:740px}

.next-steps[hidden]{display:none}

/* Learn navigation: previous and next below the material */
.learn-body{min-width:0}
.section-nav{display:flex;justify-content:space-between;gap:12px;max-width:780px;margin-top:32px;padding-top:20px;border-top:1px solid var(--line);flex-wrap:wrap}
.section-nav .btn{max-width:48%;text-align:left;justify-content:flex-start}
.section-nav .btn.primary{justify-content:flex-end;text-align:right}
@media (max-width:560px){.section-nav .btn{max-width:100%;width:100%}}

.learn{display:grid;grid-template-columns:200px minmax(0,1fr);gap:36px;align-items:start}
.learn:not(:has(.toc)){grid-template-columns:minmax(0,1fr)}
@media (max-width:860px){.learn{grid-template-columns:minmax(0,1fr);gap:16px}}

/* quiz: one question at a time */
.quiz{display:block;max-width:none}
.q-progress{display:flex;gap:5px;margin:0 0 14px}
.q-seg{flex:1;height:8px;border-radius:99px;background:var(--surface-2);box-shadow:inset 0 0 0 1px var(--line-strong)}
.q-seg.now{outline:2px solid var(--accent);outline-offset:2px}
.q-seg.right{background:var(--good)}
.q-seg.wrong{background:var(--warn) repeating-linear-gradient(135deg,transparent 0 3px,rgba(255,255,255,.55) 3px 5px)} /* hatched, so right and wrong differ without colour */
.q-actions{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:18px;flex-wrap:wrap}
.q-actions-end{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap;margin-left:auto}
.quiz .q fieldset{border:0;padding:0;margin:0;min-width:0}
.q-results .q-score{font:600 30px/1.1 var(--serif);margin:2px 0 8px}
.q-review{list-style:none;margin:16px 0 0;padding:0;display:grid;gap:8px}
.q-review li{display:grid;grid-template-columns:24px 1fr auto;gap:10px;align-items:start;padding:10px 12px;border:1px solid var(--line);border-radius:10px;font-size:14px}
.q-review li.right{border-color:var(--good)}
.q-review li.wrong{border-color:var(--warn);background:var(--bad-soft)}
.q-review .mark{font-weight:800}
.q-review li.right .mark{color:var(--good)}
.q-review li.wrong .mark{color:var(--warn)}
.q-answer{display:block;margin-top:3px;color:var(--muted);font-size:13px}
.link-btn{padding:0;border:0;background:none;color:var(--accent);font-size:13px;font-weight:650;cursor:pointer;text-decoration:underline;text-underline-offset:2px}
/* a checked answer's verdict must win over the plain "selected" tint */
.quiz .opt.right,.quiz .opt.right:has(input:checked){border-color:var(--good);background:var(--good-soft)}
.quiz .opt.wrong,.quiz .opt.wrong:has(input:checked){border-color:var(--warn);background:var(--bad-soft)}
.quiz .opt:has(input:disabled){cursor:default}
.quiz .opt input:disabled{opacity:1}
.opt-text{flex:1;min-width:0}
.verdict{display:block;margin-top:3px;font-size:13px;font-weight:700}
.verdict .ico{display:inline-block;width:1.2em;font-weight:800}
.verdict.ok .ico{color:var(--good)}
.verdict.no .ico{color:var(--warn)}
.quiz{scroll-margin-top:16px}
.quiz legend:focus-visible,.q-score:focus-visible{outline-offset:4px;border-radius:4px}
/* a section change in Learn scrolls to the top of the material with a little air above it */
.prose,.prose h2{scroll-margin-top:16px}

.completion{margin:8px 0 0;font-size:14px;font-weight:650;color:var(--muted)}
.completion.done{color:var(--good)}
.quiz-done{display:flex;justify-content:space-between;align-items:center;gap:16px;flex-wrap:wrap;padding:20px 22px}
.quiz-done h2{font-size:20px}
.quiz-done p{margin:4px 0 0}

/* paths, modules */
.path-courses{margin:6px 0 0;padding-left:18px;color:var(--muted);font-size:14px}
.module{margin-top:34px}
.module-head{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;margin-bottom:12px}
.module-head h2{font-size:22px}
.module-head p{margin:4px 0 0;font-size:14px}
.module-head .eyebrow{margin-bottom:4px}
.module-count{font-size:13px;white-space:nowrap}

/* language toggle */
.lang-toggle{display:inline-flex;border:1px solid var(--line-strong);border-radius:10px;overflow:hidden;background:var(--surface)}
.lang-btn{padding:6px 11px;border:0;background:none;color:var(--muted);font-size:13px;font-weight:700;cursor:pointer;letter-spacing:.03em}
.lang-btn:hover{color:var(--ink)}
.lang-btn[aria-pressed=true]{background:var(--accent);color:var(--accent-ink)}
.untranslated{margin:0 0 16px;padding:10px 14px;border:1px solid var(--line);border-left:4px solid var(--gold);border-radius:10px;background:var(--surface);font-size:14px;color:var(--muted)}

/* the first thing shown starts flush with the top of the reading area */
.learn .prose > .first-shown,.learn .prose > h2.first-shown,.learn .prose > .intro-card.first-shown{margin-top:0}

/* "Predict first" box */
.predict{margin-top:16px;padding:16px 18px}
.predict fieldset{border:0;margin:0;padding:0}
.predict legend{font-weight:700;font-size:14px;padding:0;margin-bottom:6px;color:var(--accent)}
.predict-q{margin:0 0 8px;font-weight:600}
.predict-options{display:flex;flex-wrap:wrap;gap:8px 20px}
.predict-options label{display:inline-flex;gap:6px;align-items:center;cursor:pointer}
.predict-feedback{margin:10px 0 0;min-height:1.2em;color:var(--muted)}
.predict-feedback.right{color:var(--good, #1f7a4d)}
.predict-feedback.wrong{color:var(--bad, #b3261e)}

/* footer */
.foot-grid{display:grid;grid-template-columns:1.6fr 1fr 1.2fr 1.4fr;gap:28px 36px}
.foot-brand .brand{display:inline-flex;align-items:center;gap:10px;font:700 18px var(--serif);color:var(--ink);text-decoration:none;margin-bottom:8px}
.foot-brand p{margin:0;max-width:34ch}
.foot-col h2{margin:0 0 10px;font:700 12px var(--sans);letter-spacing:.08em;text-transform:uppercase;color:var(--ink)}
.foot-col ul{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.foot-col p{margin:0}
.foot-col a,.foot-base a{color:var(--accent);text-decoration:none;text-underline-offset:3px}
.foot-col a:hover,.foot-col a:focus-visible{text-decoration:underline}
.foot-base{margin:28px 0 0;padding-top:16px;border-top:1px solid var(--line);font-size:13px}
@media (max-width:860px){.foot-grid{grid-template-columns:1fr 1fr}.foot-brand{grid-column:1 / -1}}
@media (max-width:520px){.foot-grid{grid-template-columns:1fr}}

/* ---- router: loading, notices, errors, focus ---- */
.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
.no-js .loading{display:none}
.loading{display:flex;align-items:center;gap:12px;color:var(--muted);padding:40px 0}
.spinner{width:20px;height:20px;border-radius:50%;border:3px solid var(--line);border-top-color:var(--accent);animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
/* While the next page loads, the one on screen is dimmed (after a short delay, so quick loads do not flicker) and a bar runs across the top. */
#app{transition:opacity .15s}
#app.refreshing{opacity:.55;transition-delay:.25s}
body:has(#app.refreshing)::before{content:"";position:fixed;inset:0 0 auto 0;height:3px;z-index:40;background:linear-gradient(90deg,transparent,var(--accent),transparent);background-size:40% 100%;background-repeat:no-repeat;animation:route-bar 1s ease-in-out infinite;animation-delay:.25s;opacity:0;animation-fill-mode:backwards}
@keyframes route-bar{0%{background-position:-40% 0;opacity:1}100%{background-position:140% 0;opacity:1}}
#app h1[tabindex="-1"]:focus{outline:none}
.notice{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:16px;padding:10px 14px;border:1px solid var(--line);border-left:4px solid var(--accent);border-radius:12px;background:var(--surface);font-size:14px}
.notice.warn{border-left-color:var(--warn);background:var(--bad-soft)}
.notice p{margin:0;flex:1 1 260px}
.notice .btn{padding:6px 12px}
.notice-close{margin-left:auto;border:0;background:none;color:var(--muted);font-size:20px;line-height:1;cursor:pointer;padding:2px 8px;border-radius:8px}
.notice-close:hover{color:var(--ink)}
.inline-error{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin:16px 0;padding:14px 16px;border:1px solid var(--warn);border-radius:12px;background:var(--bad-soft)}
.inline-error p{margin:0}
.empty .inline-error{margin:0;background:none;border:0;padding:0}
.resume-note{margin:0 0 16px;padding:10px 14px;border:1px solid var(--line);border-left:4px solid var(--accent);border-radius:10px;background:var(--surface);font-size:14px;color:var(--muted)}
.section-nav .btn.primary{margin-left:auto}
.hero-actions .btn{white-space:normal;text-align:center}

/* Long unbroken words (a long compound, a URL) wrap instead of widening the page. */
h1,h2,h3,.crumbs,.tag,.lede,.course-card p,.course-card li,.lesson-main,.lesson-main strong,.module-head p,.notice p,.empty p{overflow-wrap:break-word}
.course-card,.lesson-main,.course-head>*,.module-head>div,.hero>*{min-width:0}

/* The nav: where you are */
.bar nav a[aria-current]{color:var(--ink)}
.bar nav a[aria-current=page]{text-decoration:underline;text-underline-offset:6px;text-decoration-thickness:2px;text-decoration-color:var(--accent)}

/* A single path card (the home page has one path today) uses the width as a deliberate two-column card. */
@media (min-width:860px){
  .grid>.course-card:only-child:has(.path-courses){grid-column:1/-1;display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);grid-template-rows:auto auto 1fr auto;grid-template-areas:"tags list" "title list" "summary list" "foot foot";column-gap:48px;row-gap:10px}
  .grid>.course-card:only-child:has(.path-courses) .tags{grid-area:tags}
  .grid>.course-card:only-child:has(.path-courses) h3{grid-area:title}
  .grid>.course-card:only-child:has(.path-courses)>p{grid-area:summary}
  .grid>.course-card:only-child:has(.path-courses) .path-courses{grid-area:list;margin:0}
  .grid>.course-card:only-child:has(.path-courses) .card-foot{grid-area:foot;margin-top:8px}
}

/* ---- scrolling boxes: a shade on the side that has more, and a visible focus ---- */
.scroll-shell{position:relative;min-width:0}
.scroll-shell::before,.scroll-shell::after{content:"";position:absolute;top:0;bottom:0;width:26px;z-index:1;pointer-events:none;opacity:0;transition:opacity .15s}
.scroll-shell::before{left:0;border-radius:12px 0 0 12px;background:linear-gradient(to right,color-mix(in srgb,var(--ink) 22%,transparent),transparent)}
.scroll-shell::after{right:0;border-radius:0 12px 12px 0;background:linear-gradient(to left,color-mix(in srgb,var(--ink) 22%,transparent),transparent)}
.scroll-shell[data-more=right]::after,.scroll-shell[data-more=both]::after,.scroll-shell[data-more=left]::before,.scroll-shell[data-more=both]::before{opacity:1}
.scroll-shell [tabindex]:focus-visible{outline:3px solid var(--accent);outline-offset:-3px;border-radius:12px}
.fig-hint{display:none;margin:6px 0 0;text-align:center;font-size:12px;color:var(--muted)}

/* ---- figures on a phone keep their drawn size and scroll sideways, so their text stays readable ---- */
@media (max-width:640px){
  .figure{padding:12px 10px 10px}
  .figure-art{overflow-x:auto;justify-content:flex-start;padding-block:4px;-webkit-overflow-scrolling:touch}
  .fig-svg{flex:none;width:calc(var(--fig-w,700) * .97px);min-width:calc(var(--fig-w,700) * .97px);max-width:none}
  .scroll-shell[data-scrolls]+.fig-hint{display:block}
  .prose th,.prose td{padding:8px 9px}
  .prose th{letter-spacing:0}
  .deeper-body{padding:6px 12px 12px}
}

/* ---- coloured words inside figures use the darker ink of their hue (4.5:1 on the light theme) ---- */
.fig-svg text[fill="var(--k0)"]{fill:var(--k0-ink)}
.fig-svg text[fill="var(--k1)"]{fill:var(--k1-ink)}
.fig-svg text[fill="var(--k2)"]{fill:var(--k2-ink)}
.fig-svg text[fill="var(--k3)"]{fill:var(--k3-ink)}
.fig-svg text[fill="var(--k4)"]{fill:var(--k4-ink)}
.fig-svg text[fill="var(--k5)"]{fill:var(--k5-ink)}
.fig-svg text[fill="var(--k6)"]{fill:var(--k6-ink)}

/* ---- headings that are only card titles ---- */
.lab-h{font:700 17px/1.2 var(--sans);letter-spacing:0}

/* ---- links are told apart by more than colour ---- */
.crumbs a{text-decoration:underline;text-decoration-color:color-mix(in srgb,currentColor 45%,transparent);text-underline-offset:3px}
.crumbs [aria-current=page]{color:var(--ink);font-weight:600}
.foot-col p a,.foot-base a,.prose a,.hint a,.lede a,.notice a,.muted a{text-decoration:underline;text-underline-offset:3px}
.foot-col p a,.foot-base a{color:var(--accent)}

/* ---- on a tablet or phone: contents of a lesson folds into one line; toolbars stay on one row; targets are big enough ---- */
.toc summary{display:flex;justify-content:space-between;align-items:baseline;gap:8px;list-style:none;cursor:default;margin-bottom:6px}
.toc summary::-webkit-details-marker{display:none}
.toc summary::after{display:none}
@media (max-width:860px){
  .toc{padding:0}
  .toc>details{border:1px solid var(--line-strong);border-radius:12px;background:var(--surface)}
  .toc summary{margin:0;padding:10px 14px;min-height:44px;align-items:center;cursor:pointer}
  .toc summary::after{display:block;content:"";flex:none;width:8px;height:8px;border-right:2px solid var(--muted);border-bottom:2px solid var(--muted);transform:rotate(45deg);transition:transform .15s}
  .toc details[open] summary::after{transform:rotate(-135deg)}
  .toc summary .toc-count{margin-left:auto}
  .toc details[open] summary{border-bottom:1px solid var(--line)}
  .toc ol{display:block;columns:2;column-gap:20px;margin:0;padding:6px 8px 10px;border-left:0}
  .toc li{break-inside:avoid}
  .toc button.link{margin-left:0;border-left:0;padding:10px 8px;min-height:44px}
  .playback{gap:8px 10px}
  .playback button:not(.primary) span{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  .playback button{min-width:44px;justify-content:center}
}
@media (max-width:560px){
  .toc ol{columns:1}
}
@media (max-width:860px),(pointer:coarse){
  .sim button:not(.btn),.panel-button{min-height:44px}
  .settings select,.settings input[type=number],.speed-control input[type=number],.inspector select{min-height:44px}
  .settings .toggle{min-height:44px}
  .settings .toggle input{width:22px;height:22px}
  .slider-label input[type=range],.speed-control input[type=range]{min-height:32px}
  .crumbs{margin-bottom:8px}
  .crumbs a{display:inline-block;padding-block:11px}
  .foot-col ul{gap:0}
  .foot-col a,.foot-base a{display:inline-block;padding-block:11px}
  .foot-col p a{padding-block:0;display:inline}
  .bar nav a{padding-block:12px}
  .lang-btn{min-height:42px;padding-inline:12px}
  .theme-toggle{width:44px;height:44px}
  .link-btn{padding-block:10px}
  .tab{padding-block:12px}
  .brand{min-height:44px}
  .foot-brand .brand{padding-block:7px}
  .predict-options label{min-height:44px}
  .predict-options input{width:20px;height:20px}
}

/* The footer waits for the first page, so it does not sit under "Loading…" and jump away when the page arrives. */
html:not(.app-ready) footer.site{display:none}

/* "Parameters" shortcut in the lab toolbar: only where the parameters are stacked below the plot */


@media (max-width:860px){.crumbbar{margin-bottom:8px}.back-btn{width:44px;height:44px}}

/* kind and length tags */
.meta-chips{display:inline-flex;flex-wrap:wrap;gap:6px}
.meta-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 11px 4px 9px;border-radius:999px;font-size:13px;font-weight:650;line-height:1.3;white-space:nowrap;border:1px solid transparent}
.meta-chip .ic{display:inline-flex}
.meta-chip.kind-reading{background:color-mix(in srgb,var(--k4) 15%,transparent);color:var(--k4-ink);border-color:color-mix(in srgb,var(--k4) 35%,transparent)}
.meta-chip.kind-lab{background:var(--accent-soft);color:var(--accent);border-color:color-mix(in srgb,var(--accent) 40%,transparent)}
.meta-chip.time{background:var(--surface-2);color:var(--ink);border-color:var(--line)}
.lesson-meta-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;margin-top:6px}
.lesson-meta-row .status-inline{display:none;font-size:13px}
.lesson-meta-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 14px;margin-bottom:6px}
.lesson-meta-bar .eyebrow{margin:0}
@media (max-width:560px){.lesson-meta-row .status-inline{display:inline}}

/* ---- lab layout: the parameters stay in view ---- */
.fab-settings,.sheet-bar{display:none}
/* Wide screens: one grid of twelve columns beside a sticky parameters column. The plot, the charts below it and the
   tables share the six columns (the grid is only used for placing the cards: on the normal page every card takes a full row), and the
   parameters card runs beside all of them, so a slider stays reachable while you scroll down to the chart it moves.
   display:contents puts the plot card, the parameters card and the cards of the "below" box into the same grid; the
   twelve explicit rows are empty ones that cost nothing (no row gap: cards carry their own top margin). */
@media (min-width:861px){
  :is(.sim-host,.sim-host > div):has(> .sim){display:grid;grid-template-columns:repeat(12,minmax(0,1fr)) 300px;grid-template-rows:repeat(14,auto);grid-auto-flow:row dense;column-gap:18px;row-gap:0;align-items:start}
  :is(.sim-host,.sim-host > div):has(> .sim) > .sim{display:contents}
  :is(.sim-host,.sim-host > div):has(> .sim) > .sim > .plot-card{grid-column:1 / 13;grid-row:1}
  :is(.sim-host,.sim-host > div):has(> .sim) > .sim > :is(.settings,.side){grid-column:13;grid-row:1 / 15;position:sticky;top:16px;max-height:calc(100dvh - 32px);overflow:auto;overscroll-behavior:contain}
  :is(.sim-host,.sim-host > div):has(> .sim) > [data-ref=below]{display:contents}
  :is(.sim-host,.sim-host > div):has(> .sim) > .sim ~ .sim{display:contents !important}
  :is(.sim-host,.sim-host > div):has(> .sim) > :not(.sim):not([data-ref=below]),
  :is(.sim-host,.sim-host > div):has(> .sim) > [data-ref=below] > *,
  :is(.sim-host,.sim-host > div):has(> .sim) > .sim ~ .sim > *{grid-column:span 12;margin-top:18px}

  /* a chart beside a table: the table is the narrower card, so it does not stretch to the chart's height */
  [data-lab-card]{min-width:0}
  /* legacy labs: their own fullscreen element is the .sim, which keeps its own two columns */
  .sim:is(:fullscreen,.expanded){display:grid !important}
  .sim:is(:fullscreen,.expanded) > :is(.settings,.side){position:static;max-height:none}
}
/* Fullscreen (the stage): the same grid, but each chart is a screen tall, so a long chart such as the sigmoid fills the
   screen from top to bottom. The page scrolls (and snaps) from one to the next while the parameters stay pinned. */
.lab-stage:is(:fullscreen,.expanded){scroll-snap-type:y proximity}
.lab-stage:is(:fullscreen,.expanded) .plot-card,.lab-stage:is(:fullscreen,.expanded) [data-lab-card=chart]{scroll-snap-align:start;scroll-margin-top:12px}
.lab-stage:is(:fullscreen,.expanded){--plot-h:max(280px,calc(100dvh - 290px))}
.lab-stage:is(:fullscreen,.expanded) [data-lab-card=chart] .chart canvas{height:max(240px,calc(100dvh - 230px)) !important}
.lab-stage:is(:fullscreen,.expanded) [data-lab-card=chart]{min-height:calc(100dvh - 2 * clamp(12px,2vw,24px))}
/* Phones: the parameters open as a sheet over the lower part of the screen. */
@media (max-width:860px){
  .lab-sheet-target:not(.sheet-open){display:none}
  .lab-stage:is(:fullscreen,.expanded) .lab-sheet-target:not(.sheet-open),.sim:is(:fullscreen,.expanded) .lab-sheet-target:not(.sheet-open){display:block}
  .lab-sheet-target.sheet-open{position:fixed;left:8px;right:8px;bottom:8px;z-index:60;max-height:56dvh;overflow:auto;margin:0;border:1px solid var(--line-strong);border-radius:16px;box-shadow:0 -10px 30px var(--shadow);overscroll-behavior:contain}
  .sheet-bar{display:flex;align-items:center;justify-content:space-between;position:sticky;top:-18px;margin:-18px -18px 8px;padding:12px 18px;background:var(--surface);border-bottom:1px solid var(--line);z-index:1}
  .sheet-close{display:inline-grid;place-items:center;width:44px;height:44px;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--ink);cursor:pointer}
  .lab-stage:not(:is(:fullscreen,.expanded)) .sheet-bar{display:flex}
  .fab-settings{display:inline-flex;align-items:center;gap:8px;position:fixed;right:14px;bottom:14px;z-index:50;min-height:48px;padding:0 18px;border:1px solid var(--accent);border-radius:999px;background:var(--accent);color:var(--accent-ink);font:700 14px var(--sans);box-shadow:0 6px 20px var(--shadow);cursor:pointer}
  body.lab-sheet-open{padding-bottom:calc(56dvh + 16px)}
  body.lab-sheet-open .fab-settings{display:none}
  body:has(:is(.sim,.lab-stage):is(:fullscreen,.expanded)) .fab-settings{display:none}
}
.to-settings{display:none}
@media (max-width:860px){.to-settings{display:inline-flex}}
@media (max-width:860px){.lab-sheet-target.sheet-open > h3{display:none}}

/* Fullscreen (the stage), wide screens: the main simulator on the left, the first one or two boxes (tables or charts) in a
   column to its right, and the plot card spans as many rows as there are such boxes; the parameters stay pinned in their own
   column at the far edge. Boxes after the second get a screen of their own below. */
@media (min-width:1100px){
  .sim-host .lab-stage:is(:fullscreen,.expanded) > .sim > .plot-card{grid-column:1 / 8;grid-row:1 / span var(--side-rows,1)}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side]{grid-column:8 / 13 !important;grid-row:auto;margin-top:0}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] ~ [data-lab-card=side]{margin-top:18px}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] table{width:100%;min-width:0}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] :is(th,td){white-space:normal;overflow-wrap:break-word;word-break:normal}
}

/* ---- Quick Quiz: a floating button and panel, separate from the parameters ---- */
.qq-widget{position:fixed;right:24px;bottom:16px;z-index:45;display:flex;flex-direction:column;align-items:flex-end;gap:10px;pointer-events:none}
.qq-widget > *{pointer-events:auto}
.qq-fab{position:relative;display:inline-grid;place-items:center;width:52px;height:52px;border:1px solid var(--accent);border-radius:50%;background:var(--accent);color:var(--accent-ink);box-shadow:0 6px 20px var(--shadow);cursor:pointer}
.qq-fab:hover{filter:brightness(1.08)}
.qq-fab > svg{width:24px;height:24px}
.qq-badge[hidden]{display:none}
.qq-badge{position:absolute;top:-6px;right:-6px;display:inline-grid;place-items:center;min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:var(--warn);color:#fff;font:700 12px var(--sans);border:2px solid var(--bg)}
.qq-badge.pulse{animation:qq-pulse .9s ease-out 3}
@keyframes qq-pulse{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--accent) 60%,transparent)}100%{box-shadow:0 0 0 14px transparent}}
@media (prefers-reduced-motion:reduce){.qq-badge.pulse{animation:none}}
.qq-panel{width:min(360px,calc(100vw - 32px));max-height:min(70dvh,560px);overflow:auto;padding:14px 16px;border:1px solid var(--line-strong);border-radius:16px;background:var(--surface);box-shadow:0 10px 36px var(--shadow);overscroll-behavior:contain}
.qq-panel[hidden]{display:none}
.qq-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.qq-head strong{flex:1;font-size:15px}
.qq-nav{display:inline-flex;align-items:center;gap:6px}
.qq-nav[hidden]{display:none}
.qq-nav button,.qq-close{display:inline-grid;place-items:center;width:34px;height:34px;border:1px solid var(--line-strong);border-radius:10px;background:var(--surface);color:var(--ink);font-size:18px;line-height:1;cursor:pointer}
.qq-nav button:disabled{opacity:.4;cursor:default}
.qq-pos{font-size:13px;color:var(--muted);min-width:3.2em;text-align:center}
.qq-panel .predict{margin:0;padding:0;border:0;background:none;box-shadow:none}
.qq-panel .predict legend{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.qq-panel .predict-q{font-size:14px;margin:0 0 10px}
.qq-panel .predict-options{flex-direction:column;align-items:flex-start;gap:8px}
.qq-panel .predict-feedback{font-size:13px}
.qq-note{margin:12px 0 0;font-size:12px;color:var(--muted)}
/* The parameters card keeps clear of the quiz button below it. */
@media (min-width:861px){
  :is(.sim-host,.sim-host > div):has(> .sim) > .sim > :is(.settings,.side){max-height:calc(100dvh - 32px - 72px)}
}
@media (max-width:860px){
  .qq-widget{right:14px;bottom:78px}
  body.lab-sheet-open .qq-widget{display:none}
  .qq-fab{width:48px;height:48px}
}

/* Fullscreen, wide screens: the layout fills the screen. The plot column is as wide as the square plot at full height
   (but never more than 42% of the screen), the boxes beside it share what is left, and the parameters are pinned at the
   far edge. A box after the second spans the plot and boxes columns. */
@media (min-width:1100px){
  .sim-host .lab-stage:is(:fullscreen,.expanded){grid-template-columns:minmax(0,min(max(calc(var(--plot-h) + 52px),480px),42%)) minmax(0,1fr) 300px;min-height:100dvh}
  .sim-host .lab-stage:is(:fullscreen,.expanded) > .sim > .plot-card{grid-column:1;grid-row:1 / span var(--side-rows,1)}
  .sim-host .lab-stage:is(:fullscreen,.expanded) > .sim > :is(.settings,.side){grid-column:3;grid-row:1 / 15;max-height:calc(100dvh - 32px - 72px)}
  .sim-host .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side]{grid-column:2 !important}
  .sim-host .lab-stage:is(:fullscreen,.expanded) [data-lab-card=chart],
  .sim-host .lab-stage:is(:fullscreen,.expanded) [data-lab-card=table],
  .sim-host .lab-stage:is(:fullscreen,.expanded) > :not(.sim):not([data-ref=below]):not(.qq-widget):not([data-lab-card]),
  .sim-host .lab-stage:is(:fullscreen,.expanded) > [data-ref=below] > :not([data-lab-card]){grid-column:1 / 3 !important}
}
.lab-stage:is(:fullscreen,.expanded) .qq-widget{right:24px;bottom:16px}

/* Docked: on a wide screen the round Quick Quiz button sits right under the Parameters card (placed by predict.js) and the
   panel opens below it, as wide as the card. */
.qq-fab-label{display:none}
/* Wide screens: the button is a rectangle docked under the Parameters card (kit/predict.js sets its position), the panel opens below it. */
.qq-widget.qq-docked{right:auto;bottom:auto;align-items:stretch;flex-direction:column-reverse}
.qq-docked .qq-fab{width:100%;height:44px;display:flex;align-items:center;justify-content:center;gap:8px;padding:0 14px;border-radius:12px;font:700 14px var(--sans)}
.qq-docked .qq-fab-label{display:inline}
.qq-docked .qq-badge{position:static;min-width:22px;border:0;margin-left:2px}
.qq-docked .qq-panel{position:static;width:100%;max-height:none}



.predict-check{margin-top:12px;min-height:40px}
.predict-feedback.none{color:var(--muted)}

/* Fullscreen, wide screens: the boxes beside the plot share the height of the first screen, so there are no gaps and no empty
   space under them on a very wide screen (3440x1440): each box stretches, its chart or table fills it. */
@media (min-width:1100px){
  .sim-host .lab-stage:is(:fullscreen,.expanded) > .sim > .plot-card{min-height:calc(100dvh - 2 * clamp(12px,2vw,24px))}
  .sim-host .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side]{align-self:stretch;display:flex;flex-direction:column;min-height:0}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] .chart{flex:1;min-height:var(--chart-min,200px)}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] .chart canvas{height:100% !important}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] .table-scroll{flex:1;min-height:0;overflow:auto}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] table{height:100%}
}

/* Fullscreen: the fixed row tracks of the lab grid must not add their gaps (14 empty rows = 230px of scroll). */
@media (min-width:1100px){
  .sim:is(:fullscreen,.expanded),.sim-host .lab-stage:is(:fullscreen,.expanded),.lab-stage:is(:fullscreen,.expanded) > .sim{row-gap:0 !important}
}

/* Fullscreen, wide: the plot card, the boxes beside it and the Parameters box all start on the same line, and the last of them ends with the plot card. */
@media (min-width:1100px){
  .sim-host .lab-stage:is(:fullscreen,.expanded) > .sim > :is(.settings,.side){margin-top:0;top:0}
  .sim-host .lab-stage:is(:fullscreen,.expanded) > .sim > .plot-card,
  .sim-host .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side]{margin-top:0}
  .sim-host .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] ~ [data-lab-card=side]{margin-top:18px}
}
/* Flow mode (data-side-flow on the stage): the boxes beside the plot keep the height of their content, and the stage scrolls. */
@media (min-width:1100px){
  .lab-stage[data-side-flow]:is(:fullscreen,.expanded) [data-lab-card=side]{align-self:start;min-height:auto;display:block}
  .lab-stage[data-side-flow]:is(:fullscreen,.expanded) [data-lab-card=side] .chart{flex:none;min-height:0}
}
@media (min-width:1100px){
  .sim-host .lab-stage:is(:fullscreen,.expanded){grid-template-rows:var(--side-tpl,repeat(14,auto))}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] .table-scroll{flex:0 1 auto}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side] table{height:auto}
}


/* The docked Quick Quiz button sits under the Parameters card, so the lab area keeps that much room below its grid: the button
   never lands on the lesson text that follows the lab. */
@media (min-width:861px){
  .has-qq:not(:is(:fullscreen,.expanded)){padding-bottom:68px}
}

/* Fullscreen, wide: every lab lines up the same way: the plot card, the boxes beside it and the Parameters box all start on the
   padding line, and a second box beside the plot is separated by a gap, not by stray margins (the grid rules above set margins
   with a higher specificity, hence !important). */
@media (min-width:1100px){
  .lab-stage:is(:fullscreen,.expanded) [data-lab-first],
  .lab-stage:is(:fullscreen,.expanded) > .sim > :is(.settings,.side,.plot-card),
  .sim:is(:fullscreen,.expanded) > :is(.settings,.side,.plot-card){margin-top:0 !important}
  .lab-stage:is(:fullscreen,.expanded) [data-lab-card=side]:not([data-lab-first]){margin-top:18px !important}
  .sim:is(:fullscreen,.expanded) > :is(.settings,.side){top:0 !important}
  .lab-stage:is(:fullscreen,.expanded),.sim:is(:fullscreen,.expanded){row-gap:0 !important}
}

/* Fullscreen, wide: a pair wrapper hands its two cards to the lab grid, like any other box. */
@media (min-width:1100px){
  .lab-stage:is(:fullscreen,.expanded) [data-ref=pair]{display:contents !important}
}

/* Fullscreen, wide: no empty row from a spacer's margin; a lab without boxes beside the plot gives the plot card the width; whatever
   is still taller than the screen (a long form) scrolls inside the plot card, never the page. */
@media (min-width:1100px){
  .lab-stage:is(:fullscreen,.expanded) > :not(.sim):not(.card):not(.qq-widget):not([data-lab-card]),
  .lab-stage:is(:fullscreen,.expanded) > [data-ref=below] > :not(.card):not(.qq-widget):not([data-lab-card]){margin-top:0 !important}
  .sim-host .lab-stage[data-sides="0"]:is(:fullscreen,.expanded){grid-template-columns:minmax(0,1fr) 300px}
  .sim-host .lab-stage[data-sides="0"]:is(:fullscreen,.expanded) > .sim > .plot-card{grid-column:1}
  .sim-host .lab-stage[data-sides="0"]:is(:fullscreen,.expanded) > .sim > :is(.settings,.side){grid-column:2}
  .lab-stage:is(:fullscreen,.expanded) > .sim > .plot-card{max-height:calc(100dvh - 2 * clamp(12px,2vw,24px));overflow:auto}
}
