/*
 * Broccoli — GenesisL1's search page: topic maps for search results.
 * Copyright (c) 2026 Decentralized Science Labs LLC. MIT License.
 *
 * The page wears GenesisL1's colours and type, as on genesisl1.com: Inter for
 * text, IBM Plex Sans for headings, DM Mono for labels. The fonts are bundled
 * (SIL Open Font License, see app/fonts/), so the page makes no third-party
 * requests besides the sources'. The maps' surface (--stage) is the one
 * app/colors.js was made for: white, or near-black in dark mode.
 */

@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('fonts/Inter-Italic-Variable.woff2') format('woff2');
  font-weight: 400 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('fonts/IBMPlexSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('fonts/IBMPlexSans-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('fonts/IBMPlexSans-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('fonts/IBMPlexSans-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Sans';
  src: url('fonts/IBMPlexSans-MediumItalic.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'DM Mono';
  src: url('fonts/DMMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DM Mono';
  src: url('fonts/DMMono-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --sheet: #f7f9fb;
  --panel: #ffffff;
  --ink: #11161d;
  --muted: #626b77;
  --intro: #4d5b6d;
  --stem: #4f5d70;
  --stem-soft: #c9d1dc;
  --hairline: #dde2e8;
  --bud: #ffffff;
  --accent: #245cae;
  --accent-soft: #e6eef8;
  --accent-ink: #ffffff;
  --mark: #e3ecfa;
  --danger: #a3321f;
  --focus: #245cae;
  /* the maps' surface, as in app/colors.js (STAGE) */
  --stage: #ffffff;
  --tip: #ffffff;
  --tip-shadow: 0 8px 24px rgba(7, 17, 29, 0.14), 0 1px 3px rgba(7, 17, 29, 0.1);
  --card-shadow: 0 1px 2px rgba(7, 17, 29, 0.04), 0 12px 36px rgba(7, 17, 29, 0.06);
  --page: 1680px;
  --display: 'IBM Plex Sans', 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
  --radius: 0;
  --pill: 0;
  --sidebar: 288px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --sheet: #0b0f15;
    --panel: #11161d;
    --ink: #e1e8f3;
    --muted: #b2bcca;
    --intro: #b5c5da;
    --stem: #8e9db2;
    --stem-soft: #313b49;
    --hairline: #222a35;
    --bud: #18202a;
    --accent: #9cc3fd;
    --accent-soft: #172438;
    --accent-ink: #0b0f15;
    --mark: #1b2b45;
    --danger: #f0a28f;
    --focus: #9cc3fd;
    --stage: #11171f;
    --tip: #18202a;
    --tip-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --sheet: #0b0f15;
  --panel: #11161d;
  --ink: #e1e8f3;
  --muted: #b2bcca;
  --intro: #b5c5da;
  --stem: #8e9db2;
  --stem-soft: #313b49;
  --hairline: #222a35;
  --bud: #18202a;
  --accent: #9cc3fd;
  --accent-soft: #172438;
  --accent-ink: #0b0f15;
  --mark: #1b2b45;
  --danger: #f0a28f;
  --focus: #9cc3fd;
  --stage: #11171f;
  --tip: #18202a;
  --tip-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--sheet);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
}

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- header ---------- */

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

.masthead-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 12px 24px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand sources switch" "brand search switch" ". options .";
  gap: 8px 32px;
  align-items: center;
}

/* light and dark, as the switch in genesisl1.com's header */
.theme-switch {
  grid-area: switch;
  align-self: start;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}
.theme-switch:hover { border-color: var(--ink); }
.theme-switch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.theme-switch svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-switch .i-sun { display: none; }
:root[data-theme='dark'] .theme-switch .i-sun { display: block; }
:root[data-theme='dark'] .theme-switch .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-switch .i-sun { display: block; }
  :root:not([data-theme='light']) .theme-switch .i-moon { display: none; }
}

.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

/* the mark is the Unicode broccoli, drawn by the system's emoji font */
.brand-mark {
  flex: none;
  width: 40px;
  font: 400 35px/1 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'Twemoji Mozilla', sans-serif;
  text-align: center;
}

.brand-name {
  font: 600 25px/1 var(--display);
  letter-spacing: -0.025em;
}

.brand-tag {
  display: block;
  font: 400 13px/1.2 var(--sans);
  color: var(--muted);
  margin-top: 3px;
}

/* the sources: tabs above the search field, every one in sight. Where the
   row is too narrow they wrap onto another line, a group of sources at a time;
   they never scroll sideways. */
.sources { grid-area: sources; min-width: 0; max-width: 880px; }

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 2px 0;
}

