/* AP Bio Lab Bench — shared stylesheet
   Layout: header band → sticky step nav → single reading column (max 880px)
   that widens to 1120px for simulation panels. */
/* Fallback faces sized to match the web fonts (Audit 5, CLS). While Google Fonts load (font-display: swap), text is drawn in
   Arial / Courier New (or their metric twins Arimo, Liberation, Cousine) scaled to the web font's width and line metrics, so the
   swap does not re-wrap the nav, tags or footer. Ratios measured in Chromium against the loaded fonts. */
@font-face { font-family: "Source Sans fb"; font-weight: 100 549; src: local("Arial"), local("ArialMT"), local("Arimo"), local("Liberation Sans"), local("LiberationSans"); size-adjust: 92.5%; ascent-override: 110%; descent-override: 43%; line-gap-override: 0%; }
@font-face { font-family: "Source Sans fb"; font-weight: 550 649; src: local("Arial Bold"), local("Arial-BoldMT"), local("Arimo Bold"), local("Arimo-Bold"), local("Liberation Sans Bold"), local("LiberationSans-Bold"); size-adjust: 89.1%; ascent-override: 114.5%; descent-override: 45%; line-gap-override: 0%; }
@font-face { font-family: "Source Sans fb"; font-weight: 650 900; src: local("Arial Bold"), local("Arial-BoldMT"), local("Arimo Bold"), local("Arimo-Bold"), local("Liberation Sans Bold"), local("LiberationSans-Bold"); size-adjust: 91.6%; ascent-override: 111.5%; descent-override: 43.5%; line-gap-override: 0%; }
@font-face { font-family: "Bricolage fb"; font-weight: 100 900; src: local("Arial Bold"), local("Arial-BoldMT"), local("Arimo Bold"), local("Arimo-Bold"), local("Liberation Sans Bold"), local("LiberationSans-Bold"); size-adjust: 98.5%; ascent-override: 94.5%; descent-override: 27.5%; line-gap-override: 0%; }
@font-face { font-family: "JetBrains Mono fb"; font-weight: 100 549; src: local("Courier New"), local("CourierNewPSMT"), local("Cousine"), local("Liberation Mono"), local("LiberationMono"); ascent-override: 102%; descent-override: 30%; line-gap-override: 0%; }
@font-face { font-family: "JetBrains Mono fb"; font-weight: 550 900; src: local("Courier New Bold"), local("CourierNewPS-BoldMT"), local("Cousine Bold"), local("Cousine-Bold"), local("Liberation Mono Bold"), local("LiberationMono-Bold"); ascent-override: 102%; descent-override: 30%; line-gap-override: 0%; }
:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-2: #e8eeea;
  --ink: #14211c;
  --muted: #56665f;
  --line: #cfd9d3;
  --accent: #0d6e55;          /* chlorophyll green */
  --accent-ink: #ffffff;
  --accent-soft: #d9efe6;
  --stain: #a8326b;           /* stain magenta: secondary emphasis */
  --stain-soft: #f6e1eb;
  --ok: #1f7a3d;  --ok-soft: #dff1e4;
  --warn: #9a5b00; --warn-soft: #fbedd5;
  --bad: #b3261e;  --bad-soft: #f9e0de;
  /* chart series */
  --s1: #0d6e55; --s2: #d55e00; --s3: #0072b2; --s4: #b3261e; --s5: #00798c; --s6: #222222;
  --grid: #e1e8e4;
  --f-display: "Bricolage Grotesque", "Bricolage fb", "Segoe UI", system-ui, sans-serif;
  --f-body: "Source Sans 3", "Source Sans fb", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "JetBrains Mono", "JetBrains Mono fb", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --r: 10px;
  --r-sm: 6px;
  /* Paper colors for the report and worksheet views: always black on white, in every theme */
  --paper: #ffffff; --paper-ink: #111111; --paper-muted: #555555; --paper-line: #777777; --paper-shade: #eeeeee;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1613; --surface: #17211d; --surface-2: #1f2b26; --ink: #e4ece8; --muted: #9db0a7;
    --line: #2f3d37; --accent: #4cc39b; --accent-ink: #06231a; --accent-soft: #173a2f;
    --stain: #e781b1; --stain-soft: #3d1f2e;
    --ok: #6fd08f; --ok-soft: #173723; --warn: #f0b85a; --warn-soft: #3a2b12; --bad: #f2867f; --bad-soft: #401c1a;
    --s1: #4cc39b; --s2: #ff9a4d; --s3: #6aaaf5; --s4: #ff6f61; --s5: #eef2f0; --s6: #e0c000;
    --grid: #26332d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1613; --surface: #17211d; --surface-2: #1f2b26; --ink: #e4ece8; --muted: #9db0a7;
  --line: #2f3d37; --accent: #4cc39b; --accent-ink: #06231a; --accent-soft: #173a2f;
  --stain: #e781b1; --stain-soft: #3d1f2e;
  --ok: #6fd08f; --ok-soft: #173723; --warn: #f0b85a; --warn-soft: #3a2b12; --bad: #f2867f; --bad-soft: #401c1a;
  --s1: #4cc39b; --s2: #ff9a4d; --s3: #6aaaf5; --s4: #ff6f61; --s5: #eef2f0; --s6: #e0c000;
  --grid: #26332d; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-body); font-size: 17px; line-height: 1.55;
}
img, svg, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.9rem, 4.5vw, 2.8rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; font-weight: 650; }
h4 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.3em; display: grid; gap: .35em; }
code, .mono { font-family: var(--f-mono); font-size: .88em; }
sub, sup { line-height: 0; }

