/* ==========================================================================
   GT7 Suspension & Differential Course — design system
   --------------------------------------------------------------------------
   Idea: a setup sheet on the pit wall. Cool paper, navy ink, and ONE
   information-carrying colour code used everywhere:
     FRONT axle = blue   (--front)
     REAR axle  = amber  (--rear)
   Diagrams, tables, tags and the header telemetry trace all use it.
   Fonts: Saira Condensed (display, race-plate numbers) + IBM Plex Sans (body).
   No framework, no build step. Pages work with JS disabled.
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */
:root {
  color-scheme: light;
  --paper: #edf0f3;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #17212c;
  --ink-soft: #2e3b48;
  --muted: #56636f;
  --line: #c9d1d9;
  --line-soft: #dde3e9;

  --front: #1764c4;
  --front-wash: #e3eefb;
  --rear: #b45a00;
  --rear-wash: #fbeedf;

  --gt7: #2c3e7a;
  --gt7-wash: #e8ecf8;
  --rule: #0f7b5f;
  --rule-wash: #e1f3ec;
  --mistake: #b42318;
  --mistake-wash: #fbe9e7;
  --drill: #6b4fa0;
  --drill-wash: #efeaf8;

  --focus: #1764c4;
  --shadow: 0 1px 0 rgba(23, 33, 44, 0.06), 0 6px 18px -12px rgba(23, 33, 44, 0.25);

  --font-display: "Saira Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Type scale (perfect fourth-ish, tuned for long reading) */
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9rem;
  --fs-base: 1.0625rem;
  --fs-md: 1.25rem;
  --fs-lg: 1.6rem;
  --fs-xl: 2.25rem;
  --fs-xxl: clamp(2.4rem, 1.6rem + 3.2vw, 3.6rem);
  --fs-plate: clamp(3.6rem, 2.4rem + 5vw, 6rem);

  --measure: 68ch;
  --gutter: 16px;
  --radius-s: 4px;
  --radius-m: 8px;
  --nav-w: 17rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0e1621;
    --surface: #152030;
    --surface-2: #1a2738;
    --ink: #e2e8ef;
    --ink-soft: #c6d0db;
    --muted: #98a6b5;
    --line: #2a3a4d;
    --line-soft: #223143;

    --front: #6cb2ff;
    --front-wash: #15304f;
    --rear: #ffae4d;
    --rear-wash: #3b2a14;

    --gt7: #9bb0f5;
    --gt7-wash: #1c2648;
    --rule: #4fd1a5;
    --rule-wash: #12332a;
    --mistake: #ff7a6b;
    --mistake-wash: #3a1b19;
    --drill: #c3a8f2;
    --drill-wash: #2a2140;

    --focus: #6cb2ff;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 22px -14px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e1621;
  --surface: #152030;
  --surface-2: #1a2738;
  --ink: #e2e8ef;
  --ink-soft: #c6d0db;
  --muted: #98a6b5;
  --line: #2a3a4d;
  --line-soft: #223143;

  --front: #6cb2ff;
  --front-wash: #15304f;
  --rear: #ffae4d;
  --rear-wash: #3b2a14;

  --gt7: #9bb0f5;
  --gt7-wash: #1c2648;
  --rule: #4fd1a5;
  --rule-wash: #12332a;
  --mistake: #ff7a6b;
  --mistake-wash: #3a1b19;
  --drill: #c3a8f2;
  --drill-wash: #2a2140;

  --focus: #6cb2ff;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 22px -14px rgba(0, 0, 0, 0.7);
}

