/* ==========================================================================
   Spellworks · handbook (agent D)
   A long-form service manual: sticky contents, numbered sections, plates,
   inline SVG diagrams, and three bench instruments (key tester, TV test
   signal, bridge tester). Tokens only; the TV screen is the one place
   with hardcoded colours.
   ========================================================================== */

/* --------------------------------------------------------------------------
   hero
   -------------------------------------------------------------------------- */
.hb-hero { padding-top: clamp(40px, 6vw, 96px); padding-bottom: clamp(40px, 5vw, 72px); }
.hb-hero__grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(16px, 2vw, 32px);
  row-gap: 2rem;
  align-items: end;
}
.hb-hero__text { grid-column: 1 / span 7; display: grid; gap: 1.4rem; align-content: end; }
.hb-hero__title { max-width: 13ch; }
.hb-hero__lede { max-width: 44ch; }
.hb-hero__plate { grid-column: 8 / -1; margin: 0; }
.hb-hero__plate img {
  width: 100%;
  aspect-ratio: 4 / 3.4;
  object-fit: cover;
  object-position: 50% 40%;
  border-radius: var(--r);
}
.hb-hero__plate figcaption, .hb-plate figcaption {
  display: flex;
  gap: 0.8rem;
  align-items: baseline;
  margin-top: 0.8rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--fg-3);
}
.hb-hero__plate figcaption .t-label, .hb-plate figcaption .t-label { flex: 0 0 auto; }
.hb-legend { list-style: none; margin: 0.2rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem 1.6rem; font-size: 0.8rem; color: var(--fg-3); }
.hb-legend li { display: inline-flex; align-items: center; gap: 0.55rem; }
.hb-legend__mark { width: 1.1rem; height: 0; border-top: 2px solid var(--fg); display: inline-block; }
.hb-legend__mark--warn { border-top-color: var(--alert); }
.hb-stats { margin-top: clamp(40px, 5vw, 72px); }
.hb-stats .stat__n small { font-size: 0.42em; letter-spacing: 0; margin-left: 0.08em; color: var(--fg-2); }

/* "to confirm": the honest marker */
.tbc {
  display: inline-flex;
  align-items: center;
  padding: 0.12em 0.6em 0.1em;
  border: 1px dashed var(--hair-2);
  border-radius: var(--r-pill);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 118;
  font-weight: 600;
  font-size: 0.56rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
  vertical-align: 0.12em;
  line-height: 1.3;
}

/* --------------------------------------------------------------------------
   layout: contents + main column
   -------------------------------------------------------------------------- */
.hb-layout {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: clamp(16px, 2vw, 32px);
  border-top: 1px solid var(--hair);
}
.hb-toc { grid-column: 1 / span 3; padding-top: clamp(40px, 5vw, 72px); }
.hb-main { grid-column: 4 / -1; min-width: 0; }
.hb-toc .toc { padding-bottom: 2rem; }
.hb-toc__label { margin-bottom: 0.8rem; }
.hb-toc .toc a { font-size: 0.86rem; }
.hb-toc .toc a[aria-current="true"] { color: var(--fg); }
.hb-toc .toc a[aria-current="true"] .n { color: var(--signal-ink); }
@media (min-width: 1081px) {
  .hb-toc .toc a {
    padding-left: 0.65rem;
    border-left: 2px solid transparent;
  }
  .hb-toc .toc a[aria-current="true"] {
    border-left-color: var(--signal-ink);
  }
}
.hb-toc__files { display: grid; gap: 0.35rem; margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--hair); }
.hb-toc__files .t-label { margin-bottom: 0.4rem; }
.hb-toc .hb-toc__files a { display: block; padding: 0.12rem 0; font-family: var(--f-mono); font-size: 0.74rem; line-height: 1.5; color: var(--fg-3); text-decoration: none; overflow-wrap: anywhere; }
.hb-toc .hb-toc__files a:hover { color: var(--fg); }

@media (max-width: 1080px) {
  .hb-layout { display: block; }
  .hb-toc {
    position: sticky;
    top: var(--header-h);
    z-index: 30;
    padding-top: 0;
    margin: 0 calc(-1 * var(--gutter));
    background: var(--bg);
    border-bottom: 1px solid var(--hair);
  }
  .hb-toc .toc {
    position: static;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.55rem var(--gutter);
  }
  .hb-toc__label, .hb-toc__files { display: none; }
  .hb-toc .toc ol { grid-auto-flow: column; grid-auto-columns: max-content; gap: 0.4rem; }
  .hb-toc .toc a {
    display: inline-flex;
    gap: 0.5em;
    align-items: baseline;
    padding: 0.42rem 0.85rem;
    border: 1px solid var(--hair-2);
    border-radius: var(--r-pill);
    font-size: 0.74rem;
    white-space: nowrap;
  }
  .hb-toc .toc a[aria-current="true"] { background: var(--solid-bg); color: var(--solid-fg); border-color: var(--solid-bg); }
  .hb-toc .toc a[aria-current="true"] .n { color: inherit; }
  [id] { scroll-margin-top: calc(var(--header-h) + 72px); }
}

