/* site-v3: engineering notebook (proto-a + DESIGN-DECISION grafts). One stylesheet, no external requests.
   Tokens are the style guide in DESIGN-DECISION.md; every text/background pair passes WCAG AA. */

:root {
  --paper: #fbfbf9;
  --panel: #f2f4f3;
  --ink: #1b2127;
  --muted: #5a646d;
  --faint: #626c76;
  --rule: #d8dcdf;
  --rule-strong: #b9c0c5;
  --accent: #0e6f63;
  --accent-ink: #0a564d;
  --accent-tint: #e6f3f0;
  --warn-ink: #7a4b00;
  --warn-line: #946016;
  --warn-tint: #fdf3df;
  --fail-ink: #9b2c2c;
  --fail-tint: #fbe9e7;
  --paused: #5a646d;
  --white: #ffffff;

  --sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --sans-display: "Segoe UI Variable Display", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --measure: 66ch;
  --margin-col: 11rem;
  --gutter: 2.5rem;
  --page-max: 1120px;
  --pad-x: clamp(1.25rem, 4vw, 3.5rem);

  --fs-0: 0.8125rem;
  --fs-1: 0.9375rem;
  --fs-2: 1.0625rem;
  --fs-3: 1.3125rem;
  --fs-4: 1.75rem;
  --fs-5: clamp(2rem, 4.2vw, 3rem);
}

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

html { background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--fs-2);
  line-height: 1.55;
  font-feature-settings: "kern", "liga";
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
a:hover { color: var(--ink); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px;
}

h1, h2, h3, h4 { font-family: var(--sans-display); line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-5); font-weight: 600; letter-spacing: -0.02em; max-width: 22ch; }
h2 { font-size: var(--fs-4); font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: var(--fs-3); font-weight: 600; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { padding-left: 1.25em; margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
strong { font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 0.875em; }
code { background: var(--panel); padding: 0.05em 0.3em; border-radius: 2px; overflow-wrap: anywhere; }
img { max-width: 100%; height: auto; display: block; }
picture { display: block; }

.visually-hidden {
  position: absolute !important; 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: -3rem; background: var(--ink); color: var(--white);
  padding: 0.5rem 0.75rem; z-index: 10; text-decoration: none;
}
.skip:focus { top: 1rem; }

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

.page { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--pad-x); }

.topbar {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.75rem 1.5rem;
  padding-top: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule);
}
.topbar .wordmark { font-weight: 600; text-decoration: none; color: var(--ink); margin-right: auto; }
.topbar .wordmark span { color: var(--muted); font-weight: 400; }
.topbar nav ul { display: flex; flex-wrap: wrap; gap: 0.1rem 1.1rem; list-style: none; margin: 0; padding: 0; font-size: var(--fs-1); }
.topbar nav li { margin: 0; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: 0.2rem 0; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a[aria-current="page"] { color: var(--ink); border-bottom: 2px solid var(--accent); }

/* Notebook grid: margin column + text column. Figures may span both. */
.sheet {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, 1fr);
  column-gap: var(--gutter);
  row-gap: 0;
}
.sheet > * { grid-column: 2; }
.sheet > .marginalia { grid-column: 1; grid-row: span 2; }
.sheet > .wide { grid-column: 1 / -1; }
.text { max-width: var(--measure); }

.marginalia {
  font-family: var(--mono); font-size: var(--fs-0); line-height: 1.5; color: var(--muted);
  padding-top: 0.35rem;
}
.marginalia .mark { color: var(--accent); display: inline-block; margin: 0 0.5rem 0.25rem 0; }
.marginalia p { margin-bottom: 0.75rem; }
.marginalia dl { margin: 0; }
.marginalia dt { color: var(--faint); margin-top: 0.75rem; }
.marginalia dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.marginalia dd + dd { margin-top: 0.25rem; }
.marginalia .legend-title { display: none; }

/* section rhythm */
.section { padding: 3.25rem 0 0.5rem; }
.section + .section { border-top: 1px solid var(--rule); margin-top: 3rem; }
.section > h2 { margin-bottom: 1.25rem; }
.section > div > h2:last-child { margin-bottom: 0.75rem; }
.sub { margin-top: 2.25rem; }
.sub > h3 { margin-bottom: 0.75rem; }

