/* v2 handbook page (2026-10-07). Loaded after v2.css on handbook.html only.
   The figure and chapter CSS is ported from the old inline <style>; its legacy
   tokens are aliased to the v2 theme tokens below, so the figures follow light
   and dark mode without per-figure colour overrides. */

:root {
  --ink: var(--fg);
  --ink-2: var(--fg-2);
  --paper: var(--bg);
  --paper-cool: var(--surface);
  --paper-warm: var(--surface);
  --mute-1: var(--fg-2);
  --mute-2: var(--muted);
  --mute-3: var(--faint);
  --signal: var(--accent);
  --signal-wash: var(--accent-wash);
  --neg: var(--accent);
  --rule-strong: color-mix(in srgb, var(--fg) 20%, var(--bg));
  --bw-rule: 1px;
  --bw-strong: 1.5px;
  --r-pill: 999px;
  --font-serif: var(--font-sans);   /* v2 is Geist only */
  --ease-out: cubic-bezier(.2,.7,.2,1);
  --hb-head: 76px;                  /* sticky header height, set by v2-handbook.js */
  --hb-bar: 0px;                    /* contents bar height (narrow screens), set by v2-handbook.js */
}

/* ── Layout: the text column lines up with the v2 header (640px + gutters);
      the contents list sits in the left margin on wide screens. ── */
.kd-handbook-wrap {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, calc(var(--col) + var(--gutter) * 2)) minmax(0, 1fr);
}
.kd-handbook-main {
  grid-column: 2; grid-row: 1;
  min-width: 0;
  padding: 32px var(--gutter) 80px;
  background: var(--bg);
}
.kd-handbook-main section, .kd-handbook-figure, .fig-card { min-width: 0; max-width: 100%; }
.kd-handbook-main section + section { margin-top: 72px; }
.kd-handbook-main pre { max-width: 100% !important; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.kd-handbook-main :not(pre) > code { font-family: var(--font-mono); font-size: .9em; overflow-wrap: anywhere; word-break: break-word; }
.kd-handbook-main [id] { scroll-margin-top: calc(var(--hb-head) + var(--hb-bar) + 20px); }
.kd-handbook-main em { font-style: italic; }

/* ── Contents: sticky panel in the left margin (wide screens) ── */
.kd-handbook-sidebar {
  grid-column: 1; grid-row: 1;
  justify-self: end; align-self: start;
  width: 232px; margin-right: 16px;
  position: sticky; top: calc(var(--hb-head) + 16px);
  max-height: calc(100vh - var(--hb-head) - 32px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 16px 24px;
  background: var(--bg);
  border: 1px solid var(--rule); border-radius: 10px;
  scrollbar-width: thin; scrollbar-color: var(--rule) transparent;
}
.kd-toc-title { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 16px; }
.kd-toc-part { margin-bottom: 16px; }
.kd-toc-part-label {
  font-family: var(--font-mono); font-weight: 500; font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint);
  margin-bottom: 6px; padding-left: 10px;
}
.kd-toc-list { list-style: none; }
.kd-toc-link {
  display: block; font-size: 13px; line-height: 1.4; color: var(--muted);
  text-decoration: none; padding: 5px 10px; border-left: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.kd-toc-link:hover { color: var(--fg); }
.kd-toc-link.active { color: var(--fg); font-weight: 500; border-left-color: var(--accent); }

/* Contents button (narrow screens only) */
.kd-toc-toggle { display: none; }

/* ── Narrow screens (no room for the margin panel): a contents bar under the
      header that opens a drop-down list. ── */
@media (max-width: 1259px) {
  .kd-toc-toggle {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: var(--hb-head); z-index: 40;
    width: 100%; max-width: calc(var(--col) + var(--gutter) * 2); margin: 0 auto;
    min-height: 44px; padding: 0 var(--gutter);
    background: var(--bg); color: var(--fg);
    border: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
    font: 500 14px var(--font-sans); text-align: left; cursor: pointer;
  }
  .kd-toc-toggle::after {
    content: ''; width: 7px; height: 7px; margin-right: 3px;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg); transition: transform .25s var(--ease-out);
  }
  .kd-toc-toggle.open::after { transform: translateY(2px) rotate(-135deg); }
  .kd-handbook-sidebar {
    position: fixed; z-index: 39;
    top: calc(var(--hb-head) + var(--hb-bar));
    left: 50%; transform: translate(-50%, -8px);
    width: min(calc(var(--col) + var(--gutter) * 2), 100vw); margin: 0;
    max-height: calc(100vh - var(--hb-head) - var(--hb-bar) - 16px);
    border-radius: 0 0 10px 10px; border-top: 0;
    box-shadow: 0 18px 30px -24px rgba(0,0,0,.35);
    padding: 16px var(--gutter) 20px;
    visibility: hidden; opacity: 0;
    transition: opacity .2s, transform .25s var(--ease-out), visibility 0s .25s;
  }
  .kd-handbook-sidebar.open { visibility: visible; opacity: 1; transform: translate(-50%, 0); transition: opacity .2s, transform .25s var(--ease-out); }
  .kd-toc-link { padding: 11px 10px; font-size: 15px; }   /* about 44px tap targets */
  .kd-toc-part-label { margin-top: 4px; }
}
@media (max-width: 640px) {
  /* Phones: the contents list is a full-height sheet, so no page text shows under it. */
  .kd-handbook-sidebar {
    border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0;
    height: calc(100vh - var(--hb-head) - var(--hb-bar));
    height: calc(100dvh - var(--hb-head) - var(--hb-bar));
    max-height: none; padding-bottom: 32px;
  }
  .kd-handbook-main { padding: 24px var(--gutter) 64px; }
}

/* ── Chapter text (ported) ── */
/* Chapter header */
.kd-chapter-eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--signal);
  margin-bottom: 12px;
}

