/* ─────────────────────────────────────────────────────────────────────────
   Fathohm — Chapter 1: The Flow
   Warm editorial aesthetic. Theme via [data-theme] on <body>.
   ───────────────────────────────────────────────────────────────────────── */

:root, body[data-theme="paper"] {  --bg:          #f1ece0;
  --bg-deeper:   #e6dfca;
  --bg-card:     #faf6ec;
  --ink:         #2c2a26;
  --ink-soft:    #6b665d;
  --ink-faint:   #a39d92;
  --rule:        rgba(44, 42, 38, 0.14);
  --rule-strong: rgba(44, 42, 38, 0.32);

  --water:       #2c5e8e;
  --water-soft:  #6ba6c7;
  --water-faint: #c8dbe8;
  --water-deep:  #1c3f60;

  --current:      #c45a36;
  --current-soft: #e89972;
  --current-faint:#f3d5c0;
  --current-deep: #8a3a20;
}

body[data-theme="blueprint"] {
  --bg:          #0e2540;
  --bg-deeper:   #081a30;
  --bg-card:     #133153;
  --ink:         #f1ead4;
  --ink-soft:    #b6cde2;
  --ink-faint:   #6485a6;
  --rule:        rgba(241, 234, 212, 0.18);
  --rule-strong: rgba(241, 234, 212, 0.45);

  --water:       #7ec8e3;
  --water-soft:  #4a9bc4;
  --water-faint: rgba(126, 200, 227, 0.22);
  --water-deep:  #b9def0;

  --current:      #f5b969;
  --current-soft: #d99445;
  --current-faint:rgba(245, 185, 105, 0.22);
  --current-deep: #ffd49a;
}

body[data-theme="botanical"] {
  --bg:          #e8e2cf;
  --bg-deeper:   #d4ccb2;
  --bg-card:     #f0eada;
  --ink:         #232618;
  --ink-soft:    #585c47;
  --ink-faint:   #95987f;
  --rule:        rgba(35, 38, 24, 0.14);
  --rule-strong: rgba(35, 38, 24, 0.32);

  --water:       #4d6f50;
  --water-soft:  #84a387;
  --water-faint: #c8d4c5;
  --water-deep:  #2c4a30;

  --current:      #8a3a2f;
  --current-soft: #b8665a;
  --current-faint:#dfc0b7;
  --current-deep: #5c2218;
}

/* ─── reset / base ───────────────────────────────────────────────────────── */

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

html, body { margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Geist', 'Söhne', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "ss02", "kern";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 240ms ease, color 240ms ease;
  overflow-x: hidden;
}

::selection { background: var(--current-faint); color: var(--ink); }

/* ─── sitewide blueprint grid + copper texture ──────────────────────────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.45;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, black 55%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, black 55%, transparent 100%);
}
body[data-theme="blueprint"]::before { opacity: 0.7; }
/* keep real content above the grid (topbar excluded — it owns z-index:50 + fixed below) */
.progress-rail, .chapter-nav, #root > *:not(.topbar) { position: relative; z-index: 1; }

/* ─── typography ─────────────────────────────────────────────────────────── */

.serif, h1, h2, h3 {
  font-family: 'Newsreader', 'Iowan Old Style', 'Source Serif Pro', Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.012em;
}

.mono, .num {
  font-family: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-feature-settings: "tnum", "zero";
}

h1 {
  font-size: clamp(48px, 8vw, 120px);
  line-height: 0.96;
  margin: 0;
}

h2 {
  font-size: clamp(36px, 5.5vw, 76px);
  line-height: 1.02;
  margin: 0 0 0.4em;
}

h3 {
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.2;
  margin: 0 0 0.6em;
}

em, .italic { font-style: italic; }

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 500;
}
/* soldered-node bullet before section eyebrows / markers */
.section .marker::before,
.beat-marker::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--current);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--current-faint);
  vertical-align: middle;
}

.lede {
  font-size: clamp(19px, 1.6vw, 23px);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 32em;
}

p { margin: 0 0 1em; max-width: 36em; }

/* Fact card — an emphasized "interesting fact" aside. Reuses the soldered-
   node dot motif (see .beat-marker::before) so it reads as a distinct,
   on-brand card type wherever it appears — not a one-off style. */
.fact-card {
  margin: 18px 0 0; padding: 16px 20px; background: var(--bg-deeper);
  border: 1px solid var(--rule); border-radius: 10px;
}
.fact-card .fact-eyebrow {
  display: flex; align-items: center;
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--current); font-weight: 600; margin-bottom: 8px;
}
.fact-card .fact-eyebrow::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 9px;
  border-radius: 50%; background: var(--current);
  box-shadow: 0 0 0 2px var(--bg-deeper), 0 0 0 3px var(--current-faint);
  flex: 0 0 auto;
}
.fact-card p { margin: 0; font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); }
.fact-card p + p { margin-top: 9px; }
.fact-card b { color: var(--ink); font-weight: 600; }

.note {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.94em;
}

a { color: var(--water); text-decoration: none; border-bottom: 1px solid var(--rule); }
a:hover { color: var(--water-deep); border-bottom-color: var(--water); }

/* ─── depth pass — elevation tokens (theme-aware via --ink) ───────────── */
:root {
  --edge-hi: inset 0 1px 0 color-mix(in oklch, #ffffff 50%, transparent);
  --shadow-card:
    0 1px 2px color-mix(in oklch, var(--ink) 9%, transparent),
    0 14px 32px -22px color-mix(in oklch, var(--ink) 55%, transparent);
  --shadow-panel:
    0 2px 5px color-mix(in oklch, var(--ink) 11%, transparent),
    0 28px 60px -34px color-mix(in oklch, var(--ink) 65%, transparent);
}
body[data-theme="blueprint"] {
  --edge-hi: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.30), 0 16px 38px -22px rgba(0, 0, 0, 0.85);
  --shadow-panel: 0 3px 8px rgba(0, 0, 0, 0.34), 0 30px 70px -34px rgba(0, 0, 0, 0.95);
}

/* ─── chrome ─────────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  box-shadow: 0 10px 26px -22px color-mix(in oklch, var(--ink) 80%, transparent);
  padding: 13px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink-soft);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(9px) saturate(1.1);
  backdrop-filter: blur(9px) saturate(1.1);
  border-bottom: 1px solid var(--rule);
}
body[data-theme="blueprint"] .topbar { background: color-mix(in oklch, var(--bg) 84%, transparent); }

/* On narrow screens, drop the chapter label so the brand + audience pill
   don't crowd or overlap. */
