:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #5b6573;
  --line: #dde1e6;
  --accent: #1f5fae;
  --accent-ink: #ffffff;
  --ok-bg: #e3f3e8; --ok-ink: #1b6b34;
  --warn-bg: #fff3d6; --warn-ink: #7a5200;
  --bad-bg: #fde7e9; --bad-ink: #9b1c2c;
  --info-bg: #e8f0fb; --info-ink: #1f4f8f;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161b; --surface: #1b2128; --ink: #e8ecf0; --muted: #9aa5b1; --line: #2e3742;
    --accent: #6aa2ea; --accent-ink: #0d1520;
    --ok-bg: #173623; --ok-ink: #8fd8a6; --warn-bg: #3a2d0f; --warn-ink: #f0c66b;
    --bad-bg: #3d1a1f; --bad-ink: #f3a3ad; --info-bg: #162a44; --info-ink: #a9c8f2;
  }
}
:root[data-theme="dark"] {
  --bg: #12161b; --surface: #1b2128; --ink: #e8ecf0; --muted: #9aa5b1; --line: #2e3742;
  --accent: #6aa2ea; --accent-ink: #0d1520;
  --ok-bg: #173623; --ok-ink: #8fd8a6; --warn-bg: #3a2d0f; --warn-ink: #f0c66b;
  --bad-bg: #3d1a1f; --bad-ink: #f3a3ad; --info-bg: #162a44; --info-ink: #a9c8f2;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: var(--accent); }

.topbar {
  display: flex; flex-direction: column; align-items: stretch; gap: 10px; position: relative; z-index: 1100;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 18px; margin: 0; }
.brand .sub { margin: 0; color: var(--muted); font-size: 12.5px; }
.search { display: flex; gap: 6px; width: 100%; max-width: 720px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.search input {
  flex: 1; min-width: 0; padding: 9px 11px; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.search button {
  padding: 9px 16px; font: inherit; font-weight: 600; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.mode { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.mode label { padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13.5px; white-space: nowrap; color: var(--muted); }
.mode label:hover { color: var(--ink); }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode label:has(input:checked) { background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.mode label:has(input:checked)::before { content: "✓ "; }
.mode label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.fullscreen { font-size: 13px; white-space: nowrap; }
.unionpick { position: relative; }
.unionpick summary {
  list-style: none; cursor: pointer; padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); font-size: 13.5px; white-space: nowrap; user-select: none;
}
.unionpick summary::-webkit-details-marker { display: none; }
.unionpick summary::after { content: " ▾"; color: var(--muted); }
.unionpick[open] summary { border-color: var(--accent); }
.unionpick-k { color: var(--muted); }
#unionpick-label { font-weight: 700; }
.unionpick-menu {
  position: absolute; z-index: 5000; top: calc(100% + 4px); left: 0; min-width: 260px; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.unionpick-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.unionpick-actions button { font: inherit; font-size: 12.5px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); cursor: pointer; }
#unionpick-list { max-height: 60vh; overflow: auto; }
.unionpick-h { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 4px 2px; }
.unionpick-cols { columns: 2; column-gap: 8px; }
.unionpick-cols label { break-inside: avoid; font-size: 13px !important; }
.unionpick-menu { min-width: 420px; }
@media (max-width: 520px) { .unionpick-menu { min-width: 0; width: calc(100vw - 40px); } .unionpick-cols { columns: 1; } }
#unionpick-list label { display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 6px; cursor: pointer; font-size: 14px; }
#unionpick-list label:hover { background: var(--bg); }
#unionpick-list input { width: 16px; height: 16px; accent-color: var(--accent); }

#banners .banner { margin: 8px 16px 0; padding: 8px 12px; border-radius: var(--radius); font-size: 13.5px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.bad { background: var(--bad-bg); color: var(--bad-ink); }

.layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(430px, 1fr); gap: 12px; padding: 12px 16px; }
.mapwrap { position: relative; }
#map { height: calc(100vh - 195px); min-height: 460px; border-radius: var(--radius); border: 1px solid var(--line); }
.shade {
  position: absolute; left: 10px; bottom: 10px; z-index: 500; display: flex; align-items: center; gap: 6px;
  background: var(--surface); padding: 6px 8px; border-radius: var(--radius); border: 1px solid var(--line); font-size: 13px;
}
.shade select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; }
.legend { background: var(--surface); color: var(--ink); padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); font-size: 12px; max-height: 40vh; overflow: auto; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; border: 1px solid rgba(0,0,0,.25); }

.panel { max-height: calc(100vh - 195px); overflow: auto; padding-right: 2px; }
.place { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.place h2 { font-size: 16px; margin: 0 0 2px; }
.place p { margin: 0; color: var(--muted); font-size: 13.5px; }
.hint { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }
.match { padding: 6px 0; border-top: 1px dashed var(--line); }
.match:first-of-type { border-top: 0; padding-top: 0; }
.local { font-size: 18px; font-weight: 700; }
.meta { font-size: 13px; color: var(--muted); }
.note { font-size: 13px; margin: 4px 0 0; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: 3px; }
.badge.Confirmed { background: var(--ok-bg); color: var(--ok-ink); }
.badge.Likely, .badge.Approximate { background: var(--warn-bg); color: var(--warn-ink); }
.badge.Unknown { background: var(--bad-bg); color: var(--bad-ink); }
.flag { font-size: 13px; padding: 6px 8px; border-radius: 6px; margin: 6px 0; background: var(--info-bg); color: var(--info-ink); }

.pw { margin-top: 12px; padding-top: 10px; border-top: 2px solid var(--line); }
.pw-title { font-size: 14px; margin: 0 0 2px; }
.pw-title .meta { font-weight: 400; }
.pw .rates { margin-top: 4px; }
.rates { margin-top: 10px; }
.rates h5 { font-size: 13px; margin: 8px 0 4px; }
.trade-title { font-size: 13.5px; margin: 14px 0 2px; padding-top: 8px; border-top: 1px dashed var(--line); }
.pw-title + .trade-title { border-top: 0; padding-top: 0; margin-top: 6px; }
.note.unavailable { color: var(--muted); font-style: italic; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 4px 3px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; }
.tablewrap { overflow-x: auto; }
details { font-size: 13px; margin-top: 6px; }
details summary { cursor: pointer; color: var(--accent); }
details .deftext { white-space: pre-wrap; color: var(--muted); margin: 6px 0 0; }

.disclaimer { font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn-ink); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
.disclaimer p { margin: 0 0 6px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.foot { padding: 6px 16px 14px; font-size: 12px; color: var(--muted); }

/* Narrow frames (e.g. a Squarespace content column): map on top, full-width cards below. */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  #map { height: 48vh; min-height: 320px; }
  .panel { max-height: none; }
}
