/* tos-toolkit — documentation stylesheet.
 *
 * Direction: an annotated engineering spec sheet. Warm drafting paper (graphite
 * at night), hairline rules, figure numbers, numbered sections hung in the
 * margin, and one signal colour reserved for things that are wrong.
 *
 * Typography trade-off: no web fonts are downloaded, so this site makes no
 * font requests and works offline. Each role names a deliberate system stack
 * (Iowan Old Style / Charter / Palatino for display, Avenir Next / Segoe UI for
 * text, SF Mono / Cascadia for code). Exact glyphs vary by OS; scale, tracking,
 * and rhythm carry the identity instead of a single licensed face.
 */

:root {
  --f-display: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Heading",
    "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --f-text: "Avenir Next", "Avenir", "Segoe UI Variable Text", "Segoe UI", Ubuntu,
    "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", "Roboto Mono",
    Menlo, Consolas, "Liberation Mono", monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.9rem, 1.4rem + 1.8vw, 2.6rem);
  --step-4: clamp(2.3rem, 1.4rem + 4vw, 4.4rem);

  --measure: 38rem;
  --mast-h: 3.5rem;
  --radius: 2px;

  /* Light: drafting paper. Every text pair below is >= 4.5:1 on --paper-2. */
  --paper: #f3efe6;
  --paper-2: #e9e3d5;
  --paper-3: #fbf9f4;
  --ink: #1a1c1e;
  --ink-2: #4f545a;
  --rule: #cfc6b3;
  --rule-strong: #1a1c1e;
  --signal: #b2361b;
  --signal-tint: #f3dcd2;
  --amber: #855000;
  --amber-tint: #f1e3c4;
  --ok: #2b6a3b;
  --ok-tint: #d9e8d6;
  --focus: #0b57c4;
  --grid: rgb(26 28 30 / 0.05);

  --t-kd: #a3321a;
  --t-kw: #6a3d97;
  --t-fn: #1c5689;
  --t-cst: #0e6464;
  --t-num: #855000;
  --t-str: #2b6a3b;
  --t-com: #5c6066;
}

/* Dark: graphite. Applied by system preference unless a choice is stored. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121416;
    --paper-2: #1b1e22;
    --paper-3: #16191c;
    --ink: #e8e3d8;
    --ink-2: #a4a9b0;
    --rule: #2f343a;
    --rule-strong: #e8e3d8;
    --signal: #ff8058;
    --signal-tint: #3a211a;
    --amber: #e8b54f;
    --amber-tint: #33291a;
    --ok: #82cc92;
    --ok-tint: #1c2e21;
    --focus: #7eb2ff;
    --grid: rgb(232 227 216 / 0.04);
    --t-kd: #ff8a63;
    --t-kw: #c9a3f0;
    --t-fn: #8cc3f5;
    --t-cst: #6fd0c8;
    --t-num: #e8b54f;
    --t-str: #9fd48f;
    --t-com: #8d9298;
  }
}
:root[data-theme="dark"] {
  --paper: #121416;
  --paper-2: #1b1e22;
  --paper-3: #16191c;
  --ink: #e8e3d8;
  --ink-2: #a4a9b0;
  --rule: #2f343a;
  --rule-strong: #e8e3d8;
  --signal: #ff8058;
  --signal-tint: #3a211a;
  --amber: #e8b54f;
  --amber-tint: #33291a;
  --ok: #82cc92;
  --ok-tint: #1c2e21;
  --focus: #7eb2ff;
  --grid: rgb(232 227 216 / 0.04);
  --t-kd: #ff8a63;
  --t-kw: #c9a3f0;
  --t-fn: #8cc3f5;
  --t-cst: #6fd0c8;
  --t-num: #e8b54f;
  --t-str: #9fd48f;
  --t-com: #8d9298;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------------------------------------------------------------- base -- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--mast-h) + 1rem); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.65 var(--f-text);
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
::selection { background: var(--signal); color: var(--paper); }

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

a { color: inherit; text-decoration-line: underline; text-decoration-color: var(--signal);
    text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: var(--signal); text-decoration-thickness: 2px; }

.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 {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--ink); color: var(--paper); padding: 0.6rem 1rem;
  font: 600 var(--step--1)/1 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none;
}
.skip:focus { top: 0.75rem; }

kbd {
  font: 500 0.75em/1 var(--f-mono);
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: var(--radius);
  padding: 0.15em 0.4em; background: var(--paper-3);
}

/* ---------------------------------------------------------- masthead -- */

