/* Startup Atlas — base styles and theme tokens. */
:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --topbar-h: 52px;

  /* dark (default) */
  color-scheme: dark;
  --bg: #070b14;
  --ocean: #080c18;
  --ocean-grid: rgba(120, 150, 220, 0.055);
  --land: #18233f;
  --land-hi: #18233d;
  --border: #2b3a5f;
  --coast: #3d5287;
  --inset-frame: rgba(140, 165, 230, 0.28);
  --label: rgba(190, 205, 240, 0.55);
  --label-halo: rgba(7, 11, 20, 0.85);
  --panel: rgba(13, 19, 34, 0.92);
  --panel-solid: #0d1322;
  --panel-border: rgba(120, 145, 210, 0.18);
  --text: #e6ecfb;
  --text-dim: #93a0c0;
  --accent: #7aa2ff;
  --focus: #9cbcff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #eef1f6;
    --ocean: #e6ebf3;
    --ocean-grid: rgba(40, 70, 130, 0.06);
    --land: #fbfaf6;
    --land-hi: #ffffff;
    --border: #c5ccd9;
    --coast: #9aa7c0;
    --inset-frame: rgba(60, 80, 130, 0.3);
    --label: rgba(50, 65, 100, 0.55);
    --label-halo: rgba(251, 250, 246, 0.9);
    --panel: rgba(255, 255, 255, 0.94);
    --panel-solid: #ffffff;
    --panel-border: rgba(30, 50, 100, 0.14);
    --text: #141b2d;
    --text-dim: #5b6680;
    --accent: #2f5fd0;
    --focus: #2f5fd0;
    --shadow: 0 10px 30px rgba(20, 30, 60, 0.15);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f6;
  --ocean: #e6ebf3;
  --ocean-grid: rgba(40, 70, 130, 0.06);
  --land: #fbfaf6;
  --land-hi: #ffffff;
  --border: #c5ccd9;
  --coast: #9aa7c0;
  --inset-frame: rgba(60, 80, 130, 0.3);
  --label: rgba(50, 65, 100, 0.55);
  --label-halo: rgba(251, 250, 246, 0.9);
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --panel-border: rgba(30, 50, 100, 0.14);
  --text: #141b2d;
  --text-dim: #5b6680;
  --accent: #2f5fd0;
  --focus: #2f5fd0;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.15);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(10px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.02em; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); }
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.tab {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 7px;
  color: var(--text-dim); cursor: pointer; font-weight: 600; font-size: 13px;
}
.tab.is-active { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.topbar-actions { margin-left: auto; display: flex; gap: 6px; }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--panel-border);
  background: var(--panel); cursor: pointer; font-size: 18px; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- map ---------- */