@media (max-width: 640px) {
  .topbar { padding: 12px 14px; gap: 10px; }
  .topbar > div > span { display: none; }
  /* breadcrumb + progress chip are redundant on phones (title is in the hero,
     progress lives on the dashboard) — hide them so the right cluster fits and
     the Explorer/Engineer toggle is never clipped off-screen. */
  .topbar .crumb,
  .topbar .course-prog,
  .topbar .section-badge { display: none; }
  .audience-pill button { padding: 5px 10px; letter-spacing: 0.08em; }
}
@media (max-width: 380px) {
  .audience-pill button { padding: 5px 8px; font-size: 10px; }
}

.topbar .brand { display: flex; gap: 14px; align-items: baseline; }
.topbar .brand .mark {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: var(--current);
  transform: translateY(1px);
}

.progress-rail {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: transparent; z-index: 60;
}
.progress-rail > div {
  height: 100%; width: 0; background: var(--current);
  transition: width 80ms linear;
}

.chapter-nav {
  position: fixed;
  right: 32px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 40;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.06em;
}
.chapter-nav a {
  border: none;
  color: var(--ink-faint);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: color 160ms ease;
}
.chapter-nav a::before {
  content: ""; display: block;
  width: 16px; height: 1px; background: var(--ink-faint);
  transition: width 160ms ease, background 160ms ease;
}
.chapter-nav a:hover, .chapter-nav a.active {
  color: var(--ink);
}
.chapter-nav a.active::before { width: 28px; background: var(--current); }
.chapter-nav a .label { opacity: 0; transition: opacity 160ms ease; }
.chapter-nav a:hover .label, .chapter-nav a.active .label { opacity: 1; }

@media (max-width: 1240px) { .chapter-nav { display: none; } }

/* ─── course map dropdown (top bar, every page) ─────────────────────────── */
.coursemenu { position: relative; margin-left: 6px; }
.cm-btn {
  display: inline-flex; align-items: center; gap: 8px;
  appearance: none; cursor: pointer;
  background: var(--bg-card); color: var(--ink);
  border: 1.5px solid var(--rule-strong); border-radius: 8px;
  padding: 6px 12px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  transition: border-color 140ms ease, background 140ms ease;
}
.cm-btn:hover { border-color: var(--current); }
.cm-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  width: 13px; height: 13px;
}
.cm-grid span { background: var(--current); border-radius: 1px; }
@media (max-width: 600px) { .cm-btn-label { display: none; } }

.cm-scrim { position: fixed; inset: 0; z-index: 65; }
.cm-map-link {
  grid-column: 1 / -1; margin-top: 2px; padding: 9px 10px 4px;
  border-top: 1px solid var(--rule); text-decoration: none;
  font-family: 'IBM Plex Mono', monospace; font-size: 11.5px;
  letter-spacing: 0.05em; color: var(--current);
}
.cm-map-link:hover { color: var(--current-deep); }
.cm-map-link.cm-feedback { border-top: none; padding-top: 2px; color: var(--ink-faint); }
.cm-map-link.cm-feedback:hover { color: var(--ink-soft); }
.cm-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 66;
  width: min(620px, 90vw);
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: var(--bg); border: 1px solid var(--rule-strong);
  border-radius: 12px; padding: 16px;
  box-shadow: 0 24px 60px -30px var(--ink);
  max-height: calc(100vh - 80px); overflow-y: auto;
  animation: cm-pop 150ms ease;
}
@keyframes cm-pop { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 640px) {
  .cm-panel { grid-template-columns: 1fr; max-height: 70vh; overflow-y: auto; }
}
.cm-group { display: flex; flex-direction: column; }
.cm-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--bg-card); padding: 5px 8px; border-radius: 5px;
  margin-bottom: 8px; align-self: flex-start;
}
.cm-tag.l0 { background: var(--water); }
.cm-tag.l1 { background: var(--ink); }
.cm-tag.l2 { background: var(--current); }
.cm-tag.pj { background: var(--current-deep); }
.cm-group-wide { grid-column: 1 / -1; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--rule); }
.cm-links { display: flex; flex-direction: column; gap: 1px; }
.cm-links a {
  display: flex; align-items: center; gap: 7px;
  border: none; border-radius: 6px;
  padding: 7px 9px; font-size: 13.5px; color: var(--ink-soft);
  transition: background 120ms ease, color 120ms ease;
}
.cm-links a:hover { background: var(--bg-deeper); color: var(--ink); }
.cm-links a.here { background: color-mix(in oklch, var(--current) 14%, transparent); color: var(--ink); }
.cm-link-t { flex: 1; }
.cm-check { color: var(--water); font-weight: 700; font-size: 12px; }
.cm-you {
  font-family: 'IBM Plex Mono', monospace; font-size: 8.5px;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--current); background: var(--bg-card);
  padding: 2px 5px; border-radius: 4px; border: 1px solid var(--current);
}
@media print { .coursemenu { display: none; } }

/* ─── breadcrumb in topbar ──────────────────────────────────────────────── */
.section-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--bg-card);
  background: var(--current);
  padding: 3px 9px;
  border-radius: 5px;
  position: relative;
}
.section-badge::before {
  content: "";
  position: absolute;
  left: -2px; top: 50%;
  width: 4px; height: 11px;
  transform: translateY(-50%);
  background: var(--current-deep);
  border-radius: 0 2px 2px 0;
}
.crumb {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.crumb a { border: none; color: var(--ink-faint); }
.crumb a:hover { color: var(--ink); }
.crumb-sep { color: var(--ink-faint); opacity: 0.7; }
.crumb-lvl { color: var(--ink-faint); }
.crumb-cur { color: var(--current); }
@media (max-width: 720px) {
  .crumb a, .crumb-lvl, .crumb-sep:first-of-type { display: none; }
}

/* ─── audience toggle in topbar ──────────────────────────────────────────── */
.audience-pill {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 2px;
  pointer-events: auto;
}
.audience-pill button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
  transition: background 160ms ease, color 160ms ease;
}
.audience-pill button.active {
  background: var(--current);
  color: var(--bg-card);
}

/* ─── always-visible course progress chip ──────────────────────────── */
.course-prog {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 11px 3px 4px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  border-bottom: 1px solid var(--rule-strong);
  background: var(--bg-card);
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
  transition: border-color 140ms ease;
}
.course-prog:hover { border-color: var(--current); }
.course-prog svg { display: block; }
.cp-text {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}
.cp-text b { color: var(--ink); font-weight: 600; }
.cp-text i { font-style: normal; color: var(--current); }
@media (max-width: 760px) { .cp-text i { display: none; } }
@media (max-width: 560px) { .course-prog { padding: 3px; } .cp-text { display: none; } }