.tab-group { display: inline-flex; flex-wrap: wrap; gap: 2px; min-width: 0; }

.source-tab {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 9px 7px;
  border-radius: var(--pill);
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.source-tab:hover { color: var(--ink); background: var(--panel); }
.source-tab[aria-selected='true'] { background: var(--ink); color: var(--sheet); font-weight: 700; }
.source-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.search {
  grid-area: search;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  max-width: 880px;
  min-width: 0;
}

.search-field {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--stem-soft);
  border-radius: var(--radius);
  background: var(--panel);
}

.search-field:focus-within { border-color: var(--ink); }

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 11px 12px;
  font-size: 16px;
  outline: none;
}

.search-field input::placeholder { color: var(--muted); opacity: 0.85; }

.btn {
  border: 1px solid var(--stem-soft);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 8px 12px;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--sheet);
  padding: 10px 20px;
  font-weight: 700;
}

.btn-primary:hover { background: var(--stem); border-color: var(--stem); }
.btn-primary.busy { opacity: 0.6; }

.btn-quiet {
  border-color: transparent;
  background: transparent;
  padding: 6px 8px;
  color: var(--muted);
}

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

.search-options {
  grid-area: options;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  font-size: 14px;
  color: var(--muted);
}

.search-options label { display: inline-flex; align-items: center; gap: 6px; }

.search-options select {
  border: 1px solid var(--hairline);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 4px 6px;
  color: var(--ink);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: var(--panel);
  padding: 4px 10px;
  cursor: pointer;
  color: var(--muted);
}

.segmented button + button { border-left: 1px solid var(--hairline); }
.segmented button[aria-pressed='true'] { background: var(--ink); color: var(--sheet); }

/* ---------- status ---------- */

.status {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 24px;
}

.status-line {
  min-height: 0;
  font-size: 14px;
  color: var(--muted);
  padding: 10px 0 0;
}

.status-line:empty { padding: 0; }
.status-line.error { color: var(--danger); }

.progress {
  height: 2px;
  background: var(--hairline);
  margin-top: 8px;
  overflow: hidden;
}

.progress[hidden] { display: none; }

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--stem);
  transition: width 0.25s ease;
}

.status-line button { margin-left: 6px; }

/* ---------- layout ---------- */

main {
  max-width: var(--page);
  margin: 0 auto;
  padding: 20px 24px 64px;
}

.results {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  column-gap: 40px;
  align-items: start;
}

.map-figure { grid-column: 1 / -1; min-width: 0; }

.results[hidden], .landing[hidden] { display: none; }

/* ---------- topic list ---------- */

.topics {
  position: sticky;
  top: 12px;
  align-self: start;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
}

.topics-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hairline);
}

.topics-head h2 {
  margin: 0;
  font: 500 18px/1.2 var(--display);
  letter-spacing: -0.01em;
}

