/* === TOKENS === */
:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-sunken: #F4F3F9;
  --text: #1A1A2E;
  --text-muted: #5C5C7A;
  --accent: #C2342B;          /* moto red — primary */
  --accent-dark: #9A2922;
  --accent-light: #F7DEDB;
  --accent-secondary: #3F5C7A; /* asphalt slate — secondary */
  --accent-secondary-light: #DEE6EE;
  --warn: #D97706;
  --warn-light: #FDF1E0;
  --ok: #2D7D46;
  --ok-light: #E8F5EC;
  --err: #DC2626;
  --err-light: #FEE8E8;
  --grid-line: rgba(194, 52, 43, 0.06);
  --border: #E5E3EC;
  --shadow: rgba(40, 30, 90, 0.07);
  --radius: 0.75rem;
  --mono: 'SF Mono', 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;

  /* light code theme — the user finds dark code hard to read */
  --code-bg: #EEF2F5;
  --code-bg-soft: #E1E7EC;
  --code-border: #D3DAE0;
  --code-fg: #1F2533;
  --code-cm: #7A8590;
  --code-kw: #9C2D6E;
  --code-ty: #2D6E78;
  --code-fn: #2F5FA3;
  --code-op: #B5552A;
  --code-st: #3B7A4B;
}

/* === RESET === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === LAYOUT === */
.container { max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }
.wide { max-width: 1040px; }

/* === HEADER === */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, box-shadow 0.3s;
}
header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px var(--shadow);
}
header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; max-width: 1040px;
}
.wordmark {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.95rem; color: var(--text);
}
.wordmark:hover { text-decoration: none; }
.wordmark .mk {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.85rem;
}
.wordmark span { opacity: 0.5; font-weight: 400; }
header nav { display: flex; gap: 1.2rem; }
header nav a {
  font-size: 0.85rem; color: var(--text-muted);
  transition: color 0.2s;
}
header nav a:hover { color: var(--accent); text-decoration: none; }
/* scroll progress */
.progress {
  position: absolute; left: 0; bottom: -1px; height: 2px;
  background: var(--accent); width: 0%;
  transition: width 0.1s linear;
}

/* === CHAPTER STRIP === */
.ch-strip {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.ch-strip::-webkit-scrollbar { display: none; }
.ch-strip .container {
  display: flex; align-items: center; gap: 0.4rem;
  padding-top: 0.55rem; padding-bottom: 0.55rem;
  max-width: 1040px;
}
.ch-pill {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.78rem; color: var(--text-muted);
  padding: 0.32rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-card);
  transition: all 0.15s ease-out;
  text-decoration: none;
  white-space: nowrap;
}
.ch-pill:hover { color: var(--accent-dark); border-color: var(--accent); text-decoration: none; }
.ch-pill .ch-num {
  font-family: var(--mono); font-weight: 700; font-size: 0.7rem;
  color: var(--accent);
}
.ch-pill .ch-name { font-weight: 500; }
.ch-pill.current {
  background: var(--accent); color: #fff;
  border-color: var(--accent);
}
.ch-pill.current .ch-num { color: rgba(255,255,255,0.75); }
.ch-pill.current:hover { color: #fff; background: var(--accent-dark); border-color: var(--accent-dark); }
.ch-divider {
  width: 12px; height: 1px; background: var(--border); flex-shrink: 0;
}
@media (max-width: 767px) {
  .ch-pill .ch-name { display: none; }
  .ch-pill { padding: 0.28rem 0.5rem; }
  .ch-divider { width: 6px; }
}

/* === HERO === */
.hero {
  padding: 4.5rem 0 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
}
.hero::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 80px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--accent-dark);
  background: var(--accent-light);
  padding: 0.35rem 0.8rem; border-radius: 999px;
  margin-bottom: 1.25rem;
  animation: fadeUp 0.6s ease-out both;
}
.hero-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 3rem; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.1;
  margin-bottom: 0.85rem;
  animation: fadeUp 0.6s ease-out 0.08s both;
}
.hero-title em { font-style: italic; color: var(--accent); }
.hero-subtitle {
  font-size: 1.15rem; color: var(--text-muted);
  max-width: 560px; margin: 0 auto 2rem;
  animation: fadeUp 0.6s ease-out 0.16s both;
}
.hero-arrows { animation: fadeUp 0.6s ease-out 0.28s both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* === SECTIONS === */
section.lesson { padding: 1rem 0; }
.block { margin: 2.75rem 0; }
h2.sec {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
  scroll-margin-top: 72px;
}
h2.sec .num {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
  color: var(--accent); margin-right: 0.5rem;
  vertical-align: 0.12em;
}
h3.sub { font-size: 1.1rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }
p.lead { font-size: 1.05rem; color: var(--text-muted); margin-bottom: 1rem; }
.prose p { margin-bottom: 0.9rem; }
.prose ul { margin: 0.4rem 0 1rem 1.3rem; }
.prose li { margin-bottom: 0.35rem; }

/* inline math-ish */
.m {
  font-family: var(--mono); font-size: 0.92em;
  background: var(--bg-sunken);
  padding: 0.08em 0.38em; border-radius: 4px;
  white-space: nowrap;
}
.m.obj { color: var(--accent-secondary); background: var(--accent-secondary-light); }
.m.mor { color: var(--accent-dark); background: var(--accent-light); }

/* === CALLOUT === */
.callout {
  display: flex; gap: 0.85rem;
  background: var(--accent-light);
  border: 1px solid #eccac6;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}
.callout .ic { font-size: 1.2rem; flex-shrink: 0; line-height: 1.5; }
.callout.warn { background: var(--warn-light); border-color: #f3dcb6; border-left-color: var(--warn); }
.callout strong { color: var(--accent-dark); }
.callout.warn strong { color: var(--warn); }

/* === FIGURE / WIDGET === */
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px var(--shadow);
}
.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.widget-title {
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 0.45rem;
}
.widget-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.hint { font-size: 0.8rem; color: var(--text-muted); }

svg.diagram { width: 100%; height: auto; display: block; touch-action: none; user-select: none; }
.diagram-wrap { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.5rem; }

/* === BUTTONS / CONTROLS === */
.controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; align-items: center; }
.btn {
  font: inherit; font-size: 0.85rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.readout {
  font-family: var(--mono); font-size: 0.85rem;
  color: var(--text-muted); margin-left: auto;
}
select.pick {
  font: inherit; font-family: var(--mono); font-size: 0.85rem;
  padding: 0.3rem 0.5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  cursor: pointer;
}

/* === CODE / CHEAT-SHEET CARD (LIGHT THEME) === */
.code-card { border: 1px solid var(--code-border); border-radius: var(--radius); overflow: hidden; margin: 1.5rem 0; }
.code-tabs { display: flex; background: var(--code-bg-soft); border-bottom: 1px solid var(--code-border); }
.code-tab {
  font: inherit; font-size: 0.82rem; font-weight: 500;
  font-family: var(--mono);
  color: var(--text-muted); background: transparent; border: none;
  padding: 0.6rem 1.05rem; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.code-tab:hover { color: var(--text); }
.code-tab.active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.code-tab .lang-ic { opacity: 0.9; margin-right: 0.4rem; }
pre.code {
  margin: 0; padding: 1.1rem 1.2rem;
  background: var(--code-bg); color: var(--code-fg);
  font-family: var(--mono); font-size: 0.84rem; line-height: 1.7;
  overflow-x: auto;
}
pre.code .cm { color: var(--code-cm); font-style: italic; } /* comment / plain-English annotation */
pre.code .kw { color: var(--code-kw); }                     /* the action / cue */
pre.code .ty { color: var(--code-ty); }                     /* named thing */
pre.code .fn { color: var(--code-fn); }                     /* named thing */
pre.code .op { color: var(--code-op); }                     /* operator */
pre.code .st { color: var(--code-st); }                     /* literal */
pre.code .hl { color: var(--accent-dark); font-weight: 600; } /* hand-marked highlight */
.code-pane { display: none; }
.code-pane.active { display: block; }

/* === QUIZ === */
.quiz-q { margin-bottom: 1.4rem; }
.quiz-q:last-child { margin-bottom: 0; }
.quiz-q .q { font-weight: 600; margin-bottom: 0.6rem; }
.quiz-q .q .qn {
  font-family: var(--mono); color: var(--accent); font-size: 0.85rem; margin-right: 0.4rem;
}
.opt {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 0.92rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.85rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.12s ease-out;
  display: flex; align-items: center; gap: 0.6rem;
}
.opt:hover:not(.locked) { border-color: var(--accent); background: var(--accent-light); }
.opt .mark { width: 18px; flex-shrink: 0; font-weight: 700; }
.opt.correct { border-color: var(--ok); background: var(--ok-light); color: #1b5e2e; }
.opt.wrong { border-color: var(--err); background: var(--err-light); color: #b91c1c; }
.opt.locked { cursor: default; }
.quiz-fb { font-size: 0.88rem; margin-top: 0.4rem; min-height: 1.2em; color: var(--text-muted); }
.quiz-fb.show.ok { color: var(--ok); }
.quiz-fb.show.no { color: var(--err); }

/* === NEXT / FOOTER === */
.next-card {
  display: flex; align-items: center; gap: 1rem;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light));
  border: 1px solid #eccac6; border-radius: var(--radius);
  padding: 1.25rem 1.4rem; margin: 2.5rem 0 1rem;
}
.next-card .big { font-size: 1.6rem; }
.next-card .t1 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
.next-card .t2 { font-weight: 600; font-size: 1.05rem; }
.next-card .t3 { font-size: 0.88rem; color: var(--text-muted); }
.next-card .lock { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); }
a.next-card { color: inherit; text-decoration: none; transition: transform 0.2s ease-out, box-shadow 0.2s ease-out; }
a.next-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); text-decoration: none; }
.next-card .arrow { margin-left: auto; font-size: 1.4rem; color: var(--accent-dark); transition: transform 0.2s ease-out; }
a.next-card:hover .arrow { transform: translateX(4px); }

