/**
 * The documentation site's stylesheet.
 *
 * ## Shape
 *
 * Three columns on a wide screen — navigation, content, contents-of-this-page —
 * collapsing to two at 1180px and to one with a drawer at 860px. The grid is
 * declared once on `.shell`; nothing below it positions itself absolutely.
 *
 * ## Tokens
 *
 * Every colour, space and size is a custom property, for one concrete reason:
 * the diagrams are inline SVG that consume the same tokens, so they follow the
 * theme toggle. A hard-coded hex here would be a diagram that disagrees with
 * the page around it in dark mode — which is why a test forbids hex in diagram
 * sources.
 *
 * The palette is defined three times on purpose: `:root` for light,
 * `prefers-color-scheme: dark` for people who never touch the toggle, and
 * `[data-theme]` for people who do. The third must win over the second, so it
 * comes last.
 */

/* ── Tokens ──────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces, back to front. Light is warm paper; dark (below) is graphite. */
  --bg: #f3efe8;
  --bg-soft: #ebe6dc;
  --bg-raised: #faf8f3;
  --bg-code: #eae4d9;
  --bg-scrim: rgb(13 14 17 / 50%);

  /* Ink. */
  --fg: #15161a;
  --fg-soft: #42434a;
  --fg-faint: #625f58;

  /* Edges. */
  --line: #dcd5c8;
  --line-strong: #c4bcad;

  /* Accent and status. `--accent` is the text-and-link orange: dark enough to
   * read on paper. `--brand` is the fill orange, always with `--on-brand` ink
   * on it — white on that orange fails contrast, near-black passes. */
  --accent: #b93d0b;
  --accent-hover: #8f2f08;
  --accent-soft: #f8e1d4;
  --brand: #ff5b1f;
  --on-brand: #160600;
  /* The orange as large display text: on paper the fill orange is under 3:1,
   * so headings use this slightly deeper one. */
  --brand-text: #d9480f;
  --green: #2c6b47;
  --amber: #855600;
  --red: #b42318;

  /* The block that inverts the page: the closing call to action. */
  --inverse-bg: #15161a;
  --inverse-fg: #f3efe8;

  /* Syntax. */
  --tok-comment: #6f6b62;
  --tok-string: #2c6b47;
  --tok-keyword: #b93d0b;
  --tok-number: #855600;
  --tok-attr: #2b5596;
  --tok-fn: #6b3a13;

  /* Type. Syne for display, IBM Plex for reading and for code. `--serif` keeps
   * its name because every heading rule reads it; it is the display face. */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Syne", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --display: var(--serif);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.85rem;
  --text-base: 0.95rem;
  --text-lg: 1.1rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.7rem;
  --text-3xl: 2.15rem;

  /* A 4px rhythm. Every margin below is one of these. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Frame. Monolith is square-shouldered: small radii, solid offset shadows. */
  --radius: 4px;
  --radius-lg: 6px;
  --shadow: 0 1px 2px rgb(40 36 24 / 8%), 0 18px 40px -18px rgb(40 36 24 / 28%);
  --shadow-block: 10px 10px 0 rgb(185 61 11 / 14%);
  --side-w: 17rem;
  --toc-w: 15rem;
  --top-h: 3.75rem;
  --measure: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e11;
    --bg-soft: #15171b;
    --bg-raised: #1a1c21;
    --bg-code: #08090b;
    --bg-scrim: rgb(0 0 0 / 66%);
    --fg: #e9e4dc;
    --fg-soft: #b9b3a9;
    --fg-faint: #8f897f;
    --line: #26282e;
    --line-strong: #383b42;
    --accent: #ff6a2b;
    --accent-hover: #ff9466;
    --accent-soft: #2b170e;
    --green: #8fd4a8;
    --amber: #e9bb5f;
    --red: #ff8f7a;
    --inverse-bg: #e9e4dc;
    --inverse-fg: #0d0e11;
    --brand-text: #ff5b1f;
    --tok-comment: #8a847b;
    --tok-string: #9fd8b4;
    --tok-keyword: #ff9466;
    --tok-number: #e9bb5f;
    --tok-attr: #a9c6f0;
    --tok-fn: #f2d3a6;
    --shadow: 0 1px 2px rgb(0 0 0 / 45%), 0 18px 40px -16px rgb(0 0 0 / 70%);
    --shadow-block: 12px 12px 0 rgb(255 91 31 / 14%);
  }
}