/* ---------- 2. Base ------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  font-feature-settings: "kern" 1;
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--front); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.005em;
  color: var(--ink);
  text-wrap: balance;
}

h2 { font-size: var(--fs-xl); margin: 3rem 0 1rem; }
h3 { font-size: var(--fs-lg); font-weight: 600; margin: 2.2rem 0 0.6rem; }
h4 { font-size: var(--fs-md); font-weight: 600; margin: 1.6rem 0 0.4rem; }

p, ul, ol { margin: 0 0 1.1rem; }
ul, ol { padding-left: 1.4rem; }
li + li { margin-top: 0.3rem; }
strong { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }

abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.2em; cursor: help; }

.num, td, .tabular { font-variant-numeric: tabular-nums; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--focus);
}
.skip-link:focus { left: 0.5rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- 3. Site header ---------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 0.6rem var(--gutter);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1;
  margin-right: auto;
}
.brand:hover { text-decoration: none; }

/* Brand mark: two stacked trace bars, front + rear */
.brand__mark {
  display: inline-grid;
  gap: 3px;
  width: 26px;
}
.brand__mark::before,
.brand__mark::after {
  content: "";
  height: 5px;
  border-radius: 3px;
}
.brand__mark::before { background: var(--front); width: 100%; }
.brand__mark::after { background: var(--rear); width: 70%; }

.brand__sub {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--muted);
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 500 var(--fs-sm) / 1 var(--font-body);
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle svg { width: 1rem; height: 1rem; }
/* Hidden until JS proves it can work */
.no-js .theme-toggle { display: none; }

/* ---------- 4. Layout: nav rail + main ---------------------------------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 76rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  gap: 0 3rem;
}

@media (min-width: 64rem) {
  .layout { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
}

main {
  min-width: 0;
  max-width: var(--measure);
  padding-bottom: 4rem;
}
@media (min-width: 64rem) {
  main { padding-top: 0.5rem; }
}
/* Wide content (tables, figures, widgets) may break out a little */
.wide { max-width: min(54rem, 100%); }

/* ---------- 5. Course nav (lesson list) ---------------------------------- */
.course-nav {
  margin: 1rem 0 0.5rem;
  font-size: var(--fs-sm);
}

.course-nav > details > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  font-weight: 600;
}
.course-nav > details > summary::-webkit-details-marker { display: none; }
.course-nav > details > summary::after {
  content: "";
  width: 0.55rem; height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}
.course-nav > details[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }

.course-nav ol {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  counter-reset: lesson;
}
.course-nav li { margin: 0; }
.course-nav li a {
  display: grid;
  grid-template-columns: 2rem 1fr;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-s);
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.3;
  border-left: 3px solid transparent;
}
.course-nav li a:hover { background: var(--surface); color: var(--ink); }
.course-nav .nav-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.course-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--front);
}
.course-nav a[aria-current="page"] .nav-num { color: var(--front); }
.course-nav .nav-group {
  margin: 0.9rem 0 0.2rem 0.6rem;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 500;
}

@media (min-width: 64rem) {
  .course-nav {
    position: sticky;
    top: 4.2rem;
    align-self: start;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    margin-top: 1.5rem;
  }
  /* The nav <details> ships with [open]; on desktop the toggle is hidden */
  .course-nav > details[open] > summary { display: none; }
}

/* ---------- 6. Breadcrumb ----------------------------------------------- */
.breadcrumb {
  font-size: var(--fs-xs);
  color: var(--muted);
  margin: 1.25rem 0 0.5rem;
}
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.breadcrumb li { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.breadcrumb li + li::before { content: "/"; color: var(--line); }
.breadcrumb a { color: var(--muted); }
.breadcrumb [aria-current="page"] { color: var(--ink-soft); }

/* ---------- 7. Lesson header (the one bold moment) ---------------------- */
.lesson-header {
  position: relative;
  margin: 0.5rem 0 2rem;
  padding: 0 0 1.25rem;
}
.lesson-header__top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 1.1rem;
  align-items: end;
}
/* Race-number plate */
.lesson-plate {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-plate);
  line-height: 0.82;
  color: var(--surface);
  background: var(--ink);
  padding: 0.12em 0.16em 0.06em;
  border-radius: var(--radius-m);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  align-self: start;
}
.lesson-header h1 {
  font-size: var(--fs-xxl);
  margin: 0;
}
.lesson-summary {
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 1rem 0 0.75rem;
  max-width: 60ch;
}
.lesson-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.lesson-meta li { margin: 0; }
.lesson-meta li + li::before { content: "/"; margin-right: 0.4rem; color: var(--line); }