footer {
  padding: 2.5rem 0; text-align: center;
  font-size: 0.8rem; color: var(--text-muted);
  border-top: 1px solid var(--border); margin-top: 1rem;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* === RESPONSIVE === */
@media (max-width: 767px) {
  .hero { padding: 3rem 0 2rem; }
  .hero-title { font-size: 2.1rem; }
  .hero-subtitle { font-size: 1rem; }
  h2.sec { font-size: 1.4rem; }
  header nav a:not(.nav-keep) { display: none; }
  .readout { margin-left: 0; width: 100%; }
}

/* ============================================================
   CHAPTER 1 — "The Enemy" — widget-specific rules
   ============================================================ */

/* --- Widget: SR Flashcard Matcher --- */
.sr-match { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.sr-col-head {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.5rem;
}
.sr-card {
  display: block; width: 100%; text-align: left; font: inherit;
  background: var(--accent-light); border: 1px solid #eccac6;
  border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 0.55rem 0.7rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.13s ease-out;
  font-size: 0.86rem; line-height: 1.4;
}
.sr-card:hover:not(.sr-done) { transform: translateX(2px); border-color: var(--accent); }
.sr-card.sr-sel { background: var(--accent); color: #fff; border-color: var(--accent-dark); border-left-color: var(--accent-dark); }
.sr-card.sr-done { opacity: 0.4; cursor: default; background: var(--bg-sunken); border-color: var(--border); border-left-color: var(--ok); }
.sr-card .sr-tag { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; opacity: 0.8; }
.cure-card {
  display: block; width: 100%; text-align: left; font: inherit;
  background: var(--accent-secondary-light); border: 1px solid #c3d1e0;
  border-left: 3px solid var(--accent-secondary);
  border-radius: 8px; padding: 0.55rem 0.7rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.13s ease-out;
  font-size: 0.86rem; line-height: 1.4;
}
.cure-card:hover:not(.sr-done) { transform: translateX(-2px); border-color: var(--accent-secondary); }
.cure-card.sr-sel { background: var(--accent-secondary); color: #fff; border-color: #2c425b; }
.cure-card.sr-done { opacity: 0.4; cursor: default; background: var(--bg-sunken); border-color: var(--border); border-left-color: var(--ok); }
.cure-card .cure-ch { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; color: var(--accent-secondary); }
.cure-card.sr-sel .cure-ch { color: rgba(255,255,255,0.85); }
.sr-flash-bad { animation: srShake 0.32s ease-out; }
@keyframes srShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
@media (max-width: 600px) { .sr-match { grid-template-columns: 1fr; } }

/* --- Widget: Flinch Timeline (SVG side-view bike) --- */
.flinch-stage .diagram-wrap { padding: 0.75rem; }
.flinch-scrub { width: 100%; margin: 0.4rem 0; accent-color: var(--accent); }
.flinch-phase {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 600;
  color: var(--accent-dark);
}

/* --- Widget: Enemy Map (track TOC) --- */
.emap-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.55rem;
}
.emap-cell {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); padding: 0.55rem 0.65rem;
  cursor: default; transition: all 0.14s ease-out;
}
.emap-cell:hover { border-color: var(--accent); box-shadow: 0 3px 10px var(--shadow); transform: translateY(-2px); }
.emap-cell.emap-lit { border-color: var(--accent); background: var(--accent-light); }
.emap-cell .emap-num { font-family: var(--mono); font-weight: 700; font-size: 0.72rem; color: var(--accent); }
.emap-cell .emap-name { font-weight: 600; font-size: 0.82rem; line-height: 1.25; margin: 0.1rem 0; }
.emap-cell .emap-sr { font-size: 0.72rem; color: var(--text-muted); line-height: 1.3; }
.emap-cell.emap-lit .emap-sr { color: var(--accent-dark); }
.emap-readout {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.88rem; min-height: 2.6em; line-height: 1.45;
}
.emap-readout strong { color: var(--accent-dark); }


/* ===== Chapter 2 widget rules (merged from parts/ch02.css) ===== */
/* ============================================================
   CHAPTER 2 — "The $10 of Attention" — widget-specific rules
   All classes prefixed .ch2- to avoid collisions.
   ============================================================ */

/* --- Widget 1: Attention Budget Meter --- */
.ch2-budget { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.1rem; align-items: start; }
.ch2-stressors { display: flex; flex-direction: column; gap: 0.45rem; }
.ch2-stress {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  width: 100%; text-align: left; font: inherit; font-size: 0.86rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 8px; padding: 0.5rem 0.7rem;
  cursor: pointer; transition: all 0.13s ease-out;
}
.ch2-stress:hover { border-color: var(--accent); }
.ch2-stress.on {
  background: var(--accent-light); border-color: var(--accent);
  border-left-color: var(--accent); color: var(--accent-dark);
}
.ch2-stress .ch2-stress-label { display: flex; align-items: center; gap: 0.5rem; }
.ch2-stress .ch2-stress-ic { font-size: 1.05rem; }
.ch2-stress .ch2-cost {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 700;
  color: var(--text-muted); flex-shrink: 0;
}
.ch2-stress.on .ch2-cost { color: var(--accent-dark); }

.ch2-gauge-wrap { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.85rem; text-align: center; }
.ch2-gauge-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.5rem; }
.ch2-wallet {
  font-family: 'Fraunces', Georgia, serif; font-size: 2.4rem; font-weight: 600;
  line-height: 1; color: var(--ok); transition: color 0.25s;
}
.ch2-wallet.low { color: var(--warn); }
.ch2-wallet.broke { color: var(--err); }
.ch2-meter-track {
  height: 22px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; margin: 0.7rem 0 0.3rem;
}
.ch2-meter-fill {
  height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--ok), #57a06b);
  transition: width 0.35s ease-out, background 0.35s;
}
.ch2-meter-fill.low { background: linear-gradient(90deg, var(--warn), #e89542); }
.ch2-meter-fill.broke { background: linear-gradient(90deg, var(--err), #ef5350); }
.ch2-spent { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); }
.ch2-flinch {
  margin-top: 0.7rem; padding: 0.65rem 0.75rem; border-radius: 8px;
  background: var(--err-light); border: 1px solid #f3c9c9;
  border-left: 3px solid var(--err); color: #b91c1c;
  font-size: 0.85rem; font-weight: 600; line-height: 1.4;
  display: none;
}
.ch2-flinch.show { display: block; animation: ch2Buzz 0.4s ease-out; }
@keyframes ch2Buzz {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  60% { transform: translateX(4px); }
}
@media (max-width: 600px) { .ch2-budget { grid-template-columns: 1fr; } }

/* --- Widget 2: Skill Cost Over Time --- */
.ch2-drill-row { display: flex; flex-direction: column; gap: 0.55rem; }
.ch2-bar-block { background: var(--bg-sunken); border-radius: 0.5rem; padding: 0.7rem 0.85rem; }
.ch2-bar-head {
  display: flex; align-items: baseline; justify-content: space-between;
  font-size: 0.8rem; font-weight: 600; margin-bottom: 0.4rem;
}
.ch2-bar-head .ch2-bar-val { font-family: var(--mono); font-weight: 700; }
.ch2-bar-track { height: 18px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.ch2-bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease-out; }
.ch2-bar-fill.cost { background: linear-gradient(90deg, var(--accent), var(--accent-dark)); }
.ch2-bar-fill.free { background: linear-gradient(90deg, var(--accent-secondary), #2c425b); }
.ch2-bar-block.cost .ch2-bar-val { color: var(--accent-dark); }
.ch2-bar-block.free .ch2-bar-val { color: var(--accent-secondary); }
.ch2-reps { font-family: var(--mono); font-size: 0.82rem; color: var(--text-muted); }
.ch2-drill-note {
  margin-top: 0.6rem; padding: 0.6rem 0.75rem; background: var(--ok-light);
  border-radius: 8px; border-left: 3px solid var(--ok);
  font-size: 0.85rem; color: #1b5e2e; min-height: 1.2em; line-height: 1.4;
}

/* --- Widget 3: Spend-it-right Allocator --- */
.ch2-alloc-row {
  display: grid; grid-template-columns: 120px 1fr 56px; align-items: center;
  gap: 0.7rem; margin-bottom: 0.6rem;
}
.ch2-alloc-label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.86rem; font-weight: 500; }
.ch2-alloc-label .ch2-alloc-ic { font-size: 1.05rem; }
.ch2-alloc-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.ch2-alloc-val { font-family: var(--mono); font-size: 0.82rem; font-weight: 700; color: var(--accent-dark); text-align: right; }
.ch2-alloc-total {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  margin-top: 0.5rem; padding: 0.6rem 0.8rem; background: var(--bg-sunken);
  border-radius: 8px; font-size: 0.85rem;
}
.ch2-alloc-total .ch2-total-num { font-family: var(--mono); font-weight: 700; font-size: 1rem; }
.ch2-alloc-total.over .ch2-total-num { color: var(--err); }
.ch2-alloc-total.ok .ch2-total-num { color: var(--ok); }
.ch2-verdict {
  margin-top: 0.7rem; padding: 0.7rem 0.85rem; border-radius: 8px;
  font-size: 0.88rem; line-height: 1.45; min-height: 2.6em;
  background: var(--bg-sunken); border-left: 3px solid var(--border);
  transition: all 0.2s;
}
.ch2-verdict.good { background: var(--ok-light); border-left-color: var(--ok); color: #1b5e2e; }
.ch2-verdict.bad { background: var(--err-light); border-left-color: var(--err); color: #b91c1c; }
.ch2-verdict.over { background: var(--warn-light); border-left-color: var(--warn); color: var(--warn); }
.ch2-verdict strong { font-weight: 700; }
@media (max-width: 600px) {
  .ch2-alloc-row { grid-template-columns: 96px 1fr 44px; gap: 0.5rem; }
}


/* ===== Chapter 3 widget rules (merged from parts/ch03.css) ===== */
/* ============================================================
   CHAPTER 3 — "Throttle Rule #1" — widget-specific rules
   Linked AFTER style.css. All classes prefixed .ch3-
   ============================================================ */

/* --- Widget 1: Roll-on vs Chop simulator --- */
.ch3-sim .diagram-wrap { padding: 0.75rem; }
.ch3-sim-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; align-items: center; }
.ch3-throttle-wrap {
  display: flex; align-items: center; gap: 0.6rem;
  flex: 1 1 240px; min-width: 200px;
}
.ch3-throttle-wrap label {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 600;
  color: var(--text-muted); white-space: nowrap;
}
.ch3-range { flex: 1; accent-color: var(--accent); min-width: 120px; }
.ch3-state {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 600;
  color: var(--accent-dark);
}
.ch3-state.ch3-bad { color: var(--err); }
.ch3-state.ch3-good { color: var(--ok); }

/* --- Widget 2: 40/60 weight-balance gauge --- */
.ch3-gauge-bar {
  position: relative;
  height: 46px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  display: flex;
  margin: 0.4rem 0 0.2rem;
}
.ch3-gauge-front, .ch3-gauge-rear {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  color: #fff; transition: width 0.18s ease-out;
  white-space: nowrap; overflow: hidden;
}
.ch3-gauge-front { background: var(--accent); }
.ch3-gauge-rear { background: var(--accent-secondary); }
.ch3-gauge-ideal {
  position: absolute; top: -4px; bottom: -4px; width: 0;
  border-left: 2px dashed var(--text);
  pointer-events: none;
}
.ch3-gauge-ideal::after {
  content: "40 / 60 ideal";
  position: absolute; top: -1.35rem; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 0.68rem; font-weight: 700;
  color: var(--text); white-space: nowrap;
}
.ch3-gauge-legend {
  display: flex; gap: 1.1rem; margin-top: 1.6rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--text-muted);
}
.ch3-gauge-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.ch3-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.ch3-swatch.front { background: var(--accent); }
.ch3-swatch.rear { background: var(--accent-secondary); }
.ch3-gauge-verdict {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.9rem; min-height: 2.6em; line-height: 1.45;
}
.ch3-gauge-verdict strong { color: var(--accent-dark); }
.ch3-gauge-verdict.ch3-ok { background: var(--ok-light); }
.ch3-gauge-verdict.ch3-ok strong { color: var(--ok); }
.ch3-gauge-verdict.ch3-warn { background: var(--warn-light); }
.ch3-gauge-verdict.ch3-warn strong { color: var(--warn); }

/* --- Widget 3: The throttle trace --- */
.ch3-trace .diagram-wrap { padding: 0.75rem; }
.ch3-trace svg .ch3-handle { cursor: grab; }
.ch3-trace svg .ch3-handle:active { cursor: grabbing; }
.ch3-trace-score {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.9rem; min-height: 2.6em; line-height: 1.45;
}
.ch3-trace-score strong { color: var(--accent-dark); }
.ch3-trace-score.ch3-ok { background: var(--ok-light); }
.ch3-trace-score.ch3-ok strong { color: var(--ok); }
.ch3-trace-score.ch3-warn { background: var(--err-light); }
.ch3-trace-score.ch3-warn strong { color: var(--err); }
.ch3-trace-grade {
  font-family: var(--mono); font-weight: 700; font-size: 1rem;
}


/* ===== Chapter 4 widget rules (merged from parts/ch04.css) ===== */
/* ============================================================
   CHAPTER 4 — "The Traction Pie" — widget-specific rules
   All classes prefixed .ch4-  ·  uses tokens from style.css
   ============================================================ */

/* --- Shared status line under widgets --- */
.ch4-status {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted); line-height: 1.4;
}
.ch4-status.ch4-warn { color: var(--warn); }
.ch4-status.ch4-bad  { color: var(--err); }

/* --- Widget 1: Traction Circle --- */
#circSvg { cursor: grab; }

/* --- Widget 2: The Pie Allocator --- */
.ch4-pie-grid {
  display: grid; grid-template-columns: 240px 1fr; gap: 1.1rem; align-items: center;
}
.ch4-sliders { display: flex; flex-direction: column; gap: 1.1rem; }
.ch4-slider { display: block; }
.ch4-slabel {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.86rem; color: var(--text); margin-bottom: 0.35rem;
}
.ch4-slabel b { font-family: var(--mono); margin-left: auto; color: var(--text-muted); }
.ch4-sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.ch4-sw-brake { background: var(--accent); }
.ch4-sw-turn  { background: var(--accent-secondary); }
.ch4-sw-drive { background: var(--warn); }
.ch4-slider input[type="range"] { width: 100%; accent-color: var(--accent); }

/* tint each slider's thumb to match its slice */
#pieTurn  { accent-color: var(--accent-secondary); }
#pieDrive { accent-color: var(--warn); }

@media (max-width: 600px) {
  .ch4-pie-grid { grid-template-columns: 1fr; }
  .ch4-pie-grid .diagram-wrap { max-width: 240px; margin: 0 auto; }
}

/* --- Widget 3: Shrink the Pie --- */
.ch4-toggles {
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem;
}
.ch4-toggle {
  font: inherit; font-size: 0.84rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 999px;
  padding: 0.4rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
}
.ch4-toggle:hover { border-color: var(--accent); color: var(--accent-dark); }
.ch4-toggle.ch4-on {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.ch4-toggle.ch4-on:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }


/* ===== Chapter 5 widget rules (merged from parts/ch05.css) ===== */
/* ============================================================
   CHAPTER 5 — "Push to Turn" — widget-specific rules
   (countersteering & the quick-flick). All surfaces LIGHT.
   ============================================================ */

/* --- Shared small bits --- */
.ch5-stat {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem;
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.86rem;
}
.ch5-stat .ch5-stat-item { display: flex; flex-direction: column; gap: 0.1rem; }
.ch5-stat .ch5-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
}
.ch5-stat .ch5-v {
  font-family: var(--mono); font-weight: 700; font-size: 1rem; color: var(--accent-dark);
}
.ch5-stat .ch5-v.slate { color: var(--accent-secondary); }
.ch5-cue {
  font-family: var(--mono); font-size: 0.78rem; font-weight: 600;
  color: var(--accent-dark);
}

/* --- Widget 1: Countersteering simulator --- */
.ch5-cs-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.ch5-pushrow { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.ch5-pushrow label {
  font-size: 0.8rem; color: var(--text-muted); font-weight: 600;
}
.ch5-slider { width: 100%; max-width: 320px; accent-color: var(--accent); }
.ch5-cs-legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.6rem;
  font-size: 0.78rem; color: var(--text-muted);
}
.ch5-cs-legend .sw {
  display: inline-block; width: 14px; height: 4px; border-radius: 2px;
  vertical-align: middle; margin-right: 0.35rem;
}
.ch5-cs-legend .sw.force { background: var(--accent); }
.ch5-cs-legend .sw.lean  { background: var(--accent-secondary); }
.ch5-cs-legend .sw.path  { background: var(--warn); }

/* --- Widget 2: Quick-flick vs Lazy-turn --- */
.ch5-flick-tags { display: flex; gap: 0.4rem 1rem; flex-wrap: wrap; margin-bottom: 0.4rem; font-size: 0.78rem; }
.ch5-tag { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.ch5-tag .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.ch5-tag.flick { color: var(--accent-dark); }
.ch5-tag.flick .sw { background: var(--accent); }
.ch5-tag.lazy  { color: var(--accent-secondary); }
.ch5-tag.lazy  .sw { background: var(--accent-secondary); }
.ch5-rate-label {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; color: var(--text-muted); font-weight: 600;
  max-width: 320px;
}
.ch5-cmp {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 0.85rem;
}
.ch5-cmp .ch5-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.75rem; background: var(--bg-card);
}
.ch5-cmp .ch5-card.flick { border-left: 3px solid var(--accent); }
.ch5-cmp .ch5-card.lazy  { border-left: 3px solid var(--accent-secondary); }
.ch5-cmp .ch5-card h4 {
  font-size: 0.74rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.4rem;
}
.ch5-cmp .ch5-card.flick h4 { color: var(--accent-dark); }
.ch5-cmp .ch5-card.lazy  h4 { color: var(--accent-secondary); }
.ch5-cmp .ch5-row {
  display: flex; justify-content: space-between; gap: 0.5rem;
  font-size: 0.82rem; padding: 0.12rem 0;
}
.ch5-cmp .ch5-row .v { font-family: var(--mono); font-weight: 700; }
@media (max-width: 600px) { .ch5-cmp { grid-template-columns: 1fr; } }

/* --- Widget 3: Hunting vs one clean input --- */
.ch5-hunt-toggle { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.ch5-hunt-note {
  margin-top: 0.7rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.88rem; line-height: 1.45; min-height: 2.6em;
}
.ch5-hunt-note strong { color: var(--accent-dark); }
.ch5-hunt-note.tense { background: var(--warn-light); }
.ch5-hunt-note.tense strong { color: var(--warn); }


/* ===== Chapter 6 widget rules (merged from parts/ch06.css) ===== */
/* ============================================================
   CHAPTER 6 — "Loose on the Bars" — widget-specific rules
   All classes prefixed .ch6- to avoid collisions.
   ============================================================ */

/* --- Widget 1: Grip-pressure -> Wobble Meter --- */
.ch6-grip-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.ch6-grip-row {
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
}
.ch6-grip-row label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  min-width: 5.5rem;
}
.ch6-slider {
  flex: 1; min-width: 160px; accent-color: var(--accent);
}
.ch6-grip-state {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 700;
  padding: 0.18rem 0.6rem; border-radius: 999px;
  background: var(--ok-light); color: #1b5e2e;
  transition: background 0.2s, color 0.2s;
}
.ch6-grip-state.warn { background: var(--warn-light); color: var(--warn); }
.ch6-grip-state.bad  { background: var(--err-light); color: #b91c1c; }
.ch6-verdict {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.88rem; line-height: 1.45; min-height: 2.6em;
}
.ch6-verdict strong { color: var(--accent-dark); }
.ch6-verdict.bad strong { color: #b91c1c; }

/* --- Widget 2: Self-stabilizing bike --- */
.ch6-stab-readout {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  margin-top: 0.6rem; font-family: var(--mono); font-size: 0.8rem;
  color: var(--text-muted);
}
.ch6-stab-readout b { color: var(--accent-dark); font-weight: 700; }
.ch6-arms-toggle.active { background: var(--err-light); border-color: var(--err); color: #b91c1c; }

/* --- Widget 3: Unwanted-input spotter --- */
.ch6-spot-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem;
}
.ch6-spot-timeline {
  position: relative; height: 30px; margin: 0.6rem 0 0.2rem;
  background: var(--bg-sunken); border-radius: 999px; overflow: hidden;
}
.ch6-spot-fill {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0%;
  background: var(--accent-secondary-light);
  border-right: 2px solid var(--accent-secondary);
}
.ch6-spot-tick {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-muted); background: var(--bg-card);
  z-index: 2;
}
.ch6-spot-tick.hit  { border-color: var(--ok); background: var(--ok); }
.ch6-spot-tick.miss { border-color: var(--err); background: var(--err); }
.ch6-spot-fb {
  margin-top: 0.7rem; padding: 0.6rem 0.8rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.86rem; line-height: 1.4; min-height: 2.4em;
}
.ch6-spot-fb strong { color: var(--accent-dark); }
.ch6-spot-fb.ok strong { color: var(--ok); }
.ch6-spot-fb.no strong { color: var(--err); }
.ch6-spot-log { margin: 0.5rem 0 0; font-size: 0.82rem; }
.ch6-spot-log li { margin-bottom: 0.2rem; color: var(--text-muted); }
.ch6-spot-log li.good { color: var(--ok); }
.ch6-spot-log li.bad { color: var(--err); }

@media (max-width: 600px) {
  .ch6-grip-row label { min-width: 0; }
  .ch6-stab-readout { gap: 0.7rem; }
}


/* ===== Chapter 7 widget rules (merged from parts/ch07.css) ===== */
/* ============================================================
   CHAPTER 7 — "Reference Points" — widget-specific rules
   All classes prefixed .ch7-  ·  uses tokens from style.css
   ============================================================ */

/* --- shared widget bits --- */
.ch7-panel {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}
.ch7-stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-sunken);
  padding: 0.55rem 0.7rem;
  transition: background 0.15s ease-out, border-color 0.15s ease-out;
}
.ch7-stat .ch7-stat-k {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
  margin-bottom: 0.12rem;
}
.ch7-stat .ch7-stat-v {
  font-family: var(--mono); font-size: 0.92rem; font-weight: 600;
  color: var(--text);
}
.ch7-stat.ch7-changed {
  background: var(--accent-light);
  border-color: var(--accent);
}
.ch7-stat.ch7-changed .ch7-stat-v { color: var(--accent-dark); }

/* --- Widget 1: Reference-point corner builder --- */
.ch7-build-readout {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.9rem; line-height: 1.45; min-height: 2.6em;
}
.ch7-build-readout.ok    { background: var(--ok-light); }
.ch7-build-readout.warn2 { background: var(--warn-light); }
.ch7-build-readout strong { color: var(--accent-dark); }
.ch7-build-readout.ok strong   { color: var(--ok); }
.ch7-build-readout.warn2 strong { color: var(--warn); }
.ch7-grip {
  cursor: grab;
}
.ch7-grip:active { cursor: grabbing; }
.ch7-grip-label {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  pointer-events: none;
}

/* --- Widget 2: turn point sets eleven variables --- */
.ch7-tp-wrap { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 720px) { .ch7-tp-wrap { grid-template-columns: 1fr; } }
.ch7-vars {
  display: grid; gap: 0.4rem;
}
.ch7-var {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg-card); padding: 0.4rem 0.6rem;
  font-size: 0.84rem;
  transition: background 0.18s ease-out, border-color 0.18s ease-out;
}
.ch7-var .ch7-var-k { color: var(--text-muted); }
.ch7-var .ch7-var-v {
  font-family: var(--mono); font-weight: 600; color: var(--text);
  white-space: nowrap;
}
.ch7-var.ch7-pulse {
  background: var(--accent-light);
  border-color: var(--accent);
}
.ch7-var.ch7-pulse .ch7-var-v { color: var(--accent-dark); }