/* --------------------------------------------------------------------------
   sections
   -------------------------------------------------------------------------- */
.hb-sec { padding-top: clamp(48px, 6vw, 96px); padding-bottom: clamp(48px, 6vw, 96px); display: grid; gap: 1.6rem; }
.hb-sec + .hb-sec { border-top: 1px solid var(--hair); }
.hb-sec > * { min-width: 0; }
.hb-run {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--f-body);
  font-variation-settings: "wdth" 125;
  font-weight: 600;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.hb-run::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--hair); }
.hb-run__n { font-family: var(--f-mono); font-size: 0.86rem; letter-spacing: 0; color: var(--fg); }
.hb-sec__title { max-width: 18ch; margin-top: -0.2rem; }
.hb-intro {
  font-family: var(--f-display);
  font-size: clamp(1.12rem, 1.35vw, 1.3rem);
  line-height: 1.5;
  font-weight: 360;
  color: var(--fg-2);
  max-width: 52ch;
  text-wrap: pretty;
}

/* the recommendation, always first */
.hb-rec {
  display: grid;
  gap: 0.55rem;
  padding: 0.25rem 0 0.25rem 1.3rem;
  border-left: 2px solid var(--fg);
  max-width: 62ch;
}
.hb-rec .t-label { color: var(--fg); }
.hb-rec__text {
  font-family: var(--f-display);
  font-size: clamp(1.14rem, 1.45vw, 1.36rem);
  line-height: 1.45;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-wrap: pretty;
}

/* sub headings with manual numbering */
.hb-h3 {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin-top: 1.4rem;
  font-family: var(--f-display);
  font-size: clamp(1.3rem, 1.8vw, 1.6rem);
  line-height: 1.2;
  font-weight: 420;
  letter-spacing: -0.015em;
}
.hb-h3__n { flex: 0 0 auto; font-family: var(--f-mono); font-size: 0.8rem; font-weight: 400; letter-spacing: 0; color: var(--fg-3); transform: translateY(-0.12em); }
.hb-h3 code { font-size: 0.82em; }

.hb-main .prose { max-width: 68ch; }
.hb-main .prose p, .hb-main .prose li { text-wrap: pretty; }
.hb-after { margin-top: -0.6rem; }

/* plates (photos) */
.hb-plate { margin: 0.4rem 0; }
.hb-plate img { width: 100%; border-radius: var(--r); aspect-ratio: 16 / 7.6; object-fit: cover; }
.hb-plate--tall { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 1.6rem; align-items: end; }
.hb-plate--tall img { aspect-ratio: 4 / 4.2; object-position: 50% 30%; }
.hb-plate--tall figcaption { flex-direction: column; gap: 0.5rem; margin: 0; padding-bottom: 0.4rem; max-width: 28ch; }
@media (max-width: 640px) {
  .hb-plate--tall { grid-template-columns: 1fr; }
  .hb-plate img { aspect-ratio: 4 / 3; }
}

/* figures and diagrams */
.hb-fig { margin: 0.6rem 0; display: grid; gap: 0.9rem; }
.hb-fig figcaption {
  display: block;
  padding-top: 0.8rem;
  border-top: 1px solid var(--hair);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--fg-3);
  max-width: 78ch;
}
.hb-fig__n { font-family: var(--f-mono); color: var(--fg-2); margin-right: 0.55rem; }
.hb-fig__hint { color: var(--signal-ink); white-space: nowrap; }
@media (hover: none) { .hb-fig__hint { display: none; } }