/* section head with a meta note on the right (G11) */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; flex-wrap: wrap; }
.sec-head h2 { margin-bottom: 0.75rem; }
.nobr { white-space: nowrap; }   /* fix-site-r3: product codes such as PA-440 never break inside the h1 */
.sec-meta { font-family: var(--mono); font-size: var(--fs-0); color: var(--faint); }

/* ---------- hero ---------- */

.hero { padding: 4.5rem 0 3rem; }
.hero .byline { font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); margin-bottom: 1.5rem; }
.hero .byline b { color: var(--ink); font-weight: 500; }
.hero h1 { margin-bottom: 1.25rem; }
.hero .lede { font-size: var(--fs-3); line-height: 1.45; color: var(--muted); max-width: 44ch; margin-bottom: 2rem; }
.hero .intro-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem 2.5rem; align-items: start; }
.hero .intro { max-width: 60ch; }
.hero .intro p { max-width: var(--measure); }
.hero .marginalia { padding-top: 0.6rem; }
.hero .note { margin-top: 0; }
@media (min-width: 1000px) {
  .hero .intro-row { grid-template-columns: minmax(0, 60ch) minmax(16rem, 1fr); }
}

/* status key line shown under the lede on phones only (G8) */
.legend-line { display: none; }

.note {
  border-left: 3px solid var(--accent); background: var(--accent-tint);
  padding: 0.85rem 1rem; margin: 1.5rem 0 0; font-size: var(--fs-1); max-width: var(--measure);
}
.note--warn { border-left-color: var(--warn-line); background: var(--warn-tint); }
.note--private { border-left-color: var(--rule-strong); background: var(--panel); }

/* ---------- status tags (pip + word, never colour alone) ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-family: var(--mono); font-size: 0.75rem; line-height: 1; letter-spacing: 0.01em;
  padding: 0.3em 0.55em; border: 1px solid var(--rule-strong); border-radius: 2px;
  color: var(--muted); background: var(--white); white-space: nowrap; vertical-align: middle;
}
.tag::before { content: ""; width: 0.5em; height: 0.5em; border-radius: 50%; background: currentColor; flex: none; }
.tag--running { color: var(--accent-ink); border-color: var(--accent); }
.tag--designed { color: var(--warn-ink); border-style: dashed; border-color: var(--warn-line); }
.tag--designed::before { background: transparent; border: 1px solid currentColor; }
.tag--paused { color: var(--paused); }
.tag--paused::before { background: transparent; border: 1px solid currentColor; }
.tag--dormant { color: var(--paused); }
.tag--failed { color: var(--fail-ink); border-color: var(--fail-ink); }
.tag--failed::before { background: transparent; border: 1px solid currentColor; }
.tag--private { color: var(--muted); border-color: var(--rule-strong); border-radius: 999px; }
.tag--private::before, .tag--plain::before { display: none; }

/* ---------- tables (typeset like a paper's tables) ---------- */

.table-wrap { overflow-x: auto; margin: 0 0 1rem; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-1); line-height: 1.4; }
caption { text-align: left; font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); padding: 0 0 0.75rem; }
caption b { color: var(--ink); font-weight: 500; }
th, td { text-align: left; vertical-align: top; padding: 0.7rem 1rem 0.7rem 0; border-top: 1px solid var(--rule); }
thead th { font-weight: 500; color: var(--muted); border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule); font-size: var(--fs-0); }
tbody tr:last-child td { border-bottom: 2px solid var(--ink); }
td.num, th.num { font-family: var(--mono); font-size: 0.875em; }
td.state { white-space: nowrap; }
td a { font-weight: 500; }
td .tag { margin-top: 0.05rem; }
td .tag--inline { white-space: normal; text-align: left; }
td.state .cell { display: block; }
td.state small { display: block; margin-top: 0.25rem; white-space: normal; }

/* ---------- figures ---------- */

