:root {
  --bg: #f8f7f3;
  --surface: #ffffff;
  --ink: #1c1c1e;
  --muted: #5d6066;
  --line: #dfddd6;
  --accent: #2153cc;
  --accent-ink: #ffffff;
  --accent-soft: #eaf0fd;
  --good: #17703f;
  --good-soft: #e6f4ec;
  --bad: #a8261c;
  --bad-soft: #fbeceb;
  --warn: #7a5200;
  --warn-soft: #fbf3e2;
  --curve: #2153cc;
  --grid: #ebe9e3;
  --axis: #8a8a8a;
  --trace: #c2410c;
  --radius: 10px;
  --font:
    ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1b1b1f;
    --ink: #ececee;
    --muted: #a2a4aa;
    --line: #2d2d33;
    --accent: #84a9ff;
    --accent-ink: #0c0c0e;
    --accent-soft: #1f2740;
    --good: #6fd6a0;
    --good-soft: #15291f;
    --bad: #ff8f85;
    --bad-soft: #2e1817;
    --warn: #f2c063;
    --warn-soft: #2c2414;
    --curve: #84a9ff;
    --grid: #25252a;
    --axis: #75757c;
    --trace: #fb923c;
  }
}
:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1b1b1f;
  --ink: #ececee;
  --muted: #a2a4aa;
  --line: #2d2d33;
  --accent: #84a9ff;
  --accent-ink: #0c0c0e;
  --accent-soft: #1f2740;
  --good: #6fd6a0;
  --good-soft: #15291f;
  --bad: #ff8f85;
  --bad-soft: #2e1817;
  --warn: #f2c063;
  --warn-soft: #2c2414;
  --curve: #84a9ff;
  --grid: #25252a;
  --axis: #75757c;
  --trace: #fb923c;
}

* {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--font);
}
main,
header.page,
footer.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}
header.page {
  padding-top: 32px;
}
h1 {
  font-size: 1.9rem;
  line-height: 1.2;
  margin: 0.2em 0 0.3em;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 1.35rem;
  margin: 0 0 0.4em;
  line-height: 1.25;
}
h3 {
  font-size: 1.05rem;
  margin: 1.2em 0 0.3em;
}
p {
  margin: 0.5em 0;
}
a {
  color: var(--accent);
}
.muted {
  color: var(--muted);
}
.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

section.seg-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
}
.seg-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.cap {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  margin: 0 4px 4px 0;
}
.caps {
  margin: 0 0 8px;
}

.objectives {
  margin: 12px 0 0;
  padding-left: 1.2em;
}
.objectives li {
  margin: 0.3em 0;
}
.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}
.toc a {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
}