/* Telemetry trace under the header: front (blue) + rear (amber) */
.trace {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 1rem;
}
.trace .trace-grid { stroke: var(--line-soft); stroke-width: 1; }
.trace .trace-front { stroke: var(--front); }
.trace .trace-rear { stroke: var(--rear); }
.trace .trace-front,
.trace .trace-rear {
  fill: none;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
@media (prefers-reduced-motion: no-preference) {
  .js .trace .trace-front,
  .js .trace .trace-rear {
    stroke-dasharray: 1400;
    stroke-dashoffset: 1400;
    animation: trace-draw 1.4s cubic-bezier(.3,.7,.2,1) 0.15s forwards;
  }
  .js .trace .trace-rear { animation-delay: 0.3s; }
}
@keyframes trace-draw { to { stroke-dashoffset: 0; } }

/* ---------- 8. Objectives ----------------------------------------------- */
.objectives {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1.1rem 1.25rem 0.6rem;
  margin: 0 0 2rem;
  box-shadow: var(--shadow);
}
.objectives h2 {
  font-size: var(--fs-md);
  margin: 0 0 0.6rem;
}
.objectives ul { list-style: none; padding: 0; }
.objectives li {
  position: relative;
  padding-left: 1.6rem;
}
.objectives li::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 0.45em;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid var(--front);
  border-radius: 2px;
}

/* ---------- 9. Inline setting vocabulary -------------------------------- */
/* Exact GT7 menu name: <span class="setting">Natural Frequency</span> */
.setting {
  font-weight: 600;
  color: var(--gt7);
  background: var(--gt7-wash);
  padding: 0.05em 0.25em;
  border-radius: 3px;
  white-space: nowrap;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
@media (max-width: 30rem) { .setting { white-space: normal; } }

/* Axle tags: <span class="axle axle--front">Front</span> */
.axle {
  display: inline-block;
  font-size: 0.8em;
  font-weight: 600;
  line-height: 1.3;
  padding: 0.05em 0.45em;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  vertical-align: 0.08em;
}
.axle--front { color: var(--front); background: var(--front-wash); }
.axle--rear { color: var(--rear); background: var(--rear-wash); }

/* Direction of change: <span class="move move--up">Raise</span> */
.move { font-weight: 600; white-space: nowrap; }
.move::before { display: inline-block; margin-right: 0.25em; font-size: 0.8em; }
.move--up::before { content: "\25B2"; }      /* ▲ */
.move--down::before { content: "\25BC"; }    /* ▼ */
.move--left::before { content: "\25C0"; }    /* ◀ toward toe-out / front bias */
.move--right::before { content: "\25B6"; }   /* ▶ toward toe-in / rear bias */

/* Effect labels */
.effect { font-weight: 600; }
.effect--understeer { color: var(--front); }
.effect--oversteer { color: var(--rear); }

/* Keyboard / button glyph */
kbd {
  font: 600 0.85em var(--font-body);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  background: var(--surface);
}

/* ---------- 10. Callouts ------------------------------------------------- */
.callout {
  --c: var(--gt7);
  --c-wash: var(--gt7-wash);
  margin: 1.75rem 0;
  padding: 1rem 1.15rem 0.35rem;
  background: var(--c-wash);
  border-left: 5px solid var(--c);
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
}
.callout__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
  color: var(--c);
  margin: 0 0 0.45rem;
}
.callout p:last-child,
.callout ul:last-child,
.callout ol:last-child { margin-bottom: 0.75rem; }

.callout--gt7 { --c: var(--gt7); --c-wash: var(--gt7-wash); }
.callout--rule { --c: var(--rule); --c-wash: var(--rule-wash); }
.callout--mistake { --c: var(--mistake); --c-wash: var(--mistake-wash); }
.callout--note { --c: var(--muted); --c-wash: var(--surface-2); }