.masthead {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  height: var(--mast-h); padding: 0 1.25rem;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
}
.wordmark {
  display: inline-flex; align-items: stretch;
  font: 700 0.95rem/1 var(--f-mono); letter-spacing: 0.02em; text-decoration: none;
  border: 1.5px solid var(--ink);
}
.wordmark span { padding: 0.35rem 0.5rem; }
.wm-a { background: var(--ink); color: var(--paper); }
.wordmark:hover { color: inherit; }
.wordmark:hover .wm-b { color: var(--signal); }
.rev {
  font: 500 0.7rem/1 var(--f-mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-2); white-space: nowrap;
}
.search { position: relative; margin-left: auto; width: min(22rem, 40vw); }
.no-js .search { display: none; }
/* Without scripting the theme button cannot do anything, so do not offer it. */
.no-js .no-js-hide { display: none; }
.search input {
  width: 100%; height: 2.25rem; padding: 0 2.2rem 0 0.75rem;
  font: 400 1rem/1 var(--f-mono); color: var(--ink);
  background: var(--paper-3); border: 1px solid var(--ink-2); border-radius: var(--radius);
}
.search input::placeholder { color: var(--ink-2); opacity: 1; }
.search input:focus-visible { border-color: var(--focus); outline-offset: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.kbd-hint { position: absolute; right: 0.55rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:focus ~ .kbd-hint { display: none; }

#q-results {
  position: absolute; right: 0; top: calc(100% + 0.4rem);
  width: min(34rem, calc(100vw - 2rem)); max-height: min(70vh, 32rem); overflow: auto;
  margin: 0; padding: 0.35rem; list-style: none;
  background: var(--paper-3); border: 1px solid var(--rule-strong);
  box-shadow: 6px 6px 0 var(--grid), 0 18px 40px rgb(0 0 0 / 0.18);
}
#q-results li { padding: 0.55rem 0.7rem; cursor: pointer; border-left: 3px solid transparent; }
#q-results li[aria-selected="true"] { background: var(--paper-2); border-left-color: var(--signal); }
#q-results .r-where {
  display: block; font: 500 0.75rem/1.3 var(--f-mono); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-2);
}
#q-results .r-title { display: block; font-weight: 600; }
#q-results .r-snip { display: block; font-size: var(--step--1); color: var(--ink-2); }
#q-results mark { background: var(--signal-tint); color: inherit; }
#q-results .r-empty { cursor: default; color: var(--ink-2); }

.theme-toggle, .menu-toggle {
  height: 2.25rem; min-width: 2.25rem; padding: 0 0.6rem;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: transparent; color: var(--ink); cursor: pointer;
  font: 600 0.75rem/1 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase;
}
.theme-toggle:hover, .menu-toggle:hover { border-color: var(--ink); }
.theme-icon {
  display: block; width: 1rem; height: 1rem; margin: auto; border-radius: 50%;
  border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 50%);
}
.menu-toggle { display: none; }
.repo {
  font: 600 0.75rem/1 var(--f-mono); letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none; white-space: nowrap;
}

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

.frame {
  display: grid;
  grid-template-columns: 16.5rem minmax(0, 1fr) 14rem;
  gap: 0 3rem;
  max-width: 92rem; margin: 0 auto; padding: 0 1.25rem;
}
main { min-width: 0; padding: 2.5rem 0 4rem; }
article { max-width: var(--measure); }
.home article { max-width: none; }

.sidebar, .rail {
  position: sticky; top: var(--mast-h);
  max-height: calc(100vh - var(--mast-h)); overflow-y: auto;
  padding: 2.5rem 0 3rem;
  font-size: 0.9rem;
}
.sidebar { border-right: 1px solid var(--rule); padding-right: 1.25rem; }
.nav-h {
  margin: 1.75rem 0 0.5rem; font: 600 0.75rem/1.2 var(--f-mono);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2);
}
.sidebar section:first-child .nav-h { margin-top: 0; }
.nav-list, .toc ul { list-style: none; margin: 0; padding: 0; }
.nav-list > li > a {
  display: block; padding: 0.28rem 0.6rem; margin-left: -0.6rem;
  text-decoration: none; border-left: 2px solid transparent;
}
.nav-list > li > a:hover { border-left-color: var(--rule-strong); color: var(--ink); background: var(--paper-2); }
.nav-list a[aria-current="page"] {
  border-left-color: var(--signal); font-weight: 600; background: var(--paper-2);
}

