/* OD-LAYOUT-PRIMITIVES v1 — structure only: display, flex/grid, overflow, wrapping, ratio, geometry.
   Put this @layer first; product CSS outside the layer always wins. */
@layer od-layout {
  :where(.od-stack,.od-row,.od-row-top,.od-cluster,.od-grid,.od-field,.od-stat,.od-cell,.od-tile) > :where(*) { min-width: 0; }

  /* containers */
  .od-stack   { display: flex; flex-direction: column; gap: var(--od-gap, 8px); }
  .od-row     { display: flex; align-items: center; gap: var(--od-gap, 8px); }
  .od-row-top { display: flex; align-items: flex-start; gap: var(--od-gap, 8px); }
  .od-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--od-gap, 8px); }
  .od-fill    { flex: 1 1 0; min-width: 0; }
  .od-fixed   { flex: none; }
  .od-grid    { display: grid; gap: var(--od-gap, 12px); grid-template-columns: repeat(var(--od-cols, 3), minmax(0, 1fr)); }

  /* stacked information: each piece is its own line — never sibling inline spans */
  .od-stat, .od-field, .od-cell { display: grid; gap: var(--od-gap, 2px); }
  :where(.od-stat,.od-field,.od-cell) > :where(*) { display: block; }
  .od-tile { display: grid; grid-template-rows: auto 1fr; }
  :where(.od-tile) > :where(*) { display: block; }

  /* media keeps its intrinsic ratio by default; never a distorted or cropped
     cover by accident. height:auto lets the ratio win over an <img height="…">
     attribute. Cropping to a uniform box is an explicit opt-in: set --od-ratio
     AND add .od-media-cover together (per the core rule, only where a crop is
     deliberate — tile thumbs, decorative fills — never on full-frame content). */
  .od-media { display: block; width: 100%; height: auto; aspect-ratio: var(--od-ratio, auto); }
  .od-media-cover { object-fit: cover; }

  /* functional inline SVG icons opt into bounded geometry; content SVGs keep their own */
  .od-icon { display: inline-block; inline-size: var(--od-icon-size, 1em); block-size: var(--od-icon-size, 1em); flex: none; }

  /* data text only — authored copy is rewritten to its budget instead */
  .od-truncate { display: block; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .od-clamp-2, .od-clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
  .od-clamp-2 { -webkit-line-clamp: 2; }
  .od-clamp-3 { -webkit-line-clamp: 3; }
  .od-lines-2 { min-height: calc(2 * 1.4em); }   /* block-level reservation for a shared baseline */
  .od-nowrap  { white-space: nowrap; }           /* 数字+单位 · 价格+起 · 日期+星期 */
  .od-keep    { word-break: keep-all; overflow-wrap: anywhere; } /* CJK labels break at spaces / <wbr> first */

  /* screen skeleton (optional): bars take their own space, the middle scrolls — no padding guessed for chrome */
  .od-screen { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
  .od-scroll { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }

  /* horizontal rail: the next item peeks at the edge; trailing room survives overflow */
  .od-rail { display: flex; gap: var(--od-gap, 8px); overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
             padding-inline: var(--od-rail-pad, 16px); scroll-padding-inline: var(--od-rail-pad, 16px); }
  .od-rail::-webkit-scrollbar { display: none; }
  :where(.od-rail) > :where(*) { flex: none; scroll-snap-align: start; }
  :where(.od-rail) > :where(:last-child) { margin-inline-end: var(--od-rail-pad, 16px); }

  .od-spacer { flex: none; visibility: hidden; pointer-events: none; }
  .od-touch  { min-width: 44px; min-height: 44px; }
}
/* /OD-LAYOUT-PRIMITIVES v1 */

:root {
  --paper: #f3f6f1;
  --paper-deep: #e9eee7;
  --white: #fbfdfa;
  --ink: #15211f;
  --ink-soft: #334542;
  --muted: #5a6a66;
  --muted-light: #8a9994;
  --teal: #0f766e;
  --teal-deep: #075c56;
  --teal-tint: #dceee8;
  --teal-tint-2: #edf6f2;
  --coral: #cf5b3e;
  --coral-ink: #9b3e28;
  --coral-light: #f29b7c;
  --coral-tint: #f7e3dc;
  --line: #cdd8d2;
  --line-strong: #9fb1aa;
  --dark: #11211e;
  --dark-2: #182c28;
  --dark-line: rgba(238, 247, 242, 0.14);
  --dark-text: #edf6f1;
  --dark-muted: #a9bbb6;
  --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-soft: 0 18px 50px rgba(21, 33, 31, 0.07);
  --shadow-lab: 0 28px 70px rgba(17, 33, 30, 0.18);
  --shell-wide: 1220px;
  --shell-narrow: 1180px;
  --focus: #b9482e;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(21, 33, 31, 0.038) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(21, 33, 31, 0.038) 1px, transparent 1px);
  background-size: 32px 32px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--coral-tint);
  color: var(--ink);
}

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