.topics-head span { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.topic-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.topic-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: baseline;
  text-align: left;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  padding: 6px 8px 6px 10px;
  cursor: pointer;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.topic-list button:hover { background: var(--panel); }

.topic-list .topic-name { overflow-wrap: anywhere; }
.topic-list .topic-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.topic-list .mark { display: inline-flex; justify-content: center; align-self: center; color: var(--muted); }
.topic-list .mark .swatch { width: 11px; height: 11px; }

.topic-list button[aria-current='true'] {
  border-left-color: var(--accent);
  background: var(--panel);
  font-weight: 700;
}

.topic-list .is-up { color: var(--muted); font-size: 14px; }
.topic-list .is-up .topic-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-list .is-child { padding-left: 14px; }
.topic-list .is-other .topic-name { font-style: italic; color: var(--muted); }

.topic-list .topics-note {
  padding: 10px 10px 4px 14px;
  font: 400 14px/1.5 var(--sans);
  color: var(--muted);
}

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

.map-figure {
  margin: 0 0 30px;
}

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0 0 12px;
  min-height: 38px;
}

.map-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.crumbs {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 2px 4px;
  min-width: 0;
  font-size: 14.5px;
  overflow-x: auto;
  scrollbar-width: none;
}

.crumbs::-webkit-scrollbar { display: none; }

.crumb {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  max-width: 26ch;
  border: 0;
  background: none;
  padding: 3px 4px;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
}

.crumb:hover { color: var(--ink); background: var(--panel); }
.crumb.current { color: var(--ink); font-weight: 700; cursor: default; max-width: 40ch; }
.crumb, .crumb.current { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { flex: none; color: var(--stem-soft); }

.swatch {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.swatch.hatched {
  background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px) !important;
}

.view-switch {
  position: relative;
  isolation: isolate;
  padding: 3px;
  gap: 2px;
  border-radius: var(--pill);
  background: var(--panel);
  overflow: visible;
}

.view-switch button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: var(--pill);
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  transition: color 0.2s ease;
}

.view-switch button + button { border-left: 0; }
.view-switch button:hover { color: var(--ink); }
.view-switch button[aria-pressed='true'] { background: transparent; color: var(--sheet); }

.view-switch .seg-thumb {
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: var(--pill);
  background: var(--ink);
  transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1), width 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
}

/* Before the script measures the buttons, the pressed one has its own background. */
.view-switch:not(.measured) button[aria-pressed='true'] { background: var(--ink); }

.view-switch svg {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--hairline);
  border-radius: var(--pill);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover { color: var(--ink); border-color: var(--stem-soft); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .when-on { display: none; }
.icon-btn[aria-pressed='true'] .when-on { display: block; }
.icon-btn[aria-pressed='true'] .when-off { display: none; }

.stage {
  position: relative;
  background: var(--stage);
  border: 1px solid var(--hairline);
  border-radius: 0;
  overflow: hidden;
  min-height: 200px;
  box-shadow: var(--card-shadow);
}

.views-canvas {
  display: block;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.views-canvas[hidden] { display: none; }
.views-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); border-radius: 0; }

.stage .florets { padding: 4px 0; }
.stage .florets[hidden] { display: none; }

.views-tip {
  position: absolute;
  z-index: 3;
  max-width: min(320px, 80%);
  padding: 9px 12px 10px;
  background: var(--tip);
  color: var(--ink);
  border-radius: 0;
  border: 1px solid var(--hairline);
  box-shadow: var(--tip-shadow);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  display: grid;
  gap: 3px;
}

.views-tip[hidden] { display: none; }
.views-tip strong { font-size: 14px; font-weight: 700; }
.views-tip .meta { color: var(--muted); }
.views-tip .sub { color: var(--ink); }
.views-tip .hint { color: var(--muted); font-style: italic; font-size: 12.5px; }

.map-nav {
  display: flex;
  align-items: center;
  gap: 4px 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.up-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--hairline);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--pill);
  padding: 4px 14px 4px 11px;
  font-size: 14px;
  cursor: pointer;
}

.up-btn::before { content: '‹'; margin-right: 7px; color: var(--muted); font-size: 18px; line-height: 1; }
.up-btn:hover { border-color: var(--ink); }
.up-btn[hidden] { display: none; }

.stage-note {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100% - 24px);
  padding: 5px 12px;
  border-radius: var(--pill);
  background: var(--panel);
  border: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}