/* The rule-code register under "Rules": every diagnostic, one click away. */
.chips {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(3.35rem, 1fr));
  gap: 0.25rem; list-style: none; margin: 0.4rem 0 0.6rem; padding: 0;
}
.chip {
  display: block; text-align: center; padding: 0.18rem 0;
  font: 600 0.7rem/1.2 var(--f-mono); letter-spacing: 0.04em; text-decoration: none;
  border: 1px solid var(--rule); border-radius: var(--radius);
}
.chip-e { color: var(--signal); }
.chip-w { color: var(--amber); }
.chip:hover { border-color: currentColor; background: var(--paper-2); color: var(--ink); }
.chip-e:hover { box-shadow: inset 0 -2px 0 var(--signal); }
.chip-w:hover { box-shadow: inset 0 -2px 0 var(--amber); }

.toc { border-left: 1px solid var(--rule); padding-left: 1rem; }
.toc a { display: block; padding: 0.2rem 0; color: var(--ink-2); text-decoration: none; line-height: 1.35; }
.toc a:hover { color: var(--signal); }
.toc ul ul { padding-left: 0.8rem; font-size: 0.85rem; }

/* ------------------------------------------------------------ page head -- */

.kicker {
  margin: 0 0 0.75rem; font: 600 0.72rem/1.2 var(--f-mono);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2);
}
.page-head { padding-bottom: 1.25rem; margin-bottom: 2rem; border-bottom: 1px solid var(--rule-strong); }
.page-head h1 {
  margin: 0; font: 600 var(--step-3)/1.08 var(--f-display);
  letter-spacing: -0.015em; text-wrap: balance;
}
.page-head h1 code { font-size: 0.82em; }

/* --------------------------------------------------------------- prose -- */

.prose { counter-reset: sec; }
.prose > * + * { margin-top: 1.1rem; }
.prose p, .prose ul, .prose ol, .prose dl { margin-bottom: 0; }
.prose p, .prose li { hanging-punctuation: first; }
.prose h2, .prose h3, .prose h4 { position: relative; scroll-margin-top: calc(var(--mast-h) + 1rem); }
.prose h2 {
  margin: 3.25rem 0 0; padding-top: 0.5rem;
  font: 600 var(--step-2)/1.2 var(--f-display); letter-spacing: -0.01em; text-wrap: balance;
}
/* Section numbers hang in the left margin like a spec sheet's clause numbers. */
.prose > h2::before {
  counter-increment: sec;
  content: "§" counter(sec, decimal-leading-zero);
  position: absolute; right: calc(100% + 1rem); top: 1.05rem;
  font: 600 0.72rem/1 var(--f-mono); letter-spacing: 0.06em; color: var(--signal);
}
.prose h3 { margin: 2.25rem 0 0; font: 700 var(--step-1)/1.3 var(--f-text); }
.prose h4 { margin: 1.75rem 0 0; font: 700 var(--step-0)/1.3 var(--f-text); }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.75rem; }
.headerlink {
  margin-left: 0.4rem; font: 400 0.75em/1 var(--f-mono); color: var(--ink-2);
  text-decoration: none; opacity: 0;
}
h2:hover .headerlink, h3:hover .headerlink, .headerlink:focus-visible { opacity: 1; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.35rem; }
.prose ul > li::marker { content: "— "; color: var(--ink-2); }
.prose strong { font-weight: 650; }
.prose hr {
  height: 9px; border: 0; margin: 3rem 0;
  background:
    linear-gradient(var(--rule), var(--rule)) center / 100% 1px no-repeat,
    linear-gradient(var(--ink-2), var(--ink-2)) center / 1px 9px no-repeat;
}
.prose blockquote { margin: 1.25rem 0; padding: 0.25rem 0 0.25rem 1rem; border-left: 3px solid var(--amber); color: var(--ink-2); }

:not(pre) > code {
  font: 500 0.86em/1 var(--f-mono);
  padding: 0.12em 0.32em; border-radius: var(--radius);
  background: var(--paper-2); box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
h1 code, h2 code, h3 code { background: none; padding: 0; }

/* ---------------------------------------------------------------- code -- */

.code {
  position: relative; margin: 1.25rem 0 0;
  background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius);
}
.code pre {
  margin: 0; padding: 1rem 1.1rem; overflow-x: auto;
  font: 400 0.84rem/1.6 var(--f-mono); tab-size: 4;
}
.code-lang {
  position: absolute; top: -0.55rem; left: 0.8rem; padding: 0 0.35rem;
  font: 600 0.75rem/1.1rem var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-2); background: var(--paper);
}
.copy {
  position: absolute; top: 0.45rem; right: 0.45rem;
  padding: 0.25rem 0.5rem; font: 600 0.65rem/1 var(--f-mono); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-2);
  background: var(--paper-3); border: 1px solid var(--ink-2); border-radius: var(--radius);
  cursor: pointer; opacity: 0;
}
.code:hover .copy, .copy:focus-visible, .copy[data-done] { opacity: 1; }
@media (hover: none) { .copy { opacity: 1; } }