/* Menu path inside the "In GT7" callout */
.menu-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.8rem;
  font-size: var(--fs-sm);
}
.menu-path li { margin: 0; display: flex; align-items: center; gap: 0.3rem; }
.menu-path li + li::before {
  content: "";
  width: 0.4rem; height: 0.4rem;
  border-right: 2px solid var(--muted);
  border-top: 2px solid var(--muted);
  transform: rotate(45deg);
  margin: 0 0.25rem 0 0.1rem;
}
.menu-path span {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.12rem 0.5rem;
  font-weight: 500;
}

/* Small "requires part" line inside GT7 callouts */
.requires {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}
.requires strong { color: var(--c); }

/* ---------- 11. Tables --------------------------------------------------- */
.table-wrap {
  margin: 1.5rem 0 2rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
}
.table-wrap:focus-visible { outline-offset: 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  line-height: 1.45;
}
caption {
  caption-side: top;
  text-align: left;
  padding: 0.75rem 0.9rem 0.25rem;
  font-weight: 600;
  color: var(--ink);
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}
thead th {
  font-weight: 600;
  color: var(--muted);
  font-size: var(--fs-xs);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Settings table: setting | unit | range | typical start | raise does | lower does */
.settings-table td:nth-child(2),
.settings-table td:nth-child(3),
.settings-table td:nth-child(4) { white-space: nowrap; font-variant-numeric: tabular-nums; }

.settings-table tbody th { min-width: 8.5rem; }

/* Rows can be axle-coded */
tr.row--front > :first-child { box-shadow: inset 4px 0 0 var(--front); }
tr.row--rear > :first-child { box-shadow: inset 4px 0 0 var(--rear); }

/* Symptom -> fix table */
.symptom-table td:first-child { font-weight: 600; min-width: 9rem; }
.symptom-table td:nth-child(3) { min-width: 14rem; }
.symptom-table ol { margin: 0; padding-left: 1.2rem; }
.symptom-table li + li { margin-top: 0.15rem; }
.phase {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- 12. Figures / inline SVG diagrams --------------------------- */
.diagram {
  margin: 2rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 28rem;
  margin: 0 auto;
  font-family: var(--font-body);
}
.diagram figcaption {
  margin-top: 0.75rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.5;
}
.diagram figcaption strong { color: var(--ink); }

/* SVG paint classes — use these inside every diagram so themes work */
.diagram .d-ink { stroke: var(--ink); fill: none; }
.diagram .d-ink-fill { fill: var(--ink); }
.diagram .d-muted { stroke: var(--muted); fill: none; }
.diagram .d-muted-fill { fill: var(--muted); }
.diagram .d-grid { stroke: var(--line); fill: none; }
.diagram .d-ground { stroke: var(--muted); stroke-width: 2; fill: none; }
.diagram .d-body { fill: var(--surface-2); stroke: var(--ink); stroke-width: 2; }
.diagram .d-tire { fill: var(--ink); }
.diagram .d-front { stroke: var(--front); fill: none; }
.diagram .d-front-fill { fill: var(--front); }
.diagram .d-front-wash { fill: var(--front-wash); stroke: var(--front); }
.diagram .d-rear { stroke: var(--rear); fill: none; }
.diagram .d-rear-fill { fill: var(--rear); }
.diagram .d-rear-wash { fill: var(--rear-wash); stroke: var(--rear); }
.diagram .d-bad { stroke: var(--mistake); fill: none; }
.diagram .d-good { stroke: var(--rule); fill: none; }
.diagram .d-arrow { stroke: var(--ink); fill: none; stroke-width: 2; }
.diagram text { fill: var(--ink); font-size: 14px; }
.diagram text.d-label-muted { fill: var(--muted); font-size: 13px; }
.diagram text.d-label-front { fill: var(--front); font-weight: 600; }
.diagram text.d-label-rear { fill: var(--rear); font-weight: 600; }
.diagram text.d-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; }

/* Legend chips under a figure */
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.5rem 0 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--muted); }
.legend li { margin: 0; display: inline-flex; align-items: center; gap: 0.35rem; }
.legend li::before { content: ""; width: 1rem; height: 4px; border-radius: 2px; background: var(--muted); }
.legend .lg-front::before { background: var(--front); }
.legend .lg-rear::before { background: var(--rear); }

