/*Blueprint — 3D & 4D reconstruction course.
  Drafting-sheet aesthetic: vellum by day, darkroom graphite by night.
  Figures sit on gridded "plates" with engineering title blocks.
  Font pairing: Space Grotesk (display) + Newsreader (body) + JetBrains Mono (data).*/

:root {
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Light — vellum drafting paper */
  --bg: #f4f1e7;
  --surface: #fbf9f1;
  --surface-2: #ece7d8;
  --ink: #262a30;
  --muted: #6e6a5e;
  --accent: #a34e19;
  --accent-hover: #7d3a10;
  --on-accent: #fdfbf6;
  --plate: #f7f4ea;
  --grid-line: rgba(38, 42, 48, 0.06);
  --line: rgba(38, 42, 48, 0.16);
  --line-strong: rgba(38, 42, 48, 0.32);
  --danger: #a03524;
  --danger-tint: rgba(160, 53, 36, 0.09);
  --ok: #1e6e52;
  --ok-tint: rgba(30, 110, 82, 0.1);
  --shadow: rgba(38, 42, 48, 0.14);
  color-scheme: light;
}

[data-theme="dark"] {
  /* Dark — the night shift */
  --bg: #17191f;
  --surface: #1e2128;
  --surface-2: #272b33;
  --ink: #e9e4d5;
  --muted: #9b9587;
  --accent: #e3973c;
  --accent-hover: #f2b05a;
  --on-accent: #201409;
  --plate: #1c1f25;
  --grid-line: rgba(233, 228, 213, 0.05);
  --line: rgba(233, 228, 213, 0.16);
  --line-strong: rgba(233, 228, 213, 0.34);
  --danger: #e2705f;
  --danger-tint: rgba(226, 112, 95, 0.12);
  --ok: #5abf95;
  --ok-tint: rgba(90, 191, 149, 0.12);
  --shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17.5px;
  line-height: 1.66;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.25s ease, color 0.25s ease;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.18;
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.16em;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

svg {
  display: block;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-radius: 0 0 8px 8px;
}

.skip-link:focus {
  top: 0;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.6rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}

.chapter-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}

.chapter-nav::-webkit-scrollbar {
  display: none;
}

.chapter-nav a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.chapter-nav a:hover {
  color: var(--accent);
  text-decoration: none;
  background: var(--surface-2);
}

.chapter-nav a.active {
  color: var(--on-accent);
  background: var(--accent);
}