.stage-note[hidden] { display: none; }
.stage-note.busy::before, .topics-note .spinner {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  vertical-align: -1px;
  border-radius: 50%;
  border: 2px solid var(--stem-soft);
  border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.florets { display: block; width: 100%; height: auto; overflow: visible; }

.florets .ray { stroke: var(--ray, var(--stem-soft)); stroke-width: 1.2; fill: none; opacity: 0.75; }
.florets .center { fill: var(--accent); }
.florets .floret { cursor: pointer; outline: none; }
.florets .floret .disc { fill: var(--sheet); stroke: none; }
.florets .floret .bud { fill: var(--bud-fill, var(--bud)); stroke: var(--bud-stroke, var(--stem)); stroke-width: 0.9; }
.florets .floret .bud.shared { fill: var(--accent-soft); stroke: var(--accent); }
.florets .floret .label { fill: var(--ink); font: 400 var(--florets-fs, 13px) var(--sans); }
.florets .floret .count { fill: var(--muted); font: 400 calc(var(--florets-fs, 13px) - 1px) var(--sans); }
.florets .floret .label.hidden-label, .florets .floret .count.hidden-label { opacity: 0; }
.florets .floret:hover .label.hidden-label, .florets .floret:focus .label.hidden-label,
.florets .floret:hover .count.hidden-label, .florets .floret:focus .count.hidden-label { opacity: 1; }
.florets .floret:hover .bud { stroke: var(--ink); }
.florets .floret:focus-visible .disc { stroke: var(--focus); stroke-width: 2; }
.florets .floret.selected .bud { fill: var(--accent); stroke: var(--accent); }
.florets .floret.selected .label { fill: var(--accent); font-weight: 700; }
.florets .floret.selected .count { fill: var(--accent); }
.florets .ray.selected { stroke: var(--accent); stroke-width: 2; }
.florets .label-bg { fill: var(--sheet); opacity: 0.86; }

.florets.blooming .ray { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: ray-grow 0.55s ease-out forwards; animation-delay: var(--delay); }
.florets.blooming .floret { opacity: 0; animation: floret-open 0.45s ease-out forwards; animation-delay: calc(var(--delay) + 0.3s); }

@keyframes ray-grow { to { stroke-dashoffset: 0; } }
@keyframes floret-open { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .florets.blooming .ray, .florets.blooming .floret { animation: none; opacity: 1; stroke-dashoffset: 0; }
  .progress span { transition: none; }
  .stage-note.busy::before, .topics-note .spinner { animation-duration: 2.4s; }
  .record.flash { animation: none; }
}

.map-caption {
  font: 400 14px/1.5 var(--sans);
  color: var(--muted);
  max-width: 80ch;
  margin: 10px 2px 0;
}

/* The map on the whole screen. */
body.map-expanded { overflow: hidden; }

.map-figure.expanded {
  position: fixed;
  inset: 0;
  z-index: 25;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--sheet);
  padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}

.map-figure.expanded .map-caption { display: none; }
.map-figure.expanded .map-toolbar { margin-bottom: 10px; }

/* ---------- records ---------- */

.records-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin: 18px 0 6px;
}

.records-head h2 {
  margin: 0;
  font: 500 27px/1.15 var(--display);
  letter-spacing: -0.025em;
  overflow-wrap: anywhere;
}

.records-head .records-sub {
  display: block;
  margin-top: 4px;
  font: 400 14px/1.4 var(--sans);
  color: var(--muted);
}

.records-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ''; display: inline-block; margin-left: 8px; border: 4px solid transparent; border-top-color: currentColor; transform: translateY(2px); }
.menu[open] > summary { border-color: var(--ink); }

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 4px;
  display: grid;
}

.menu-list button {
  border: 0;
  background: none;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.menu-list button:hover, .menu-list button:focus-visible { background: var(--sheet); }
.menu-list small { display: block; color: var(--muted); font-size: 12.5px; }

.record-list { list-style: none; margin: 0; padding: 0; max-width: 78ch; transition: opacity 0.2s ease; }
.record-list.stale { opacity: 0.45; }

.record {
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--hairline);
}