:root[data-theme="dark"] {
  --bg: #0d0e11;
  --bg-soft: #15171b;
  --bg-raised: #1a1c21;
  --bg-code: #08090b;
  --bg-scrim: rgb(0 0 0 / 66%);
  --fg: #e9e4dc;
  --fg-soft: #b9b3a9;
  --fg-faint: #8f897f;
  --line: #26282e;
  --line-strong: #383b42;
  --accent: #ff6a2b;
  --accent-hover: #ff9466;
  --accent-soft: #2b170e;
  --green: #8fd4a8;
  --amber: #e9bb5f;
  --red: #ff8f7a;
  --inverse-bg: #e9e4dc;
  --inverse-fg: #0d0e11;
  --brand-text: #ff5b1f;
  --tok-comment: #8a847b;
  --tok-string: #9fd8b4;
  --tok-keyword: #ff9466;
  --tok-number: #e9bb5f;
  --tok-attr: #a9c6f0;
  --tok-fn: #f2d3a6;
  --shadow: 0 1px 2px rgb(0 0 0 / 45%), 0 18px 40px -16px rgb(0 0 0 / 70%);
  --shadow-block: 12px 12px 0 rgb(255 91 31 / 14%);
}

/* ── Base ────────────────────────────────────────────────────────────────── */

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--top-h) + var(--space-4)); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

::selection { background: var(--brand); color: var(--on-brand); }

.icon { width: 1em; height: 1em; flex: none; }

.skip {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--brand);
  color: var(--on-brand);
  border-radius: var(--radius);
  z-index: 60;
}
.skip:focus { left: var(--space-2); }

/* ── Top bar ─────────────────────────────────────────────────────────────── */

.top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--top-h);
  padding: 0 var(--space-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.top__menu {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--fg);
  border-radius: var(--radius);
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-base);
  cursor: pointer;
}

.top__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--fg);
  letter-spacing: -0.015em;
}
.top__brand:hover { text-decoration: none; color: var(--fg); }
.top__brand > span[aria-hidden] { color: var(--brand); font-size: 1.2em; line-height: 1; }
.top__brand-sub { font-family: var(--mono); font-size: var(--text-xs); font-weight: 400; color: var(--fg-faint); letter-spacing: 0; }

.top__version {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px var(--space-2);
}

/* The search trigger sits where a docs reader reaches for it: middle of the
 * bar, always visible, with its own shortcut printed on it. */
.top__search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
  min-width: 17rem;
  min-height: 2.5rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--fg-faint);
  font: inherit;
  font-family: var(--mono);
  font-size: var(--text-sm);
  cursor: pointer;
  text-align: left;
}
.top__search:hover { border-color: var(--accent); color: var(--fg-soft); }
.top__search .icon { display: none; }
/* A prompt, not a magnifier: the search reads like the CLI it documents. */
.top__search::before { content: ">"; color: var(--accent); font-weight: 600; }
.top__search-label { flex: 1; }

.top__kbd, .palette kbd {
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 var(--space-1);
  background: var(--bg);
}
.top__kbd-mod { font-size: 1.05em; }

.top__links { display: flex; gap: var(--space-4); font-size: var(--text-sm); }
.top__links a { color: var(--fg-soft); display: inline-flex; align-items: center; min-height: 44px; }
.top__links a:hover { color: var(--fg); text-decoration: none; }

.top__theme {
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--fg-soft);
  border-radius: var(--radius);
  width: 2.75rem;
  height: 2.75rem;
  cursor: pointer;
  font-size: var(--text-base);
  line-height: 1;
}
.top__theme:hover { color: var(--fg); border-color: var(--line-strong); }