/* Pygments tokens (nowrap HTML formatter classes), scoped to code blocks. */
.code :is(.c, .c1, .cm, .ch, .cs) { color: var(--t-com); font-style: italic; }
.code :is(.kd, .kn) { color: var(--t-kd); font-weight: 650; }
.code :is(.k, .kc, .kr, .kt, .ow, .nt) { color: var(--t-kw); }
.code :is(.nf, .nb, .fm, .nv) { color: var(--t-fn); }
.code :is(.nc, .no, .na, .nd) { color: var(--t-cst); }
.code :is(.m, .mi, .mf, .mh, .il) { color: var(--t-num); }
.code :is(.s, .s1, .s2, .sb, .sd, .se, .sh, .si, .sx, .dl) { color: var(--t-str); }
.code .gp { color: var(--signal); font-weight: 700; user-select: none; }
.code .go { color: var(--ink-2); }
.code .err { color: inherit; background: none; }

/* --------------------------------------------------------------- tables -- */

.table-wrap {
  overflow-x: auto; margin-top: 1.25rem;
  border-top: 1.5px solid var(--rule-strong); border-bottom: 1.5px solid var(--rule-strong);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; line-height: 1.45; }
th {
  text-align: left; vertical-align: bottom; padding: 0.55rem 0.75rem 0.45rem;
  font: 600 0.75rem/1.2 var(--f-mono); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-2); border-bottom: 1px solid var(--rule-strong); white-space: nowrap;
}
td { padding: 0.5rem 0.75rem; vertical-align: top; border-top: 1px solid var(--rule); }
tbody tr:first-child td { border-top: 0; }
tbody tr:hover td { background: var(--paper-2); }
td:first-child, th:first-child { padding-left: 0.25rem; }

/* Diagnostic tables — the heart of the site. Code stamps, shape-coded
 * severity (never colour alone), a margin tab on hover, a sweep on :target. */
.rules-table td { padding-top: 0.6rem; padding-bottom: 0.6rem; }
.rules-table td:first-child { width: 5.25rem; white-space: nowrap; }
.rules-table tr.rule { position: relative; }
.code-tag { text-decoration: none; display: inline-block; }
.code-tag code {
  display: inline-block; padding: 0.22em 0.45em 0.18em !important;
  font: 700 0.8rem/1 var(--f-mono) !important; letter-spacing: 0.05em;
  background: var(--paper-3) !important; border: 1.5px solid currentColor;
}
.rule-e .code-tag { color: var(--signal); }
.rule-w .code-tag { color: var(--amber); }
.code-tag:hover code { background: var(--paper) !important; }
.rules-table tr.rule td:first-child { box-shadow: inset 3px 0 0 transparent; transition: box-shadow 120ms; }
.rules-table tr.rule-e:hover td:first-child { box-shadow: inset 3px 0 0 var(--signal); }
.rules-table tr.rule-w:hover td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
.rules-table tr.rule:hover td:last-child { color: var(--ink); }

.sev {
  width: 5.5rem; white-space: nowrap;
  font: 600 0.72rem/1.6 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase;
}
.sev::before { display: inline-block; width: 1.1em; }
.sev-error { color: var(--signal); }
.sev-error::before { content: "■" / ""; }
.sev-warn { color: var(--amber); }
.sev-warn::before { content: "▲" / ""; }

tr:target td {
  background: linear-gradient(90deg, var(--signal-tint), var(--signal-tint)) no-repeat 0 0 / 100% 100%;
  animation: sweep 900ms cubic-bezier(.2,.7,.2,1) both;
}
tr.rule-w:target td { background-image: linear-gradient(90deg, var(--amber-tint), var(--amber-tint)); }
@keyframes sweep { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }

/* -------------------------------------------------------------- pager -- */