.record h3 {
  margin: 0 0 4px;
  font: 500 18.5px/1.35 var(--display);
  letter-spacing: -0.01em;
}

.record h3 a { text-decoration: none; }
.record h3 a:hover { text-decoration: underline; }

.citation {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--muted);
  margin: 0 0 8px;
}

.citation a { color: var(--muted); }
.citation a:hover { color: var(--accent); }
.citation .ids { white-space: nowrap; }

.abstract {
  font: 400 15.5px/1.68 var(--sans);
  margin: 0;
}

.abstract.clamped {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.abstract-section { margin: 0 0 8px; }
.abstract-section b { font: 700 13px/1 var(--sans); color: var(--muted); margin-right: 6px; letter-spacing: 0.01em; }

.abstract mark, .record h3 mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.record-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--muted);
}

.record-foot .in-topics button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--stem-soft);
  text-underline-offset: 2px;
  cursor: pointer;
}

.record-foot .in-topics button:hover { color: var(--accent); }
.record-foot .in-topics .swatch { width: 8px; height: 8px; margin-right: 5px; vertical-align: 0; }

.record.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.record-foot .in-topics button[aria-current='true'] { color: var(--accent); font-weight: 700; text-decoration: none; }

.mesh { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.mesh b { color: var(--ink); font-weight: 700; }

.more { margin: 18px 0; }

.empty {
  padding: 32px 0;
  font: 400 16px/1.55 var(--sans);
  color: var(--muted);
}

.about-result { margin-top: 28px; font-size: 13.5px; color: var(--muted); max-width: 78ch; }
.about-result summary { cursor: pointer; }
.about-result dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; margin: 10px 0 0; }
.about-result dt { color: var(--ink); }
.about-result dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- landing ---------- */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 40px;
  align-items: center;
  padding: 24px 0 8px;
}

.landing h1 {
  font: 400 clamp(36px, 4.4vw, 58px)/1.02 var(--display);
  letter-spacing: -0.045em;
  margin: 0 0 18px;
  max-width: 15ch;
}

.landing p {
  font: 400 18px/1.62 var(--sans);
  color: var(--intro);
  max-width: 44ch;
  margin: 0 0 14px;
}

.landing .fine { font: 400 14.5px/1.5 var(--sans); color: var(--muted); max-width: 52ch; }

.source-card {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 16px;
  margin: 20px 0 20px;
  max-width: 50ch;
}
.landing .source-card .source-kicker {
  font: 500 11px/1.25 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
.source-card h2 { font: 400 30px/1.1 var(--display); letter-spacing: -0.035em; margin: 0 0 8px; }
.landing .source-card p { font: 400 16px/1.6 var(--sans); color: var(--ink); margin: 0 0 8px; }
.landing .source-card .fine { font: 400 14px/1.5 var(--sans); color: var(--muted); margin: 0; }
.source-links { white-space: nowrap; }
.source-links a { color: var(--accent); }

.access-group h3 { font: 700 14px/1.3 var(--sans); margin: 16px 0 0; }
.access-group:first-child h3 { margin-top: 6px; }
#years-row[hidden] { display: none; }

.examples { display: none; }

.examples ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.examples button {
  border: 1px solid var(--hairline);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  text-align: left;
}

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

.landing-map figcaption {
  font: 400 11px/1.4 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

/* ---------- settings drawer ---------- */

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(460px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--hairline);
  z-index: 20;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  visibility: hidden;
}

.drawer.open { transform: none; visibility: visible; }

@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
}

.drawer-head h2 { margin: 0; font: 500 21px/1.2 var(--display); letter-spacing: -0.02em; }

.drawer-body { overflow-y: auto; padding: 4px 18px 32px; }

.drawer fieldset {
  border: 0;
  border-bottom: 1px solid var(--hairline);
  margin: 0;
  padding: 14px 0 16px;
}

