/* TWIRX public website
 *
 * One stylesheet. No preprocessor, no framework, no external font, no import.
 *
 * Three typographic voices carry the whole design:
 *   serif      long-form argument, sized for sustained reading
 *   sans       structure: headings, navigation, labels
 *   monospace  anything that is evidence — digests, commands, figures, status
 *
 * Colour is decorative only. Every state is also carried by a text label and a
 * non-colour marker, so the page survives greyscale, low vision, and CSS-off.
 */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light dark;

  --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --paper: #fdfcfa;
  --paper-sunk: #f4f2ed;
  --paper-raised: #ffffff;
  --ink: #16181c;
  --ink-2: #3f454c;
  --ink-3: #6a7178;
  --rule: #ddd8ce;
  --rule-strong: #b6b0a3;
  --accent: #14507d;
  --accent-ink: #0e3c60;
  --accent-wash: #eaf1f7;
  --ok: #1c5b3c;
  --ok-wash: #e8f2ec;
  --warn: #7d5410;
  --warn-wash: #f7f0e2;
  --stop: #8b2f2f;
  --stop-wash: #f7ecec;

  --measure: min(66ch, 100%);
  --column: 62rem;
  --gutter: clamp(1.15rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101317;
    --paper-sunk: #171b21;
    --paper-raised: #1a1f26;
    --ink: #e7eaee;
    --ink-2: #b5bcc4;
    --ink-3: #878f98;
    --rule: #2b313a;
    --rule-strong: #414a55;
    --accent: #8cbde9;
    --accent-ink: #a9d0f4;
    --accent-wash: #16232f;
    --ok: #79c6a0;
    --ok-wash: #14251d;
    --warn: #d7ab5c;
    --warn-wash: #26200f;
    --stop: #e79494;
    --stop-wash: #2a1717;
  }
}

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

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

@media (min-width: 40rem) {
  body { font-size: 1.125rem; }
}

/* ------------------------------------------------------------ foundations */

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 620;
  line-height: 1.2;
  letter-spacing: -0.014em;
  text-wrap: balance;
  margin: 0;
}

p, ul, ol, dl, table, pre, figure, blockquote { margin: 0; }

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

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

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

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

strong { font-weight: 680; }

abbr[title] { text-underline-offset: 0.25em; }

.sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: -9999px;
  z-index: 20;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
}
.skip:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.ext {
  margin-left: 0.25em;
  font-size: 0.85em;
  vertical-align: 0.08em;
}

/* --------------------------------------------------------------- statusbar */

.statusbar {
  border-bottom: 1px solid var(--rule);
  background: var(--paper-sunk);
}

.statusbar__inner {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0.55rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.statusbar__states { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; }

.state { color: var(--ink-2); }
.state + .state::before {
  content: "·";
  margin-right: 0.9rem;
  color: var(--rule-strong);
}

.statusbar__note {
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0.02em;
}

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

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.masthead__inner {
  max-width: var(--column);
  margin: 0 auto;
  padding: 1.05rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  text-decoration: none;
  color: var(--ink);
}

.brand__name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: 0.02em;
}

.brand__mission {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

.brand:hover .brand__name { text-decoration: underline; text-underline-offset: 0.22em; }

.nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav a {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--ink-2);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.nav a:hover { color: var(--ink); border-bottom-color: var(--rule-strong); }

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

.nav__out { color: var(--ink-3); }

/* ------------------------------------------------------------- page shell */

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

.pagehead {
  padding: clamp(2.5rem, 6vw, 4.25rem) 0 clamp(1.75rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--rule);
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.9rem;
}

.pagehead h1 {
  font-size: clamp(1.95rem, 4.6vw, 3rem);
  max-width: min(22ch, 100%);
}

.standfirst {
  max-width: var(--measure);
  margin-top: 1.1rem;
  font-size: 1.14em;
  color: var(--ink-2);
}

/* Two-column shell: sticky contents rail beside the document. */
.shell {
  display: grid;
  /* minmax(0, …) rather than the default `auto`, which would size the column to
     max-content and let long lines push the page wider than the viewport. */
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  padding: clamp(2rem, 5vw, 3.25rem) 0 4.5rem;
}

.shell > * { min-width: 0; }

@media (min-width: 62rem) {
  .shell {
    grid-template-columns: 13.5rem minmax(0, 1fr);
    gap: 3.25rem;
  }
  .rail { order: -1; }
}

.rail {
  font-family: var(--font-sans);
  font-size: 0.86rem;
}

@media (min-width: 62rem) {
  .rail__inner {
    position: sticky;
    top: 1.5rem;
  }
}

.rail h2 {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 0.55rem;
  border-bottom: 1px solid var(--rule);
}

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

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

.rail a {
  color: var(--ink-2);
  text-decoration: none;
  display: block;
  line-height: 1.35;
}

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

.rail li::before {
  counter-increment: rail;
  content: counter(rail) ".";
  float: left;
  width: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-3);
  line-height: 1.55;
}