/* ---------- 13. Drill: "Try it on track" -------------------------------- */
.drill {
  margin: 2rem 0;
  padding: 1.1rem 1.25rem 0.5rem;
  border: 2px dashed var(--drill);
  border-radius: var(--radius-m);
  background: var(--drill-wash);
}
.drill__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--drill);
  margin: 0 0 0.25rem;
}
.drill__setup {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}
.drill ol { counter-reset: step; list-style: none; padding-left: 0; }
.drill ol > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.2rem;
  margin-bottom: 0.5rem;
}
.drill ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--drill);
  color: var(--surface);
  font: 700 0.95rem/1 var(--font-display);
}
.drill__feel {
  font-size: var(--fs-sm);
  border-top: 1px solid color-mix(in srgb, var(--drill) 35%, transparent);
  padding-top: 0.6rem;
}

/* ---------- 14. Key takeaways ------------------------------------------- */
.takeaways {
  margin: 3rem 0 2rem;
  padding: 1.25rem 1.25rem 0.5rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-m);
}
.takeaways h2 {
  color: var(--paper);
  font-size: var(--fs-lg);
  margin: 0 0 0.75rem;
}
.takeaways ul { padding-left: 1.2rem; }
.takeaways li::marker { color: var(--rear); }
.takeaways .setting { color: var(--ink); background: var(--paper); }
.takeaways a { color: inherit; }

/* ---------- 15. Quiz ----------------------------------------------------- */
.quiz { margin: 2.5rem 0; }
.quiz__intro { color: var(--muted); font-size: var(--fs-sm); }
.quiz__tools { margin: 0 0 0.75rem; }
.quiz-q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  margin: 0 0 0.75rem;
}
.quiz-q > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.85rem 1rem 0.85rem 3rem;
  position: relative;
  font-weight: 500;
  line-height: 1.45;
}
.quiz-q > summary::-webkit-details-marker { display: none; }
.quiz-q > summary::before {
  content: "Q";
  position: absolute;
  left: 0.9rem;
  top: 0.75rem;
  font: 700 1.2rem/1.2 var(--font-display);
  color: var(--front);
}
.quiz-q > summary .quiz-hint {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  font-weight: 400;
  margin-top: 0.2rem;
}
.quiz-q[open] > summary .quiz-hint { display: none; }
.quiz-q .answer {
  padding: 0.75rem 1rem 0.3rem 3rem;
  border-top: 1px solid var(--line-soft);
  position: relative;
}
.quiz-q .answer::before {
  content: "A";
  position: absolute;
  left: 0.9rem;
  top: 0.65rem;
  font: 700 1.2rem/1.2 var(--font-display);
  color: var(--rule);
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: 500 var(--fs-sm) / 1.2 var(--font-body);
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-s);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { opacity: 0.9; }
.no-js .js-only { display: none !important; }

/* ---------- 16. Prev / next lesson nav ---------------------------------- */
.lesson-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 3rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
@media (min-width: 40rem) { .lesson-nav { grid-template-columns: 1fr 1fr; } }
.lesson-nav a {
  display: block;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
}
.lesson-nav a:hover { border-color: var(--front); }
.lesson-nav__dir { display: block; font-size: var(--fs-xs); color: var(--muted); }
.lesson-nav__title { display: block; font: 700 1.2rem/1.2 var(--font-display); margin-top: 0.15rem; }
.lesson-nav__next { text-align: right; }
@media (min-width: 40rem) { .lesson-nav__next:only-child { grid-column: 2; } }

/* ---------- 17. Footer -------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-xs);
}
.site-footer__inner {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.5rem var(--gutter) 2.5rem;
}
.site-footer p { margin: 0 0 0.4rem; max-width: 80ch; }
.site-footer a { color: var(--muted); }

/* ---------- 18. Home page ------------------------------------------------ */
.home-hero { margin: 2rem 0 2.5rem; }
.home-hero h1 { font-size: clamp(2.6rem, 1.6rem + 4.5vw, 4.6rem); margin: 0 0 0.75rem; line-height: 0.98; }
.home-hero p { font-size: var(--fs-md); color: var(--ink-soft); max-width: 58ch; }

