:root {
  --ink: #efe4c6;
  --ink-dim: #b3a684;
  --ink-faint: #7f765f;
  --gold: #c9a45c;
  --gold-bright: #ecd08e;
  --panel: rgba(14, 21, 30, 0.97);
  --panel-2: rgba(26, 37, 51, 0.97);
  --line: rgba(201, 164, 92, 0.5);
  --line-soft: rgba(201, 164, 92, 0.18);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, "Segoe UI", system-ui, sans-serif;
  --topbar-h: 42px;
  --food: #8bc34a; --production: #e0884a; --gold-y: #f2c94c; --science: #5ab0f0;
  --culture: #c58af0; --faith: #f3efe0; --health: #ef6f7a; --infra: #9fb4c8;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b2238; color: var(--ink); font: 13px/1.4 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--gold-bright); }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.num { font-variant-numeric: tabular-nums; }
.serif { font-family: var(--serif); }

#map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 8px 24px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,235,190,.07);
  border-radius: 6px;
}
.icon-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; padding: 0; background: rgba(0,0,0,.3); border: 1px solid rgba(201,164,92,.45); border-radius: 50%; color: var(--ink-dim); }
.icon-btn:hover { color: var(--gold-bright); border-color: var(--gold); }
.btn { white-space: nowrap; background: rgba(0,0,0,.25); border: 1px solid rgba(201,164,92,.45); border-radius: 4px; padding: 4px 12px; color: var(--ink); font-family: var(--serif); letter-spacing: .06em; }
.btn:hover, .btn[aria-pressed="true"] { border-color: var(--gold-bright); color: var(--gold-bright); background: rgba(201,164,92,.12); }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: linear-gradient(180deg, #22344a, #111a25);
  border-bottom: 1px solid var(--gold);
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.brand { display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; font-family: var(--serif); font-weight: bold; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-bright); font-size: 15px; }
.brand-flag { display: block; width: 33px; height: 22px; border-radius: 2px; flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(236,208,142,.55), 0 1px 4px rgba(0,0,0,.6); }
.yields { display: flex; flex-wrap: wrap; gap: 0 10px; height: 26px; min-width: 0; overflow: hidden; flex: 0 1 auto; } /* whole items drop out, never half an icon */
.brand, .mode-switch, .tb-buttons { flex-shrink: 0; }
.tb-buttons { display: flex; gap: 6px; }
.search { flex: 0 1 230px; min-width: 120px; }
.search input { width: 100% !important; }
.yield { display: flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; white-space: nowrap; background: none; border: 1px solid transparent; border-radius: 4px; padding: 2px 4px; font-variant-numeric: tabular-nums; }
.yield:hover { border-color: var(--line); background: rgba(0,0,0,.25); }
.yield .yi { font-size: 14px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.7)); }
.spacer { flex: 1; }
.mode-switch { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.mode-switch button { white-space: nowrap; background: rgba(0,0,0,.25); border: 0; padding: 4px 12px; font-family: var(--serif); letter-spacing: .08em; text-transform: uppercase; font-size: 11px; color: var(--ink-dim); }
.mode-switch button[aria-selected="true"] { background: linear-gradient(180deg, #6e5527, #3e2f14); color: var(--gold-bright); }
.search { position: relative; display: flex; align-items: center; }
.search input { width: 230px; background: rgba(0,0,0,.35); border: 1px solid rgba(201,164,92,.4); border-radius: 4px; color: var(--ink); padding: 4px 26px 4px 8px; font: inherit; }
.search input:focus { outline: none; border-color: var(--gold-bright); }
.search kbd { position: absolute; right: 6px; font-size: 10px; color: var(--ink-faint); border: 1px solid var(--ink-faint); border-radius: 3px; padding: 0 4px; }
.tb-buttons { display: flex; gap: 6px; }
.search-results { position: fixed; top: calc(var(--topbar-h) + 4px); right: 250px; width: 320px; max-height: 60vh; overflow: auto; z-index: 30; padding: 4px; }
.search-results button { display: flex; width: 100%; gap: 8px; align-items: baseline; text-align: left; background: none; border: 0; padding: 5px 8px; border-radius: 4px; }
.search-results button:hover, .search-results button.active { background: rgba(201,164,92,.15); }
.search-results .kind { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); }

/* ---------- side panel ---------- */
.side { position: fixed; top: calc(var(--topbar-h) + 10px); right: 10px; width: 380px; max-height: calc(100vh - var(--topbar-h) - 20px); overflow: auto; z-index: 15; padding: 0; }
.side header { position: sticky; top: 0; z-index: 1; padding: 12px 14px 10px; background: linear-gradient(180deg, #2a3c52, #182433); border-bottom: 1px solid var(--line); }
.side h2 { margin: 0; font: bold 19px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-bright); }
.side .sub { color: var(--ink-dim); font-size: 12px; margin-top: 2px; }
.side .close { position: absolute; top: 10px; right: 10px; }
.side section { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.side h3 { margin: 0 0 6px; font: 600 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.kv .k { color: var(--ink-dim); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }
.kv .v small { color: var(--ink-faint); font-size: 10px; }
.src { font-size: 10px; color: var(--ink-faint); margin-top: 6px; }
.src a { color: var(--ink-dim); }
.yield-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.yield-cell { background: rgba(0,0,0,.25); border: 1px solid var(--line-soft); border-radius: 4px; padding: 5px 6px; text-align: center; }
.yield-cell .yv { font: bold 16px var(--serif); }
.yield-cell .yl { font-size: 10px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .06em; }
.pips { letter-spacing: -1px; }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.jobs { display: grid; gap: 4px; }
.jobs .row { display: grid; grid-template-columns: 120px 1fr 48px; gap: 8px; align-items: center; font-size: 12px; }
.chip { display: inline-block; padding: 1px 7px; border: 1px solid var(--line); border-radius: 10px; font-size: 11px; margin: 0 4px 4px 0; color: var(--ink); background: rgba(0,0,0,.2); }
.chip.spec { border-color: var(--gold-bright); color: var(--gold-bright); }
.linkish { background: none; border: 0; padding: 0; color: var(--gold-bright); text-decoration: underline dotted; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 3px 0; border-bottom: 1px dotted var(--line-soft); display: flex; gap: 6px; align-items: baseline; }
.list-plain li:last-child { border: 0; }

/* ---------- tooltip ---------- */
.tooltip { position: fixed; z-index: 40; pointer-events: none; max-width: 300px; padding: 7px 9px; font-size: 12px; background: rgba(12,18,26,.96); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.5); }
.tooltip b { color: var(--gold-bright); font-family: var(--serif); letter-spacing: .04em; }
.tooltip .tl { color: var(--ink-dim); }

/* ---------- lenses ---------- */
#lens-area { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 15; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lens-dock { display: flex; align-items: center; gap: 4px; padding: 4px; max-width: calc(100vw - 110px); overflow-x: auto; scrollbar-width: none; }
.lens-btn { display: flex; align-items: center; gap: 5px; background: rgba(0,0,0,.25); border: 1px solid transparent; border-radius: 4px; padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.lens-btn:hover { border-color: var(--line); }
.lens-btn[aria-pressed="true"] { border-color: var(--gold-bright); background: rgba(201,164,92,.18); color: var(--gold-bright); }
.lens-btn .e { font-size: 14px; }
.lens-picker { width: min(860px, 94vw); max-height: 56vh; overflow: auto; padding: 10px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 14px; }
.lens-picker h4 { grid-column: 1 / -1; margin: 8px 0 2px; font: 600 10px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--line-soft); padding-bottom: 3px; }
.lens-picker button { text-align: left; background: none; border: 1px solid transparent; border-radius: 4px; padding: 3px 6px; display: flex; gap: 6px; align-items: baseline; }
.lens-picker button:hover { border-color: var(--line); }
.lens-picker button[aria-pressed="true"] { color: var(--gold-bright); border-color: var(--gold); }
.lens-picker .kindtag { margin-left: auto; font-size: 9px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.legend { position: fixed; left: 12px; bottom: 66px; z-index: 15; padding: 10px 12px; width: 300px; max-height: calc(100vh - var(--topbar-h) - 90px); overflow: auto; }
.legend .lt2 { display: flex; gap: 6px; align-items: center; margin-top: 3px; font-size: 11px; }
.legend .dir { font-size: 11px; color: var(--gold); margin-top: 4px; }
.legend details { margin-top: 6px; font-size: 11px; color: var(--ink-dim); }
.legend summary { cursor: pointer; color: var(--ink-dim); list-style: none; }
.legend summary::before { content: "▸ "; } .legend details[open] summary::before { content: "▾ "; }
.legend summary:hover { color: var(--gold-bright); }
.legend details p { margin: 6px 0 0; line-height: 1.45; }
.legend .lt { display: flex; gap: 8px; align-items: baseline; }
.legend .lt b { font-family: var(--serif); letter-spacing: .06em; color: var(--gold-bright); }
.legend .ramp { height: 10px; border-radius: 2px; margin: 6px 0 2px; }
.legend .ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.legend .desc { font-size: 11px; color: var(--ink-dim); margin-top: 4px; }
.legend .cats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; margin-top: 8px; font-size: 11px; }
.legend .cats .wide { grid-column: 1 / -1; }
.legend .cats i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.kind-badge { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; padding: 0 5px; border-radius: 3px; border: 1px solid; }
.kind-official { color: #9fd49a; border-color: #4f7f4a; }
.kind-modelled { color: #f0c27a; border-color: #8a6a30; }
.kind-satellite { color: #8fc8f0; border-color: #3f6f90; }
.kind-historical { color: #d6a8f0; border-color: #6f4a8a; }
.kind-curated { color: #d8d0b8; border-color: #6f6a58; }

/* ---------- timeline ---------- */
.timeline { position: fixed; left: 50%; bottom: 62px; transform: translateX(-50%); z-index: 16; width: min(1100px, 96vw); padding: 8px 12px 10px; }
.timeline .eras { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 2px; }
.timeline .era { flex: 1 0 auto; min-width: 74px; background: rgba(0,0,0,.25); border: 1px solid var(--line-soft); border-radius: 4px; padding: 4px 6px; text-align: left; font-size: 11px; }
.timeline .era b { display: block; font-family: var(--serif); letter-spacing: .04em; font-size: 12px; }
.timeline .era span { color: var(--ink-faint); font-size: 10px; }
.timeline .era[aria-pressed="true"] { border-color: var(--gold-bright); background: rgba(201,164,92,.16); color: var(--gold-bright); }
.timeline .note { font-size: 11px; color: var(--ink-dim); margin-top: 6px; }

.zoom-ctl { position: fixed; right: 10px; bottom: 12px; z-index: 14; display: flex; flex-direction: column; }
.zoom-ctl button { width: 30px; height: 28px; background: none; border: 0; font-size: 16px; color: var(--ink-dim); }
.zoom-ctl button:hover { color: var(--gold-bright); }
.zoom-ctl button + button { border-top: 1px solid var(--line-soft); }
.scale-note { position: fixed; left: 12px; bottom: 14px; z-index: 14; font-size: 11px; color: rgba(239,228,198,.75); text-shadow: 0 1px 2px #000; pointer-events: none; }

/* ---------- modal (Explorer, Advisors, Almanac) ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(4,8,12,.55); display: grid; place-items: center; }
.modal-card { position: relative; width: min(1180px, 96vw); height: min(820px, 92vh); display: flex; flex-direction: column; overflow: hidden; }
.modal-card .close { position: absolute; top: 10px; right: 10px; z-index: 2; }
#modal-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mhead { padding: 12px 16px 10px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #2a3c52, #182433); }
.mhead h2 { margin: 0; font: bold 20px var(--serif); letter-spacing: .12em; text-transform: uppercase; color: var(--gold-bright); }
.mhead .sub { color: var(--ink-dim); font-size: 12px; }
.mbody { flex: 1; min-height: 0; display: flex; }
.mnav { width: 220px; flex: none; overflow: auto; border-right: 1px solid var(--line-soft); padding: 8px; }
.mnav button { display: block; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 4px; padding: 5px 8px; }
.mnav button:hover { border-color: var(--line-soft); }
.mnav button[aria-current="true"] { border-color: var(--gold); color: var(--gold-bright); background: rgba(201,164,92,.1); }
.mnav h4 { margin: 10px 8px 4px; font: 600 10px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.mmain { flex: 1; min-width: 0; overflow: auto; padding: 14px 18px; }
.mmain h3 { font: bold 16px var(--serif); letter-spacing: .06em; color: var(--gold-bright); margin: 4px 0 8px; }
.mmain h4 { font: 600 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); margin: 16px 0 6px; }
.mmain p { max-width: 78ch; }
table.data { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 4px 8px; border-bottom: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child, table.data td.l, table.data th.l { text-align: left; }
table.data th { position: sticky; top: 0; background: #1b2838; color: var(--gold); font-weight: 600; cursor: pointer; user-select: none; }
table.data tr:hover td { background: rgba(201,164,92,.08); }
table.data tr.sel td { background: rgba(201,164,92,.18); }
table.data td.null { color: var(--ink-faint); }
.ex-controls { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line-soft); }
.ex-controls label { display: flex; gap: 6px; align-items: center; color: var(--ink-dim); font-size: 12px; }
select, .ex-controls input { background: #0f1822; color: var(--ink); border: 1px solid rgba(201,164,92,.4); border-radius: 4px; padding: 3px 6px; font: inherit; max-width: 300px; }
.ex-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0; flex: 1; min-height: 0; }
.ex-grid > div { min-height: 0; overflow: auto; padding: 10px 14px; }
.ex-grid > div + div { border-left: 1px solid var(--line-soft); }
.chart { width: 100%; }
.chart text { fill: var(--ink-dim); font: 10px var(--sans); }
.chart .axis line, .chart .axis path { stroke: rgba(239,228,198,.25); }
.chart .dot { cursor: pointer; }
.chart .dot:hover { stroke: #fff; stroke-width: 1.5; }
.chart .dot.sel { stroke: var(--gold-bright); stroke-width: 2.5; }
.stat { display: inline-block; margin-right: 16px; }
.stat b { font: bold 16px var(--serif); color: var(--gold-bright); }
.advisors { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.advisor { border: 1px solid var(--line-soft); border-radius: 6px; padding: 10px 12px; background: rgba(0,0,0,.18); }
.advisor header { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.advisor .face { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; border: 1px solid var(--gold); background: radial-gradient(circle at 35% 30%, #3b5270, #142030); flex: none; }
.advisor h3 { margin: 0; font: bold 14px var(--serif); letter-spacing: .08em; text-transform: uppercase; color: var(--gold-bright); }
.advisor .role { font-size: 11px; color: var(--ink-dim); }
.insight { padding: 6px 0; border-top: 1px dotted var(--line-soft); font-size: 12.5px; }
.insight .ev { font-size: 10.5px; color: var(--ink-faint); margin-top: 2px; }
.insight button { font-size: 10.5px; }
.pedia-src { border: 1px solid var(--line-soft); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; background: rgba(0,0,0,.15); }
.pedia-src .t { font-weight: 600; }
.pedia-src .m { font-size: 11px; color: var(--ink-dim); }

.toast { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); z-index: 60; padding: 6px 14px; background: rgba(12,18,26,.96); border: 1px solid var(--gold); border-radius: 4px; }
#loading { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 12px; background: #0b1520; font: 16px var(--serif); letter-spacing: .12em; color: var(--gold-bright); }
#loading .ld-flag { border-radius: 3px; box-shadow: 0 0 0 1px rgba(236,208,142,.5), 0 6px 24px rgba(0,0,0,.6); animation: pulse 1.6s ease-in-out infinite alternate; }
@keyframes pulse { from { opacity: .55; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
  .lens-btn[data-lens]:not([aria-pressed="true"]) .lbl { display: none; } /* icons only; the title gives the name */
}
@media (max-width: 900px) {
  .yields .yield:nth-child(n+5) { display: none; }
  .search input { width: 140px; }
  .side { width: auto; left: 8px; right: 8px; top: auto; bottom: 64px; max-height: 50vh; }
  .ex-grid { grid-template-columns: 1fr; }
  .mnav { width: 150px; }
}
@media (max-width: 640px) {
  .legend { width: auto; right: 12px; bottom: 60px; }
  body:has(#panel:not([hidden])) .legend { display: none; }
  .yields, .brand-text, .search kbd { display: none; }
  #topbar { gap: 5px; padding: 0 6px; }
  .search { flex: 1 1 60px; min-width: 0; }
  .search input { width: 100%; padding-right: 6px; }
  .tb-buttons { display: flex; gap: 3px; }
  .tb-buttons .btn { padding: 3px 5px; font-size: 11px; letter-spacing: 0; }
  .mode-switch button { padding: 3px 5px; font-size: 9px; letter-spacing: 0; }
  .spacer { display: none; }
}

/* ---------- explorer drawer ---------- */
.explorer { position: fixed; top: calc(var(--topbar-h) + 8px); left: 8px; bottom: 8px; width: min(1060px, 64vw); z-index: 18; display: flex; flex-direction: column; overflow: hidden; }
.ex-head { display: flex; align-items: baseline; gap: 12px; padding: 10px 44px 8px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #2a3c52, #182433); position: relative; }
.ex-head h2 { margin: 0; font: bold 18px var(--serif); letter-spacing: .12em; text-transform: uppercase; color: var(--gold-bright); }
.ex-head .close { position: absolute; right: 10px; top: 8px; }
.ex-stats { padding: 6px 16px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.ex-table { font-size: 12px; }
.explorer .ex-grid { grid-template-columns: minmax(0, 1fr) minmax(300px, 440px); }
.explorer table.data td:first-child { white-space: normal; min-width: 110px; }
.explorer table.data td.l.muted { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .explorer { width: auto; right: 8px; } }

/* ---------- hidden strengths drawer ---------- */
.drawer-left { position: fixed; top: calc(var(--topbar-h) + 8px); left: 8px; bottom: 8px; width: 400px; z-index: 18; overflow: auto; padding: 0; }
.drawer-left header { position: sticky; top: 0; z-index: 1; padding: 12px 14px 10px; background: linear-gradient(180deg, #2a3c52, #182433); border-bottom: 1px solid var(--line); }
.drawer-left h2 { margin: 0; font: bold 19px var(--serif); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-bright); }
.drawer-left .sub { color: var(--ink-dim); font-size: 12px; margin-top: 2px; }
.drawer-left .close { position: absolute; top: 10px; right: 10px; }
.drawer-left section { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.drawer-left h3 { margin: 0 0 6px; font: 600 11px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.hs-tabs { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.hs-tabs button { background: rgba(0,0,0,.25); border: 1px solid var(--line-soft); border-radius: 12px; padding: 3px 9px; font-size: 11px; white-space: nowrap; }
.hs-tabs button:hover { border-color: var(--line); }
.hs-tabs button[aria-pressed="true"] { border-color: var(--gold-bright); color: var(--gold-bright); background: rgba(201,164,92,.15); }
.hs-q { margin: 0 0 10px; font: 15px/1.4 var(--serif); color: var(--ink); }
.hs-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.hs-actions .btn { font-size: 12px; }
.hs-list { list-style: none; margin: 0; padding: 0; }
.hs-row { display: grid; grid-template-columns: 20px 1fr auto; grid-template-rows: auto auto; gap: 0 8px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 4px; padding: 5px 6px; align-items: baseline; }
.hs-row:hover { border-color: var(--line); background: rgba(201,164,92,.08); }
.hs-rank { grid-row: 1 / 3; color: var(--ink-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.hs-name { font-weight: 600; }
.hs-vals { grid-column: 2; font-size: 12px; font-variant-numeric: tabular-nums; }
.hs-z { grid-column: 3; grid-row: 1 / 3; align-self: center; font: 600 12px var(--sans); padding: 2px 7px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.hs-z.up { color: #9fe0a8; background: rgba(60,140,80,.22); }
.hs-z.down { color: #f0a59a; background: rgba(170,70,60,.22); }
.hs-more { margin-top: 8px; } .hs-more summary { cursor: pointer; color: var(--ink-dim); font-size: 12px; }
.hs-method p { font-size: 12px; line-height: 1.5; margin: 0 0 8px; }
.hs-conds { display: grid; gap: 4px; margin: 4px 0 10px; }
.hs-conds div { display: grid; grid-template-columns: 150px 1fr 12px; gap: 8px; align-items: center; font-size: 11px; color: var(--ink-dim); }
.hs-conds i { display: block; height: 6px; border-radius: 3px; }
.hs-conds i.pos { background: var(--gold); } .hs-conds i.neg { background: #7d93ad; }
/* keep the legend and the lens dock clear of the left drawers */
body:has(#strengths:not([hidden])) #lens-area { left: calc(50% + 208px); }
body:has(#strengths:not([hidden])) .lens-dock { max-width: calc(100vw - 540px); }
body:has(#strengths:not([hidden])) .legend { left: 420px; }
@media (max-width: 900px) { .drawer-left { width: auto; right: 8px; top: auto; height: 55vh; } body:has(#strengths:not([hidden])) .legend { display: none; } }
.hs-note { border-left: 2px solid var(--gold); padding-left: 8px; color: var(--ink); }

/* ---------- history: compare and overlay ---------- */
.era-pop { position: fixed; z-index: 30; width: 320px; max-height: 60vh; overflow: auto; padding: 10px; display: grid; gap: 3px; }
.era-pop h4 { margin: 0 0 4px; font: 600 10px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.era-pop button { display: flex; justify-content: space-between; gap: 8px; text-align: left; background: none; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; font-size: 12px; }
.era-pop button span { color: var(--ink-faint); font-size: 11px; white-space: nowrap; }
.era-pop button:hover:not(:disabled) { border-color: var(--line); }
.era-pop button[aria-pressed="true"] { border-color: var(--gold-bright); color: var(--gold-bright); }
.era-pop p { margin: 6px 0 0; font-size: 11px; }
.era-note { position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 16; padding: 8px 40px 8px 12px; font-size: 12px; line-height: 1.5; max-width: min(560px, 90vw); }
.era-note b { color: var(--gold-bright); font-family: var(--serif); }
.era-note .close { position: absolute; top: 7px; right: 8px; width: 22px; height: 22px; }
body:has(#timeline:not([hidden])) .legend { display: none; } /* history mode has its own key in the timeline */

/* ---------- time-series lenses ---------- */
.legend .time { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.legend .time input[type=range] { flex: 1; accent-color: var(--gold); }
.legend .time .icon-btn { width: 24px; height: 24px; font-size: 10px; }
.legend .yr-l { font: bold 16px var(--serif); color: var(--gold-bright); min-width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.legend .yr-ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-faint); padding: 0 66px 0 32px; }
.legend .yr-note { font-size: 10.5px; color: var(--ink-dim); margin-top: 4px; border-left: 2px solid var(--line); padding-left: 6px; }
.legend .spark { width: 100%; height: 34px; margin-top: 6px; }
.legend .spark polyline { fill: none; stroke: var(--gold); stroke-width: 1.5; }
.legend .spark circle { fill: var(--gold-bright); stroke: #1a1208; }
.legend .spark-l { font-size: 10.5px; }

/* ---------- history: compare two eras ---------- */
.timeline .tl-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.timeline .cmp-btn { font-size: 12px; padding: 3px 10px; }
.timeline .cmp-btn[aria-pressed="true"] { border-color: #bcd8ff; color: #bcd8ff; background: rgba(110,170,255,.12); }
.timeline .tl-hint { font-size: 11.5px; color: var(--ink-dim); }
.timeline .tl-hint b { color: var(--gold-bright); }
.timeline.picking { box-shadow: 0 0 0 1px #bcd8ff, 0 8px 24px rgba(0,0,0,.45); }
.timeline.picking .era:not([aria-disabled]):hover { border-color: #bcd8ff; background: rgba(110,170,255,.14); }
.timeline .era[aria-disabled="true"] { opacity: .35; cursor: not-allowed; }
.timeline .era { position: relative; }
.timeline .era.role-b { border-color: #bcd8ff; background: rgba(110,170,255,.14); color: #dbe9ff; }
.badge { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font: bold 10px var(--sans); font-style: normal; border: 1.5px solid; }
.badge.a { color: #f2c46a; border-color: #f2c46a; } .badge.b { color: #bcd8ff; border-color: #bcd8ff; }
.timeline .era .badge { width: 14px; height: 14px; font-size: 9px; vertical-align: 1px; }
.cmp-card { position: fixed; top: calc(var(--topbar-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 17; width: min(600px, 94vw); padding: 8px 12px 6px; font-size: 12px; }
.cc-head { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start; padding-right: 28px; }
.cc-col .cc-name { display: flex; align-items: center; gap: 6px; }
.cc-col b { font: bold 14px var(--serif); letter-spacing: .03em; color: var(--ink); }
.cc-col .faint { font-size: 11px; margin-top: 2px; }
#cc-swap { align-self: center; }
.cc-close { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; }
.sw { display: inline-block; width: 16px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.sw.a { background: rgba(212,162,74,.55); border: 1.5px dashed #d4a24a; }
.sw.b { background: rgba(110,170,255,.35); border: 1.5px solid #bcd8ff; }
.sw.ab { background: linear-gradient(135deg, rgba(212,162,74,.75), rgba(110,170,255,.6)); border: 1.5px solid #e6dcc4; }
.cc-t { width: 100%; border-collapse: collapse; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.cc-t th { text-align: left; font-weight: 500; color: var(--ink-dim); width: 34%; padding: 2px 0; }
.cc-t td { padding: 2px 8px 2px 0; width: 33%; }
.cc-t td span[title] { border-bottom: 1px dotted var(--ink-faint); cursor: help; }
.cc-t tr + tr { border-top: 1px solid var(--line-soft); }
.cc-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: rgba(0,0,0,.3); margin-top: 4px; }
.cc-bar span { min-width: 0; }
.cc-bar .a { background: #b8893c; } .cc-bar .ab { background: linear-gradient(90deg, #c9a46a, #9fb8d8); } .cc-bar .b { background: #6c9bd6; }
.cc-legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 5px; font-size: 11px; color: var(--ink-dim); }
.cc-legend .sw { margin-right: 5px; }
.cc-sum { margin: 6px 0 2px; font-size: 12.5px; }
.cc-foot { margin: 2px 0 0; font-size: 10.5px; }
@media (max-width: 640px) { .cc-head { grid-template-columns: 1fr; } #cc-swap { justify-self: start; } .cc-t th { width: 40%; } }