figure { margin: 2.5rem 0; }
figure.wide { margin: 3rem 0; }
.frame { border: 1px solid var(--rule); background: var(--white); padding: 1rem; }
.frame img { margin: 0 auto; }
.frame--shot img { border: 1px solid var(--rule); }
.frame--tall { max-width: 52rem; margin: 0 auto; }
figcaption {
  font-size: var(--fs-1); color: var(--muted); margin-top: 0.85rem; max-width: var(--measure);
  padding-left: 4.25rem; text-indent: -4.25rem;
}
figcaption .fignum { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink); display: inline-block; width: 4.25rem; text-indent: 0; }
figure.wide figcaption { margin-left: calc(var(--margin-col) + var(--gutter)); }
figure a.frame { display: block; text-decoration: none; }
figcaption .fig-full { font-family: var(--mono); font-size: var(--fs-0); margin-left: 0.6rem; white-space: nowrap; color: var(--accent-ink); }

/* ---------- project entries (hub) ---------- */

.entries { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.entry {
  display: grid; grid-template-columns: minmax(0, 1fr) 13.5rem; gap: 1rem 2rem; align-items: start;
  padding: 1.5rem 0; border-bottom: 1px solid var(--rule); margin: 0;
}
.entry h3 { font-size: var(--fs-3); margin-bottom: 0.35rem; }
.entry h3 a { text-decoration: none; }
.entry h3 a:hover { text-decoration: underline; }
.entry .what { color: var(--muted); margin-bottom: 0.75rem; }
.entry .facts { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.25rem 1rem; font-size: var(--fs-1); margin: 0; }
.entry .facts dt { color: var(--faint); font-family: var(--mono); font-size: var(--fs-0); padding-top: 0.15rem; }
.entry .facts dd { margin: 0; }
.entry .thumb { display: block; border: 1px solid var(--rule); background: var(--white); padding: 0.4rem; aspect-ratio: 4 / 3; overflow: hidden; }
.entry .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }
/* big readout for figure-less entries (G5) */
.entry .thumb--empty {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  background: var(--panel); border-color: var(--rule); padding: 1rem 1.1rem; border-left: 3px solid var(--accent);
}
.readout { font-family: var(--mono); font-size: 2.6rem; line-height: 1; color: var(--ink); letter-spacing: -0.02em; }
.readout .of { color: var(--faint); padding: 0 0.1em; }
.readout-label { font-size: var(--fs-0); color: var(--muted); margin-top: 0.5rem; font-family: var(--mono); }

/* ---------- private tiles (A tile + B header row, G4) ---------- */

/* fix-site-r3: rem-based tracks (10.8rem = 5-up from a 912 px row, i.e. viewport >= ~1000 px at 16 px root) instead of
   a px breakpoint forcing 5 columns, so at 200% text size the row reflows to 2-up instead of overflowing (WCAG 1.4.4) */
.tiles { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10.8rem, 1fr)); gap: 0.75rem; }
.tiles li { display: grid; grid-template-rows: 1fr auto; margin: 0; min-width: 0; }   /* fix-site-r2: tile fills the row, link line aligned; fix-site-r3: min-width 0 (grid items default to min-width:auto, so at 200% text zoom the longest word widened the cell past its track) */
.tile {
  width: 100%; height: 100%; min-width: 0; text-align: left; font: inherit; color: var(--muted);
  background: repeating-linear-gradient(135deg, #f4f5f4 0 6px, #eef0ef 6px 12px);
  border: 1px dashed var(--rule-strong); border-radius: 2px; padding: 0.9rem 1rem; cursor: pointer;
  display: grid; grid-template-rows: minmax(3rem, auto) auto 1fr; gap: 0.45rem; align-content: start; text-decoration: none;
}
/* fix-site-r2: the head row reserves two lines (3rem covers lock+word plus a wrapped pill at 45 px), so every
   .label in the row starts at the same height whether or not the pill wraps under the lock word */
.tile:hover { border-color: var(--muted); color: var(--ink); }
.tile .head { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 0.4rem; row-gap: 0.25rem; font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); }
.tile .head .word { margin-right: auto; }
.tile .lock { width: 0.95rem; height: 0.95rem; color: var(--muted); flex: none; }
.tile .label { font-weight: 600; color: var(--ink); line-height: 1.3; }
.tile .line { font-size: var(--fs-1); }
.tile .label, .tile .line { overflow-wrap: anywhere; }   /* fix-site-r3: a long word can never push past the tile */
a.tile { background: var(--white); border-style: solid; }
a.tile .head { color: var(--accent-ink); }
a.tile .lock { color: var(--accent-ink); }
/* fix-site-r3: 1-up tiles (phones) need no reserved head row; at 421-999 px the pill always takes line 2 so the
   reserved 3rem is used on every tile that has a pill and labels align by construction */
