/* Revolution Crossroads Explorer. All colours are tokens; dark mode redefines them (no colours in JS). */
:root {
  --paper: #f5efe2;
  --paper-2: #ece3cf;
  --paper-3: #e2d6bb;
  --ink: #1d1a16;
  --ink-soft: #4a443b;
  --ink-faint: #635b4e;       /* 4.64:1 on --paper-3 (the open row), 4.95:1 on a hovered row, 5.84:1 on --paper */
  --rule: rgba(29, 26, 22, 0.18);
  --accent: #7d2a1f;          /* oxblood */
  --accent-soft: rgba(125, 42, 31, 0.10);
  --mark: rgba(184, 134, 11, 0.32);
  --focus: #7d2a1f;
  --shadow: 0 12px 40px rgba(29, 26, 22, 0.18);

  /* Entity types: the dataviz reference categorical palette in its validated slot order (CVD-safe on the
     parchment surfaces; checked with validate_palette.js). Always shown beside a text label. */
  --t-person: #2a78d6;
  --t-geographic_location: #eb6834;
  --t-named_place: #e34948;
  --t-organization: #eda100;
  --t-named_event: #e87ba4;
  --t-named_vessel: #008300;
  --t-calendar_date: #4a3aa7;
  --t-norp: #1baf7a;
  /* Heatmap: one hue (the accent), light -> dark, mixed with the paper so it follows the theme. */
  --heat-0: var(--paper-2);
  --heat-1: color-mix(in oklab, var(--accent) 16%, var(--paper));
  --heat-2: color-mix(in oklab, var(--accent) 34%, var(--paper));
  --heat-3: color-mix(in oklab, var(--accent) 54%, var(--paper));
  --heat-4: color-mix(in oklab, var(--accent) 76%, var(--paper));
  --heat-5: var(--accent);

  --font-display: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-ui: "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, sans-serif;
  --detail-w: clamp(360px, 38vw, 640px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17150f;
    --paper-2: #211e17;
    --paper-3: #2c2820;
    --ink: #efe7d6;
    --ink-soft: #cfc5b1;
    --ink-faint: #a89e8b;
    --rule: rgba(239, 231, 214, 0.16);
    --accent: #e0907f;
    --accent-soft: rgba(224, 144, 127, 0.14);
    --mark: rgba(224, 180, 92, 0.30);
    --focus: #e0907f;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    --t-person: #3987e5;
    --t-geographic_location: #d95926;
    --t-named_place: #e66767;
    --t-organization: #c98500;
    --t-named_event: #d55181;
    --t-named_vessel: #008300;
    --t-calendar_date: #9085e9;
    --t-norp: #199e70;
    /* Dark heat steps start stronger: a light mix into near-black is indistinguishable from an empty cell. */
    --heat-1: color-mix(in oklab, var(--accent) 30%, var(--paper));
    --heat-2: color-mix(in oklab, var(--accent) 46%, var(--paper));
    --heat-3: color-mix(in oklab, var(--accent) 63%, var(--paper));
    --heat-4: color-mix(in oklab, var(--accent) 81%, var(--paper));
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: clamp(0.9375rem, 0.95vw, 1.125rem); }  /* 15-18 px at the default size; rem follows the reader's setting */
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-ui); line-height: 1.45;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -48px; background: var(--accent); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip-link:focus { top: 8px; }
.hint { color: var(--ink-faint); font-size: 0.85rem; margin: 0.25rem 0 0.5rem; }

