/* Jaryo Adaptive Design Lab — local demo companion (not production product)
 * 2026-11-09 polish (grok-bot-1):
 *   · Visual direction: black & white, factory/shop-floor, quiet surfaces. Monochrome is primary;
 *     the F17 color batch renders only inside its own previews.
 *   · Light + dark tokens (WCAG AA), :focus-visible everywhere, responsive to ~260px,
 *     quiet 120–160ms transitions that drop out under prefers-reduced-motion.
 * 2026-11-09 typography-1 reference (legacy-uiux):
 *   · Type roles from Louis Calata Typography 1 booklet (FALL 2021): machine / reading / display.
 *   · Scale 11/12/13/14/16/20/24/32 · body lh 1.5 (from print 8/12) · spacing 4/8/12/16/24/32.
 *   · Spec-sheet meta labels; red accent only via F19. See docs/TYPOGRAPHY-PRINCIPLES.md.
 *   · Latin woff2 cuts, SIL OFL: IBM Plex Sans, IBM Plex Mono, Libre Baskerville.
 *     See docs/FONTS.md. Libre Baskerville is the study serif; Baskerville itself is not shipped.
 */

/* ============ Fonts (SIL OFL, latin) ============ */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/ibm-plex-sans-700.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: italic; font-weight: 700; font-display: swap; src: url("assets/fonts/ibm-plex-sans-700italic.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("assets/fonts/ibm-plex-mono-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/ibm-plex-mono-700.woff2") format("woff2"); }
@font-face { font-family: "Libre Baskerville"; font-style: normal; font-weight: 400; font-display: swap; src: url("assets/fonts/libre-baskerville-400.woff2") format("woff2"); }
@font-face { font-family: "Libre Baskerville"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/libre-baskerville-700.woff2") format("woff2"); }
@font-face { font-family: "Libre Baskerville"; font-style: italic; font-weight: 400; font-display: swap; src: url("assets/fonts/libre-baskerville-400italic.woff2") format("woff2"); }

/* ============ Tokens ============ */
:root {
  color-scheme: light;
  /* color — light */
  --bg: #ffffff;
  --fg: #000000;
  --fg2: #1f1f1f;      /* body copy   16.4:1 */
  --muted: #4d4d4d;    /* meta text    8.4:1 */
  --rule: #000000;     /* 2px structural rules */
  --hair: #8a8a8a;     /* 1px hairlines (decorative; 3.4:1 non-text) */
  --border: #000000;
  --focus: #000000;
  --focus-halo: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --hover: #ebebeb;
  --chip: #ffffff;
  --inv-bg: #000000;   /* inverted = "selected" grammar */
  --inv-fg: #ffffff;
  /* type scale — Typography 1 → screen (body floor ≥12px; 8/12 print → lh 1.5) */
  --fs-0: 11px;  /* chrome-only floor */
  --fs-1: 12px;  /* meta / chips / table heads */
  --fs-2: 13px;  /* nav / secondary UI */
  --fs-3: 14px;  /* reading body */
  --fs-4: 16px;  /* card titles */
  --fs-5: 20px;  /* panel titles */
  --fs-6: 24px;  /* section titles */
  --fs-7: 32px;  /* wordmark / folio-scale */
  --lh-tight: 1.2;
  --lh: 1.5;
  --lh-body: 1.5;   /* explicit 8/12 mapping */
  --lh-ui: 1.35;
  --track: 0.06em;           /* alias → meta */
  --track-body: 0;
  --track-meta: 0.06em;
  --track-display: 0.04em;
  --track-display-tight: -0.01em;
  --track-open: 0.12em;
  --fw-regular: 400;
  --fw-semibold: 600;
  --fw-bold: 700;
  /* spacing rhythm (4px base) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --hit: 44px;
  /* motion: quiet, purposeful */
  --dur: 120ms; --dur-2: 160ms; --ease: cubic-bezier(.2, 0, 0, 1);
  --mono: "IBM Plex Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-machine: var(--mono);
  --font-reading: var(--sans);
  --font-display: var(--mono);
  --font-serif-study: "Libre Baskerville", "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --hatch: repeating-linear-gradient(-45deg, transparent 0 4px, var(--fg) 4px 5px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0c0c; --fg: #f0f0f0; --fg2: #d9d9d9; --muted: #ababab; --rule: #f0f0f0; --hair: #6b6b6b;
    --border: #f0f0f0; --focus: #ffd75e; --focus-halo: #0c0c0c;
    --surface: #121212; --surface-2: #1a1a1a; --hover: #242424; --chip: #121212;
    --inv-bg: #f0f0f0; --inv-fg: #0c0c0c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0c; --fg: #f0f0f0; --fg2: #d9d9d9; --muted: #ababab; --rule: #f0f0f0; --hair: #6b6b6b;
  --border: #f0f0f0; --focus: #ffd75e; --focus-halo: #0c0c0c;
  --surface: #121212; --surface-2: #1a1a1a; --hover: #242424; --chip: #121212;
  --inv-bg: #f0f0f0; --inv-fg: #0c0c0c;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-reading); font-size: var(--fs-3); line-height: var(--lh-body); letter-spacing: var(--track-body); overflow-wrap: break-word;
  transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
code { font-family: var(--mono); font-size: 0.95em; overflow-wrap: anywhere; }
h1, h2, h3 { line-height: var(--lh-tight); }
p { margin: 0; }

/* Mono "stencil" label used across the UI */
.label, .sidebar h2, .navgroup, .subhead, .opt-card .body p strong, .meta-label {
  font-family: var(--font-machine); font-size: var(--fs-0); font-weight: var(--fw-semibold);
  letter-spacing: var(--track-meta); text-transform: uppercase;
}

/* ============ Focus ============ */
:focus { outline: none; }
:focus-visible {
  outline: 3px dashed var(--focus); outline-offset: 3px; box-shadow: 0 0 0 2px var(--focus-halo);
}
.choose-label:has(input:focus-visible) {
  outline: 3px dashed var(--focus); outline-offset: 3px; box-shadow: 0 0 0 2px var(--focus-halo);
}
.choose-label input:focus-visible { outline-offset: 2px; }
@supports not selector(:has(*)) {
  .choose-label:focus-within { outline: 3px dashed var(--focus); outline-offset: 3px; }
}
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--inv-bg); color: var(--inv-fg); padding: var(--s3) var(--s4); min-height: var(--hit);
  font-family: var(--mono); font-size: var(--fs-2);
}
.skip:focus, .skip:focus-visible { left: var(--s2); top: var(--s2); }

/* ============ Header (machine plate) ============ */
.app-header {
  display: grid; gap: var(--s3); padding: var(--s4) var(--s5) var(--s4);
  background: var(--bg); border-bottom: 2px solid var(--rule); position: relative;
}
.app-header::after { /* quiet hazard strip */
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 6px;
  background: var(--hatch); opacity: 0.55; pointer-events: none;
}
.brandrow { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); }
.brand { display: flex; align-items: baseline; gap: var(--s3); min-width: 0; flex-wrap: wrap; }
.plate {
  font-family: var(--font-machine); font-size: var(--fs-0); font-weight: var(--fw-bold); letter-spacing: var(--track-open);
  border: 2px solid var(--rule); padding: 2px var(--s2); line-height: 1.4;
}
.app-header h1 {
  margin: 0; font-family: var(--mono); font-size: var(--fs-4); font-weight: 700;
  letter-spacing: var(--track); text-transform: uppercase; overflow-wrap: anywhere;
}
.h1-sub { font-weight: 400; color: var(--muted); }
.h1-sub::before { content: "/ "; }
.banner {
  font-family: var(--mono); font-size: var(--fs-2); color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border); border-left: 6px solid var(--rule);
  padding: var(--s2) var(--s3);
}
.banner.warn { border-left-style: solid; }
.banner.err { border-left: 10px double var(--rule); font-weight: 600; }
.banner.err::before { content: "! "; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.toolbar .spacer { flex: 1; }
.theme-field { display: inline-flex; align-items: center; gap: var(--s2); }
.theme-field { font-family: var(--mono); font-size: var(--fs-1); font-weight: 600; letter-spacing: var(--track); text-transform: uppercase; }
.notice { max-width: 100ch; }

/* ============ Controls ============ */
.btn {
  min-height: var(--hit); min-width: var(--hit); padding: var(--s2) var(--s4);
  border: 2px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 0;
  font-family: var(--mono); font-size: var(--fs-2); letter-spacing: 0.02em; cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--hover); }