@media (max-width: 420px) { .tile { grid-template-rows: auto auto 1fr; } }
@media (min-width: 421px) and (max-width: 999px) { .tile .head .word { flex-basis: calc(100% - 1.35rem); } }   /* word fills line 1 after the lock (0.95rem + 0.4rem gap), the pill wraps at its own width */
.tiles-foot { font-size: var(--fs-1); color: var(--muted); margin-top: 1rem; }
.tile-links { font-size: var(--fs-1); margin-top: 0.25rem; }
/* Without JS the tile buttons are inert: show the plain links under every tile and the note under the grid */
.tiles-nojs { margin-top: 1rem; }
.no-js .tile-links[hidden] { display: block; min-height: 3em; line-height: 1.5; }   /* fix-site-r2: two lines reserved so the Open lines align */

/* unlock form (only inside the dialog, or static without JS) */
.unlock { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; margin-top: 1rem; }
.unlock label { display: grid; gap: 0.3rem; font-size: var(--fs-1); color: var(--muted); }
.unlock-msg { flex-basis: 100%; font-size: var(--fs-1); color: var(--fail-ink); min-height: 1.4em; margin: 0; }
.unlock-msg:empty { display: none; }
.btn {
  font: inherit; font-weight: 500; padding: 0.55rem 1rem; border-radius: 2px; cursor: pointer;
  background: var(--ink); color: var(--white); border: 1px solid var(--ink);
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--quiet { background: transparent; color: var(--ink); }
.btn--quiet:hover { background: var(--panel); color: var(--ink); }
.btn--small { padding: 0.35rem 0.7rem; font-size: var(--fs-1); }

/* ---------- v3.2: the primary "Open app" button (every project card and page; locked tiles show it too) ---------- */
a.btn, a.btn:hover { text-decoration: none; }
.btn--open { background: var(--accent); border-color: var(--accent); color: var(--white); display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.btn--open:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn--open .arrow { font-size: 0.9em; line-height: 1; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.9rem; margin: 1rem 0 0; font-size: var(--fs-1); color: var(--muted); }
.entry .actions { margin-top: 0.9rem; }
.pagehead .actions { margin-top: 1.25rem; }
.app-host { font-family: var(--mono); font-size: var(--fs-0); color: var(--faint); }
.app-note { flex-basis: 100%; font-size: var(--fs-0); color: var(--muted); }
.actions--none .no-demo { font-family: var(--mono); font-size: var(--fs-0); color: var(--faint); }
/* locked tile: the affordance is a styled span (a button cannot nest a button); the whole tile is the control */
.tile .open { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; margin-top: 0.35rem; align-self: end; }
.tile .open .btn { pointer-events: none; }
.tile--app { grid-template-rows: minmax(3rem, auto) auto 1fr auto; }
.tile:hover .btn--open, a.tile .btn--open { background: var(--accent-ink); border-color: var(--accent-ink); }
.tile-links a[target="_blank"] { font-weight: 500; }
/* dialog: the after-unlock state (form hidden, link shown) */
.unlock-done { margin-top: 1.25rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.unlock-done-note { flex-basis: 100%; font-size: var(--fs-0); }

dialog.unlock-dialog {
  border: 1px solid var(--rule-strong); border-radius: 2px; padding: 1.75rem; max-width: 26rem; width: calc(100% - 2rem);
  background: var(--paper); color: var(--ink); box-shadow: 0 12px 40px rgba(27, 33, 39, 0.18); margin: auto;
}
dialog.unlock-dialog::backdrop { background: rgba(27, 33, 39, 0.35); }
dialog.unlock-dialog h2 { font-size: var(--fs-3); margin-bottom: 0.5rem; }
dialog.unlock-dialog p { color: var(--muted); font-size: var(--fs-1); }
dialog.unlock-dialog .unlock { margin-top: 1.25rem; }
dialog.unlock-dialog .unlock label { flex-basis: 100%; }
dialog.unlock-dialog .target-name { font-weight: 500; color: var(--ink); }
/* Without JS the dialog renders as a plain block under the tiles (G3) */
.no-js dialog.unlock-dialog { display: block; position: static; box-shadow: none; max-width: var(--measure); margin: 1.5rem 0 0; }
.no-js dialog.unlock-dialog [data-close] { display: none; }
.no-js .tile { cursor: default; }

/* lock form in the footer, shown only when unlocked */
.lockform { margin-top: 1rem; display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.lockform[hidden] { display: none; }

/* ---------- teasers ---------- */

.teasers { display: grid; grid-template-columns: 1fr 1fr; gap: 2.5rem; }
.teaser h3 { margin-bottom: 0.6rem; }
.teaser .frame { display: block; margin-bottom: 0.9rem; padding: 0.6rem; }
.teaser .frame img { aspect-ratio: 16 / 9; object-fit: cover; object-position: top left; width: 100%; }
.teaser p { font-size: var(--fs-1); }

.more-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); max-width: var(--measure); }
.more-list li { margin: 0; padding: 0.8rem 0; border-bottom: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: baseline; }
.more-list a { font-weight: 500; text-decoration: none; }
.more-list a:hover { text-decoration: underline; }
.more-list span { color: var(--muted); font-size: var(--fs-1); }

/* ---------- showcase / essay page ---------- */

.pagehead { padding: 3.5rem 0 2.5rem; border-bottom: 1px solid var(--rule); }
.crumbs { font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); margin-bottom: 1.25rem; }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 0.5rem; }
.crumbs li { margin: 0; }
.crumbs li + li::before { content: "/"; color: var(--rule-strong); margin-right: 0.5rem; }
.crumbs a { color: var(--muted); }
.pagehead h1 { margin-bottom: 1rem; }
.pagehead .summary { font-size: var(--fs-3); line-height: 1.45; color: var(--muted); max-width: 46ch; }
.pagehead .marginalia { padding-top: 0.5rem; }
.pagehead .status-line { margin-top: 1.5rem; display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; font-size: var(--fs-1); color: var(--muted); }