/* ─── "Expand your Beacon" hook at the end of each chapter ────────────────── */
.wn-beacon {
  display: flex; align-items: center; gap: 18px; margin-top: 30px;
  padding: 18px 22px; border: 1px solid var(--current); border-radius: 12px;
  background: color-mix(in oklch, var(--current) 6%, var(--bg-card));
  text-decoration: none; color: inherit; border-bottom: 1px solid var(--current);
  transition: box-shadow 200ms ease, transform 200ms ease;
}
.wn-beacon:hover { transform: translateY(-2px); box-shadow: var(--edge-hi), 0 14px 36px -24px var(--current); }
.wn-beacon { box-shadow: var(--edge-hi), var(--shadow-card); }
.wn-beacon-icon { flex: 0 0 auto; display: flex; }
.wn-beacon-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; }
.wn-beacon-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10.5px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--current);
}
.wn-beacon-title { font-size: 17px; color: var(--ink); }
.wn-beacon-title em { font-style: italic; }
.wn-beacon-go {
  flex: 0 0 auto; font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap;
}
@media (max-width: 560px) { .wn-beacon { flex-wrap: wrap; gap: 12px; } }

/* ─── chapter strip (footer band) ────────────────────────────────────────── */
.chapter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-card);
  margin-bottom: 28px;
  align-self: flex-start;
}
.chapter-strip a {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--ink-faint);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  transition: background 160ms ease, color 160ms ease;
}
.chapter-strip a:hover { color: var(--ink); background: var(--bg-deeper); }
.chapter-strip a.current { background: var(--current); color: var(--bg-card); }
.chapter-strip .num { opacity: 0.6; font-size: 10px; letter-spacing: 0.14em; }
.chapter-strip a.current .num { opacity: 0.85; }
.chapter-strip .title { font-style: italic; }
.chapter-strip a.done {
  color: var(--ink);
}
.chapter-strip a.done::before {
  content: "";
}
.chapter-strip .check {
  margin-left: 4px;
  color: var(--water);
  font-weight: 700;
  font-size: 11px;
}
.chapter-strip a.current .check { color: var(--bg-card); }

/* ─── cover-page (sits ABOVE the sticky grid, full-bleed) ─────────────── */
.cover-page {
  position: relative;
  min-height: 100vh;
  padding: 8vh 6vw 8vh;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
}
.cover-inner {
  position: relative;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}
.cover-title {
  font-size: clamp(56px, 9vw, 132px);
  line-height: 0.94;
  letter-spacing: -0.015em;
  margin: 0;
}
.cover-lede {
  max-width: 36em;
  font-size: clamp(19px, 1.6vw, 23px);
  line-height: 1.5;
  color: var(--ink-soft);
  margin-top: 6px;
}
/* "Previously" recap card on a chapter cover — a landing spot for returning learners */
.cover-recap {
  display: block;
  margin-top: 30px;
  max-width: 40em;
  padding: 15px 18px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--current);
  border-radius: 10px;
  background: color-mix(in oklch, var(--bg-card) 70%, transparent);
  text-decoration: none;
  transition: border-color 140ms ease, transform 140ms ease;
}
.cover-recap:hover { border-color: var(--current); transform: translateY(-1px); }
.cover-recap-tag {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--current); margin-bottom: 5px;
}
.cover-recap-text {
  display: block; font-size: 15.5px; line-height: 1.5; color: var(--ink-soft);
}
.cover-recap-go {
  display: inline-block; margin-top: 7px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-faint);
}
.cover-recap:hover .cover-recap-go { color: var(--current); }

/* hierarchy label above the secondary "paths from here" cards in WhatsNext */
.wn-more-label {
  margin-top: 34px; margin-bottom: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint);
}
.wn-more-label + .wn-beacon { margin-top: 12px; }

.cover-cta {
  margin-top: 56px;
  display: flex;
  gap: 14px;
}
.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--current-deep) !important;
  background: var(--current);
  color: var(--bg-card) !important;
  padding: 13px 26px;
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.arrow-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 -2px var(--current-deep), 0 12px 22px -12px var(--current);
}
.arrow-glyph {
  font-family: serif;
  font-size: 14px;
  line-height: 1;
}

/* ─── unified CTA buttons ─────────────────────────────────────────────── */
/* ─── unified CTA buttons ─────────────────────────────────────────────── */
/* ─── chunkier "chip" CTA buttons ─────────────────────────────────────── */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 24px;
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  border: 2px solid var(--rule-strong);
  transition: transform 120ms ease, box-shadow 120ms ease;
  position: relative;
}
/* solder-pad notches on the leading edge — reads like an IC pin */
.cta::before {
  content: "";
  position: absolute;
  left: -2px; top: 50%;
  width: 5px; height: 14px;
  transform: translateY(-50%);
  border-radius: 0 3px 3px 0;
  background: currentColor;
  opacity: 0.55;
}
.cta-primary {
  background: var(--current);
  color: var(--bg-card) !important;
  border-color: var(--current-deep);
}
.cta-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 -2px var(--current-deep), 0 12px 22px -12px var(--current);
}
.cta-secondary {
  background: var(--bg-card);
  color: var(--ink) !important;
}
.cta-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 -2px var(--rule-strong);
}

/* ─── predict-then-reveal ────────────────────────────────────────────── */
.predict-reveal {
  background: var(--bg-card);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 22px 24px;
  margin: 32px 0;
}
.predict-q {
  font-family: 'Newsreader', serif;
  font-size: 22px;
  line-height: 1.3;
  font-style: italic;
  margin: 12px 0 18px;
  max-width: 40em;
}
.predict-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.predict-opts button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-align: left;
  padding: 12px 14px;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 12px;
  transition: background 120ms ease, border-color 120ms ease;
}
.predict-opts button:hover:not(:disabled) {
  background: var(--bg-deeper);
  border-color: var(--rule-strong);
}
.predict-opts button .letter {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  border: 1px solid var(--rule-strong);
  padding: 3px 7px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.predict-opts button.correct {
  background: color-mix(in oklch, var(--water) 12%, transparent);
  border-color: var(--water);
}
.predict-opts button.correct .letter {
  color: var(--water);
  border-color: var(--water);
}
.predict-opts button.wrong {
  background: color-mix(in oklch, var(--current) 8%, transparent);
  border-color: var(--current-soft);
  opacity: 0.75;
}
.predict-opts button.reveal-correct {
  background: color-mix(in oklch, var(--water) 8%, transparent);
  border-color: var(--water-soft);
}
.predict-opts button:disabled { cursor: default; }
.predict-explain {
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  border-left: 2px solid var(--water);
  padding-left: 14px;
}
.predict-explain.wrong { border-left-color: var(--current); }

/* ─── ch2 branch readouts + live total ───────────────────────────────────── */
.branch-readout {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-soft);
  padding: 4px 2px 10px;
  border-bottom: 1px dotted var(--rule);
  margin-bottom: 8px;
}
.branch-readout .mono { font-size: 12px; }
.total-calc {
  margin-top: 18px;
  border: 2px solid var(--current);
  border-radius: 8px;
  background: var(--bg-card);
  padding: 16px 18px;
}
.predict-explain strong { color: var(--ink); }