.drawer legend {
  float: left;
  width: 100%;
  font: 600 16px/1.3 var(--display);
  letter-spacing: -0.01em;
  padding: 0;
  margin: 0 0 6px;
}

.drawer fieldset > :not(legend) { clear: both; }

.drawer .hint { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }

.field { display: grid; gap: 4px; margin: 10px 0; }
.field > span { font-size: 14px; }
.field small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

.field input[type='text'], .field input[type='number'], .field input[type='email'],
.field input[type='password'], .field input[type='url'], .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--sheet);
  padding: 7px 9px;
}

.field textarea { min-height: 70px; resize: vertical; font-size: 14px; }

.check { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0; font-size: 14px; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: 12.5px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.param-group { margin: 6px 0 0; }
.param-group summary { cursor: pointer; font-size: 14px; padding: 6px 0; }
.param-group[open] summary { color: var(--accent); }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(7, 17, 29, 0.32);
  z-index: 19;
}

.scrim[hidden] { display: none; }

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

.colophon {
  max-width: var(--page);
  margin: 0 auto;
  padding: 18px 24px 36px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}

.colophon p { margin: 0; max-width: 80ch; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--sheet);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 30;
}

.toast[hidden] { display: none; }

/* ---------- small screens ---------- */

@media (max-width: 1020px) {
  .results { grid-template-columns: minmax(0, 1fr); row-gap: 12px; }
  .map-figure { margin-bottom: 14px; }
  .topics { position: static; max-height: none; }
  .topic-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 196px; padding: 10px 0; }
  .topic-list li { flex: 0 1 auto; }
  .topic-list button {
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 4px 9px;
    gap: 6px;
  }
  .topic-list button[aria-current='true'] { border-color: var(--accent); }
  .topic-list button { grid-template-columns: auto 1fr auto; }
  .topic-list .is-child { padding-left: 9px; }
  .topic-list .topics-note { flex-basis: 100%; padding: 2px 2px; }
  .landing { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

/* Tablets and phones: the header stacks, the tabs and the search field take the full width. */
@media (max-width: 1020px) {
  .masthead-inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand switch" "sources sources" "search search" "options options"; gap: 10px 16px; }
  .theme-switch { align-self: center; }
  .sources, .search { max-width: none; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  .examples { display: block; }
  .landing-map figcaption { display: none; }
  .masthead-inner { padding: 12px 16px; gap: 10px; }
  /* Phones: the tabs flow one by one, on as few lines as fit. */
  .tab-group { display: contents; }
  .source-tabs { gap: 4px 2px; }
  .source-tab { padding: 7px 10px 8px; }
  .source-card { margin: 14px 0; }
  .status, main, .colophon { padding-left: 16px; padding-right: 16px; }
  .records-head h2 { font-size: 23px; }
  .map-toolbar { flex-direction: column-reverse; align-items: stretch; gap: 10px; }
  .map-tools { width: 100%; }
  .view-switch { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .view-switch button { padding: 8px 4px; font-size: 13.5px; gap: 5px; min-height: 36px; }
  .map-nav { min-height: 34px; flex-wrap: nowrap; }
  /* Phones: the map runs edge to edge. */
  .stage { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .views-canvas:focus-visible { border-radius: 0; }
  .map-caption { font-size: 14px; }
  .map-figure.expanded { padding-left: 0; padding-right: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .map-figure.expanded .map-toolbar { padding: 0 max(12px, env(safe-area-inset-left, 0px)) 0 max(12px, env(safe-area-inset-right, 0px)); }
  .map-figure.expanded .stage { margin: 0; }
  .record h3 { font-size: 18px; }
  .abstract { font-size: 16px; }
  .row { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .view-switch button { font-size: 12.5px; gap: 4px; }
  .view-switch svg { width: 14px; height: 14px; }
}

@media (max-width: 345px) {
  /* The narrowest phones: icons only (each button keeps its title and pressed state). */
  .view-switch .seg-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .view-switch svg { width: 17px; height: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .view-switch .seg-thumb { transition: none; }
}
