:root {
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --line-2: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --hover: #f0efec;
  --c-settlement: #2a78d6;
  --c-hill: #eb6834;
  --c-water: #1baf7a;
  --c-land: #eda100;
  --c-camp: #e87ba4;
  --c-fort: #008300;
  --dot-ring: #0b0b0b;
  color-scheme: light;
  /* naming layers, one hue each (elements.py FAMILIES) */
  --f-preroman: #8a6a2f; --f-celtic: #1a9e6c; --f-greek: #0f9bc0; --f-roman: #c9342c; --f-norse: #6c43c0;
  --f-germanic: #2a78d6; --f-slavic: #dd5c93; --f-arabic: #e09400; --f-medieval: #77766f;
  --f-uralic: #8fa800; --f-baltic: #4f7a3a; --f-semitic: #00897b; --f-iranian: #a23bb5; --f-turkic: #e2571c; --f-modern: #f08a76;
  --f-indoaryan: #d9480f; --f-dravidian: #0b7285; --f-caucasus: #862e9c; --f-sinitic: #c92a2a; --f-tibetoburman: #5f3dc4; --f-tai: #2b8a3e; --f-austroasiatic: #a61e4d; --f-japonic: #1864ab; --f-northasian: #5c940d; --f-mongolic: #e67700; --f-russian: #364fc7; --f-australian: #b35c00;
  --f-ancient: #9a7d0a; --f-nativena: #d35400; --f-mesoam: #1f9d55; --f-andean: #8e44ad; --f-tupi: #16a085; --f-col_es: #c9a000; --f-col_pt: #1e8bc3; --f-col_fr: #e84393; --f-col_en: #5d6d7e; --f-diaspora: #b03a2e;
  --f-romance: #d9776a; --f-egyptian: #2f55c8; --f-berber: #2e9d5b; --f-horn: #00a0a8; --f-westafrican: #c2185b; --f-bantu: #7b5cd6; --f-malagasy: #b89a00; --f-colonial: #00a6d6;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #104281;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1a1a19; --page: #0d0d0d; --raised: #232322;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --line: #2c2c2a; --line-2: #383835; --accent: #3987e5; --hover: #2c2c2a;
    --c-settlement: #3987e5; --c-hill: #d95926; --c-water: #199e70;
    --c-land: #c98500; --c-camp: #d55181; --c-fort: #008300;
    --dot-ring: #0d0d0d;
    color-scheme: dark;
  
    --f-preroman: #b08a45; --f-celtic: #22b07c; --f-greek: #2bb3d6; --f-roman: #e0564d; --f-norse: #9170e0;
  --f-germanic: #3987e5; --f-slavic: #e574a5; --f-arabic: #e0a020; --f-medieval: #9a9992;
  --f-uralic: #a9c21a; --f-baltic: #6f9d55; --f-semitic: #1fb3a3; --f-iranian: #c264d6; --f-turkic: #f0703a; --f-modern: #f5a394;
  --f-indoaryan: #ff922b; --f-dravidian: #3bc9db; --f-caucasus: #da77f2; --f-sinitic: #ff6b6b; --f-tibetoburman: #9775fa; --f-tai: #69db7c; --f-austroasiatic: #f783ac; --f-japonic: #74c0fc; --f-northasian: #c0eb75; --f-mongolic: #ffc078; --f-russian: #91a7ff; --f-australian: #e8a45c;
  --f-ancient: #fff3a0; --f-nativena: #ff8c42; --f-mesoam: #3fc67a; --f-andean: #b57edc; --f-tupi: #2fd0b0; --f-col_es: #e6c229; --f-col_pt: #4aa8e0; --f-col_fr: #ff6fb1; --f-col_en: #aab7c4; --f-diaspora: #ff6b5b;
  --f-romance: #e89384; --f-egyptian: #5b7df0; --f-berber: #3fbf74; --f-horn: #19bcc4; --f-westafrican: #e04a84; --f-bantu: #9a80ee; --f-malagasy: #d4b51a; --f-colonial: #38c6f0;
    --seq-1: #104281; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  --surface: #1a1a19; --page: #0d0d0d; --raised: #232322;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --line: #2c2c2a; --line-2: #383835; --accent: #3987e5; --hover: #2c2c2a;
  --c-settlement: #3987e5; --c-hill: #d95926; --c-water: #199e70;
  --c-land: #c98500; --c-camp: #d55181; --c-fort: #008300;
  --dot-ring: #0d0d0d;
  color-scheme: dark;

  --f-preroman: #b08a45; --f-celtic: #22b07c; --f-greek: #2bb3d6; --f-roman: #e0564d; --f-norse: #9170e0;
  --f-germanic: #3987e5; --f-slavic: #e574a5; --f-arabic: #e0a020; --f-medieval: #9a9992;
  --f-uralic: #a9c21a; --f-baltic: #6f9d55; --f-semitic: #1fb3a3; --f-iranian: #c264d6; --f-turkic: #f0703a; --f-modern: #f5a394;
  --f-indoaryan: #ff922b; --f-dravidian: #3bc9db; --f-caucasus: #da77f2; --f-sinitic: #ff6b6b; --f-tibetoburman: #9775fa; --f-tai: #69db7c; --f-austroasiatic: #f783ac; --f-japonic: #74c0fc; --f-northasian: #c0eb75; --f-mongolic: #ffc078; --f-russian: #91a7ff; --f-australian: #e8a45c;
  --f-ancient: #fff3a0; --f-nativena: #ff8c42; --f-mesoam: #3fc67a; --f-andean: #b57edc; --f-tupi: #2fd0b0; --f-col_es: #e6c229; --f-col_pt: #4aa8e0; --f-col_fr: #ff6fb1; --f-col_en: #aab7c4; --f-diaspora: #ff6b5b;
  --f-romance: #e89384; --f-egyptian: #5b7df0; --f-berber: #3fbf74; --f-horn: #19bcc4; --f-westafrican: #e04a84; --f-bantu: #9a80ee; --f-malagasy: #d4b51a; --f-colonial: #38c6f0;
  --seq-1: #104281; --seq-2: #184f95; --seq-3: #256abf; --seq-4: #3987e5; --seq-5: #6da7ec; --seq-6: #b7d3f6;
  }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }

#app { display: flex; height: 100vh; height: 100dvh; }

#panel {
  width: 380px; flex: none;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 0;
}
#app.collapsed #panel { display: none; }

.brand { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.wordmark { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; border-radius: 6px; }
.wordmark:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.logo { width: 30px; height: 30px; flex: none; }
.brand h1 { font-size: 21px; margin: 0; font-weight: 750; letter-spacing: -0.025em; line-height: 1; }
.brand h1 span { font-weight: 400; color: var(--ink-2); }

.search { display: flex; gap: 6px; padding: 4px 16px 10px; }
.search input { flex: 1; min-width: 0; }
.hint.search-hint { margin: -4px 16px 10px; }
input[type="search"], select {
  border: 1px solid var(--line-2); background: var(--raised);
  border-radius: 8px; padding: 7px 9px; height: 36px;
}
input[type="search"]:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 9px 10px; cursor: pointer;
  color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--hover); color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums;
}

.tab { flex: 1; overflow-y: auto; padding: 12px 16px 16px; min-height: 0; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.field select { color: var(--ink); width: 100%; }
.field-title { font-size: 12px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; margin: 6px 0 6px; }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.muted { color: var(--muted); }
.check { display: block; font-size: 13px; margin: 4px 0 12px; }
.check input { margin: 0 6px 0 0; vertical-align: -2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line-2); background: var(--raised); border-radius: 999px;
  padding: 3px 10px; cursor: pointer; font-size: 12.5px;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 4px; }
.chip[aria-pressed="true"] .n { color: inherit; opacity: 0.7; }
.chip.tier-broad { border-style: dashed; }
.chip.tier-contested { border-style: dotted; }
.tier-preset { font-size: 12.5px; margin-left: 4px; align-self: center; }

.group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.group-head .field-title { margin: 0; }
.group-head .field-title .muted { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 4px; }
.group-actions { display: flex; gap: 6px; }
.group-actions .chip:hover { background: var(--hover); }
#groups-empty { margin: 10px 0 0; color: var(--ink-2); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }

.family-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; padding: 6px; border-top: 1px solid var(--line); }
.family-head label { display: flex; align-items: center; gap: 8px; font-weight: 650; cursor: pointer; flex: 1; }
.family-head input { margin: 0; }
.family-head .muted { font-size: 12px; font-variant-numeric: tabular-nums; }
.family-head .expand { border: 0; background: none; cursor: pointer; color: var(--muted); width: 24px; height: 24px; border-radius: 6px; }
.group-row .swatch { width: 8px; height: 8px; align-self: center; }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px var(--dot-ring); }