/* ── Shell ───────────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--toc-w);
  gap: var(--space-8);
  max-width: 96rem;
  margin: 0 auto;
  padding: 0 var(--space-6);
  align-items: start;
}

.side {
  position: sticky;
  top: var(--top-h);
  max-height: calc(100vh - var(--top-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6) 0 var(--space-12);
  scrollbar-width: thin;
}

.side__group { border: 0; margin-bottom: var(--space-2); }

.side__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
  user-select: none;
  min-height: 2.25rem;
}
.side__group[open] > .side__head { color: var(--accent); }
.side__head::-webkit-details-marker { display: none; }
.side__head:hover { color: var(--fg-soft); background: var(--bg-soft); }
.side__icon { width: 0.95rem; height: 0.95rem; }

/* The disclosure caret is drawn rather than a glyph, so it can rotate. */
.side__head::after {
  content: "";
  margin-left: auto;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}
.side__group[open] > .side__head::after { transform: rotate(45deg); }

.side ul { list-style: none; margin: var(--space-1) 0 var(--space-4); padding: 0; }

.side li a {
  display: block;
  padding: var(--space-2) var(--space-3);
  margin-left: var(--space-2);
  border-left: 2px solid var(--line);
  color: var(--fg-soft);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.side li a:hover { color: var(--fg); border-left-color: var(--line-strong); text-decoration: none; }
.side li a.is-active {
  color: var(--fg);
  font-weight: 600;
  border-left-color: var(--brand);
  border-left-width: 3px;
  background: var(--accent-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Content column ──────────────────────────────────────────────────────── */

.content {
  min-width: 0;
  padding: var(--space-8) 0 var(--space-16);
}

.crumbs { margin: 0 0 var(--space-4); }
.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.crumbs li + li::before { content: "▸"; margin-right: var(--space-2); color: var(--accent); }
.crumbs li:last-child { color: var(--accent); }
.crumbs a { color: var(--fg-faint); }
.crumbs a:hover { color: var(--fg-soft); }

.prose { max-width: var(--measure); }

/* ── Right rail ──────────────────────────────────────────────────────────── */

.rail {
  position: sticky;
  top: var(--top-h);
  max-height: calc(100vh - var(--top-h));
  overflow-y: auto;
  padding: var(--space-8) 0;
}

.toc h2 {
  margin: 0 0 var(--space-3);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: block;
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  border-left: 2px solid var(--line);
  color: var(--fg-soft);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.toc a:hover { color: var(--fg); text-decoration: none; }
.toc a.is-active { color: var(--accent); border-left-color: var(--brand); }
.toc__l3 a { padding-left: var(--space-6); font-size: var(--text-xs); }

/* ── Prose ───────────────────────────────────────────────────────────────── */

.prose h1 {
  margin: 0 0 var(--space-6);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 1.5rem + 1.8vw, 2.8rem);
  line-height: 1;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
/* Code in a heading reads as a word in it, not as a block beside it. */
.prose :is(h1, h2, h3) code { font-size: 0.72em; padding: 0.05em 0.35em; vertical-align: 0.08em; }

/* A section opens with an orange tick on a hairline — the rule the whole site
 * draws under its headings, and the only ornament it allows itself. */
.prose h2 {
  position: relative;
  margin: var(--space-16) 0 var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.7rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.prose h2::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 0;
  width: 2.5rem;
  height: 3px;
  background: var(--brand);
}
.prose h3 {
  margin: var(--space-8) 0 var(--space-3);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.prose h4 { margin: var(--space-6) 0 var(--space-2); font-size: var(--text-base); }

.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-4); }
.prose li { margin-bottom: var(--space-2); }
.prose li > ul, .prose li > ol { margin-top: var(--space-2); }

.prose strong { font-weight: 600; color: var(--fg); }

/* The anchor appears on hover, and on keyboard focus — a link that only exists
 * for a mouse is a link half the readers never get. */
.anchor {
  margin-left: var(--space-2);
  color: var(--fg-faint);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
}
.prose h2:hover .anchor,
.prose h3:hover .anchor,
.anchor:focus-visible { opacity: 1; }

.prose blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--brand);
  color: var(--fg-soft);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-12) 0; }
/* A `---` right before a section heading drew a second rule above the h2's own. */
.prose hr:has(+ h2) { display: none; }
.prose img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.prose img[src*="-mobile"] { display: block; max-width: min(320px, 100%); margin-inline: auto; border-radius: 22px; }

