/* Anomadex — dark field-archive theme.
   Near-black forest surfaces, bone text, one lantern-amber accent. Category hues are used only
   for data (observation types), never for chrome. */

:root {
  color-scheme: dark;
  --bg: #090d0b;
  --bg-2: #0d1310;
  --surface: #121915;
  --surface-2: #18211c;
  --surface-3: #1f2a24;
  --line: #243029;
  --line-strong: #33423a;
  --ink: #ece8dc;
  --ink-2: #bdbaae;
  --muted: #858c83;
  --faint: #5d655d;
  --accent: #e9b04b;
  --accent-2: #f5c877;
  --accent-ink: #1b1405;
  --accent-soft: rgba(233, 176, 75, .11);
  --accent-line: rgba(233, 176, 75, .35);
  --focus: #8ec9ff;
  --good: #7fcf8e;
  --warn: #e9b04b;
  --bad: #f08a7a;

  /* Observation categories (data only) */
  --cat-sighting: #f0a93c;
  --cat-sound: #4cc3c9;
  --cat-trace: #a996f7;
  --cat-contact: #f07b6d;
  --cat-sense: #9fcd5f;
  --cat-context: #97a3b4;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  --header-h: 64px;
  --maxw: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font: 400 15.5px/1.6 var(--font-ui); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(233, 176, 75, .35); color: var(--ink); }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
h1, h2 { font-family: var(--font-display); font-optical-sizing: auto; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); font-weight: 600; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--font-mono); font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 2000; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 12px; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ------------------------------------------------------------------ header */
.site-header {
  position: sticky; top: 0; z-index: 1000; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { height: 100%; display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); flex-shrink: 0; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 34px; height: 34px; color: var(--accent); }
.brand-name { font: 600 1.28rem/1 var(--font-display); letter-spacing: -.01em; }
.brand-name em { font-style: normal; color: var(--accent); }
.nav { display: flex; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500; font-size: .92rem;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.nav .icon { width: 17px; height: 17px; opacity: .8; }
.header-search { margin-left: auto; position: relative; width: min(300px, 32vw); }
.header-search input {
  width: 100%; height: 38px; padding: 0 44px 0 38px; border-radius: 9px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); font: inherit; font-size: .9rem;
}
.header-search input::placeholder { color: var(--faint); }
.header-search input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.header-search .icon { position: absolute; left: 12px; top: 10px; width: 17px; height: 17px; color: var(--muted); }
.header-search kbd {
  position: absolute; right: 9px; top: 9px; font: 500 .72rem/1 var(--font-mono); color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 3px 6px;
}
.btn.menu-btn { display: none; }