.btn {
  font: inherit; font-weight: 600; color: var(--paper); background: var(--accent);
  border: 1px solid var(--accent); border-radius: 3px; padding: 0.4rem 0.85rem; cursor: pointer;
}
.btn-quiet { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Hero: the title and figures, and beside them on wide screens a note on the data (as in the Green Books explorer) */
.hero { padding: 2.5rem clamp(16px, 5vw, 72px) 1.75rem; border-bottom: 1px solid var(--rule);
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem 3.5rem; }
@media (min-width: 1000px) { .hero { grid-template-columns: minmax(0, 1fr) minmax(18rem, 27rem); align-items: start; } }
.hero-note { background: var(--paper-2); border-left: 3px solid var(--accent); padding: 0.9rem 1.15rem 1rem;
  color: var(--ink-soft); font-size: 0.93rem; line-height: 1.5; max-width: 62ch; }
.hero-note-label { margin: 0 0 0.45rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); }
.hero-note p { margin: 0 0 0.55rem; }
.hero-note .hero-note-short { display: none; }  /* the one-line version, for a frame on si.edu (embed) */
.link-btn { font: inherit; font-weight: 600; color: var(--accent); background: none; border: 0; padding: 0; min-height: 24px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.eyebrow {
  margin: 0 0 0.75rem; font-size: 0.8rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft);
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 4px 0; display: inline-block;
}
.eyebrow[hidden] { display: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.4rem); line-height: 1.05; margin: 0 0 0.6rem; max-width: 22ch; }
.lede { max-width: 62ch; color: var(--ink-soft); font-size: 1.08rem; margin: 0 0 0.6rem; }
.hero-credit { max-width: 62ch; color: var(--ink-soft); font-size: 0.95rem; margin: 0 0 1.25rem; }
.stats { display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem; margin: 0 0 1.25rem; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { color: var(--ink-faint); font-size: 0.85rem; }
/* IM Fell only has old-style figures, which read badly as statistics; use the UI face for numbers. */
.stats dd { margin: 0; font-size: 1.75rem; font-weight: 600; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; }
.hero-actions { margin: 0; }
/* "Found in the records": one random example across the hero's full width, clip beside its passage. */
.featured { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding-top: 1rem; }
.featured[hidden] { display: none; }
.featured-head { display: flex; align-items: baseline; gap: 1rem; margin: 0 0 0.7rem; }
.featured-label { margin: 0; font-family: var(--font-ui); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink); }
.featured-shuffle { font-size: 0.9rem; }
.featured-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.75rem 1.75rem; align-items: start; }
/* fit-content: a wide clip's column is capped where the image is (its natural width would push the text away). */
@media (min-width: 760px) { .featured-body { grid-template-columns: fit-content(34rem) minmax(0, 62ch); } }
.featured .crop { margin: 0; min-height: 7rem; min-width: 12rem; }
.featured .crop.loaded { min-height: 0; min-width: 0; }
.featured .crop img { max-height: 210px; width: auto; max-width: min(100%, 34rem); }
.featured .featured-type { margin: 0 0 0.3rem; }
.featured .kwic { font-size: 1.08rem; line-height: 1.5; margin: 0 0 0.45rem; }
.featured .m-source { margin: 0 0 0.5rem; }
.featured-links { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1.25rem; }
.featured-links a { display: inline-block; padding: 2px 0; }   /* 24 px targets */
.featured-links a.zoom-link { display: inline-flex; align-items: center; gap: 0.2rem; font-weight: 600; }
.featured .zoom-icon { width: 1.25rem; height: 1.25rem; fill: currentColor; flex: none; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(220px, 270px) minmax(0, 1fr); align-items: start; }
.filters { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 1.25rem 1rem 2rem clamp(16px, 5vw, 72px); border-right: 1px solid var(--rule); }
.filters summary { font-family: var(--font-display); font-size: 1.35rem; cursor: pointer; list-style: none; margin-bottom: 0.5rem; }
.filters summary::after { content: " ▾"; font-size: 0.9rem; color: var(--ink-faint); }
.filters details:not([open]) > summary::after { content: " ▸"; }
/* What is filtered, shown while the filters are folded (phones start that way) */
.filters-state { font-family: var(--font-ui); font-size: 0.85rem; color: var(--ink-soft); }
.filters details[open] .filters-state { display: none; }
.search-group { margin-bottom: 1rem; }
.filters summary::-webkit-details-marker { display: none; }
.filter-group { border: 0; padding: 0; margin: 0 0 1.25rem; min-width: 0; }
.filters #reset { margin: 0 0 1.1rem; }  /* first in the filters, above Type */
.filter-label { display: block; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 0.4rem; padding: 0; }
#q { width: 100%; font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--ink-faint); border-radius: 3px; background: var(--paper-2); color: var(--ink); }
#q::placeholder { color: var(--ink-faint); opacity: 1; }  /* the field's edge and placeholder at 3:1 and 4.5:1 (1.4.11, 1.4.3) */
.options label { display: flex; align-items: baseline; gap: 0.45rem; padding: 0.18rem 0; cursor: pointer; font-size: 0.95rem; }
.options .n { margin-left: auto; color: var(--ink-faint); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
/* Type rows: an "only" button that covers the row's count on hover or focus, so it takes no width of its own (the
   column is narrow); touch screens can't hover, so there it sits beside the count, always visible. */
.options .option { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.35rem; }  /* with wider text spacing, a count drops below its label */
.options .option label { flex: 1; }
.options .option .n { margin-left: 0; }
/* "All types" heads the type rows, set off from them by a rule (it is all of them, not one more type). */
.options .option-all { border-bottom: 1px solid var(--rule); margin-bottom: 0.2rem; padding-bottom: 0.1rem; }
.only-btn { position: absolute; right: 0; top: 0; bottom: 0; font: inherit; font-size: 0.85rem; line-height: inherit;
  min-width: 4.2rem; text-align: right;  /* wide enough to cover a count like "60,315" */
  color: var(--accent); background: var(--paper); border: 0; padding: 0 0 0 0.6rem; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px; opacity: 0; }
.option:hover .only-btn, .option:focus-within .only-btn { opacity: 1; }
@media (hover: none) { .only-btn { position: static; opacity: 1; padding: 0 0.15rem; min-width: 0; } }
.swatch { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; align-self: center; }

main { padding: 1rem clamp(16px, 3vw, 40px) 3rem; min-width: 0; }
/* Keep the table readable beside the open panel instead of underneath it. */
body.detail-open main { padding-right: calc(var(--detail-w) + 16px); }
main:focus { outline: none; }
/* The count, the buttons and the table head stay at the top while the rows scroll; app.js sets --bar-h to the bar's
   height (it wraps on narrow screens) so the head sits just under it, and keyboard focus scrolls rows clear of both. */
:root { scroll-padding-top: calc(var(--bar-h, 3rem) + 2.5rem); }
.results-bar { display: flex; align-items: center; gap: 1rem; justify-content: space-between; position: sticky; top: 0; z-index: 2; background: var(--paper); padding: 0.4rem 0; }
.count { margin: 0; color: var(--ink-soft); }
.results-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--paper); }
.si-thumb { display: inline-block; margin: 0.5rem 0 0.25rem; }
.si-thumb img { display: block; max-width: 100%; max-height: 240px; height: auto; border: 1px solid var(--rule); }
/* No overflow here: a scroll container would hold the sticky header cells, which then never stick to the page. */
.table-wrap { min-width: 0; }
table.entities { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
/* The rule is a shadow, not a border: a collapsed border belongs to the table and stays behind when the cells stick. */
.entities th { text-align: left; box-shadow: inset 0 -2px 0 var(--ink); padding: 0; position: sticky; top: var(--bar-h, 0px); background: var(--paper); z-index: 1; }
.entities th button { font: inherit; font-weight: 700; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); background: none; border: 0; padding: 0.55rem 0.5rem; cursor: pointer; width: 100%; text-align: inherit; }
.entities th[aria-sort] button { color: var(--ink); }
.entities th[aria-sort="ascending"] button::after { content: " ▲"; }
.entities th[aria-sort="descending"] button::after { content: " ▼"; }
.entities .num { text-align: right; }
.entities td { padding: 0.42rem 0.5rem; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
.entities tbody tr:hover { background: var(--accent-soft); }
.entities tbody tr.active { background: var(--paper-3); }
/* The open name's row: a bar in the accent, not only the (1.3:1) background (1.4.11); aria-current says it to screen readers */
.entities td.name { position: relative; }
.entities tr.active td.name::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.entities td.name a { color: var(--ink); text-decoration: none; font-weight: 600; }
.entities td.name a:hover { text-decoration: underline; }
.entities td.zero { color: var(--ink-faint); }
.type-tag { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.88rem; color: var(--ink-soft); white-space: nowrap; }
/* On a phone the longest type ("Nationality or group") wraps, or it would push the list past a 320 px screen. */
@media (max-width: 480px) { .type-tag { white-space: normal; } }
.flag-tag { font-size: 0.72rem; color: var(--ink-faint); border: 1px solid var(--rule); border-radius: 2px; padding: 0 0.25rem; margin-left: 0.35rem; }
#sentinel { height: 1px; }
/* Mentions give way when space is short: on phones, and beside the open panel (which shows the name's mentions) */
@media (max-width: 900px) { .men-col { display: none; } }
@media (max-width: 1700px) { body.detail-open .men-col { display: none; } }
.entities td.empty { padding: 1.25rem 0.5rem; color: var(--ink-soft); }
.entities tr.bal-divider td { padding: 0.55rem 0.5rem 0.3rem; font-size: 0.82rem; color: var(--ink-soft); background: var(--paper-2);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
#more-hint { margin: 0.2rem 0 0; }
#more-hint .m-act, .entities td.empty .m-act { margin-left: 0.3rem; }

/* Detail panel */
.detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--detail-w); background: var(--paper);
  border-left: 1px solid var(--rule); box-shadow: var(--shadow); overflow-y: auto; z-index: 20;
}
.detail-inner { padding: 1.25rem 1.5rem 3rem; }
.detail-tools { float: right; display: flex; gap: 0.4rem; margin-left: 0.75rem; }
#d-full .narrow-label { display: none; }
@media (max-width: 900px) {
  #d-full .wide-label { display: none; }
  #d-full .narrow-label { display: inline; }
  #d-full.no-more, body.detail-full #d-full { display: none; }
}
.d-type { margin: 0.25rem 0 0; font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); display: flex; align-items: center; gap: 0.4rem; }
.detail h2 { font-size: 2rem; line-height: 1.1; margin: 0.25rem 0 0.5rem; }
.detail h2:focus { outline: none; }
.d-role { margin: 0 0 0.5rem; padding: 0.4rem 0.6rem; background: var(--paper-2); border-left: 3px solid var(--accent); font-size: 0.92rem; }
.d-counts { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin: 0.5rem 0; }
.d-counts div { display: flex; flex-direction: column-reverse; }
.d-counts dt { font-size: 0.8rem; color: var(--ink-faint); }
.d-counts dd { margin: 0; font-size: 1.25rem; font-weight: 600; }
.d-variants { color: var(--ink-soft); font-size: 0.92rem; margin: 0.25rem 0 0.75rem; }
.d-section { font-size: 1.35rem; margin: 1.25rem 0 0.25rem; border-top: 1px solid var(--rule); padding-top: 0.75rem; }
/* The contact sheet: its own card, so it reads as a tool rather than part of the examples */
.d-sheet { margin: 0.6rem 0 0.9rem; padding: 0.75rem 1rem 0.8rem; background: var(--paper-2); border: 1px solid var(--rule);
  border-left: 3px solid var(--accent); border-radius: 3px; }
