/* =========================================================================
   SmartDocs — public reading surface.
   Transcribed from design/SmartDocs.dc.html + design/Stamp.dc.html, with the
   color tokens pinned to DESIGN.md. Dark is the first-class default; light is
   selected via [data-theme="light"]. Fully readable with JS disabled.
   ========================================================================= */

/* ---- Self-hosted fonts (latin subset, woff2) ---------------------------- */

/* Inter — chrome / UI text */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-v20-latin-600.woff2') format('woff2');
}

/* Source Serif 4 — reading / doc body */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/source-serif-4-v14-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/source-serif-4-v14-latin-600.woff2') format('woff2');
}

/* Space Grotesk — display / headings / wordmark / eyebrows */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/space-grotesk-v22-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/space-grotesk-v22-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/space-grotesk-v22-latin-700.woff2') format('woff2');
}

/* JetBrains Mono — code / terminal / logs */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-v24-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-v24-latin-500.woff2') format('woff2');
}

/* ---- Color tokens (pinned to DESIGN.md) --------------------------------- */

/* Dark — first-class default (devs live here). */
:root {
  --bg: #0E1014;
  --surface: #15181E;
  --ink: #E8E6E1;
  --muted: #969BA3;
  --hairline: #262A31;
  --brand: #6E84FF;
  --brand-weak: #1B2140;
  --verified: #4ECB86;
  --verified-weak: #16271E;
  --stale: #E0A035;
  --danger: #FF6B6B;
  --code-bg: #11141A;
  --grid: rgba(255, 255, 255, .035);

  --font-chrome: 'Inter', system-ui, sans-serif;
  --font-read: 'Source Serif 4', Georgia, serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

/* Light. */
[data-theme="light"] {
  --bg: #FBFAF7;
  --surface: #FFFFFF;
  --ink: #1A1C20;
  --muted: #5B6068;
  --hairline: #E6E3DC;
  --brand: #2A43B8;
  --brand-weak: #ECEFFB;
  --verified: #1F7A4D;
  --verified-weak: #E3F2E9;
  --stale: #B5730F;
  --danger: #C2392F;
  --code-bg: #F6F4EF;
  --grid: rgba(26, 28, 32, .04);
}

/* ---- Base --------------------------------------------------------------- */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-chrome);
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--brand) 30%, transparent); }

a { color: var(--brand); }

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

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Chrome bar --------------------------------------------------------- */

.chrome {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 54px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  position: relative;
  width: 26px;
  height: 26px;
  flex: none;
  border: 1.5px solid var(--brand);
  border-radius: 5px;
  transform: rotate(45deg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-check {
  transform: rotate(-45deg);
  /* Brand indigo, not verified-green: green is reserved for the verification
     stamp so it always means "proven" (DESIGN.md). */
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.02em;
}
.chrome-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 11px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease;
}
.theme-toggle:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.theme-icon { font-size: 14px; }

/* Sign-in: crosses to the authoring plane (/app). Brand-filled so it reads as
   the primary affordance for editors arriving from a published page. */
.signin-link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 13px;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 7px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: filter 150ms ease;
}
.signin-link:hover { filter: brightness(1.08); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-weak);
  border: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand);
}

/* ---- Three-column reading layout ---------------------------------------- */

.reading {
  flex: 1;
  min-height: 0;
  display: grid;
  /* Default to two columns (nav + article). The right TOC column is only added
     when a TOC is actually rendered, so short docs that drop the redundant TOC
     reflow wider instead of leaving an empty 232px gutter. */
  grid-template-columns: 266px minmax(0, 1fr);
  min-height: calc(100vh - 54px);
}
.reading:has(.rail-right) {
  grid-template-columns: 266px minmax(0, 1fr) 232px;
}

/* Sticky rails: the left nav/search and right TOC stay pinned below the 54px
   chrome bar while the center content scrolls. align-self:start keeps each rail
   only as tall as its content so sticky has room to move; the rail scrolls
   internally if it outgrows the viewport. */
.rail-left,
.rail-right {
  position: sticky;
  top: 54px;
  align-self: start;
  max-height: calc(100vh - 54px);
  overflow-y: auto;
}

/* left rail */
.rail-left {
  border-right: 1px solid var(--hairline);
  padding: 20px 14px;
  background: color-mix(in srgb, var(--surface) 35%, var(--bg));
}
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  color: var(--muted);
}
.search-icon { font-size: 13px; }
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}
.search kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 6px;
}
.nav-tree {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.nav-group-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 11px 7px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 150ms ease, color 150ms ease;
  min-width: 0; /* allow flex children to shrink below content size */
}
.nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item:hover {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  color: var(--ink);
}
.nav-item-active {
  color: var(--brand);
  background: var(--brand-weak);
  font-weight: 600;
}
.nav-item-active:hover { color: var(--brand); }
/* Subtle green dot on nav items whose doc has ≥1 verified block.
   flex:none keeps the dot visible even when the label truncates. */