.stage { position: fixed; inset: var(--topbar-h) 0 0 0; }
.map-wrap { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.is-dragging { cursor: grabbing; }
#map.is-pointing { cursor: pointer; }

.map-controls {
  position: absolute; right: 14px; bottom: 34px;
  display: flex; flex-direction: column; gap: 6px;
}
.map-controls .icon-btn { box-shadow: var(--shadow); }
.map-attrib {
  position: absolute; right: 10px; bottom: 8px; font-size: 11px;
  color: var(--text-dim); opacity: 0.8; pointer-events: none;
}

/* ---------- loading ---------- */
.loading {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: var(--bg); transition: opacity 0.4s; z-index: 5;
}
.loading.is-done { opacity: 0; pointer-events: none; }
.loading-mark {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--panel-border); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.loading-text { color: var(--text-dim); }
.loading.is-error .loading-mark { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- shared bits ---------- */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px var(--panel-solid); }
.is-unknown { color: var(--text-dim); font-style: italic; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- tooltip ---------- */
.tooltip {
  position: absolute; left: 0; top: 0; z-index: 10; pointer-events: none;
  min-width: 160px; max-width: 260px; padding: 9px 11px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  backdrop-filter: blur(8px); opacity: 0; transition: opacity 0.12s;
}
.tooltip.is-visible { opacity: 1; }
.tt-name { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.tt-row { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.tt-dim { color: var(--text-dim); }

/* ---------- legend ---------- */
.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 4;
  padding: 8px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.legend-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px 6px; }
.legend-item {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 3px 6px; border: 0; border-radius: 6px; background: transparent;
  cursor: pointer; font-size: 12px; text-align: left; white-space: nowrap;
}
.legend-item:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.legend-item.is-off { opacity: 0.38; }
.legend-item.is-off .swatch { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--text-dim); }
.legend-name { flex: 1; }
.legend-count { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 11px; }

/* ---------- drawer ---------- */
.drawer {
  position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(400px, calc(100vw - 20px));
  z-index: 12; border-radius: 14px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transform: translateX(calc(100% + 20px)); transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
}
.drawer.is-open { transform: none; }
.drawer-close { position: absolute; top: 12px; right: 12px; z-index: 1; }
.drawer-body { height: 100%; overflow-y: auto; padding: 18px 18px 22px; overscroll-behavior: contain; }
.d-head { padding-right: 44px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--chip) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--chip) 40%, transparent);
}
.d-name { margin: 10px 0 2px; font-size: 22px; line-height: 1.2; letter-spacing: -0.01em; }
.d-site { font-size: 13px; }
.d-summary { margin: 14px 0; color: var(--text); font-size: 14px; line-height: 1.55; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin: 0 0 6px; padding: 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--text) 4%, transparent); }
.fact dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); }
.fact dd { margin: 1px 0 0; font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.d-section { margin-top: 18px; }
.d-section:empty { display: none; }
.d-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin: 0 0 8px; }
.d-section p { margin: 0; }
.skeleton { height: 38px; border-radius: 8px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 8%, transparent), transparent);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.people li { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--panel-border); }
.p-name { font-weight: 600; }
.p-role, .p-bg { font-size: 12.5px; color: var(--text-dim); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 6px; bottom: 6px; width: 1px; background: var(--panel-border); }
.ev { display: flex; gap: 10px; padding: 6px 0; position: relative; }
.ev-icon { flex: none; width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-solid); border: 1px solid var(--panel-border); color: var(--text-dim); }
.ev-icon svg { width: 15px; height: 15px; }
.ev-funding .ev-icon { color: #4fbf67; } .ev-acquisition .ev-icon { color: #e3a33b; }
.ev-launch .ev-icon { color: var(--accent); } .ev-hire .ev-icon { color: #b48af0; }
.ev-title { font-size: 13.5px; line-height: 1.35; }
.ev-meta { font-size: 12px; color: var(--text-dim); }
.news-link { display: inline-block; margin-top: 10px; font-size: 13px; font-weight: 600; }
.similar { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sim { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 7px;
  background: transparent; cursor: pointer; text-align: left; }
.sim:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.sim-name { font-weight: 600; flex: 1; }
.sim-meta { font-size: 12px; color: var(--text-dim); }
.d-sources { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--panel-border); font-size: 12px; color: var(--text-dim); }

/* ---------- filter panel ---------- */
:root { --panel-w: 300px; }
.filters {
  position: absolute; top: 10px; left: 10px; bottom: 10px; width: var(--panel-w); z-index: 11;
  display: flex; flex-direction: column; border-radius: 14px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  backdrop-filter: blur(12px); transition: transform 0.25s cubic-bezier(.2,.8,.2,1), opacity 0.2s;
}
body.panel-closed .filters { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.fp-head { padding: 14px 16px 8px; }
.fp-title-row { display: flex; align-items: baseline; justify-content: space-between; }
.fp-title { margin: 0; font-size: 15px; }
.fp-count { color: var(--text-dim); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.btn-link { border: 0; background: none; color: var(--accent); cursor: pointer; font-weight: 600; font-size: 13px; padding: 2px 4px; }
.btn-link:disabled { color: var(--text-dim); opacity: 0.5; cursor: default; }
.fp-search-wrap { position: relative; margin: 2px 12px 8px; }
.fp-search-icon { position: absolute; left: 10px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.fp-search {
  width: 100%; padding: 8px 34px 8px 32px; border-radius: 9px; font: inherit; color: var(--text);
  background: color-mix(in srgb, var(--text) 6%, transparent); border: 1px solid var(--panel-border);
}
.fp-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.fp-search::-webkit-search-cancel-button { filter: grayscale(1); }
.kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 11px var(--mono); color: var(--text-dim);
  border: 1px solid var(--panel-border); border-radius: 4px; padding: 0 5px; }
.fp-search:focus + .kbd { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 12px 8px; }
.fchip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px 3px 9px; border-radius: 99px; cursor: pointer;
  font-size: 12px; font-weight: 600; border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent); max-width: 100%; }
.fchip span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fchip-x { font-size: 15px; line-height: 1; opacity: 0.7; }
.fchip:hover .fchip-x { opacity: 1; }
.fp-sections { flex: 1; overflow-y: auto; padding: 0 12px 16px; overscroll-behavior: contain; border-top: 1px solid var(--panel-border); }
.fp-section { padding: 12px 2px 4px; }
.fp-section h3 { margin: 0 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.fp-domains, .ms-list { list-style: none; margin: 0; padding: 0; }
.check { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.check:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.check input { margin: 0; accent-color: var(--accent); }
.check-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-count { color: var(--text-dim); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { padding: 4px 10px; border-radius: 99px; border: 1px solid var(--panel-border); background: transparent; cursor: pointer; font-size: 12.5px; }
.pill:hover { border-color: var(--accent); }
.pill.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.is-empty { opacity: 0.45; }
.segmented { display: flex; padding: 3px; border-radius: 9px; gap: 2px; background: color-mix(in srgb, var(--text) 6%, transparent); }
.seg { flex: 1; white-space: nowrap; padding: 5px 8px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--text-dim); }
.seg.is-on { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.range-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.range-track { position: relative; height: 22px; }
.range-track::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; border-radius: 3px; background: var(--panel-border); }
.range-fill { position: absolute; top: 10px; height: 3px; border-radius: 3px; background: var(--accent); }
.range-track input { position: absolute; left: 0; top: 0; width: 100%; height: 22px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.range-track input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--panel-solid); border: 2px solid var(--accent); cursor: pointer; }
.range-track input::-moz-range-thumb { pointer-events: auto; width: 13px; height: 13px; border-radius: 50%; background: var(--panel-solid); border: 2px solid var(--accent); cursor: pointer; }
.range-track input::-moz-range-track { background: none; }
.ms summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--panel-border); font-size: 13px; }
.ms summary::-webkit-details-marker { display: none; }
.ms[open] summary { border-color: var(--accent); }
.ms-summary { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--text-dim); }
.ms-pop { margin-top: 6px; border: 1px solid var(--panel-border); border-radius: 8px; padding: 6px; }
.ms-search { width: 100%; padding: 6px 8px; margin-bottom: 4px; border-radius: 6px; border: 1px solid var(--panel-border);
  background: transparent; color: var(--text); font: inherit; font-size: 13px; }
