:root {
  --bg: #ffffff; --fg: #1c2024; --muted: #60646c; --line: #d9d9e0; --panel: rgba(255, 255, 255, .96);
  --accent: #3b6fe0; --ok: #1f9d55; --warn: #d9822b; --bad: #d23b3b; --replay: #6b57d6;
  --shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --fg: #e8e8ea; --muted: #9a9ca3; --line: #2e3136; --panel: rgba(24, 26, 30, .96);
    --accent: #7ea2ff; --ok: #3ccf7e; --warn: #f0a04b; --bad: #ff6b6b; --replay: #a08cff;
    --shadow: 0 2px 12px rgba(0, 0, 0, .55);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0; }

#bar {
  position: fixed; z-index: 1000; top: 12px; left: 56px; right: 12px; max-width: 760px;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
}
#bar h1 { margin: 0; font-size: 15px; font-weight: 650; white-space: nowrap; }
#clock { color: var(--muted); font-size: 12.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#toggle { display: none; }
.pill { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; color: #fff; }
.pill-live { background: var(--ok); } .pill-replay { background: var(--replay); }
.pill-off { background: var(--bad); } .pill-wait { background: var(--muted); } .pill-done { background: var(--accent); }

#panel {
  position: fixed; z-index: 1000; top: 64px; right: 12px; width: 300px; max-height: calc(100% - 140px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px 14px 10px;
}
#panel section { padding: 10px 0; border-bottom: 1px solid var(--line); }
#panel section:last-child { border-bottom: 0; }
#panel h2 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.about p { margin: 0 0 6px; font-size: 12px; color: var(--muted); }

.layer { margin-bottom: 10px; }
.layer label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.layer .count { margin-left: auto; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid rgba(0, 0, 0, .25); }
.swatch.line { height: 3px; border-radius: 2px; border: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 12px; padding: 2px 9px; cursor: pointer;
  color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 99px;
}
.chip[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.chip:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

select, input[type="search"] {
  width: 100%; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
#zoomAll {
  margin-top: 10px; width: 100%; font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; cursor: pointer;
}
#zoomAll:hover { border-color: var(--accent); }
#results { list-style: none; margin: 6px 0 0; padding: 0; }
#results li button {
  display: flex; width: 100%; gap: 8px; text-align: left; font: inherit; color: var(--fg); background: transparent;
  border: 0; border-radius: 4px; padding: 4px 6px; cursor: pointer;
}
#results li button:hover { background: var(--line); }
#results .muted { color: var(--muted); margin-left: auto; }

#banner {
  position: fixed; z-index: 1001; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100% - 24px);
  background: var(--bad); color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow);
}

.popup table { border-collapse: collapse; }
.popup th { text-align: left; font-weight: 500; color: #60646c; padding: 1px 12px 1px 0; white-space: nowrap; vertical-align: top; }
.popup td { padding: 1px 0; font-variant-numeric: tabular-nums; }
.popup .ttl { font-weight: 700; margin-bottom: 4px; }

@media (max-width: 700px) {
  #bar { left: 12px; right: 12px; top: 8px; }
  #bar h1 { font-size: 14px; }
  #toggle { display: inline-block; font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 3px 9px; }
  #panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 55%; border-radius: 12px 12px 0 0; }
  #panel[hidden] { display: none; }
  #banner { bottom: auto; top: 64px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
