/* Warring Nations design tokens. Source of truth: DESIGN.md. Do not hard-code values in pages; use these names.
   Concept: stamps and banknotes. Dark scheme is designed first; light is the same system on newsprint. */

@font-face { font-family: "Bodoni Moda"; src: url("fonts/bodoni-moda-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("fonts/libre-franklin-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("fonts/libre-franklin-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Literata"; src: url("fonts/literata-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Martian Mono"; src: url("fonts/martian-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  color-scheme: dark light;

  /* Inks that do not change with the scheme: nation inks, used only as flat fills on stamps and map territory. */
  --n-vermilion: #d9502f;
  --n-carmine:   #b5253a;
  --n-rust:      #a5502a;
  --n-sepia:     #8a5a3c;
  --n-bistre:    #8a7a45;
  --n-olive:     #7f9a4f;
  --n-bottle:    #3f7a55;
  --n-prussian:  #3d6a99;
  --n-slate:     #6c7f93;
  --n-cream:     #d8d0b8;
  --n-graphite:  #5e594d;
  --n-oxblood:   #7a2c2c;

  /* Type */
  --f-display: "Bodoni Moda", "Bodoni 72", Didot, "Times New Roman", serif;
  --f-ui:      "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --f-prose:   "Literata", Georgia, "Times New Roman", serif;
  --f-mono:    "Martian Mono", ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;

  --t-micro: 0.75rem;   /* 12px caps labels */
  --t-small: 0.875rem;  /* 14px captions, mono */
  --t-base:  1rem;      /* 16px UI */
  --t-prose: 1.125rem;  /* 18px long prose */
  --t-h4:    1.375rem;  /* 22px */
  --t-h3:    1.75rem;   /* 28px */
  --t-h2:    2.25rem;   /* 36px */
  --t-h1:    3.5rem;    /* 56px */
  --t-face:  6rem;      /* 96px face value numerals */

  /* Spacing, 4px rhythm */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;
  --w-page: 1120px;
  --w-prose: 68ch;

  /* Shape: no radius, no shadow. Edges are rules and perforations. */
  --radius: 0;
  --perf: 4px dotted var(--ink);       /* stamp perforation */
  --rule-hair: 1px solid var(--hair);
  --rule-ink: 1px solid var(--ink);
  --rule-double: 3px double var(--line);
  --focus: 3px solid var(--seal);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 140ms;
}

/* Dark (designed first): intaglio black-brown ground, banknote cream ink, vermilion seal. */
:root, :root[data-theme="dark"] {
  --ground: #17140f;   /* Intaglio: page ground */
  --plate:  #201c16;   /* Plate: stamp faces, table heads, code */
  --ink:    #e6dfcc;   /* Banknote cream: primary text and rules */
  --ink-2:  #bdb59f;   /* Dull cream: secondary text */
  --ink-3:  #9b937e;   /* Faded: captions and metadata */
  --line:   #8c8369;   /* Strong line: input borders, double rules (3:1+) */
  --hair:   #4a4333;   /* Hairline: decorative dividers only */
  --seal:   #e8643c;   /* Vermilion seal: links, primary action, war */
  --seal-ink: #17140f; /* Text on a seal fill */
  --held:   #98ae66;   /* Greenback olive: held, peace, success */
  --wire:   #7ca1cc;   /* Postal blue: information, ceasefire */
}

/* Light: the same system on newsprint. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground: #f2ecdc;  --plate: #e8e1cd;
    --ink: #1c1812;     --ink-2: #4b4437;  --ink-3: #675f4b;
    --line: #7a7157;    --hair: #cbc3aa;
    --seal: #b02e10;    --seal-ink: #f7f2e4;
    --held: #4d671d;    --wire: #2c5b92;
  }
}
:root[data-theme="light"] {
  --ground: #f2ecdc;  --plate: #e8e1cd;
  --ink: #1c1812;     --ink-2: #4b4437;  --ink-3: #675f4b;
  --line: #7a7157;    --hair: #cbc3aa;
  --seal: #b02e10;    --seal-ink: #f7f2e4;
  --held: #4d671d;    --wire: #2c5b92;
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0.01ms; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Warring Nations shared components. Needs tokens.css first. Spec: DESIGN.md. Token names only, no raw colours. */

/* Base */
*, ::before, ::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--s-7); }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 var(--t-base)/1.5 var(--f-ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-wrap: break-word; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, pre, blockquote { margin: 0; }
h1, h2 { font-family: var(--f-display); font-weight: 700; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.5rem, 9vw, var(--t-h1)); line-height: 1.05; }
h2 { font-size: clamp(1.75rem, 6vw, var(--t-h2)); line-height: 1.15; }
h3 { font-size: var(--t-h3); line-height: 1.2; font-weight: 700; text-wrap: balance; }
h4 { font-size: var(--t-h4); line-height: 1.3; font-weight: 700; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
hr { border: 0; border-top: var(--rule-hair); margin: var(--s-6) 0; }
::selection { background: var(--seal); color: var(--seal-ink); }
:focus-visible { outline: var(--focus); outline-offset: 2px; }
a { color: var(--seal); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 3px; }
button, input, select, textarea { font: inherit; color: inherit; border-radius: 0; }
small, .small { font-size: var(--t-small); }
code, kbd, samp, .mono { font-family: var(--f-mono); font-size: 0.9em; }
b, strong { font-weight: 700; }
.skip { position: absolute; left: var(--s-2); top: -100px; z-index: 20; background: var(--seal); color: var(--seal-ink); padding: var(--s-3) var(--s-4); font-weight: 700; }
.skip:focus { top: var(--s-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Layout */
.wrap { max-width: var(--w-page); margin-inline: auto; padding-inline: var(--s-5); }
.prose { max-width: var(--w-prose); font: 400 var(--t-prose)/1.6 var(--f-prose); text-wrap: pretty; }
.prose > * + * { margin-top: var(--s-4); }
.prose h2, .prose h3, .prose h4 { font-family: var(--f-prose); font-weight: 600; letter-spacing: 0; }
.prose h2 { font-size: var(--t-h3); margin-top: var(--s-7); }
.prose h3 { font-size: var(--t-h4); margin-top: var(--s-6); }
.prose ul { list-style: square; padding-left: var(--s-5); }
.prose ol { list-style: decimal; padding-left: var(--s-5); }
.prose li + li { margin-top: var(--s-2); }
.lead { font: 400 var(--t-prose)/1.6 var(--f-prose); max-width: var(--w-prose); color: var(--ink-2); }
.stack > * + * { margin-top: var(--s-4); }
.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); } .mt-7 { margin-top: var(--s-7); } .mt-8 { margin-top: var(--s-8); } .mt-9 { margin-top: var(--s-9); }
.mb-5 { margin-bottom: var(--s-5); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); }
.split { display: grid; grid-template-columns: 7fr 5fr; gap: var(--s-7); align-items: start; }
.split.even { grid-template-columns: 1fr 1fr; } .split.three { grid-template-columns: repeat(3, 1fr); } .split.flip { grid-template-columns: 5fr 7fr; }
.section { border-top: var(--rule-double); padding-top: var(--s-5); }
.section > h2 { margin-bottom: var(--s-5); }
.page-head { padding-top: var(--s-7); }
.page-head h1 + * { margin-top: var(--s-4); }
.micro, th { font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums lining-nums; }
.dataline { font-size: var(--t-small); color: var(--ink-3); }
.dataline.stale { color: var(--seal); }

/* Masthead */
.mast { position: relative; z-index: 10; border-bottom: var(--rule-hair); }
.mast-row { display: flex; align-items: center; gap: var(--s-4); min-height: 64px; }
.wordmark { font: 700 1.5rem/1 var(--f-display); color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.wordmark:hover { text-decoration: none; }
.nav { margin-left: auto; }
.nav summary { display: block; padding: var(--s-3) var(--s-2); min-height: 44px; font-weight: 700; cursor: pointer; list-style: none; text-decoration: underline; text-underline-offset: 0.2em; }
.nav summary::-webkit-details-marker { display: none; }
.nav ul { position: absolute; left: 0; right: 0; top: 100%; background: var(--ground); border-bottom: var(--rule-double); padding: var(--s-2) var(--s-5) var(--s-4); }
.nav a { display: block; padding: var(--s-3) 0; color: var(--ink); text-decoration: none; }
.nav a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.nav a[aria-current="page"] { font-weight: 700; }
@media (min-width: 640px) {
  .nav { margin: 0 0 0 var(--s-6); flex: 1; }
  .nav summary { display: none; }
  .nav ul { position: static; display: flex; gap: var(--s-5); padding: 0; border: 0; background: none; }
  .nav a { padding: var(--s-5) 0 var(--s-2); border-bottom: 3px double transparent; }
  .nav a[aria-current="page"] { border-bottom-color: var(--line); }
}
.theme-btn { margin-left: auto; min-height: 44px; padding: 0 var(--s-2); background: none; border: 0; color: var(--ink); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 0.2em; }
.nav + .theme-btn { margin-left: 0; }
.microprint { height: 14px; overflow: hidden; white-space: nowrap; font: 700 7px/14px var(--f-ui); letter-spacing: 0.2em; color: var(--ink-3); user-select: none; }
.microprint::before { content: "WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7  WARRING NATIONS \B7"; }

/* Footer */
.foot { margin-top: var(--s-9); }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--s-6); padding: var(--s-6) 0; border-top: var(--rule-double); }
.foot h2 { font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--s-3); }
.foot li + li { margin-top: var(--s-2); }
.foot a { color: var(--ink); }
.foot .legal { padding-bottom: var(--s-7); font-size: var(--t-small); color: var(--ink-3); }