.ms-list { max-height: 220px; overflow-y: auto; }

/* panel toggle in the top bar + legend offset when the panel is open */
.panel-toggle { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 10px; font-size: 13px; font-weight: 600; }
.panel-toggle .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; display: grid; place-items: center; }
.panel-toggle .badge:empty { display: none; }
body:not(.panel-closed) .legend { left: calc(var(--panel-w) + 22px); }
body:not(.panel-closed) .view-switch { left: calc(50% + var(--panel-w) / 2); }

/* ---------- view switcher ---------- */
.view-switch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 5px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow); backdrop-filter: blur(8px);
}
.view-switch .segmented { background: transparent; padding: 0; }
.view-switch select { font: inherit; font-size: 12.5px; color: var(--text); background: transparent; border: 1px solid var(--panel-border); border-radius: 7px; padding: 4px 6px; }
.view-switch label.toggle { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-dim); padding-right: 6px; cursor: pointer; }
.view-switch [hidden] { display: none !important; }

/* sequential legend (hex/states) */
.seq-legend { display: flex; flex-direction: column; gap: 4px; min-width: 210px; }
.seq-title { font-size: 12px; font-weight: 600; }
.seq-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; gap: 2px; }
.seq-bar span { flex: 1; }
.seq-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.empty-state { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 5; padding: 14px 18px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow); text-align: center; }
.empty-state p { margin: 0 0 8px; color: var(--text-dim); }
:root { --cluster-fill: rgba(13, 19, 34, 0.86); }
.legend[hidden] { display: none; }