.nav-item-verified {
  display: block;
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--verified);
}

/* reading column */
.article {
  min-width: 0;
  padding: 46px 8% 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.article-inner {
  width: 100%;
  max-width: 680px; /* ~68ch measure (DESIGN.md: 66-72ch) */
  /* Fill the article's height and let the body grow, so short docs ground their
     provenance footer at the bottom instead of floating mid-page (audit N1). */
  flex: 1;
  display: flex;
  flex-direction: column;
}
.doc-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: -.022em;
  margin: 0 0 16px;
}

/* ---- Near-title trust card -------------------------------------------------
   A calm, single-line provenance strip above the title, shown on every doc
   (markdown-derived). Pure-prose pages render no strip at all. */
.doc-trust {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: .005em;
  margin: 0 0 18px;
  color: var(--muted);
}
.doc-trust-icon { font-size: 12px; }
.doc-trust-label { font-weight: 600; }
.doc-trust-verified { color: var(--verified); }
/* Partially verified (proof-semantics D1): a verified doc where only some code
   blocks are proven. Qualified amber tone — distinct from green verified and red
   failed — reusing the staleness palette so it never reads as full green. */
.doc-trust-partial { color: var(--stale); }
.doc-trust-stale { color: var(--stale); }
/* Passed with fixes (proof-semantics phase A1): the latest run passed but only via
   a correction not yet applied to this page. Qualified amber — never full green —
   mirroring the editor's needs-accept state for cross-plane honesty. */
.doc-trust-needs-accept { color: var(--stale); }
.doc-trust-failed { color: var(--danger); }
.doc-trust-cancelled { color: var(--stale); }
.doc-trust-unverified { color: var(--muted); }
.doc-trust-expired { color: var(--stale); }
.doc-trust-count { color: var(--muted); font-weight: 400; }
.doc-trust-changed { color: var(--stale); font-weight: 400; }

/* Enrichment line (#3): freshness + env + proof link, on its own row below the
   pill. flex-basis:100% forces a line break within the wrapping .doc-trust flex. */
.doc-trust-meta {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.doc-trust-fresh { color: var(--muted); }
.doc-trust-aging { color: var(--stale); font-weight: 500; }
/* Caution line for "Passed with fixes" — small, muted-amber, never a green claim. */
.doc-trust-caution { color: var(--stale); font-weight: 400; }
.doc-trust-proof {
  color: var(--brand);
  font-weight: 500;
  text-decoration: none;
}
.doc-trust-proof:hover { text-decoration: underline; }

/* :target highlight (proof-semantics D2). The "Jump to verified block" link
   anchors to #verified-block-N; on arrival the targeted block briefly outlines so
   the jump is visibly felt rather than landing silently. Works with JS disabled. */
[id^="verified-block-"]:target {
  outline: 2px solid var(--brand);
  outline-offset: 4px;
  border-radius: 4px;
  animation: vd-target-flash 1.6s ease-out 1;
}
@keyframes vd-target-flash {
  0%   { background: var(--brand-weak); }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  [id^="verified-block-"]:target { animation: none; }
}

/* ---- Reading typography (serif body, big rhythm) ------------------------ */

.doc-body {
  font-family: var(--font-read);
  font-size: 1.0625rem; /* 17px, within DESIGN.md 1.0625-1.125rem */
  line-height: 1.7;
  color: var(--ink);
  flex: 1 0 auto; /* grow to fill short pages; natural height on long ones */
}
.doc-body p { margin: 0 0 16px; max-width: 72ch; }
.doc-body > p:first-child { font-size: 18px; margin-bottom: 30px; }
.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
  scroll-margin-top: 70px;
}
/* The body's first H1 is the page title (we no longer render a separate
   doc-title H1 — that produced a duplicate heading). Give it title scale. */
.doc-body h1 { font-size: 42px; font-weight: 700; line-height: 1.08; letter-spacing: -.022em; margin: 0 0 18px; }
.doc-body h2 { font-size: 25px; margin: 44px 0 12px; }
.doc-body h3 { font-size: 20px; margin: 30px 0 10px; }
.doc-body h4 { font-size: 17px; margin: 24px 0 8px; }
.doc-body ul,
.doc-body ol { padding-left: 22px; margin: 0 0 14px; }
.doc-body li { margin-bottom: 4px; }
.doc-body a { text-decoration: underline; text-underline-offset: 2px; }