.locked {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0.35rem 0.6rem;
  white-space: nowrap;
  opacity: 0.75;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.all-lectures,
.theme-hint {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.32rem 0.75rem;
  white-space: nowrap;
}

.all-lectures:hover,
.theme-hint:hover {
  color: var(--accent);
  border-color: var(--accent);
  text-decoration: none;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.theme-toggle-track {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  transition: background 0.2s ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s ease, background 0.2s ease;
}

[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(15px);
  background: var(--accent);
}

.theme-toggle:hover .theme-toggle-track {
  border-color: var(--accent);
}

/* ---------------------------------------------------------------- book layout */

.layout-book {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 3.25rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2.75rem 1.5rem 4rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 92px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  align-self: start;
}

.toc-title {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.7rem;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.9rem;
  border-left: 1px solid var(--line);
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.26rem 0 0.26rem 0.65rem;
  color: var(--muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
  line-height: 1.4;
}

.toc a:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.study-main {
  min-width: 0;
  max-width: 74ch;
}

.chapter-kicker {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

.study-title {
  font-size: clamp(2rem, 4.4vw, 2.85rem);
  margin: 0 0 1.1rem;
}

.study-title em {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--accent);
}

.abstract {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  padding: 1rem 1.25rem;
  border-radius: 10px;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

.study-section {
  margin-top: 3.4rem;
  scroll-margin-top: 80px;
}

.study-section > h2 {
  font-size: 1.5rem;
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.15rem;
}

.study-section h3 {
  font-size: 1.07rem;
  margin: 1.9rem 0 0.65rem;
  letter-spacing: 0;
}

.prose-study {
  max-width: 72ch;
}

.prose-study p {
  margin: 0 0 0.95rem;
}

.prose-study .lead {
  font-size: 1.13rem;
  line-height: 1.6;
}

.prose-study ul,
.prose-study ol {
  margin: 0 0 0.95rem;
  padding-left: 1.35rem;
}

.prose-study li {
  margin-bottom: 0.35rem;
}

.prose-study li::marker {
  color: var(--accent);
}

.punch {
  border-left: 3px solid var(--accent);
  padding: 0.15rem 0 0.15rem 1.1rem;
  font-size: 1.08rem;
  line-height: 1.55;
  margin: 1.2rem 0 1.2rem;
}

/* ---------------------------------------------------------------- equations */

.eq-block {
  position: relative;
  overflow-x: auto;
  padding: 0.9rem 3.4rem 0.9rem 0.75rem;
  margin: 1rem 0 1.15rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--plate);
}

.eq-block mjx-container {
  margin: 0 !important;
}

.eq-tag {
  position: absolute;
  top: 0.85rem;
  right: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- boxes */

.box-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.def-box,
.warn-box,
.note-box {
  padding: 0.95rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  margin: 1.15rem 0;
  font-size: 0.98rem;
  line-height: 1.6;
}

.def-box {
  border-left: 3px solid var(--accent);
}

.warn-box {
  border-left: 3px solid var(--danger);
}

.warn-box .box-label {
  color: var(--danger);
}

.warn-box mjx-container {
  background: transparent;
}

.note-box {
  border-left: 3px solid var(--ok);
}

.note-box .box-label {
  color: var(--ok);
}

.def-box p,
.warn-box p,
.note-box p {
  margin: 0 0 0.5rem;
}

.def-box p:last-child,
.warn-box p:last-child,
.note-box p:last-child {
  margin-bottom: 0;
}

/* ---------------------------------------------------------------- tables */

.table-scroll {
  overflow-x: auto;
  margin: 1.15rem 0;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  background: var(--surface);
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2);
  white-space: nowrap;
}

.data-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  line-height: 1.5;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table .num {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  white-space: nowrap;
}

.data-table td[data-eq] {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

/* ---------------------------------------------------------------- plates (figures) */

.study-figure {
  margin: 1.35rem 0;
}

.plate {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--plate);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 26px 26px;
  padding: 1rem 0.9rem 0;
}

.plate-inner {
  position: relative;
  overflow: visible;
}

.plate-inner svg {
  width: 100%;
  height: auto;
}

.plate-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1.1rem;
  border-top: 1px solid var(--line-strong);
  margin: 0.7rem -0.9rem 0;
  padding: 0.5rem 0.9rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.plate-title .fig-no {
  font-weight: 700;
  color: var(--accent);
}

.plate-title .fig-note {
  margin-left: auto;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.study-figure figcaption {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 0.55rem;
}

.plate text,
.stage text {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.plate .lbl,
.stage .lbl {
  fill: var(--ink);
}

.plate .lbl-mut,
.stage .lbl-mut {
  fill: var(--muted);
}

.plate .lbl-acc,
.stage .lbl-acc {
  fill: var(--accent);
}

.plate .stroke,
.stage .stroke {
  stroke: var(--ink);
  fill: none;
  stroke-width: 1.5;
}

.plate .stroke-thin,
.stage .stroke-thin {
  stroke: var(--muted);
  fill: none;
  stroke-width: 1;
}

.plate .stroke-acc,
.stage .stroke-acc {
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.7;
}

.plate .dash,
.stage .dash {
  stroke-dasharray: 4 4;
}

.plate .dot,
.stage .dot {
  fill: var(--accent);
}

.plate .field,
.stage .field {
  fill: var(--surface-2);
  stroke: var(--line);
}

/* ---------------------------------------------------------------- roadmap cards */

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 0.85rem;
  margin: 1.35rem 0;
}

.phase {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.95rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 118px;
}

a.phase:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 10px 26px -18px var(--shadow);
}

.phase-num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.phase-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.25;
  color: var(--ink);
}

.phase-blurb {
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
  margin: 0;
}

a.phase .phase-title {
  color: var(--accent);
}

.has-phase .phase-tag,
.phase-tag {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.phase-tag--today {
  background: var(--accent);
  color: var(--on-accent);
}

.phase-tag--next {
  background: var(--ok-tint);
  color: var(--ok);
}

.phase-tag--up {
  background: var(--surface-2);
  color: var(--muted);
}

.phase--up {
  opacity: 0.68;
}

/* ---------------------------------------------------------------- evolution flow */

.evo-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.55rem;
  margin: 1.2rem 0;
}

.evo-chip {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.35;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
}

.evo-arrow {
  align-self: center;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- timeline eras */

.era-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
  gap: 0.85rem;
  margin: 1.35rem 0;
}

.era {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.95rem 1.05rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.era-year {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.era-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.3;
}

.era-blurb {
  font-size: 0.87rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0;
}

.era-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  margin-top: auto;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--line);
}

.era-links a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- lab */

.lab {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--plate);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 26px 26px;
  padding: 1.2rem 1.2rem 1.35rem;
  margin: 1.6rem 0;
}

.lab-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.8rem;
}

.lab-head h3 {
  font-size: 1.14rem;
}

.lab-head span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lab-intro {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0 0 1.1rem;
  max-width: 62ch;
}

.lab-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 1rem;
}

.lab-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 1rem 1.05rem 1.1rem;
  min-width: 0;
}

.lab-panel > h4 {
  font-size: 0.98rem;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.lab-panel .bench-id {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

.lab-panel > p {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0.35rem 0 0.9rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 0.7rem;
  margin: 0.55rem 0;
  font-size: 0.86rem;
}

.slider-row label {
  color: var(--ink);
  line-height: 1.3;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.lab-val {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-align: right;
  white-space: nowrap;
}

.readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 0.5rem;
  margin: 0.85rem 0 0;
}

.readout dl {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: var(--plate);
}

.readout dt {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.readout dd {
  margin: 0.15rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.readout dd small {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.66rem;
}

.stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--plate);
  margin: 0.75rem 0 0;
  overflow: hidden;
}

.stage svg {
  width: 100%;
  height: auto;
}

.stage text {
  font-family: var(--font-mono);
  font-size: 10px;
}

.verdict {
  margin-top: 0.8rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink);
  border-top: 1px dashed var(--line);
  padding-top: 0.65rem;
}

.verdict strong {
  color: var(--accent);
}

/* scenario rows for the ambiguity machine */

.sc-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.6rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
}