.prose :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.08em 0.34em;
  overflow-wrap: anywhere;
}

/* ── Code blocks ─────────────────────────────────────────────────────────── */

/* The orange rule on the left and the solid offset shadow are the code
 * block's signature; the shadow sits in the margin, so it never clips text. */
.code {
  margin: var(--space-6) var(--space-3) var(--space-8) 0;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  background: var(--bg-code);
  box-shadow: var(--shadow-block);
  overflow: hidden;
}

.code__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-soft) 60%, transparent);
}

.code__lang {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--fg-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.code__copy {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--fg-soft);
  border-radius: 3px;
  min-height: 1.9rem;
  padding: 2px var(--space-3);
  font: inherit;
  font-family: var(--mono);
  font-size: var(--text-xs);
  cursor: pointer;
}
.code__copy:hover { color: var(--fg); border-color: var(--line-strong); }
.code__copy[data-copied] { color: var(--green); border-color: var(--green); }

.code pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.65;
}
.code code { font-family: var(--mono); }

/* Syntax. Six roles, not sixty: a palette a reader can learn in one page. */
.tok--c { color: var(--tok-comment); font-style: italic; }
.tok--s { color: var(--tok-string); }
.tok--k, .tok--g { color: var(--tok-keyword); font-weight: 600; }
.tok--n { color: var(--tok-number); }
.tok--a, .tok--an, .tok--v, .tok--t { color: var(--tok-attr); }
.tok--f, .tok--o { color: var(--tok-fn); }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  margin: var(--space-6) 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-top: 3px solid var(--fg);
  border-radius: var(--radius);
  background: var(--bg-raised);
}
.table-wrap table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
.table-wrap th, .table-wrap td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table-wrap thead th {
  background: var(--bg-soft);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-soft);
}
.table-wrap tbody tr:last-child td { border-bottom: 0; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.cards {
  display: grid;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}
.cards[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4) var(--space-4);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--line-strong);
  border-top-color: var(--brand);
  text-decoration: none;
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0 var(--fg);
}
.card__icon { color: var(--accent); font-size: var(--text-lg); line-height: 1; }
.card__icon .icon { width: 1.25rem; height: 1.25rem; }
.card__title { color: var(--fg); font-family: var(--display); font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.card__body { color: var(--fg-soft); font-size: var(--text-sm); line-height: 1.6; }

/* ── Tabs ────────────────────────────────────────────────────────────────── */

.tabs { margin: var(--space-6) 0; }
.tabs__list {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs__tab {
  border: 0;
  background: none;
  color: var(--fg-soft);
  font: inherit;
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}
.tabs__tab:hover { color: var(--fg); }
.tabs__tab { min-height: 2.75rem; font-family: var(--mono); }
.tabs__tab[aria-selected="true"] { color: var(--fg); border-bottom: 3px solid var(--brand); font-weight: 600; }
.tabs__panel { padding-top: var(--space-4); }
.tabs__panel > :first-child { margin-top: 0; }
.tabs__panel > :last-child { margin-bottom: 0; }

/* ── Steps ───────────────────────────────────────────────────────────────── */

.steps { list-style: none; margin: var(--space-6) 0; padding: 0; counter-reset: step; }
.steps__step { display: flex; gap: var(--space-4); margin: 0; padding-bottom: var(--space-6); position: relative; }

/* The rule joins one number to the next, so the sequence reads as a sequence. */
.steps__step:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 0.87rem;
  top: 2rem;
  bottom: 0;
  width: 1px;
  background: var(--line);
}
.steps__n {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 2px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--on-brand);
  border: 0;
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 700;
  position: relative;
  z-index: 1;
}
.steps__body { min-width: 0; flex: 1; }
.steps__title { margin: 0.1rem 0 var(--space-2); font-family: var(--display); font-size: 1.05rem; font-weight: 700; }
.steps__body > :last-child { margin-bottom: 0; }

/* ── Callouts ────────────────────────────────────────────────────────────── */