.syllabus { list-style: none; padding: 0; margin: 1.5rem 0 2rem; counter-reset: s; }
.syllabus > li {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  gap: 0 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.syllabus > li:last-child { border-bottom: 1px solid var(--line); }
.syllabus .s-num {
  font: 700 2.2rem/1 var(--font-display);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.syllabus h3 { margin: 0 0 0.25rem; font-size: 1.4rem; }
.syllabus h3 a { color: var(--ink); text-decoration: none; }
.syllabus h3 a:hover { color: var(--front); text-decoration: underline; }
.syllabus p { margin: 0; color: var(--ink-soft); font-size: var(--fs-sm); }

/* Home: hero extras, intro panels, learning path cards, quick links */
.home-kicker {
  font: 600 var(--fs-sm) / 1.2 var(--font-body);
  color: var(--muted);
  margin: 0 0 0.6rem;
}
.home-hero .lead { font-size: var(--fs-md); color: var(--ink-soft); max-width: 58ch; }
.home-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0 0.5rem; }
.home-actions .btn { font-size: var(--fs-base); padding: 0.65rem 1.1rem; text-decoration: none; }
.home-hero .legend { margin-top: 1rem; }
.home-steps { padding-left: 1.4rem; }
.home-steps > li + li { margin-top: 0.6rem; }
.home-kicker + h2 { margin-top: 1rem; }

.home-panels {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin: 1.5rem 0 1rem;
}
.home-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1rem 1.15rem 0.4rem;
  box-shadow: var(--shadow);
}
.home-panel h2 { font-size: 1.45rem; margin: 0 0 0.5rem; }
.home-panel ul, .home-panel ol { padding-left: 1.15rem; font-size: var(--fs-sm); }
.home-panel p { font-size: var(--fs-sm); }

.path { list-style: none; padding: 0; margin: 1rem 0 2rem; display: grid; gap: 0.9rem; }
.path > li { margin: 0; }
.path-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 1rem 1.15rem;
  position: relative;
}
.path-card:hover { border-color: var(--muted); }
.path-card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.path-card .p-num {
  font: 700 2.4rem/0.85 var(--font-display);
  color: var(--surface);
  background: var(--ink);
  border-radius: var(--radius-s);
  padding: 0.12em 0.18em 0.06em;
  min-width: 1.5em;
  text-align: center;
  align-self: start;
  font-variant-numeric: tabular-nums;
}
.path-card h3 { margin: 0 0 0.3rem; font-size: 1.45rem; }
.path-card h3 a { color: var(--ink); text-decoration: none; }
/* whole card is clickable via the heading link */
.path-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-m); }
.path-card h3 a:focus-visible { outline: none; }
.path-card p { margin: 0 0 0.5rem; color: var(--ink-soft); font-size: var(--fs-sm); }
.path-card .p-meta { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 0.35rem; }
.path-card .p-settings { font-size: var(--fs-xs); margin: 0; line-height: 1.9; color: var(--muted); }
.path-card .p-settings .setting { font-size: var(--fs-xs); }
@media (max-width: 30rem) {
  .path-card { grid-template-columns: minmax(0, 1fr); }
  .path-card .p-num { justify-self: start; margin-bottom: 0.5rem; font-size: 2rem; }
}

.quick-links {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  margin: 1.25rem 0 2rem;
}
.quick-link {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--c, var(--ink));
  border-radius: var(--radius-m);
  padding: 0.9rem 1.15rem 0.8rem;
  box-shadow: var(--shadow);
}
.quick-link:hover { border-color: var(--muted); border-top-color: var(--c, var(--ink)); color: var(--ink); }
.quick-link strong { display: block; font: 700 1.45rem/1.15 var(--font-display); margin-bottom: 0.3rem; }
.quick-link span { display: block; font-size: var(--fs-sm); color: var(--ink-soft); }
.quick-link--doctor { --c: var(--mistake); }
.quick-link--cheat { --c: var(--rule); }
.quick-link--start { --c: var(--front); }

