/* Asia in Deep Time — stylesheet. Light/dark themes via [data-theme] on <html>. */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 14px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 8px 24px rgba(40, 30, 20, .06);
  --topbar-h: 60px;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f2ea; --surface: #fffdf8; --surface-2: #f0eadf; --hover: #ebe3d5;
  --ink: #1f1b16; --ink-2: #554d43; --ink-3: #857c70; --on-color: #fff;
  --line: #e4dccd; --line-2: #d2c7b4;
  --accent: #b4532a; --accent-2: #93401d; --accent-soft: #f6e1d5;
  --blue: #2f6690; --gold: #d39b2a; --teal: #2f8c80; --gray: #a69d90;
  --sea: #dde7ec; --land: #ede5d6; --land-line: #c9bfae;
  --area: rgba(47, 102, 144, .14);
  --era-0: #6e4426; --era-1: #8f5530; --era-2: #b4532a; --era-3: #c7812e; --era-4: #a9962a;
  --era-5: #6f8f3a; --era-6: #2f8c80; --era-7: #2f6690; --era-8: #5a4f9a; --era-9: #8b3f7a; --era-10: #b0365a;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111316; --surface: #191c20; --surface-2: #22262b; --hover: #2a2f35;
  --ink: #eee8de; --ink-2: #bdb4a7; --ink-3: #8a8277; --on-color: #14110d;
  --line: #2b3036; --line-2: #3b4148;
  --accent: #e5804f; --accent-2: #f19a6c; --accent-soft: #3a2519;
  --blue: #74acd9; --gold: #e8b850; --teal: #5cc2b4; --gray: #6f6a63;
  --sea: #142029; --land: #31363d; --land-line: #4b525b;
  --area: rgba(116, 172, 217, .16);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --era-0: #b07a52; --era-1: #c98a5c; --era-2: #e5804f; --era-3: #eaa552; --era-4: #d6c24f;
  --era-5: #9cc265; --era-6: #5cc2b4; --era-7: #74acd9; --era-8: #9d93e0; --era-9: #d781bf; --era-10: #f07f9c;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 10px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); }
button, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg :focus-visible { outline: none; }
svg g[tabindex]:focus-visible circle.hit, svg g[tabindex]:focus-visible rect.hit { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
[hidden] { display: none !important; }

.wrap { max-width: 1840px; margin: 0 auto; padding: 0 clamp(14px, 2.2vw, 40px); }

/* ---------- slim sticky header ---------- */
:root { --topbar-h: 52px; }
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1840px; margin: 0 auto; height: var(--topbar-h); display: flex; align-items: center; gap: 14px; padding: 0 clamp(14px, 2.2vw, 40px); }
.brand { display: flex; align-items: center; gap: 9px; background: none; border: 0; padding: 0; cursor: pointer; font-family: var(--serif); font-weight: 600; font-size: 17px; white-space: nowrap; }
.brand svg { width: 26px; height: 26px; }
.brand-bg { fill: var(--accent); } .brand-fg { stroke: #fff; stroke-width: 4; fill: none; stroke-linejoin: round; }
.nav { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 0 1 auto; }
.nav::-webkit-scrollbar { display: none; }
.nav button { background: none; border: 0; padding: 6px 10px; border-radius: 999px; color: var(--ink-2); cursor: pointer; white-space: nowrap; font-size: 13.5px; }
.nav button:hover { background: var(--hover); color: var(--ink); }
.sel-chip { margin-left: auto; display: flex; align-items: center; min-width: 0; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); height: 34px; max-width: 420px; }
.chip-main { display: flex; align-items: center; gap: 7px; border: 0; background: none; cursor: pointer; padding: 0 8px; min-width: 0; height: 100%; }
.chip-main strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-main small { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.chip-main:hover strong { color: var(--accent-2); }
.chip-step { border: 0; background: none; width: 30px; height: 100%; cursor: pointer; font-size: 18px; color: var(--ink-2); border-radius: 999px; }
.chip-step:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.chip-step:disabled { opacity: .35; cursor: default; }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; }
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.i-moon { fill: currentColor !important; stroke: none !important; }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }

/* ---------- hero ---------- */
.hero { padding: 30px 0 22px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px 48px; align-items: end; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 11.5px; font-weight: 600; color: var(--accent-2); margin: 0 0 8px; }
.hero h1 { font-size: clamp(32px, 3.6vw, 52px); }
.lede { font-size: 16.5px; color: var(--ink-2); max-width: 78ch; margin: 10px 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.stats div { padding: 12px 16px; border-left: 1px solid var(--line); }
.stats div:first-child { border-left: 0; }
.stats strong { display: block; font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.stats span { color: var(--ink-2); font-size: 12.5px; line-height: 1.35; display: block; margin-top: 2px; }
.caveat { font-size: 13.5px; color: var(--ink-2); margin: 16px 0 0; padding-left: 12px; border-left: 3px solid var(--gold); }

/* ---------- sections: full-width bands ---------- */
.sec { padding: 30px 0 32px; border-bottom: 1px solid var(--line); background: var(--surface); }
.sec-alt { background: var(--bg); }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px 32px; flex-wrap: wrap; margin-bottom: 14px; }
.sec-title { flex: 1 1 420px; min-width: 0; }
.sec-head h2 { font-size: 25px; margin-bottom: 3px; }
.sec-head p { margin: 0; color: var(--ink-2); max-width: 92ch; }
.sec-head > .legend, .sec-head > .chips, .sec-head > .controls, .sec-head > .seg { margin: 0; }
.kbd-hint { color: var(--ink-3); font-size: 12.5px; margin-left: 6px; }
.note { color: var(--ink-2); font-size: 13.5px; margin: 10px 0 0; max-width: 110ch; }
h3.sub { font-size: 20px; margin: 30px 0 2px; }
h3.sub-sm { font-size: 16px; margin: 0 0 10px; font-family: var(--font); font-weight: 600; }

/* ---------- controls ---------- */
.controls, .toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.toolbar { margin: 6px 0 0; justify-content: space-between; align-items: center; }
.btn-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13.5px; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-sm { padding: 4px 11px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .btn-primary { color: #1a0f08; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); }
.win-label { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 160px; text-align: center; }
.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; }
.sec-alt .seg { background: var(--hover); }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); font-weight: 600; }
.seg-scale button { display: flex; flex-direction: column; align-items: center; line-height: 1.15; padding: 6px 14px; }
.seg-scale small { font-size: 10.5px; color: var(--ink-3); font-weight: 400; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.field span { display: flex; align-items: center; gap: 6px; }
.field select { border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px; padding: 7px 10px; font-size: 13.5px; color: var(--ink); max-width: 100%; }
.jump-field { flex-direction: row; align-items: center; gap: 8px; }
.combo { position: relative; }
.combo label { font-size: 12.5px; color: var(--ink-2); }
.combo input { width: min(400px, 44vw); border: 1px solid var(--line-2); background: var(--surface); border-radius: 9px; padding: 7px 10px; font: inherit; font-size: 13.5px; color: var(--ink); }
.combo input::placeholder { color: var(--ink-3); }
.combo-list { position: absolute; z-index: 40; top: calc(100% + 4px); right: 0; width: min(560px, 92vw); max-height: min(420px, 60vh); overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); }
.combo-list li[role="option"] { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
.combo-list li[role="option"]:hover, .combo-list li.act { background: var(--hover); }
.combo-list li.act { outline: 2px solid var(--accent); outline-offset: -2px; }
.jl-name { font-weight: 600; font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jl-when { font-size: 12px; color: var(--ink-2); white-space: nowrap; text-align: right; }
.jl-place { grid-column: 2 / 4; font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jl-none { padding: 10px; font-size: 13px; color: var(--ink-2); }
.tl-filter { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 10px; }
.tl-filter .chips { gap: 5px; }
.tl-filter .chip { padding: 3px 10px; font-size: 12.5px; }
.chip-n { font-size: 11px; opacity: .65; margin-left: 2px; }
.tl-note { font-size: 12.5px; color: var(--ink-3); }
.ins-cat, .ins-cmp { font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-2); }
.ins-cmp { border-color: var(--accent); color: var(--accent-2); }
circle.dot-cmp { fill: var(--surface); stroke: var(--blue); stroke-width: 1.6; }
circle.dot-minor.dot-cmp { stroke: var(--gray); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.readout { margin: 0 0 2px; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 1.5em; }

/* ---------- legends & swatches ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; flex: none; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
span.dot-major { background: var(--blue); } span.dot-minor { background: var(--gray); }
.swatch.sp-0 { background: var(--accent); } .swatch.sp-1 { background: var(--blue); } .swatch.sp-2 { background: var(--teal); } .swatch.sp-3 { background: var(--gray); } .swatch.sp-4 { background: var(--gold); } .swatch.sp-5 { background: var(--era-9); }
.swatch.span-a { background: var(--blue); } .swatch.span-b { background: var(--accent); }
.anc-0 { background: var(--blue); } .anc-1 { background: var(--gold); } .anc-2 { background: var(--accent); } .anc-3 { background: var(--teal); }
.era-bg-0 { background: var(--era-0); } .era-bg-1 { background: var(--era-1); } .era-bg-2 { background: var(--era-2); } .era-bg-3 { background: var(--era-3); } .era-bg-4 { background: var(--era-4); }
.era-bg-5 { background: var(--era-5); } .era-bg-6 { background: var(--era-6); } .era-bg-7 { background: var(--era-7); } .era-bg-8 { background: var(--era-8); } .era-bg-9 { background: var(--era-9); } .era-bg-10 { background: var(--era-10); }

/* ---------- SVG charts ---------- */
.chart { width: 100%; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart text, .mini-map text { font-family: var(--font); font-size: 12px; }
.t-label, .t-secondary { fill: var(--ink-2); }
.t-tertiary { fill: var(--ink-3); }
.t-band { fill: var(--ink-2); font-weight: 500; }
.t-sel { fill: var(--ink); font-weight: 700; }
.t-oncolor { fill: #fff; font-weight: 500; }
[data-theme="dark"] .t-oncolor { fill: #15110d; }
.band-0 { fill: var(--surface-2); stroke: var(--line); }
.band-1 { fill: var(--surface); stroke: var(--line); }
.sec-alt .band-1 { fill: var(--bg); }
.grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.axis { stroke: var(--line-2); stroke-width: 1; }
.tick-line, .stem { stroke: var(--line-2); stroke-width: 1; }
.life-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 4; opacity: .5; }
.sp-0 { fill: var(--accent); } .sp-1 { fill: var(--blue); } .sp-2 { fill: var(--teal); } .sp-3 { fill: var(--gray); } .sp-4 { fill: var(--gold); } .sp-5 { fill: var(--era-9); }
.hit { fill: transparent; }
.ev, .pt, .span-row, .site { cursor: pointer; }
circle.dot-major { fill: var(--blue); } circle.dot-minor { fill: var(--gray); }
circle.dot-sel { fill: var(--gold); stroke: var(--ink); stroke-width: 2; }
.ev:hover circle.dot-major, .ev:hover circle.dot-minor, .pt:hover circle.dot-major { fill: var(--accent); }
.ev:hover text { fill: var(--ink); }
.series { fill: none; stroke: var(--blue); stroke-width: 2.25; stroke-linejoin: round; }
.area { fill: var(--area); }
.span-a { fill: var(--blue); } .span-b { fill: var(--accent); } .span-rest { fill: var(--line-2); }
.span-row:hover .span-rest { fill: var(--ink-3); }
.span-row:hover rect.hit { fill: var(--surface-2); }
.cell-bg { fill: none; stroke: var(--line); }

/* ---------- map ---------- */
.map-grid { display: grid; grid-template-columns: minmax(0, 1100px) minmax(340px, 1fr); gap: 28px; align-items: start; }
.map svg, .mini-map svg { overflow: hidden !important; }
.map svg { border-radius: 10px; border: 1px solid var(--line); }
.map-sea { fill: var(--sea); }
.map-land { fill: var(--land); stroke: var(--land-line); stroke-width: .6; stroke-linejoin: round; }
.map-border { fill: none; stroke: var(--land-line); stroke-dasharray: 2 2; opacity: .8; }
.site-dot { stroke: var(--surface); }
.site-dot.site-cmp { fill: var(--surface); }
span.dot-cmp-k { background: var(--surface); border: 1.6px solid var(--blue); box-sizing: border-box; }
.map-filters-col { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.map-filters-col .reg-chips .chip { padding: 3px 10px; font-size: 12.5px; }
.tl-regs { margin-bottom: 6px; }
.ins-reg { border-style: dashed; }
.anc-panel .anc-legend { margin: 0 0 8px; }
.anc-row.anc-scaled { grid-template-columns: minmax(140px, 34%) minmax(0, 1fr) 44px; }
.anc-total { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.anc-scale-note { margin-top: 6px; font-size: 12px; }
.site:hover .site-dot { stroke: var(--ink); }
.era-0 { fill: var(--era-0); } .era-1 { fill: var(--era-1); } .era-2 { fill: var(--era-2); } .era-3 { fill: var(--era-3); } .era-4 { fill: var(--era-4); }
.era-5 { fill: var(--era-5); } .era-6 { fill: var(--era-6); } .era-7 { fill: var(--era-7); } .era-8 { fill: var(--era-8); } .era-9 { fill: var(--era-9); } .era-10 { fill: var(--era-10); }
.site-ring { fill: none; stroke: var(--ink); }
.t-maplabel { fill: var(--ink); font-weight: 700; paint-order: stroke; stroke: var(--land); stroke-linejoin: round; }
.t-count { fill: var(--ink-2); font-weight: 600; }
.map-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.legend-col { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.side-title { font-family: var(--font); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 4px 0 0; }
.site-list { list-style: none; margin: 0; padding: 0; columns: 260px; column-gap: 0; column-rule: 1px solid var(--line); border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: auto; }
.site-list li { break-inside: avoid; border-bottom: 1px solid var(--line); }
.site-list button { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.site-list button:hover { background: var(--hover); }
.site-list button.is-sel { background: var(--accent-soft); font-weight: 600; }
.sl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-when { color: var(--ink-3); font-size: 12px; white-space: nowrap; }

/* ---------- comparator ---------- */
.cmp-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.facts div { background: var(--surface-2); border-radius: 8px; padding: 9px 12px; }
.facts .fact-ratio { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; }
.facts dt { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.facts dd { margin: 2px 0 0; font-weight: 500; font-size: 14px; }
.big-num { font-family: var(--serif); font-size: 34px !important; font-weight: 600 !important; margin: 0 !important; }
.cells { margin-top: 14px; max-height: 420px; overflow: auto; }

/* ---------- ancestry ---------- */
.anc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 48px; }
.anc { display: flex; flex-direction: column; gap: 7px; }
.anc-row { display: grid; grid-template-columns: minmax(140px, 34%) minmax(0, 1fr); gap: 12px; align-items: center; }
.anc-label { font-size: 13.5px; color: var(--ink-2); }
.anc-bar { display: flex; height: 22px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.anc-bar .part { display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 600; color: #fff; font-variant-numeric: tabular-nums; transition: width .35s ease; }
.anc-bar .anc-1 { color: #2a1d05; }
[data-theme="dark"] .anc-bar .part { color: #15110d; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { background: var(--surface-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
table.data tbody th { font-weight: 600; }
table.data tbody tr:last-child > * { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-col { width: 22%; min-width: 140px; vertical-align: middle !important; }
.inline-bar { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.inline-bar span { display: block; height: 100%; border-radius: 4px; }
.bar-a { background: var(--teal); } .bar-b { background: var(--blue); }
#gen-body tr { cursor: pointer; }
#gen-body tr:hover { background: var(--surface-2); }
#gen-body tr.is-sel { background: var(--accent-soft); }
.sortable { cursor: pointer; }
.sortable:hover { color: var(--ink); }
th[aria-sort="ascending"]::after { content: " ↑"; } th[aria-sort="descending"]::after { content: " ↓"; }
table.eras td:nth-child(n+6) { min-width: 180px; }
table.eras tbody th { position: sticky; left: 0; background: var(--surface); min-width: 150px; }

/* ---------- detail strip (desktop) ---------- */
.detail-slot:empty { display: none; }
.detail-slot { margin-top: 14px; }
.detail { position: relative; background: var(--surface); border: 1px solid var(--line-2); border-top: 3px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 52px 16px 20px; }
.sec:not(.sec-alt) .detail { background: var(--bg); }
@keyframes detail-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sheet-head { display: none; }
.detail-grid { display: grid; grid-template-columns: minmax(220px, 1.05fr) minmax(300px, 1.15fr) minmax(280px, 1.6fr) minmax(170px, 250px); gap: 22px; align-items: start; }
.ins-era { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 7px; margin: 0 0 4px; font-size: 11.5px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.d-id h3 { font-size: 24px; outline: none; }
.ins-when { margin: 4px 0 0; font-weight: 600; color: var(--accent-2); }
.ins-place { margin: 1px 0 0; color: var(--ink-2); font-size: 13.5px; }
.d-nav { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.ins-pos { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.d-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 0; }
.d-stats div { background: var(--surface-2); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.d-stats dt { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.d-stats dd { margin: 1px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; overflow-wrap: anywhere; }
.ins-text { margin: 0 0 10px; font-size: 15px; }
.ins-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini-map { cursor: pointer; }
.mini-map svg { display: block; border-radius: 8px; border: 1px solid var(--line); }
.detail-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; line-height: 1; color: var(--ink-2); }
.detail-close:hover { background: var(--hover); color: var(--ink); }

/* ---------- tooltip ---------- */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; line-height: 1.35; max-width: 280px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); display: flex; flex-direction: column; }
.tip strong { font-size: 13px; }
.tip span { opacity: .85; }
.tip strong + span + strong { margin-top: 5px; }
.tip em { font-style: normal; opacity: .7; font-size: 12px; margin-top: 2px; }

/* ---------- misc ---------- */
.sources-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px 48px; }
.sources-grid h2 { font-size: 20px; }
.sources-grid ul { padding-left: 18px; margin: 8px 0 0; columns: 2; column-gap: 32px; }
.sources-grid li { margin: 0 0 6px; font-size: 13.5px; break-inside: avoid; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10, 8, 6, .45); display: grid; place-items: center; padding: 20px; }
.modal-card { background: var(--surface); border-radius: 14px; padding: 22px 24px; width: min(460px, 100%); box-shadow: var(--shadow); border: 1px solid var(--line); }
.keys { margin: 14px 0 18px; }
.keys div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.keys dd { margin: 0; color: var(--ink-2); text-align: right; }
kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 70; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 20px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
  .detail-grid { grid-template-columns: minmax(200px, 1fr) minmax(280px, 1.1fr) minmax(260px, 1.5fr) 200px; gap: 18px; }
}
@media (max-width: 1280px) {
  .nav button { padding: 6px 7px; font-size: 13px; }
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 190px; }
  .d-text { grid-column: 1 / 3; grid-row: 2; }
  .d-map { grid-column: 3; grid-row: 1 / 3; }
}
@media (max-width: 1100px) {
  .brand span { display: none; }
  .cmp-grid { grid-template-columns: minmax(0, 1fr); }
  .anc-grid { grid-template-columns: minmax(0, 1fr); }
  .sources-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .map-filters-col { align-items: flex-start; max-width: 100%; }
  .map-filters-col .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 4px; scrollbar-width: thin; }
  .map-filters-col .chip { flex: 0 0 auto; }
  .sel-chip { display: none; }
  .top-actions { margin-left: auto; }
  body.has-sheet main { padding-bottom: 96px; }
  .map-grid { grid-template-columns: minmax(0, 1fr); }
  .map-side { position: static; }
  .site-list { max-height: 280px; overflow: auto; columns: auto; }
  .legend-col { grid-template-columns: 1fr 1fr 1fr; }
  /* detail becomes a bottom sheet */
  .detail { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; border-radius: 16px 16px 0 0; border: 1px solid var(--line); border-bottom: 0; border-top: 3px solid var(--accent); padding: 0 14px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); animation: none; background: var(--surface) !important; }
  .detail-close { display: none; }
  .sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 0 6px; position: relative; }
  .sheet-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
  .sheet-grip { position: absolute; top: 5px; left: 50%; width: 38px; height: 4px; border-radius: 4px; background: var(--line-2); transform: translateX(-50%); }
  .sheet-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .sheet-text strong { font-family: var(--serif); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-text small { color: var(--ink-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sheet-chev { transition: transform .2s; color: var(--ink-3); font-size: 16px; }
  .detail.open .sheet-chev { transform: rotate(180deg); }
  .sheet-head .btn { padding: 6px 14px; font-size: 16px; }
  .detail-grid { display: none; }
  .detail.open .detail-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; max-height: 64vh; overflow: auto; padding: 4px 0 6px; }
  .detail.open .d-text, .detail.open .d-map { grid-column: auto; grid-row: auto; }
  .d-nav { display: none; }
  .d-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-map { max-width: 420px; }
  .detail-slot { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .topbar-inner { gap: 6px; }
  .nav button { padding: 6px 7px; font-size: 12.5px; }
  .hero { padding: 20px 0 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div:nth-child(3) { border-left: 0; }
  .stats div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .sec { padding: 22px 0 24px; }
  .sec-head h2 { font-size: 21px; }
  .seg-scale { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .btn-group { justify-content: space-between; }
  .win-label { min-width: 0; flex: 1; }
  .jump-field { flex-direction: column; align-items: stretch; }
  .combo input { width: 100%; }
  .combo-list { left: 0; right: 0; width: auto; }
  .tl-filter .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin: 0 -2px; scrollbar-width: thin; }
  .tl-filter .chip { flex: 0 0 auto; }
  .controls { width: 100%; }
  .controls .field { flex: 1 1 100%; }
  .controls .field select { width: 100%; }
  .anc-row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .legend-col { grid-template-columns: 1fr 1fr; }
  .sources-grid ul { columns: 1; }
}
@media (max-width: 560px) { .hide-sm, .kbd-hint { display: none; } }
@media (hover: none) { .kbd-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print { .topbar, .detail, .toolbar, .controls { display: none !important; } }

/* era table column sizing */
table.eras td:nth-child(2) { min-width: 128px; white-space: normal; }
table.eras td.bar-col { width: 160px; min-width: 120px; vertical-align: middle; }
table.eras td:nth-child(5) { min-width: 120px; }
table.gens td.bar-col { width: 32%; vertical-align: middle; }

/* methods & sources-per-event */
.methods-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 32px; margin-top: 8px; }
.methods-grid .note { margin: 4px 0 0; }
@media (max-width: 1100px) { .methods-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .methods-grid { grid-template-columns: 1fr; } }
#sec-methods .controls select { max-width: 460px; width: 100%; }
#sec-methods .controls .field { min-width: 0; flex: 1 1 320px; }
#sec-methods .controls { flex: 1 1 640px; justify-content: flex-end; }
.ins-src { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 0; }
.ins-src a { color: var(--ink-2); }
.d-stats dd small { font-weight: 400; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.caveat a { white-space: nowrap; }