/* Postmark address box, serial number */
.postmark { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-5); border: 2px dotted var(--ink); background: var(--plate); }
.postmark code { font-size: var(--t-h4); letter-spacing: 0.02em; }
.serial { font-family: var(--f-mono); font-size: var(--t-small); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; word-break: break-all; }
.serial::before { content: "No. "; color: var(--ink-3); }

/* Stamp card and sheet */
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: var(--s-3); }
.stamp { display: block; background: var(--plate); border: var(--perf); color: var(--ink); text-decoration: none; text-align: center; }
.stamp:hover { text-decoration: none; }
.stamp:hover .stamp-name { text-decoration: underline; text-underline-offset: 0.2em; }
.stamp:focus-visible { outline-offset: 4px; }
.stamp-face { display: grid; justify-items: center; gap: var(--s-2); padding: var(--s-5) var(--s-3) var(--s-4); outline: 1px solid var(--ink); outline-offset: -10px; }
.stamp-value { font: 700 var(--t-h1)/1 var(--f-display); font-variant-numeric: lining-nums; margin: var(--s-2) 0; }
.stamp.atwar .stamp-value { color: var(--seal); }
.stamp-name { font-weight: 700; font-size: var(--t-small); letter-spacing: 0.14em; text-transform: uppercase; overflow-wrap: anywhere; }
.stamp-micro { font-size: var(--t-micro); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); min-height: 1.3em; }
.stamp .flag { margin-top: var(--s-1); }
.badge .o { stroke: var(--ink); }
.badge { flex: none; }
.enter .stamp { animation: wn-in var(--dur) var(--ease) both; animation-delay: calc(min(var(--i, 0), 12) * 30ms); }
@keyframes wn-in { from { opacity: 0; transform: translateY(4px); } }