.group { border-radius: 8px; }
.group-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; }
.group-row:hover { background: var(--hover); }
.group-row input { margin: 0; }
.group-row label { flex: 1; min-width: 0; cursor: pointer; display: flex; gap: 6px; align-items: baseline; }
.group-row .lbl { font-weight: 600; white-space: nowrap; }
.group-row .mean { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-row .n { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; }
.group-row .expand { border: 0; background: none; cursor: pointer; color: var(--muted); width: 24px; height: 24px; border-radius: 6px; }
.group-row .expand:hover { background: var(--line); }
.group.empty .group-row { opacity: 0.45; }
.variants { padding: 4px 6px 10px 30px; }
.variants .chips { margin-bottom: 8px; }
.variants .more { font-size: 12.5px; }

.results-head { align-items: center; margin-bottom: 8px; }
.results-head select { flex: none; width: auto; }
.result {
  display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 7px 6px; border-bottom: 1px solid var(--line); border-radius: 0;
}
.result:hover { background: var(--hover); }
.result .nm { font-weight: 600; }
.result .nm b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.result .sub { color: var(--muted); font-size: 12px; }
.result .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 1px var(--dot-ring); }
.result .dot.ring { background: transparent !important; box-shadow: inset 0 0 0 2px currentColor; }

table.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; border-bottom: 1px solid var(--line-2); padding: 4px 4px; }
table.stats td { padding: 4px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.stats td.num, table.stats th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--accent); margin-top: 3px; }

.export { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600;
}
.btn.secondary { background: transparent; color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }


.sources { font-size: 11.5px; color: var(--muted); padding: 8px 16px 12px; border-top: 1px solid var(--line); }
.sources a { color: inherit; }

#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--page); }
.leaflet-container { font: inherit; }
.icon-btn { border: 1px solid var(--line-2); background: var(--raised); border-radius: 8px; height: 32px; min-width: 32px; cursor: pointer; }
.icon-btn.floating { position: absolute; top: 12px; left: 56px; z-index: 1000; padding: 0 12px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }

.legend {
  position: absolute; left: 12px; bottom: 24px; z-index: 1000;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.15); max-width: calc(100% - 24px);
}
.legend .item { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.legend .ring { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--ink-2); }
.legend hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.legend-toggle { display: none; font-size: 12px; }