/* ─── chapter quiz ───────────────────────────────────────────────────── */
.quiz-section { border-bottom: 1px solid var(--rule); }
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin: 32px 0;
}
.quiz-q {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 22px 24px;
  box-shadow: var(--edge-hi), var(--shadow-card);
}
.quiz-q-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 10px;
}
.quiz-q-text {
  font-family: 'Newsreader', serif;
  font-size: 23px;
  line-height: 1.3;
  font-style: italic;
  margin: 0 0 18px;
  max-width: none;
}
.quiz-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quiz-opts button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-align: left;
  padding: 12px 14px;
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 120ms ease, border-color 120ms ease;
}
.quiz-opts button:hover:not(:disabled) {
  background: var(--bg-deeper);
  border-color: var(--rule-strong);
}
.quiz-opts button .letter {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  border: 1px solid var(--rule-strong);
  padding: 3px 7px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.quiz-opts button .tick,
.quiz-opts button .cross {
  margin-left: auto;
  font-weight: 700;
}
.quiz-opts button .tick { color: var(--water); }
.quiz-opts button .cross { color: var(--current); }
.quiz-opts button.picked {
  background: var(--bg-deeper);
  border-color: var(--ink-faint);
}
.quiz-opts button.picked .letter {
  color: var(--ink);
  border-color: var(--ink-faint);
}
.quiz-opts button.correct {
  background: color-mix(in oklch, var(--water) 12%, transparent);
  border-color: var(--water);
}
.quiz-opts button.correct .letter { color: var(--water); border-color: var(--water); }
.quiz-opts button.wrong {
  background: color-mix(in oklch, var(--current) 9%, transparent);
  border-color: var(--current-soft);
}
.quiz-opts button.wrong .letter { color: var(--current); border-color: var(--current-soft); }
.quiz-opts button:disabled { cursor: default; }
.quiz-explain {
  margin-top: 14px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  border-left: 2px solid var(--water);
  padding-left: 14px;
}
.quiz-explain.wrong { border-left-color: var(--current); }

.quiz-actions { display: flex; }
.quiz-submit, .quiz-retry {
  appearance: none;
  border: 1px solid var(--current);
  background: var(--current);
  color: var(--bg-card);
  padding: 13px 26px;
  border-radius: 999px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
.quiz-submit:hover:not(:disabled), .quiz-retry:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px -8px var(--current);
}
.quiz-submit:disabled {
  background: transparent;
  color: var(--ink-faint);
  border-color: var(--rule-strong);
  cursor: default;
}
.quiz-retry {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-strong);
}

.quiz-result {
  display: flex;
  gap: 28px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--bg-card);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  padding: 26px 28px;
  margin-top: 8px;
}
.quiz-result.passed { border-color: var(--water); }
.quiz-result.review { border-color: var(--current-soft); }
.quiz-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
  min-width: 120px;
}
.quiz-score-num {
  font-family: 'Newsreader', serif;
  font-size: 56px;
  line-height: 1;
  font-style: italic;
}
.quiz-score-den { font-size: 26px; color: var(--ink-faint); }
.quiz-score-pct {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin-top: 6px;
}
.quiz-verdict {
  flex: 1 1 280px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.quiz-verdict strong { color: var(--ink); }

/* ─── section layout ─────────────────────────────────────────────────────── */

.section {
  position: relative;
  min-height: 100vh;
  padding: 14vh 8vw 9vh;
  display: flex; flex-direction: column; justify-content: center;
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}

.section .marker {
  position: absolute; top: 6vh; left: 8vw;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ─── practice problems (numeric drills) ─────────────────────────────────── */
.practice .lede { margin-bottom: 8px; }
.practice-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px 24px; flex-wrap: wrap;
}
.practice-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pp-reroll {
  appearance: none; cursor: pointer; height: 34px; padding: 0 14px;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: transparent;
  color: var(--ink-soft); font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  letter-spacing: 0.04em; transition: all 140ms ease;
}
.pp-reroll:hover { border-color: var(--current); color: var(--current); }
.pp-prehint {
  margin: 2px 0 0; font-size: 13.5px; color: var(--water); font-style: italic;
  background: color-mix(in oklch, var(--water) 7%, transparent);
  padding: 8px 12px; border-radius: 7px;
}

/* difficulty segmented control */
.diff-toggle { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.diff-label {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint);
}
.diff-seg {
  display: inline-flex; background: var(--bg-card);
  border: 1px solid var(--rule-strong); border-radius: 999px; padding: 2px;
}
.diff-seg button {
  appearance: none; border: none; cursor: pointer; background: transparent;
  font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; letter-spacing: 0.03em;
  padding: 5px 13px; border-radius: 999px; color: var(--ink-soft);
  transition: background 150ms ease, color 150ms ease;
}
.diff-toggle.compact .diff-seg button { padding: 4px 11px; font-size: 11px; }
.diff-seg button.active { background: var(--current); color: var(--bg-card); }
.diff-blurb { font-size: 12.5px; color: var(--ink-faint); font-style: italic; min-width: 0; }

.pp-list { display: grid; gap: 16px; margin-top: 28px; }
.pp-item {
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: 10px; padding: 20px 22px;
  box-shadow: var(--edge-hi), var(--shadow-card);
  border-left: 3px solid var(--rule-strong);
  transition: border-color 180ms ease;
}
.pp-item.ok { border-left-color: var(--current); }
.pp-item.no { border-left-color: color-mix(in oklch, #c0392b 70%, var(--rule-strong)); }
.pp-q { display: flex; gap: 12px; align-items: baseline; }
.pp-n { font-size: 12px; color: var(--ink-faint); flex: 0 0 auto; padding-top: 2px; }
.pp-q-text { font-family: 'Newsreader', serif; font-size: 21px; line-height: 1.35; color: var(--ink); }
.pp-q-text sub { font-size: 0.72em; }
.pp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; padding-left: 24px; }
.pp-input {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--rule-strong); border-radius: 8px;
  background: var(--bg); padding: 0 12px; height: 42px;
}
.pp-input:focus-within { border-color: var(--water); }
.pp-input input {
  appearance: none; border: none; background: transparent; outline: none;
  font-family: 'IBM Plex Mono', monospace; font-size: 16px; color: var(--ink);
  width: 110px; height: 100%;
}
.pp-unit { font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: var(--ink-faint); }
.pp-check, .pp-soltoggle {
  appearance: none; cursor: pointer; height: 42px; padding: 0 18px;
  border-radius: 8px; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.pp-check { border: none; background: var(--current); color: var(--bg-card); }
.pp-check:disabled { background: var(--bg-deeper); color: var(--ink-faint); cursor: not-allowed; }
.pp-soltoggle { border: 1px solid var(--rule-strong); background: transparent; color: var(--ink-soft); }
.pp-soltoggle:hover { border-color: var(--ink-soft); }
.pp-verdict { margin: 12px 0 0 24px; font-size: 15px; line-height: 1.5; color: var(--ink-soft); }
.pp-verdict.ok { color: var(--current); font-weight: 500; }
.pp-hint { color: var(--ink-faint); font-style: italic; }
.pp-solution {
  margin: 14px 0 0 24px; padding: 14px 16px; border-radius: 8px;
  background: var(--bg-deeper); display: grid; gap: 6px;
}
.pp-sol-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-faint);
}
.pp-sol-body { font-size: 15.5px; line-height: 1.55; color: var(--ink); }
.pp-sol-body sub { font-size: 0.72em; }
.pp-answer { font-size: 14px; color: var(--current); }
.pp-foot { margin-top: 20px; font-size: 14px; color: var(--ink-faint); font-style: italic; }
.pp-foot a { color: var(--water); }

