/* ==========================================================================
   LocalNPC — split-harness documentation site
   One stylesheet. No frameworks, no build step, no remote assets.
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  color-scheme: light dark;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* Light (warm paper / ink) */
  --bg: #f4f2ec;
  --bg-sunk: #eae6dd;
  --panel: #fffefb;
  --panel-2: #f7f5ef;
  --term-bg: #14181a;
  --term-ink: #d9e0dd;
  --ink: #191d1b;
  --ink-2: #454e4a;
  --ink-3: #6c766f;
  --line: #d7d1c4;
  --line-2: #c2bbaa;
  --accent: #0f6b47;
  --accent-soft: #dceee5;
  --amber: #8a5510;
  --amber-soft: #f6e8cf;
  --danger: #a02f28;
  --danger-soft: #f6dedc;
  --violet: #4b3f7a;
  --violet-soft: #e6e2f2;

  /* Diagram tokens (referenced by inline SVG) */
  --svg-surface: #fffefb;
  --svg-surface-2: #f0ece2;
  --svg-stroke: #b7b0a0;
  --svg-stroke-strong: #6c766f;
  --svg-ink: #191d1b;
  --svg-ink-2: #5b645f;
  --svg-accent: #0f6b47;
  --svg-accent-fill: #dceee5;
  --svg-amber: #8a5510;
  --svg-amber-fill: #f6e8cf;
  --svg-danger: #a02f28;
  --svg-danger-fill: #f6dedc;
  --svg-violet: #4b3f7a;
  --svg-violet-fill: #e6e2f2;

  --texture-opacity: 0.05;
  --texture-blend: multiply;

  --radius: 3px;
  --rail-w: 14.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e0d;
    --bg-sunk: #070909;
    --panel: #121715;
    --panel-2: #171d1a;
    --term-bg: #080b0a;
    --term-ink: #cfd8d3;
    --ink: #dde3e0;
    --ink-2: #a4afaa;
    --ink-3: #7c8781;
    --line: #232b28;
    --line-2: #313b37;
    --accent: #6fd6a0;
    --accent-soft: #10261c;
    --amber: #e6b866;
    --amber-soft: #2a2115;
    --danger: #ef8b83;
    --danger-soft: #2c1715;
    --violet: #b0a4e6;
    --violet-soft: #1c1930;

    --svg-surface: #131917;
    --svg-surface-2: #1b2320;
    --svg-stroke: #384340;
    --svg-stroke-strong: #7c8781;
    --svg-ink: #dde3e0;
    --svg-ink-2: #98a39e;
    --svg-accent: #6fd6a0;
    --svg-accent-fill: #10261c;
    --svg-amber: #e6b866;
    --svg-amber-fill: #2a2115;
    --svg-danger: #ef8b83;
    --svg-danger-fill: #2c1715;
    --svg-violet: #b0a4e6;
    --svg-violet-fill: #1c1930;

    --texture-opacity: 0.045;
    --texture-blend: screen;
  }
}

/* --- 2. Reset & base ----------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.62;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

/* Subtle circuit texture, fixed behind everything. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("circuit.png");
  background-size: 760px auto;
  background-repeat: repeat;
  opacity: var(--texture-opacity);
  mix-blend-mode: var(--texture-blend);
  pointer-events: none;
  z-index: 0;
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: from-font;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

p code,
li code,
td code,
th code,
dt code,
dd code,
figcaption code,
caption code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.05em 0.32em;
  /* Long identifiers and message strings must wrap rather than force the page
     wider than the viewport. */
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 40;
  background: var(--panel);
  color: var(--ink);
  padding: 0.7rem 1.1rem;
  border: 1px solid var(--accent);
}

.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* --- 3. Shell: rail + harness ------------------------------------------- */

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-sunk);
  padding: 1.5rem 1.1rem 2rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.rail-mark {
  display: block;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.rail-mark span {
  display: block;
  font-weight: 400;
  font-size: 0.68rem;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.3rem;
}

.rail-head {
  margin: 1.9rem 0 0.55rem;
  font-size: 0.63rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.rail nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: railitem;
}

.rail nav li {
  margin: 0;
}

.rail nav a {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.3rem 0.45rem 0.3rem 0.4rem;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  line-height: 1.35;
}

.rail nav a::before {
  counter-increment: railitem;
  content: counter(railitem, decimal-leading-zero);
  color: var(--ink-3);
  font-size: 0.68rem;
  flex: none;
}

.rail nav a:hover {
  color: var(--ink);
  background: var(--panel-2);
}

.rail nav a[aria-current="page"] {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.rail-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 0.68rem;
  line-height: 1.7;
}

.rail-foot a {
  color: var(--ink-2);
}

/* --- 4. Masthead (status-line, not a hero) ------------------------------ */

.harness {
  min-width: 0;
  padding: 0 clamp(1rem, 3.2vw, 3.25rem) 4rem;
}

.masthead {
  border-bottom: 1px solid var(--line);
  padding: 1.4rem 0 1.9rem;
  margin-bottom: 0.5rem;
}

.statusline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  margin: 0 0 1rem;
}