/* ---------- 19. Interactive widgets (shared shell) ---------------------- */
.widget {
  margin: 2rem 0;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow);
}
.widget__title { font: 700 1.25rem/1.2 var(--font-display); margin: 0 0 0.6rem; }
.widget label { font-weight: 500; font-size: var(--fs-sm); display: block; margin-bottom: 0.25rem; }
.widget input[type="range"] { width: 100%; accent-color: var(--front); }
.widget select {
  font: inherit;
  font-size: var(--fs-sm);
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--ink);
  max-width: 100%;
}
.widget output { font-weight: 600; font-variant-numeric: tabular-nums; }
.widget__row { display: grid; gap: 0.75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); margin-bottom: 0.75rem; }
.widget__result {
  margin-top: 0.75rem;
  padding: 0.8rem 1rem;
  background: var(--surface-2);
  border-radius: var(--radius-s);
  border-left: 4px solid var(--front);
}
.widget__result:empty { display: none; }

/* Segmented choice (radio pills) */
.choice { display: flex; flex-wrap: wrap; gap: 0.4rem; border: 0; padding: 0; margin: 0 0 0.9rem; }
.choice legend { font-weight: 600; font-size: var(--fs-sm); margin-bottom: 0.4rem; padding: 0; }
.choice label { display: inline-flex; margin: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.choice input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Symptom Doctor specifics */
.doctor-fixes { counter-reset: fix; list-style: none; padding: 0; margin: 0.5rem 0 0; }
.doctor-fixes > li {
  counter-increment: fix;
  position: relative;
  padding: 0.6rem 0 0.6rem 2.6rem;
  border-top: 1px solid var(--line-soft);
  margin: 0;
}
.doctor-fixes > li::before {
  content: counter(fix);
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 1.8rem; height: 1.8rem;
  display: grid; place-items: center;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: var(--paper);
  font: 700 1.05rem/1 var(--font-display);
}
.doctor-fixes .why { display: block; font-size: var(--fs-sm); color: var(--muted); }

/* ---------- 20. Cheat sheet --------------------------------------------- */
.cheat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  margin: 1.5rem 0;
}
.cheat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 0.9rem 1rem 0.4rem;
  font-size: var(--fs-sm);
  line-height: 1.45;
  break-inside: avoid;
}
.cheat-card h2,
.cheat-card h3 { font-size: 1.2rem; margin: 0 0 0.4rem; }
.cheat-card ul { padding-left: 1.1rem; margin-bottom: 0.6rem; }
.cheat-card table { font-size: var(--fs-xs); }
.cheat-card th, .cheat-card td { padding: 0.3rem 0.4rem; }

/* ---------- 21. Utilities ------------------------------------------------ */
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.stack > * + * { margin-top: 1rem; }

/* ---------- 22. Motion preferences -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 23. Small screens ------------------------------------------- */
@media (max-width: 40rem) {
  :root { --fs-base: 1rem; }
  h2 { font-size: 1.85rem; margin-top: 2.5rem; }
  .lesson-header__top { grid-template-columns: 1fr; gap: 0.75rem; }
  .lesson-plate { justify-self: start; }
  .callout, .drill, .objectives, .widget, .diagram { padding-left: 0.9rem; padding-right: 0.9rem; }
  .quiz-q > summary { padding-left: 2.5rem; }
  .quiz-q .answer { padding-left: 2.5rem; }
  .brand__sub { display: none; }
  .lesson-meta { flex-direction: column; gap: 0.1rem; }
  .lesson-meta li + li::before { content: none; }
  th, td { padding: 0.5rem 0.6rem; }
}