.rail li a { padding-left: 1.5rem; }

/* ------------------------------------------------------------- document */

.doc > * { max-width: var(--measure); }
.doc > .wide, .doc > figure, .doc > .tablewrap { max-width: 100%; }

.doc > * + * { margin-top: 1.05rem; }

.doc section { max-width: 100%; }
.doc section > * { max-width: var(--measure); }
.doc section > .wide,
.doc section > figure,
.doc section > .tablewrap { max-width: 100%; }
.doc section > * + * { margin-top: 1.05rem; }

.doc section + section { margin-top: clamp(2.75rem, 6vw, 4rem); }

.doc h2 {
  font-size: clamp(1.35rem, 2.6vw, 1.7rem);
  margin-top: 0;
  padding-top: 1.5rem;
  border-top: 2px solid var(--ink);
  max-width: var(--measure);
}

.doc section:first-child h2 { border-top: 0; padding-top: 0; }

.doc h3 {
  font-size: 1.08rem;
  margin-top: 2rem !important;
  letter-spacing: -0.008em;
}

.doc h4 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 1.75rem !important;
}

.doc ul, .doc ol { padding-left: 1.35rem; }
.doc li + li { margin-top: 0.4rem; }
.doc li > ul, .doc li > ol { margin-top: 0.4rem; }

.lede {
  font-size: 1.1em;
  color: var(--ink-2);
}

.note {
  font-size: 0.9em;
  color: var(--ink-3);
}

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