.statusline b {
  font-weight: 600;
  color: var(--accent);
}

.statusline .sep {
  color: var(--line-2);
}

.masthead h1 {
  font-size: clamp(1.65rem, 3.4vw, 2.55rem);
  line-height: 1.14;
  letter-spacing: -0.018em;
  margin: 0 0 0.65rem;
  max-width: 22ch;
}

.masthead .standfirst {
  margin: 0;
  max-width: 62ch;
  font-size: 1.06rem;
  color: var(--ink-2);
}

/* --- 5. The split harness ----------------------------------------------- */

.seg {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(19rem, 26rem);
  gap: 1.5rem clamp(1.5rem, 3vw, 3rem);
  align-items: start;
  padding: 2.6rem 0 3rem;
  border-bottom: 1px solid var(--line);
}

.seg:last-of-type {
  border-bottom: 0;
}

.prose {
  min-width: 0;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2 {
  font-size: 1.42rem;
  line-height: 1.24;
  letter-spacing: -0.012em;
  margin: 0 0 0.9rem;
  max-width: 30ch;
}

.prose h2 .idx {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.prose h3 {
  font-size: 1.02rem;
  margin: 2rem 0 0.6rem;
  letter-spacing: -0.005em;
}

.prose h4 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 1.6rem 0 0.5rem;
}

.prose p,
.prose li {
  max-width: 68ch;
}

.prose p {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1.15rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.42rem;
}

.prose ul li::marker {
  color: var(--accent);
}

.prose ol li::marker {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.lede {
  font-size: 1.08rem;
  color: var(--ink-2);
}

/* Sticky trace panel — the right rail of the harness */
.trace {
  position: sticky;
  top: 1.25rem;
  min-width: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--term-bg);
  color: var(--term-ink);
  font-family: var(--font-mono);
  font-size: 0.735rem;
  line-height: 1.62;
  overflow: hidden;
  box-shadow: 0 1px 0 var(--line);
}

.trace-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  background: #1d2422;
  border-bottom: 1px solid #2b3532;
  color: #8d9b95;
  font-size: 0.66rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.trace-bar .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fd6a0;
  flex: none;
}

.trace-bar .dot.warn {
  background: #e6b866;
}

.trace-bar .dot.stop {
  background: #ef8b83;
}

.trace-bar .grow {
  margin-left: auto;
  text-transform: none;
  letter-spacing: 0.02em;
  color: #66736e;
}

.trace-body {
  padding: 0.7rem 0.75rem 0.85rem;
  overflow-x: auto;
}

.trace-body > *:first-child {
  margin-top: 0;
}

.trace-body > *:last-child {
  margin-bottom: 0;
}

.trace ul {
  list-style: none;
  margin: 0 0 0.7rem;
  padding: 0;
}

.trace li {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.1rem 0;
}

/* A fixed grid column clipped long labels into the value; a flex basis lets a
   short label align and a long one take the room it needs. */
.trace li > span:first-child {
  color: #5f6d67;
  flex: 0 0 auto;
  min-width: 4.2rem;
  white-space: nowrap;
}