.callout {
  margin: var(--space-6) 0;
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--fg-faint);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.callout__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-soft);
}
.callout__icon { width: 0.95rem; height: 0.95rem; }
.callout__body > :last-child { margin-bottom: 0; }
.callout--note { border-left-color: var(--accent); }
.callout--note .callout__label { color: var(--accent); }
.callout--tip { border-left-color: var(--green); }
.callout--tip .callout__label { color: var(--green); }
.callout--warning { border-left-color: var(--amber); }
.callout--warning .callout__label { color: var(--amber); }
.callout--danger { border-left-color: var(--red); }
.callout--danger .callout__label { color: var(--red); }

/* ── Page furniture ──────────────────────────────────────────────────────── */

.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--line);
  max-width: var(--measure);
}
.pager a {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
  color: var(--fg);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.pager a:hover { text-decoration: none; transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--fg); }
.pager span { font-family: var(--mono); font-size: 0.7rem; font-weight: 400; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-faint); }
.pager__prev span::before { content: "◂ "; }
.pager__next span::after { content: " ▸"; }
.pager__next { text-align: right; }
/* Next is the way forward, so it is the one block the page fills. */
.pager a.pager__next { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.pager a.pager__next span { color: var(--on-brand); opacity: 0.75; }

.page-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-8);
  font-size: var(--text-sm);
  color: var(--fg-faint);
  max-width: var(--measure);
}
.page-foot__ask { margin: 0 auto 0 0; color: var(--fg-soft); }

/* ── Search palette ──────────────────────────────────────────────────────── */

.palette {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding: 8vh var(--space-4) var(--space-4);
}
.palette[hidden] { display: none; }
.palette__scrim { position: absolute; inset: 0; background: var(--bg-scrim); }

.palette__box {
  position: relative;
  width: min(40rem, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  border-top: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.palette__field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  color: var(--fg-faint);
}
.palette__field input {
  flex: 1;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-family: var(--mono);
  font-size: var(--text-base);
  outline: none;
  min-width: 0;
}
.palette__field input::-webkit-search-cancel-button { display: none; }

.palette__results { overflow-y: auto; padding: var(--space-2); }

.palette__group {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.palette__hit {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--fg);
}
.palette__hit:hover, .palette__hit.is-active { background: var(--accent-soft); text-decoration: none; }
.palette__hit.is-active { outline: 1px solid var(--accent); box-shadow: inset 3px 0 0 var(--brand); }
.palette__hit strong { display: block; font-size: var(--text-sm); font-weight: 600; }
.palette__hit span { display: block; font-size: var(--text-xs); color: var(--fg-soft); }
.palette__hit mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; }

.palette__empty { padding: var(--space-8); text-align: center; color: var(--fg-faint); font-size: var(--text-sm); }

.palette__hint {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--line);
  font-size: var(--text-xs);
  color: var(--fg-faint);
}
.palette__esc { flex: none; }

/* ── Documentation home ──────────────────────────────────────────────────── */

.home { margin-top: var(--space-8); }
.home__lede { font-size: var(--text-lg); color: var(--fg-soft); max-width: var(--measure); }
.home__group { margin: var(--space-12) 0 0; }
.home__group h2 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-1);
  padding: 0;
  border: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--text-xl);
}
.home__group h2::before { display: none; }
.home__summary { margin: 0 0 var(--space-4); color: var(--fg-soft); font-size: var(--text-sm); }

/* ── Narrow screens ──────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .rail { display: none; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 0 var(--space-4); }
  .top__menu { display: block; }
  .top__links { display: none; }
  .top__search { min-width: 2.75rem; min-height: 2.75rem; justify-content: center; }
  .top__search-label, .top__kbd { display: none; }
  .top__version { display: none; }

  /* A drawer, not a column: it overlays rather than pushing the text. */
  .side {
    position: fixed;
    inset: var(--top-h) auto 0 0;
    width: min(20rem, 84vw);
    max-height: none;
    padding: var(--space-4);
    background: var(--bg-raised);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    z-index: 45;
  }
  .side.is-open { transform: none; }
  .pager { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .side, .card, .pager a, .side__head::after { transition: none; }
  .card:hover, .pager a:hover { transform: none; }
}