.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  max-width: var(--measure); margin-top: 4rem; padding-top: 1.25rem;
  border-top: 1px solid var(--rule-strong);
}
.pager a {
  display: block; padding: 0.75rem 0; text-decoration: none;
  font: 600 var(--step-1)/1.25 var(--f-display);
}
.pager a span {
  display: block; margin-bottom: 0.25rem; font: 600 0.75rem/1 var(--f-mono);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2);
}
.pager .next { grid-column: 2; text-align: right; }
.page-source { max-width: var(--measure); margin: 1.5rem 0 0; font-size: var(--step--1); color: var(--ink-2); }

.colophon {
  border-top: 1px solid var(--rule-strong); padding: 1.5rem 1.25rem 2.5rem;
  font: 400 0.75rem/1.6 var(--f-mono); color: var(--ink-2); text-align: center;
}
.colophon p { margin: 0; }

/* ---------------------------------------------------------------- home -- */

.hero { max-width: 58rem; padding: 1rem 0 2.5rem; }
.kicker-no {
  display: inline-block; margin-right: 0.6rem; padding: 0.2rem 0.45rem;
  border: 1px solid var(--ink); color: var(--ink);
}
.hero-title { margin: 0; font-weight: 400; }
.hero-product {
  display: block; margin-bottom: 0.75rem;
  font: 700 var(--step-1)/1 var(--f-mono); letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-2);
}
.hero-err {
  display: block;
  font: 600 var(--step-4)/0.98 var(--f-display); letter-spacing: -0.025em;
  text-wrap: balance;
}
.hero-sub {
  display: block; margin-top: 1rem;
  font: 400 var(--step-2)/1.25 var(--f-display); font-style: italic; color: var(--ok);
}
.hero-lede { max-width: 40rem; margin: 1.5rem 0 0; font-size: var(--step-1); line-height: 1.55; color: var(--ink-2); }
.hero-lede strong { color: var(--ink); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 2rem 0 0; }
.btn {
  display: inline-block; padding: 0.7rem 1.1rem; text-decoration: none;
  font: 700 0.78rem/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase;
  border: 1.5px solid var(--ink); border-radius: var(--radius);
}
.btn:hover { color: var(--ink); background: var(--paper-2); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--signal); border-color: var(--signal); color: var(--paper); }

.plates {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem;
  padding: 1.5rem; margin: 0 0 3.5rem;
  border: 1px solid var(--rule-strong);
  /* Drafting-paper grid behind the figure only. */
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 100% 16px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 16px 100%,
    var(--paper-3);
}
.plate { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.plate figcaption {
  display: flex; align-items: center; gap: 0.6rem; padding-bottom: 0.6rem;
  font: 600 0.75rem/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase;
}
.plate-tag {
  display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem;
  border: 1.5px solid currentColor;
}
.plate-before .plate-tag { color: var(--signal); }
.plate-after .plate-tag { color: var(--ok); }
.plate-file { margin-left: auto; letter-spacing: 0.02em; text-transform: none; font-weight: 400; color: var(--ink-2); }
.code-figure { margin: 0; }
.code-figure pre { font-size: 0.82rem; }
.ln { display: block; min-height: 1.6em; }
mark.hit, mark.fix {
  color: inherit; background: no-repeat 0 100% / 100% 2px;
  padding-bottom: 1px;
}
mark.hit { background-image: linear-gradient(var(--signal), var(--signal)); }
mark.hit .n { color: var(--signal); font-weight: 700; }
mark.fix { background-image: linear-gradient(var(--ok), var(--ok)); }
mark.fix .n { color: var(--ok); font-weight: 700; }
.proof {
  position: absolute; right: 0.9rem; bottom: 0.7rem;
  padding: 0.25rem 0.5rem; font: 800 0.85rem/1 var(--f-mono); letter-spacing: 0.08em;
  color: var(--signal); border: 2px solid var(--signal); background: var(--paper-2);
  transform: rotate(-4deg);
}
.term {
  flex: 1; margin: 0.75rem 0 0; padding: 0.8rem 1rem;
  font: 400 0.76rem/1.55 var(--f-mono); white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--ink); background: var(--paper); border: 1px solid var(--rule);
  border-left: 3px solid var(--rule-strong);
}
.term .prompt { color: var(--ink-2); user-select: none; }
.t-err { color: var(--signal); font-weight: 700; }
.t-ok { color: var(--ok); font-weight: 700; }
.exit {
  display: inline-block; padding: 0 0.35rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; font-size: 0.75rem; border: 1px solid currentColor;
}
.exit-1 { color: var(--signal); }
.exit-0 { color: var(--ok); }