.dg { width: 100%; color: var(--fg); }
.dg svg { width: 100%; height: auto; overflow: visible; }
.dg-edge { fill: none; stroke: var(--hair-2); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.dg-edge--signal { stroke: color-mix(in srgb, var(--signal-ink) 70%, transparent); }
.dg-edge--glow { stroke: color-mix(in srgb, var(--glow-ink) 75%, transparent); }
.dg-edge--alert { stroke: color-mix(in srgb, var(--alert-ink) 75%, transparent); }
.dg-edge--dash { stroke-dasharray: 3 4; }
.dg-edge.is-lit { stroke: var(--signal); stroke-width: 2; }
.dg-node rect { fill: var(--bg); stroke: var(--hair-2); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.dg-node--signal rect { stroke: color-mix(in srgb, var(--signal-ink) 70%, transparent); }
.dg-node--glow rect { stroke: color-mix(in srgb, var(--glow-ink) 75%, transparent); }
.dg-node--alert rect { stroke: color-mix(in srgb, var(--alert-ink) 75%, transparent); }
.dg-node--solid rect { fill: var(--bg-2); stroke: var(--fg-2); }
.dg-node--ghost rect { stroke-dasharray: 3 4; fill: transparent; }
.dg-node__t {
  font-family: var(--f-body);
  font-variation-settings: "wdth" 120;
  font-weight: 650;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  fill: var(--fg);
}
.dg-node__s { font-family: var(--f-body); font-size: 13px; fill: var(--fg-2); }
.dg-node__m { font-family: var(--f-mono); font-size: 12px; fill: var(--fg-3); }
.dg-node--signal .dg-node__t { fill: var(--signal-ink); }
.dg-node--glow .dg-node__t { fill: var(--glow-ink); }
.dg-node--alert .dg-node__t { fill: var(--alert-ink); }
.dg-label { font-family: var(--f-mono); font-size: 11.5px; fill: var(--fg-3); }
.dg-label-bg { fill: var(--bg); }
.dg-group { fill: none; stroke: var(--hair); stroke-width: 1; stroke-dasharray: 2 5; vector-effect: non-scaling-stroke; }
.dg-group__t { font-family: var(--f-body); font-variation-settings: "wdth" 125; font-weight: 600; font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; fill: var(--fg-3); }
.dg-pulse { fill: var(--signal); }
.dg-pulse-halo { fill: var(--signal); opacity: 0.22; }

/* the hand-drawn key lever (fig 02.1) */
.hb-lever { color: var(--fg); padding: 0.6rem 0; }
.hb-lever__svg { width: 100%; max-width: 720px; height: auto; overflow: visible; }
.lv-key { fill: var(--bg-2); stroke: var(--fg-2); stroke-width: 1.25; }
.lv-line { stroke: var(--fg-2); stroke-width: 2; fill: none; stroke-linecap: round; }
.lv-line--soft { stroke: var(--hair-2); stroke-width: 1.5; }
.lv-lever { stroke: var(--fg); stroke-width: 6; stroke-linecap: round; fill: none; }
.lv-ghost { stroke: var(--fg-3); stroke-width: 1.25; stroke-dasharray: 4 5; fill: none; }
.lv-pivot { fill: var(--bg); stroke: var(--fg); stroke-width: 2; }
.lv-mag { fill: var(--glow); stroke: none; }
.lv-mag--ghost { fill: none; stroke: var(--glow-ink); stroke-dasharray: 3 3; }
.lv-board { fill: var(--bg-3); stroke: var(--hair-2); }
.lv-chip { fill: var(--signal); }
.lv-dim { stroke: var(--fg-3); stroke-width: 1.25; color: var(--fg-3); }
.lv-t { font-family: var(--f-body); font-size: 13px; fill: var(--fg-2); }
.lv-t--mono { font-family: var(--f-mono); font-size: 12px; fill: var(--fg-3); }
.lv-t--glow { fill: var(--glow-ink); }
.lv-t--signal { fill: var(--signal-ink); }

/* tables */
.hb-tablewrap { margin: 0.2rem 0; }
.hb-table { font-size: 0.84rem; }
.hb-table td, .hb-table th[scope="row"] { line-height: 1.5; }
.hb-table th[scope="row"] {
  text-align: left;
  padding: 0.85rem 1rem 0.85rem 0;
  border-bottom: 1px solid var(--hair);
  font-family: var(--f-body);
  font-variation-settings: "wdth" 120;
  font-weight: 600;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  vertical-align: top;
  white-space: nowrap;
}
.hb-table tr:last-child th[scope="row"] { border-bottom: 0; }
.hb-table .hb-same { color: var(--fg); font-style: italic; font-family: var(--f-display); }
.hb-table--compare td:first-child { min-width: 12rem; font-weight: 500; }
.hb-table--compare tr.is-pick td { color: var(--fg); }
.hb-table--compare tr.is-pick td:first-child { box-shadow: inset 2px 0 0 var(--fg); padding-left: 0.9rem; }
.hb-table--trade td { min-width: 12rem; }
.hb-table--mono td { font-family: var(--f-mono); font-size: 0.78rem; }
.hb-table--mono td:last-child { font-family: var(--f-body); font-size: 0.84rem; }
.hb-table--power td.num, .hb-table--power th.num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; padding-right: 1.6rem; white-space: nowrap; }
.hb-table--power tfoot td { border-top: 1px solid var(--hair-2); border-bottom: 0; color: var(--fg); font-weight: 600; padding-top: 0.95rem; }
.hb-table--tests td:first-child { white-space: nowrap; font-weight: 500; }

/* rating dots: <span class="hb-dots" data-v="3">text</span> */
.hb-dots { display: inline-flex; align-items: center; gap: 0.6rem; }
.hb-dots::before {
  content: "";
  flex: 0 0 auto;
  width: 3.4rem;
  height: 0.5rem;
  background:
    radial-gradient(circle at 0.25rem 50%, var(--fg) 0.2rem, transparent 0.22rem) 0 0 / 0.72rem 100% repeat-x;
  -webkit-mask: linear-gradient(90deg, #000 calc(var(--v, 0) * 0.72rem), rgba(0, 0, 0, 0.22) 0);
  mask: linear-gradient(90deg, #000 calc(var(--v, 0) * 0.72rem), rgba(0, 0, 0, 0.22) 0);
}
.hb-dots[data-v="1"] { --v: 1; } .hb-dots[data-v="2"] { --v: 2; } .hb-dots[data-v="3"] { --v: 3; }
.hb-dots[data-v="4"] { --v: 4; } .hb-dots[data-v="5"] { --v: 5; }

/* step lists */
.hb-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-width: 68ch; }
.hb-steps li { display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.6rem; padding: 0.85rem 0; border-top: 1px solid var(--hair); }
.hb-steps li:last-child { border-bottom: 1px solid var(--hair); }
.hb-steps__n { font-family: var(--f-mono); font-size: 0.86rem; color: var(--fg-3); padding-top: 0.08rem; }
.hb-steps p { color: var(--fg-2); }
.hb-steps + .hb-steps li:first-child { border-top: 0; }

/* two columns: prose + aside */
.hb-two { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: clamp(24px, 3vw, 48px); align-items: start; }
.hb-two--even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.hb-aside { display: grid; gap: 0.7rem; padding-top: 0.9rem; border-top: 1px solid var(--hair-2); }
.hb-aside .t-small a { color: var(--fg); }
.hb-aside pre.code { font-size: 0.72rem; }
@media (max-width: 900px) { .hb-two, .hb-two--even { grid-template-columns: 1fr; } }

.hb-quirks { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.hb-quirks li { display: grid; grid-template-columns: 2.3rem 1fr; gap: 0.6rem; align-items: start; font-size: 0.86rem; color: var(--fg-2); line-height: 1.45; }
.hb-quirks kbd { font-size: 0.92rem; }

.hb-checks { list-style: none; margin: 0; padding: 0; display: grid; max-width: 70ch; }
.hb-checks li { position: relative; padding: 0.8rem 0 0.8rem 1.7rem; border-top: 1px solid var(--hair); color: var(--fg-2); }
.hb-checks li:last-child { border-bottom: 1px solid var(--hair); }
.hb-checks li::before { content: ""; position: absolute; left: 0.1rem; top: 1.25rem; width: 0.7rem; height: 0.38rem; border-left: 1.5px solid var(--fg); border-bottom: 1.5px solid var(--fg); transform: rotate(-45deg); }
.hb-checks strong { color: var(--fg); font-weight: 600; }

/* code grid */
.hb-codegrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.hb-codegrid > div { display: grid; gap: 0.55rem; align-content: start; min-width: 0; }
@media (max-width: 760px) { .hb-codegrid { grid-template-columns: 1fr; } }
.hb-main pre.code { max-width: 100%; }
.hb-codegrid pre.code, .hb-aside pre.code { padding-top: 2.7rem; }
.hb-main pre.code code { white-space: pre; }

/* warnings */
.hb-warn { max-width: 66ch; padding-top: 0.4rem; padding-bottom: 0.4rem; }
.hb-warn p:not(.t-label) { color: var(--fg); font-size: 0.95rem; }

/* surprise cards (open, hairline-topped) */
.hb-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(24px, 3vw, 48px); }
.hb-card { display: grid; gap: 0.5rem; align-content: start; padding: 1.2rem 0 1.4rem; border-top: 1px solid var(--hair-2); }
.hb-card__t { font-family: var(--f-display); font-size: 1.2rem; font-weight: 450; letter-spacing: -0.01em; }
.hb-card p:not(.t-label) { color: var(--fg-2); font-size: 0.9rem; }
@media (max-width: 760px) { .hb-cards { grid-template-columns: 1fr; } }

/* three columns */
.hb-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 2.6vw, 40px); }
.hb-col { display: grid; gap: 0.6rem; align-content: start; padding-top: 1rem; border-top: 1px solid var(--hair-2); }
.hb-col p:not(.t-label) { color: var(--fg-2); font-size: 0.9rem; }
@media (max-width: 900px) { .hb-grid3 { grid-template-columns: 1fr; } }