/* ------------------------------------------------------------------ buttons, chips */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  font: 500 .92rem/1 var(--font-ui); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); color: var(--ink); border-color: var(--faint); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: .84rem; border-radius: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  font-size: .8rem; font-weight: 500; line-height: 1.4; white-space: nowrap;
}
a.chip:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-3); }
.chip .dot { width: 8px; height: 8px; }
.chip-x::after { content: "×"; margin-left: 2px; color: var(--muted); font-size: 1rem; line-height: 1; }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cat-context); flex-shrink: 0; }
[data-cat="sighting"] { --cat: var(--cat-sighting); }
[data-cat="sound"] { --cat: var(--cat-sound); }
[data-cat="trace"] { --cat: var(--cat-trace); }
[data-cat="contact"] { --cat: var(--cat-contact); }
[data-cat="sense"] { --cat: var(--cat-sense); }
[data-cat="context"] { --cat: var(--cat-context); }
.dot[data-cat], [data-cat] > .dot { background: var(--cat); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font: 600 .72rem/1 var(--font-ui); letter-spacing: .03em; text-transform: uppercase;
  background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--line-strong);
}
.badge-class { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-line); }
.badge-extra { background: rgba(169, 150, 247, .1); color: #c9bdff; border-color: rgba(169, 150, 247, .3); }
.badge-method-AI_INFERRED { background: rgba(240, 138, 122, .1); color: #f7b0a4; border-color: rgba(240, 138, 122, .3); }
.badge-method-SOURCE_EXPLICIT { background: rgba(127, 207, 142, .09); color: #a6e0b1; border-color: rgba(127, 207, 142, .28); }
.badge-method-DERIVED, .badge-method-GEOCODED { background: rgba(142, 201, 255, .08); color: #b6dcff; border-color: rgba(142, 201, 255, .25); }

.eyebrow { font: 600 .74rem/1 var(--font-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.catno { font: 500 .78rem/1 var(--font-mono); color: var(--muted); letter-spacing: .02em; }

/* ------------------------------------------------------------------ hero */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(233, 176, 75, .16), transparent 62%),
    radial-gradient(700px 500px at 88% 110%, rgba(76, 195, 201, .07), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}
.hero-topo { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; opacity: .5; color: var(--line-strong);
  mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at 50% 30%, #000 20%, transparent 75%); }
.hero-trees { position: absolute; left: 0; right: 0; bottom: -1px; z-index: -1; width: 100%; height: 120px; color: #070a09; }
.hero .container { padding-top: clamp(56px, 9vw, 104px); padding-bottom: clamp(88px, 11vw, 136px); text-align: center; }
.hero h1 { font-size: clamp(2.5rem, 6.5vw, 4.4rem); font-weight: 600; letter-spacing: -.025em; line-height: 1.02; margin: 16px 0 14px; }
.hero h1 em { font-style: italic; font-weight: 500; color: var(--accent); }
.hero-sub { font-size: clamp(1.02rem, 1.6vw, 1.18rem); color: var(--ink-2); max-width: 640px; margin: 0 auto 34px; }

.search-box { position: relative; max-width: 720px; margin: 0 auto; }
.search-box input {
  width: 100%; height: 62px; padding: 0 148px 0 56px; border-radius: 14px; font: 400 1.08rem/1 var(--font-ui);
  background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--ink);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg), 0 0 0 6px rgba(233, 176, 75, .04);
}
.search-box input::placeholder { color: var(--faint); }
.search-box input:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--shadow-lg), 0 0 0 4px var(--accent-soft); }
.search-box > .icon { position: absolute; left: 20px; top: 21px; width: 21px; height: 21px; color: var(--muted); }
.search-box .btn { position: absolute; right: 8px; top: 8px; height: 46px; padding: 0 22px; border-radius: 10px; }
.search-hints { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; font-size: .86rem; color: var(--muted); }

.stats-band { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; margin-top: -46px; position: relative; z-index: 2;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat { padding: 20px 22px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat-value { font: 600 1.85rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-label { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* ------------------------------------------------------------------ sections, cards */
.section { padding: 64px 0 0; }
.section:last-of-type { padding-bottom: 80px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head p { margin: 6px 0 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 22px; }

.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.cat-tile {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 20px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink);
  transition: border-color .15s, transform .15s, background .15s;
}
.cat-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cat); opacity: .9; }
.cat-tile:hover { border-color: var(--line-strong); background: var(--surface-2); transform: translateY(-2px); color: var(--ink); }
.cat-tile-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.cat-tile h3 { font: 600 1.14rem/1.2 var(--font-display); }
.cat-tile .count { font: 600 1.4rem/1 var(--font-display); color: var(--cat); font-variant-numeric: tabular-nums; }
.cat-tile p { margin: 0; color: var(--muted); font-size: .88rem; }
.cat-tile .top { font-size: .82rem; color: var(--ink-2); }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; }
.enc-list { display: flex; flex-direction: column; gap: 12px; }

.enc-card {
  display: block; position: relative; padding: 18px 20px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s, background .15s;
}
.enc-card:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }
.enc-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: .82rem; color: var(--muted); }
.enc-card-meta span { display: inline-flex; align-items: center; gap: 6px; }
.enc-card-meta .icon { width: 14px; height: 14px; opacity: .75; }
.enc-card h3 { font: 600 1.12rem/1.3 var(--font-display); margin: 8px 0 6px; letter-spacing: -.005em; }
.enc-card:hover h3 { color: var(--accent-2); }
.enc-card p { margin: 0 0 12px; color: var(--ink-2); font-size: .92rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.enc-card .chips .chip { font-size: .75rem; padding: 2px 9px; }

.mini-list { display: flex; flex-direction: column; }
.mini-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 13px 0; border-top: 1px solid var(--line); color: var(--ink); }
.mini-item:first-child { border-top: 0; padding-top: 0; }
.mini-item:hover .mini-title { color: var(--accent-2); }
.mini-title { font-weight: 550; font-size: .94rem; line-height: 1.35; }
.mini-sub { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.mini-item .catno { align-self: start; padding-top: 3px; }

/* ------------------------------------------------------------------ charts (ported from PodDB) */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .label { fill: var(--muted); font-size: 11px; font-family: var(--font-ui); }
.chart .value { fill: var(--ink-2); font-size: 11px; font-weight: 600; font-family: var(--font-ui); }
.chart .name { fill: var(--ink-2); font-size: 12px; font-family: var(--font-ui); }
.chart .bar { fill: var(--accent); transition: opacity .12s; }
.chart .bar.is-dim { opacity: .28; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar.is-hover { opacity: .78; }
.tooltip {
  position: fixed; z-index: 3000; pointer-events: none; padding: 6px 10px; border-radius: 7px;
  background: var(--ink); color: var(--bg); font-size: .8rem; font-weight: 550; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(4px); transition: opacity .1s, transform .1s; white-space: nowrap;
}
.tooltip.is-visible { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ page header */
.page-head { padding: 44px 0 28px; border-bottom: 1px solid var(--line);
  background: radial-gradient(700px 240px at 10% -30%, rgba(233, 176, 75, .09), transparent 70%); }
.page-head p.lead { color: var(--ink-2); font-size: 1.05rem; max-width: 760px; margin: 12px 0 0; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--ink-2); }
.crumbs a:hover { color: var(--accent-2); }
.crumbs .sep { color: var(--faint); }

/* ------------------------------------------------------------------ search page */
.search-top { padding: 28px 0 22px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.search-top .search-box { max-width: none; margin: 0; }
.search-top .search-box input { height: 54px; box-shadow: none; font-size: 1rem; }
.search-top .search-box > .icon { top: 17px; }
.search-top .search-box .btn { height: 40px; top: 7px; right: 7px; }
.search-layout { display: grid; grid-template-columns: 272px 1fr; gap: 32px; padding: 28px 0 72px; align-items: start; }
.filters { position: sticky; top: calc(var(--header-h) + 20px); display: flex; flex-direction: column; gap: 22px;
  max-height: calc(100vh - var(--header-h) - 40px); overflow: auto; padding-right: 6px; scrollbar-width: thin; }
.filter-group h3 { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.facet { display: flex; align-items: center; gap: 9px; padding: 5px 8px; margin: 0 -8px; border-radius: 7px; color: var(--ink-2); font-size: .9rem; }
.facet:hover { background: var(--surface-2); color: var(--ink); }
.facet .n { margin-left: auto; color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.facet.is-on { color: var(--ink); background: var(--accent-soft); }
.facet.is-on .n { color: var(--accent-2); }
.facet .box { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid var(--line-strong); flex-shrink: 0; display: grid; place-items: center; }
.facet.is-on .box { background: var(--accent); border-color: var(--accent); }
.facet.is-on .box::after { content: ""; width: 7px; height: 4px; border: solid var(--accent-ink); border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px); }
.facet .dot { width: 9px; height: 9px; }
.year-form { display: flex; gap: 8px; align-items: center; }
.year-form input, .select {
  width: 100%; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem;
}
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23858c83' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
.more { font-size: .82rem; margin-top: 4px; display: inline-block; }
details.facet-more summary { list-style: none; cursor: pointer; font-size: .82rem; color: var(--accent-2); padding: 4px 0; }
details.facet-more summary::-webkit-details-marker { display: none; }
details.facet-more[open] summary { display: none; }

.results-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.results-count { font-size: .95rem; color: var(--ink-2); }
.results-count strong { color: var(--ink); font-weight: 650; }
.sort { display: flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--muted); }
.sort .select { width: auto; height: 34px; }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; align-items: center; }
.result-list { display: flex; flex-direction: column; gap: 12px; }
mark { background: rgba(233, 176, 75, .22); color: var(--ink); border-radius: 3px; padding: 0 1px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 28px; }
.pager a, .pager span { min-width: 38px; height: 38px; padding: 0 12px; display: grid; place-items: center; border-radius: 9px;
  border: 1px solid var(--line); color: var(--ink-2); font-size: .9rem; font-variant-numeric: tabular-nums; }
.pager a:hover { background: var(--surface-2); color: var(--ink); }
.pager .is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.pager .gap { border: 0; }

.empty { text-align: center; padding: 64px 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.filters-toggle { display: none; }

/* ------------------------------------------------------------------ encounter page */
.enc-head { padding: 36px 0 30px; border-bottom: 1px solid var(--line);
  background: radial-gradient(900px 300px at 0% -40%, rgba(233, 176, 75, .1), transparent 70%), var(--bg-2); }
.enc-head h1 { max-width: 900px; margin: 12px 0 16px; }
.enc-keyline { display: flex; flex-wrap: wrap; gap: 10px 22px; color: var(--ink-2); font-size: .95rem; }
.enc-keyline span { display: inline-flex; align-items: center; gap: 8px; }
.enc-keyline .icon { color: var(--accent); width: 17px; height: 17px; }
.enc-badges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.enc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; padding: 32px 0 80px; align-items: start; }
.enc-main { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.enc-side { display: flex; flex-direction: column; gap: 18px; position: sticky; top: calc(var(--header-h) + 20px); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.panel > h2 { font-size: 1.15rem; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.panel > .panel-sub { color: var(--muted); font-size: .86rem; margin: 0 0 16px; }
.summary-text { font: 400 1.14rem/1.72 var(--font-display); color: var(--ink); margin: 14px 0 0; font-optical-sizing: auto; }
.summary-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.summary-note .icon { width: 15px; height: 15px; margin-top: 2px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 10px; font-size: .9rem;
  background: rgba(169, 150, 247, .07); border: 1px solid rgba(169, 150, 247, .25); color: var(--ink-2); }
.notice .icon { color: #c9bdff; margin-top: 2px; }
.notice-ok { background: rgba(127, 207, 142, .07); border-color: rgba(127, 207, 142, .28); }
.notice-ok .icon { color: var(--good); }

.modes-grid { display: grid; gap: 16px; margin-top: 14px; }
.mode-group h3 { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.mode-items { display: flex; flex-wrap: wrap; gap: 8px; }
.mode-item { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px 7px 10px; border-radius: 9px;
  background: color-mix(in srgb, var(--cat) 9%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--cat) 30%, transparent);
  color: var(--ink); font-size: .88rem; font-weight: 500; }
.mode-item:hover { color: var(--ink); border-color: var(--cat); }

.facts { width: 100%; border-collapse: collapse; font-size: .92rem; }
.facts th, .facts td { text-align: left; vertical-align: top; padding: 12px 0; border-top: 1px solid var(--line); }
.facts tr:first-child th, .facts tr:first-child td { border-top: 0; }
.facts th { width: 34%; padding-right: 16px; color: var(--muted); font-weight: 500; }
.fact-value { color: var(--ink); font-weight: 500; }
.fact-prov { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: .78rem; color: var(--muted); }
.fact-prov .conf { font-variant-numeric: tabular-nums; }
.alt { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(233, 176, 75, .06); border: 1px dashed var(--accent-line); font-size: .84rem; color: var(--ink-2); }
.alt b { color: var(--accent-2); font-weight: 600; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; display: block; margin-bottom: 2px; }

.desc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 14px; }
.desc-cell { background: var(--surface); padding: 12px 14px; }
.desc-cell dt { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.desc-cell dd { margin: 0; color: var(--ink); font-size: .95rem; }
.desc-cell .q::before { content: "“"; color: var(--faint); }
.desc-cell .q::after { content: "”"; color: var(--faint); }
.desc-cell.wide { grid-column: 1 / -1; }
.src-tick { font: 500 .68rem/1 var(--font-mono); color: var(--faint); text-transform: none; letter-spacing: 0; cursor: help; }

.ev-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.ev-item { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.ev-item .ev-type { font-weight: 600; font-size: .86rem; display: flex; justify-content: space-between; gap: 10px; }
.ev-item p { margin: 4px 0 0; color: var(--ink-2); font-size: .9rem; }
.ev-item .ptr { font-size: .76rem; color: var(--muted); margin-top: 6px; }

.timeline { list-style: none; margin: 14px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line-strong); }
.timeline li { position: relative; padding: 0 0 18px 30px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 1px; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); }
.timeline li.is-secondary::before { border-color: var(--line-strong); }
.tl-title { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tl-meta { font-size: .8rem; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.tl-meta code { font-size: .76rem; color: var(--ink-2); }

.side-map { height: 240px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); margin-top: 12px; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: .88rem; margin: 14px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); text-align: right; }
.rel-list { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.rel-item { display: block; padding: 10px 12px; margin: 0 -12px; border-radius: 8px; color: var(--ink); }
.rel-item:hover { background: var(--surface-2); color: var(--ink); }
.rel-item .t { font-size: .9rem; font-weight: 550; line-height: 1.35; }
.rel-item .s { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.report-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.report-form textarea { min-height: 96px; resize: vertical; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--bg-2); color: var(--ink); font: inherit; font-size: .9rem; }
.report-form textarea:focus, .select:focus, .year-form input:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.hp { position: absolute; left: -9999px; }

.consent { position: fixed; z-index: 2000; left: 16px; right: 16px; bottom: 16px; max-width: 720px; margin: 0 auto;
  display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); font-size: .88rem; color: var(--ink-2); }
.consent[hidden] { display: none; }
.consent p { margin: 0; flex: 1; line-height: 1.5; }
.consent strong { color: var(--ink); }
.consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.linklike:hover { color: var(--accent-2); }

.place-head { padding-top: 28px; padding-bottom: 4px; }
.place-head h1 { margin: 6px 0 8px; }
.place-head p { margin: 0; max-width: 760px; }

.contact-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 28px; align-items: start; padding: 8px 0 56px; }
.contact-form { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.contact-form label { font-size: .85rem; color: var(--ink-2); margin-top: 6px; }
.contact-form .input, .contact-form textarea { width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--bg-2); color: var(--ink); font: inherit; font-size: .92rem; }
.contact-form textarea { min-height: 150px; resize: vertical; }
.contact-form .input:focus, .contact-form textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.contact-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.contact-row > div { display: flex; flex-direction: column; gap: 8px; }
.contact-aside h3 { font-size: .95rem; margin: 4px 0 10px; }
.contact-aside ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); font-size: .9rem; }

/* ------------------------------------------------------------------ prose, phenomena, places */
.prose { max-width: 760px; }
.prose h2 { margin: 44px 0 12px; }
.prose h3 { margin: 26px 0 8px; font-size: 1.05rem; }
.prose p, .prose li { color: var(--ink-2); }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--ink); }
.about-layout { display: grid; grid-template-columns: 220px 1fr; gap: 48px; padding: 36px 0 88px; }
.toc { position: sticky; top: calc(var(--header-h) + 24px); align-self: start; display: flex; flex-direction: column; gap: 2px; font-size: .88rem; }
.toc a { color: var(--muted); padding: 6px 12px; border-left: 2px solid var(--line); }
.toc a:hover { color: var(--ink); border-left-color: var(--accent); }
.def-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 12px 0 20px; }
.def-table th, .def-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.def-table th { color: var(--muted); font-weight: 600; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase; }
.def-table td:first-child { color: var(--ink); font-weight: 550; white-space: nowrap; }

.ph-section { padding: 36px 0 0; }
.ph-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ph-head h2 { font-size: 1.35rem; }
.ph-head .dot { width: 12px; height: 12px; }
.ph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ph-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); position: relative; overflow: hidden; }
.ph-card:hover { border-color: color-mix(in srgb, var(--cat) 55%, transparent); color: var(--ink); background: var(--surface-2); }
.ph-card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ph-card h3 { font-size: 1rem; }
.ph-card .n { font: 600 1.1rem/1 var(--font-display); color: var(--cat); font-variant-numeric: tabular-nums; }
.ph-card p { margin: 0; font-size: .86rem; color: var(--muted); }
.ph-card .meter { height: 3px; border-radius: 2px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.ph-card .meter i { display: block; height: 100%; background: var(--cat); border-radius: 2px; }
.ph-card.is-empty { opacity: .55; }

.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; padding: 32px 0 80px; }
.place-card h2 { font-size: 1.3rem; display: flex; justify-content: space-between; align-items: baseline; }
.place-card h2 a { color: var(--ink); }
.place-card h2 a:hover { color: var(--accent-2); }
.place-card h2 .n { font-size: 1rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.county-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; }
.county-list li a { display: grid; grid-template-columns: 1fr 90px 36px; align-items: center; gap: 12px; padding: 6px 0; color: var(--ink-2); font-size: .9rem; }
.county-list li a:hover { color: var(--ink); }
.county-list .bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.county-list .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; opacity: .8; }
.county-list .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; }

