:root {
  --bg: #f7f7f5; --fg: #1d1d1b; --muted: #6b6b66; --line: #d9d9d4; --accent: #0b5cad; --proj: #b4410c;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg); }
body { display: grid; grid-template-rows: auto 1fr auto; }

header { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
h1 { font-size: 16px; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
legend { float: left; color: var(--muted); margin-right: 6px; }
#search { display: flex; gap: 4px; }
#q { width: 260px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; }
button { padding: 5px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; }
.badge { font-size: 11px; color: var(--muted); }

main { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
#detail { position: absolute; top: 10px; right: 10px; bottom: 10px; width: min(380px, calc(100% - 20px));
  overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; box-shadow: 0 2px 10px #0002; }
#detail-close { position: absolute; top: 6px; right: 6px; border: 0; font-size: 18px; }
#detail h2 { font-size: 15px; margin: 0 24px 6px 0; }
#detail h3 { font-size: 13px; margin: 14px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
#detail ul { list-style: none; padding: 0; margin: 0; }
#detail li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.gap { color: var(--muted); font-style: italic; }
.legend-item { white-space: nowrap; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-left: 6px; }
.legend-swatch.now { background: #08306b; }
.legend-swatch.future { background: #2b8cbe; }
.live { color: var(--proj); font-weight: 600; }

footer { border-top: 1px solid var(--line); padding: 6px 16px; }
#timebar { display: flex; align-items: center; gap: 12px; }
#year { flex: 1; }
#year-label { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; width: 3.2em; }
#mode-badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
#mode-badge.observed { background: #e3eefa; color: var(--accent); }
#mode-badge.projection { background: #fbe9df; color: var(--proj); }
#mode-badge.exploratory, #mode-badge.extrapolated { background: #fde2e2; color: #9b1c1c; white-space: normal; }
#mode-badge.extrapolated { outline: 1px dashed #9b1c1c; }
#attribution { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
#quote { margin: 6px 0 2px; padding: 4px 10px; border-left: 3px solid #9b1c1c; font-size: 13px; }
#quote p { margin: 0; font-style: italic; }
#quote cite { font-size: 11px; color: var(--muted); font-style: normal; }

.maplibregl-popup-content { font-size: 13px; max-width: 340px; }
.popup h4 { margin: 0 0 4px; font-size: 14px; }
.popup .cite { font-size: 11px; color: var(--muted); margin-top: 6px; }
.popup svg { display: block; margin-top: 6px; }

@media (max-width: 700px) {
  #q { width: 100%; }
  #search { flex: 1 1 100%; }
}