.section-inner { width: 100%; max-width: 1280px; margin: 0 auto; }

.two-col {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1.4fr;
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ─── cards / panels ─────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 24px;
  box-shadow: var(--edge-hi), var(--shadow-card);
}

.stage {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 28px;
  position: relative;
  box-shadow: var(--edge-hi), var(--shadow-card);
}

.stage-label {
  position: absolute; top: 14px; left: 18px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint);
}

/* ─── sliders ────────────────────────────────────────────────────────────── */

.ctrl { display: flex; flex-direction: column; gap: 8px; padding: 14px 0; }
.ctrl-head { display: flex; justify-content: space-between; align-items: baseline; }
.ctrl-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.ctrl-val {
  font-family: 'Newsreader', serif;
  font-size: 28px; line-height: 1; font-style: italic;
}
.ctrl-val .unit { font-style: normal; font-size: 14px; margin-left: 4px; color: var(--ink-faint); font-family: 'IBM Plex Mono', monospace; }

.range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 2px;
  background: var(--rule-strong);
  outline: none; cursor: pointer;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink);
  border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--rule-strong);
  cursor: grab;
}
.range::-webkit-slider-thumb:active { cursor: grabbing; }
.range::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--rule-strong);
}
.range.range-water::-webkit-slider-thumb { background: var(--water); }
.range.range-water::-moz-range-thumb { background: var(--water); }
.range.range-current::-webkit-slider-thumb { background: var(--current); }
.range.range-current::-moz-range-thumb { background: var(--current); }

/* ─── badge / chip ───────────────────────────────────────────────────────── */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.06em;
  color: var(--ink-soft);
  align-self: flex-start;
}
.chip.water { color: var(--water); border-color: var(--water); }
.chip.current { color: var(--current); border-color: var(--current); }

/* ─── equation block ─────────────────────────────────────────────────────── */

.eq {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: clamp(48px, 7vw, 96px);
  line-height: 1;
  display: inline-flex; align-items: baseline; gap: 0.18em;
}
.eq .op { font-style: normal; color: var(--ink-faint); }
.eq .num { font-style: normal; font-family: 'IBM Plex Mono', monospace; }
.eq .V { color: var(--water); }
.eq .I { color: var(--current); }
.eq .R { color: var(--ink); }

/* stacked fraction (e.g. V/R) — bar gets breathing room so numerator and
   denominator never touch it */
.eq .frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
}
.eq .frac > .top { padding: 0 0.32em 0.12em; }
.eq .frac > .bot { padding: 0.12em 0.32em 0; }
/* fallback for fracs whose children carry no .top/.bot classes */
.eq .frac > :first-child:not(.bar) { padding: 0 0.32em 0.14em; }
.eq .frac > :last-child:not(.bar) { padding: 0.14em 0.32em 0; }
.eq .frac > .bar {
  width: 100%;
  height: 0;
  border-top: 0.055em solid var(--ink-faint);
}

.kbd {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-soft);
}

/* ─── water + circuit flow ───────────────────────────────────────────────── */

.flow-anim {
  stroke-dasharray: 6 10;
  animation: flow-march var(--flow-period, 1.4s) linear infinite;
}
@keyframes flow-march {
  to { stroke-dashoffset: -160; }
}

/* Drifting sine streaks — the water-current texture inside pipes.
   The 56px translate MUST equal WATER_WAVELENGTH in visuals.jsx so each
   loop lands exactly one wavelength along and repeats seamlessly. */
.water-drift {
  animation: water-drift var(--flow-period, 1.4s) linear infinite;
}
@keyframes water-drift {
  to { transform: translateX(56px); }
}

.flow-particle {
  animation: particle-march var(--flow-period, 1.4s) linear infinite;
}
@keyframes particle-march {
  from { offset-distance: 0%; }
  to   { offset-distance: 100%; }
}

.pulse-glow {
  animation: pulse-glow 1.6s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ─── hero scribbles ─────────────────────────────────────────────────────── */

.hero-grid {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(to right, var(--rule) 1px, transparent 1px),
    linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 70% 60% at 60% 50%, black 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 60% 50%, black 30%, transparent 80%);
}

body[data-theme="blueprint"] .hero-grid {
  opacity: 0.5;
}

/* ─── divider rule ──────────────────────────────────────────────────────── */

.rule {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-faint);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  margin: 36px 0;
}
.rule::before, .rule::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}

/* ─── pull quote / marginalia ───────────────────────────────────────────── */

.pull {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: clamp(24px, 2.6vw, 34px);
  line-height: 1.25;
  color: var(--ink);
  border-left: 2px solid var(--current);
  padding-left: 22px;
  margin: 28px 0;
  max-width: 26em;
}

.marg {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.45;
  max-width: 22em;
}

/* hairline arrow */
.arrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.arrow::after { content: "→"; font-family: serif; font-size: 16px; }

/* ─── lesson scrollytelling ──────────────────────────────────────────────── */

/* stacked, self-contained lesson sections (each owns its own visual) */
.lesson-stack { display: flex; flex-direction: column; }
.lesson-stack > * + * { border-top: 1px solid var(--rule); }
.lesson-stack > .lesson { padding-top: 4vh; padding-bottom: 4vh; }
.lesson-solo { width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 6vw; }
.lesson-solo .beat {
  min-height: auto; padding: 8vh 0; max-width: 900px; margin: 0 auto;
  border-top: none; justify-content: flex-start;
}

.lesson {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding: 9vh 6vw 6vh;
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(440px, 1.15fr);
  gap: clamp(40px, 5vw, 88px);
  align-items: start;
}