.loading {
  position: absolute; inset: 0; z-index: 2000; display: grid; place-items: center;
  background: color-mix(in srgb, var(--page) 80%, transparent); font-weight: 600;
}
.loading[hidden] { display: none; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content { margin: 12px 14px; min-width: 220px; }
.pop h4 { margin: 0 0 2px; font-size: 15px; }
.pop h4 b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.pop .sub { color: var(--ink-2); font-size: 12.5px; }
.pop .tag { display: inline-block; font-size: 11.5px; border: 1px solid var(--line-2); border-radius: 999px; padding: 0 7px; margin: 6px 4px 0 0; }
.pop .warn { color: var(--ink-2); font-size: 12px; margin-top: 6px; }
.pop .acts { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; }
.pop a, .pop .link { color: var(--accent); }

@media (max-width: 760px) {
  #app { flex-direction: column-reverse; }
  #panel { width: 100%; height: 55%; border-right: 0; border-top: 1px solid var(--line); }
  #map-wrap { flex: 1; min-height: 45%; }
  .brand { padding: 10px 16px 4px; }
  .legend { bottom: 44px; left: 8px; font-size: 11px; padding: 4px 8px; }
  .legend-toggle { display: block; }
  .legend:not(.open) .item, .legend:not(.open) hr { display: none; }
  .sources { display: none; }
  .icon-btn.floating { left: auto; right: 12px; }
  /* phones: pinch to zoom, one-line credit, no search row in the Story, sticky chapter nav */
  .leaflet-control-zoom { display: none; }
  .leaflet-control-attribution { font-size: 9.5px; max-width: 100vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #app[data-tab="story"] .search, #app[data-tab="pairs"] .search,
  #app[data-tab="story"] .search-all, #app[data-tab="pairs"] .search-all { display: none; }
  .story-nav { position: sticky; bottom: -16px; background: var(--surface); padding: 8px 0 10px; margin: 0; border-top: 1px solid var(--line); }
  .story h2 { font-size: 20px; }
}

.segmented { display: flex; border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 12px; background: var(--page); }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 7px; padding: 6px 8px; cursor: pointer; font-weight: 600; }
.segmented button .muted { font-weight: 400; font-size: 11.5px; }
.segmented button[aria-pressed="true"] { background: var(--raised); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.view-switch { display: flex; gap: 4px; margin-bottom: 6px; }
.view-switch .chip { padding: 2px 10px; font-size: 12px; }
.legend .cell { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.legend select { height: 26px; padding: 2px 6px; font-size: 12px; margin-left: 4px; }
.legend .cell.hot1 { background: transparent; box-shadow: inset 0 0 0 1.2px var(--ink); }
.legend .cell.hot2 { background: transparent; box-shadow: inset 0 0 0 2.5px var(--ink); }
.legend input[type="checkbox"] { margin: 0 4px 0 0; }

/* story */
.story h2 { font-size: 22px; margin: 2px 0 8px; letter-spacing: -0.01em; }
.story-steps { display: flex; gap: 6px; margin: 2px 0 8px; }
.story-steps .step { flex: 1; height: 4px; border: 0; border-radius: 2px; background: var(--line-2); cursor: pointer; padding: 0; }
.story-steps .step[aria-current="true"] { background: var(--accent); }
.story-count { font-size: 12px; }
.story-body { font-size: 14.5px; line-height: 1.55; }
.story-body p { margin: 0 0 10px; }
.story-body ul { padding-left: 18px; margin: 0 0 10px; }
.story-body li { margin-bottom: 6px; }
.story-evidence { background: var(--hover); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.story-evidence .ev-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.story-evidence .ev-line b { font-size: 17px; font-variant-numeric: tabular-nums; }
.story-evidence .ev-line > span:first-child { width: 96px; flex: none; }
.story-evidence .ev-yes { color: var(--accent); font-weight: 600; }
.story-evidence .stats { margin-top: 8px; }
.story-evidence .hint { margin-bottom: 0; }
.story-nav { justify-content: space-between; margin: 4px 0 6px; }

.legend .ramp { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin: 4px 0 2px; }
.legend .ramp span { height: 10px; border-radius: 2px; }
.legend .ramp-labels { display: grid; grid-template-columns: repeat(4, 1fr); font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.legend .item.muted { max-width: 230px; }

/* word pairs */
.pairs { display: flex; flex-direction: column; gap: 6px; }
.pair { display: block; width: 100%; text-align: left; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; cursor: pointer; }
.pair:hover { background: var(--hover); }
.pair.open { border-color: var(--accent); cursor: default; }
.pair-title { font-weight: 650; font-size: 15px; }
.pair-sides { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 2px; }
.pair-side { display: grid; grid-template-columns: 12px 1fr auto; column-gap: 7px; align-items: baseline; font-size: 13px; }
.pair-side .swatch { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.pair-side .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.pair-side .pair-top { grid-column: 2 / 4; font-size: 12px; }
.pair .hint { display: block; margin: 6px 0 0; }

.legend .shade-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }

/* compare two states: first state grey, second blue, same scale */
.stats.cmp .bar.a { background: var(--ink-2); }
.stats.cmp .bar.b { background: var(--accent); opacity: 0.75; margin-top: 2px; }
.cmp .swatch { display: inline-block; vertical-align: middle; }
.cmp .key { display: inline-block; width: 10px; height: 6px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.cmp .key.a { background: var(--ink-2); } .cmp .key.b { background: var(--accent); opacity: 0.75; }

/* pronunciations in the place popup (voices.js) */
.voices { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12.5px; }
.voices-title { font-weight: 650; margin-bottom: 4px; }
.voice { margin: 4px 0 6px; }
.voices audio { width: 100%; height: 32px; }
.voices .field { display: block; margin: 6px 0; font-size: 12px; }
.voices .field input { width: 100%; height: 30px; border: 1px solid var(--line-2); background: var(--raised); border-radius: 6px; padding: 4px 7px; }
.voices .check { font-size: 12px; margin: 6px 0; }
.voices .btn { padding: 5px 10px; font-size: 12.5px; }
.rec-btn { margin-top: 6px; }
.rec-live { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #d63b3b; animation: rec-pulse 1s infinite; }
@keyframes rec-pulse { 50% { opacity: 0.3; } }
.rec-done { color: var(--ink); margin-top: 6px; }

/* invitation to record pronunciations (voices.js) */
.voice-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; max-width: min(520px, calc(100% - 140px));
  display: flex; align-items: center; gap: 8px; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 7px 8px 7px 12px; font-size: 13px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
.voice-hint[hidden] { display: none; }
.voice-hint .icon-btn { flex: none; width: 26px; height: 26px; font-size: 16px; }
@media (max-width: 760px) { .voice-hint { top: 8px; left: 8px; transform: none; max-width: calc(100% - 70px); font-size: 12px; } }

/* "All places" search switch (search.js) */
.check.search-all { margin: -4px 16px 8px; font-size: 12.5px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* native-script name and ISO 15919 form with a recording */
.voice-name { margin-bottom: 2px; }
.voice-name .native { font-size: 15px; }
.voice-name .iso { font-style: italic; color: var(--ink-2); }

/* while a popup is open it has the map to itself */
#map-wrap.popup-open .legend, #map-wrap.popup-open .voice-hint { visibility: hidden; }

/* local-script names (local.js) */
.local-name { margin: 6px 0 2px; }
.local-name .native { font-size: 17px; }
.local-name .iso { font-style: italic; color: var(--ink-2); margin-left: 4px; }
.legend .ramp-labels.five, .legend .ramp:has(+ .ramp-labels.five) { grid-template-columns: repeat(5, 1fr); }
.spell .form { white-space: nowrap; margin-right: 8px; }

/* script check verdict in popups (local.js) */
.verdict { font-size: 12px; margin-top: 4px; padding: 3px 7px; border-radius: 6px; display: inline-block; }
.verdict.v1 { background: color-mix(in srgb, var(--f-dravidian) 18%, transparent); }
.verdict.v-1 { background: color-mix(in srgb, var(--f-indo-aryan) 22%, transparent); }
.verdict.v0 { background: var(--hover); color: var(--ink-2); }
.check.story-script { font-size: 12.5px; margin: 8px 0 2px; }

/* timeline: the year slider over the map */
.timeline { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; width: min(520px, calc(100% - 150px));
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; box-shadow: 0 2px 10px rgb(0 0 0 / 0.18); }
.timeline .icon-btn { width: 30px; height: 30px; grid-row: 1 / 3; }
.timeline input[type=range] { width: 100%; accent-color: var(--accent); }
#tl-label { grid-column: 2; font-weight: 650; font-size: 13.5px; }
#tl-now { grid-column: 1 / 3; font-size: 12px; min-height: 15px; }
.family-head .era { font-weight: 400; font-size: 11.5px; }
#map-wrap.popup-open .timeline { visibility: hidden; }
@media (max-width: 760px) { .timeline { left: 8px; transform: none; width: calc(100% - 70px); } #tl-now { display: none; } }

/* many layers: the legend scrolls instead of covering the map */
.legend { max-height: min(46vh, 420px); overflow-y: auto; }

/* migration routes (routes.js) */
.route-head { background: none; border: 0; }
.route-head svg { width: 14px; height: 14px; display: block; }
.route-tip { max-width: 260px; white-space: normal; font-size: 12.5px; line-height: 1.35; }

/* stories (tales.js) */
.tale-star { background: none; border: 0; cursor: pointer; }
.tale-star svg { width: 18px; height: 18px; display: block; filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.5)); }
.pop.tale p { margin: 6px 0 0; font-size: 13.5px; line-height: 1.5; }
.tales { display: flex; flex-direction: column; gap: 4px; }
.tale-item { display: grid; grid-template-columns: 68px 1fr; gap: 8px; text-align: left; background: var(--raised); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; color: inherit; font: inherit; font-size: 13.5px; }
.tale-item:hover { background: var(--hover); }
.tale-when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tale-item .swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.story-tales { margin: 10px 0 2px; }
.tale-link { display: block; text-align: left; margin: 3px 0; font-size: 13.5px; }

/* ancient places overlay (ancient.js) */
.legend .diamond { display: inline-block; width: 9px; height: 9px; transform: rotate(45deg); margin: 0 7px 0 3px; border: 1px solid var(--dot-ring); }

.tale-item.open { border-color: var(--accent); }
.tabs button { padding-left: 8px; padding-right: 8px; }