.d-sheet[hidden] { display: none; }
.d-all { margin: 0.4rem 0 0.9rem; }
.d-all[hidden] { display: none; }
.d-all .hint { margin: 0.35rem 0 0; color: var(--ink-soft); }
.d-all .hint:empty { display: none; }
.d-sheet h4 { font-family: var(--font-display); font-weight: 400; font-size: 1.15rem; margin: 0 0 0.1rem; }
.d-sheet .hint { margin: 0 0 0.55rem; color: var(--ink-soft); }
.d-sheet .hint:empty { display: none; }
.d-sheet-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.d-sheet label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.9rem; color: var(--ink-soft); cursor: pointer; min-height: 24px; }
.d-sheet #d-sheet-note, .d-sheet #d-sheet-status { margin: 0.5rem 0 0; }
.mentions { list-style: none; padding: 0; margin: 0; }
.mention { padding: 0.8rem 0; border-bottom: 1px solid var(--rule); }
.mention.set-aside { padding: 0.35rem 0; }
.mention.set-aside > :not(.m-aside), .mention:not(.set-aside) > .m-aside { display: none; }
.m-aside { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.6rem; font-size: 0.85rem; color: var(--ink-faint); }
.m-aside span { font-style: italic; min-width: 0; overflow-wrap: anywhere; }
/* "Hide" is the full page's (to leave an example off the contact sheet); the side panel offers only the zoom */
body:not(.detail-full) .act-hide { display: none; }
.m-source { margin: 0 0 0.3rem; font-size: 0.88rem; color: var(--ink-soft); }
.coll-badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; border: 1px solid currentColor; border-radius: 2px; padding: 0 0.3rem; margin-right: 0.35rem; color: var(--ink-soft); }
.kwic { margin: 0; font-size: 1rem; }
.kwic mark { background: var(--mark); color: inherit; padding: 0 1px; border-radius: 2px; font-weight: 600; }
.crop { margin: 0.5rem 0 0.25rem; min-height: 3rem; background: var(--paper-2); border: 1px solid var(--rule); display: flex; align-items: center; justify-content: center; }
.crop img { display: block; max-width: 100%; height: auto; }
.crop .crop-note { color: var(--ink-faint); font-size: 0.85rem; padding: 0.75rem; }
.crop.loaded { background: none; border: 0; min-height: 0; justify-content: flex-start; }
.m-links { margin: 0.2rem 0 0; font-size: 0.85rem; }
.m-links a { margin-right: 0.9rem; display: inline-block; line-height: 24px; }  /* 24 px targets (2.5.8) */
/* Actions on one example (they change the panel, so they are buttons, not links) */
.m-acts { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; vertical-align: baseline; }
.m-act { font: inherit; color: var(--ink-soft); background: transparent; border: 1px solid var(--rule); border-radius: 3px;
         padding: 0 0.45rem; min-height: 24px; cursor: pointer; }