/* Ledger table */
.ledger { width: 100%; border-collapse: collapse; font-size: var(--t-base); }
.ledger caption { text-align: left; padding-bottom: var(--s-3); color: var(--ink-3); font-size: var(--t-small); }
.ledger th { background: var(--plate); color: var(--ink-2); padding: 0 var(--s-4); height: 44px; text-align: left; border-bottom: var(--rule-double); }
.ledger td { padding: var(--s-3) var(--s-4); border-bottom: var(--rule-hair); vertical-align: middle; }
.ledger tbody tr:hover { background: var(--plate); }
.ledger .r { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums lining-nums; }
.ledger td.name { font-weight: 700; }
.ledger td.name a { color: var(--ink); }
.ledger .who { display: inline-flex; align-items: center; gap: var(--s-3); }
.sort { all: unset; cursor: pointer; display: inline-block; padding: var(--s-3) 0; text-decoration: underline; text-underline-offset: 0.3em; text-decoration-color: var(--line); }
.sort:focus-visible { outline: var(--focus); outline-offset: 2px; }
th[aria-sort="ascending"] .sort::after { content: " up"; }
th[aria-sort="descending"] .sort::after { content: " down"; }
.ledger.compact td, .ledger.compact th { padding: var(--s-2) var(--s-3); }
@media (max-width: 639px) {
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; }
  .ledger thead { display: flex; flex-wrap: wrap; gap: 0 var(--s-4); background: var(--plate); padding: var(--s-2) var(--s-3); border-bottom: var(--rule-double); }
  .ledger thead tr { display: flex; flex-wrap: wrap; gap: 0 var(--s-4); }
  .ledger th { display: block; padding: 0; border: 0; height: auto; }
  .ledger tr { padding: var(--s-3) 0; border-bottom: var(--rule-hair); }
  .ledger td { display: grid; grid-template-columns: 7.5rem 1fr; gap: var(--s-3); padding: var(--s-1) var(--s-3); border: 0; text-align: left; }
  .ledger td::before { content: attr(data-label); font: 700 var(--t-micro)/1.8 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
  .ledger td.name { padding-bottom: var(--s-2); font-size: var(--t-h4); display: block; }
  .ledger td.name::before { content: none; }
  .ledger .r { text-align: left; }
  .ledger td .flag { justify-self: start; white-space: normal; }
  .ledger caption { display: block; }
}