/* ------------------------------------------------------------------ map (approach ported from PodDB) */
.map-view { position: relative; height: calc(100vh - var(--header-h)); min-height: 520px; display: grid; grid-template-columns: 340px 1fr; }
.map-panel { overflow: auto; border-right: 1px solid var(--line); background: var(--surface); padding: 22px; display: flex; flex-direction: column; gap: 22px; scrollbar-width: thin; }
.map-panel h1 { font-size: 1.5rem; }
.map-panel h3 { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.map-canvas { position: relative; }
#map { position: absolute; inset: 0; background: #0b0f0d; }
.legend-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.legend-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin: 0 -8px; border-radius: 7px; cursor: pointer; font-size: .9rem; user-select: none; color: var(--ink-2); }
.legend-item:hover { background: var(--surface-2); color: var(--ink); }
.legend-item input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.legend-item .dot { width: 12px; height: 12px; box-shadow: 0 0 0 2px var(--surface); }
.legend-item .count { margin-left: auto; color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.marker-key { display: flex; flex-direction: column; gap: 9px; font-size: .86rem; color: var(--ink-2); }
.marker-key > span { display: flex; align-items: center; gap: 10px; }
.key-solid, .key-ring { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.key-solid { background: var(--ink-2); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-strong); }
.key-ring { border: 3px solid var(--ink-2); background: color-mix(in srgb, var(--ink-2) 20%, transparent); }
.map-count { font-size: .92rem; color: var(--ink-2); padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.map-count strong { color: var(--ink); font-size: 1.05rem; }
.map-panel-toggle { display: none; }
.map-note { font-size: .8rem; color: var(--muted); margin: 0; }

.leaflet-container { font: inherit; background: #0b0f0d; }
/* Dark basemap from standard OSM tiles: invert and re-hue the tile pane only, so marker colours are untouched. */
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) grayscale(.55) brightness(1.45) contrast(.78); }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-lg); border: 1px solid var(--line-strong); }
.leaflet-popup-tip { background: var(--surface); border: 1px solid var(--line-strong); }
.leaflet-popup-content { margin: 16px 18px; width: 290px !important; font-size: .88rem; line-height: 1.5; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); padding: 6px 6px 0 0; }
.leaflet-bar { border: 1px solid var(--line-strong) !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a, .leaflet-bar a:hover { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface-2); }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important; color: var(--muted); font-size: 11px; }
.leaflet-control-attribution a { color: var(--ink-2); }
.popup-kicker { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.popup-title { font: 600 1.02rem/1.3 var(--font-display); margin: 6px 0 8px; color: var(--ink); }
.popup-facts { display: flex; flex-direction: column; gap: 3px; color: var(--ink-2); margin-bottom: 10px; }
.popup-facts div { display: flex; gap: 8px; }
.popup-facts b { color: var(--muted); font-weight: 500; min-width: 44px; }
.popup-actions { display: flex; gap: 6px; }
.popup-actions .btn { color: var(--accent-ink); }

/* Source-given point: solid dot with a surface ring. Town/county estimate: translucent ring. */
.pin { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--cat, var(--cat-context));
  box-shadow: 0 0 0 2px #0b0f0d, 0 0 10px color-mix(in srgb, var(--cat) 60%, transparent); transition: transform .12s; }
.pin-approx { width: 20px; height: 20px; background: color-mix(in srgb, var(--cat) 20%, transparent); border: 2.5px solid var(--cat); box-shadow: none; }
.leaflet-marker-icon:hover .pin, .leaflet-marker-icon:focus .pin { transform: scale(1.3); }
.cluster { display: grid; place-items: center; border-radius: 50%; background: rgba(233, 176, 75, .88); color: var(--accent-ink);
  font: 700 .8rem/1 var(--font-ui); box-shadow: 0 0 0 5px rgba(233, 176, 75, .22), 0 4px 14px rgba(0, 0, 0, .5); }
.radius-circle { stroke: var(--accent); }

/* ------------------------------------------------------------------ footer */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); padding: 40px 0 36px; font-size: .86rem; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px; }
.site-footer h4 { color: var(--ink); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--accent-2); }
.footer-base { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-size: .8rem; }