/* ---------- insights bar ---------- */
.insights {
  position: absolute; right: 64px; bottom: 26px; z-index: 6;
  left: 12px; display: flex; align-items: stretch; gap: 0; max-width: 1180px; margin-left: auto;
  border-radius: 12px; background: var(--panel); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
  backdrop-filter: blur(10px); overflow: hidden;
}
body:not(.panel-closed) .insights { left: calc(var(--panel-w) + 22px); }
.ins-toggle { writing-mode: vertical-rl; transform: rotate(180deg); border: 0; border-left: 1px solid var(--panel-border); cursor: pointer;
  background: color-mix(in srgb, var(--text) 5%, transparent); font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); padding: 8px 5px; }
.ins-body { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.insights.is-collapsed { left: auto !important; }
.insights.is-collapsed .ins-body { display: none; }
.ins-block { padding: 10px 14px; border-right: 1px solid var(--panel-border); min-width: 0; flex: none; }
.ins-block:last-child { border-right: 0; }
.ins-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); margin-bottom: 4px; white-space: nowrap; }
.ins-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.ins-cities ol { margin: 0; padding: 0; list-style: none; font-size: 12px; columns: 2; column-gap: 12px; }
.ins-cities li { display: flex; gap: 6px; justify-content: space-between; break-inside: avoid; }
.ins-num { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ins-link { border: 0; background: none; padding: 0; color: var(--text); cursor: pointer; font-size: 12px; text-align: left; white-space: nowrap; }
.ins-link:hover { color: var(--accent); text-decoration: underline; }
.ins-mix { width: 190px; }
.mix-bar { display: flex; gap: 2px; height: 12px; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.mix-bar span { min-width: 2px; }
.ins-sub { font-size: 11.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ins-hot-name { font-size: 14px; font-weight: 700; }
.spark { display: block; cursor: crosshair; }
body:has(.insights:not(.is-collapsed)) .legend { bottom: 128px; }
body:has(.insights:not(.is-collapsed)) .map-controls { bottom: 128px; }

/* ---------- explorer ---------- */
.explorer {
  position: absolute; top: 0; bottom: 0; left: 0; width: 56%; z-index: 9; display: flex; flex-direction: column;
  background: var(--panel-solid); border-right: 1px solid var(--panel-border);
}
.explorer[hidden] { display: none; }
body.mode-explorer .map-wrap { left: 56%; }
body.mode-explorer .filters, body.mode-explorer .insights, body.mode-explorer .view-switch { display: none; }
body.mode-explorer .legend { left: 12px !important; }
.ex-top { padding: 10px 14px 6px; border-bottom: 1px solid var(--panel-border); }
.ex-summary { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.ex-scatter-wrap { position: relative; }
.ex-scatter { display: block; width: 100%; height: 190px; cursor: crosshair; }
.ex-tip { position: absolute; }
.ex-table { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-x: auto; }
.ex-head, .ex-scroll { min-width: 880px; }
.ex-head { display: grid; border-bottom: 1px solid var(--panel-border); background: var(--panel-solid); }
.ex-th { border: 0; background: none; text-align: left; padding: 8px 10px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); cursor: pointer; white-space: nowrap; }
.ex-th.num, .ex-td.num { text-align: right; justify-content: flex-end; }
.ex-th.is-sorted { color: var(--text); }
.ex-sort { margin-left: 4px; font-size: 9px; }
.ex-scroll { flex: 1; overflow-y: auto; position: relative; }
.ex-spacer { width: 1px; }
.ex-rows { position: absolute; top: 0; left: 0; right: 0; }
.ex-row { display: grid; height: 34px; align-items: center; border-bottom: 1px solid color-mix(in srgb, var(--panel-border) 60%, transparent); cursor: pointer; }
.ex-row:hover, .ex-row:focus-visible { background: color-mix(in srgb, var(--accent) 10%, transparent); outline: none; }
.ex-row.is-selected { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ex-td { padding: 0 10px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 4px; }
.ex-td:first-child { font-weight: 600; }

/* ---------- responsive: tablet / phone ---------- */
@media (max-width: 899px) {
  :root { --panel-w: 100%; }
  .filters {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(72vh, 640px);
    border-radius: 16px 16px 0 0; border-bottom: 0;
  }
  .filters::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 2px; margin: 8px auto 0; background: var(--panel-border); flex: none; }
  body.panel-closed .filters { transform: translateY(105%); }
  body:not(.panel-closed) .legend, body:not(.panel-closed) .insights { left: 12px; }
  body:not(.panel-closed) .view-switch { left: 50%; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(68vh, 620px); border-radius: 16px 16px 0 0;
    transform: translateY(105%); }
  .drawer.is-open { transform: none; }
  .insights { left: 8px; right: 8px; bottom: 8px; max-width: none; }
  .insights.is-collapsed { right: auto; left: 8px !important; }
  .insights.is-collapsed .ins-toggle { writing-mode: horizontal-tb; transform: none; border-left: 0; padding: 7px 12px; }
  .map-controls { bottom: 64px; right: 8px; }
  body:has(.insights:not(.is-collapsed)) .map-controls { bottom: 140px; }
  .legend { bottom: 64px; left: 8px; max-width: calc(100% - 70px); }
  .legend-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-attrib { display: none; }
  .explorer { width: auto; right: 0; bottom: 45%; border-right: 0; border-bottom: 1px solid var(--panel-border); }
  body.mode-explorer .map-wrap { left: 0; top: 55%; }
  .ex-scatter { height: 130px; }
}
@media (max-width: 600px) {
  .topbar { gap: 8px; padding: 0 8px; }
  .brand-name { display: none; }
  .tab { padding: 5px 9px; }
  .panel-toggle-label { display: none; }
  .view-switch { top: 8px; padding: 4px; gap: 4px; max-width: calc(100% - 16px); }
  .view-switch .seg { padding: 5px 8px; font-size: 12px; }
  .view-switch label.toggle { font-size: 0; gap: 0; padding-right: 2px; }
  .view-switch label.toggle input { width: 16px; height: 16px; }
  .legend { display: none; }
  .legend:has(.seq-legend) { display: block; }
  .seq-legend { min-width: 0; }
  .ins-block { padding: 8px 11px; }
  .ins-value { font-size: 17px; }
  .d-name { font-size: 20px; }
  .facts { grid-template-columns: 1fr 1fr; }
}

/* ---------- review fixes ---------- */
:root { --on-accent: #0d1322; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --on-accent: #ffffff; } }
:root[data-theme="light"] { --on-accent: #ffffff; }
.pill.is-on, .panel-toggle .badge { color: var(--on-accent); }
.fact-note { display: block; font-size: 11px; font-weight: 400; color: var(--text-dim); }
#drawer-title:focus { outline: none; }
#drawer-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
/* zoom controls step aside for the drawer */
.map-controls { transition: right 0.28s, bottom 0.28s; }
@media (min-width: 900px) { body:has(.drawer.is-open) .map-controls { right: calc(min(400px, 100vw - 20px) + 24px); } }
.view-switch .short { display: none; }
.legend-toggle { display: none; }
@media (max-width: 899px) {
  body:has(.drawer.is-open) .map-controls { bottom: calc(min(68vh, 620px) + 12px); }
  body:not(.panel-closed) .filters { z-index: 13; }
}
@media (max-width: 600px) {
  .view-switch label.toggle { font-size: 11.5px; gap: 4px; }
  .view-switch .long { display: none; }
  .view-switch .short { display: inline; }
  .legend { display: block; padding: 4px; }
  .legend-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; cursor: pointer; font-size: 12px; font-weight: 600; padding: 4px 6px; }
  .legend-dots { display: inline-flex; gap: 2px; }
  .legend-dots .swatch { width: 7px; height: 7px; box-shadow: none; }
  .legend:not(.is-expanded) .legend-list { display: none; }
  .legend.is-expanded .legend-list { margin-top: 4px; max-height: 40vh; overflow-y: auto; }
}

/* ---------- about dialog ---------- */
.about {
  width: min(640px, calc(100vw - 24px)); max-height: min(86vh, 820px); max-height: min(86dvh, 820px);
  padding: 0; border-radius: 16px; overflow: hidden;
  color: var(--text); background: var(--panel-solid); border: 1px solid var(--panel-border); box-shadow: var(--shadow);
}
.about::backdrop { background: rgba(4, 7, 14, 0.55); backdrop-filter: blur(2px); }
.about[open] { animation: about-in 0.18s cubic-bezier(.2,.8,.2,1); }
@keyframes about-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
@media (prefers-reduced-motion: reduce) { .about[open] { animation: none; } }
.ab-inner {
  position: relative; max-height: inherit; overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 24px 20px;
}
.ab-close { position: absolute; top: 14px; right: 14px; background: transparent; }
.ab-title { margin: 0 44px 8px 0; font-size: 21px; line-height: 1.25; letter-spacing: 0.005em; }
.ab-lead { margin: 0 0 6px; color: var(--text); }
.ab-build { margin: 0 0 4px; font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ab-section { margin-top: 18px; }
.ab-section h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.ab-legend, .ab-sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ab-legend li { display: flex; gap: 10px; align-items: flex-start; }
.ab-sources li { padding-left: 14px; position: relative; color: var(--text-dim); }
.ab-sources li::before { content: ""; position: absolute; left: 2px; top: 0.62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.ab-sources a { font-weight: 600; }
.ab-defs { margin: 0; display: grid; gap: 4px; }
.ab-defs dt { font-weight: 700; }
.ab-defs dd { margin: 0 0 8px; color: var(--text-dim); }

/* little legend glyphs, drawn in CSS to match the canvas */
.ab-ico { flex: none; width: 26px; height: 20px; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.ab-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1.5px var(--panel-solid), 0 0 0 2.5px var(--panel-border); }
.ab-colour i, .ab-size i { display: block; border-radius: 50%; }
.ab-colour i { width: 7px; height: 7px; }
.ab-colour i:nth-child(1) { background: var(--ab-c1, #9887ef); }
.ab-colour i:nth-child(2) { background: var(--ab-c2, #d28e05); }
.ab-colour i:nth-child(3) { background: var(--ab-c3, #338ced); }
.ab-size i { background: var(--accent); }
.ab-size i:nth-child(1) { width: 6px; height: 6px; }
.ab-size i:nth-child(2) { width: 14px; height: 14px; }
.ab-ring::before {
  content: ""; width: 18px; height: 18px; border-radius: 50%;
  background: conic-gradient(var(--ab-c1, #9887ef) 0 45%, var(--ab-c2, #d28e05) 0 75%, var(--ab-c3, #338ced) 0);
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 5.5px); mask: radial-gradient(circle, transparent 5px, #000 5.5px);
}
.ab-hex::before {
  content: ""; width: 18px; height: 20px; background: color-mix(in srgb, var(--accent) 70%, transparent);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.ab-keys { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px 12px; }
.ab-keys > dt, .ab-keys > dd { display: flex; align-items: center; gap: 4px; margin: 0; }
.ab-keys dd { color: var(--text-dim); font-size: 13px; }
.ab-keys kbd {
  min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center;
  font: 600 11.5px var(--mono); color: var(--text);
  border: 1px solid var(--panel-border); border-bottom-width: 2px; border-radius: 5px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.ab-foot { margin-top: 20px; display: flex; justify-content: flex-end; }
.ab-ok {
  border: 0; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-weight: 700;
  background: var(--accent); color: var(--on-accent);
}
.ab-ok:hover { filter: brightness(1.08); }
@media (max-width: 600px) {
  .about { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .ab-inner { padding: 18px 16px 16px; }
  .ab-title { font-size: 19px; }
  .ab-keys { grid-template-columns: auto minmax(0, 1fr); }
  .ab-foot .ab-ok { width: 100%; }
}
.d-geo-note { margin: 0 0 6px; }

/* insights: let the wider blocks give way before anything is clipped */
.ins-mix { width: auto; min-width: 140px; flex: 1 1 160px; }
.ins-cities { flex: 0 1 auto; }
.ins-hot { min-width: 150px; }