/* Signature: the figure is "proof-read" on load. Lines set in one by one,
 * then the colliding names are struck through with the signal pen, the E071
 * stamp lands, and the transcript prints. Plate B follows with the fix. */
@media (prefers-reduced-motion: no-preference) {
  .js .plate .ln {
    animation: set-line 380ms cubic-bezier(.2,.7,.2,1) both;
    animation-delay: calc(var(--d, 0ms) + var(--i) * 110ms + 150ms);
  }
  .js .plate-after { --d: 1900ms; }
  .js mark.hit, .js mark.fix {
    animation: pen 420ms cubic-bezier(.6,0,.2,1) both;
    animation-delay: calc(var(--d, 0ms) + 820ms);
  }
  .js .proof { animation: stamp 260ms cubic-bezier(.3,1.6,.5,1) both; animation-delay: 1250ms; }
  .js .plate .term { animation: print 400ms ease-out both; animation-delay: calc(var(--d, 0ms) + 1450ms); }
  @keyframes set-line {
    from { clip-path: inset(0 100% 0 0); opacity: 0.3; }
    to { clip-path: inset(0 0 0 0); opacity: 1; }
  }
  @keyframes pen { from { background-size: 0% 2px; } to { background-size: 100% 2px; } }
  @keyframes stamp {
    from { opacity: 0; transform: rotate(-12deg) scale(1.8); }
    to { opacity: 1; transform: rotate(-4deg) scale(1); }
  }
  @keyframes print { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 1240px) {
  .frame { grid-template-columns: 15rem minmax(0, 1fr); gap: 0 2.5rem; }
  .rail { display: none; }
}
@media (max-width: 1000px) {
  .plates { grid-template-columns: minmax(0, 1fr); padding: 1rem; }
}
@media (max-width: 900px) {
  :root { --mast-h: 3.25rem; }
  .frame { grid-template-columns: minmax(0, 1fr); }
  .js .menu-toggle { display: inline-block; }
  .rev, .repo { display: none; }
  .search { width: auto; flex: 1; }
  .sidebar {
    position: static; max-height: none; border-right: 0;
    border-bottom: 1px solid var(--rule); padding: 1.5rem 0;
  }
  /* Only hide the nav once the toggle is known to work: `nav-js` is set by
     app.js itself, so a failed script leaves the nav visible. */
  .nav-js .sidebar { display: none; }
  .nav-js.nav-open .sidebar { display: block; }
  .prose > h2::before { position: static; display: block; margin-bottom: 0.4rem; }
  main { padding-top: 1.75rem; }
}
@media (max-width: 520px) {
  .masthead { gap: 0.5rem; padding: 0 0.75rem; }
  .wordmark span { padding: 0.35rem 0.35rem; }
  .frame { padding: 0 1rem; }
  .kbd-hint { display: none; }
}

@media (forced-colors: active) {
  .code-tag code, .chip, .btn, .plate-tag, .proof { border-color: CanvasText; }
  mark.hit, mark.fix { text-decoration: underline 2px; }
}

/* ---------------------------------------------------------------- print -- */

@media print {
  @page { margin: 16mm 14mm; }
  :root, :root[data-theme] {
    --paper: #fff; --paper-2: #fff; --paper-3: #fff; --ink: #000; --ink-2: #333;
    --rule: #999; --rule-strong: #000; --signal: #000; --amber: #000; --ok: #000;
    --signal-tint: #fff; --amber-tint: #fff;
  }
  body { font: 10pt/1.45 var(--f-display); background: #fff; color: #000; }
  .masthead, .sidebar, .rail, .pager, .copy, .skip, .headerlink, .hero-cta, .colophon p + p { display: none !important; }
  .frame { display: block; padding: 0; max-width: none; }
  main { padding: 0; }
  article, .page-source { max-width: none; }
  .prose > h2::before { position: static; margin-right: 0.5em; }
  .prose h2, .prose h3 { break-after: avoid; }
  .code, .table-wrap, .plate { break-inside: avoid; }
  tr, .code pre { break-inside: avoid; }
  .code pre, .term { white-space: pre-wrap; overflow: visible; }
  .table-wrap { overflow: visible; }
  tbody tr:hover td { background: none; }
  .prose a[rel~="external"]::after { content: " <" attr(href) ">"; font: 8pt var(--f-mono); }
  .plates { background: none; }
  .page-source a::after { content: " — " attr(href); }
}