/* ------------------------------------------------------------------ error */
.error-page { text-align: center; padding: 120px 24px; }
.error-page .code { font: 600 5rem/1 var(--font-display); color: var(--accent); opacity: .9; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1080px) {
  .enc-layout { grid-template-columns: 1fr; }
  .enc-side { position: static; }
  .stats-band { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n+4) { border-top: 1px solid var(--line); }
  .header-search { display: none; }
}
@media (max-width: 860px) {
  .container { padding: 0 16px; }
  .site-header .container { gap: 12px; }
  .nav { position: fixed; left: 0; right: 0; top: var(--header-h); flex-direction: column; padding: 10px 12px 16px;
    background: var(--bg-2); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg); display: none; }
  .nav.is-open { display: flex; }
  .nav a { padding: 12px; }
  .btn.menu-btn { display: inline-flex; margin-left: auto; width: 40px; padding: 0; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .search-layout { grid-template-columns: 1fr; gap: 16px; }
  .filters { position: static; max-height: none; display: none; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
  .filters.is-open { display: flex; }
  .filters-toggle { display: inline-flex; }
  .about-layout { grid-template-columns: 1fr; gap: 16px; }
  .toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .toc a { border-left: 0; border-bottom: 2px solid var(--line); }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .contact-layout, .contact-row { grid-template-columns: 1fr; }
  .consent { flex-direction: column; align-items: stretch; }
  .consent-actions > .btn { flex: 1; }
  .map-view { grid-template-columns: 1fr; }
  .map-panel { position: absolute; z-index: 800; left: 0; right: 0; bottom: 0; max-height: 64%; border-right: 0; border-top: 1px solid var(--line-strong);
    border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); transform: translateY(calc(100% - 60px)); transition: transform .22s ease; }
  .map-panel.is-open { transform: none; }
  .map-panel-toggle { display: flex; width: 100%; }
  .map-canvas .leaflet-bottom { bottom: 60px; }
  .desc-grid { grid-template-columns: 1fr; }
  .facts th { width: 40%; }
}
@media (max-width: 560px) {
  .hero h1 { font-size: 2.35rem; }
  .search-box input { height: 54px; padding-right: 16px; font-size: 1rem; }
  .search-box > .icon { top: 17px; }
  .search-box .btn { display: none; }
  .stats-band { grid-template-columns: repeat(2, 1fr); }
  .stat { border-left: 0 !important; border-top: 1px solid var(--line); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .stat:last-child { grid-column: 1 / -1; border-left: 0 !important; }
  .cat-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .facts th, .facts td { display: block; width: 100%; padding: 0; border: 0; }
  .facts th { padding-top: 12px; border-top: 1px solid var(--line); }
  .facts td { padding: 2px 0 12px; }
  .facts tr:first-child th { border-top: 0; }
  .place-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .dot, .pin, .chart .bar, .legend-item .dot { forced-color-adjust: none; }
}