@media (max-width: 560px) {
  .cards[data-cols="2"], .cards[data-cols="3"] { grid-template-columns: minmax(0, 1fr); }
  .prose h1 { font-size: var(--text-2xl); }
  .content { padding-top: var(--space-6); }
}
/* ── Diagrams ────────────────────────────────────────────────────────────────
 *
 * Inlined into the page rather than loaded as `<img src="…svg">`, because the
 * colours are the site's tokens and a custom property does not cross into an
 * externally loaded SVG. An `<img>` diagram would follow the system's
 * `prefers-color-scheme` and ignore the theme toggle — the one case where it
 * would visibly disagree with the page around it.
 */

.dia {
  margin: 2rem 0;
  padding: 0;
}

/* Below `min-width` the diagram scrolls rather than shrinking. A sequence
 * diagram scaled to a 360px screen renders its labels at about five pixels,
 * which is not a diagram — it is a texture. */
.dia__scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.dia__svg {
  display: block;
  width: 100%;
  min-width: 34rem;
  height: auto;
  max-width: 48rem;
  margin: 0 auto;
  font-family: var(--sans);
}

.dia figcaption,
.dia > figcaption {
  margin: 0.9rem auto 0;
  max-width: 44rem;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--fg-soft);
  text-align: center;
}

/* Shared SVG vocabulary. */
.dia__lane rect,
.dia__box rect { fill: var(--bg-soft); stroke: var(--line); stroke-width: 1; }
.dia__box--tool rect { fill: var(--accent-soft); stroke: var(--accent); }
.dia__lane rect, .dia__box rect { rx: 3px; }
.dia__actor text { font-size: 13px; font-weight: 600; fill: var(--fg); }
.dia__life line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; }
.dia__msg line,
.dia__msg path { stroke: var(--fg-soft); stroke-width: 1.4; fill: none; }
.dia__msg text { font-size: 12px; fill: var(--fg-soft); }
.dia__msg .dia__ok { stroke: var(--green); }
.dia__ok-t { fill: var(--green) !important; font-weight: 600; }
.dia__msg .dia__no { stroke: var(--red); }
.dia__no-t { fill: var(--red) !important; font-weight: 600; }
.dia__small { font-size: 10.5px !important; font-weight: 500 !important; }
.dia__step { font-weight: 700; fill: var(--accent); }
.dia__phase { font-size: 11px; font-weight: 700; letter-spacing: .12em; fill: var(--fg-faint); }
.dia__box--wait rect { fill: var(--bg-raised); stroke: var(--amber); stroke-dasharray: 5 4; }
.dia__wait-t { fill: var(--amber) !important; font-weight: 600; }
.dia__box--gate rect { fill: var(--brand); stroke: var(--brand); }
.dia__on-gate, .dia__on-gate tspan { fill: var(--on-brand) !important; }
.dia__box--ok rect { fill: color-mix(in srgb, var(--green) 10%, var(--bg-raised)); stroke: var(--green); }
.dia__box--no rect { fill: color-mix(in srgb, var(--red) 8%, var(--bg-raised)); stroke: var(--red); stroke-dasharray: 5 4; }
.dia--loop .dia__h { font-family: var(--display); font-size: 15px; letter-spacing: -0.01em; }
.dia--loop .dia__note { font-style: normal; font-family: var(--mono); font-size: 12px; }
.dia__mono { font-family: var(--mono); fill: var(--fg); }
.dia__h { font-size: 14px; font-weight: 700; fill: var(--fg); }
.dia__s { font-size: 12px; fill: var(--fg-soft); }
.dia__faint { fill: var(--fg-faint); font-style: italic; }
.dia__note { font-size: 11.5px; fill: var(--fg-faint); font-style: italic; }

/* The traceability chain is markup, not a drawing: it has to wrap on a phone,
 * and every label in it is a string a reader may want to copy. */
.chain {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 0.45rem 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chain__n {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  text-align: center;
  min-width: 0;
}

.chain__n b {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg);
  overflow-wrap: anywhere;
}

.chain__n span {
  font-size: 0.68rem;
  color: var(--fg-faint);
  letter-spacing: 0.02em;
}

.chain__n:not(:last-child)::after {
  content: "→";
  position: absolute;
}

/* The arrow sits in the gap rather than inside the node, so a wrapped row does
 * not end with an arrow pointing at nothing. */