/* Accessible page title. The book has no visible title block, so the single
   H1 is exposed to assistive tech and crawlers without altering the layout. */
.kd-visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.kd-handbook-main h2 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 32px;
}

/* Body content */
.kd-handbook-main h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 48px 0 16px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  color: var(--ink);
}

.kd-handbook-main h3:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border: 0;
}

.kd-handbook-main p {
  font-size: 17px;
  line-height: 1.7;
  color: var(--mute-1);
  margin-bottom: 18px;
  max-width: 640px;
}

.kd-handbook-main strong {
  color: var(--ink);
  font-weight: 500;
}

.kd-handbook-signature {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 24px;
  line-height: 1.25;
  color: var(--ink);
  margin: 32px 0 0;
}

.kd-handbook-signature + .kd-handbook-signature {
  margin-top: 4px;
}

/* Chapter nav (prev/next) */
.kd-chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 32px 0;
  border-top: 1px solid var(--rule);
  margin-top: 64px;
}

.kd-chapter-nav a {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 14px;
  color: var(--mute-1);
  text-decoration: none;
  transition: color 150ms;
}

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

.kd-chapter-nav-disabled {
  color: var(--mute-3) !important;
  pointer-events: none;
}

/* Disclaimer */
.kd-handbook-disclaimer {
  margin-top: 48px;
  padding: 20px 24px;
  background: var(--signal-wash);
  border-left: 2px solid var(--signal);
  max-width: 640px;
}

.kd-handbook-disclaimer p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 0;
}


/* v2 type: Geist only, so the old serif italic chapter titles and signature
   take the v2 heading style. */