.lesson-scroll {
  display: flex; flex-direction: column;
}

.beat {
  min-height: 92vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6vh 0;
  border-top: 1px solid var(--rule);
  position: relative;
}
.beat:first-child { border-top: none; padding-top: 0; min-height: 88vh; }
.beat .beat-marker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 26px;
}

.beat-cover h1 {
  font-size: clamp(48px, 7vw, 104px);
  line-height: 0.96;
}
.beat-cover .hero-grid { position: absolute; inset: 0; }

.lesson-sticky {
  position: sticky;
  top: 6vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  height: 88vh;
}
.lesson-sticky[data-single="1"] .vis-block { flex: 1 1 0; }

.vis-block {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 18px 10px;
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: flex; flex-direction: column;
  box-shadow: var(--edge-hi), var(--shadow-panel);
}
.vis-block .stage-label { position: static; margin-bottom: 4px; }
.vis-block svg { flex: 1; min-height: 0; }

.vis-readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.vis-readout > div {
  background: var(--bg-card);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.vis-readout .ro-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-faint);
}
.vis-readout .ro-val {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: clamp(22px, 2vw, 28px);
  line-height: 1;
}
.vis-readout .ro-unit {
  font-family: 'IBM Plex Mono', monospace;
  font-style: normal;
  font-size: 11px; color: var(--ink-faint);
  margin-left: 2px;
}
.vis-readout .ro-v   .ro-val { color: var(--water); }
.vis-readout .ro-i   .ro-val { color: var(--current); }
.vis-readout .ro-active { background: var(--bg-deeper); }

/* highlight per-mode */
.lesson[data-mode="voltage"]    .vis-readout .ro-v { background: var(--bg-deeper); }
.lesson[data-mode="resistance"] .vis-readout .ro-r { background: var(--bg-deeper); }
.lesson[data-mode="current"]    .vis-readout .ro-i { background: var(--bg-deeper); }
.lesson[data-mode="playground"] .vis-readout .ro-p { background: var(--bg-deeper); }

@media (max-width: 1100px) {
  /* minmax(0,1fr) (not bare 1fr) so the single column can shrink BELOW its
     children's min-content — otherwise a non-wrapping child (the 4-up readout
     row, a wide SVG) forces the column wider than the viewport and clips every
     line on narrow phones (~360px). min-width:0 on the items is the partner fix. */
  .lesson { grid-template-columns: minmax(0, 1fr); padding: 0 5vw; }
  .lesson-scroll, .lesson-sticky { min-width: 0; }
  .lesson-sticky {
    order: -1;
    position: sticky;
    /* clear the fixed topbar (measured into --topbar-h) so the scene tabs
       at the panel's top don't tuck up behind the bar when it pins */
    top: var(--topbar-h, 52px);
    height: auto;
    max-height: none;
    z-index: 5;
    background: var(--bg);
    padding: 8px 0 10px;
    border-bottom: 1px solid var(--rule);
    gap: 8px;
  }
  /* On mobile only ONE animation fits — default to the water scene and let
     the VisTabs switcher flip to the second block. (Sibling selector, not
     nth-of-type: the tabs div must not shift the count.) */
  .lesson-sticky .vis-block { flex: 0 0 auto; }
  .lesson-sticky:not([data-vis-tab="1"]) .vis-block ~ .vis-block { display: none; }
  .lesson-sticky[data-vis-tab="1"] .vis-block:has(~ .vis-block) { display: none; }
  .lesson-sticky .vis-tabs { display: flex; }
  .lesson-sticky .vis-block svg { max-height: 30vh !important; height: auto !important; }
  .vis-block { padding: 4px 8px 3px; }
  .vis-block .stage-label { font-size: 9px; margin-bottom: 2px; }
  /* compact single-row readout so the pinned panel leaves most of the screen
     to the prose + sliders (it was eating ~2/3 of a phone viewport) */
  .vis-readout { flex: 0 0 auto; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .vis-readout > div { padding: 5px 8px; }
  .vis-readout .ro-name { font-size: 8.5px; letter-spacing: 0.08em; }
  .vis-readout .ro-val { font-size: 17px; }
  .vis-readout .ro-unit { font-size: 10px; }
  .beat { min-height: auto; padding: 7vh 0; }
}

@media (max-width: 1100px) {
  /* Mobile note that the circuit view is hidden */
  .mobile-anim-note { display: block; }
}
.mobile-anim-note { display: none; }

/* mobile scene tabs — base hidden; the max-width:1100px block above shows
   them via the more-specific .lesson-sticky .vis-tabs (a bare .vis-tabs
   rule here would win on source order and keep them hidden forever) */
.vis-tabs { display: none; gap: 6px; }
.vis-tabs button {
  appearance: none; flex: 1;
  border: 1.5px solid var(--rule-strong);
  background: transparent; color: var(--ink-soft);
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  letter-spacing: 0.12em; font-weight: 500;
}
.vis-tabs button.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg-card);
}

/* ─── glossary floating button + slide-over ─────────────────────────────── */
.fab-stack {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.fab-stack .glossary-fab { position: static; right: auto; bottom: auto; }
.feedback-fab {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card); color: var(--ink);
  border: 1.5px solid var(--rule-strong); border-radius: 999px;
  padding: 9px 15px 9px 11px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: 0 6px 20px -10px var(--ink);
  transition: transform 140ms ease, border-color 140ms ease;
}
.feedback-fab:hover { transform: translateY(-2px); border-color: var(--current); }
.feedback-fab .gf-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--current); color: var(--bg-card);
  font-weight: 700; font-size: 12px;
}
@media (max-width: 600px) { .feedback-fab .gf-label { display: none; } }
.feedback-panel .fb-body { padding: 6px 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.fb-lead { font-size: 15px; color: var(--ink-soft); line-height: 1.55; margin: 0; max-width: none; }
.fb-text {
  width: 100%; resize: vertical; min-height: 130px; box-sizing: border-box;
  font-family: 'Geist', system-ui, sans-serif; font-size: 15px; line-height: 1.5;
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--rule-strong);
  background: var(--bg); color: var(--ink);
}
.fb-text:focus { outline: none; border-color: var(--current); }
.fb-send {
  appearance: none; cursor: pointer; align-self: flex-start;
  font-family: 'IBM Plex Mono', monospace; font-size: 13px;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 11px 18px; border-radius: 9px; border: none;
  background: var(--current); color: var(--bg-card);
}
.fb-send:disabled { background: var(--bg-deeper); color: var(--ink-faint); cursor: not-allowed; }
.fb-form { font-size: 13px; color: var(--water); border: none; align-self: flex-start; }
.fb-note { font-size: 12.5px; color: var(--ink-faint); font-style: italic; margin: 0; }
@media print { .fab-stack { display: none; } }
.search-fab {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card); color: var(--ink);
  border: 1.5px solid var(--rule-strong); border-radius: 999px;
  padding: 9px 15px 9px 11px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: 0 6px 20px -10px var(--ink);
  transition: transform 140ms ease, border-color 140ms ease;
}
.search-fab:hover { transform: translateY(-2px); border-color: var(--current); }
.search-fab .gf-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); color: var(--bg-card); font-size: 13px;
}
@media (max-width: 600px) { .search-fab .gf-label { display: none; } }