.hero {
  padding: clamp(3rem, 8vw, 5.5rem) 0 clamp(2.25rem, 5vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}

.hero h1 {
  font-size: clamp(2.1rem, 6.2vw, 3.9rem);
  max-width: min(17ch, 100%);
  letter-spacing: -0.026em;
}

.hero__sub {
  max-width: min(58ch, 100%);
  margin-top: 1.35rem;
  font-size: clamp(1.1rem, 2.1vw, 1.32rem);
  color: var(--ink-2);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 2rem;
}

.btn {
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 550;
  text-decoration: none;
  padding: 0.62rem 1.1rem;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  background: var(--paper-raised);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.btn:hover { border-color: var(--ink); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .btn--primary { color: #0d1116; }
}

.btn--primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }

/* --------------------------------------------------------------- trace */

/* The evidence trace under the hero. Every cell is a real datum, so it is a
   figure, not decoration: it scrolls rather than truncates. */
.trace { margin-top: clamp(1.75rem, 4vw, 2.5rem); }

.trace ol {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(7.25rem, 1fr);
  list-style: none;
  margin: 0;
  padding: 0 !important;
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}

.trace li {
  position: relative;
  padding: 0.85rem 0.95rem;
  border-right: 1px solid var(--rule);
  margin: 0 !important;
}

.trace li:last-child { border-right: 0; }

.trace__last { background: var(--accent-wash); }

.trace__label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.trace__value {
  display: block;
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.trace__meta {
  display: block;
  margin-top: 0.3rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ink-3);
}

/* Metrics table: the number leads, the caveat follows it. */
.metrics td.num small {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 0.2rem;
  white-space: normal;
}

.metrics td.num { font-size: 1.05rem; font-weight: 600; }

/* -------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35em;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0.18em 0.5em;
  border: 1px solid currentColor;
  border-radius: 2px;
  vertical-align: 0.12em;
}

.chip__mark { font-size: 0.9em; }

.chip--implemented, .chip--complete { color: var(--ok); background: var(--ok-wash); }
.chip--specified, .chip--in-progress { color: var(--warn); background: var(--warn-wash); }
.chip--planned { color: var(--ink-3); background: var(--paper-sunk); }
.chip--research { color: var(--ink-3); background: transparent; border-style: dashed; }
.chip--not-proven { color: var(--stop); background: var(--stop-wash); }
.chip--normative { color: var(--accent); background: var(--accent-wash); }
.chip--explanatory { color: var(--ink-3); background: var(--paper-sunk); }

h2 .chip, h3 .chip, h4 .chip { margin-left: 0.5em; }

/* ------------------------------------------------------------- callouts */

.callout {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--rule-strong);
  background: var(--paper-sunk);
  padding: 1rem 1.15rem;
}

.callout > * + * { margin-top: 0.6rem; }

.callout__title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.callout--limit { border-left-color: var(--warn); background: var(--warn-wash); }
.callout--limit .callout__title { color: var(--warn); }

.callout--stop { border-left-color: var(--stop); background: var(--stop-wash); }
.callout--stop .callout__title { color: var(--stop); }

.callout--key { border-left-color: var(--accent); background: var(--accent-wash); }
.callout--key .callout__title { color: var(--accent); }

/* The single most important statement on the site gets its own treatment. */
.contract {
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  padding: 1.6rem 0;
  max-width: min(62ch, 100%);
}

.contract p {
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.contract p + p {
  margin-top: 0.9rem;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-2);
  letter-spacing: 0;
}

/* ---------------------------------------------------------------- spine */

/* The derivation chain, as an ordered list rather than an ASCII drawing:
   readable by a screen reader, selectable, and legible at 320px. */
.spine {
  list-style: none;
  padding: 0 !important;
  margin: 0;
  counter-reset: spine;
  border-top: 1px solid var(--rule);
}

/* Absolute-positioned numbering rather than a grid, so that a status chip can
   sit inline beside the stage label instead of becoming its own grid cell. */
.spine li {
  counter-increment: spine;
  position: relative;
  padding: 0.78rem 0 0.78rem 3.3rem;
  border-bottom: 1px solid var(--rule);
  margin: 0 !important;
}

.spine li::before {
  content: counter(spine, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0.78rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.9;
  color: var(--ink-3);
}

.spine b {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: -0.006em;
}

/* The description is the classless span. The :not() guard keeps this rule from
   capturing a status chip or its marker, which are also spans in this list. */
.spine li > span:not([class]) {
  display: block;
  color: var(--ink-2);
  font-size: 0.94rem;
  margin-top: 0.12rem;
}

.spine--tight li { padding-top: 0.5rem; padding-bottom: 0.5rem; }

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

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.45;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 0.75rem 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--rule);
  background: var(--paper-sunk);
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 0.62rem 0.9rem;
  border-bottom: 1px solid var(--rule);
}

thead th {
  font-size: 0.74rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--paper-sunk);
  white-space: nowrap;
}

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

tbody th {
  font-weight: 600;
  color: var(--ink);
}

td.num, th.num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td code { font-size: 0.82em; word-break: break-all; }

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

figure { margin: 0; }

figcaption {
  margin-top: 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.83rem;
  color: var(--ink-3);
  max-width: var(--measure);
}

.diagram {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 1.4rem 1.1rem;
  overflow-x: auto;
}

.diagram svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 30rem;
  color: var(--ink);
}

.diagram svg text {
  font-family: var(--font-sans);
  fill: currentColor;
}

.diagram svg .dim { fill: var(--ink-3); }
.diagram svg .mono { font-family: var(--font-mono); }
.diagram svg .box { fill: var(--paper-sunk); stroke: var(--rule-strong); }
.diagram svg .box-accent { fill: var(--accent-wash); stroke: var(--accent); }
.diagram svg .line { stroke: var(--rule-strong); fill: none; }
.diagram svg .line-accent { stroke: var(--accent); fill: none; }
.diagram svg .boundary { fill: none; stroke: var(--ink-3); stroke-dasharray: 5 4; }

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

pre {
  overflow-x: auto;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--rule);
  background: var(--paper-sunk);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  tab-size: 2;
}

pre code { font-size: inherit; }

/* Inline annotations inside a code block. */
pre .dim { color: var(--ink-3); }