.hb-kit, .hb-daily { list-style: none; margin: 0.8rem 0 0; padding: 0; display: grid; }
.hb-kit li, .hb-daily li { padding: 0.6rem 0; border-top: 1px solid var(--hair); color: var(--fg-2); font-size: 0.9rem; }
.hb-kit li:last-child, .hb-daily li:last-child { border-bottom: 1px solid var(--hair); }
.hb-daily label { display: flex; gap: 0.7rem; align-items: baseline; cursor: pointer; }
.hb-daily input { accent-color: var(--fg); width: 1rem; height: 1rem; flex: 0 0 auto; transform: translateY(0.15em); }
.hb-daily + .t-small { margin-top: 0.6rem; color: var(--fg-3); }

/* --------------------------------------------------------------------------
   latency budget
   -------------------------------------------------------------------------- */
.lat { display: grid; gap: 1rem; padding: 0.2rem 0 0.4rem; }
.lat__top { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between; }
.lat__total { display: flex; align-items: baseline; gap: 0.8rem; }
.lat__ms { font-size: 1.6rem; color: var(--fg); }
.lat__verdict { font-size: 0.8rem; color: var(--fg-3); }
.lat__verdict.is-over { color: var(--fg); font-weight: 600; }
.lat__bar { position: relative; display: flex; height: 2.4rem; border-radius: var(--r-pill); overflow: hidden; background: var(--bg-3); }
.lat__seg { position: relative; height: 100%; border-right: 2px solid var(--bg); transition: flex-basis 0.5s var(--ease); display: grid; place-items: center; overflow: hidden; }
.lat__seg span { font-family: var(--f-mono); font-size: 0.66rem; color: var(--bg); white-space: nowrap; }
.lat__seg:nth-child(odd) { background: var(--fg); }
.lat__seg:nth-child(even) { background: var(--fg-2); }
.lat__seg.is-signal { background: var(--signal); }
.lat__seg.is-signal span { color: #0b0a0e; }
.lat__mark { position: absolute; top: -0.35rem; bottom: -0.35rem; width: 0; border-left: 2px dashed var(--fg); pointer-events: none; }
.lat__scale { position: relative; display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 0.68rem; color: var(--fg-3); }
.lat__budget { color: var(--fg); }
.lat__legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.2rem 1.4rem; }
.lat__legend li { display: grid; grid-template-columns: 0.7rem 1fr auto; gap: 0.55rem; align-items: baseline; padding: 0.55rem 0; border-top: 1px solid var(--hair); font-size: 0.8rem; color: var(--fg-2); }
.lat__legend i { width: 0.7rem; height: 0.7rem; border-radius: 3px; background: var(--fg); transform: translateY(0.08em); }
.lat__legend li:nth-child(even) i { background: var(--fg-2); }
.lat__legend li.is-signal i { background: var(--signal); }
.lat__legend b { font-family: var(--f-mono); font-weight: 400; color: var(--fg); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .lat__legend { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .lat__seg span { display: none; } }

/* --------------------------------------------------------------------------
   key tester
   -------------------------------------------------------------------------- */
.kt {
  display: grid;
  gap: 0;
  margin-top: 0.4rem;
  border: 1px solid var(--hair-2);
  border-radius: var(--r);
  background: var(--bg-2);
  overflow: hidden;
}
.kt__head { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; align-items: center; justify-content: space-between; padding: 1rem 1.3rem; border-bottom: 1px solid var(--hair); }
.kt__status { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 0.84rem; color: var(--fg-2); }
.kt__ctrls { --cluster: 1rem; }
.kt__capture {
  position: relative;
  padding: clamp(18px, 3vw, 36px) clamp(14px, 3vw, 40px) clamp(14px, 2vw, 22px);
  background: var(--bg-inset);
  cursor: text;
  outline: none;
  transition: box-shadow 0.2s var(--ease-soft);
}
.kt__capture:focus-visible, .kt.is-listening .kt__capture { box-shadow: inset 0 0 0 2px var(--signal-ink); }
.kt__map { display: grid; gap: clamp(5px, 0.7vw, 9px); justify-content: center; }
.kt-row { display: flex; gap: clamp(5px, 0.7vw, 9px); justify-content: center; }
.kt-row:nth-child(2) { padding-left: clamp(10px, 1.6vw, 24px); }
.kt-row:nth-child(3) { padding-left: clamp(18px, 2.8vw, 42px); }
.kt-row:nth-child(4) { padding-left: clamp(26px, 4vw, 60px); }
.kt-key {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(26px, 4.1vw, 50px);
  height: clamp(26px, 4.1vw, 50px);
  border-radius: 50%;
  border: 1.5px solid var(--hair-2);
  background: var(--bg-2);
  font-family: var(--f-mono);
  font-size: clamp(0.62rem, 1.1vw, 0.86rem);
  color: var(--fg-2);
  transition: background-color 0.35s var(--ease-soft), border-color 0.35s var(--ease-soft), color 0.35s var(--ease-soft), transform 0.12s var(--ease);
}
.kt-key--wide { width: auto; min-width: clamp(54px, 8vw, 104px); padding: 0 0.8em; border-radius: var(--r-pill); font-family: var(--f-body); font-variation-settings: "wdth" 118; font-weight: 600; font-size: clamp(0.48rem, 0.8vw, 0.6rem); letter-spacing: 0.1em; text-transform: uppercase; }
.kt-key--space { width: clamp(180px, 34vw, 400px); }
.kt-key--lever { border-style: dashed; }
.kt-key.is-hit { border-color: color-mix(in srgb, var(--signal-ink) 60%, transparent); color: var(--fg); background: var(--signal-wash); }
.kt-key.is-last { background: var(--signal); border-color: var(--signal); color: #0b0a0e; transform: translateY(2px); }
.kt-key.is-dbl::after { content: ""; position: absolute; inset: -5px; border-radius: inherit; border: 1.5px dashed var(--fg); }
.kt-key__c { position: absolute; right: -0.35em; top: -0.45em; min-width: 1.35em; padding: 0 0.3em; border-radius: var(--r-pill); background: var(--bg); border: 1px solid var(--hair-2); font-family: var(--f-mono); font-size: 0.56rem; line-height: 1.35; color: var(--fg-3); text-align: center; }
.kt__note { min-height: 1.4em; margin-top: 0.9rem; text-align: center; font-size: 0.8rem; color: var(--fg-3); }
.kt__readouts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr); border-top: 1px solid var(--hair); }
.kt__stats { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-right: 1px solid var(--hair); }
.kt__stats > div { padding: 0.85rem 1.3rem; border-bottom: 1px solid var(--hair); }
.kt__stats > div:nth-child(odd) { border-right: 1px solid var(--hair); }
.kt__stats > div:last-child { border-bottom: 0; }
.kt__stats dt { font-family: var(--f-body); font-variation-settings: "wdth" 120; font-weight: 600; font-size: 0.56rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3); }
.kt__stats dd { margin: 0.2rem 0 0; font-size: 1.35rem; color: var(--fg); line-height: 1.2; }
.kt__stats dd small { font-size: 0.6em; color: var(--fg-3); margin-left: 0.15em; }
.kt__chartwrap { padding: 0.9rem 1.3rem 1rem; display: grid; gap: 0.6rem; min-width: 0; }
.kt__chartlabel { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; justify-content: space-between; }
.kt__legend { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; letter-spacing: 0.08em; }
.kt__sw { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-left: 0.4rem; }
.kt__sw--gap { background: var(--signal); }
.kt__sw--dbl { background: transparent; border: 1.5px dashed var(--fg); }
.kt__chart { width: 100%; height: 120px; display: block; }
.kt__lines { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--hair); }
.kt__line { padding: 0.9rem 1.3rem 1rem; display: grid; gap: 0.4rem; min-width: 0; }
.kt__line + .kt__line { border-left: 1px solid var(--hair); }
.kt__raw, .kt__norm { font-size: 1.12rem; line-height: 1.4; min-height: 1.6em; overflow-wrap: anywhere; color: var(--fg); }
.kt__norm { color: var(--signal-ink); letter-spacing: 0.06em; }
.kt__src { color: var(--fg-3); letter-spacing: 0.08em; margin-left: 0.4rem; }
.kt__caret { display: inline-block; width: 0.55em; height: 1.05em; margin-left: 1px; vertical-align: -0.15em; background: var(--fg-3); animation: kt-blink 1.1s steps(1) infinite; }
.kt.is-listening .kt__caret { background: var(--signal); }
@keyframes kt-blink { 50% { opacity: 0; } }
.kt__cast { grid-column: 1 / -1; padding: 0.75rem 1.3rem; border-top: 1px solid var(--hair); color: var(--fg-2); }
.kt__cast b { font-family: var(--f-mono); font-weight: 400; color: var(--fg); }
.kt__logwrap { border-top: 1px solid var(--hair); padding: 0.2rem 1.3rem 0.6rem; max-height: 22rem; overflow-y: auto; }
.kt__log { font-size: 0.8rem; }
.kt__log td { font-family: var(--f-mono); font-variant-numeric: tabular-nums; padding-top: 0.5rem; padding-bottom: 0.5rem; white-space: nowrap; }
.kt__log td:last-child { font-family: var(--f-body); white-space: normal; }
.kt__log .kt__empty td { font-family: var(--f-body); color: var(--fg-3); white-space: normal; }
.kt__flag { display: inline-block; margin-right: 0.35rem; padding: 0.05em 0.55em; border: 1px solid var(--hair-2); border-radius: var(--r-pill); font-size: 0.6rem; font-variation-settings: "wdth" 118; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
.kt__flag--dbl { border-style: dashed; border-color: var(--fg); color: var(--fg); }
.kt__flag--cast { border-color: color-mix(in srgb, var(--signal-ink) 60%, transparent); color: var(--signal-ink); }
@media (max-width: 760px) {
  .kt__readouts, .kt__lines { grid-template-columns: 1fr; }
  .kt__stats { border-right: 0; border-bottom: 1px solid var(--hair); }
  .kt__line + .kt__line { border-left: 0; border-top: 1px solid var(--hair); }
  .kt-row:nth-child(n) { padding-left: 0; }
}

/* --------------------------------------------------------------------------
   TV test signal
   -------------------------------------------------------------------------- */
.tvx { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 40px); align-items: center; margin-top: 0.4rem; }
.tvx__screen {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r);
  overflow: hidden;
  background: #050605;
  border: 1px solid var(--hair-2);
}
.tvx__screen > canvas.tvx__canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.tvx__screen.has-tv > canvas.tvx__canvas { display: none; }
.tvx__screen .tvx__mount { position: absolute; inset: 0; }
.tvx__panel { display: grid; gap: 1rem; align-content: center; }
.tvx__label { gap: 0.6rem; }
.tvx__desc { min-height: 3em; max-width: 36ch; }
.tvx__patterns, .tvx__modes { flex-wrap: wrap; justify-self: start; }
.tvx__screen:fullscreen { border-radius: 0; border: 0; background: #000; }
@media (max-width: 900px) { .tvx { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   zone map
   -------------------------------------------------------------------------- */
.zm { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: clamp(20px, 3vw, 48px); align-items: start; }
.zm__z { font-family: var(--f-mono); font-size: 0.86rem; color: var(--fg); }
.zm__hw { font-size: 0.72rem; color: var(--fg-3); line-height: 1.35; }
.zm__fig .t-label, .zm__cab > .t-label { margin-bottom: 0.8rem; display: flex; gap: 0.8rem; }
.zm__list { list-style: none; margin: 0; padding: 0; display: grid; }
.zm__list li { display: grid; grid-template-columns: 0.55rem 6rem 1fr; gap: 0.7rem; align-items: baseline; padding: 0.62rem 0; border-top: 1px solid var(--hair); }
.zm__list li::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--glow); box-shadow: 0 0 0 4px var(--glow-wash); transform: translateY(0.05em); }
.zm__list li:last-child { border-bottom: 1px solid var(--hair); }
.zm__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.zm__drawer, .zm__door {
  position: relative;
  display: grid;
  gap: 0.2rem;
  align-content: end;
  min-height: 5.2rem;
  padding: 0.75rem 0.85rem 0.7rem;
  border: 1px solid color-mix(in srgb, var(--glow-ink) 45%, transparent);
  border-radius: var(--r-sm);
  background: linear-gradient(180deg, var(--glow-wash), transparent 70%);
}
.zm__drawer::before { content: ""; position: absolute; top: 0.7rem; left: 50%; width: 1.4rem; height: 0.32rem; margin-left: -0.7rem; border-radius: var(--r-pill); border: 1px solid color-mix(in srgb, var(--glow-ink) 55%, transparent); }
.zm__drawer--mouth { border-color: var(--glow-ink); }
.zm__door { margin-top: 8px; min-height: 3.2rem; grid-template-columns: auto 1fr; align-items: baseline; gap: 0.8rem; max-width: 50%; }
@media (max-width: 760px) {
  .zm { grid-template-columns: 1fr; }
  .zm__door { max-width: none; }
  .zm__drawer { min-height: 4.4rem; padding: 0.6rem 0.6rem 0.55rem; }
  .zm__drawer .zm__z { font-size: 0.74rem; }
}

/* --------------------------------------------------------------------------
   bridge tester
   -------------------------------------------------------------------------- */
.bt { display: grid; gap: 0; margin-top: 0.4rem; border: 1px solid var(--hair-2); border-radius: var(--r); background: var(--bg-2); overflow: hidden; }
.bt__bar { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--hair); }
.bt__url { flex: 1 1 14rem; max-width: 22rem; }
.bt__url .input { min-height: 2.1rem; padding: 0.35rem 0.8rem; font-size: 0.8rem; border-radius: var(--r-pill); }
.bt__status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 0.8rem; padding: 0.8rem 1.3rem; font-size: 0.86rem; color: var(--fg-2); border-bottom: 1px solid var(--hair); }
.bt__fw { margin-left: auto; font-size: 0.74rem; color: var(--fg-3); }
.bt__support { padding: 0.75rem 1.3rem; border-bottom: 1px solid var(--hair); color: var(--fg); }
.bt__body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.bt__controls { display: grid; gap: 0.8rem; align-content: start; padding: 1.1rem 1.3rem 1.3rem; border-right: 1px solid var(--hair); }
.bt__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; align-items: end; }
.bt__row:nth-of-type(2) { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; }
.bt__row .select, .bt__row .input { min-height: 2.2rem; padding-top: 0.35rem; padding-bottom: 0.35rem; font-size: 0.82rem; }
.bt__sub { margin-top: 0.4rem; }
.bt__quick { --cluster: 0.45rem; }
.bt__logwrap { display: grid; grid-template-rows: auto 1fr; min-width: 0; background: var(--bg-inset); }
.bt__logtitle { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem 0.6rem; }
.bt__counts { letter-spacing: 0; text-transform: none; font-family: var(--f-mono); font-weight: 400; font-size: 0.72rem; }
.bt__log { list-style: none; margin: 0; padding: 0 1.3rem 1rem; max-height: 23rem; min-height: 14rem; overflow-y: auto; font-size: 0.74rem; line-height: 1.5; display: grid; align-content: start; gap: 0.15rem; }
.bt__log li { display: grid; grid-template-columns: 4.4rem 1.2rem 1fr; gap: 0.4rem; padding: 0.22rem 0; border-bottom: 1px solid var(--hair); overflow-wrap: anywhere; color: var(--fg-2); }
.bt__log li.bt__empty { display: block; font-family: var(--f-body); color: var(--fg-3); border-bottom: 0; }
.bt__log .bt__t { color: var(--fg-3); font-variant-numeric: tabular-nums; }
.bt__log .bt__dir { color: var(--fg-3); }
.bt__log li.is-rx { color: var(--fg); }
.bt__log li.is-rx .bt__dir { color: var(--signal-ink); }
.bt__log li.is-drop { opacity: 0.55; text-decoration: line-through; text-decoration-color: var(--fg-3); }
.bt__log li.is-sys { color: var(--fg-3); font-family: var(--f-body); }
@media (max-width: 900px) {
  .bt__body { grid-template-columns: 1fr; }
  .bt__controls { border-right: 0; border-bottom: 1px solid var(--hair); }
}
@media (max-width: 480px) {
  .bt__row, .bt__row:nth-of-type(2) { grid-template-columns: 1fr 1fr; }
  .bt__row .bt__send { grid-column: 1 / -1; }
}