/* ─── sound toggle fab + narration ───────────────────────────────────────── */
.sound-fab {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-card); color: var(--ink);
  border: 1.5px solid var(--rule-strong); border-radius: 999px;
  padding: 9px 15px 9px 11px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: 0 6px 20px -10px var(--ink);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}
.sound-fab:hover { transform: translateY(-2px); border-color: var(--current); }
.sound-fab .gf-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ink); color: var(--bg-card); font-size: 12px;
}
.sound-fab.on { border-color: var(--current); }
.sound-fab.on .gf-q { background: var(--current); }
@media (max-width: 600px) { .sound-fab .gf-label { display: none; } }

.narrate-btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; color: var(--current);
  border: 1px solid color-mix(in oklch, var(--current) 45%, transparent);
  border-radius: 999px; padding: 5px 13px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 11.5px;
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: background 140ms ease, color 140ms ease;
}
.narrate-btn:hover { background: color-mix(in oklch, var(--current) 10%, transparent); }
.narrate-btn.on { background: var(--current); color: var(--bg-card); border-color: var(--current); }
.sonify-hint {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 7px 13px; border-radius: 999px;
  background: color-mix(in oklch, var(--current) 9%, transparent);
  border: 1px solid color-mix(in oklch, var(--current) 35%, transparent);
  font-family: 'IBM Plex Mono', monospace; font-size: 12.5px;
  color: var(--current); letter-spacing: 0.02em;
}
.sonify-hint-ico { font-size: 13px; }

/* ─── read-as-I-scroll narrator bar ──────────────────────────────────────── */
.readalong {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 61; display: inline-flex; align-items: center; gap: 12px;
  max-width: min(92vw, 520px);
}
.readalong-btn {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--ink); color: var(--bg-card);
  border: none; border-radius: 999px; padding: 11px 20px; cursor: pointer;
  font-family: 'IBM Plex Mono', monospace; font-size: 12.5px;
  letter-spacing: 0.08em; text-transform: uppercase;
  box-shadow: 0 10px 30px -12px var(--ink);
  transition: transform 140ms ease, background 140ms ease;
}
.readalong-btn:hover { transform: translateY(-2px); }
.readalong.on .readalong-btn { background: var(--current); }
.readalong-ico { font-size: 11px; }
.readalong-now {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-soft);
  background: var(--bg-card); border: 1px solid var(--rule-strong);
  border-radius: 999px; padding: 6px 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
@media (max-width: 600px) {
  .readalong { bottom: 76px; }
  .readalong-now { display: none; }
}
@media print { .readalong { display: none; } }
.narrate-ico { font-size: 9px; }

/* ─── course search overlay ──────────────────────────────────────────────── */
.search-panel {
  position: fixed; left: 50%; top: 12vh; transform: translateX(-50%);
  width: min(620px, 92vw); max-height: 76vh; z-index: 80;
  background: var(--bg-card); border: 1px solid var(--rule-strong);
  border-radius: 16px; box-shadow: 0 40px 90px -40px var(--ink);
  display: flex; flex-direction: column; overflow: hidden;
}
.sp-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--rule);
}
.sp-mag { font-size: 20px; color: var(--ink-faint); }
.sp-input {
  flex: 1; appearance: none; border: none; background: transparent; outline: none;
  font-family: 'Newsreader', serif; font-size: 22px; color: var(--ink);
}
.sp-results { overflow-y: auto; padding: 8px; }
.sp-group {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--ink-faint); padding: 12px 12px 6px;
}
.sp-row {
  display: flex; align-items: center; gap: 13px; padding: 10px 12px;
  border-radius: 9px; text-decoration: none; color: inherit; cursor: pointer;
}
a.sp-row:hover { background: var(--bg-deeper); }
.sp-row.term { cursor: default; }
.sp-row.soon { opacity: 0.5; cursor: default; }
.sp-n {
  flex: 0 0 auto; min-width: 34px; font-size: 12px; color: var(--current);
  text-align: center;
}
.sp-title { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 16px; color: var(--ink); }
.sp-title i { font-style: normal; font-size: 12.5px; color: var(--ink-faint); line-height: 1.35; }
.sp-level {
  flex: 0 0 auto; font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.08em; color: var(--ink-faint); text-transform: uppercase;
}
.sp-foot {
  padding: 11px 18px; border-top: 1px solid var(--rule);
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-faint);
}
.sp-foot kbd {
  font-family: 'IBM Plex Mono', monospace; background: var(--bg-deeper);
  border: 1px solid var(--rule-strong); border-radius: 4px; padding: 1px 5px; font-size: 10px;
}

/* ─── design gate (calculate → unlock build) ─────────────────────────────── */
.design-gate { display: flex; flex-direction: column; gap: 18px; }
.dg-card {
  border: 1px solid var(--rule-strong); border-radius: 12px;
  border-left: 3px solid var(--water); background: var(--bg-card);
  padding: 18px 20px;
}
.dg-card.done { border-left-color: var(--current); }
.dg-tag {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--current); margin-bottom: 10px;
}
.dg-spec {
  font-size: 14px; color: var(--ink-soft); background: var(--bg-deeper);
  padding: 9px 12px; border-radius: 7px; margin-bottom: 12px;
}
.dg-spec sub, .dg-prompt sub, .dg-formula sub, .dg-fb sub { font-size: 0.72em; }
.dg-prompt { font-size: 16px; line-height: 1.5; color: var(--ink); margin-bottom: 10px; }
.dg-formula {
  font-size: 13px; color: var(--ink-soft); background: var(--bg-deeper);
  padding: 8px 11px; border-radius: 7px; margin-bottom: 12px;
}
.dg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dg-input {
  display: inline-flex; align-items: center; gap: 6px; height: 42px;
  border: 1.5px solid var(--rule-strong); border-radius: 8px;
  background: var(--bg); padding: 0 12px;
}
.dg-input:focus-within { border-color: var(--water); }
.dg-input input {
  appearance: none; border: none; background: transparent; outline: none;
  font-family: 'IBM Plex Mono', monospace; font-size: 16px; color: var(--ink);
  width: 110px; height: 100%;
}
.dg-unit { font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: var(--ink-faint); }
.dg-check {
  appearance: none; cursor: pointer; height: 42px; padding: 0 20px; border: none;
  border-radius: 8px; background: var(--current); color: var(--bg-card);
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.dg-check:disabled { background: var(--bg-deeper); color: var(--ink-faint); cursor: not-allowed; }
.dg-fb { margin-top: 12px; font-size: 14.5px; line-height: 1.5; }
.dg-fb.ok { color: var(--ink-soft); }
.dg-fb.ok b { color: var(--current); }
.dg-fb.wrong { color: #b3402f; }
.dg-step2 {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--current); margin-bottom: 12px;
}
.dg-lock {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 40px 24px; border: 1.5px dashed var(--rule-strong); border-radius: 12px;
  background: var(--bg-deeper); color: var(--ink-faint);
  font-size: 15px; text-align: center;
}
.dg-lock-icon { font-size: 22px; opacity: 0.7; }

.glossary-fab {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 60;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--current); color: var(--bg-card);
  border: 2px solid var(--current-deep);
  border-radius: 999px;
  padding: 10px 16px 10px 12px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  box-shadow: 0 6px 20px -8px var(--current);
  transition: transform 140ms ease;
}
.glossary-fab:hover { transform: translateY(-2px); }
.glossary-fab .gf-q {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-card); color: var(--current);
  font-weight: 700; font-size: 13px;
}
@media (max-width: 600px) { .glossary-fab .gf-label { display: none; } }