@media screen and (max-width: 40rem) {
  /* Phones: tables become one card per row (app.js adds .stack and data-label) */
  .table-wrap--stack { overflow: visible; border: 0; background: none; border-radius: 0; }
  table.stack, table.stack tbody, table.stack tr, table.stack th, table.stack td { display: block; }
  table.stack caption { display: block; padding: 0 0 0.5rem; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.stack tr {
    margin: 0 0 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    overflow: hidden;
  }
  table.stack tr > * {
    width: auto !important;
    min-width: 0 !important;
    white-space: normal !important;
    text-align: left;
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--line-soft);
  }
  table.stack tr > :last-child { border-bottom: 0; }
  table.stack tr > :first-child { background: var(--surface-2); font-weight: 600; }
  table.stack [data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--muted);
  }
  table.stack td.stack-kv { text-align: right; padding-top: 0.45rem; padding-bottom: 0.45rem; }
  table.stack td.stack-kv::before { float: left; margin: 0.1rem 1rem 0 0; text-align: left; }
  table.stack td.stack-kv::after { content: ""; display: block; clear: both; }
  .brand { padding: 0.6rem 0; }
  .axle { font-size: max(0.8em, 0.75rem); }
}

/* Touch screens at any width (incl. iPhone landscape): iOS Safari zooms into
   form controls under 16px, and controls need to be thumb-sized */
@media (pointer: coarse) {
  .widget select, select, input:not([type="range"]):not([type="radio"]):not([type="checkbox"]), textarea { font-size: 16px; }
  .widget select { min-height: 2.75rem; }
  .choice span { min-height: 2.75rem; display: inline-flex; align-items: center; }
  .btn { min-height: 2.75rem; display: inline-flex; align-items: center; }
}

/* Range sliders: a larger track and thumb that are easy to drag on touch screens */
.widget input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 2.75rem;
  background: transparent;
  touch-action: pan-y;
  --range-c: var(--front);
}
.widget input[type="range"].toe-rear-range { --range-c: var(--rear); }
.widget input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
}
.widget input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.75rem;
  height: 1.75rem;
  margin-top: calc(3px - 0.875rem);
  border-radius: 50%;
  background: var(--range-c);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
}
.widget input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.widget input[type="range"]::-moz-range-thumb {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--range-c);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.35);
}
.widget input[type="range"]:focus-visible { outline: none; }
.widget input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--focus); outline-offset: 2px; }
.widget input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--focus); outline-offset: 2px; }

.doctor-jump { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0; }
.doctor-jump .btn { text-decoration: none; }

/* ---------- 24. Print (cheat sheet + any lesson) ------------------------ */
@media print {
  @page { margin: 12mm; }
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    color-scheme: light;
    --paper: #fff; --surface: #fff; --surface-2: #f3f3f3;
    --ink: #000; --ink-soft: #222; --muted: #444; --line: #999; --line-soft: #ccc;
    --front: #0b4fa8; --front-wash: #fff; --rear: #a24f00; --rear-wash: #fff;
    --gt7: #1d2c5e; --gt7-wash: #fff; --rule: #0a5e48; --rule-wash: #fff;
    --mistake: #9a1c12; --mistake-wash: #fff; --drill: #4a3672; --drill-wash: #fff;
    --shadow: none;
  }
  html { font-size: 10pt; }
  body { background: #fff; color: #000; line-height: 1.4; }
  .site-header, .course-nav, .breadcrumb, .lesson-nav, .theme-toggle, .quiz__tools,
  .skip-link, .trace, .widget, .no-print { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  main { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .lesson-plate { color: #fff; background: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .takeaways { background: #fff; color: #000; border: 2px solid #000; }
  .takeaways h2 { color: #000; }
  .takeaways .setting { background: none; }
  .setting { background: none; padding: 0; }
  .callout, .drill, .table-wrap, .diagram, .objectives, .quiz-q, .cheat-card { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  /* Print every quiz answer */
  .quiz-q > summary::before, .quiz-q .answer::before { color: #000; }
  .quiz-q::details-content { content-visibility: visible; display: block; }
  .cheat-grid { grid-template-columns: repeat(2, 1fr); gap: 4mm; }
  .cheat-card { padding: 3mm; border-color: #000; }
  .axle--front, .axle--rear { background: #fff; }
  .site-footer { border: 0; }
  .site-footer__inner { padding: 4mm 0 0; }
}