/* Status flags */
.flag { display: inline-block; padding: 2px var(--s-2); border: 1px solid currentColor; font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }
.flag.war { color: var(--seal); } .flag.held { color: var(--held); } .flag.ceasefire { color: var(--wire); } .flag.offline { color: var(--ink-3); }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: var(--s-3) 20px; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-weight: 700; text-decoration: none; cursor: pointer; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.btn:hover { background: var(--ink); color: var(--ground); text-decoration: none; }
.btn:focus-visible { outline-offset: 2px; }
.btn.primary { background: var(--seal); border-color: var(--seal); color: var(--seal-ink); }
.btn.primary:hover { background: transparent; color: var(--seal); }
.btn.quiet { border-color: transparent; color: var(--seal); text-decoration: underline; text-underline-offset: 0.2em; padding-inline: var(--s-2); }
.btn.quiet:hover { background: transparent; text-decoration-thickness: 3px; }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--ink-3); border-color: var(--hair); background: transparent; cursor: not-allowed; text-decoration: none; }
.field { display: grid; gap: var(--s-2); max-width: 28rem; }
.field label { font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; }
.field input, .field select, .field textarea { background: var(--plate); border: 1px solid var(--line); padding: var(--s-3); min-height: 44px; width: 100%; }
.field .help { font-size: var(--t-small); color: var(--ink-2); }
.field .err { font-size: var(--t-small); color: var(--seal); }
.field.bad input { border-color: var(--seal); }
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s-4) var(--s-5); }

/* Code, callout, definition list */
.code { position: relative; }
.code pre { background: var(--plate); border: var(--rule-hair); padding: var(--s-4) 5.5rem var(--s-4) var(--s-4); overflow-x: auto; font: 400 13px/1.7 var(--f-mono); }
.code .btn { position: absolute; top: var(--s-1); right: var(--s-1); min-height: 36px; }
.cmd { color: var(--seal); }
.callout { border: 1px solid var(--line); padding: var(--s-4) var(--s-5); max-width: var(--w-prose); }
.callout > .micro { display: block; margin-bottom: var(--s-2); color: var(--ink-2); }
.spec { display: grid; grid-template-columns: minmax(8rem, 14rem) 1fr; border-top: var(--rule-hair); }
.spec dt, .spec dd { padding: var(--s-3) 0; border-bottom: var(--rule-hair); }
.spec dt { color: var(--ink-2); font-size: var(--t-small); font-weight: 700; padding-right: var(--s-4); }
@media (max-width: 559px) { .spec { grid-template-columns: 1fr; } .spec dt { border: 0; padding-bottom: 0; } }