.btn:active { background: var(--inv-bg); color: var(--inv-fg); }
.btn.primary { background: var(--inv-bg); color: var(--inv-fg); }
.btn.primary:hover { text-decoration: underline; }
.btn[aria-pressed="true"] { background: var(--inv-bg); color: var(--inv-fg); }
.btn:disabled, .btn[aria-disabled="true"] { border-style: dashed; cursor: not-allowed; }
select.btn { padding: var(--s2) var(--s3); }

/* ============ Layout ============ */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 140px); margin-top: 8px; }
.sidebar {
  border-right: 2px solid var(--rule); padding: var(--s5) var(--s4); min-width: 0;
  position: sticky; top: 0; align-self: start; max-height: 100vh; overflow: auto;
}
.sidebar h2 { margin: 0 0 var(--s3); line-height: var(--lh-tight); }
#catalog-count { font-size: var(--fs-2); text-transform: none; letter-spacing: 0; font-weight: var(--fw-semibold); }
a[href^="http"] { text-decoration: underline; text-underline-offset: 2px; }
.navgroup { margin: var(--s4) 0 var(--s2); color: var(--muted); border-top: 1px solid var(--hair); padding-top: var(--s2); }
#family-nav > .navgroup:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.navbtn {
  display: flex; align-items: center; gap: var(--s2); width: 100%; text-align: left;
  min-height: var(--hit); margin: 0 0 -1px; padding: var(--s2) var(--s3);
  border: 1px solid var(--border); background: var(--surface); color: var(--fg); cursor: pointer;
  font-family: var(--mono); font-size: var(--fs-2); line-height: 1.3; position: relative;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.navbtn .fid { font-weight: 700; flex: none; }