.m-act:hover { color: var(--accent); border-color: var(--accent); }
.m-act:disabled { opacity: 0.6; cursor: default; }
/* A clip in the panel links to the page viewer: a magnifying glass shows under the pointer (and stays on touch
   screens, which can't hover). Escape hides it (1.4.13, app.js). */
.crop-zoom { position: relative; display: inline-block; max-width: 100%; cursor: zoom-in; }
.crop-zoom img { transition: filter 0.12s; }
.zoom-badge {
  position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.6rem 0.25rem 0.4rem; background: var(--ink); color: var(--paper); font-size: 0.85rem; font-weight: 600;
  border-radius: 3px; box-shadow: var(--shadow); opacity: 0; transition: opacity 0.12s; pointer-events: none;
}
.zoom-badge .zoom-icon { width: 1.35rem; height: 1.35rem; fill: currentColor; }
.crop-zoom:hover .zoom-badge { opacity: 1; }
.crop-zoom:hover img { filter: brightness(0.92); }
@media (hover: none) { .zoom-badge { opacity: 0.9; } }
/* The one action under each example */
.m-links a.zoom-link { display: inline-flex; align-items: center; gap: 0.2rem; font-weight: 600; vertical-align: bottom; }
.zoom-link .zoom-icon { width: 1.25rem; height: 1.25rem; fill: currentColor; flex: none; }
.cite { margin-top: 1.5rem; font-size: 0.9rem; }
.cite summary { cursor: pointer; color: var(--accent); }
.cite .btn { margin: 0 0.4rem 0.4rem 0; }

/* Full page (?e=<id>&full=1): the panel covers the window and shows the further samples (data/mentions-more/); on wide
   screens each example sets its text beside a larger page image (crops are requested at up to 720 px wide, which the
   side panel scales down). On narrow screens the panel already fills the screen, and the full page adds the samples. */