.sc-row .sc-name {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sc-row .sc-fig {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  white-space: nowrap;
}

.sc-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  position: relative;
  overflow: hidden;
}

.sc-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: var(--accent);
}

.sc-bars {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sc-cause {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin: 0.3rem 0 0;
}

.sc-cause b {
  color: var(--ink);
  font-weight: 600;
}

/* ---------------------------------------------------------------- worked example */

.worked-board {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  padding: 1rem 1.2rem 1.1rem;
  margin: 1.4rem 0;
}

.worked-board .box-label {
  margin-bottom: 0.65rem;
}

.math-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.math-steps li {
  counter-increment: step;
  position: relative;
  padding: 0.5rem 0 0.5rem 2.4rem;
  border-bottom: 1px dashed var(--line);
  font-size: 0.96rem;
  line-height: 1.55;
  opacity: 1;
  max-height: 400px;
  overflow: visible;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.math-steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0.15rem;
  top: 0.62rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
}

.math-steps li:last-child {
  border-bottom: 0;
}

.math-steps li.hidden-step {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom-color: transparent;
  overflow: hidden;
  pointer-events: none;
}

.reveal-btns {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.btn-ink {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ink:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ink--fill {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-ink--fill:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}

/* ---------------------------------------------------------------- checkpoint quiz */

.quiz {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  padding: 1.1rem 1.25rem 1.2rem;
  margin: 1.5rem 0;
}

.quiz-q {
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 0 0 0.9rem;
}

.quiz-opts {
  display: grid;
  gap: 0.5rem;
}

.quiz-opt {
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.45;
  padding: 0.6rem 0.85rem 0.6rem 2.2rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--plate);
  color: var(--ink);
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-opt::before {
  content: "";
  position: absolute;
  left: 0.85rem;
  top: 0.95rem;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  transition: all 0.15s ease;
}

.quiz-opt:hover {
  border-color: var(--accent);
}

.quiz-opts.is-locked .quiz-opt {
  cursor: default;
}

.quiz-opt[data-state="chosen-wrong"] {
  border-color: var(--danger);
  background: var(--danger-tint);
}

.quiz-opt[data-state="chosen-wrong"]::before {
  border-color: var(--danger);
  background: var(--danger);
}

.quiz-opt[data-state="chosen-right"] {
  border-color: var(--ok);
  background: var(--ok-tint);
}

.quiz-opt[data-state="chosen-right"]::before {
  border-color: var(--ok);
  background: var(--ok);
}

.quiz-opt:disabled {
  opacity: 0.55;
}

.quiz-opt:disabled[data-state] {
  opacity: 1;
}

.quiz-verdict {
  margin-top: 0.95rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--line);
  font-size: 0.94rem;
  line-height: 1.55;
}

.quiz-verdict .verdict-flag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.4rem;
}

.quiz-verdict[data-state="right"] .verdict-flag {
  color: var(--ok);
}

.quiz-verdict[data-state="wrong"] .verdict-flag {
  color: var(--danger);
}

/* ---------------------------------------------------------------- next-lecture box */

.lesson-next {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  padding: 1.15rem 1.3rem 1.25rem;
  margin: 3rem 0 0;
}

.lesson-next h2 {
  font-size: 1.28rem;
  margin-bottom: 0.7rem;
}

.lesson-next p {
  margin: 0 0 0.8rem;
}

.source-note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-top: 2.6rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

/* ---------------------------------------------------------------- footer */

.series-foot {
  margin-top: 3.2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.series-foot a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
}

.series-foot a:hover {
  color: var(--accent);
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1150px) {
  .layout-book {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .toc {
    position: static;
    order: 2;
    margin: 2.5rem 0 0;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
  }

  .toc ol {
    border-left: 0;
    padding-left: 0;
    columns: 2;
    column-gap: 2rem;
  }

  .toc a {
    border-left: 0;
    margin-left: 0;
    padding: 0.28rem 0;
    break-inside: avoid;
  }

  .toc a.active {
    color: var(--accent);
  }
}

@media (max-width: 760px) {
  body {
    font-size: 16.5px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
  }

  .chapter-nav {
    order: 3;
    width: 100%;
  }

  .layout-book {
    padding: 1.9rem 1rem 3rem;
  }

  .toc ol {
    columns: 1;
  }

  .slider-row {
    grid-template-columns: 110px minmax(0, 1fr);
    grid-template-rows: auto auto;
  }

  .slider-row .lab-val {
    grid-column: 2;
    text-align: left;
  }

  .study-section {
    scroll-margin-top: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .topbar,
  .toc,
  .reveal-btns,
  .lab,
  .quiz-opts {
    display: none !important;
  }

  .study-main {
    max-width: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