.navbtn .ftitle { min-width: 0; }
.navbtn .sep { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.navbtn:hover { background: var(--hover); z-index: 1; }
.navbtn[aria-current="true"] { background: var(--inv-bg); color: var(--inv-fg); z-index: 2; }
.navbtn[aria-current="true"]::after { content: "▶"; margin-left: auto; font-size: 9px; }
.navbtn:focus-visible { z-index: 3; }
.grammar-box { margin-top: var(--s5); padding-top: var(--s4); border-top: 2px solid var(--rule); }
.grammar-box .btn { width: 100%; }
.main { padding: var(--s5) var(--s5) var(--s6); min-width: 0; }

/* ============ Tabs ============ */
.tabs { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 var(--s5); border-bottom: 2px solid var(--rule); }
.tab {
  min-height: var(--hit); padding: var(--s2) var(--s4); margin: 0 -2px -2px 0;
  border: 2px solid var(--border); background: var(--surface); color: var(--fg); cursor: pointer;
  font-family: var(--mono); font-size: var(--fs-2); letter-spacing: var(--track); text-transform: uppercase;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab:hover { background: var(--hover); }
.tab[aria-selected="true"] { background: var(--inv-bg); color: var(--inv-fg); position: relative; z-index: 1; }
.tab:focus-visible { position: relative; z-index: 2; }
.panel { display: none; }
.panel.active { display: block; animation: panel-in var(--dur-2) var(--ease) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel > h2 { margin: 0 0 var(--s2); font-family: var(--mono); font-size: var(--fs-5); }
.panel > .meta { margin-bottom: var(--s4); }

/* ============ Section head ============ */
.section-head { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); align-items: baseline; margin-bottom: var(--s3); }
.section-head h2 { margin: 0; font-family: var(--font-display); font-size: var(--fs-6); font-weight: var(--fw-bold); letter-spacing: var(--track-display-tight); text-transform: uppercase; overflow-wrap: anywhere; }
.meta { font-family: var(--font-machine); font-size: var(--fs-1); letter-spacing: var(--track-meta); color: var(--muted); }
.contexts { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s5); }
.chip {
  display: inline-flex; align-items: center; min-height: 28px; max-width: 100%; padding: 2px var(--s2);
  border: 1px solid var(--border); background: var(--chip); font-family: var(--mono); font-size: var(--fs-1);
  letter-spacing: 0.02em;
}
.chip::before { content: "#"; color: var(--muted); margin-right: 2px; }

/* ============ Option cards ============ */
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s4); align-items: stretch; }
@media (max-width: 1400px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; max-height: none; border-right: 0; border-bottom: 2px solid var(--rule); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) { .cards { grid-template-columns: minmax(0, 1fr); } }
.opt-card {
  display: flex; flex-direction: column; min-width: 0;
  border: 2px solid var(--border); background: var(--surface);
  transition: box-shadow var(--dur) var(--ease);
}
.opt-card.chosen { box-shadow: inset 0 0 0 2px var(--border), 4px 4px 0 0 var(--rule); }
.opt-card .idbar {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  background: var(--inv-bg); color: var(--inv-fg); padding: var(--s2) var(--s3);
  font-family: var(--mono); font-size: var(--fs-2); letter-spacing: var(--track); min-height: 36px;
}
.opt-card .oid { font-weight: 700; }
.opt-card .oidx { opacity: 0.75; font-size: var(--fs-1); }
.opt-card .chosen-marker { margin-left: auto; font-weight: 700; }
.opt-card .chosen-marker:not(:empty)::before { content: "■ "; }
.opt-card .body { display: flex; flex-direction: column; gap: var(--s3); flex: 1; min-width: 0; padding: var(--s3); }
.opt-card h3 { margin: 0; font-family: var(--font-reading); font-size: var(--fs-4); font-weight: var(--fw-bold); letter-spacing: var(--track-display-tight); line-height: var(--lh-tight); overflow-wrap: anywhere; }
.spec-foot {
  margin: 0; font-family: var(--font-machine); font-size: var(--fs-1); font-weight: var(--fw-semibold);
  letter-spacing: var(--track-meta); text-transform: uppercase; color: var(--muted); line-height: var(--lh-ui);
}
.type-specimen { display: grid; gap: var(--s4); max-width: 42rem; }
.type-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--s3); align-items: baseline; }
.type-specimen .role-display {
  font-family: var(--font-display); font-size: var(--fs-6); font-weight: var(--fw-bold);
  letter-spacing: var(--track-display); text-transform: uppercase; line-height: var(--lh-tight);
}
.type-specimen .role-title {
  font-family: var(--font-reading); font-size: var(--fs-4); font-weight: var(--fw-bold);
  letter-spacing: var(--track-display-tight); line-height: var(--lh-tight);
}
.type-specimen .role-body { font-family: var(--font-reading); font-size: var(--fs-3); line-height: var(--lh-body); letter-spacing: var(--track-body); max-width: 38em; }
.type-specimen .role-serif { font-family: var(--font-serif-study); font-size: var(--fs-3); line-height: var(--lh-body); max-width: 38em; }
@media (max-width: 480px) { .type-row { grid-template-columns: minmax(0, 1fr); } }
.opt-card .body p strong { display: block; color: var(--muted); margin-bottom: 2px; }
.small { font-family: var(--font-reading); font-size: var(--fs-3); line-height: var(--lh-body); letter-spacing: var(--track-body); color: var(--fg2); font-weight: var(--fw-regular); }
.tradeoff { font-family: var(--font-reading); font-size: var(--fs-3); line-height: var(--lh-body); color: var(--fg2); border-left: 3px solid var(--rule); padding-left: var(--s2); }
/* Spec-sheet provenance (Typography 1 footer pattern) */
.provenance {
  font-family: var(--font-machine); font-size: var(--fs-0); line-height: var(--lh-ui);
  letter-spacing: var(--track-meta); text-transform: uppercase; font-weight: var(--fw-semibold);
  border-left: 2px solid var(--rule); padding-left: var(--s2); color: var(--muted);
}
.provenance strong { font-weight: var(--fw-bold); color: var(--fg); letter-spacing: var(--track-meta); }
.type-specimen-serif { font-family: var(--font-serif-study); font-size: var(--fs-3); line-height: var(--lh-body); }
.card-actions {
  display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: auto;
  padding-top: var(--s3); border-top: 1px solid var(--hair);
}
.card-actions > * { flex: 1 1 auto; }