.item {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.item:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.prompt {
  margin-bottom: 8px;
}
.figure {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  margin: 8px 0 12px;
}
.plot {
  width: 100%;
  max-width: 340px;
  height: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.plot .grid line {
  stroke: var(--grid);
  stroke-width: 1;
}
.plot .axis {
  stroke: var(--axis);
  stroke-width: 1.3;
}
.plot .ticks text {
  fill: var(--muted);
  font-size: 9px;
  font-family: var(--font);
}
.plot .curve path {
  fill: none;
  stroke: var(--curve);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.plot .guide {
  stroke: var(--muted);
  stroke-dasharray: 3 4;
  stroke-width: 1;
}
.plot circle.open {
  fill: var(--surface);
  stroke: var(--curve);
  stroke-width: 2.2;
}
.plot circle.closed {
  fill: var(--curve);
  stroke: var(--surface);
  stroke-width: 1.5;
}
.plot .trace-line {
  stroke: var(--trace);
  stroke-dasharray: 4 3;
  stroke-width: 1.3;
}
.plot .trace-dot {
  fill: var(--trace);
  stroke: var(--surface);
  stroke-width: 1.5;
}
.plot .secant {
  stroke: var(--trace);
  stroke-width: 2;
}
.plot .pt {
  fill: var(--trace);
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
table.vals {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  min-width: 200px;
}
table.vals th,
table.vals td {
  border: 1px solid var(--line);
  padding: 4px 12px;
  text-align: right;
}
table.vals th {
  background: var(--accent-soft);
  font-weight: 600;
}
table.vals tr.split td {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  background: transparent;
}
table.vals input {
  width: 6.5em;
  font: inherit;
  text-align: right;
}
table.vals caption {
  caption-side: top;
  text-align: left;
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: 4px;
}

form.answer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.input-row input,
textarea {
  font: inherit;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.input-row input {
  width: 12em;
  max-width: 100%;
}
textarea {
  width: 100%;
  min-height: 6em;
}
.format {
  flex-basis: 100%;
  order: 5;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: -4px;
}
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
fieldset.choices {
  flex-basis: 100%;
  display: grid;
  gap: 8px;
}
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg);
}
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.choice input {
  margin-top: 0.35em;
}
fieldset.confidence {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.92rem;
}
fieldset.confidence legend {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0;
  margin-bottom: 2px;
  width: 100%;
}

.btn {
  font: inherit;
  font-size: 0.95rem;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  min-height: 40px;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn.ghost {
  border-color: var(--line);
  color: var(--ink);
}
.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
}
.btn.next {
  margin-top: 12px;
}
.tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.tools:empty {
  display: none;
}
.hint {
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  padding: 6px 10px;
  border-radius: 0 6px 6px 0;
  margin: 8px 0 0;
  font-size: 0.95rem;
}
.hint-n {
  font-weight: 700;
  color: var(--warn);
}
.feedback:empty {
  display: none;
}
.feedback {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
}
.feedback.good {
  background: var(--good-soft);
  color: var(--good);
}
.feedback.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.feedback.warn,
.feedback.note {
  background: var(--warn-soft);
  color: var(--warn);
}
.feedback .muted {
  color: inherit;
  opacity: 0.8;
}
.solution {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.95rem;
}
.worked .solution {
  border-color: var(--accent);
}
.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin: 12px 0;
}
.reveal[hidden] {
  display: none;
}

.tracer-ctl {
  display: grid;
  gap: 8px;
  max-width: 340px;
}
.tracer-ctl label {
  font-size: 0.9rem;
  color: var(--muted);
}
.tracer-ctl input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.readout {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
}
.seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meters {
  list-style: none;
  padding: 0;
  margin: 8px 0 12px;
  display: grid;
  gap: 8px;
}
.meters li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
}
.m-name {
  font-weight: 600;
  font-size: 0.95rem;
}
.m-bar {
  display: inline-flex;
  gap: 3px;
  grid-row: 1;
  grid-column: 2;
}
.m-bar i {
  width: 22px;
  height: 10px;
  border-radius: 3px;
  background: var(--line);
}
.m-bar.l1 i:nth-child(-n + 1),
.m-bar.l2 i:nth-child(-n + 2),
.m-bar.l3 i:nth-child(-n + 3),
.m-bar.l4 i {
  background: var(--accent);
}
.m-level {
  font-size: 0.8rem;
  color: var(--muted);
}
.m-detail {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: right;
}

.calib {
  border-collapse: collapse;
  margin: 8px 0;
}
.calib td,
.calib th {
  border: 1px solid var(--line);
  padding: 4px 10px;
  text-align: left;
}

.units {
  list-style: none;
  padding: 0;
  margin: 0;
}
.units > li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 12px 0;
}
.units ol {
  margin: 6px 0 0;
  padding-left: 1.3em;
}
.units ol li {
  margin: 3px 0;
}
.soon {
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 7px;
  margin-left: 6px;
}

footer.page {
  padding: 24px 16px 48px;
  font-size: 0.85rem;
  color: var(--muted);
}
footer.page .btn {
  font-size: 0.8rem;
  min-height: 32px;
  padding: 4px 10px;
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }
  h1 {
    font-size: 1.55rem;
  }
  section.seg-block {
    padding: 16px 14px;
  }
}