.kd-handbook-main h2 { font-family: var(--font-sans); font-style: normal; font-weight: 600; font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.03em; margin-bottom: 28px; }
.kd-handbook-main h3 em { font-style: normal; color: var(--muted); font-weight: 500; }
.kd-handbook-signature { font-family: var(--font-sans); font-style: normal; font-size: 17px; font-weight: 500; }
.kd-handbook-disclaimer { border-radius: 0 8px 8px 0; }
@media (max-width: 640px) {
  .kd-chapter-nav { flex-wrap: wrap; gap: 4px 16px; }
  .kd-chapter-nav a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ── Print (ported; v2 chrome hidden) ── */
@media print {
  @page {
    size: A4;
    margin: 18mm 16mm;
  }

  body {
    background: #fff;
  }

  .kd-progress,
  .site-header,
  .menu-panel,
  .kd-toc-toggle,
  .kd-handbook-sidebar,
  .kd-chapter-nav,
  .site-footer,
  .ambient {
    display: none !important;
  }

  .kd-handbook-wrap {
    display: block;
  }

  .kd-handbook-main {
    max-width: none;
    padding: 0;
  }

  .kd-handbook-main section {
    break-before: page;
  }

  .kd-handbook-main section:first-child {
    break-before: auto;
  }

  .kd-handbook-main h2,
  .kd-handbook-main h3,
  .kd-handbook-figure,
  .kd-handbook-disclaimer {
    break-inside: avoid;
  }

  .kd-handbook-main p {
    max-width: none;
  }
}


/* ── Figures (ported verbatim; colours come through the aliases above) ── */
/* ── Visual aid figures ── */
.kd-handbook-figure {
  margin: 40px 0;
}

.figure {
  margin-top: 0;
}

.fig-card {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 30px 32px 32px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fig-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 26px;
}

.fig-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin: 0;
  max-width: 44ch;
}

.illus {
  flex: none;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute-2);
  border: 1px solid var(--rule);
  padding: 5px 8px;
  white-space: nowrap;
}

.fig-cap {
  display: flex;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
}

.fig-cap .k {
  flex: none;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute-2);
  padding-top: 2px;
  width: 78px;
}

.fig-cap .t {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
  max-width: 60ch;
}

.fig-cap .t em {
  font-family: var(--font-serif);
  font-style: italic;
}

.flow2 {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
}

.flow-col {
  padding: 0 26px;
}

.flow-col:first-child {
  padding-left: 0;
}

.flow-col:last-child {
  padding-right: 0;
}

.flow-div {
  background: var(--rule);
  width: 1px;
}

.flow-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 18px;
}

.flow-label .lab {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}

.flow-label .sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mute-3);
}

.node {
  position: relative;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  padding: 11px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.node .n {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mute-3);
  font-variant-numeric: tabular-nums;
}

.node .lab {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.node.skill {
  border-color: var(--ink);
}

.arrow-v {
  display: flex;
  justify-content: center;
  padding: 7px 0;
}

.arrow-v svg {
  display: block;
}

.flow-stack {
  position: relative;
}

.skill-flag {
  position: absolute;
  left: -26px;
  top: 0;
  width: 14px;
  border-left: var(--bw-strong) solid var(--signal);
}

.flow-foot {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flow-foot .sq {
  width: 9px;
  height: 9px;
  background: var(--signal);
  flex: none;
}

.flow-foot .tx {
  font-size: 13px;
  line-height: 1.45;
  color: var(--mute-1);
}

.flow-foot .tx b {
  color: var(--ink);
  font-weight: 600;
}

.chart {
  width: 100%;
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-key {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 18px;
}

.chart-key .item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--mute-1);
}

.chart-key .swatch {
  width: 16px;
  height: 0;
  border-top-width: 2px;
  border-top-style: solid;
}

.chart-key .swatch.bar {
  height: 11px;
  border-top: 0;
  width: 8px;
}

.formula {
  margin-top: 20px;
  background: var(--paper-cool);
  border-left: var(--bw-strong) solid var(--ink);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.formula .k {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute-2);
}

.formula .eq {
  font-family: var(--font-mono);
  font-size: 13.5px;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.formula .eq .red {
  color: var(--signal);
}

.settings {
  border-top: 1px solid var(--rule);
}

.set-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
}

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

.set-row .st {
  color: var(--mute-3);
  margin-top: 1px;
}

.set-row .st svg {
  width: 16px;
  height: 16px;
  display: block;
}

.set-row.trap .st {
  color: var(--signal);
}

.set-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.set-main .name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.set-main .note {
  font-size: 12.5px;
  color: var(--mute-1);
  line-height: 1.45;
}

.set-main .note .flag {
  color: var(--signal);
  font-weight: 600;
}

.set-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  text-align: right;
  padding-top: 1px;
}