/* Map plate */
.plate { border: var(--rule-double); padding: var(--s-2); background: var(--ground); }
.plate-cap { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--s-2) var(--s-5); padding: var(--s-3) var(--s-3) var(--s-4); }
.plate-cap dt { font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.plate-cap dd { font-weight: 700; }
.plate-map { border: var(--rule-ink); background: var(--plate); }
.plate-map svg { width: 100%; height: auto; }
.terr { fill: var(--c); stroke: var(--ink); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.grat { stroke: var(--hair); stroke-width: 1px; vector-effect: non-scaling-stroke; fill: none; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); padding: var(--s-4) var(--s-3) var(--s-2); font-size: var(--t-small); }
.legend li { display: flex; align-items: center; gap: var(--s-2); }
.sw { width: 14px; height: 14px; background: var(--c); border: 1px solid var(--ink); flex: none; }
.n-vermilion { --c: var(--n-vermilion); } .n-carmine { --c: var(--n-carmine); } .n-rust { --c: var(--n-rust); } .n-sepia { --c: var(--n-sepia); }
.n-bistre { --c: var(--n-bistre); } .n-olive { --c: var(--n-olive); } .n-bottle { --c: var(--n-bottle); } .n-prussian { --c: var(--n-prussian); }
.n-slate { --c: var(--n-slate); } .n-cream { --c: var(--n-cream); } .n-graphite { --c: var(--n-graphite); } .n-oxblood { --c: var(--n-oxblood); }

/* Data states */
.state { border: var(--rule-hair); padding: var(--s-5); max-width: var(--w-prose); display: grid; gap: var(--s-3); justify-items: start; }
.state h3 { font-size: var(--t-h4); }
.state.error { border: 1px solid var(--line); }
.state.error p::first-line { color: var(--seal); }
.state .btn { margin-top: var(--s-2); }
.notice { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); align-items: center; border: 1px solid var(--line); padding: var(--s-3) var(--s-4); font-size: var(--t-small); }
.skel { width: 100%; }
.skel li { height: 44px; border-bottom: 1px dotted var(--line); }

/* Dispatch log */
.log h2 { font: 700 var(--t-small)/1.3 var(--f-mono); letter-spacing: 0.04em; border-top: var(--rule-double); padding-top: var(--s-3); margin-top: var(--s-7); text-wrap: initial; }
.log h2:first-child { margin-top: 0; }
.entry { display: grid; grid-template-columns: 7.5rem 1fr; gap: var(--s-4); padding: var(--s-3) 0; border-bottom: var(--rule-hair); }
.entry time { font: 400 var(--t-small)/1.7 var(--f-mono); color: var(--ink-3); }
.entry p { max-width: var(--w-prose); }
.entry b { font-weight: 700; }
@media (max-width: 559px) { .entry { grid-template-columns: 1fr; gap: 0; } }

/* Instrument: numbered articles, index, margin notes */
.instrument { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: var(--s-6); align-items: start; margin-top: var(--s-7); }
.index { position: sticky; top: var(--s-5); font-size: var(--t-small); }
.index h2 { font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: var(--s-3); }
.index a { display: block; padding: var(--s-3) 0; color: var(--ink); text-decoration: none; }
.index a:hover { text-decoration: underline; }
.index .n { display: inline-block; width: 2rem; font-family: var(--f-mono); color: var(--ink-3); }
.art { padding-top: var(--s-5); margin-top: var(--s-6); border-top: var(--rule-double); max-width: var(--w-prose); }
.art > * + * { margin-top: var(--s-4); }
.art .code, .art .callout { margin-left: 3.25rem; max-width: none; }
.art .code pre { padding-right: 5.5rem; }
.art:first-child { margin-top: 0; }
.art > h2 { font: 600 var(--t-h3)/1.2 var(--f-prose); letter-spacing: 0; margin: 0 0 var(--s-4); max-width: var(--w-prose); }
.art-no { display: block; font: 700 var(--t-small)/1.3 var(--f-mono); letter-spacing: 0.04em; color: var(--ink-3); margin-bottom: var(--s-1); }
.sec { position: relative; padding-left: 3.25rem; }
.sec-no { position: absolute; left: 0; top: 0.35em; font: 400 var(--t-small)/1.2 var(--f-mono); color: var(--ink-3); }
dfn { font-style: normal; font-variant-caps: all-small-caps; letter-spacing: 0.06em; font-weight: 600; }
.margin-note { font: 400 var(--t-small)/1.5 var(--f-ui); color: var(--ink-2); border-top: var(--rule-hair); padding-top: var(--s-2); margin: var(--s-4) 0 var(--s-4) 3.25rem; max-width: 40ch; }
@media (min-width: 1200px) { .margin-note { float: right; clear: right; width: 12rem; margin: 0 calc(-12rem - var(--s-5)) var(--s-4) 0; } }
@media (max-width: 799px) { .instrument { grid-template-columns: 1fr; gap: var(--s-5); } .index { position: static; border-bottom: var(--rule-hair); padding-bottom: var(--s-3); } .index ol { display: flex; flex-wrap: wrap; gap: 0 var(--s-5); } }