/* --- Widget 3: consistency laps --- */
.ch7-lap-readout {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.9rem; line-height: 1.45;
}
.ch7-lap-readout strong { color: var(--accent-dark); }
.ch7-spread {
  font-family: var(--mono); font-weight: 700;
}
.ch7-spread.tight { color: var(--ok); }
.ch7-spread.wide  { color: var(--warn); }


/* ===== Chapter 8 widget rules (merged from parts/ch08.css) ===== */
/* ============================================================
   CHAPTER 8 — "Where You Look" — widget-specific rules
   All classes prefixed .ch8-  ·  uses tokens from style.css
   ============================================================ */

/* --- shared scrub slider (Two-Step, Wide-vs-Tunnel) --- */
.ch8-scrub {
  width: 100%;
  margin: 0.55rem 0 0.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- shared phase / status line under a widget --- */
.ch8-phase {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-dark);
  line-height: 1.4;
}

/* --- Target fixation demo: tighten the diagram padding --- */
#tfSvg, #tsSvg, #wvSvg { background: transparent; }

/* mode buttons read as a toggle pair; .active comes from style.css .btn.active */
#tfHazard.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-dark); }
#tfClean.active  { background: var(--ok-light); border-color: var(--ok); color: #1b5e2e; }

/* --- readout colour cues --- */
#tfVerdict { line-height: 1.4; }