svg {
  display: block;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure,
blockquote {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  transform: translateY(-160%);
  transition: transform 180ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: min(var(--shell-wide), calc(100% - 64px));
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.brand-mark {
  color: var(--ink);
  flex: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: clamp(14px, 2.4vw, 28px);
  margin-left: auto;
}

.site-nav a {
  position: relative;
  padding-block: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color 160ms ease-out;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  height: 1px;
  background: var(--teal);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease-out;
}

.site-nav a:hover {
  color: var(--ink);
}

.site-nav a:hover::after {
  transform: scaleX(1);
}

.header-query-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  transition: background-color 180ms ease-out, color 180ms ease-out, border-color 180ms ease-out;
}

.header-query-link:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

/* ---------- Hero ---------- */

.hero {
  padding-top: clamp(48px, 7vw, 88px);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(360px, 0.94fr);
  align-items: center;
  gap: clamp(36px, 5.4vw, 76px);
  padding-bottom: clamp(40px, 5vw, 64px);
}

.hero-copy {
  animation: rise-in 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow-rule {
  width: 38px;
  height: 1px;
  background: var(--teal);
}

.hero h1 {
  max-width: 12ch;
  font-family: var(--font-display);
  font-size: clamp(46px, 6.2vw, 82px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.hero h1 em {
  color: var(--teal-deep);
  font-weight: 500;
}

.hero-lede {
  max-width: 59ch;
  margin-top: 28px;
  color: var(--ink-soft);
  font-size: clamp(17px, 1.45vw, 19px);
  line-height: 1.65;
  text-wrap: pretty;
}

.hero-lede strong {
  color: var(--ink);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px 28px;
  margin-top: 34px;
}

.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--radius-s);
  background: var(--ink);
  color: var(--white);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 180ms ease-out, transform 180ms ease-out;
}

.button-primary span {
  font-size: 18px;
  line-height: 1;
}

.button-primary:hover {
  background: var(--teal-deep);
  transform: translateY(-1px);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hero-meta span + span::before {
  content: "·";
  margin-right: 8px;
  color: var(--line-strong);
}

.hero-figure {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
  box-shadow: var(--shadow-soft);
  animation: rise-in 620ms 80ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.figure-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 5px 12px;
}

.figure-label,
.figure-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.figure-label {
  color: var(--ink-soft);
}

.figure-status {
  color: var(--coral-ink);
  letter-spacing: 0.06em;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
}

.hero-figure svg {
  width: 100%;
  height: auto;
}

.hero-figure figcaption {
  margin-top: 10px;
  padding: 12px 5px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.hero-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.hero-strip li {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 14px clamp(0px, 2vw, 24px);
}

.hero-strip li:first-child {
  padding-left: 0;
}

.hero-strip li + li {
  border-left: 1px solid var(--line);
}

.strip-number {
  color: var(--coral-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}

.strip-text {
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
}

/* ---------- Lesson frame ---------- */

.lesson-shell {
  display: grid;
  grid-template-columns: 208px minmax(0, 860px);
  justify-content: center;
  align-items: start;
  gap: clamp(34px, 5vw, 72px);
  padding-block: clamp(56px, 7vw, 84px) clamp(72px, 9vw, 116px);
}

.lesson-rail {
  position: sticky;
  top: 96px;
}

.rail-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rail-list {
  margin-top: 14px;
  border-left: 1px solid var(--line);
}

.rail-list a {
  display: flex;
  align-items: baseline;
  gap: 11px;
  margin-left: -1px;
  padding: 9px 11px 9px 15px;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  transition: color 160ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out;
}

.rail-num {
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-size: 9px;
  transition: color 160ms ease-out;
}

.rail-list a:hover {
  color: var(--ink);
  background: rgba(220, 238, 232, 0.38);
}

.rail-list a.is-current {
  border-left-color: var(--teal);
  background: var(--teal-tint);
  color: var(--teal-deep);
  font-weight: 600;
}

.rail-list a.is-current .rail-num {
  color: var(--teal-deep);
}

.rail-fact {
  margin-top: 28px;
  padding: 17px 0 0 15px;
  border-top: 1px solid var(--line);
}

.rail-fact p {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.rail-fact strong {
  display: block;
  margin-top: 5px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
}

.rail-fact span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10.5px;
}

.mobile-toc {
  display: none;
}

.lesson-body {
  min-width: 0;
}

.lesson-section {
  scroll-margin-top: 96px;
  margin-bottom: clamp(76px, 8.5vw, 116px);
}

.lesson-section:last-child {
  margin-bottom: 0;
}

.section-head {
  margin-bottom: clamp(28px, 4vw, 38px);
}

.section-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--teal-deep);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-kicker > span {
  padding-right: 10px;
  border-right: 1px solid var(--line-strong);
  color: var(--coral-ink);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.section-head h2 {
  max-width: 22ch;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: clamp(34px, 4.35vw, 50px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.032em;
  text-wrap: balance;
}

.lede {
  max-width: 70ch;
  margin-top: 16px;
  color: var(--muted);
  font-size: clamp(17px, 1.55vw, 18.5px);
  line-height: 1.63;
  text-wrap: pretty;
}

.lede strong {
  color: var(--ink);
  font-weight: 600;
}

h3 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.015em;
}

.inline-vector {
  display: inline-block;
  padding: 0.06em 0.36em 0.08em;
  border-radius: 4px;
  background: var(--teal-tint);
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 0.88em;
  line-height: 1.3;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.prose {
  max-width: 69ch;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.72;
}

.prose p + p {
  margin-top: 1em;
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---------- Dataset table ---------- */

.table-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.table-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
}

.table-kicker {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.table-card-head h3 {
  margin-top: 4px;
}

.sample-count {
  flex: none;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.dataset-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.dataset-table th {
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #eef3ef;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.065em;
  line-height: 1.35;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.dataset-table th.feature-column {
  background: #e4f0eb;
  color: var(--teal-deep);
}

.th-label {
  display: block;
  margin-bottom: 2px;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  opacity: 0.78;
}

.dataset-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  text-align: left;
}

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

.dataset-table tbody tr {
  transition: background-color 150ms ease-out;
}

.dataset-table tbody tr:hover {
  background: #f5f9f5;
}

.dataset-table td.feature-cell {
  background: rgba(220, 238, 232, 0.38);
  color: var(--teal-deep);
}

.cell-value,
.outcome-cell {
  font-family: var(--font-mono);
  font-size: 14.5px;
}

.outcome-cell {
  color: var(--muted) !important;
}

.sample-identity {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 600;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.table-key {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: #fafcf9;
}

.table-key p {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.key-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.key-swatch--feature {
  background: var(--teal-tint);
  border: 1px solid #b8d8ce;
}

.key-swatch--outcome {
  background: #eef1ee;
  border: 1px solid var(--line);
}

/* ---------- Notes and reveals ---------- */

.note {
  margin-top: 22px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--white);
}

.note--teal {
  border-color: #c6ded6;
  background: var(--teal-tint);
}

.note--warm {
  border-color: #e8cec2;
  background: #f7ebe5;
}

.note-label {
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.note--teal .note-label {
  color: var(--teal-deep);
}

.note--warm .note-label {
  color: var(--coral-ink);
}

.note p:last-child {
  max-width: 72ch;
  color: var(--ink-soft);
  font-size: 15.5px;
  line-height: 1.65;
}

.reveal {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.reveal summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0 7px;
  color: var(--ink);
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
  list-style: none;
}

.reveal summary::-webkit-details-marker {
  display: none;
}

.reveal summary::after {
  content: "+";
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}

.reveal[open] summary::after {
  content: "−";
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}

.reveal summary:hover::after {
  background: var(--teal-tint);
}

.reveal-body {
  max-width: 72ch;
  padding: 7px 40px 10px 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.65;
}

/* ---------- Vectors ---------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(280px, 0.94fr);
  align-items: center;
  gap: clamp(24px, 4vw, 38px);
  margin-top: 30px;
}

.split--worked {
  align-items: start;
  margin-top: 28px;
}

.vector-definition {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
  background: var(--white);
}

.vector-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
}

.vector-name {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.vector-value {
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: clamp(18px, 2.2vw, 22px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.vector-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  background: #f8fbf8;
}

.vector-legend > div {
  padding: 11px 18px;
}

.vector-legend > div + div {
  border-left: 1px solid var(--line);
}

.vector-legend dt {
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.vector-legend dd {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

.diagram-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 14px 14px 0;
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.diagram-card svg {
  width: 100%;
  height: auto;
}

.diagram-card figcaption {
  margin-top: 8px;
  padding: 11px 4px 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------- Distance ---------- */

.formula-card {
  padding: clamp(22px, 3.4vw, 30px);
  border-radius: var(--radius-l);
  background: var(--dark);
  color: var(--dark-text);
  box-shadow: var(--shadow-lab);
}

.formula-label {
  color: var(--coral-light);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.formula {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 18px;
  color: var(--dark-text);
  font-family: var(--font-display);
  font-size: clamp(22px, 3.3vw, 34px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.formula-main {
  white-space: nowrap;
}

.formula .sqrt {
  display: inline-flex;
  align-items: flex-start;
  color: var(--dark-text);
}

.formula .sqrt::before {
  content: "√";
  display: block;
  margin-right: -0.14em;
  font-family: var(--font-display);
  font-size: 1.55em;
  font-weight: 400;
  line-height: 0.92;
  color: var(--coral-light);
}

.formula .sqrt > span {
  margin-top: 0.44em;
  padding: 0.16em 0.34em 0 0.28em;
  border-top: 1.5px solid var(--dark-text);
  white-space: nowrap;
}

.formula sub {
  font-size: 0.55em;
  vertical-align: -0.26em;
}

.formula sup {
  font-size: 0.58em;
  vertical-align: 0.5em;
}

.formula-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--dark-line);
}

.formula-legend p {
  color: var(--dark-muted);
  font-size: 11.5px;
}

.formula-legend strong {
  color: var(--dark-text);
  font-family: var(--font-mono);
  font-size: 11px;
}

.mini-kicker {
  margin-bottom: 8px;
  color: var(--coral-ink);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.calc-steps {
  margin: 22px 0;
  border-top: 1px solid var(--line);
}

.calc-steps li {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.step-label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-math {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.result-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 16px;
  border-radius: var(--radius-s);
  background: var(--teal-tint);
}

.result-line span {
  color: var(--teal-deep);
  font-size: 12px;
  font-weight: 600;
}

.result-line strong {
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Matrices ---------- */

.matrix-stage {
  padding: clamp(22px, 3.2vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
  box-shadow: var(--shadow-soft);
}

.matrix-scene {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px 30px;
}

.matrix-unit {
  width: 220px;
}

.matrix-unit--query {
  width: 164px;
}

.matrix-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.matrix-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
  font-style: italic;
  line-height: 1;
}

.matrix-shape {
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.matrix-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 22px;
  margin-top: 14px;
  padding-inline: 20px;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-align: right;
  text-transform: uppercase;
}

.matrix-frame {
  position: relative;
  margin-top: 5px;
  padding: 9px 19px;
}

.matrix-frame::before,
.matrix-frame::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  border-top: 1.5px solid var(--ink-soft);
  border-bottom: 1.5px solid var(--ink-soft);
}

.matrix-frame::before {
  left: 0;
  border-left: 1.5px solid var(--ink-soft);
}

.matrix-frame::after {
  right: 0;
  border-right: 1.5px solid var(--ink-soft);
}

.matrix-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 22px;
  row-gap: 7px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: right;
}

.matrix-caption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.matrix-join {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 78px;
  color: var(--coral-ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.matrix-join span:last-child {
  color: var(--coral);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1;
}

.matrix-annotations {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.matrix-annotations > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.annotation-label {
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.matrix-annotations strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 500;
}

.matrix-annotations div > span:last-child {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

.prose--matrix {
  max-width: 74ch;
  margin-top: 26px;
}

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

.lab-panel {
  position: relative;
  border-radius: 24px;
  padding: clamp(20px, 3.4vw, 34px);
  background-color: var(--dark);
  background-image:
    linear-gradient(to right, rgba(238, 247, 242, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(238, 247, 242, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--dark-text);
  box-shadow: var(--shadow-lab);
}

.lab-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--dark-line);
  margin-bottom: 26px;
}

.lab-kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--coral-light);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #65cbb2;
  box-shadow: 0 0 0 3px rgba(101, 203, 178, 0.14);
}

.lab-head h3 {
  color: var(--dark-text);
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 500;
}

.lab-hint {
  max-width: 34ch;
  color: var(--dark-muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: right;
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: clamp(18px, 2.6vw, 28px);
  align-items: stretch;
}

.lab-controls {
  padding: 20px;
  border: 1px solid var(--dark-line);
  border-radius: var(--radius-m);
  background: var(--dark-2);
}

.query-display {
  padding-bottom: 17px;
  border-bottom: 1px solid var(--dark-line);
}

.query-display-label {
  color: var(--dark-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.query-vector {
  margin-top: 6px;
  color: var(--dark-text);
  font-family: var(--font-mono);
  font-size: clamp(28px, 3.8vw, 36px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.2;
  white-space: nowrap;
}

.vector-bracket {
  color: var(--coral-light);
  font-weight: 400;
}

.vector-comma {
  color: var(--dark-muted);
}

.query-display-note {
  margin-top: 4px;
  color: var(--dark-muted);
  font-size: 10.5px;
}

.control-group {
  margin-top: 20px;
}

.control-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.control-top label {
  color: var(--dark-text);
  font-size: 13px;
  font-weight: 500;
}

.control-top output {
  color: var(--coral-light);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.control-group input[type="range"] {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  margin: 7px 0 0;
  background: transparent;
  cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--coral-light) 0 var(--fill), #3e504b var(--fill) 100%);
}

.control-group input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: #3e504b;
}

.control-group input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--coral-light);
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 3px solid var(--dark-2);
  border-radius: 50%;
  background: var(--coral-light);
  box-shadow: 0 0 0 1px var(--coral-light);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid var(--dark-2);
  border-radius: 50%;
  background: var(--coral-light);
  box-shadow: 0 0 0 1px var(--coral-light);
}

.control-group input[type="range"]:focus-visible {
  outline: 3px solid #f6c7b7;
  outline-offset: 4px;
  border-radius: 999px;
}

.control-scale {
  display: flex;
  justify-content: space-between;
  color: #8fa39d;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.preset-group {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px solid var(--dark-line);
}

.preset-label {
  color: var(--dark-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.preset-chip {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid rgba(238, 247, 242, 0.24);
  border-radius: 999px;
  background: transparent;
  color: #d6e1dd;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms ease-out, color 160ms ease-out, border-color 160ms ease-out;
}

.preset-chip:hover {
  border-color: var(--coral-light);
  color: var(--dark-text);
}

.preset-chip[aria-pressed="true"] {
  border-color: var(--coral-light);
  background: var(--coral-light);
  color: #1b2522;
  font-weight: 600;
}

.lab-chart {
  min-width: 0;
  padding: 16px 16px 13px;
  border: 1px solid var(--dark-line);
  border-radius: var(--radius-m);
  background: #0c1a17;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 1px 4px 10px;
}

.chart-head > p {
  color: var(--dark-text);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--dark-muted);
  font-size: 9.5px;
}

.legend-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fc9b8;
}

.legend-diamond {
  width: 7px;
  height: 7px;
  background: var(--coral-light);
  transform: rotate(45deg);
}

.legend-ring {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--coral-light);
  border-radius: 50%;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
}

.chart-note {
  padding: 8px 4px 1px;
  border-top: 1px solid var(--dark-line);
  color: #8fa39d;
  font-size: 9.5px;
}

.chart-grid-line {
  stroke: rgba(238, 247, 242, 0.08);
  stroke-width: 1;
}

.chart-axis {
  stroke: rgba(238, 247, 242, 0.28);
  stroke-width: 1.2;
}

.chart-tick {
  fill: #91a7a0;
  font-family: var(--font-mono);
  font-size: 11px;
}

.chart-axis-label {
  fill: #b9cbc5;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sample-point {
  fill: #6fc9b8;
}

.sample-label {
  fill: #dbe9e4;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
}

.nearest-ring {
  fill: none;
  stroke: var(--coral-light);
  stroke-width: 2;
}

.distance-line {
  stroke: var(--coral-light);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
}

.query-shape {
  fill: var(--coral-light);
}

.query-label {
  fill: #fff8f4;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
}

.distance-badge {
  fill: #213530;
  stroke: rgba(242, 155, 124, 0.45);
  stroke-width: 1;
}

.distance-badge-text {
  fill: #f7cab9;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
}

/* Results */

.results-panel {
  margin-top: 24px;
  padding: clamp(18px, 2.8vw, 24px);
  border-radius: var(--radius-m);
  background: var(--white);
  color: var(--ink);
}

.results-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 13px;
}

.results-kicker {
  margin-bottom: 4px;
  color: var(--coral-ink);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.results-head h3 {
  font-size: clamp(21px, 2.4vw, 25px);
  font-weight: 500;
}

.results-summary {
  max-width: 40ch;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.results-labels {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 86px minmax(70px, 0.75fr);
  gap: 14px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.result-list {
  counter-reset: none;
}

.result-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 86px minmax(70px, 0.75fr);
  gap: 14px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.result-row:last-child {
  border-bottom: 0;
}

.result-rank {
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.result-id {
  min-width: 0;
}

.result-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}

.result-vector {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.result-badge {
  flex: none;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--coral-tint);
  color: var(--coral-ink);
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-distance {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  text-align: right;
  white-space: nowrap;
}

.result-distance small {
  display: block;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-bar {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #e3eae5;
  overflow: hidden;
}

.result-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.result-row.is-nearest .result-fill {
  background: var(--coral);
}

.result-row.is-nearest .result-rank {
  color: var(--coral-ink);
  font-weight: 700;
}

.results-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

/* ---------- Checkpoint ---------- */

.quiz-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.quiz-score {
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.quiz-reset {
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 160ms ease-out, border-color 160ms ease-out;
}

.quiz-reset:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.quiz-list {
  display: grid;
  gap: 14px;
}

.quiz-card {
  min-width: 0;
  margin: 0;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--white);
}

.quiz-card legend {
  max-width: 100%;
  padding: 0 0 13px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.012em;
}

.quiz-card legend > span:first-child {
  display: inline-block;
  margin-right: 10px;
  padding-right: 10px;
  border-right: 1px solid var(--line);
  color: var(--coral-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: 0.2em;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: #fbfcfa;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 150ms ease-out, background-color 150ms ease-out, color 150ms ease-out;
}

.quiz-option:hover {
  border-color: var(--line-strong);
  background: #f4f8f4;
}

.quiz-option input {
  width: 15px;
  height: 15px;
  flex: none;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.quiz-option:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-tint);
  color: var(--teal-deep);
  font-weight: 500;
}

.quiz-option.is-correct {
  border-color: #75a98f;
  background: #e2f1e7;
  color: #174b37;
}

.quiz-option.is-wrong {
  border-color: #d59a87;
  background: #f9e8e2;
  color: #7f3220;
}

.quiz-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.quiz-feedback {
  margin-top: 13px;
  padding: 11px 13px;
  border-radius: var(--radius-s);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
}

.quiz-feedback.is-correct {
  background: #e2f1e7;
  color: #174b37;
}

.quiz-feedback.is-wrong {
  background: #f9e8e2;
  color: #7f3220;
}

/* ---------- Recap ---------- */

.recap-panel {
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid #bcd9d0;
  border-radius: 24px;
  background: var(--teal-tint);
}

.recap-panel h2 {
  max-width: 18ch;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 500;
  line-height: 1.06;
  letter-spacing: -0.03em;
}

.recap-panel blockquote {
  max-width: 21ch;
  margin-top: 28px;
  color: var(--teal-deep);
  font-family: var(--font-display);
  font-size: clamp(28px, 4.1vw, 48px);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.034em;
}

.recap-panel blockquote em {
  color: var(--coral-ink);
  font-weight: 500;
}

.recap-points {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
  margin-top: 38px;
  padding-top: 20px;
  border-top: 1px solid #b9d6cc;
}

.recap-points > div {
  display: grid;
  gap: 7px;
}

.recap-points span {
  color: var(--coral-ink);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
}

.recap-points p {
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.58;
}

.recap-points strong {
  color: var(--ink);
  font-weight: 600;
}

.lesson-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.lesson-footer p {
  max-width: 62ch;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.lesson-footer a {
  flex: none;
  color: var(--teal-deep);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.lesson-footer a:hover {
  text-decoration: underline;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1120px) {
  .lesson-shell {
    grid-template-columns: 188px minmax(0, 1fr);
    gap: 42px;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1.02fr) minmax(340px, 0.98fr);
    gap: 38px;
  }

  .hero h1 {
    font-size: clamp(44px, 6vw, 68px);
  }
}

@media (max-width: 1024px) {
  .lesson-shell {
    display: block;
    max-width: 920px;
    padding-top: 44px;
  }

  .lesson-rail {
    display: none;
  }

  .mobile-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 42px;
  }

  .mobile-toc a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    color: var(--muted);
    text-decoration: none;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: border-color 160ms ease-out, color 160ms ease-out;
  }

  .mobile-toc a:hover {
    border-color: var(--teal);
    color: var(--teal-deep);
  }

  .lab-grid {
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 38px;
  }

  .hero h1 {
    max-width: 15ch;
  }

  .hero-figure {
    max-width: 640px;
  }

  .lab-grid {
    grid-template-columns: 1fr;
  }

  .lab-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 22px;
  }

  .query-display,
  .preset-group {
    grid-column: 1 / -1;
  }

  .control-group {
    min-width: 0;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .split .diagram-card {
    max-width: 540px;
  }

  .split--worked .diagram-card {
    max-width: 440px;
  }
}

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

  .header-query-link {
    margin-left: auto;
  }

  .hero-strip li {
    padding-inline: 14px;
  }

  .hero-strip li:first-child {
    padding-left: 0;
  }

  .hero-strip li:last-child {
    padding-right: 0;
  }

  .strip-text {
    font-size: 12.5px;
  }

  .results-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .results-summary {
    text-align: left;
  }

  .recap-points {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 720px) {
  .shell {
    width: calc(100% - 40px);
  }

  .hero {
    padding-top: 38px;
  }

  .hero h1 {
    font-size: clamp(42px, 11.5vw, 60px);
  }

  .hero-lede {
    margin-top: 22px;
    font-size: 17px;
  }

  .hero-strip {
    grid-template-columns: 1fr;
  }

  .hero-strip li,
  .hero-strip li:first-child,
  .hero-strip li:last-child {
    min-height: 50px;
    padding: 10px 0;
  }

  .hero-strip li + li {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .lesson-shell {
    padding-top: 34px;
  }

  .mobile-toc {
    margin-bottom: 34px;
  }

  .section-head h2 {
    max-width: 20ch;
  }

  .dataset-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .dataset-table,
  .dataset-table tbody,
  .dataset-table tr,
  .dataset-table td {
    display: block;
    width: 100%;
  }

  .dataset-table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
  }

  .dataset-table tbody tr:first-child {
    border-top: 0;
  }

  .dataset-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border: 0;
    background: transparent !important;
  }

  .dataset-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.07em;
    line-height: 1.4;
    text-transform: uppercase;
  }

  .dataset-table td:first-child {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-bottom: 10px !important;
    border-bottom: 1px solid var(--line);
  }

  .dataset-table td:first-child::before {
    content: none;
  }

  .dataset-table td.feature-cell::before {
    color: var(--teal-deep);
  }

  .dataset-table td.outcome-cell {
    grid-column: 1 / -1;
  }

  .table-key {
    display: grid;
    gap: 7px;
    padding: 14px 18px;
  }

  .table-key p {
    font-size: 10.5px;
  }

  .vector-legend {
    grid-template-columns: 1fr;
  }

  .vector-legend > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .matrix-scene {
    justify-content: flex-start;
  }

  .matrix-join {
    padding-top: 62px;
  }

  .matrix-annotations {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .matrix-annotations > div {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    align-items: baseline;
    gap: 2px 10px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--line);
  }

  .matrix-annotations > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .matrix-annotations div > span:last-child {
    grid-column: 2;
  }

  .lab-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .lab-hint {
    max-width: 56ch;
    text-align: left;
  }

  .lab-controls {
    display: block;
  }

  .results-labels {
    display: none;
  }

  .result-row {
    grid-template-columns: 30px minmax(0, 1fr) 70px minmax(54px, 0.6fr);
    gap: 9px;
  }

  .result-name {
    font-size: 12.5px;
  }

  .quiz-options {
    grid-template-columns: 1fr;
  }

  .quiz-card {
    padding: 18px;
  }

  .quiz-card legend {
    font-size: 18px;
  }

  .lesson-footer {
    flex-direction: column;
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .shell {
    width: calc(100% - 32px);
  }

  .header-inner {
    min-height: 60px;
    gap: 12px;
  }

  .brand {
    font-size: 18px;
  }

  .brand-mark {
    width: 24px;
    height: 24px;
  }

  .header-query-link {
    padding: 7px 10px;
    font-size: 11px;
  }

  .hero-grid {
    padding-bottom: 34px;
  }

  .hero h1 {
    font-size: clamp(40px, 12.4vw, 54px);
  }

  .hero-actions {
    align-items: stretch;
  }

  .button-primary {
    width: 100%;
  }

  .hero-meta {
    font-size: 9.5px;
  }

  .hero-figure {
    padding: 10px 10px 8px;
    border-radius: var(--radius-m);
  }

  .figure-topline {
    padding-bottom: 8px;
  }

  .hero-figure figcaption {
    font-size: 11.5px;
  }

  .table-card-head {
    padding: 18px 16px 14px;
  }

  .dataset-table tr {
    padding: 13px 16px;
  }

  .table-key {
    padding-inline: 16px;
  }

  .section-head h2 {
    font-size: clamp(31px, 9.2vw, 40px);
  }

  .lede {
    font-size: 16.5px;
  }

  .prose {
    font-size: 16px;
  }

  .formula-card {
    border-radius: var(--radius-m);
  }

  .formula {
    font-size: clamp(18px, 5.4vw, 24px);
  }

  .formula .sqrt::before {
    font-size: 1.45em;
  }

  .formula-legend {
    display: grid;
    gap: 5px;
  }

  .calc-steps li {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .step-label {
    font-size: 9px;
  }

  .matrix-unit {
    width: 200px;
  }

  .matrix-unit--query {
    width: 146px;
  }

  .matrix-join {
    display: none;
  }

  .matrix-stage {
    padding: 18px;
  }

  .matrix-scene {
    gap: 20px;
  }

  .matrix-values {
    font-size: 13px;
  }

  .matrix-annotations > div {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .lab-panel {
    border-radius: 18px;
    padding: 16px;
  }

  .lab-controls {
    padding: 17px;
  }

  .query-vector {
    font-size: 29px;
  }

  .preset-list {
    gap: 6px;
  }

  .preset-chip {
    min-height: 40px;
  }

  .lab-chart {
    padding: 12px 10px 10px;
  }

  .chart-head {
    padding-inline: 2px;
  }

  .chart-legend {
    gap: 6px 10px;
  }

  .results-panel {
    padding: 15px;
  }

  .result-row {
    grid-template-columns: 24px minmax(0, 1fr) 62px;
    gap: 7px 8px;
    padding: 10px 0;
  }

  .result-bar {
    grid-column: 2 / -1;
    height: 4px;
  }

  .result-vector {
    font-size: 9.5px;
  }

  .result-distance {
    font-size: 12px;
  }

  .result-badge {
    padding: 2px 4px;
    font-size: 7px;
  }

  .quiz-card {
    padding: 16px;
  }

  .quiz-card legend {
    font-size: 17px;
  }

  .quiz-option {
    font-size: 12.5px;
  }

  .recap-panel {
    border-radius: 18px;
    padding: 24px 20px;
  }

  .recap-points {
    margin-top: 28px;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