.trace li > span:last-child {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.trace .k-ok {
  color: #6fd6a0;
}
.trace .k-warn {
  color: #e6b866;
}
.trace .k-err {
  color: #ef8b83;
}
.trace .k-dim {
  color: #7f8c86;
}
.trace .k-hi {
  color: #f0f5f2;
}
.trace .k-vio {
  color: #b0a4e6;
}

.trace h3 {
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #7f8c86;
  margin: 1rem 0 0.4rem;
  font-weight: 500;
}

.trace p {
  margin: 0 0 0.6rem;
  color: #9aa8a2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.trace dl {
  margin: 0 0 0.6rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.05rem 0.7rem;
}

.trace dt {
  color: #6b7873;
}

.trace dd {
  margin: 0;
  color: var(--term-ink);
  word-break: break-word;
}

.trace .rule {
  height: 1px;
  background: #263029;
  margin: 0.75rem 0;
}

.trace .meter {
  display: block;
  height: 6px;
  background: #232c29;
  border-radius: 1px;
  overflow: hidden;
  margin: 0.15rem 0 0.55rem;
}

.trace .meter i {
  display: block;
  height: 100%;
  background: #6fd6a0;
}

.trace .meter i.warn {
  background: #e6b866;
}

/* --- 6. Figures & diagrams ---------------------------------------------- */

.fig {
  margin: 1.8rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 1rem 1rem 0.85rem;
  overflow: hidden;
}

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

.fig figcaption {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
  font-size: 0.83rem;
  color: var(--ink-2);
  line-height: 1.55;
  max-width: 78ch;
}

.fig figcaption b {
  color: var(--ink);
  font-weight: 600;
}

/* SVG primitive classes */
.d-surface {
  fill: var(--svg-surface);
  stroke: var(--svg-stroke);
  stroke-width: 1;
}
.d-surface-2 {
  fill: var(--svg-surface-2);
  stroke: var(--svg-stroke);
  stroke-width: 1;
}
.d-accent {
  fill: var(--svg-accent-fill);
  stroke: var(--svg-accent);
  stroke-width: 1.3;
}
.d-amber {
  fill: var(--svg-amber-fill);
  stroke: var(--svg-amber);
  stroke-width: 1.3;
}
.d-danger {
  fill: var(--svg-danger-fill);
  stroke: var(--svg-danger);
  stroke-width: 1.3;
}
.d-violet {
  fill: var(--svg-violet-fill);
  stroke: var(--svg-violet);
  stroke-width: 1.3;
}
.d-zone {
  fill: none;
  stroke: var(--svg-stroke);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}
.d-line {
  fill: none;
  stroke: var(--svg-stroke-strong);
  stroke-width: 1.4;
}
.d-line-a {
  fill: none;
  stroke: var(--svg-accent);
  stroke-width: 1.6;
}
.d-line-d {
  fill: none;
  stroke: var(--svg-danger);
  stroke-width: 1.5;
}
.d-line-m {
  fill: none;
  stroke: var(--svg-amber);
  stroke-width: 1.5;
}
.d-dash {
  fill: none;
  stroke: var(--svg-stroke-strong);
  stroke-width: 1.2;
  stroke-dasharray: 5 4;
}
.d-t {
  fill: var(--svg-ink);
  font-family: var(--font-mono);
  font-size: 12px;
}
.d-t-b {
  fill: var(--svg-ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
}
.d-t-s {
  fill: var(--svg-ink-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
}
.d-t-xs {
  fill: var(--svg-ink-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
}
.d-t-cap {
  fill: var(--svg-ink-2);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.4px;
}
.d-t-a {
  fill: var(--svg-accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.d-t-m {
  fill: var(--svg-amber);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.d-t-d {
  fill: var(--svg-danger);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.d-t-v {
  fill: var(--svg-violet);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.d-arrow {
  fill: var(--svg-stroke-strong);
}
.d-arrow-a {
  fill: var(--svg-accent);
}
.d-arrow-d {
  fill: var(--svg-danger);
}
.d-arrow-m {
  fill: var(--svg-amber);
}

/* --- 7. Terminal renderings --------------------------------------------- */

.term {
  margin: 1.8rem 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--term-bg);
}

.term-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.8rem;
  background: #1d2422;
  border-bottom: 1px solid #2b3532;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #8d9b95;
  letter-spacing: 0.06em;
}

.term-bar i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3d4a45;
  display: block;
  flex: none;
}

.term-bar i:first-of-type {
  background: #ef8b83;
}
.term-bar i:nth-of-type(2) {
  background: #e6b866;
}
.term-bar i:nth-of-type(3) {
  background: #6fd6a0;
}

.term-bar span {
  margin-left: 0.5rem;
}

.term pre {
  margin: 0;
  padding: 0.9rem 1rem 1.05rem;
  overflow-x: auto;
  color: var(--term-ink);
  font-size: 0.775rem;
  line-height: 1.62;
  tab-size: 2;
}

.term .p {
  color: #6fd6a0;
  font-weight: 700;
}
.term .c {
  color: #f0f5f2;
}
.term .f {
  color: #e6b866;
}
.term .o {
  color: #a9b5b0;
}
.term .k {
  color: #8fbfa8;
}
.term .e {
  color: #ef8b83;
}
.term .d {
  color: #66736e;
}
.term .v {
  color: #b0a4e6;
}

.term-note {
  padding: 0.55rem 1rem 0.65rem;
  border-top: 1px solid #232b28;
  background: #101514;
  color: #7f8c86;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.55;
}

.term-note a {
  color: #8fbfa8;
}

/* --- 8. Code blocks (annotated Rust) ------------------------------------ */

.code {
  margin: 1.6rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
}

.code-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.8rem;
  align-items: baseline;
  padding: 0.42rem 0.8rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--ink-3);
}

.code-head b {
  color: var(--ink-2);
  font-weight: 600;
}

.code pre {
  margin: 0;
  padding: 0.8rem 0.9rem 0.95rem;
  overflow-x: auto;
  font-size: 0.775rem;
  line-height: 1.62;
  color: var(--ink);
}

.code .kw {
  color: var(--violet);
  font-weight: 600;
}
.code .ty {
  color: var(--accent);
}
.code .st {
  color: var(--amber);
}
.code .cm {
  color: var(--ink-3);
  font-style: italic;
}
.code .fn {
  color: var(--ink);
  font-weight: 600;
}
.code .nm {
  color: var(--danger);
}

/* --- 9. Tables ----------------------------------------------------------- */

.tablewrap {
  margin: 1.6rem 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 30rem;
  font-size: 0.855rem;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.71rem;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  background: var(--panel-2);
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  background: var(--panel-2);
  white-space: nowrap;
}

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

tbody th {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Inside a horizontally scrollable table wrapper, keeping identifiers on one
   line is safe — the wrapper scrolls, the page does not. */
.tablewrap td code,
.tablewrap th code {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.yes {
  color: var(--accent);
  font-weight: 600;
}
.no {
  color: var(--ink-3);
}

/* --- 10. Callouts, pull quotes, stat blocks ----------------------------- */

.callout {
  margin: 1.6rem 0;
  padding: 0.85rem 1rem 0.9rem 1.05rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
}

.callout.warn {
  border-left-color: var(--amber);
}
.callout.stop {
  border-left-color: var(--danger);
}

.callout > *:first-child {
  margin-top: 0;
}
.callout > *:last-child {
  margin-bottom: 0;
}

.callout .tag {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.callout.warn .tag {
  color: var(--amber);
}
.callout.stop .tag {
  color: var(--danger);
}

.pull {
  margin: 2rem 0;
  padding: 0.2rem 0 0.2rem 1.15rem;
  border-left: 3px solid var(--line-2);
  font-size: 1.14rem;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 46ch;
}

.pull p {
  margin: 0 0 0.5rem;
  max-width: none;
}

.pull cite {
  display: block;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  color: var(--ink-3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 1px;
  margin: 1.7rem 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}

.stats div {
  background: var(--panel);
  padding: 0.75rem 0.85rem 0.8rem;
}

.stats dt,
.stats .lbl {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.15rem;
}

.stats dd,
.stats .val {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stats .sub {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--ink-3);
  margin-top: 0.15rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.stats dd,
.stats .val {
  overflow-wrap: anywhere;
}

.deflist {
  margin: 1.4rem 0;
  display: grid;
  grid-template-columns: minmax(7rem, auto) minmax(0, 1fr);
  gap: 0.1rem 1rem;
}

.deflist dt {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--accent);
  padding-top: 0.12rem;
}

.deflist dd {
  margin: 0 0 0.6rem;
  max-width: 62ch;
}

/* --- 11. Footer & page links -------------------------------------------- */

.pagefoot {
  border-top: 1px solid var(--line);
  padding-top: 1.6rem;
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  justify-content: space-between;
  align-items: flex-start;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.pagefoot .next {
  max-width: 34ch;
}

.pagefoot .next .lbl {
  display: block;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.2rem;
}

.pagefoot .colophon {
  color: var(--ink-3);
  max-width: 42ch;
  line-height: 1.65;
  font-size: 0.72rem;
}

/* --- 12. Responsive ------------------------------------------------------ */

@media (max-width: 1180px) {
  :root {
    --rail-w: 12.5rem;
  }
  .seg {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 21rem);
  }
}

@media (max-width: 1000px) {
  .seg {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
  .trace {
    position: static;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 1rem 1rem 1.1rem;
  }
  .rail nav ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.35rem;
  }
  .rail nav a {
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 0.25rem 0.5rem;
  }
  .rail nav a[aria-current="page"] {
    border-left: 0;
    border-bottom-color: var(--accent);
  }
  .rail-head {
    margin-top: 1.1rem;
  }
  .rail-foot {
    margin-top: 1.1rem;
  }
  body {
    font-size: 15.5px;
  }
}

@media (max-width: 520px) {
  .harness {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  .fig {
    padding: 0.7rem 0.7rem 0.6rem;
  }
  .term pre,
  .code pre {
    font-size: 0.72rem;
  }
  .deflist {
    grid-template-columns: minmax(0, 1fr);
  }
  .deflist dd {
    margin-bottom: 0.9rem;
  }
  .pull {
    font-size: 1.05rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .rail,
  body::before {
    display: none;
  }
  .shell {
    grid-template-columns: 1fr;
  }
  .trace {
    position: static;
  }
}