.anatomy {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.anat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  width: 100%;
}

.anat-card {
  border: 1px solid var(--rule-strong);
  padding: 15px 14px;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.anat-card .n {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mute-3);
}

.anat-card .nm {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.anat-card .ds {
  font-size: 12px;
  color: var(--mute-1);
  line-height: 1.4;
}

.anat-connect {
  width: 100%;
}

.anat-connect svg {
  display: block;
  width: 100%;
  height: auto;
}

.anat-out {
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 13px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.anat-out .sq {
  width: 9px;
  height: 9px;
  background: var(--signal);
  flex: none;
}

.anat-out .nm {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.anat-foot {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.anat-foot .sq {
  width: 9px;
  height: 9px;
  background: var(--signal);
  flex: none;
}

.anat-foot .tx {
  font-size: 13px;
  line-height: 1.45;
  color: var(--mute-1);
}

.anat-foot .tx b {
  color: var(--ink);
  font-weight: 600;
}

.tl-bar {
  display: grid;
  grid-template-columns: 25fr 60fr 15fr;
  border: 1px solid var(--rule-strong);
}

.tl-seg {
  padding: 15px 15px 16px;
  border-right: 1px solid var(--rule-strong);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 104px;
}

.tl-seg:last-child {
  border-right: 0;
}

.tl-seg .ph {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute-2);
}

.tl-seg .nm {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tl-seg .ds {
  font-size: 12px;
  color: var(--mute-1);
  line-height: 1.4;
}

.tl-seg .pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--mute-2);
  margin-top: auto;
}

.tl-seg.val {
  background: var(--paper-cool);
}

.tl-seg.hold {
  box-shadow: inset 0 0 0 1.5px var(--signal);
}

.tl-seg.hold .lockrow {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--signal);
}

.tl-seg.hold .lockrow svg {
  width: 14px;
  height: 14px;
}

.tl-seg.hold .lockrow .lab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
}

.tl-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--mute-3);
}

.dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.dual .pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dual .pane .cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.dual .pane .cap .nm {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dual .pane .cap .t2 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute-2);
}

.dual .pane.bad .cap .t2 {
  color: var(--signal);
}

table.matrix {
  width: 100%;
  border-collapse: collapse;
}

table.matrix th,
table.matrix td {
  text-align: left;
  vertical-align: top;
  padding: 16px 20px 16px 0;
  border-bottom: 1px solid var(--rule);
}

table.matrix th:not(:first-child),
table.matrix td:not(:first-child) {
  padding-right: 16px;
}

table.matrix thead th {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute-2);
  font-weight: 500;
  border-bottom: 1.5px solid var(--ink);
  padding-top: 0;
  padding-bottom: 11px;
  white-space: nowrap;
}

table.matrix thead th.fail {
  color: var(--signal);
}

table.matrix .matrix-head-cell {
  display: inline-flex;
  align-items: center;
}

table.matrix .reddot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--signal);
  margin-left: 7px;
}

table.matrix tbody th {
  width: 22%;
}

table.matrix tbody th .tname {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: block;
}

table.matrix td {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--mute-1);
}

table.matrix td.pass {
  color: var(--ink);
}

table.matrix td.fail {
  color: var(--signal);
}

table.matrix tbody tr:last-child th,
table.matrix tbody tr:last-child td {
  border-bottom: 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--rule);
}

.metric {
  padding: 18px 18px 20px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.metric:nth-child(3n) {
  border-right: 0;
}

.metric:nth-child(n+4) {
  border-bottom: 0;
}

.metric .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute-2);
}

.metric .val {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1;
}