.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 1rem 0 0; font-size: var(--fs-1); border-top: 1px solid var(--rule); padding-top: 1rem; }
.roles dt { font-family: var(--mono); font-size: var(--fs-0); color: var(--faint); margin-bottom: 0.25rem; }
.roles dd { margin: 0; }

/* status board: works / designed only / failed or missed (G1) */
.board { margin: 2.5rem 0 0; }
.board-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.board-col { border-top: 2px solid var(--rule-strong); padding-top: 0.85rem; font-size: var(--fs-1); }
.board-col h2 { font-size: var(--fs-1); margin: 0 0 0.6rem; font-family: var(--sans); font-weight: 600; }
.board-col ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.board-col li { margin: 0.3rem 0; }
.board-col li::marker { color: var(--faint); }
.board--works { border-top-color: var(--accent); }
.board--designed { border-top-color: var(--warn-line); border-top-style: dashed; }
.board--failed { border-top-color: var(--fail-ink); }
.board-col .none { color: var(--faint); font-family: var(--mono); font-size: var(--fs-0); }

/* document body: sticky on-this-page TOC in the margin column (G7) */
.doc { display: grid; grid-template-columns: var(--margin-col) minmax(0, 1fr); column-gap: var(--gutter); align-items: stretch; }
.docside { grid-column: 1; min-width: 0; }
.docside .marginalia { padding-top: 3.35rem; }
.docside .marginalia dt:first-child { margin-top: 0; }
.toc { position: sticky; top: 1.5rem; font-family: var(--mono); font-size: var(--fs-0); line-height: 1.5; padding-top: 3.35rem; }
.docside .toc { padding-top: 2.5rem; }
.toc-title { color: var(--faint); margin-bottom: 0.5rem; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li { margin: 0; }
.toc a { display: block; padding: 0.25rem 0 0.25rem 0.8rem; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; margin-left: -1px; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--ink); border-left-color: var(--accent); }
.doc-body { min-width: 0; grid-column: 2; }
.doc-sec { padding: 3.25rem 0 0.5rem; }
.doc-sec p, .doc-sec ul, .doc-sec ol, .doc-sec .lesson, .doc-sec .note { max-width: var(--measure); }
.doc-sec > h2 { max-width: none; }
.doc-sec + .doc-sec { border-top: 1px solid var(--rule); margin-top: 3rem; }
.doc-sec > h2 { margin-bottom: 1rem; }
.doc-sec > h2 .marknum { font-family: var(--mono); font-size: var(--fs-0); color: var(--accent); font-weight: 400; margin-right: 0.75rem; vertical-align: 0.35em; }
.doc-sec figure, .doc-sec .table-wrap { max-width: none; }
.doc-sec figure { margin: 2.5rem 0; }
.doc-sec figcaption { padding-left: 4.25rem; text-indent: -4.25rem; }
.doc-sec table { font-size: var(--fs-1); }
.doc-sec .wider { width: 100%; }
.doc-sec .note { margin-top: 1.25rem; }
.doc-sec .frame--shot { padding: 0.6rem; }
.doc-sec .lesson { margin-top: 0.25rem; }