.wrap { width: 100%; max-width: 880px; margin: 0 auto; }
.wrap--wide { max-width: 1120px; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* ---------- Header ---------- */
.lab-header { background: var(--surface); border-bottom: 1px solid var(--line); padding-block: 20px 26px; }
.lab-header .crumbs { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: .92rem; color: var(--muted); margin-bottom: 14px; }
.lab-header .crumbs a { color: var(--muted); }
.eyebrow { font-family: var(--f-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 600; }
.lab-header .driving-q { font-size: 1.18rem; color: var(--muted); margin-top: 10px; max-width: 60ch; font-style: italic; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.eyebrow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.time-chip { font-family: var(--f-mono); font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tags .tag--time { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.tag { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ---------- Step nav ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--surface); }
.step-nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.step-nav ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin; padding-block: 8px; }
.step-nav li { flex: none; }
.step-nav a { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .9rem; font-weight: 600; white-space: nowrap; }
.step-nav a .n { font-family: var(--f-mono); font-size: .75rem; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.step-nav a:hover { background: var(--surface-2); color: var(--ink); }
.step-nav a[aria-current="true"] { background: var(--accent-soft); color: var(--ink); }
.step-nav a[aria-current="true"] .n { background: var(--accent); color: var(--accent-ink); }

/* ---------- Sections ---------- */
main { padding-block: 28px 64px; }
.step { display: grid; gap: 18px; padding-block: 34px; border-bottom: 1px solid var(--line); scroll-margin-top: 64px; }
.step:last-child { border-bottom: 0; }
.step > header { display: grid; gap: 6px; }
.step-body { display: grid; gap: 16px; }
.step-body > p, .prose > p, .prose li { max-width: 68ch; }
.prose { display: grid; gap: 12px; }
.lede { font-size: 1.08rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Callouts */
.callout { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 8px; }
.callout > .callout-title { font-family: var(--f-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.callout--question { background: var(--accent-soft); border-color: transparent; }
.callout--question > .callout-title { color: var(--accent); }
.callout--safety { background: var(--warn-soft); border-color: transparent; }
.callout--safety > .callout-title { color: var(--warn); }
.callout--tip { background: var(--surface-2); border-color: transparent; }
.callout--key { background: var(--stain-soft); border-color: transparent; }
.callout--key > .callout-title { color: var(--stain); }
.equation { font-family: var(--f-mono); font-size: 1rem; background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 14px; overflow-x: auto; white-space: nowrap; }

/* Layout helpers */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: grid; gap: 10px; }
.grid-2 > *, .grid-3 > *, .row > * { min-width: 0; }

/* ---------- Simulation panel ---------- */
.sim { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: grid; grid-template-columns: minmax(240px, 300px) 1fr; }
.sim > .controls { padding: 18px; border-right: 1px solid var(--line); background: var(--surface-2); display: grid; gap: 14px; align-content: start; }
.sim > .stage { padding: 18px; display: grid; gap: 14px; align-content: start; min-width: 0; }
.sim-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .sim { grid-template-columns: 1fr; }
  .sim > .controls { border-right: 0; border-bottom: 1px solid var(--line); }
}
.viz { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); display: block; }
canvas.viz { height: auto; }

/* Form controls */
.field { display: grid; gap: 5px; }
.field > label, .field > .label { font-size: .86rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: .8rem; color: var(--muted); }
.field output, .val { font-family: var(--f-mono); font-size: .85rem; color: var(--accent); font-weight: 600; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; width: 100%;
}
textarea { min-height: 92px; resize: vertical; line-height: 1.45; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 17px; height: 17px; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; min-height: 24px; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem; padding: 6px 12px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.btn { font: inherit; font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--sm { padding: 5px 10px; font-size: .84rem; }

/* Readouts */
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.readout { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 12px; display: grid; gap: 2px; }
.readout .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.readout .v { font-family: var(--f-mono); font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { background: var(--surface-2); font-weight: 650; font-size: .82rem; }
table.data th .unit { font-weight: 400; color: var(--muted); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--f-mono); font-size: .85rem; }
table.data tr:last-child td { border-bottom: 0; }
table.data input { padding: 4px 6px; min-width: 72px; font-family: var(--f-mono); font-size: .85rem; text-align: right; }
table.data tfoot td { background: var(--surface-2); font-weight: 600; }

/* Chart */
.chart { width: 100%; max-width: 760px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-family: var(--f-body); font-size: 12px; }
.chart .axis-label { fill: var(--ink); font-weight: 600; font-size: 13px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--muted); stroke-width: 1; }
/* Empty chart: labelled axes with a centred note (no fake 0–1 scale) */
.chart.is-empty .gridline { stroke-dasharray: 3 5; opacity: .7; }
.chart .chart-empty rect { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.chart .chart-empty text { fill: var(--muted); font-size: 14px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-note { font-size: .82rem; color: var(--muted); font-family: var(--f-mono); }
/* Modeled, not measured: a quiet tag under each Lab.table (charts draw it in the SVG), and the one-time note on "observed". */
.sim-tag { margin: 3px 2px 0; max-width: none; text-align: right; font-size: .74rem; font-weight: 600; letter-spacing: .03em; color: var(--muted); }
.sim-tag::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; border: 1.5px solid currentColor; vertical-align: 1px; }
.sim-note { margin: 6px 0 10px; padding: 6px 10px; max-width: 70ch; font-size: .86rem; color: var(--muted); border-left: 3px solid var(--line); background: var(--surface-2); border-radius: 0 var(--r) var(--r) 0; }
.sim-note strong { color: var(--ink); }

/* Quiz */
.quiz { display: grid; gap: 14px; }
.q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 10px; }
.q .q-stem { font-weight: 600; max-width: 70ch; }
.q .q-num { font-family: var(--f-mono); color: var(--accent); margin-right: 6px; }
.q .choices { display: grid; gap: 6px; }
.q .choice { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; }
.q .choice:hover { border-color: var(--accent); }
.q .choice input { margin-top: 3px; flex: none; }
.q .choice.is-right { border-color: var(--ok); background: var(--ok-soft); }
.q .choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.q .num-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.q .num-row input { max-width: 160px; font-family: var(--f-mono); }
.feedback { font-size: .92rem; border-radius: var(--r-sm); padding: 8px 12px; }
.feedback.ok { background: var(--ok-soft); color: var(--ink); border-left: 3px solid var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--ink); border-left: 3px solid var(--bad); }
.field-msg { margin: 4px 0 0; flex: 1 0 100%; max-width: 60ch; } /* Lab.validate message under an input */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.score { font-family: var(--f-mono); font-size: .9rem; color: var(--muted); }

/* Written responses */
.prompt { display: grid; gap: 6px; }
.prompt > label { font-weight: 600; max-width: 70ch; }
.prompt .saved { font-size: .76rem; color: var(--muted); font-family: var(--f-mono); min-height: 1em; }
.cer { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.cer .prompt > label::before { content: attr(data-letter); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--stain); color: #fff; font-size: .78rem; font-family: var(--f-mono); margin-right: 8px; }

/* Pills / status */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* Responses toolbar */
.responses-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.responses-bar .grow { flex: 1 1 200px; font-size: .9rem; color: var(--muted); }
.copy-fallback { width: 100%; min-height: 160px; font-family: var(--f-mono); font-size: .8rem; }

details.disclose { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
details.disclose > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
details.disclose > .inner { padding: 0 14px 14px; display: grid; gap: 10px; }

.site-footer { padding-block: 28px 40px; font-size: .84rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--surface); }
.site-footer .wrap { display: grid; gap: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  h2 { font-size: 1.35rem; }
}

/* ---------- Student identity (site-wide sign-in line / panel) ---------- */
.linkbtn { font: inherit; background: none; border: 0; padding: 0 2px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkbtn:hover { color: var(--ink); }
.id-host { display: grid; gap: 8px; }
.id-box { display: grid; gap: 8px; }
.id-panel { background: var(--accent-soft); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 8px; }
.id-title { font-family: var(--f-display); font-weight: 700; font-size: 1.08rem; }
.id-fields { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; }
.id-fields .id-f-name { flex: 1 1 260px; min-width: 0; }
.id-fields .id-f-period { flex: 0 1 150px; min-width: 0; }
.id-actions { display: flex; gap: 8px; }
.id-err { color: var(--bad); font-size: .9rem; min-height: 0; }
.id-err:empty { display: none; }
.id-line { font-size: .92rem; color: var(--muted); }
.id-line strong { color: var(--ink); }
.id-line .ds-id { font-family: var(--f-mono); color: var(--ink); background: var(--surface-2); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }
.id-note { color: var(--warn); }
.id-confirm { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; font-size: .9rem; background: var(--warn-soft); border-radius: var(--r-sm); padding: 8px 12px; }
.id-line .id-saved { margin-left: 10px; font-size: .84rem; color: var(--ok); white-space: nowrap; }
.id-line .id-saved[data-state="bad"] { color: var(--bad); font-weight: 600; }
.restore-newer { color: var(--bad); }
.id-owner { display: grid; gap: 8px; font-size: .92rem; background: var(--warn-soft); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--r-sm); padding: 10px 14px; }
.id-owner--close { background: var(--accent-soft); border-left-color: var(--accent); }
.id-owner-msg { margin: 0; overflow-wrap: anywhere; }
.id-owner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media print { .id-owner, .id-saved { display: none !important; } }

/* ---------- Report + save/resume tools (responses toolbar) ---------- */
[data-responses] { display: grid; gap: 10px; }
.tool-status { font-size: .9rem; color: var(--muted); }
.tool-status:empty { display: none; }
.tool-status.is-bad { color: var(--bad); }
.preview-note { font-size: .88rem; color: var(--ink); background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: var(--r-sm); padding: 8px 12px; }
.code-box { font-family: var(--f-mono); font-size: .78rem; min-height: 72px; word-break: break-all; }
.move-work .row { gap: 8px; }

/* ---------- Report view (Save as PDF) ---------- */
body.report-mode > *:not(#lab-report) { display: none !important; }
body.report-mode::before { display: none; }
.report-view { min-height: 100vh; background: var(--surface-2); padding: 16px; display: grid; gap: 16px; justify-items: center; align-content: start; }
.rv-tools { width: 100%; max-width: 8.5in; display: grid; gap: 8px; }
.rv-status:empty { display: none; }
.rv-paper { width: 100%; max-width: 8.5in; min-width: 0; overflow-x: auto; background: var(--paper); color: var(--paper-ink); padding: .6in .7in; border: 1px solid var(--line); border-radius: 4px; font-size: 11pt; line-height: 1.4; display: block; }
.rv-paper > * + *, .rv-sec > * + *, .rv-qa > * + * { margin-top: 10px; }
.rv-qa > p + p { margin-top: 2px; }
.rv-paper h1 { font-size: 20pt; letter-spacing: -0.01em; }
.rv-paper p { max-width: none; }
.rv-eyebrow { font-size: 8.5pt; text-transform: uppercase; letter-spacing: .08em; color: var(--paper-muted); font-weight: 700; }
.rv-info { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 8px 0 0; }
.rv-info div { display: flex; gap: 6px; }
.rv-info dt { font-weight: 700; }
.rv-info dd { margin: 0; }
.rv-sim { margin: 6px 0 0; font-size: 9.5pt; font-style: italic; color: var(--paper-muted); }
.rv-sec { display: block; }
.rv-sec h2 { font-size: 14pt; border-bottom: 1.5px solid var(--paper-ink); padding-bottom: 3px; margin-top: 10px; break-after: avoid; }
.rv-sub { font-weight: 400; }
.rv-q { font-weight: 700; }
.rv-none { font-style: italic; color: var(--paper-muted); }
.rv-qa, .rv-quiz li, .rv-fig { break-inside: avoid; }
.rv-quiz ol { display: block; }
.rv-quiz li + li { margin-top: 6px; }
.rv-table { border-collapse: collapse; width: 100%; font-size: 9.5pt; font-variant-numeric: tabular-nums; }
.rv-table th, .rv-table td { border: 1px solid var(--paper-line); padding: 3px 6px; text-align: left; vertical-align: top; }
.rv-table th, .rv-table tfoot td { background: var(--paper-shade); font-weight: 700; }
.rv-table tr { break-inside: avoid; }
.rv-fig { margin: 0; }
.rv-fig img { width: 100%; max-width: 6.5in; height: auto; display: block; }
@page { size: letter; margin: .6in; }
@media print {
  body.report-mode, body.report-mode .report-view { background: #fff; padding: 0; display: block; min-height: 0; }
  body.report-mode .rv-tools { display: none !important; }
  body.report-mode .rv-paper { max-width: none; padding: 0; border: 0; border-radius: 0; color: #000; background: #fff; overflow: visible; }
}

/* ---------- Deep links + progress ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* Skip to content: the first focusable thing on every page; off-screen until it has keyboard focus. */
.skip-link { position: absolute; z-index: 4000; left: max(12px, env(safe-area-inset-left, 0px)); top: 8px; padding: 10px 16px; background: var(--surface); color: var(--ink); border: 2px solid var(--accent); border-radius: var(--r); font-weight: 700; text-decoration: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); transform: translateY(-200%); }
.skip-link:focus { transform: none; outline: 3px solid var(--ink); outline-offset: 2px; }
.skip-link:focus:not(:focus-visible) { outline: none; }
@media print { .skip-link { display: none; } }
.step > header.has-link { grid-template-columns: minmax(0, 1fr) auto; }
.step > header.has-link > * { grid-column: 1 / -1; }
.step > header.has-link > :first-child { grid-column: 1; grid-row: 1; }
.step > header.has-link > .link-tools { grid-column: 2; grid-row: 1; justify-self: end; align-self: center; }
.link-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 8px; }
.link-btn { font: inherit; font-size: .78rem; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.link-btn:hover { border-color: var(--line); color: var(--ink); background: var(--surface); }
.link-status { font-size: .78rem; color: var(--ok); }
.link-status:empty { display: none; }
.link-fallback { font-family: var(--f-mono); font-size: .75rem !important; max-width: 260px; padding: 3px 6px !important; }
@media (max-width: 520px) { .link-btn .lb-text { display: none; } }
.step-nav a { position: relative; } /* keeps the .sr-only "(done)" text inside the scrolling list */
.step-nav .has-progress { display: flex; align-items: center; gap: 10px; }
.step-nav .has-progress > ol { flex: 1 1 auto; min-width: 0; }
.nav-progress { flex: none; font-size: .8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
@media (max-width: 520px) { .nav-progress .np-long { display: none; } }
.nav-progress .np-short { display: none; }
.nav-progress .np-part { font-weight: 500; }
@media (max-width: 1100px) { .nav-progress .np-part { display: none; } }
@media (max-width: 520px) { .nav-progress .np-short { display: inline; } }
.step-nav a.is-done .n { background: var(--ok); color: var(--surface); font-size: 0; }
.step-nav a.is-done .n::before { content: "✓"; font-size: .78rem; font-family: var(--f-body); font-weight: 700; }
.step-nav a[aria-current="true"].is-done .n { background: var(--ok); color: var(--surface); }

/* ---------- Printable worksheet (body.worksheet-mode) ---------- */
.lab-header .crumbs .ws-print-btn { margin-left: auto; }
body.worksheet-mode > *:not(#lab-worksheet) { display: none !important; }
body.worksheet-mode::before { display: none; }
.worksheet { min-height: 100vh; background: var(--surface-2); padding: 16px; display: grid; gap: 16px; justify-items: center; align-content: start; }
.ws-tools { width: 100%; max-width: 8.5in; display: grid; gap: 8px; }
.ws-paper { width: 100%; max-width: 8.5in; min-width: 0; overflow-x: auto; background: var(--paper); color: var(--paper-ink); padding: .6in .7in; border: 1px solid var(--line); border-radius: 4px; font-size: 11pt; line-height: 1.4; display: block; }
.ws-paper > * + *, .ws-sec > * + *, .ws-prose > * + * { margin-top: 10px; }
.ws-paper p, .ws-paper li { max-width: none; }
.ws-head > * + * { margin-top: 6px; }
.ws-head h1 { font-size: 20pt; letter-spacing: -0.01em; }
.ws-eyebrow { font-size: 8.5pt; text-transform: uppercase; letter-spacing: .08em; color: var(--paper-muted); font-weight: 700; }
.ws-dq { font-style: italic; }
.ws-idline { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; }
.ws-id { flex: 1 1 auto; border-bottom: 1px solid var(--paper-ink); padding-bottom: 2px; font-weight: 700; font-size: 10pt; }
.ws-id-name { flex-basis: 50%; }
.ws-id-period, .ws-id-date { flex: 0 1 18%; min-width: 1.1in; }
.ws-sec { display: block; }
.ws-sec h2 { font-size: 14pt; border-bottom: 1.5px solid var(--paper-ink); padding-bottom: 3px; margin-top: 12px; break-after: avoid; }
.ws-shead { break-inside: avoid; break-after: avoid; }
.ws-shead .ws-eyebrow { margin-top: 3px; }
.ws-prose { display: block; }
.ws-prose ul, .ws-prose ol { display: block; }
.ws-prose li + li { margin-top: 4px; }
.ws-prose .step-body, .ws-prose .prose { gap: 10px; }
.ws-prose .callout { background: none; border: 1px solid var(--paper-line); }
.ws-prose .equation { background: none; border: 1px solid var(--paper-line); white-space: normal; }
.ws-prose svg, .ws-prose img { max-width: 100%; height: auto; break-inside: avoid; }
.ws-quiz { display: block; padding-left: 1.4em; }
.ws-quiz > li + li { margin-top: 12px; }
.ws-q { break-inside: avoid; display: list-item; }
.ws-q > * + * { margin-top: 4px; }
.ws-stem { font-weight: 600; }
.ws-hint { font-size: 9.5pt; font-style: italic; }
.ws-choices { list-style: none; padding-left: .2em; display: block; }
.ws-choices li + li { margin-top: 3px; }
.ws-choices li { display: flex; gap: 8px; align-items: baseline; }
.ws-bubble { flex: none; font-size: 13pt; line-height: 1; }
.ws-num, .ws-short { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; break-inside: avoid; }
.ws-blank { display: inline-block; min-width: 1.8in; border-bottom: 1px solid var(--paper-ink); height: 1.1em; }
.ws-unit { font-weight: 400; }
.ws-prompt { break-inside: avoid; display: block; }
.ws-plabel { font-weight: 600; margin-bottom: 2px; }
.ws-line { height: .34in; border-bottom: 1px solid var(--paper-line); }
.ws-table { border-collapse: collapse; width: 100%; font-size: 9.5pt; }
.ws-table th, .ws-table td { border: 1px solid var(--paper-ink); padding: 3px 6px; text-align: left; vertical-align: top; color: var(--paper-ink); background: none; white-space: normal; }
.ws-table th { font-weight: 700; }
.ws-table tbody td { height: .32in; }
.ws-table tr { break-inside: avoid; }
.ws-table thead { display: table-header-group; }
@media print {
  body.worksheet-mode, body.worksheet-mode .worksheet { background: #fff; padding: 0; display: block; min-height: 0; }
  body.worksheet-mode .ws-tools { display: none !important; }
  body.worksheet-mode .ws-paper { max-width: none; padding: 0; border: 0; border-radius: 0; background: #fff; color: #000; overflow: visible; }
  body.worksheet-mode .ws-paper * { color: #000; }
  .lab-header .crumbs .ws-print-btn, .link-tools { display: none; }
}

/* ---------- Home page: progress, resume ---------- */
.home-status { margin-top: 22px; display: grid; gap: 10px; }
.resume { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.lab-prog { display: grid; gap: 4px; font-size: .84rem; color: var(--muted); font-weight: 600; }
.prog-bar { display: block; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.prog-bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

/* =====================================================================
   UI patterns for laptops (1280–1440 × 720–900) — see KIT.md "UI patterns"
   ===================================================================== */

/* ---------- Step nav: compact items, scroll arrows, count + "All parts" toggle ---------- */
.step-nav .wrap { max-width: 1440px; }
.step-nav ol { gap: 2px; padding-block: 7px; scrollbar-width: none; }
.step-nav ol::-webkit-scrollbar { display: none; }
.step-nav a { padding: 5px 8px; gap: 6px; font-size: .88rem; }
.step-nav a .n { width: 19px; height: 19px; font-size: .72rem; }
.step-nav .nl { white-space: nowrap; } /* full labels always: never an ellipsis */
/* Wide screens: every part is visible; a long lab simply wraps to a second row (no scrolling, no hidden Submit). */
@media (min-width: 820px) {
  .step-nav ol { flex-wrap: wrap; overflow: visible; row-gap: 0; }
  .step-nav .nav-arrow { display: none !important; }
  .step-nav ol { -webkit-mask-image: none !important; mask-image: none !important; }
}
/* Phones: the strip scrolls with full labels; the current part is a filled pill with a bar under it and is kept in view. */
@media (max-width: 819px) {
  .step-nav a[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--accent); color: var(--ink); }
  .step-nav a { padding: 6px 9px; }
}
.step-nav .has-progress { gap: 6px; }
.nav-arrow { display: none; flex: none; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 700 1.15rem/1 var(--f-body); cursor: pointer; place-items: center; }
.nav-arrow:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.nav-arrow:disabled { opacity: .3; cursor: default; }
.nav-overflow > .nav-arrow { display: grid; }
.nav-overflow > ol { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 22px, #000 calc(100% - 22px), transparent 100%); }
.nav-overflow.at-start > ol { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent 100%); mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent 100%); }
.nav-overflow.at-end > ol { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 22px); mask-image: linear-gradient(to right, transparent 0, #000 22px); }
.nav-overflow.at-start.at-end > ol { -webkit-mask-image: none; mask-image: none; }
.nav-end { flex: none; display: flex; align-items: center; gap: 8px; }
.parts-toggle { padding: 4px 9px; font-size: .8rem; white-space: nowrap; gap: 6px; }
.parts-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.pt-icon { display: inline-block; width: 12px; height: 10px; border-block: 2px solid currentColor; background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat; }
@media (max-width: 1100px) { .parts-toggle .pt-text { display: none; } .parts-toggle { padding: 6px 8px; } }
@media (max-width: 600px) { .nav-overflow > .nav-arrow { display: none; } .step-nav a { padding: 5px 7px; } }

/* ---------- Paged mode: one part at a time ---------- */
body.paged section.step:not(.is-current) { display: none; }
body.paged main, html.will-page main { padding-block: 6px 40px; } /* will-page: set in each lab's <head> so first paint has the paged spacing */
body.paged .step, html.will-page .step { border-bottom: 0; padding-block: 22px 26px; }
/* A short part still scrolls to the top of the screen, so every part starts in the same place. */
body.paged section.step.is-current { min-height: calc(100vh - 56px); min-height: calc(100svh - 56px); align-content: start; }
.step > header h2:focus { outline: none; }
.step > header h2:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 6px; }
body:not(.paged) .pager { display: none; }
.pager .btn { min-height: 44px; padding-inline: 16px; gap: 8px; }
.pager-next { margin-left: auto; }
.pager-mid { display: grid; justify-items: center; gap: 4px; font-size: .82rem; color: var(--muted); text-align: center; }
.pager-all { font-size: .82rem; min-height: 24px; display: inline-flex; align-items: center; }
.pager-tip { font-size: .78rem; }
@media (hover: none) and (pointer: coarse) { .pager-tip { display: none; } }
@media (max-width: 640px) {
  .pager-prev .pager-name { display: none; }
  .pager-mid { order: 3; flex: 1 1 100%; }
}

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 60; right: max(16px, calc(env(safe-area-inset-right, 0px) + 12px)); bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)); width: min(380px, calc(100vw - 32px)); display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: var(--r); padding: 9px 8px 9px 12px; font-size: .9rem; line-height: 1.35; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); box-shadow: 0 8px 28px color-mix(in srgb, var(--ink) 18%, transparent); animation: toast-in .18s ease-out; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast-icon { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; background: var(--ok-soft); color: var(--ok); }
.toast-msg { flex: 1 1 auto; min-width: 0; }
.toast--info { border-left-color: var(--accent); }
.toast--info .toast-icon { background: var(--accent-soft); color: var(--accent); font-family: var(--f-mono); }
.toast--warn { border-left-color: var(--warn); }
.toast--warn .toast-icon { background: var(--warn-soft); color: var(--warn); }
.toast--bad { border-left-color: var(--bad); }
.toast--bad .toast-icon { background: var(--bad-soft); color: var(--bad); }
.toast-action { flex: none; font: inherit; font-size: .84rem; font-weight: 700; color: var(--accent); background: none; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 9px; cursor: pointer; }
.toast-action:hover { border-color: var(--accent); }
.toast-close { flex: none; width: 26px; height: 26px; border: 0; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; cursor: pointer; border-radius: 50%; }
.toast-close:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 600px) { .toasts { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; justify-items: stretch; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none !important; } .toast.is-leaving { transition: none !important; } }

/* ---------- Laptop-fit simulation: .sim.sim--fit > .sim-side + .stage (+ Lab.results) ---------- */
.wrap--sim { max-width: 1440px; }
.sim--fit { display: grid; grid-template-columns: minmax(250px, 290px) minmax(0, 1fr); align-items: start; --fit-reserve: 300px; }
.sim--fit > .sim-side { align-self: stretch; min-width: 0; padding: 14px 16px; background: var(--surface-2); border-right: 1px solid var(--line); display: grid; gap: 12px; align-content: start; }
.sim--fit .controls { display: grid; gap: 10px; align-content: start; min-width: 0; padding: 0; border: 0; background: none; }
.sim--fit .controls-title, .steps-title { font-family: var(--f-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); margin: 0; }
.sim--fit .controls-title { border-top: 1px solid var(--line); padding-top: 10px; }
.sim--fit .field { gap: 3px; }
.sim--fit .field > label, .sim--fit .field > .label { font-size: .84rem; }
.sim--fit select, .sim--fit input[type="text"], .sim--fit input[type="number"] { padding: 5px 8px; font-size: .9rem; }
.sim--fit .btn { padding: 7px 12px; justify-content: center; }
.sim--fit .callout { padding: 9px 12px; gap: 4px; }
.sim--fit .hint { font-size: .78rem; }
.sim--fit > .stage, .sim-main > .stage { padding: 12px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.sim--fit .readouts { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
.sim--fit .readout { padding: 5px 10px; }
.sim--fit .readout .k { font-size: .68rem; }
.sim--fit .readout .v { font-size: 1rem; }
.sim--fit .fb { font-size: .86rem; }
canvas.fit-h { margin-inline: auto; }
details.more { border-top: 1px dashed var(--line); padding-top: 4px; }
details.more > summary { cursor: pointer; font-size: .84rem; font-weight: 600; color: var(--muted); padding: 4px 0; }
details.more > summary:hover { color: var(--ink); }
details.more > .inner { display: grid; gap: 10px; padding-top: 6px; }
details.disclose--sm > summary { padding: 7px 12px; font-size: .86rem; }
details.disclose--sm > .inner { padding: 0 12px 12px; font-size: .9rem; }
@media (max-width: 1279px) { .sim--fit { grid-template-columns: minmax(240px, 270px) minmax(0, 1fr); } }
@media (max-width: 760px) {
  .sim--fit { grid-template-columns: minmax(0, 1fr); }
  .sim--fit > .sim-side { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* Results panel (Lab.results): Scene / Data / Graph */
.sim-main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; align-content: start; min-width: 0; --fit-reserve: 344px; }
.sim-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 12px 0; align-items: center; }
.sim-tab, .tab { font: inherit; font-size: .86rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.sim-tab:hover, .tab:hover { border-color: var(--accent); color: var(--ink); }
.sim-tab[aria-selected="true"], .tab[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab-badge { font-size: .64rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; background: var(--stain-soft); color: var(--stain); }
.sim-main > .stage { grid-column: 1; grid-row: 2; }
.sim-panel { grid-column: 1; grid-row: 2; contain: size; overflow: auto; min-width: 0; padding: 12px; background: var(--surface); display: grid; gap: 10px; align-content: start; }
.sim-main.shows-result > .stage { visibility: hidden; }
.sim-main.is-wide { grid-template-columns: minmax(0, 1fr) minmax(320px, 36%); grid-template-rows: auto minmax(0, 1fr); --fit-reserve: 300px; }
.sim-main.is-wide > .stage { grid-column: 1; grid-row: 1 / span 2; }
.sim-main.is-wide > .sim-tabs { grid-column: 2; grid-row: 1; border-left: 1px solid var(--line); }
.sim-main.is-wide > .sim-panel { grid-column: 2; grid-row: 2; border-left: 1px solid var(--line); }
.sim-panel > * { min-width: 0; }   /* wide tables scroll inside their own wrapper instead of stretching the panel */
.sim-panel .chart { max-width: none; }
.sim-panel .legend { font-size: .8rem; }
.sim-panel table.data { font-size: .82rem; }
.sim-panel table.data th, .sim-panel table.data td { padding: 5px 8px; }
.sim-panel table.data th { white-space: normal; vertical-align: bottom; min-width: 4.5em; }
.panel-title { font-family: var(--f-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.panel-title:not(:first-child) { margin-top: 6px; }
.sim-panel .panel-title + .chart { margin-top: 6px; }

/* Generic tabs (Lab.tabs) */
.tabs { display: grid; gap: 12px; }
.tabs-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tab-panel { display: grid; gap: 12px; }

/* ---------- Guidance: Lab.steps checklist, Lab.gate reasons, pulse on the next control ---------- */
.steps-box { display: grid; gap: 6px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.si { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; align-items: start; padding: 4px 6px; border-radius: var(--r-sm); font-size: .87rem; line-height: 1.35; color: var(--muted); }
.si-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-mono); font-size: .7rem; font-weight: 600; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.si.is-done .si-n { background: var(--ok); border-color: var(--ok); color: var(--surface); font-size: 0; }
.si.is-done .si-n::before { content: "✓"; font-size: .74rem; font-family: var(--f-body); font-weight: 700; }
.si.is-current { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.si.is-current .si-n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.si-body { min-width: 0; }
.si-show { font: inherit; font-size: .76rem; font-weight: 600; color: var(--accent); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; margin: 2px 0 0 2px; cursor: pointer; white-space: nowrap; vertical-align: baseline; }
.si-show:hover { border-color: var(--accent); background: var(--accent-soft); }
.si-show[hidden] { display: none; }
.si-opt { font-size: .74rem; font-style: italic; font-weight: 400; color: var(--muted); }
.steps-next { font-size: .85rem; line-height: 1.35; background: var(--accent-soft); color: var(--ink); border-radius: var(--r-sm); padding: 6px 10px; }
.steps-next .sn-k { font-weight: 700; color: var(--accent); }
.steps-next.is-complete { background: var(--ok-soft); }
.steps-next.is-complete .sn-k { color: var(--ok); }
.gate-why { font-size: .8rem; line-height: 1.3; color: var(--warn); font-weight: 600; margin-top: -4px; }
.gate-why::before { content: "⚠ "; }
.lab-pulse { outline: 2px solid var(--accent); outline-offset: 3px; animation: lab-pulse 1.8s ease-in-out infinite; }
@keyframes lab-pulse { 50% { outline-color: color-mix(in srgb, var(--accent) 20%, transparent); outline-offset: 5px; } }
@media (prefers-reduced-motion: reduce) { .lab-pulse { animation: none !important; } }
/* "Show me" ring (Lab.highlight): a two-tone frame with a glow so it reads on light and dark, plus three expanding pulses. */
.lab-ring { position: fixed; z-index: 3000; pointer-events: none; box-sizing: border-box; border-radius: 12px; border: 4px solid var(--accent); opacity: 0;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink), 0 0 26px 8px color-mix(in srgb, var(--accent) 55%, transparent); transition: opacity .12s; }
.lab-ring.is-on { opacity: 1; }
.lab-ring::after { content: ""; position: absolute; inset: -4px; border-radius: 14px; border: 4px solid var(--accent); opacity: 0; }
.lab-ring.go::after { animation: lab-ring-out .85s ease-out 3; }
@keyframes lab-ring-out { 0% { inset: -4px; opacity: .9; } 100% { inset: -28px; opacity: 0; } }
.lab-ring.is-still::after { display: none; }
@media (prefers-reduced-motion: reduce) { .lab-ring::after { display: none; } }

/* ---------- Reading parts on wide screens: Key ideas, Key terms, split columns ---------- */
.split { display: grid; gap: 16px; }
.split > .split-main, .split > .split-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 18px 32px; align-items: start; } }
.key-ideas ul { gap: .45em; }
.key-ideas li { max-width: none; }
.glossary { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 8px; }
.glossary > .callout-title { font-family: var(--f-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
.glossary dl { margin: 0; display: grid; gap: 8px; }
.glossary dt { font-weight: 700; font-size: .92rem; }
.glossary dd { margin: 0; font-size: .88rem; color: var(--muted); line-height: 1.4; }
.step-body details.disclose > summary { font-family: var(--f-display); font-size: 1.05rem; font-weight: 650; }
.step-body details.disclose--sm > summary, .step-body details.more > summary { font-family: var(--f-body); font-size: .86rem; font-weight: 600; }
details.disclose > summary:hover { color: var(--accent); }
details.disclose > .inner > p { max-width: 68ch; }
.prompts-2 { display: grid; gap: 16px; }
@media (min-width: 1100px) {
  .quiz.quiz--cols { display: block; columns: 2; column-gap: 16px; }
  .quiz.quiz--cols > .q { break-inside: avoid; margin-bottom: 14px; }
  .prompts-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; align-items: start; }
}

/* ---------- Laptop polish: shorter header on short screens ---------- */
@media (min-width: 1000px) and (max-height: 860px) {
  .lab-header { padding-block: 14px 18px; }
  .lab-header .crumbs { margin-bottom: 8px; }
  .lab-header h1 { font-size: 2.3rem; }
  .lab-header .driving-q { font-size: 1.06rem; margin-top: 6px; }
  .lab-header .tags { margin-top: 10px; }
}

/* 720-px-tall laptops (1280×720): tighten the part header and the sim side column so the sim still fits */
@media (min-width: 761px) and (max-height: 760px) {
  body.paged .step, html.will-page .step { padding-top: 12px; gap: 12px; }
  .step > header { gap: 2px; }
  .step > header h2 { font-size: 1.45rem; }
  .sim--fit > .sim-side { padding: 10px 14px; gap: 8px; }
  .sim--fit .controls { gap: 8px; }
  .si { padding-block: 2px; }
  .steps-next { padding-block: 4px; }
  .sim--fit .controls-title { padding-top: 6px; }
}

/* Worksheet copies of disclosures and tabs */
.ws-details > * + * { margin-top: 8px; }
.ws-sum { font-weight: 700; margin-top: 10px; }

@media print {
  body.paged section.step { display: grid !important; }
  .pager, .nav-arrow, .parts-toggle, .toasts, .sim-tabs, .tabs-list { display: none !important; }
  .tab-panel[hidden], .sim-panel[hidden] { display: grid !important; }
  .sim-panel { contain: none; overflow: visible; }
  .sim-main.shows-result > .stage { visibility: visible; }
  .lab-pulse { outline: 0; animation: none; }
  .lab-ring { display: none !important; }
}

/* ---------- Storage warning, backup reminder, first-visit tour ---------- */
.storage-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--warn-soft); color: var(--ink); border-bottom: 2px solid var(--warn); font-size: .94rem; line-height: 1.4; }
.storage-warn .sw-msg { flex: 1 1 260px; min-width: 0; font-weight: 600; }
.sw-icon, .bb-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.sw-icon { background: var(--warn); color: var(--bg); }
.bb-icon { background: var(--accent-soft); color: var(--accent); font-family: var(--f-mono); }

.backup-bar { position: fixed; z-index: 55; left: max(16px, calc(env(safe-area-inset-left, 0px) + 12px)); bottom: max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)); width: min(470px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 10px 8px 10px 12px; font-size: .9rem; line-height: 1.35; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); box-shadow: 0 8px 28px color-mix(in srgb, var(--ink) 18%, transparent); animation: toast-in .18s ease-out; }
.backup-bar:empty { display: none; }
.bb-msg { flex: 1 1 220px; min-width: 0; }
.bb-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.bb-close { width: 28px; height: 28px; border: 0; background: none; color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer; border-radius: 50%; }
.bb-close:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 600px) {
  .backup-bar { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: auto; }
  body.has-backup-bar .toasts { bottom: calc(max(16px, calc(env(safe-area-inset-bottom, 0px) + 12px)) + var(--backup-bar-h, 0px) + 8px); }
}
.backup-status { color: var(--muted); }
.backup-status:empty { display: none; }
.backup-status.is-unsaved { color: var(--warn); font-weight: 600; }
.id-line .id-help { font-weight: 600; }

.tour { position: fixed; inset: 0; z-index: 80; }
.tour-scrim { position: absolute; inset: 0; }
.tour.is-nospot .tour-scrim { background: rgba(0, 0, 0, .5); background: color-mix(in srgb, var(--bg) 78%, transparent); }
.tour-spot { position: fixed; border-radius: 10px; outline: 3px solid var(--accent); outline-offset: 0; pointer-events: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); box-shadow: 0 0 0 100vmax color-mix(in srgb, var(--bg) 78%, transparent); transition: left .2s, top .2s, width .2s, height .2s; }
.tour.is-nospot .tour-spot { outline: 0; box-shadow: none; }
.tour-card { position: fixed; width: min(380px, calc(100vw - 24px)); display: grid; gap: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: var(--r); padding: 12px 16px 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .24); box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 24%, transparent); }
.tour-card:focus { outline: none; }
.tour-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tour-card.is-sheet { left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: max(12px, calc(env(safe-area-inset-bottom, 0px) + 8px)); top: auto; width: auto; }
.tour-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tour-count { font-family: var(--f-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 600; }
.tour-title { font-size: 1.15rem; }
.tour-text { font-size: .95rem; color: var(--ink); }
.tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.tour-dots { display: flex; gap: 6px; }
.tour-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.tour-dot.is-on { background: var(--accent); }
.tour-actions { display: flex; gap: 8px; }
@media (prefers-reduced-motion: reduce) { .tour-spot, .backup-bar { transition: none !important; animation: none !important; } }
@media print { .tour, .backup-bar, .storage-warn { display: none !important; } }

/* ---------- Saved status ---------- */
.save-status { margin: 0; font-size: .78rem; line-height: 1.3; color: var(--muted); font-family: var(--f-mono); min-height: 1.1em; }
.save-status[data-state="ok"] { color: var(--ok); }
.save-status[data-state="bad"] { color: var(--bad); font-weight: 600; }
.save-status--bar { margin-top: 6px; text-align: right; }
@media print { .save-status { display: none !important; } }

/* ---------- Home: "Pick up where you left off" ---------- */
.pickup { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; padding: 18px 20px; background: var(--accent-soft); border: 1px solid var(--accent); border-left-width: 6px; border-radius: 12px; }
.pickup[hidden] { display: none; }
.pickup-main { flex: 1 1 320px; min-width: 0; display: grid; gap: 4px; }
.pickup-main p { margin: 0; }
.pickup .pickup-lab { font-size: clamp(1.25rem, 3vw, 1.6rem); margin: 0; }
.pickup-part { font-size: 1rem; }
.pickup-next { font-size: 1rem; color: var(--ink); }
.pickup-next .sn-k { font-weight: 700; color: var(--accent); }
.pickup .btn--lg { min-height: 56px; padding-inline: 32px; font-size: 1.15rem; font-weight: 700; flex: 0 0 auto; }
@media (max-width: 520px) { .pickup .btn--lg { width: 100%; justify-content: center; } }

/* ---------- Running header on every printed page (report PDF, worksheet) ----------
   Browsers with @page margin boxes get them from a <style> that lab.js adds. Others (body.pr-fallback) repeat
   .print-run: the page content sits in a one-cell table whose header group every browser repeats on each page.
   On screen (and with margin boxes) the table is just blocks and the header is hidden. */
.pr-t, .pr-t > tbody, .pr-t > tbody > tr, .pr-t > tbody > tr > td { display: block; padding: 0; border: 0; width: auto; }
.print-run { display: none; }
.pr-body > * + * { margin-top: 10px; }
@media print {
  body.pr-fallback .pr-t { display: table; width: 100%; border-collapse: collapse; }
  body.pr-fallback .pr-t > tbody { display: table-row-group; }
  body.pr-fallback .pr-t > tbody > tr { display: table-row; }
  body.pr-fallback .pr-t > tbody > tr > td { display: table-cell; }
  body.pr-fallback .pr-t > thead.print-run { display: table-header-group; }
  body.pr-fallback .print-run td { display: table-cell; font: 9pt Arial, sans-serif; color: #444 !important; border-bottom: 1px solid #999; padding: 0 0 4px; }
  body.pr-fallback .print-run span + span::before { content: " · "; }
  body.pr-fallback .pr-body { padding-top: 8px; }
}

/* ---------------- Transfer code (QR) and "restore from link" banner ---------------- */
.transfer { display: grid; gap: 14px; margin-top: 14px; padding: 16px 18px; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r); }
.transfer-btn { justify-self: start; min-height: 56px; padding-inline: 28px; font-size: 1.15rem; font-weight: 700; }
.transfer-out:empty { display: none; }
.transfer-out { display: grid; gap: 12px; }
.transfer-grid { display: grid; gap: 16px 28px; align-items: start; }
@media (min-width: 720px) { .transfer-grid { grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); } }
.transfer-qr { width: min(100%, 340px); aspect-ratio: 1; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px; display: grid; place-items: center; }
.transfer-qr svg { width: 100%; height: 100%; display: block; }
.transfer-noqr { color: #14211c; font-weight: 600; text-align: center; padding: 16px; }
.transfer-side { display: grid; gap: 10px; align-content: start; }
.transfer-photo { font-family: var(--f-display); font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.transfer-label { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: -6px; }
.transfer-code { font-family: var(--f-mono); font-size: 1.15rem; line-height: 1.5; letter-spacing: .02em; word-break: break-all; max-height: 9.5em; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; user-select: all; }
.resume-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px max(16px, env(safe-area-inset-left, 0px)); background: var(--accent-soft); border-bottom: 3px solid var(--accent); font-size: .98rem; position: relative; z-index: 70; }
.resume-banner > span { flex: 1 1 320px; }
.resume-banner.is-bad { background: var(--bad-soft); border-color: var(--bad); }
@media print { .resume-banner, .transfer { display: none !important; } }

/* ---------------- Pause & bookmark ---------------- */
.pause-btn { padding: 4px 9px; font-size: .8rem; white-space: nowrap; gap: 6px; }
.pb-icon { display: inline-block; width: 10px; height: 12px; border-inline: 3px solid currentColor; }
@media (max-width: 1100px) { .pause-btn .pb-text { display: none; } .pause-btn { padding: 6px 8px; } }
.pager-pause { font-size: .82rem; min-height: 24px; display: inline-flex; align-items: center; }
.pause-screen { position: fixed; inset: 0; z-index: 90; overflow-y: auto; background: var(--bg); display: grid; place-items: start center; padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.pause-card { width: min(720px, 100%); margin-block: auto; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--accent); border-radius: 14px; padding: clamp(20px, 4vw, 36px); box-shadow: 0 18px 60px rgba(0, 0, 0, .14); box-shadow: 0 18px 60px color-mix(in srgb, var(--ink) 14%, transparent); }
.pause-title { font-size: clamp(1.6rem, 4.5vw, 2.3rem); font-weight: 800; letter-spacing: -.02em; }
.pause-title:focus { outline: none; }
.pause-sub { font-size: 1.15rem; }
.pause-next { font-size: 1.05rem; padding: 10px 14px; background: var(--accent-soft); border-radius: var(--r-sm); }
.pause-next .sn-k { font-weight: 700; color: var(--accent); }
.pause-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pause-actions .btn--lg { min-height: 52px; padding-inline: 28px; font-size: 1.1rem; font-weight: 700; }
.pause-xfer .transfer { margin-top: 4px; }
body.has-pause { overflow: hidden; }
@media print { .pause-screen { display: none !important; } }

/* Data management dialogs: sign out, start over (lab.js, "Data management") */
.dm-scrim { position: fixed; inset: 0; z-index: 95; overflow-y: auto; background: rgba(0, 0, 0, .55); background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); display: grid; place-items: start center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.dm-card { width: min(640px, 100%); margin-block: auto; display: grid; gap: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-top: 6px solid var(--bad); border-radius: 14px; padding: clamp(16px, 4vw, 28px); box-shadow: 0 18px 60px rgba(0, 0, 0, .22); box-shadow: 0 18px 60px color-mix(in srgb, var(--ink) 22%, transparent); }
.dm-eyebrow { color: var(--bad); }
.dm-title { font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 800; letter-spacing: -.015em; overflow-wrap: break-word; }
.dm-title:focus { outline: none; }
.dm-title:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.dm-warn { font-weight: 600; padding: 10px 14px; background: var(--bad-soft); border-left: 4px solid var(--bad); border-radius: var(--r-sm); }
.dm-save { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.dm-save-title { font-weight: 700; }
.dm-sub { font-size: .86rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.dm-labs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dm-labs li { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; }
.dm-labs.dm-labs--plain li { justify-content: flex-start; }
.dm-save .transfer { margin: 0; }
.dm-save .transfer-btn { min-height: 0; padding: 5px 10px; font-size: .84rem; font-weight: 600; }
.dm-gate { display: grid; gap: 6px; }
.dm-check-label { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.dm-check { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.dm-text { width: 100%; max-width: 22rem; }
.dm-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn--danger-solid { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.btn--danger-solid:hover:not(:disabled) { filter: brightness(1.1); border-color: var(--bad); }
body.has-dm { overflow: hidden; }
@media print { .dm-scrim { display: none !important; } }

/* Theme switch (lab.js, "Theme switch"): Light / Dark / Auto */
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); overflow: hidden; vertical-align: middle; }
.theme-opt { font: inherit; font-size: .8rem; font-weight: 600; line-height: 1; padding: 6px 11px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.theme-opt + .theme-opt { border-left: 1px solid var(--line); }
.theme-opt:hover { color: var(--ink); }
.theme-opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.theme-opt:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.theme-opt[aria-pressed="true"]:focus-visible { outline-color: var(--ink); }
.crumbs .theme-switch { margin-left: auto; }
.crumbs .theme-switch ~ .ws-print-btn { margin-left: 0; }
.theme-bar { display: flex; justify-content: flex-end; padding-top: 10px; }
@media print { .theme-switch, .theme-bar { display: none !important; } }

/* ---------- "Rate my confidence" (Reflect / Evaluate part) ---------- */
.confidence { margin: 22px 0 4px; padding: 12px 14px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: grid; gap: 8px; max-width: 760px; }
.confidence legend { font-family: var(--f-display); font-weight: 700; font-size: 1.05rem; padding: 0 6px; }
.conf-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.conf-opt { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; font-weight: 600; }
.conf-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.conf-opt:hover { border-color: var(--accent); }
.conf-opt:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.conf-dots { font-size: .8rem; letter-spacing: 1px; color: var(--accent); }
.conf-tick { display: none; font-weight: 800; }
.conf-opt:has(input:checked) { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.conf-opt:has(input:checked) .conf-dots { color: var(--accent-ink); }
.conf-opt:has(input:checked) .conf-tick { display: inline; }
.conf-opt.is-checked { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }   /* the same, for browsers without :has() */
.conf-opt.is-checked .conf-dots { color: var(--accent-ink); }
.conf-opt.is-checked .conf-tick { display: inline; }
.conf-say:empty { display: none; }
@media print { .confidence { display: none !important; } }

.nudge-bar { border-left-color: var(--warn); }
.nudge-bar .bb-icon { background: var(--warn-soft); color: var(--warn); }

/* ---------- Printing (Ctrl+P, Print worksheet, Save as PDF): always light, whatever the theme ----------
   The light tokens again, with enough specificity to beat the dark-mode rules and the data-theme switch; no dark backgrounds,
   a white page. lab.js (Lab.print) swaps each visible canvas for a static light <img> while the print dialog is open. */
@media print {
  :root:root:root {
    --bg: #ffffff; --surface: #ffffff; --surface-2: #eef2f0; --ink: #111111; --muted: #444444; --line: #bbbbbb;
    --accent: #0d6e55; --accent-ink: #ffffff; --accent-soft: #e3f2ec; --stain: #a8326b; --stain-soft: #f6e1eb;
    --ok: #1f7a3d; --ok-soft: #e6f4ea; --warn: #8a5000; --warn-soft: #fbf0dd; --bad: #b3261e; --bad-soft: #fbe6e4;
    --s1: #0d6e55; --s2: #d55e00; --s3: #0072b2; --s4: #b3261e; --s5: #00798c; --s6: #222222; --grid: #dde5e0;
    color-scheme: light;
  }
  html, body { background: #fff !important; color: #111; }
  canvas.print-snap, img.print-snap { max-width: 100%; }
  /* Page breaks: headings stay with what follows; figures, tables, prompts and readouts never split. */
  h1, h2, h3, h4, .callout-title, .eyebrow, .steps-title, .controls-title { break-after: avoid; }
  section.step > header { break-after: avoid; }
  figure, .viz, .chart, img.print-snap, .readouts, .readout, .callout, .prompt, .quiz .q, .cer > *, .table-wrap, table tr, .legend, .chart-note, .steps-box, .sim-side .controls { break-inside: avoid; }
  thead { display: table-header-group; }
  section.step { break-inside: auto; }
  .sticky, .step-nav { position: static !important; }
}

/* ---------- Not by color alone (color-blind safe) ----------
   Success, error and warning states carry an icon as well as a color, and chart legends draw the series' marker or pattern. */
.feedback.ok::before, .pill.ok::before, .q .choice.is-right::after { content: "✓"; font-weight: 800; }
.feedback.bad::before, .pill.bad::before, .q .choice.is-wrong::after { content: "✕"; font-weight: 800; }
.pill.warn::before { content: "!"; font-weight: 800; }
.feedback.ok::before, .feedback.bad::before { margin-right: .45em; }
.q .choice.is-right::after, .q .choice.is-wrong::after { margin-left: auto; padding-left: 10px; }
.legend .lg-sw, .chart .legend .lg-sw { flex: none; display: block; width: 28px; height: 14px; }

.project-link { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; color: var(--muted); text-decoration: none; padding: 3px 6px; border-radius: 6px; }
.project-link:hover { color: var(--accent); background: var(--surface-2); }
@media print { .project-link { display: none !important; } }

/* ---------- Sound toggle (lab.js, "Sound"): speaker button beside the theme switch ---------- */
.sound-toggle { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); cursor: pointer; vertical-align: middle; }
.sound-toggle:hover { color: var(--ink); border-color: var(--accent); }
.sound-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sound-toggle[aria-pressed="true"] .sx-off, .sound-toggle[aria-pressed="false"] .sx-on { display: none; }
.sound-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sound-toggle[aria-pressed="true"]:focus-visible { outline-color: var(--ink); }
.crumbs .theme-switch ~ .sound-toggle { margin-left: -8px; }
.crumbs .theme-switch ~ .sound-toggle ~ .ws-print-btn { margin-left: 0; }
@media print { .sound-toggle { display: none !important; } }

/* ---------- Celebrations (lab.js, "Celebrations"): quiet check-sweep, progress ring, one confetti burst, calm badge ---------- */
.nav-ring { flex: none; display: inline-grid; width: 24px; height: 24px; place-items: center; }
.nav-ring svg { width: 24px; height: 24px; overflow: visible; }
.nav-ring .nr-bg { fill: none; stroke: var(--line); stroke-width: 4; }
.nav-ring .nr-fg { fill: none; stroke: var(--ok); stroke-width: 4; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.nav-ring .nr-check { fill: none; stroke: var(--ok); stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.nav-ring.is-full .nr-check { opacity: 1; }
.nav-ring.is-full .nr-bg { stroke: var(--ok); }
.nav-ring.just-done .nr-check { stroke-dasharray: 26; animation: lab-check-draw .7s ease-out both; }
.nav-ring.just-done .nr-fg { animation: lab-ring-glow 1.1s ease-out; }
.step-nav a.just-done .n { animation: lab-nav-pop .7s ease-out; }
.step-nav a.just-done .n::before { animation: lab-check-sweep .65s ease-out both; }
@keyframes lab-check-draw { from { stroke-dashoffset: 26; } to { stroke-dashoffset: 0; } }
@keyframes lab-check-sweep { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes lab-nav-pop { 0% { box-shadow: 0 0 0 0 var(--ok); } 60% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes lab-ring-glow { 0% { stroke-width: 4; } 40% { stroke-width: 6.5; } 100% { stroke-width: 4; } }
@media (prefers-reduced-motion: reduce) {
  .nav-ring .nr-fg { transition: none; }
  .nav-ring.just-done .nr-check, .nav-ring.just-done .nr-fg, .step-nav a.just-done .n, .step-nav a.just-done .n::before { animation: none !important; }
}
.confetti-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 3500; }
.lab-complete { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 6px 14px; border: 2px solid var(--ok); border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-weight: 700; }
@media print { .confetti-canvas, .lab-complete, .nav-ring { display: none !important; } }

/* ---------- "Bench-verified" stamp on the PDF report view (lab.js, "Stamp"): floats beside the title block, never over text ---------- */
.rv-head { display: flow-root; }
.rv-stamp { float: right; width: 1.1in; height: 1.1in; margin: -4px 0 4px 14px; shape-outside: circle(50%); }
.rv-head + .rv-sec { clear: both; }
@media print { .rv-stamp { break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* ---------- Timelapse (lab.js, "Timelapse"): buttons, replay modal ---------- */
.tl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tl-bar .tl-status { flex: 1 1 180px; font-size: .88rem; color: var(--muted); }
.responses-bar .tl-include { flex: 1 1 100%; }
.tl-modal { position: fixed; inset: 0; z-index: 3200; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .55); background: color-mix(in srgb, var(--ink) 55%, transparent); }
.tl-card { width: min(640px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; display: grid; gap: 10px; padding: 16px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.tl-view { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; line-height: 0; }
.tl-canvas { width: 100%; height: auto; display: block; }
.tl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.tl-row--meta { justify-content: space-between; font-size: .9rem; color: var(--muted); }
.tl-scrub { flex: 1 1 160px; min-width: 0; accent-color: var(--accent); }
.tl-speed { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); }
.tl-gifstatus:empty { display: none; }
@media print { .tl-modal, .tl-bar { display: none !important; } }
.tl-speed-l { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Predict vs. actual (lab.js, Lab.predictCompare) ---------- */
.pvc { margin: 18px 0; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); display: grid; gap: 12px; }
.pvc-title { font-size: 1.1rem; }
.pvc-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 760px) { .pvc-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); } }
.pvc-col { display: grid; gap: 8px; align-content: start; min-width: 0; }
.pvc-col h4 { font-family: var(--f-mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pvc-quote { margin: 0; padding: 8px 0 8px 12px; border-left: 4px solid var(--accent); font-style: italic; white-space: pre-wrap; overflow-wrap: break-word; }
.pvc-none, .pvc-wait { padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--r-sm); color: var(--muted); }
.pvc-snap { min-width: 0; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--bg); padding: 4px; }
.pvc-snap svg:not(.lg-sw) { max-width: 100%; height: auto; }
.pvc-sum { font-size: .95rem; }
.pvc-what { padding: 10px 14px; border-radius: var(--r-sm); background: var(--accent-soft); border-left: 5px solid var(--accent); font-weight: 600; }
.pvc-what.is-wait { background: var(--warn-soft); border-left-color: var(--warn); color: var(--ink); }
@media print { .pvc { break-inside: avoid; } }

/* ---------- Wide tables (Lab.tableFit in lab.js) ----------
   Fit first (compact, wrapped headers, smaller numerals in results panels), widen the Data column next (Lab.results),
   and only then scroll: first column sticky, edge shadow, and a "Scroll →" line that goes away at the right end. */
.sim-main.is-wide { grid-template-columns: minmax(0, 1fr) minmax(320px, var(--res-w, 36%)); }
@media (min-width: 1700px) { .wrap--sim { max-width: 1640px; } }
.sim-panel table.data { font-size: .8rem; }
.sim-panel table.data th, .sim-panel table.data td { padding: 4px 6px; }
.sim-panel table.data th { font-size: .74rem; line-height: 1.2; min-width: 0; overflow-wrap: break-word; }
.sim-panel table.data td.num, .sim-panel table.data th.num { font-size: .76rem; }
.sim-panel table.data td { white-space: normal; overflow-wrap: break-word; }
.sim-panel table.data td.num { white-space: nowrap; }
.sim-panel table.data input { min-width: 52px; width: 100%; padding: 3px 4px; font-size: .76rem; }
.table-wrap { position: relative; max-width: 100%;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 24px 100% no-repeat local,
    linear-gradient(to right, color-mix(in srgb, var(--ink) 22%, transparent), transparent) left center / 10px 100% no-repeat scroll,
    linear-gradient(to left, color-mix(in srgb, var(--ink) 22%, transparent), transparent) right center / 10px 100% no-repeat scroll,
    var(--surface); }
.table-wrap.is-scrollable table.data th:first-child, .table-wrap.is-scrollable table.data td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.table-wrap.is-scrollable table.data th:first-child { background: var(--surface-2); }
.table-wrap.is-scrollable table.data tfoot td:first-child { background: var(--surface-2); }
.table-wrap.is-scrollable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scroll-hint { font-size: .74rem; font-weight: 700; color: var(--accent); text-align: right; margin-top: 3px; letter-spacing: .02em; }
.scroll-hint[hidden] { display: none; }
@media print { .scroll-hint { display: none !important; } .table-wrap { background: none; } .table-wrap.is-scrollable table.data th:first-child, .table-wrap.is-scrollable table.data td:first-child { position: static; box-shadow: none; } }

/* ---------- Phone and touch: every tap target at least 40 px (tests/t50-phone.js) ---------- */
@media (max-width: 760px), (pointer: coarse) {
  .btn, .btn--sm, button.btn--ghost, button.chip, a.btn, .sim-tab, .tab, .seg > button, button.tube, .theme-opt, .sound-toggle, .link-btn,
  .linkbtn, .si-show, .project-link, .crumbs a, .step-nav a, .nav-arrow, .parts-toggle, .pause-btn { min-height: 40px; box-sizing: border-box; }
  .btn, a.btn, .sim-tab, .tab, .seg > button, .theme-opt, .sound-toggle, .link-btn, .linkbtn, .si-show, .project-link, .step-nav a, .nav-arrow, .parts-toggle, .pause-btn, button.chip, button.tube { display: inline-flex; align-items: center; justify-content: center; }
  .btn, .link-btn, .sound-toggle, .theme-opt, .linkbtn, .si-show { min-width: 40px; }
  .linkbtn, .link-btn { padding-inline: 8px; }
  .theme-opt { padding-inline: 12px; }
  .si-show { padding-block: 4px; }
  .step-nav a { padding-block: 6px; }
  .crumbs a, .project-link { display: inline-flex; align-items: center; }
  select, input[type="text"], input[type="number"], input[type="search"], input[type="email"], input:not([type]) { min-height: 40px; box-sizing: border-box; }
  input[type="range"] { min-height: 40px; }
  details > summary, details.more > summary, details.disclose > summary, details.disclose--sm > summary { min-height: 40px; box-sizing: border-box; padding-block: 10px; }
  label.check, .choice, .dm-check-label { min-height: 40px; display: flex; align-items: center; }
  .step-nav ol { padding-block: 6px; }
  .dm-save .transfer-btn { min-height: 40px; }
}

/* Audit 4: reserve room under the page for the fixed "Save progress file" bar, and a pulse for a freshly recorded timelapse. */
body.has-backup-bar { padding-bottom: calc(var(--backup-bar-h, 0px) + max(16px, env(safe-area-inset-bottom, 0px)) + 28px); }
@media (max-width: 640px) { body.has-backup-bar { padding-bottom: calc(var(--backup-bar-h, 0px) + 44px); } }
.tl-bar--new { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft, rgba(0, 0, 0, .15)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); animation: tl-new 1.2s ease-in-out 3; }
@keyframes tl-new { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 12%, transparent); } }
@media (prefers-reduced-motion: reduce) { .tl-bar--new { animation: none; } }
@media print { body.has-backup-bar { padding-bottom: 0; } }

/* Audit 5 (CLS): the nav's right end keeps one size from first paint, whatever the progress says, so the part list never re-wraps
   and the page below never jumps. Ring and count keep their space while empty; the "· part under way" note is cut with … (the
   full text is in the tooltip). Lab pages also ship inert copies of the header controls ([data-ph], swapped by lab.js). */
.nav-end .nav-ring[hidden] { display: inline-grid !important; visibility: hidden; }
.nav-end .nav-progress { display: block; width: 10.5em; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-end .nav-progress[hidden] { display: block !important; visibility: hidden; }
@media (max-width: 1100px) { .nav-end .nav-progress { width: 9.6em; } }
@media (max-width: 520px) { .nav-end .nav-progress { width: 6.4em; } }
/* Home page: the lab cards are written into main#labs by script; until then the footer waits below the fold instead of
   showing at the top and then jumping away. */
main#labs:empty { min-height: 100vh; }
/* The "Copy link" button sits beside the part's eyebrow without making that row taller (it arrives with lab.js, after first paint). */
.step > header.has-link > .link-tools { margin-block: -4px; }
@media (max-width: 760px), (pointer: coarse) { .step > header.has-link > .link-tools { margin-block: -11px; } }
/* Lab pages: the identity line's static stand-in keeps the line's size (wrapping included) but shows nothing until lab.js fills it. */
.id-box[data-ph] .id-line { visibility: hidden; }