.metric .val.neg {
  color: var(--neg);
}

.metric .sub {
  font-size: 11.5px;
  color: var(--mute-1);
  line-height: 1.35;
}

.corr {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
}

.corr .panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.corr .phead {
  display: flex;
  align-items: center;
  gap: 8px;
}

.corr .phead .sq {
  width: 8px;
  height: 8px;
  background: var(--signal);
}

.corr .phead .nm {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}

.cgrid {
  display: grid;
  grid-template-columns: 22px repeat(5, 1fr);
  gap: 3px;
}

.cgrid .cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.cgrid .hd {
  color: var(--mute-2);
  aspect-ratio: auto;
}

.corr-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--mute-2);
  margin-top: 2px;
}

.corr-legend .ramp {
  display: flex;
  gap: 2px;
}

.corr-legend .ramp i {
  width: 14px;
  height: 10px;
}

.checklist {
  border-top: 1px solid var(--rule);
}

.check-row {
  display: grid;
  grid-template-columns: 26px 22px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
}

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

.check-row .num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mute-3);
}

.check-row .box {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}

.check-row .box svg {
  width: 13px;
  height: 13px;
}

.check-row .lab {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.check-row .hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mute-2);
  text-align: right;
}

.check-row.key .box {
  border-color: var(--signal);
  color: var(--signal);
}

.check-row.key .hint {
  color: var(--signal);
  font-weight: 600;
}

.orders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.ord {
  border: 1px solid var(--rule);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ord .ohead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.ord .ohead .nm {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ord .ohead .t2 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute-2);
}

.ord .obody {
  font-size: 12px;
  color: var(--mute-1);
  line-height: 1.45;
}

.ord-blocks {
  display: flex;
  gap: 6px;
  height: 34px;
}

.ord-blocks .blk {
  background: var(--ink);
  flex: 1;
}

.ord-blocks.one .blk {
  flex: 1 1 100%;
}

.impact {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.impact .irow {
  display: flex;
  align-items: center;
  gap: 12px;
}

.impact .lab {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute-2);
}

.impact .track {
  flex: 1;
  height: 10px;
  background: var(--paper-cool);
  position: relative;
}

.impact .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--ink);
}

.impact .fill.red {
  background: var(--signal);
}

.impact .val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.impact .val.red {
  color: var(--signal);
}

table.routes {
  width: 100%;
  border-collapse: collapse;
}

table.routes th,
table.routes td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}

table.routes thead th {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mute-2);
  font-weight: 500;
  border-bottom: 1.5px solid var(--ink);
}

table.routes thead th:not(:first-child) {
  text-align: center;
}

table.routes tbody th {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  width: 32%;
}

table.routes tbody th .sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  color: var(--mute-2);
  margin-top: 3px;
  letter-spacing: 0;
  text-transform: none;
}

table.routes tbody tr:last-child th,
table.routes tbody tr:last-child td {
  border-bottom: 0;
}

td.rate {
  text-align: center;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots i {
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  border: 1px solid var(--mute-2);
  box-sizing: border-box;
}

.dots i.on {
  background: var(--ink);
  border-color: var(--ink);
}

.routes-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.routes-foot .sq {
  width: 9px;
  height: 9px;
  background: var(--signal);
  flex: none;
  margin-top: 3px;
}

.routes-foot .tx {
  font-size: 12px;
  line-height: 1.45;
  color: var(--mute-1);
}

.routes-foot .tx b {
  color: var(--ink);
  font-weight: 600;
}

.tree {
  display: flex;
  flex-direction: column;
}

.tree-start {
  align-self: flex-start;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tree-step {
  display: grid;
  grid-template-columns: 320px 64px 1fr;
  align-items: center;
}

.tree-check {
  border: 1px solid var(--rule-strong);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tree-check .n {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute-3);
}

.tree-check .q {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.tree-conn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-conn svg {
  display: block;
}

.tree-action {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--mute-1);
}

.tree-action .a {
  color: var(--ink);
  font-weight: 600;
}

.tree-down {
  padding-left: 152px;
  justify-content: flex-start;
}

.tree-down .lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute-3);
  margin-left: 12px;
  align-self: center;
}