.lesson {
  border: 1px solid var(--rule); background: var(--panel); padding: 1.25rem 1.5rem; max-width: var(--measure);
  margin-top: 0.5rem;
}
.lesson p { margin: 0; }

.prevnext { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); font-size: var(--fs-1); }
.prevnext a { text-decoration: none; }
.prevnext a:hover { text-decoration: underline; }
.prevnext small { display: block; color: var(--faint); font-family: var(--mono); font-size: var(--fs-0); }
.prevnext .next { text-align: right; margin-left: auto; }

/* ---------- guide library (filter bar reused by the library generator, G9) ---------- */

.filterbar { display: grid; grid-template-columns: 1fr auto auto; gap: 0.75rem 1rem; align-items: end; margin: 2rem 0 1.25rem; max-width: 52rem; }
.filterbar label { display: grid; gap: 0.3rem; font-size: var(--fs-1); color: var(--muted); }
.filterbar input[type="search"], .filterbar select {
  font: inherit; padding: 0.55rem 0.7rem; border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--white); color: var(--ink);
}
.filterbar input[type="search"] { width: 100%; }
.count { font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); margin-bottom: 0.75rem; }

.repos { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--ink); display: grid; grid-template-columns: 1fr 1fr; column-gap: 2.5rem; }
.repo { margin: 0; padding: 1.1rem 0 1.2rem; border-bottom: 1px solid var(--rule); display: grid; gap: 0.35rem; align-content: start; }
.repo .name { font-family: var(--mono); font-size: var(--fs-1); overflow-wrap: anywhere; }
.repo .name a { text-decoration: none; color: var(--ink); font-weight: 500; }
.repo .name a:hover { text-decoration: underline; }
.repo .name .owner { color: var(--muted); font-weight: 400; }
.repo .blurb { font-size: var(--fs-1); color: var(--muted); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.repo .meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-family: var(--mono); font-size: var(--fs-0); color: var(--muted); margin-top: 0.3rem; align-items: center; }
.repo .meta .tag { font-size: 0.7rem; }
.repo[hidden] { display: none; }
.empty { padding: 2rem 0; color: var(--muted); border-bottom: 1px solid var(--rule); }
.empty[hidden] { display: none; }
.repo--locked .name a { color: var(--muted); }

/* ---------- 404 ---------- */
.notfound { padding: 6rem 0 4rem; }
.notfound .code { font-family: var(--mono); color: var(--muted); margin-bottom: 1rem; }
.notfound h1 { margin-bottom: 1rem; }
.notfound .lede { font-size: var(--fs-3); line-height: 1.45; color: var(--muted); max-width: 46ch; }
.notfound .more-list { margin-top: 1.5rem; }

/* ---------- footer ---------- */