:not(pre) > code {
  padding: 0.1em 0.32em;
  border: 1px solid var(--rule);
  background: var(--paper-sunk);
  border-radius: 2px;
  /* `anywhere` rather than `break-word`: only `anywhere` is considered when the
     browser computes min-content width, so a long URL or digest cannot push the
     page wider than the viewport at 320px. */
  overflow-wrap: anywhere;
}

/* ----------------------------------------------------------------- cards */

.cards {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

@media (min-width: 34rem) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 58rem) { .cards--3 { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--paper-raised);
  padding: 1.1rem 1.15rem;
}

.card h3 {
  margin-top: 0 !important;
  font-size: 0.98rem;
}

.card p {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--ink-2);
}

/* two-column comparison: what exists / what does not */
.split {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

@media (min-width: 46rem) { .split { grid-template-columns: 1fr 1fr; } }

.split > div { background: var(--paper-raised); padding: 1.15rem 1.2rem; }

.split h3 { margin-top: 0 !important; display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }

.split ul {
  margin-top: 0.85rem;
  padding-left: 0;
  list-style: none;
  font-size: 0.94rem;
}

.split li {
  padding-left: 1.3rem;
  position: relative;
  color: var(--ink-2);
}

.split li::before {
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.split--yes li::before { content: "+"; color: var(--ok); }
.split--no li::before { content: "\2013"; color: var(--ink-3); }

/* ------------------------------------------------------------- key facts */

.facts {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 44rem) { .facts { grid-template-columns: repeat(4, 1fr); } }

.fact { background: var(--paper-raised); padding: 0.95rem 1rem; }

.fact dt {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  color: var(--ink-3);
  line-height: 1.3;
}

.fact dd {
  margin: 0.35rem 0 0;
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.fact dd small {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  margin-top: 0.2rem;
}

/* --------------------------------------------------------------- ledger */

/* A numbered register of risks. Numbering is part of the content: these are
   cited by number in the report and in the documentation. */
.register {
  list-style: none;
  padding: 0 !important;
  counter-reset: reg;
  border-top: 1px solid var(--rule);
}

.register li {
  counter-increment: reg;
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: 0 0.8rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
  margin: 0 !important;
  color: var(--ink-2);
}

.register li::before {
  content: "R" counter(reg);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--stop);
  padding-top: 0.2em;
}

.register--plain li::before { content: counter(reg); color: var(--ink-3); font-weight: 400; }

/* ------------------------------------------------------------- explorer */

/* Without the enhancement module this is one column of fully expanded fields:
   the complete proof, just longer. With it, a two-pane selector. */
.explorer { display: grid; gap: 1.25rem; }

@media (min-width: 52rem) {
  .explorer--enhanced { grid-template-columns: 13rem minmax(0, 1fr); gap: 2rem; }
}

.explorer > * { min-width: 0; }

.explorer__list ol {
  list-style: none;
  margin: 0;
  padding: 0 !important;
  border-top: 1px solid var(--rule);
}

.explorer__list li { margin: 0 !important; }

.explorer__list ol a {
  display: block;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.explorer__list ol a:hover { background: var(--paper-sunk); color: var(--ink); }

.explorer__list ol a[aria-selected="true"] {
  border-left-color: var(--accent);
  background: var(--accent-wash);
  color: var(--ink);
  font-weight: 600;
}

/* The tab label is already inside a bordered row; drop the inline-code chrome. */
.explorer__list ol code {
  display: block;
  font-size: 0.82rem;
  padding: 0;
  border: 0;
  background: none;
}

.explorer__native {
  display: block;
  margin-top: 0.15rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.explorer__list .note { padding: 0.7rem 0 0; }

.field {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 1.1rem 1.2rem;
}

.field + .field { margin-top: 1rem; }
.explorer--enhanced .field + .field { margin-top: 0; }

.field h3 {
  margin-top: 0 !important;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}

.field__status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ok);
}

.field h4 {
  margin-top: 1.35rem !important;
  color: var(--ink-3);
}

/* Native and semantic stack rather than sitting side by side: inside the
   panel there is not enough width for two columns of identifiers without
   breaking them mid-token, and a broken identifier is worse than a scroll. */
.field__cols { display: grid; gap: 0.25rem; }

.field__cols > div {
  border-left: 2px solid var(--rule);
  padding-left: 0.9rem;
}

.field__cols > div:first-child { border-left-color: var(--rule-strong); }
.field__cols > div:last-child { border-left-color: var(--accent); }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1rem; margin-top: 0.7rem; font-size: 0.92rem; }
.kv--wide { grid-template-columns: max-content minmax(0, 1fr); }

.kv dt {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--ink-3);
  padding-top: 0.15em;
}