/* Preview stage: a light "paper" mock surface in both themes (SVG mocks are drawn in #000/#fff). */
.preview-stage {
  --bg: #ffffff; --fg: #000000; --fg2: #1f1f1f; --muted: #4d4d4d; --border: #000000; --rule: #000000;
  --surface: #ffffff; --hover: #ebebeb; --inv-bg: #000000; --inv-fg: #ffffff; --focus: #000000;
  color-scheme: light;
  position: relative; overflow: hidden; min-height: 150px; padding: var(--s2);
  background: #fff; color: #000; border: 1px solid #000; outline: 1px solid var(--surface);
  font-family: var(--mono); font-size: var(--fs-1);
  transition: min-height var(--dur-2) var(--ease);
}
.preview-stage.expanded { min-height: 260px; }
.preview-stage.expanded svg { min-height: 220px; }
.preview-stage svg { width: 100%; height: auto; display: block; }
.ascii { font-family: var(--font-machine); white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--lh-ui); letter-spacing: var(--track-body); }
.example-tag {
  background: var(--surface); color: var(--fg); border: 1px dashed currentColor; padding: 0 var(--s1);
  font-family: var(--mono); font-size: var(--fs-0); letter-spacing: var(--track);
}
.idbar .example-tag { background: transparent; color: inherit; }