.footer { margin-top: 5rem; padding-top: 2rem; padding-bottom: 3rem; border-top: 2px solid var(--ink); font-size: var(--fs-1); color: var(--muted); }
.footer .cols { display: grid; grid-template-columns: var(--margin-col) minmax(0, 1fr); column-gap: var(--gutter); }
.footer .mono { display: block; color: var(--faint); }
.footer p { max-width: var(--measure); }
.footer ul { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.footer li { margin: 0; }

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

@media (max-width: 900px) {
  :root { --margin-col: 9rem; --gutter: 1.75rem; }
  .teasers { grid-template-columns: 1fr; }
  .repos { grid-template-columns: 1fr; }
  .board-grid { gap: 1.25rem; }
  .filterbar { grid-template-columns: 1fr 1fr; }
  .filterbar label:first-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .sheet { grid-template-columns: minmax(0, 1fr); }
  .sheet > *, .sheet > .marginalia, .sheet > .wide { grid-column: 1; grid-row: auto; }
  .marginalia { padding-top: 0; margin-bottom: 1rem; border-left: 2px solid var(--rule); padding-left: 0.75rem; }
  .marginalia .mark { display: inline; margin-right: 0.5rem; }
  .marginalia dl { display: grid; grid-template-columns: fit-content(9rem) minmax(0, 1fr); gap: 0.15rem 0.9rem; }
  .marginalia dt { grid-column: 1; margin-top: 0; }
  .marginalia dd { grid-column: 2; }
  .marginalia dd + dd { margin-top: 0; }
  .marginalia .legend { display: none; }
  .hero { padding: 3rem 0 2rem; }
  .hero .marginalia { order: 10; margin-top: 1.5rem; margin-bottom: 0; }
  .legend-line { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; font-family: var(--mono); font-size: var(--fs-0); color: var(--faint); margin: -1rem 0 1.75rem; }
  .legend-line .legend-title { flex-basis: 100%; }
  figure.wide figcaption { margin-left: 0; }
  .entry { grid-template-columns: 1fr; }
  .entry .thumb { order: -1; aspect-ratio: 16 / 9; }
  .entry .thumb--empty { aspect-ratio: auto; }
  .entry .facts { grid-template-columns: 6rem 1fr; }
  .roles { grid-template-columns: 1fr; }
  .filterbar { grid-template-columns: 1fr; }
  .footer .cols { grid-template-columns: 1fr; }
  .footer .mono { margin-bottom: 0.5rem; }
  .pagehead { padding-top: 2.5rem; }
  .section { padding-top: 2.5rem; }
  .doc { grid-template-columns: minmax(0, 1fr); }
  .docside { grid-column: 1; }
  .docside .marginalia { padding-top: 1.5rem; margin-bottom: 0; }
  .doc-body { grid-column: 1; }
  .toc { position: static; padding-top: 2rem; }
  .docside .toc { padding-top: 1.5rem; }
  .toc ol { border-left: 0; display: flex; flex-wrap: wrap; gap: 0.1rem 0.9rem; }
  .toc a { padding: 0.2rem 0; border-left: 0; margin-left: 0; }
  .toc a[aria-current="true"] { text-decoration: underline; }
  .toc li { white-space: nowrap; display: flex; align-items: baseline; }   /* fix-site-r3: each heading stays on one line (flex: the dot sits beside the block link) ... */
  .toc li + li::before { content: "\00b7"; color: var(--faint); margin-right: 0.9rem; }   /* ... with a middle dot between headings */
  .doc-sec { padding-top: 2.5rem; }
  .board-grid { grid-template-columns: 1fr; }
  th, td { padding-right: 0.75rem; }
  .stack caption { display: block; }
  .stack thead { display: none; }
  .stack table, .stack tbody, .stack tr, .stack td { display: block; }
  .stack tr { border-top: 1px solid var(--rule); padding: 0.85rem 0; }
  .stack tbody tr:last-child { border-bottom: 2px solid var(--ink); }
  .stack td, .stack tbody tr:last-child td { border: 0; padding: 0.2rem 0; display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.75rem; }
  .stack td::before { content: attr(data-label); font-family: var(--mono); font-size: var(--fs-0); color: var(--faint); padding-top: 0.15rem; }
  .stack td.num { font-size: var(--fs-1); }
  .stack td > .tag, .stack td .cell > .tag { justify-self: start; }
  .stack td.state { white-space: normal; }
  .prevnext .next { text-align: left; margin-left: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  .tile, .btn, a { transition: color 120ms ease, background-color 120ms ease, border-color 120ms ease; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- print (F4) ---------- */

@media print {
  .topbar nav, .skip, .unlock, dialog, .tiles, .tile, .tile-links, .tiles-nojs, .lockform, .toc, .legend-line { display: none !important; }
  .btn--open { background: none; border: 1px solid var(--ink); color: var(--ink); }   /* the generic a[href^="http"]::after rule below prints its URL */
  html { background: #fff; }
  body { font-size: 11pt; color: #000; }
  .page { max-width: none; padding: 0 0.25in; }
  a { color: inherit; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-family: var(--mono); font-size: 0.8em; color: #444; }
  .entry, figure, .frame, .lesson, .board-col, .teaser { break-inside: avoid; page-break-inside: avoid; }
  /* fix-site-r3: tables may split between rows (a whole table pushed to the next page left half-blank pages);
     rows stay whole and the header repeats */
  table { break-inside: auto; page-break-inside: auto; }
  tr, .stack td { break-inside: avoid; page-break-inside: avoid; }
  thead { display: table-header-group; }
  caption, th { break-after: avoid; page-break-after: avoid; }
  /* fix-site-r3: a heading never ends a page; the short at-a-glance section and the footer print whole */
  h1, h2, h3, .section > div > h2, .sec-head, .doc-sec > h2 { break-after: avoid; page-break-after: avoid; }
  .sec-head { break-inside: avoid; page-break-inside: avoid; }
  /* (no break rule on .section > .marginalia: it spans the section's grid rows, so avoid-inside would move whole
     sections; the h2 in the same grid row already keeps the mark + note with the heading) */
  .section--glance, .footer { break-inside: avoid; page-break-inside: avoid; }
  .board { break-inside: auto; page-break-inside: auto; }
  /* One explicit layout, independent of the responsive rules (a Letter page is ~700 CSS px wide, so the
     max-width:720px rules apply too; everything they set is overridden here). */
  :root { --margin-col: 9rem; --gutter: 1.5rem; }
  .sheet { grid-template-columns: 9rem minmax(0, 1fr); column-gap: 1.5rem; }
  .sheet > * { grid-column: 2; grid-row: auto; }
  .sheet > .marginalia { grid-column: 1; grid-row: span 2; border-left: 0; padding-left: 0; margin-bottom: 0; }
  .sheet > .wide { grid-column: 1 / -1; }
  /* Page 1 must hold title + summary + roles + the three-column board: compact the head and let the board
     fragment on its own (a marginalia spanning both rows keeps Chromium from breaking between them). */
  .topbar { padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .crumbs { margin-bottom: 0.5rem; }
  .pagehead { padding: 1.25rem 0 1rem; }
  .pagehead > .marginalia { grid-row: span 1; }
  .pagehead h1 { margin-bottom: 0.5rem; }
  .pagehead .summary { font-size: var(--fs-2); }
  .pagehead .status-line { margin-top: 0.75rem; }
  .roles { margin-top: 0.5rem; padding-top: 0.5rem; }
  .board { margin-top: 1rem; }
  .board-col li { margin: 0.15rem 0; }
  .marginalia dl { display: block; }
  .marginalia .legend { display: block; }
  .hero .marginalia { order: 0; margin-top: 0; }
  .doc { grid-template-columns: minmax(0, 1fr); }
  .docside, .doc-body { grid-column: 1; }
  .docside .marginalia { padding-top: 1.5rem; }
  .board-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
  .roles { grid-template-columns: 1fr 1fr; }
  .entry { grid-template-columns: minmax(0, 1fr) 13.5rem; }
  .entry .thumb { order: 0; aspect-ratio: 4 / 3; }
  figure.wide figcaption { margin-left: 0; }
  .stack thead { display: table-header-group; }
  .stack table { display: table; }
  .stack tbody { display: table-row-group; }
  .stack tr { display: table-row; padding: 0; border-top: 0; }
  .stack td, .stack tbody tr:last-child td { display: table-cell; padding: 0.5rem 0.75rem 0.5rem 0; border-top: 1px solid #999; }
  .stack tbody tr:last-child td { border-bottom: 2px solid #000; }
  .stack td::before { content: none; }
  .tag { border-color: #666; }
  .frame { border-color: #999; }
  /* fix-site-r2: a tall figure never pushes its caption to the next page (Letter body ~9.8in: image <= 7.4in) */
  .frame img { max-height: 7.4in; width: auto; max-width: 100%; margin: 0 auto; }
  figcaption { break-before: avoid; page-break-before: avoid; }
  figcaption .fig-full { display: none; }
  .docside .marginalia { break-inside: avoid; page-break-inside: avoid; }
  .marginalia dt { break-after: avoid; page-break-after: avoid; }
  .stack caption { display: table-caption; }
  .footer { border-top-color: #000; }
}