body.detail-full .detail { width: 100%; border-left: 0; box-shadow: none; overscroll-behavior: contain; }
body:not(.detail-full) .mention.more { display: none; }  /* the full page's further samples */
.d-sheet .hint { margin: 0; }
body.detail-full .detail-inner { max-width: 1320px; margin: 0 auto; padding: 1.5rem clamp(16px, 4vw, 48px) 4rem; }
body.detail-full .detail h2 { font-size: clamp(2rem, 3.6vw, 2.8rem); }
@media (min-width: 901px) {
  body.detail-full .mention:not(.set-aside) {  /* not a hidden one: this display would override its one-line form */
    display: grid; grid-template-columns: minmax(18rem, 2fr) minmax(0, 3fr); column-gap: 2rem; padding: 1.25rem 0;
    grid-template-rows: auto auto 1fr;  /* the image's height goes to the last row, so the text keeps together */
  }
  body.detail-full .mention > .m-source { grid-area: 1 / 1; }
  body.detail-full .mention > .kwic { grid-area: 2 / 1; font-size: 1.08rem; line-height: 1.5; }
  body.detail-full .mention > .m-links { grid-area: 3 / 1; align-self: start; margin-top: 0.6rem; line-height: 1.9; }
  body.detail-full .mention > .crop, body.detail-full .mention > .si-thumb { grid-area: 1 / 2 / 4 / 3; margin: 0; }
  body.detail-full .mention > .si-thumb { justify-self: start; }
  body.detail-full .si-thumb img { max-height: 320px; }
}

/* About and how-to dialogs */
dialog { border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink); max-width: min(760px, 92vw); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 8, 5, 0.45); }
.about-inner { padding: 1.5rem 1.75rem 2rem; }
.about-close { float: right; }
.dialog-body h3 { font-size: 1.3rem; margin: 1.25rem 0 0.35rem; }
.dialog-body dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; }
.dialog-body dt { color: var(--ink-faint); }
.dialog-body dd { margin: 0; }
.dialog-body code { font-size: 0.85em; }
.dialog-body ul { margin: 0.35rem 0 0.6rem; padding-left: 1.25rem; }
.dialog-body li { margin: 0.2rem 0; }
/* The how-to's lists of terms (filters, columns, sources, downloads): each term in bold, its description after it. */
.dialog-body dl.terms { display: block; margin: 0.2rem 0 0.4rem; }
.dialog-body dl.terms > div { margin: 0.25rem 0; }
.dialog-body dl.terms dt { display: inline; color: inherit; font-weight: 700; }
.dialog-body dl.terms dt::after { content: ':'; }
.dialog-body dl.terms dd { display: inline; }

.site-footer { border-top: 1px solid var(--rule); padding: 1.25rem clamp(16px, 5vw, 72px) 2rem; color: var(--ink-faint); font-size: 0.85rem; }
.site-footer a { color: inherit; }

.status-error { color: var(--accent); font-weight: 600; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); padding: 1rem 16px; }
  main { padding: 0.75rem 16px 3rem; }
  .coll-col { display: none; }
  .detail { width: 100%; border-left: 0; }
  body.detail-open main { padding-right: 16px; }
}
@media (prefers-reduced-motion: no-preference) {
  .detail:not([hidden]) { animation: slide-in 160ms ease-out; }
  @keyframes slide-in { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
}

/* ── Page viewer (viewer.html) ───────────────────────────────────────────── */
body.viewer-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.viewer-head { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; justify-content: space-between; align-items: flex-start;
  padding: 0.75rem clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--rule); background: var(--paper); }
.viewer-meta { min-width: 0; flex: 1 1 32rem; }
.viewer-head .eyebrow { margin: 0; }
.viewer-head h1 { font-size: 1.6rem; margin: 0.1rem 0 0.15rem; }
.viewer-source { margin: 0 0 0.2rem; color: var(--ink-soft); font-size: 0.9rem; }
.viewer-head .kwic { font-size: 0.95rem; max-width: 90ch; }
.viewer-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
.viewer-actions .hint { margin: 0; max-width: 32ch; text-align: right; }
#viewer-wrap { flex: 1; min-height: 0; position: relative; background: #fff; }
clover-viewer { display: block; position: absolute; inset: 0; }
clover-viewer > div { height: 100%; }
.viewer-status { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center;
  padding: 2rem; text-align: center; background: var(--paper); color: var(--ink-soft); }
.viewer-status[hidden] { display: none; }
.viewer-status.is-error { color: var(--accent); font-weight: 600; }
/* While the zoom driver opens and closes Clover's info panel, hide the panel chrome (attribute selectors: Clover's
   class names are build hashes). opacity, not display: the panel must stay laid out for the overlay to register. */
clover-viewer.rx-zoom-pending aside[data-aside-active],
clover-viewer.rx-zoom-pending div[data-dragging],
clover-viewer.rx-zoom-pending button[data-aside-active] { opacity: 0 !important; pointer-events: none !important; }
@media (max-width: 700px) {
  .viewer-head h1 { font-size: 1.3rem; }
  .viewer-head .kwic { display: none; }
  .viewer-actions { align-items: flex-start; }
  .viewer-actions .hint { text-align: left; }
}