.chain__n { position: relative; margin-right: 1.35rem; }
.chain__n:last-child { margin-right: 0; }
.chain__n:not(:last-child)::after {
  right: -1.05rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-faint);
  font-size: 0.85rem;
  line-height: 1;
}

.chain__n--end {
  border-color: color-mix(in srgb, var(--green) 50%, transparent);
  background: color-mix(in srgb, var(--green) 9%, transparent);
}
.chain__n--end b { color: var(--green); }

@media (max-width: 560px) {
  .chain { justify-content: flex-start; }
  .chain__n { flex: 1 1 8.5rem; }
}

/* Inside a table, inline code breaks at its spaces, not inside a flag:
 * `--from-pack` split as `--` / `from-pack` reads as two things. The table
 * scrolls sideways before a flag is cut. */
.table-wrap :not(pre) > code { overflow-wrap: normal; }

/* ── Subsections in the sidebar ─────────────────────────────────────────────
 * "From scratch", "Existing project": a small heading inside a section, and
 * the phase number in a circle beside each step. */
.side li.side__sub {
  margin: var(--space-3) 0 var(--space-1) var(--space-2);
  padding-left: var(--space-3);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.side li.side__sub:first-child { margin-top: var(--space-1); }
.side__step {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: var(--space-2);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  vertical-align: 0.05em;
}
.side li a.is-active .side__step { border-color: var(--accent); background: var(--accent); color: var(--bg-raised); }

/* ── The step indicator above a journey page ──────────────────────────────── */
.stepper {
  margin: 0 0 var(--space-6);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
}
.stepper__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-family: var(--mono);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}
.stepper__head span:first-child { color: var(--accent); font-weight: 600; }
.stepper__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: none;
}
.stepper__item a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius);
  color: var(--fg-soft);
  font-size: var(--text-sm);
  line-height: 1.25;
  text-decoration: none;
}
.stepper__item a:hover { background: var(--bg-soft); color: var(--fg); }
.stepper__n {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--mono);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.stepper__item.is-done .stepper__n { border-color: var(--green); background: var(--green); color: var(--bg-raised); }
.stepper__item.is-current a { color: var(--fg); font-weight: 600; background: var(--accent-soft); }
.stepper__item.is-current .stepper__n { border-color: var(--accent); background: var(--accent); color: var(--bg-raised); }
.stepper a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Recorded CLI output, drawn as the terminal it came from ───────────────
 * Dark in both themes on purpose: it is a terminal. Colours are the CLI's own
 * (scripts/lib/ui.ts), so the page looks like what you will see. */
.code--term {
  --term-bg: #15131f;
  --term-edge: #2a2740;
  --term-fg: #e6e3f5;
  border-color: var(--term-edge);
  background: var(--term-bg);
}
.code--term .code__head {
  background: #1d1a2b;
  border-bottom-color: var(--term-edge);
  color: #8b88a6;
}
.code--term .code__lang { color: #8b88a6; }
.code--term .code__copy { color: #b9b6cc; }
.term-dots { display: inline-flex; gap: 6px; margin-right: var(--space-2); }
.term-dots i { width: 10px; height: 10px; border-radius: 50%; background: #3a3651; }
.term-dots i:first-child { background: #f87171; }
.term-dots i:nth-child(2) { background: #fbbf24; }
.term-dots i:nth-child(3) { background: #4ade80; }
.code--term pre { background: var(--term-bg); color: var(--term-fg); }
.code--term .t-prompt { color: #8b88a6; }
.code--term .t-brand { color: #a78bfa; font-weight: 600; }
.code--term .t-err { color: #f87171; }
.code--term .t-warn { color: #fbbf24; }
.code--term .t-ok { color: #4ade80; }
.code--term .t-info { color: #60a5fa; }
.code--term .t-next { color: #5ecde4; font-weight: 600; }
.code--term .t-section { color: #cfcbe3; font-weight: 600; }
.code--term .t-added { color: #86efac; }
.code--term .t-dim { color: #9a97b2; }
.code--term .t-bar { color: #a78bfa; }

/* ── "In this phase": what the page gets you, before the steps ──────────── */
.callout--goal {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