.glossary-scrim {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in oklch, var(--ink) 32%, transparent);
  display: flex; justify-content: flex-end;
  animation: gp-fade 160ms ease;
}
@keyframes gp-fade { from { opacity: 0; } }
.glossary-panel {
  width: min(440px, 92vw);
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--rule-strong);
  display: flex; flex-direction: column;
  box-shadow: -18px 0 50px -30px var(--ink);
  animation: gp-slide 200ms cubic-bezier(.2,.7,.3,1);
}
@keyframes gp-slide { from { transform: translateX(40px); opacity: 0.6; } }
.gp-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 22px 12px;
}
.gp-head h3 { margin: 4px 0 0; font-size: 30px; }
.gp-close {
  appearance: none; background: transparent; border: 1px solid var(--rule-strong);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  color: var(--ink-soft); font-size: 14px;
}
.gp-close:hover { background: var(--bg-deeper); color: var(--ink); }
.gp-search {
  margin: 0 22px 12px; padding: 11px 14px;
  border: 1px solid var(--rule-strong); border-radius: 8px;
  background: var(--bg-card); color: var(--ink);
  font-family: 'Geist', system-ui, sans-serif; font-size: 15px;
}
.gp-search:focus { outline: 2px solid var(--current); outline-offset: -1px; }
.gp-list { overflow-y: auto; padding: 4px 22px 28px; display: flex; flex-direction: column; gap: 14px; }
.gp-item { border-bottom: 1px solid var(--rule); padding-bottom: 14px; }
.gp-item:last-child { border-bottom: none; }
.gp-item-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gp-term { font-family: 'Newsreader', serif; font-style: italic; font-size: 21px; color: var(--ink); }
.gp-sym { font-size: 12px; color: var(--current); background: var(--bg-deeper); padding: 2px 7px; border-radius: 5px; }
.gp-unit { font-size: 11px; color: var(--ink-faint); }
.gp-def { font-size: 15px; line-height: 1.5; color: var(--ink-soft); margin-top: 6px; }
.gp-water { font-size: 13.5px; color: var(--water-deep); margin-top: 6px; display: flex; gap: 7px; align-items: baseline; }
.gp-water-tag { flex: 0 0 auto; }
.gp-empty { color: var(--ink-faint); font-style: italic; padding: 20px 0; }
@media print { .glossary-fab { display: none; } }

/* three-up equation cards (ch.3 "one law, three ways") — stack on narrow
   screens so the big fraction in the third card can't clip off the right. */
.eq-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
}
@media (max-width: 620px) {
  .eq-three { grid-template-columns: 1fr; gap: 10px; }
}

/* Topbar fit on small phones. These use .topbar-scoped selectors so they win
   over the base .audience-pill rules regardless of source order — the base
   pill's 0.14em tracking on "ENGINEER/EXPLORER" is what overflows ~320px bars.
   (Breadcrumb + progress chip are already hidden ≤640 elsewhere.) */
@media (max-width: 600px) {
  .topbar { padding: 11px 12px; gap: 8px; }
  .topbar .audience-pill button { padding: 5px 9px; letter-spacing: 0.05em; }
}
@media (max-width: 360px) {
  .topbar { padding: 10px 10px; }
  .topbar .audience-pill button { padding: 4px 7px; font-size: 9.5px; letter-spacing: 0.02em; }
  .topbar .brand .mark { display: none; }
}

/* ─── Touch targets ──────────────────────────────────────────────────────
   On touch devices, give the primary topbar controls a comfortable thumb
   height (~40px) without inflating the dense desktop look. Coarse pointer
   only, so mouse/desktop sizing is untouched. */
@media (pointer: coarse) {
  .topbar .audience-pill button { min-height: 38px; display: inline-flex; align-items: center; }
  .topbar .cm-btn { min-height: 40px; }
  .topbar .course-prog { min-height: 38px; }
}

/* 555 free-build bench (Workbench): two columns on desktop, stack on phones so
   the live blinker/schematic/scope isn't crushed next to the 260px knob panel. */
@media (max-width: 720px) {
  .oc555-grid { grid-template-columns: 1fr !important; }
}

/* ─── Mobile overflow guards ─────────────────────────────────────────────
   body has overflow-x:hidden, so anything wider than the viewport is CLIPPED
   and unreachable on phones. These rules force the common multi-column
   layouts to stack on small screens so nothing spills off-screen. */
.wn-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1.2fr;
  gap: clamp(32px, 5vw, 80px);
  align-items: start;
}
@media (max-width: 760px) {
  .wn-grid { grid-template-columns: 1fr; gap: 32px; }
}

/* Collapse inline two-column card grids (rendered as style="...grid...1fr 1fr")
   and minmax-floored grids to a single column on phones. Inline styles beat
   class rules, so these need !important. */
@media (max-width: 600px) {
  [style*="grid"][style*="1fr 1fr"],
  [style*="grid"][style*="1.35fr 1fr"],
  [style*="grid"][style*="1.2fr"],
  [style*="grid"][style*="1.1fr"],
  [style*="minmax(280px"],
  [style*="minmax(300px"],
  [style*="minmax(320px"],
  [style*="minmax(340px"],
  [style*="minmax(360px"] {
    grid-template-columns: 1fr !important;
  }
}