/* ── Charts & trends ─────────────────────────────────────────────────────── */
/* The charts page (charts.html): the figures in one column under the hero. */
.charts-inner { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.75rem 2.5rem; }
figure.chart { margin: 1.75rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.chart h3 { font-size: 1.5rem; margin: 0 0 0.2rem; }
.chart-sub { margin: 0 0 0.75rem; color: var(--ink-soft); max-width: 72ch; }
.chart-note { margin: 0.6rem 0 0.3rem; color: var(--ink-faint); font-size: 0.88rem; max-width: 86ch; }
.chart-table summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.chart-table-scroll { overflow-x: auto; max-height: 420px; margin-top: 0.4rem; }
.chart-table table { border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { border-bottom: 1px solid var(--rule); padding: 0.2rem 0.6rem; text-align: left; white-space: nowrap; }
.chart-table .num { text-align: right; }
.chart-body svg.wide { width: 100%; height: auto; display: block; }
.chart-body .grid { stroke: var(--rule); stroke-width: 1; }
.chart-body .axis { stroke: var(--ink-faint); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-body .tick { fill: var(--ink-faint); font: 11px var(--font-ui); font-variant-numeric: tabular-nums; }
.chart-body .bar { fill: var(--accent); }
.chart-body .bar:hover, .chart-body .bar:focus { opacity: 0.75; outline: none; }
.chart-body .marker { stroke: var(--ink-soft); stroke-width: 1; }
.chart-body .marker-label { fill: var(--ink-soft); font: 600 11px var(--font-ui); }
/* small multiples */
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.1rem 1.5rem; }
.multiple-head { margin: 0; display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.multiple-sub { margin: 0 0 0.2rem; font-size: 0.8rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.multiple svg { width: 100%; height: auto; display: block; touch-action: none; }
.multiple .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.multiple .area { fill: var(--accent); opacity: 0.1; }
.multiple .low-cov { fill: var(--paper-3); opacity: 0.7; }
.multiple .crosshair { stroke: var(--ink-faint); stroke-width: 1; vector-effect: non-scaling-stroke; }
.multiple .dot { fill: var(--accent); stroke: var(--paper); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-entity { color: var(--ink); text-decoration: none; display: inline-block; min-height: 24px; }  /* 24 px targets */
.chart-entity:hover { text-decoration: underline; color: var(--accent); }
/* horizontal bars (HTML) */
.hbars { display: grid; gap: 0.45rem; }
.hbar-row { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr 5rem; align-items: center; gap: 0.75rem; }
.hbar-track { display: block; height: 14px; }
.hbar { display: block; height: 14px; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.hbar:hover, .hbar:focus { opacity: 0.75; outline: none; }
.hbar:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hbar-label { font-size: 0.92rem; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 0.9rem; }
.hbar-examples { grid-column: 2 / 4; margin: -0.2rem 0 0.4rem; font-size: 0.85rem; color: var(--ink-faint); }
.hbar-examples .chart-entity { text-decoration: underline; text-underline-offset: 2px; }  /* not told apart by colour alone */
/* one name, three collections */
.tiles { display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem; margin: 0 0 0.35rem; }
.tiles div { display: flex; flex-direction: column-reverse; }
.tiles dt { color: var(--ink-soft); font-size: 0.9rem; }
.tiles dd { margin: 0; font-size: 2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.tiles-note { margin: 0 0 1rem; color: var(--ink-soft); font-size: 0.92rem; }
.btn-inline { padding: 0; border: 0; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.spot-grid { display: grid; gap: 1.25rem; }
.spot-card { border: 1px solid var(--rule); border-radius: 4px; padding: 0.9rem 1rem 0.6rem; background: color-mix(in oklab, var(--paper-2) 45%, var(--paper)); }
.spot-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.1rem 0.9rem; margin-bottom: 0.6rem; }
.spot-type { margin: 0; font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); display: flex; align-items: center; gap: 0.35rem; }
.spot-head h4 { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; margin: 0; }
.spot-counts { margin: 0; color: var(--ink-faint); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.spot-clips { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.25rem; }
.spot-clip { min-width: 0; }
.spot-coll { margin: 0 0 0.3rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.spot-clip .crop { margin: 0 0 0.4rem; min-height: 5rem; }
.spot-clip .crop.loaded { min-height: 0; }
.spot-clip .crop img { max-height: 190px; width: auto; }
.spot-thumb { display: block; margin: 0 0 0.4rem; }
.spot-thumb img { display: block; max-width: 100%; max-height: 190px; width: auto; height: auto; border: 1px solid var(--rule); }
.spot-noimg { margin: 0 0 0.4rem; padding: 0.75rem; background: var(--paper-2); color: var(--ink-faint); font-size: 0.85rem; }
.spot-clip .kwic { font-size: 0.92rem; }
.spot-src { margin: 0.3rem 0 0; font-size: 0.82rem; color: var(--ink-faint); overflow-wrap: anywhere; }
.spot-view { margin: 0.2rem 0 0; font-size: 0.82rem; }
.spot-view a { display: inline-block; line-height: 24px; }
.spot-foot { margin: 0.6rem 0 0; font-size: 0.9rem; }
.spot-foot .chart-entity { color: var(--accent); }
/* what each collection talks about */
.at-grid { display: grid; grid-template-columns: minmax(8rem, 13rem) repeat(var(--at-cols), minmax(0, 1fr)); gap: 0.35rem 1.25rem; align-items: center; }
.at-head { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); padding-bottom: 0.2rem; border-bottom: 1px solid var(--rule); }
.at-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.92rem; }
.at-cell { display: grid; grid-template-columns: minmax(0, 1fr) 2.6rem; align-items: center; gap: 0.4rem; }
.at-cell .hbar-value { text-align: right; font-size: 0.85rem; }
/* top names by type */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.25rem 1.75rem; }
.type-panel h4 { margin: 0 0 0.4rem; font-size: 0.8rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-soft); display: flex; align-items: center; gap: 0.4rem; }
.type-panel ol { list-style: none; margin: 0; padding: 0; }
.type-panel li { display: grid; grid-template-columns: minmax(0, 1fr) 70px 3.5rem; align-items: center; gap: 0.5rem; padding: 0.12rem 0; font-size: 0.9rem; }
.type-panel li .chart-entity { overflow-wrap: anywhere; }  /* wraps rather than cutting a long name off */
.mini-track { display: block; height: 8px; }
.mini-bar { display: block; height: 8px; background: var(--accent); border-radius: 0 4px 4px 0; opacity: 0.85; }
.mini-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 0.85rem; }
/* heatmap */
.heat-scroll { overflow-x: auto; }
.heat-scroll svg { display: block; }
.chart-body .row-label { fill: var(--ink-soft); font: 12px var(--font-ui); }
.heat { cursor: default; }
.heat:hover { stroke: var(--ink); stroke-width: 1; }
.heat-0 { fill: var(--heat-0); } .heat-1 { fill: var(--heat-1); } .heat-2 { fill: var(--heat-2); }
.heat-3 { fill: var(--heat-3); } .heat-4 { fill: var(--heat-4); } .heat-5 { fill: var(--heat-5); }
.heat-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; margin-top: 0.5rem; font-size: 0.85rem; color: var(--ink-soft); }
.heat-key { display: inline-flex; align-items: center; gap: 0.3rem; font-variant-numeric: tabular-nums; }
.heat-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 2px; }
.heat-swatch.heat-1 { background: var(--heat-1); } .heat-swatch.heat-2 { background: var(--heat-2); }
.heat-swatch.heat-3 { background: var(--heat-3); } .heat-swatch.heat-4 { background: var(--heat-4); }
.heat-swatch.heat-5 { background: var(--heat-5); }
/* tooltip: value first, label after; text tokens only */
.chart-tip { position: absolute; z-index: 100; background: var(--ink); color: var(--paper);
  padding: 0.35rem 0.6rem; border-radius: 3px; font-size: 0.85rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.chart-tip strong { font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.chart-tip span { opacity: 0.85; }
@media (max-width: 700px) {
  .hbar-row { grid-template-columns: 8rem 1fr 4rem; }
  .at-grid { grid-template-columns: 6.5rem repeat(var(--at-cols), minmax(0, 1fr)); gap: 0.35rem 0.6rem; }
  .at-head { font-size: 0.68rem; letter-spacing: 0; }
  .at-cell { grid-template-columns: 1fr; gap: 0; }
  .at-cell .hbar-value { text-align: left; }
  .charts-inner { padding: 1rem 1rem 2rem; }
}

/* Shown on hover or focus, and dismissed with Escape without moving the pointer or focus (1.4.13): the "only" buttons
   cover a type's count, the arrows sit on a crop's edges. They return when the pointer or focus moves on (app.js). */
@media (hover: hover) {
  body.hover-dismissed .only-btn { opacity: 0 !important; pointer-events: none; }
  body.hover-dismissed .zoom-badge { opacity: 0 !important; }
}
/* Windows contrast themes replace background colours, which would erase the HTML bar charts and the open-row bar. */
@media (forced-colors: active) {
  .hbar, .mini-bar, .entities tr.active td.name::before { forced-color-adjust: none; background: CanvasText; }
  .swatch, .heat-swatch { forced-color-adjust: none; }
  .entities th { border-bottom: 2px solid CanvasText; }  /* forced colours drop the head's box-shadow rule */
  .btn[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* ── The Smithsonian look (?theme=si; js/theme.js) ───────────────────────────
   Colours, type and the top-level elements of the Smithsonian website design system (SI WDS): near-black and white,
   dark-blue links, yellow highlights, square corners, black primary buttons and table heads, semibold sans headings,
   a black footer. Light only. Fonts: --si-ff-sans below (Indivisible, else Public Sans). The entity-type colours stay the
   validated reference palette. */
:root[data-brand="si"] {
  --paper: #ffffff;
  --paper-2: #f2f4f7;         /* SI off-white */
  --paper-3: #e4e9f2;         /* SI light gray: the open row */
  --ink: #101820;             /* SI black */
  --ink-soft: #343b44;
  --ink-faint: #4e5661;       /* SI dark gray */
  --rule: #b8c0cc;            /* SI medium gray */
  --accent: #00458a;          /* SI dark blue: links, bars, the open row's edge */
  --accent-soft: rgba(0, 69, 138, 0.07);
  --mark: rgba(255, 205, 0, 0.55);   /* SI yellow */
  --focus: #00458a;
  --shadow: 0 8px 28px rgba(16, 24, 32, 0.16);
  --si-yellow: #ffcd00;
  /* The SI WDS font tokens, under its own names: its fonts first (used wherever they are installed or loaded), then
     free stand-ins. Every font-family in this file goes through --font-display or --font-ui. */
  --si-ff-sans: "indivisible", "Public Sans", "Helvetica Neue", Arial, sans-serif;
  --si-ff-serif: "minion-3", "Crimson Pro", Georgia, serif;   /* SI's accent face; not used by the explorer yet */
  --font-display: var(--si-ff-sans);
  --font-ui: var(--si-ff-sans);
  color-scheme: light;
}
[data-brand="si"] h1, [data-brand="si"] h2, [data-brand="si"] h3, [data-brand="si"] h4,
[data-brand="si"] .filters summary, [data-brand="si"] .d-sheet h4, [data-brand="si"] .spot-head h4 { font-weight: 600; letter-spacing: -0.01em; }
[data-brand="si"] a { font-weight: 600; text-underline-offset: 4px; text-decoration-thickness: 1px; }
[data-brand="si"] a:hover { text-decoration: none; }
[data-brand="si"] .entities td.name a, [data-brand="si"] .chart-entity { font-weight: 600; }
[data-brand="si"] .chart-entity:hover { text-decoration: underline; }
/* Buttons: square; primary black on white text, quiet ones outlined in black */
[data-brand="si"] .btn { border-radius: 0; background: var(--ink); border-color: var(--ink); color: #fff; padding: 0.45rem 0.9rem; }
[data-brand="si"] .btn:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 4px; }
[data-brand="si"] .btn-quiet { background: transparent; color: var(--ink); }
[data-brand="si"] .btn-quiet:hover:not(:disabled) { background: var(--paper-2); }
[data-brand="si"] .btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
[data-brand="si"] .btn-inline { background: none; border: 0; padding: 0; color: var(--accent); }
[data-brand="si"] .m-act, [data-brand="si"] .flag-tag, [data-brand="si"] .coll-badge, [data-brand="si"] #q,
[data-brand="si"] .d-sheet, [data-brand="si"] .spot-card, [data-brand="si"] dialog,
[data-brand="si"] .chart-tip, [data-brand="si"] .kwic mark { border-radius: 0; }
[data-brand="si"] #q { background: #fff; border-color: var(--ink-faint); }
[data-brand="si"] .eyebrow { border: 0; padding: 0; font-weight: 600; letter-spacing: 0.08em; color: var(--ink-soft); }
/* The title block: a page title in the SI style, the disclaimer as a callout with a yellow edge */
[data-brand="si"] .hero { padding-top: 2rem; padding-bottom: 1.5rem; }
[data-brand="si"] .hero h1 { font-size: clamp(1.75rem, 3.6vw, 3.25rem); line-height: 1.15; max-width: 24ch; }
[data-brand="si"] .hero-note { background: var(--paper-2); border-left: 4px solid var(--si-yellow); }
[data-brand="si"] .stats dd { font-weight: 700; }
/* The list: SI tables have a black head */
[data-brand="si"] .entities th { background: var(--ink); box-shadow: none; }
[data-brand="si"] table.entities { font-size: 0.94rem; }  /* Public Sans runs wider than Source Sans */
[data-brand="si"] .entities th button { letter-spacing: 0; padding-left: 0.4rem; padding-right: 0.4rem; }
[data-brand="si"] .entities td { padding-left: 0.4rem; padding-right: 0.4rem; }
[data-brand="si"] .d-counts { gap: 0.25rem 1.1rem; }
[data-brand="si"] .entities th button, [data-brand="si"] .entities th[aria-sort] button { color: #fff; }
[data-brand="si"] .entities td { border-bottom-color: var(--rule); }
[data-brand="si"] .entities tbody tr:hover { background: var(--accent-soft); }
[data-brand="si"] .entities tbody tr.active { background: var(--paper-3); }
[data-brand="si"] .d-sheet { border-left: 4px solid var(--si-yellow); }
[data-brand="si"] .d-role { border-left: 4px solid var(--si-yellow); }
[data-brand="si"] .zoom-badge { border-radius: 0; }
[data-brand="si"] .spot-card { background: var(--paper-2); }
[data-brand="si"] .hbar, [data-brand="si"] .mini-bar { border-radius: 0; }
[data-brand="si"] .at-head, [data-brand="si"] .at-label { min-width: 0; overflow-wrap: anywhere; }  /* phones: the wider face */
/* The footer: black, as the SI site's */
[data-brand="si"] .site-footer { background: var(--ink); color: #fff; border-top: 4px solid var(--si-yellow); padding-top: 1.5rem; padding-bottom: 2.25rem; }
[data-brand="si"] .site-footer a { color: #fff; }
[data-brand="si"] .site-footer a:focus-visible { outline-color: var(--si-yellow); }
/* In a frame on si.edu (&embed=1): the host page has the title and footer. The h1 stays for screen readers. */
[data-embed] .hero { padding-top: 1rem; padding-bottom: 1rem; }
[data-embed] #kicker, [data-embed] #subtitle, [data-embed] .hero-credit, [data-embed] .lede, [data-embed] .site-footer { display: none; }
[data-embed] .hero h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[data-embed] .hero-note p:not(.hero-note-short), [data-embed] .hero-note-label { display: none; }
[data-embed] .hero-note .hero-note-short { display: block; margin: 0 0 0.35rem; }
[data-embed] .featured { display: none; }  /* the frame stays short; the host page introduces the explorer */
@media (min-width: 1000px) { [data-embed] .hero { align-items: center; } }
[data-embed] .hero:not(:has(.hero-note)) { display: none; }  /* the charts page: nothing left to show */