.tree-term {
  align-self: flex-start;
  border: 1.5px solid var(--signal);
  color: var(--signal);
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tree-term .sq {
  width: 9px;
  height: 9px;
  background: var(--signal);
  flex: none;
}

@media (max-width: 640px) {
  .flow2 {
    grid-template-columns: 1fr;
  }

  .flow-div {
    display: none;
  }

  .flow-col {
    padding: 0;
  }

  .flow-col+.flow-col {
    margin-top: 28px;
  }

  .anat-row {
    grid-template-columns: 1fr 1fr;
  }

  .dual,
  .corr,
  .orders,
  .metrics {
    grid-template-columns: 1fr;
  }

  .metric:nth-child(n+4) {
    border-bottom: 1px solid var(--rule);
  }

  .metric:nth-child(3n) {
    border-right: 1px solid var(--rule);
  }

  .metric {
    border-right: 0 !important;
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .tree-step {
    grid-template-columns: 1fr;
  }

  .tree-conn {
    display: none;
  }

  .tree-action {
    padding: 8px 0 4px 14px;
  }

  .tree-down {
    padding-left: 20px;
  }

  .fig-card {
    padding: 22px 18px;
  }

  .fig-cap {
    flex-direction: column;
    gap: 6px;
  }

  .fig-cap .k {
    width: auto;
  }

  .formula .eq {
    overflow-wrap: anywhere;
  }

  .set-row {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .set-val {
    grid-column: 2;
    text-align: left;
    white-space: normal;
  }

  .tl-bar {
    grid-template-columns: 1fr;
  }

  .tl-seg {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule-strong);
  }

  .tl-seg:last-child {
    border-bottom: 0;
  }

  .tl-axis {
    display: none;
  }

  .check-row {
    grid-template-columns: 26px 22px minmax(0, 1fr);
    align-items: start;
  }

  .check-row .hint {
    grid-column: 3;
    text-align: left;
  }

  .impact .irow {
    flex-wrap: wrap;
  }

  .impact .track {
    flex: 1 1 100%;
    order: 2;
  }
}

@media (max-width: 480px) {
  .anat-row {
    grid-template-columns: 1fr;
  }
}

.fig-card { border-radius: 10px; }
.fig-cap .t em { font-family: var(--font-sans); font-style: italic; }

/* Subscribe blocks inside the handbook (after chapter 12 and at the end). The form
   uses the shared Substack hand-off in v2.js (form.sub-form). Selectors carry
   .kd-handbook-main so they beat the handbook's own h2/p rules. */
.kd-handbook-main .hb-sub {
  margin: 40px 0; padding: 22px 22px 18px; max-width: 640px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--surface);
}
.kd-handbook-main .hb-sub p { max-width: none; margin: 0; font-size: 15px; line-height: 1.55; color: var(--fg-2); }
.kd-handbook-main .hb-sub .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kd-handbook-main .hb-sub .hb-sub-h {
  font-family: var(--font-sans); font-style: normal; font-weight: 600;
  font-size: 20px; line-height: 1.25; letter-spacing: -0.015em; color: var(--fg); margin: 0 0 6px;
}
.kd-handbook-main .hb-sub .hb-sub-p { margin-bottom: 14px; }
.kd-handbook-main .hb-sub .fine { font-size: 12px; color: var(--muted); margin-top: 10px; }
.kd-handbook-main .hb-sub .sub-status { margin-top: 10px; }
@media (max-width: 520px) {
  .kd-handbook-main .hb-sub { padding: 18px 16px 14px; }
  .hb-sub .sub-form { flex-direction: column; }
  .hb-sub .sub-form input[type="email"], .hb-sub .sub-form .btn { height: 44px; flex: none; }
  .hb-sub .sub-form .btn { justify-content: center; }
}