/* Signed-in app: capability-aware nav, sign-in, runner, settings, packages */
.flag.info { color: var(--wire); } .flag.plain { color: var(--ink-2); } .flag.bad { color: var(--seal); }
.acct { display: flex; align-items: center; gap: var(--s-3); margin-left: auto; font-size: var(--t-small); }
.acct + .theme-btn { margin-left: 0; }
.acct span, .acct a { white-space: nowrap; }
@media (min-width: 640px) {
  .mast.app .mast-row { flex-wrap: wrap; gap: 0 var(--s-4); }
  .mast.app .wordmark { padding: var(--s-4) 0 0; }
  .mast.app .acct, .mast.app .theme-btn { margin-top: var(--s-3); }
  .mast.app .nav { order: 5; flex: 1 0 100%; margin: var(--s-1) 0 0; }
  .mast.app .nav ul { flex-wrap: wrap; gap: 0 var(--s-4); }
  .mast.app .nav a { padding: var(--s-3) 0 var(--s-2); }
  .mast.app .acct { margin-left: auto; }
}
.signin { max-width: 30rem; }
.method { padding: var(--s-5) 0; border-top: var(--rule-hair); display: grid; gap: var(--s-3); }
.method:first-of-type { border-top: var(--rule-double); }
.split h2 { margin-bottom: var(--s-4); }
.method > .btn { justify-self: start; }
.method h2 { font: 700 var(--t-h4)/1.3 var(--f-ui); letter-spacing: 0; }
.msg { border: 1px solid var(--line); padding: var(--s-3) var(--s-4); font-size: var(--t-small); max-width: 30rem; }
.msg b { color: var(--seal); }
.msg.ok b { color: var(--held); }
.state.absent { border: 1px dotted var(--line); }
.runner { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: var(--s-6); align-items: start; margin-top: var(--s-6); }
.cmdlist { border-top: var(--rule-double); }
.cmdlist details { border-bottom: var(--rule-hair); }
.cmdlist summary { padding: var(--s-3) 0; min-height: 44px; font-weight: 700; cursor: pointer; display: flex; justify-content: space-between; }
.cmdlist summary .num { color: var(--ink-3); font-weight: 400; font-size: var(--t-small); }
.cmdlist button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: var(--s-2) var(--s-2); font: 400 13px/1.5 var(--f-mono); cursor: pointer; }
.cmdlist button:hover { background: var(--plate); }
.cmdlist button[aria-current="true"] { background: var(--plate); font-weight: 700; text-decoration: underline; text-underline-offset: 0.25em; }
.cmdlist button:focus-visible { outline: var(--focus); outline-offset: -3px; }
.cmd-head h2 { font: 700 var(--t-h3)/1.2 var(--f-mono); letter-spacing: 0; word-break: break-word; }
.cmd-head p { margin-top: var(--s-2); max-width: var(--w-prose); color: var(--ink-2); }
.cmd-form { display: grid; gap: var(--s-4); margin-top: var(--s-5); padding-top: var(--s-5); border-top: var(--rule-hair); }
.opts { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-2); }
.stack > .opts { margin-top: var(--s-4); }
.opts legend { font: 700 var(--t-micro)/1.3 var(--f-ui); letter-spacing: 0.14em; text-transform: uppercase; padding: 0; margin-bottom: var(--s-2); }
.opts label { display: flex; gap: var(--s-3); align-items: center; min-height: 32px; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--seal); width: 18px; height: 18px; margin: 0; }
.suggest { border: 1px solid var(--line); background: var(--plate); max-width: 28rem; margin-top: calc(var(--s-1) * -1); }
.suggest li { padding: var(--s-2) var(--s-3); font-family: var(--f-mono); font-size: var(--t-small); }
.suggest li[aria-selected="true"] { background: var(--ink); color: var(--ground); }
.example { font: 400 var(--t-small)/1.6 var(--f-mono); color: var(--ink-2); margin-top: var(--s-3); }
.result { border: var(--rule-hair); background: var(--plate); padding: var(--s-4); margin-top: var(--s-5); font: 400 13px/1.7 var(--f-mono); max-width: var(--w-prose); }
.result .micro { display: block; margin-bottom: var(--s-2); font-family: var(--f-ui); }
.result.ok .micro { color: var(--held); } .result.err .micro { color: var(--seal); }
.confirm { border: 2px solid var(--seal); padding: var(--s-4) var(--s-5); margin-top: var(--s-5); max-width: var(--w-prose); display: grid; gap: var(--s-3); }
.confirm p { font-weight: 700; }
.switch { display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; }
.switch input { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
.sw-box { width: 44px; height: 24px; border: 1px solid var(--ink); background: var(--plate); position: relative; flex: none; }
.sw-box::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--ink-3); }
.switch input:checked + .sw-box { background: var(--seal); border-color: var(--seal); }
.switch input:checked + .sw-box::after { left: 23px; background: var(--seal-ink); }
.switch input:focus-visible + .sw-box { outline: var(--focus); outline-offset: 2px; }
.switch input:disabled + .sw-box { border-color: var(--hair); }
.sw-t { font: 700 var(--t-small)/1 var(--f-ui); min-width: 2ch; }
.sw-l { order: 3; }
.sw-t::after { content: "Off"; } .switch input:checked ~ .sw-t::after { content: "On"; }
.group { margin-top: var(--s-7); }
.group > h2 { font-size: var(--t-h3); margin-bottom: var(--s-4); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 20rem); gap: var(--s-3) var(--s-6); padding: var(--s-4) 0; border-top: var(--rule-hair); }
.kv .name { font-weight: 700; }
.kv .key { display: block; font: 400 var(--t-small)/1.6 var(--f-mono); color: var(--ink-3); }
.kv .desc { color: var(--ink-2); margin-top: var(--s-1); max-width: 60ch; }
.kv .meta { font-size: var(--t-small); color: var(--ink-3); margin-top: var(--s-2); display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); align-items: center; }
.kv .ctl { display: grid; gap: var(--s-2); align-content: start; }
.kv .ctl input[type="text"], .kv .ctl input[type="number"], .kv .ctl select { background: var(--plate); border: 1px solid var(--line); padding: var(--s-3); min-height: 44px; width: 100%; font-family: var(--f-mono); font-size: var(--t-small); }
.kv .ctl .help { font-size: var(--t-small); color: var(--ink-2); }
.kv.bad .ctl input { border-color: var(--seal); }
.kv.ro .ctl output { display: block; padding: var(--s-3); border: 1px dotted var(--line); background: var(--plate); font: 400 var(--t-small)/1.5 var(--f-mono); }
.listed { display: grid; gap: var(--s-2); }
.listed .li { display: grid; grid-template-columns: 1fr auto; gap: var(--s-2); }
.savebar { position: sticky; bottom: 0; z-index: 5; background: var(--plate); border-top: var(--rule-double); margin-top: var(--s-7); }
.savebar .wrap { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); align-items: center; justify-content: space-between; padding-block: var(--s-3); }
@media (max-width: 799px) { .runner { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; gap: var(--s-3); } }

@media (max-width: 799px) { .split, .split.even, .split.three, .split.flip { grid-template-columns: 1fr; gap: var(--s-6); } .foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 639px) { .acct-l { display: none; } }
@media (max-width: 479px) { .sheet { grid-template-columns: 1fr 1fr; } .stamp-face { padding-inline: var(--s-2); } .stamp-value { font-size: 3rem; } .wordmark { font-size: 1.25rem; white-space: nowrap; } .theme-btn { white-space: nowrap; } .foot-grid { grid-template-columns: 1fr; } .postmark { padding-left: var(--s-4); } .postmark code { font-size: var(--t-base); } }
@media print { .mast, .microprint, .foot, .btn, .theme-btn { display: none; } body { background: none; } }