/* ============ Journeys ============ */
.journey { border: 2px solid var(--border); margin: 0 0 var(--s5); overflow: hidden; }
.journey .jhead { background: var(--inv-bg); color: var(--inv-fg); padding: var(--s2) var(--s3); font-family: var(--mono); font-size: var(--fs-2); overflow-wrap: anywhere; }
.journey .jbody { display: grid; gap: var(--s3); padding: var(--s3); min-width: 0; }
.journey-frames { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 980px) { .journey-frames { grid-template-columns: minmax(0, 1fr); } }
.studies { margin: var(--s5) 0; display: grid; gap: var(--s3); }
.subhead { margin: var(--s5) 0 var(--s2); color: var(--muted); }
.frame { display: flex; flex-direction: column; min-height: 280px; min-width: 0; margin: 0; border: 2px solid var(--border); }
.frame .flabel { background: var(--inv-bg); color: var(--inv-fg); font-family: var(--mono); font-size: var(--fs-1); letter-spacing: var(--track); text-transform: uppercase; padding: var(--s1) var(--s2); }
.frame .fview { flex: 1; min-width: 0; padding: var(--s2); font-family: var(--mono); font-size: var(--fs-1); }
.frame img { background: #fff; }
.phone { max-width: 320px; margin: 0 auto; }

/* ============ State grammar ============ */
.state-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0; }
.state-swatch {
  min-height: var(--hit); padding: var(--s2) var(--s3); border: 2px solid var(--border);
  background: var(--surface); color: var(--fg); font-family: var(--mono); font-size: var(--fs-1);
}
.state-swatch.selected { background: var(--inv-bg); color: var(--inv-fg); }
.state-swatch.selected::before { content: "▶ "; }
.state-swatch.focusish { outline: 3px dashed var(--focus); outline-offset: 3px; }
.state-swatch.blocked { position: relative; padding-left: 28px; border-width: 3px; border-style: double; }
.state-swatch.blocked::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 14px;
  background: repeating-linear-gradient(-45deg, transparent 0 3px, var(--fg) 3px 4px);
}
.state-swatch.unknown { border-style: dashed; }
.state-swatch.unavailable { border-style: dashed; color: var(--muted); }
#grammar-demo { margin-top: var(--s2); display: block; }