/* --------------------------------------------------------------------------
   power calculator
   -------------------------------------------------------------------------- */
.pc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(20px, 3vw, 48px); align-items: center; padding: 1.4rem 0; border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
.pc__inputs { display: grid; gap: 1.1rem; }
.pc__inputs .field { grid-template-columns: 1fr auto; align-items: center; column-gap: 1rem; }
.pc__inputs .field .t-label { grid-column: 1 / -1; }
.pc__v { font-size: 0.82rem; color: var(--fg); white-space: nowrap; }
.pc__big { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.pc__n { font-family: var(--f-display); font-size: clamp(3rem, 6vw, 4.8rem); line-height: 1; font-weight: 340; letter-spacing: -0.02em; font-variation-settings: "SOFT" 100, "WONK" 1; }
.pc__u { font-size: 0.95rem; color: var(--fg-2); max-width: 14ch; line-height: 1.3; }
@media (max-width: 760px) { .pc { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   milestones + open questions
   -------------------------------------------------------------------------- */
.ms { list-style: none; margin: 0.4rem 0 0.6rem; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 2rem; }
.ms__step { position: relative; display: grid; gap: 0.35rem; align-content: start; padding-right: 1.2rem; }
.ms__step::after { content: ""; position: absolute; left: 2.6rem; right: 0.5rem; top: 1.05rem; height: 1px; background: var(--hair-2); }
.ms__step:nth-child(4n)::after, .ms__step:last-child::after { display: none; }
.ms__n { position: relative; display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 1px solid var(--hair-2); background: var(--bg); font-family: var(--f-mono); font-size: 0.86rem; color: var(--fg); margin-bottom: 0.45rem; }
.ms__step:first-child .ms__n { background: var(--solid-bg); color: var(--solid-fg); border-color: var(--solid-bg); }
.ms__t { font-family: var(--f-display); font-size: 1.08rem; line-height: 1.25; font-weight: 450; color: var(--fg); }
.ms__d { font-size: 0.8rem; color: var(--fg-3); line-height: 1.45; max-width: 24ch; }
@media (max-width: 760px) {
  .ms { grid-template-columns: 1fr; row-gap: 0; position: relative; }
  .ms::before { content: ""; position: absolute; left: 1.05rem; top: 0.6rem; bottom: 1.2rem; width: 1px; background: var(--hair-2); }
  .ms__step { grid-template-columns: 2.1rem 1fr; column-gap: 1rem; padding: 0 0 1.1rem; }
  .ms__step::after { display: none; }
  .ms__n { grid-row: span 2; margin: 0; }
}

.oq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 clamp(24px, 3vw, 48px); }
.oq__item { display: grid; gap: 0.55rem; align-content: start; padding: 1.3rem 0 1.5rem; border-top: 1px solid var(--hair-2); }
.oq__q { font-family: var(--f-display); font-size: 1.22rem; line-height: 1.3; font-weight: 430; letter-spacing: -0.01em; color: var(--fg); text-wrap: balance; }
.oq__opts { font-size: 0.88rem; color: var(--fg-2); }
.oq__lean { font-size: 0.88rem; color: var(--fg); display: grid; gap: 0.25rem; }
.oq__meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.3rem; font-family: var(--f-mono); font-size: 0.72rem; color: var(--fg-3); }
@media (max-width: 760px) { .oq { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------------------
   responsive hero
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .hb-hero__text, .hb-hero__plate { grid-column: 1 / -1; }
  .hb-hero__plate img { aspect-ratio: 16 / 10; }
}

/* --------------------------------------------------------------------------
   print: a clean service manual
   -------------------------------------------------------------------------- */
@media print {
  .hdr, .ftr, .hb-toc, .kt, .bt, .tvx, .code-copy, .skip-link, .hb-fig__hint, .lat__top .seg { display: none !important; }
  html, body { background: #fff !important; color: #000 !important; }
  .hb-layout { display: block; border: 0; }
  .hb-sec { break-inside: auto; padding: 24px 0; }
  .hb-fig, .hb-plate, pre.code, .hb-table { break-inside: avoid; }
  a { text-decoration: none; }
}