/* Article footer: grounds short docs and restates the verification provenance
   in a plain sentence (audit P5). Only rendered for verified docs. */
.doc-footer {
  display: flex; align-items: center; gap: 8px;
  margin-top: 56px; padding-top: 18px;
  border-top: 1px solid var(--hairline);
  font-size: 13px; color: var(--muted);
}
.doc-footer-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; flex: none;
  border-radius: 50%; background: var(--verified-weak); color: var(--verified);
  font-size: 11px; font-weight: 700;
}
.doc-footer-meta { font-family: var(--font-mono); color: var(--ink); }
.doc-body blockquote {
  margin: 22px 0;
  padding-left: 16px;
  border-left: 3px solid var(--hairline);
  color: var(--muted);
}
.doc-body img { max-width: 100%; height: auto; }
.doc-body hr { border: none; border-top: 1px solid var(--hairline); margin: 32px 0; }

/* inline code */
.doc-body code {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  background: var(--code-bg);
  border: 1px solid color-mix(in srgb, var(--hairline) 100%, var(--ink) 18%);
  border-radius: 4px;
  padding: 2px 7px;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* ---- Code blocks (chroma-highlighted, copy button) ---------------------- */

.doc-body pre {
  margin: 0 0 24px;
  padding: 15px 16px;
  overflow-x: auto;
  background: var(--code-bg);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  font-feature-settings: "liga" 0, "calt" 0;
}
/* code inside a pre: no inline-code chrome */
.doc-body pre code {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: inherit;
}
/* chroma wrapper (render pipeline emits .chroma) */
.doc-body .chroma {
  background: var(--code-bg);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  overflow: hidden;
  margin: 0 0 24px;
}
.doc-body .chroma pre {
  margin: 0;
  border: none;
  border-radius: 0;
}

/* code block with filename caption (figure/figcaption) */
.doc-body figure {
  margin: 0 0 24px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  overflow: hidden;
  background: var(--code-bg);
}
.doc-body figure pre,
.doc-body figure .chroma { border: none; border-radius: 0; margin: 0; }
.doc-body figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 13px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* ---- Premium code block: header bar (language + copy) ------------------- */
/* The render pipeline wraps every fenced code block in
   .vd-code > (.vd-code-head + chroma <pre>). The card owns the border/radius;
   the inner pre is flattened so the header, code, and (optional) verified
   footer read as one contiguous card. */
.doc-body .vd-code {
  margin: 0 0 24px;
  border: 1px solid var(--hairline);
  border-radius: 9px;
  overflow: hidden;
  background: var(--code-bg);
}
.doc-body .vd-code .chroma,
.doc-body .vd-code > pre {
  margin: 0;
  border: none;
  border-radius: 0;
}
.doc-body .vd-code-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px 7px 13px;
  border-bottom: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--ink) 3%, var(--code-bg));
}
.doc-body .vd-code-lang {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .04em;
  text-transform: lowercase;
  color: var(--muted);
}
.doc-body .vd-code-name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  opacity: .55;
}
.doc-body .vd-code-copy {
  flex: none;
  margin-left: auto;
  padding: 3px 10px;
  font-family: var(--font-chrome);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.doc-body .vd-code-copy:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--ink) 25%, var(--hairline));
}
.doc-body .vd-code-copy:disabled {
  opacity: .5;
  cursor: default;
}
/* Success state set by enhance.js when text is copied. */
.doc-body .vd-code-copy.is-copied {
  color: var(--verified);
  border-color: color-mix(in srgb, var(--verified) 45%, transparent);
}

/* ---- Callouts (render pipeline emits .callout.callout-<kind>) ----------- */

.doc-body .callout {
  display: block;
  padding: 15px 17px;
  margin: 22px 0;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  /* A thicker colored left rule so a callout reads as a semantic admonition. */
  border-left-width: 3px;
  font-family: var(--font-read);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
}
.doc-body .callout > :first-child { margin-top: 0; }
.doc-body .callout > :last-child { margin-bottom: 0; }
.doc-body .callout p:not(.callout-title) { margin: 0 0 8px; }

/* Title row: icon + label rendered as real markup in the HTML. */
.doc-body .callout-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--ink);
}
.doc-body .callout-icon {
  flex: none;
  font-style: normal;
  font-size: 15px;
  line-height: 1;
}