/* ============ Summary / docs ============ */
.table-wrap { max-width: 100%; overflow-x: auto; }
.summary-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: var(--fs-2); }
.summary-table th { background: var(--inv-bg); color: var(--inv-fg); font-size: var(--fs-1); letter-spacing: var(--track); text-transform: uppercase; }
.summary-table th, .summary-table td { border: 1px solid var(--border); padding: var(--s2); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.summary-table tbody tr:nth-child(even) td { background: var(--surface-2); }
.docs { max-width: 80ch; overflow-wrap: anywhere; }
.docs p, .docs ul { margin: 0 0 var(--s3); }
.docs li { margin-bottom: var(--s1); }
.docs h3 { margin: var(--s5) 0 var(--s2); font-family: var(--mono); font-size: var(--fs-4); }
.docs pre, .codeblock {
  max-width: 100%; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  border: 1px solid var(--border); padding: var(--s3); background: var(--surface-2); color: var(--fg);
  font-family: var(--mono); font-size: var(--fs-2);
}
.codeblock { max-height: 60vh; }
.footer-note { margin-top: var(--s6); padding-top: var(--s3); border-top: 2px solid var(--rule); font-family: var(--mono); font-size: var(--fs-1); color: var(--muted); }
.toast {
  position: fixed; right: var(--s3); bottom: var(--s3); z-index: 80; display: none;
  max-width: min(360px, calc(100vw - 24px)); padding: var(--s2) var(--s3);
  background: var(--inv-bg); color: var(--inv-fg); border: 2px solid var(--inv-bg);
  font-family: var(--mono); font-size: var(--fs-2);
}
.toast.show { display: block; animation: toast-in var(--dur-2) var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ============ Color batch (F17) — contained inside its preview ============ */
.token-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(110px, 100%), 1fr)); gap: var(--s1); }
.token { border: 1px solid currentColor; padding: var(--s1) 6px; font-family: var(--mono); font-size: var(--fs-0); overflow-wrap: anywhere; }
.token .sw { height: 24px; border: 1px solid currentColor; margin-bottom: var(--s1); }
.color-preview { border: 1px solid #000; padding: var(--s2); }
.color-preview .bar { height: 18px; margin: 2px 0; border: 1px solid #000; }
.color-preview .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hatched { background: repeating-linear-gradient(-45deg, #fff 0 5px, #000 5px 6px); }

/* ============ Native choice radios ============ */
.choose-label {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--hit); padding: 0 var(--s3);
  border: 2px solid var(--border); background: var(--surface); color: var(--fg); cursor: pointer;
  font-family: var(--mono); font-size: var(--fs-2);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.choose-label:hover { background: var(--hover); }
.choose-label:has(input:checked) { background: var(--inv-bg); color: var(--inv-fg); }
.choose-label input[type="radio"] { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--fg); }
.choose-label:has(input:checked) input[type="radio"] { accent-color: var(--inv-fg); }

/* ============ Motion ============ */
.motion-demo .dash, .dash { stroke-dasharray: 4 4; animation: dashmove 1.2s linear infinite; }
@keyframes dashmove { to { stroke-dashoffset: -16; } }
.motion-note { display: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
    transition-duration: 0.001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
  }
  .motion-demo .dash, .dash { animation: none !important; }
  .panel.active, .toast.show { animation: none !important; }
  .motion-note { display: block; }
}

/* ============ Narrow / cover screen (≤ 480px, tested to 260px) ============ */
@media (max-width: 480px) {
  .app-header { padding: var(--s3); gap: var(--s2); }
  .brand { gap: var(--s2); }
  .h1-sub { display: block; }
  .h1-sub::before { content: ""; }
  .main { padding: var(--s4) var(--s3) var(--s6); }
  .sidebar { padding: var(--s4) var(--s3); }
  .toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .toolbar .theme-field { grid-column: 1 / -1; display: flex; }
  .toolbar .spacer { display: none; }
  .toolbar .btn { width: 100%; min-width: 0; padding: var(--s1) var(--s2); }
  .theme-field select { flex: 1; min-width: 0; }
  .notice { font-size: var(--fs-1); }
  #family-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: var(--s1); }
  #family-nav .navgroup { grid-column: 1 / -1; margin: var(--s2) 0 0; }
  #family-nav > .navgroup:first-child { margin-top: 0; }
  .navbtn { justify-content: center; margin: 0; padding: var(--s1); text-align: center; }
  .navbtn[aria-current="true"]::after { content: ""; display: none; }
  .navbtn .ftitle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 0; }
  .tab { padding: var(--s1) var(--s2); letter-spacing: 0.02em; }
  .section-head h2 { font-size: var(--fs-5); }
  .card-actions { flex-direction: column; }
  .choose-label, .card-actions .btn { width: 100%; }
  .summary-table th, .summary-table td { padding: var(--s1) 6px; font-size: var(--fs-1); }
  .frame { min-height: 0; }
  .toast { left: var(--s2); right: var(--s2); bottom: var(--s2); max-width: none; }
}
@media (max-width: 300px) {
  .opt-card .body { padding: var(--s2); }
  .preview-stage { padding: 6px; }
  .plate { display: none; }
}

/* ============ Forced colors ============ */
@media (forced-colors: active) {
  :focus-visible, .choose-label:has(input:focus-visible) { outline: 3px solid Highlight; }
  .navbtn[aria-current="true"], .tab[aria-selected="true"], .choose-label:has(input:checked) { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .app-header::after { display: none; }
}


/* Additive family groups — Legacy studies + Red interactive UI (2026-11-09) */
.navgroup-legacy { margin-top: 16px; }
.navgroup-red { margin-top: 16px; }
.navgroup-red::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  background: #9B1B1B;
  vertical-align: middle;
  border: 1px solid currentColor;
}
html[data-theme="dark"] .navgroup-red::before,
html.theme-dark .navgroup-red::before { background: #FF6B6B; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.theme-light) .navgroup-red::before { background: #FF6B6B; }
}
/* Identity accent on the F19 button: left rule only — never recolor .fid (fails on inverted nav). */
.navbtn[data-fam="F19"] {
  box-shadow: inset 3px 0 0 #9B1B1B;
}
html[data-theme="dark"] .navbtn[data-fam="F19"],
html.theme-dark .navbtn[data-fam="F19"] {
  box-shadow: inset 3px 0 0 #FF6B6B;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not(.theme-light) .navbtn[data-fam="F19"] {
    box-shadow: inset 3px 0 0 #FF6B6B;
  }
}