.kv dd { margin: 0; min-width: 0; overflow-wrap: break-word; }

.kv samp {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.08em 0.35em;
  background: var(--accent-wash);
  border: 1px solid var(--rule);
  border-radius: 2px;
}

/* Digests wrap across lines constantly. Without the inline-code chrome the
   wrap reads as one continuous value instead of three separate boxes. */
code.digest {
  font-size: 0.78em;
  overflow-wrap: anywhere;
  color: var(--ink-2);
  padding: 0;
  border: 0;
  background: none;
}

.flag {
  display: inline-block;
  margin-left: 0.4em;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--warn);
}

/* --------------------------------------------------------------- gates */

.gate {
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  padding: 1.15rem 1.25rem;
}

.gate + .gate { margin-top: 0.85rem; }

.gate--now { border-color: var(--accent); border-left-width: 4px; }

.gate__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--rule);
}

.gate__num {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.gate__head h3 { margin: 0 !important; font-size: 1.08rem; flex: 1 1 12rem; }

.gate dl {
  display: grid;
  gap: 0.55rem 1.1rem;
  margin-top: 0.85rem;
  font-size: 0.94rem;
}

@media (min-width: 44rem) { .gate dl { grid-template-columns: 8.5rem minmax(0, 1fr); } }

.gate dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-top: 0.25em;
}

.gate dd { margin: 0; color: var(--ink-2); }

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

.footer {
  border-top: 1px solid var(--rule);
  background: var(--paper-sunk);
  margin-top: 2rem;
}

.footer__inner {
  max-width: var(--column);
  margin: 0 auto;
  padding: 2.75rem var(--gutter) 3.25rem;
}

.footer__lead {
  max-width: min(52ch, 100%);
  color: var(--ink-2);
  font-size: 0.98rem;
}

.footer__nav {
  display: grid;
  gap: 1.75rem 2rem;
  margin-top: 2.25rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
}

@media (min-width: 40rem) { .footer__nav { grid-template-columns: repeat(3, 1fr); } }

.footer__nav h2 {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}

.footer__nav ul {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 0.89rem;
}

.footer__nav li + li { margin-top: 0.4rem; }

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

.footer__meta {
  margin-top: 2.25rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  max-width: min(60ch, 100%);
  font-size: 0.82rem;
  color: var(--ink-3);
}

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

@media print {
  .statusbar, .nav, .rail, .skip { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .doc > *, .doc section > * { max-width: none; }
  a::after { content: " (" attr(href) ")"; font-size: 0.8em; word-break: break-all; }
  .footer__nav { display: none; }
}

/* Compact list inside a definition-list cell (gate scope). */
ul.tight { padding-left: 1.1rem; margin: 0; }
ul.tight li + li { margin-top: 0.25rem; }

/* ----------------------------------------------------------- path map */

/* Two paths with an admission boundary between them. The boundary is the
   whole point of the diagram, so it is a cell, not a border. */
.map {
  display: grid;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

@media (min-width: 50rem) {
  .map { grid-template-columns: 1fr auto 1fr; }
}

.map__col { background: var(--paper-raised); padding: 1.15rem 1.2rem; }
.map__col--fast { background: var(--accent-wash); }

.map__col h3 { margin-top: 0 !important; font-size: 1rem; }
.map__col .note { margin-top: 0.45rem; }

.map__col ol {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0 !important;
  counter-reset: map;
}

.map__col li {
  counter-increment: map;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.5rem;
  padding: 0.55rem 0 0.55rem 1.7rem;
  border-top: 1px solid var(--rule);
  margin: 0 !important;
  position: relative;
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.map__col li::before {
  content: counter(map);
  position: absolute;
  left: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  line-height: 1.9;
}

.map__col li > span {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-3);
}

.map__gate {
  background: var(--paper-sunk);
  display: grid;
  place-items: center;
  padding: 0.6rem;
}

.map__gate span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

@media (min-width: 50rem) {
  .map__gate span { writing-mode: vertical-rl; transform: rotate(180deg); }
}

.metrics td:last-child { white-space: nowrap; }