/* note / info — blueprint indigo */
.doc-body .callout-note,
.doc-body .callout-info {
  background: var(--brand-weak);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
}
.doc-body .callout-note .callout-icon,
.doc-body .callout-info .callout-icon {
  color: var(--brand);
}

/* tip — brand (no distinct success/teal token exists) */
.doc-body .callout-tip {
  background: var(--brand-weak);
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
}
.doc-body .callout-tip .callout-icon {
  color: var(--brand);
}

/* warning — amber/stale */
.doc-body .callout-warning {
  background: color-mix(in srgb, var(--stale) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--stale) 35%, transparent);
}
.doc-body .callout-warning .callout-icon {
  color: var(--stale);
}

/* danger — red */
.doc-body .callout-danger {
  background: color-mix(in srgb, var(--danger) 11%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.doc-body .callout-danger .callout-icon {
  color: var(--danger);
}

/* ---- Verified proof check glyph (emitted inside the .vd-proof-chip) ------- */
.doc-body .vd-bv-check {
  font-size: 13px;
  font-weight: 700;
  color: var(--verified);
  line-height: 1;
}

/* ---- Proof coverage map ------------------------------------------------- */

/* Proof coverage map */
.doc-coverage { margin-top: .5rem; display: flex; flex-direction: column; gap: .15rem; }
.doc-coverage-title { font-size: .8rem; font-weight: 600; color: var(--muted, #667); }
.doc-coverage-row { font-size: .85rem; text-decoration: none; color: inherit; padding: .1rem .25rem; border-radius: 4px; }
.doc-coverage-row:hover { background: var(--surface-2, #f3f4f6); }
.doc-coverage-row--unverified { color: var(--muted, #889); }
.doc-coverage-mark { display: inline-block; width: 1.1em; }

/* Copy proof link */
.doc-trust-copy { margin-top: .5rem; font: inherit; font-size: .85rem; cursor: pointer; }

/* Per-block proof receipt */
.vd-proof { margin: -0.4rem 0 1rem; font-size: .85rem; }
.vd-proof-chip { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; list-style: none;
  color: var(--verified, #166534); font-weight: 600; }
.vd-proof-chip::-webkit-details-marker { display: none; }
.vd-proof-body { margin-top: .4rem; padding: .5rem .75rem; border-left: 3px solid var(--verified, #166534);
  background: var(--surface-2, #f6f8f6); border-radius: 4px; display: flex; flex-direction: column; gap: .2rem; }
.vd-proof-support { color: var(--muted, #667); }

/* Coverage jump highlight (zero-JS via :target). The anchor span sits directly
   before the rendered code block, which the pipeline wraps in .vd-code
   (codeWrapperRenderer) — so the anchor's adjacent sibling is .vd-code. */
.vd-code-anchor { display: block; scroll-margin-top: 5rem; }
.vd-code-anchor:target + .vd-code { outline: 2px solid var(--verified, #166534); outline-offset: 3px; border-radius: 8px; }

/* ---- Right TOC ---------------------------------------------------------- */

.rail-right {
  border-left: 1px solid var(--hairline);
  padding: 48px 18px;
}
.toc-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 13px;
}
.toc {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  border-left: 1px solid var(--hairline);
}
.toc-link {
  padding: 4px 0 4px 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms ease;
}
.toc-link:hover { color: var(--ink); }
.toc-link.toc-active {
  margin-left: -1px;
  border-left: 2px solid var(--brand);
  color: var(--brand);
  font-weight: 500;
}
.toc-level-3 { padding-left: 24px; }
.toc-level-4 { padding-left: 34px; }

/* ---- Doc-meta panel (sparse pages: TocEnabled but < 2 headings) --------- */
/* Shown in the right rail instead of the TOC when the page is too short to
   warrant a table of contents. Matches the TOC's visual language. */

.doc-meta {
  padding-top: 2px; /* align label baseline with .toc-label */
}
.doc-meta-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 13px;
}
.doc-meta-row {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  padding: 4px 0;
  border-top: 1px solid var(--hairline);
}
/* Remove the top border from the first visible row.
   :first-of-type can't be used because .doc-meta-label is also a <div>,
   so no .doc-meta-row is ever the first <div> in the container. The label
   is always the direct predecessor of the first row (whether or not the
   date row is present), so the adjacent-sibling combinator is exact. */
.doc-meta-label + .doc-meta-row {
  border-top: none;
}
.doc-meta-verified {
  color: var(--verified);
}
.doc-meta-source {
  color: var(--muted);
  text-decoration: none;
  transition: color 150ms ease;
}
.doc-meta-source:hover { color: var(--ink); }
.doc-meta-trust {
  font-size: 13px;
}
.trust-verified {
  color: var(--verified);
}
.trust-stale {
  color: var(--stale);
}
.trust-muted {
  color: var(--muted);
}
.doc-meta-changed {
  color: var(--stale);
}

/* ---- Responsive (mobile: rails collapse) -------------------------------- */

/* Hamburger (mobile nav drawer trigger) — hidden on desktop, shown <=760px. */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: -4px;
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 7px;
  color: var(--ink);
  cursor: pointer;
}
.nav-toggle:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 54px 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 55;
}
.nav-backdrop.open { display: block; }

@media (max-width: 1080px) {
  .reading, .reading:has(.rail-right) { grid-template-columns: 240px minmax(0, 1fr); }
  .rail-right { display: none; }
}
@media (max-width: 760px) {
  .reading, .reading:has(.rail-right) { grid-template-columns: minmax(0, 1fr); }
  .article { padding: 32px 22px 70px; }
  .doc-title, .doc-body h1 { font-size: 32px; }
  .nav-toggle { display: inline-flex; }
  /* Left rail becomes an off-canvas drawer instead of vanishing (P3). */
  .rail-left {
    position: fixed;
    top: 54px;
    left: 0;
    bottom: 0;
    width: min(280px, 82vw);
    z-index: 60;
    background: var(--surface);
    border-right: 1px solid var(--hairline);
    box-shadow: 2px 0 18px rgba(0, 0, 0, 0.28);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  .rail-left.open { transform: translateX(0); }
}

/* ---- Reduced motion ----------------------------------------------------- */

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

/* ---- Export dropdown (progressive enhancement) -------------------------- */
/* No-JS: .export-trigger is hidden; .export-menu shows as a calm inline-flex
   group of links so the Markdown download stays reachable.
   JS-on: enhance.js adds .js to <html>, reveals the trigger, collapses the
   menu to a positioned popover, and wires toggle/outside-click/Escape. */

.export { position: relative; display: inline-flex; align-items: center; }

/* No-JS: trigger is invisible (JS hasn't run to wire it, so show menu inline). */
.export-trigger { display: none; }

/* No-JS: menu is a small inline-flex row of links. */
.export-menu {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}
.export-menu a,
.export-menu button {
  font: inherit; font-size: 0.8rem; color: var(--muted);
  background: transparent; border: 1px solid var(--hairline);
  border-radius: 0.375rem; padding: 0.2rem 0.5rem; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.export-menu a:hover,
.export-menu button:hover { color: var(--ink); border-color: var(--muted); }

/* JS-on: show the trigger button (styled like .theme-toggle). */
.js .export-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 7px;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease;
}
.js .export-trigger:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

/* JS-on: menu becomes an absolute popover (hidden attribute toggled by JS). */
.js .export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
/* When JS has collapsed the menu (hidden attr set), display:none wins. */
.js .export-menu[hidden] { display: none; }
/* When open, override to flex so items stack vertically. */
.js .export-menu:not([hidden]) { display: flex; }

.js .export-menu a,
.js .export-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 5px;
  padding: 6px 10px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
}
.js .export-menu a:hover,
.js .export-menu button:hover {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: var(--ink);
  border-color: transparent;
}

.export-note { display: block; padding: 6px 13px 4px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--hairline); margin-top: 4px; }
.search-hl { background: var(--brand-weak); color: inherit; border-radius: 2px; }
.search-meta { margin:0; padding:6px 13px; font-size:11px; color:var(--muted); letter-spacing:.02em; }
.search-hints { border-top:1px solid var(--hairline); }
.search-empty { margin:0; padding:10px 13px; font-size:13px; color:var(--muted); }
.search-incontent { color:var(--muted); font-size:12px; }

/* Declutter the mobile header (P4). */
@media (max-width: 760px) { .export { display: none; } }

/* ---- Print: show only the article; hide all chrome, rails, controls ----- */

@media print {
  [data-chrome] { display: none !important; }
  .chrome, .rail-left, .rail-right, .toc, .theme-toggle, .export { display: none !important; }
  .reading { display: block !important; }
  .article { margin: 0 !important; max-width: none !important; width: auto !important; padding: 0 !important; }
  .article-inner { max-width: none !important; }
  body { background: #fff !important; color: #111 !important; }
  pre, code { background: #f5f5f5 !important; color: #111 !important; border-color: #ccc !important; }
  a { color: #111 !important; text-decoration: underline; }
  @page { margin: 18mm 16mm; }
}