/* Two-Step toggle: when active (rushed), warn-tint it */
#tsToggle.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-dark);
}

/* clue counter for the wide-vs-tunnel widget */
#wvCount { font-weight: 600; }

/* Keep diagrams comfortable on small screens */
@media (max-width: 600px) {
  .ch8-phase { font-size: 0.76rem; }
}


/* ===== Chapter 9 widget rules (merged from parts/ch09.css) ===== */
/* ============================================================
   CHAPTER 9 — "The Line" — widget-specific rules
   All classes prefixed .ch9-  ·  light surfaces only
   ============================================================ */

/* --- Scrub slider (matches family) --- */
.ch9-scrub {
  width: 100%;
  margin: 0.55rem 0 0.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* --- Shared phase / status line under a widget --- */
.ch9-phase {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* --- Shared widget bits --- */
.ch9-legend {
  display: flex; flex-wrap: wrap; gap: 0.8rem 1.1rem;
  margin-top: 0.7rem; font-size: 0.8rem; color: var(--text-muted);
}
.ch9-legend .ch9-key { display: inline-flex; align-items: center; gap: 0.4rem; }
.ch9-legend .ch9-swatch {
  width: 16px; height: 4px; border-radius: 2px; display: inline-block;
}
.ch9-legend .ch9-dot {
  width: 11px; height: 11px; border-radius: 50%; display: inline-block;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
}

/* --- Verdict banner (Rule #1 satisfied / broken) --- */
.ch9-verdict {
  margin-top: 0.85rem; padding: 0.7rem 0.9rem;
  border-radius: 8px; font-size: 0.9rem; line-height: 1.45;
  border: 1px solid var(--border); background: var(--bg-sunken);
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.ch9-verdict strong { font-weight: 700; }
.ch9-verdict.ch9-ok {
  background: var(--ok-light); border-color: #bfe2cb; color: #1b5e2e;
}
.ch9-verdict.ch9-ok strong { color: #1b5e2e; }
.ch9-verdict.ch9-bad {
  background: var(--warn-light); border-color: #f3dcb6; color: var(--warn);
}
.ch9-verdict.ch9-bad strong { color: var(--warn); }

/* --- Drag handles in the line visualizer --- */
.ch9-handle { cursor: grab; }
.ch9-handle:active { cursor: grabbing; }
.ch9-grab-hint {
  margin-top: 0.5rem; font-size: 0.78rem; color: var(--text-muted);
  font-style: italic;
}

/* --- Toggle / pick rows --- */
.ch9-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
  margin-top: 0.85rem;
}
.ch9-row .ch9-spacer { flex: 1; }

/* --- Corner-type gallery: chip cluster --- */
.ch9-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ch9-chip {
  font: inherit; font-size: 0.82rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 999px;
  padding: 0.4rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.ch9-chip:hover { border-color: var(--accent); color: var(--accent-dark); }
.ch9-chip.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.ch9-chip.active:hover { background: var(--accent-dark); color: #fff; }
.ch9-chip .ch9-chip-ic { font-size: 0.95rem; }

/* --- Type description panel --- */
.ch9-typecard {
  margin-top: 0.85rem; padding: 0.8rem 0.95rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.9rem; line-height: 1.5; min-height: 3.2em;
}
.ch9-typecard strong { color: var(--accent-dark); }
.ch9-typecard .ch9-ask {
  display: block; margin-top: 0.35rem;
  font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted);
}
.ch9-typecard .ch9-ask b { color: var(--accent-secondary); font-weight: 700; }

/* --- Animated dash on the racing line (respect reduced motion) --- */
.ch9-line-anim { stroke-dasharray: 7 7; animation: ch9-flow 1.1s linear infinite; }
@keyframes ch9-flow { to { stroke-dashoffset: -14; } }
@media (prefers-reduced-motion: reduce) {
  .ch9-line-anim { animation: none; }
}

/* --- Small note under a widget --- */
.ch9-note {
  margin-top: 0.6rem; font-size: 0.82rem; color: var(--text-muted);
  line-height: 1.45;
}
.ch9-note b { color: var(--accent-dark); }

@media (max-width: 600px) {
  .ch9-phase { font-size: 0.76rem; }
}


/* ===== Chapter 10 widget rules (merged from parts/ch10.css) ===== */
/* ============================================================
   CHAPTER 10 — "Hanging Off" — widget-specific rules
   All classes prefixed .ch10-  ·  no edits to style.css
   ============================================================ */

/* shared little stat chips used across widgets */
.ch10-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}
.ch10-stat {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.ch10-stat .ch10-stat-label {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-muted);
}
.ch10-stat .ch10-stat-val {
  font-family: var(--mono); font-weight: 700; font-size: 1.15rem;
  color: var(--accent-dark); line-height: 1.3;
}
.ch10-stat.ch10-good .ch10-stat-val { color: var(--ok); }
.ch10-stat .ch10-stat-sub { font-size: 0.72rem; color: var(--text-muted); }

/* range sliders, themed */
.ch10-range {
  width: 100%; margin: 0.5rem 0 0.2rem;
  accent-color: var(--accent); cursor: pointer;
}
.ch10-range-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; flex-wrap: wrap;
}
.ch10-range-row .ch10-range-name {
  font-size: 0.82rem; font-weight: 600; color: var(--text);
}
.ch10-range-row .ch10-range-read {
  font-family: var(--mono); font-size: 0.82rem; color: var(--accent-dark);
  font-weight: 700;
}

/* --- Widget 1: Lean-angle saver --- */
.ch10-lean-grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1rem;
  align-items: center;
}
@media (max-width: 600px) { .ch10-lean-grid { grid-template-columns: 1fr; } }

/* --- Widget 2: Pivot-steer body diagram --- */
.ch10-pivot-grid {
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 1rem;
  align-items: center;
}
@media (max-width: 600px) { .ch10-pivot-grid { grid-template-columns: 1fr; } }
.ch10-toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.ch10-note {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.88rem; line-height: 1.45; min-height: 2.6em;
}
.ch10-note strong { color: var(--accent-dark); }
.ch10-note.ch10-ok { background: var(--ok-light); }
.ch10-note.ch10-ok strong { color: var(--ok); }

/* --- Widget 3: The hook turn --- */
.ch10-hook-grid {
  display: grid; grid-template-columns: 1fr; gap: 0.6rem;
}
.ch10-legend {
  display: flex; flex-wrap: wrap; gap: 0.9rem;
  margin-top: 0.6rem; font-size: 0.78rem; color: var(--text-muted);
}
.ch10-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.ch10-swatch { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.ch10-swatch.ch10-sw-base { background: #3F5C7A; }
.ch10-swatch.ch10-sw-hook { background: var(--accent); }
.ch10-swatch.ch10-sw-bar  { background: var(--warn); }


/* ===== Chapter 11 widget rules (merged from parts/ch11.css) ===== */
/* ============================================================
   CHAPTER 11 — "Braking & Trail Braking" — widget-specific rules
   All classes prefixed .ch11-  ·  uses tokens from style.css
   ============================================================ */

/* --- Shared status line under widgets --- */
.ch11-status {
  font-family: var(--mono); font-size: 0.82rem; font-weight: 600;
  color: var(--text-muted); line-height: 1.4;
}
.ch11-status.ch11-warn { color: var(--warn); }
.ch11-status.ch11-bad  { color: var(--err); }

/* --- A small two-up readout grid used in a couple of widgets --- */
.ch11-metrics {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem;
  margin-top: 0.6rem;
}
.ch11-metric {
  font-size: 0.82rem; color: var(--text-muted);
}
.ch11-metric b {
  font-family: var(--mono); color: var(--text); margin-left: 0.35rem;
}

/* --- Widget 1: Brake-pressure curve (drawable) --- */
.ch11-curve-grid {
  display: grid; grid-template-columns: 1fr; gap: 0.75rem;
}
#brakeCurveSvg { cursor: crosshair; touch-action: none; }
.ch11-presets { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ch11-preset {
  font: inherit; font-size: 0.84rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 999px;
  padding: 0.4rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
}
.ch11-preset:hover { border-color: var(--accent); color: var(--accent-dark); }
.ch11-preset.ch11-on {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.ch11-preset.ch11-on:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.ch11-legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  font-size: 0.78rem; color: var(--text-muted);
  margin-top: 0.2rem;
}
.ch11-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.ch11-sw { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.ch11-sw-brake { background: var(--accent); }
.ch11-sw-turn  { background: var(--accent-secondary); }
.ch11-sw-limit { background: var(--warn); }

/* --- Widget 2: Trail-brake vs brake-early comparator --- */
.ch11-cmp-toggles { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ch11-cmp-toggle {
  font: inherit; font-size: 0.84rem; font-weight: 500;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); border-radius: 8px;
  padding: 0.45rem 0.85rem; cursor: pointer;
  transition: all 0.15s ease-out;
  display: inline-flex; align-items: center; gap: 0.45rem;
}
.ch11-cmp-toggle:hover { border-color: var(--accent); color: var(--accent-dark); }
.ch11-cmp-toggle .ch11-tag {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid transparent;
}
.ch11-cmp-toggle.ch11-on { border-color: var(--text); background: var(--bg-sunken); }
.ch11-tag-code { background: var(--accent-secondary); }
.ch11-tag-ien  { background: var(--accent); }
.ch11-cmp-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 0.85rem; }
.ch11-cmp-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.7rem 0.8rem; background: var(--bg-sunken);
  font-size: 0.84rem; line-height: 1.45;
}
.ch11-cmp-card h4 {
  font-size: 0.84rem; margin-bottom: 0.3rem;
  display: flex; align-items: center; gap: 0.45rem;
}
.ch11-cmp-card .ch11-tag { width: 11px; height: 11px; border-radius: 50%; }
.ch11-cmp-card.ch11-code { border-left: 3px solid var(--accent-secondary); }
.ch11-cmp-card.ch11-ien  { border-left: 3px solid var(--accent); }
.ch11-cmp-card b { font-family: var(--mono); color: var(--text); }
@media (max-width: 600px) { .ch11-cmp-cards { grid-template-columns: 1fr; } }

/* --- Widget 3: Washout warning (grip circle) --- */
.ch11-wash-grid {
  display: grid; grid-template-columns: 1fr; gap: 0.75rem;
}
.ch11-sliders { display: flex; flex-direction: column; gap: 0.9rem; }
.ch11-slider { display: block; }
.ch11-slabel {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.86rem; color: var(--text); margin-bottom: 0.3rem;
}
.ch11-slabel b { font-family: var(--mono); margin-left: auto; color: var(--text-muted); }
.ch11-slider input[type="range"] { width: 100%; accent-color: var(--accent); }
#washLean  { accent-color: var(--accent-secondary); }
#washBrake { accent-color: var(--accent); }
@media (min-width: 700px) {
  .ch11-wash-grid { grid-template-columns: 280px 1fr; align-items: center; }
  .ch11-wash-grid .diagram-wrap { order: -1; }
}


/* ===== Chapter 12 widget rules (merged from parts/ch12.css) ===== */
/* ============================================================
   CHAPTER 12 — "Putting It Together" — widget-specific rules
   ============================================================ */

/* --- NEXT-CARD · FINALE variant --- */
.next-card.finale { background: linear-gradient(135deg, var(--accent-light), var(--accent-secondary-light)); }
.next-card.finale .big { font-size: 2.2rem; }
.next-card.finale .t2 { font-family: 'Fraunces', Georgia, serif; font-size: 1.35rem; }

/* --- Widget 1 · The clean-corner replay --- */
.ch12-scrub { width: 100%; margin: 0.5rem 0 0.3rem; accent-color: var(--accent); }
.ch12-phase-row {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin: 0.4rem 0;
}
.ch12-chip {
  font: inherit; cursor: pointer;
  display: inline-flex; flex-direction: column; align-items: flex-start;
  gap: 0.05rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.35rem 0.6rem;
  transition: all 0.14s ease-out;
  flex: 1 1 auto;
}
.ch12-chip:hover { border-color: var(--accent); }
.ch12-chip.active { background: var(--accent-light); border-color: var(--accent); }
.ch12-chip-skill { font-size: 0.76rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.ch12-chip.active .ch12-chip-skill { color: var(--accent-dark); }
.ch12-chip-ch { font-family: var(--mono); font-size: 0.66rem; font-weight: 700; color: var(--accent); }
.ch12-phase {
  font-size: 0.86rem; color: var(--text-muted); line-height: 1.4;
  flex: 1 1 240px;
}
.ch12-phase strong { color: var(--accent-dark); }

/* --- Widget 2 · SR -> Skill -> Chapter recap matrix --- */
.ch12-mtx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ch12-col-head {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.5rem;
}
.ch12-mtx-card {
  display: block; width: 100%; text-align: left; font: inherit;
  background: var(--accent-light); border: 1px solid #eccac6;
  border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 0.55rem 0.7rem; margin-bottom: 0.5rem;
  cursor: pointer; transition: all 0.13s ease-out;
  font-size: 0.86rem; line-height: 1.4;
}
.ch12-mtx-card:hover { transform: translateX(2px); border-color: var(--accent); }
.ch12-mtx-card.active { background: var(--accent); color: #fff; border-color: var(--accent-dark); border-left-color: var(--accent-dark); }
.ch12-mtx-tag { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; opacity: 0.8; }
.ch12-mtx-detail {
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.85rem 0.95rem;
  min-height: 100%; font-size: 0.88rem;
}
.ch12-mtx-empty { color: var(--text-muted); margin: 0; line-height: 1.5; }
.ch12-mtx-enemy { font-weight: 600; color: var(--accent-dark); margin-bottom: 0.4rem; }
.ch12-mtx-arrow {
  font-family: var(--mono); font-size: 0.74rem; font-weight: 700;
  color: var(--text-muted); margin-bottom: 0.4rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.ch12-mtx-skill { color: var(--text); line-height: 1.5; margin-bottom: 0.7rem; }
.ch12-mtx-jump {
  display: inline-block; font-size: 0.82rem; font-weight: 600;
  color: var(--accent-secondary);
  background: var(--accent-secondary-light); border: 1px solid #c3d1e0;
  border-radius: 8px; padding: 0.4rem 0.7rem;
  transition: all 0.14s ease-out;
}
.ch12-mtx-jump:hover { background: var(--accent-secondary); color: #fff; text-decoration: none; border-color: #2c425b; }
@media (max-width: 600px) { .ch12-mtx-grid { grid-template-columns: 1fr; } }

/* --- Widget 3 · Your reading map (Beyond Code) --- */
.ch12-spine {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--accent-light); border: 1px solid #eccac6;
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 0.7rem 0.95rem;
  margin-bottom: 0.85rem;
}
.ch12-spine-ic { font-size: 1.7rem; flex-shrink: 0; }
.ch12-spine-txt { font-size: 0.92rem; line-height: 1.35; }
.ch12-spine-txt strong { color: var(--accent-dark); }
.ch12-spine-txt span {
  display: block; font-size: 0.74rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin-top: 0.1rem;
}
.ch12-book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.55rem;
}
.ch12-book-card {
  font: inherit; text-align: left; cursor: pointer;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-card); padding: 0.6rem 0.7rem;
  transition: all 0.14s ease-out;
}
.ch12-book-card:hover { border-color: var(--accent); box-shadow: 0 3px 10px var(--shadow); transform: translateY(-2px); }
.ch12-book-card.active { border-color: var(--accent); background: var(--accent-light); }
.ch12-book-ic { font-size: 1.3rem; line-height: 1; margin-bottom: 0.3rem; }
.ch12-book-gap {
  font-family: var(--mono); font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent);
  margin-bottom: 0.2rem;
}
.ch12-book-title { font-weight: 600; font-size: 0.86rem; line-height: 1.25; }
.ch12-book-author { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.1rem; }
.ch12-book-readout {
  margin-top: 0.85rem; padding: 0.7rem 0.85rem;
  background: var(--bg-sunken); border-radius: 8px;
  font-size: 0.88rem; min-height: 2.6em; line-height: 1.45;
}
.ch12-book-readout strong { color: var(--accent-dark); }