/* ---------- visual layer: left = warm (solid), right = cool (dashed); never color alone ---------- */
:root { --left: #c2410c; --right: #6d28d9; --thumb: rgba(28, 28, 30, .78); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --left: #fb923c; --right: #a78bfa; --thumb: rgba(236, 236, 238, .82); } }
:root[data-theme="dark"] { --left: #fb923c; --right: #a78bfa; --thumb: rgba(236, 236, 238, .82); }
.plot.small { max-width: 260px; }
.approach { fill: none; stroke-width: 4.5; stroke-linecap: round; opacity: .9; }
.approach.left { stroke: var(--left); }
.approach.right { stroke: var(--right); stroke-dasharray: 7 5; }
.ah-left { fill: var(--left); }
.ah-right { fill: var(--right); }
.land text, text.land-left, text.land-right { font: 700 11px var(--font); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
text.land-left { fill: var(--left); }
text.land-right { fill: var(--right); }
.plot .tracer.left .trace-dot { fill: var(--left); }
.plot .tracer.right .trace-dot { fill: var(--right); }
.plot .tracer.left .trace-line { stroke: var(--left); }
.plot .tracer.right .trace-line { stroke: var(--right); }
.plot .thumb rect { fill: var(--thumb); }
.plot .thumb text { fill: var(--surface); font: 700 22px var(--font); }
.readout { display: grid; gap: 2px; font-size: .95rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.readout .lt { color: var(--left); }
.readout .rt { color: var(--right); }
.strip { width: 100%; max-width: 340px; height: auto; }
.strip .sv.left { fill: var(--left); }
.strip .sv.right { fill: var(--right); }
.strip .tick.left { stroke: var(--left); stroke-width: 2; }
.strip .tick.right { stroke: var(--right); stroke-width: 2; }
.strip .axis { stroke: var(--axis); }
.strip .approach { stroke-width: 2.5; }
.hint { margin: 6px 0 0; }
.big-idea { font-size: 1.25rem; font-weight: 700; line-height: 1.35; margin: 4px 0 10px; }
.big-idea small { display: block; font-size: .9rem; font-weight: 400; color: var(--muted); margin-top: 4px; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 10px 0; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); }
.card h3 { margin: 0 0 6px; font-size: .95rem; }
.key { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; margin-right: 12px; }
.key i { display: inline-block; width: 22px; height: 0; border-top: 4px solid var(--left); }
.key.r i { border-top: 4px dashed var(--right); }
.drop { width: 100%; max-width: 340px; height: auto; }
.drop .pt { fill: var(--curve); }
.drop .now { fill: none; stroke: var(--left); stroke-width: 2.5; }
.drop text { fill: var(--muted); font: 12px var(--font); }
.drop .gap { fill: var(--left); font-weight: 700; }
.strip .row { stroke: var(--grid); }
.strip .rowlab { fill: var(--muted); font: 10px var(--font); }
.strip .approach.thin { stroke-width: 1.6; opacity: .7; }
.strip .tick { stroke-dasharray: 3 3; }
.strip text.land-left, .strip text.land-right { font-size: 12px; }

/* ---------- step runner ---------- */
.stepbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0 8px; display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.stepbar-track { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.stepbar-track i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
@media (prefers-reduced-motion: reduce) { .stepbar-track i { transition: none; } }
.steplist { display: grid; gap: 10px; }
.step.current { background: var(--surface); border: 1.5px solid var(--accent); border-radius: var(--radius); padding: 16px; }
.step.current.recall { border-color: var(--left); }
.step.current h3 { margin: 0 0 8px; font-size: 1.1rem; }
.step-kicker { margin: 0; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); }
.recall .step-kicker { color: var(--left); }
details.step.done { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
details.step.done summary { cursor: pointer; font-size: .92rem; }
details.step.done .check { color: var(--good); font-weight: 700; }
details.step.done.recall summary::after { content: " · recall"; color: var(--left); font-size: .8rem; }
.teach { margin-top: 12px; padding: 12px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.teach > :first-child { margin-top: 0; }
.cloze { line-height: 2.3; margin: 0; flex-basis: 100%; }
.blank { font: inherit; padding: 2px 6px; border: 1.5px solid var(--line); border-bottom: 2.5px solid var(--accent); border-radius: 6px; background: var(--bg); color: var(--ink); max-width: 100%; }
.blank.right { border-color: var(--good); }
.blank.wrong { border-color: var(--bad); background: var(--bad-soft); }
.free { flex-basis: 100%; }
.free textarea { width: 100%; }
