/* Camera Atlas by TraceFind — UI styles. Neutral, quiet surfaces; colour is reserved for data. */

@font-face {
  font-family: "Geist";
  src: url(../fonts/geist.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* TraceFind tokens (tracefind.info: css/free-tools.css, blog.css): near-black
   surfaces, white hairlines, the TraceFind red as the only UI accent. */
:root {
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --bg: #ffffff;
  --bg-2: #f4f4f5;
  --bg-3: #e9e9eb;
  --hover: rgba(0, 0, 0, 0.045);
  --line: rgba(0, 0, 0, 0.1);
  --line-2: rgba(0, 0, 0, 0.16);
  --text: #0b0b0b;
  --text-2: #333333;
  --muted: #636363;
  --faint: #8a8a8a;
  --accent: #cf362d;
  --accent-text: #b42d25;
  --accent-soft: rgba(207, 54, 45, 0.09);
  --on-accent: #ffffff;
  --gold: #a87d0d;
  --ok: #17803d;
  --ok-soft: rgba(23, 128, 61, 0.1);
  --bad: #b42318;
  --bad-soft: rgba(180, 35, 24, 0.09);
  --warn: #a15c07;
  --warn-soft: rgba(161, 92, 7, 0.1);
  --live: #e0352b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 8px 24px -6px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 24px 64px -16px rgba(0, 0, 0, 0.3);
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 12px;
  --side-w: 340px;
  --detail-w: 404px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b0b0b;
  --bg-2: #141414;
  --bg-3: #1f1f1f;
  --hover: hsla(0, 0%, 100%, 0.05);
  --line: hsla(0, 0%, 100%, 0.08);
  --line-2: hsla(0, 0%, 100%, 0.14);
  --text: #ededed;
  --text-2: #c9c9c9;
  --muted: #a1a1a1;
  --faint: #7d7d7d;
  --accent: #cf362d;
  --accent-text: #f0786f;
  --accent-soft: rgba(207, 54, 45, 0.16);
  --on-accent: #ffffff;
  --gold: #f5d984;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -8px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 24px 64px -12px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-2);
  -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#map {
  position: fixed; inset: 0; left: var(--side-w); background: var(--bg-2);
  transition: left .22s ease;
}
html.side-collapsed #map { left: 0; }

.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.text-btn { font-size: 12px; font-weight: 500; color: var(--accent-text); padding: 2px 4px; border-radius: 4px; }
.text-btn:hover { background: var(--accent-soft); }

/* ================================================================ side */
/* Fixed column beside the map (not floating over it); collapses to the left. */
.side {
  position: fixed; z-index: 10;
  top: 0; left: 0; bottom: 0;
  width: var(--side-w);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none;
  transition: transform .22s ease, visibility 0s;
}
html.side-collapsed .side { transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }

/* Re-open button: top-left of the map when the sidebar is collapsed. */
.fab {
  position: fixed; z-index: 9; top: var(--gap); left: var(--gap);
  display: none; align-items: center; gap: 8px;
  height: 36px; padding: 0 13px 0 11px; font-weight: 500; color: var(--text-2);
}
.fab:hover { color: var(--text); }
html.side-collapsed .fab { display: inline-flex; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.brand { min-width: 0; color: inherit; text-decoration: none; }
.brand-logo { width: 30px; height: 30px; flex: none; border-radius: 50%; display: block; }
.brand-logo.lg { width: 44px; height: 44px; margin: 0 auto 4px; }
.brand h1 .by { font-weight: 400; font-size: 13px; color: var(--muted); text-decoration: none; margin-left: 2px; }
.brand h1 .by:hover { color: var(--accent-text); }
.brand-mark { width: 26px; height: 26px; color: var(--text); stroke-width: 2.1; }
.brand-mark.lg { width: 34px; height: 34px; }
.side-foot a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.side-foot a:hover { color: var(--text); }
.side-foot a img { width: 14px; height: 14px; border-radius: 50%; }
.tf-cta { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); background: var(--accent); color: var(--on-accent) !important; font-weight: 500; text-decoration: none; }
.tf-cta:hover { background: #e0473d; }

.search { position: relative; margin: 2px 14px 12px; }
.search input {
  width: 100%; height: 36px;
  padding: 0 34px 0 34px;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--bg-2);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; background: var(--bg); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search-ico { position: absolute; left: 10px; top: 9px; color: var(--faint); width: 17px; height: 17px; }
.search kbd {
  position: absolute; right: 8px; top: 8px;
  font: 500 11px var(--mono); color: var(--faint);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; line-height: 18px;
}
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

.search-results {
  position: absolute; z-index: 5; left: 0; right: 0; top: 40px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); max-height: 380px; overflow: auto; padding: 4px;
}
.sr-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px 4px; }
.sr-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  text-align: left; padding: 7px 8px; border-radius: 5px;
}
.sr-item:hover, .sr-item.active { background: var(--hover); }
.sr-item .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sr-item .t { flex: 1; min-width: 0; }
.sr-item .t b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-item .t small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sr-item svg { width: 15px; height: 15px; color: var(--faint); }
.sr-empty { padding: 10px 8px; color: var(--muted); }

.summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.summary > div { padding: 8px 10px; }
.summary > div + div { border-left: 1px solid var(--line); }
.summary b { display: block; font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.summary span { font-size: 12px; color: var(--muted); }
.sum-pos { margin: 6px 16px 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.side-scroll { flex: 1; overflow-y: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.group { padding: 14px 16px 4px; }
.group + .group { border-top: 1px solid var(--line); margin-top: 10px; }
.group h2 {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  margin: 0 0 9px; letter-spacing: 0;
}

/* Collapsible sidebar sections: the heading toggles everything below it. */
.group-toggle {
  display: inline-flex; align-items: center; gap: 4px; margin-left: -4px;
  padding: 2px 4px; border-radius: 4px; font-weight: 600; color: inherit;
}
.group-toggle:hover { background: var(--hover); }
.group-toggle .chev { width: 15px; height: 15px; color: var(--muted); transition: transform .15s; }
.group.collapsed .group-toggle .chev { transform: rotate(-90deg); }
.group.collapsed > :not(h2) { display: none; }
.group.collapsed h2 { margin-bottom: 4px; }

.seg {
  display: flex; padding: 2px; gap: 2px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.seg button {
  flex: 1; height: 28px; border-radius: 5px;
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.select { position: relative; }
.select select {
  width: 100%; height: 34px; padding: 0 32px 0 11px;
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--text); font: 500 13px var(--font); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.select select:hover { background: var(--bg); }
.select select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select svg { position: absolute; right: 9px; top: 8px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }

.check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; color: var(--text-2); cursor: pointer; font-size: 12.5px; }
.check-row input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

.facet { list-style: none; margin: 0 -6px; padding: 0; }
.facet.scroll { max-height: 220px; overflow-y: auto; scrollbar-width: thin; }
.facet li {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 6px; border-radius: 5px; cursor: pointer;
  user-select: none;
}
.facet li:hover { background: var(--hover); }
.facet .box {
  width: 15px; height: 15px; border-radius: 4px; flex: none;
  border: 1.5px solid var(--line-2); display: grid; place-items: center;
  transition: background .1s, border-color .1s;
}
.facet .box svg { width: 11px; height: 11px; stroke-width: 2.6; opacity: 0; color: var(--on-accent); }
.facet li.on .box { background: var(--accent); border-color: var(--accent); }
.facet li.on .box svg { opacity: 1; }
.facet .swatch { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.facet .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.facet .n { font-variant-numeric: tabular-nums; color: var(--faint); font-size: 12px; }
.facet li.zero .name, .facet li.zero .n { color: var(--faint); }
.facet li.zero .swatch { opacity: .35; }
.facet-filter {
  width: 100%; height: 30px; margin-bottom: 6px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2); font-size: 12.5px;
}
.facet-filter:focus { outline: none; border-color: var(--accent); background: var(--bg); }

.toggle-row { display: flex; gap: 11px; align-items: flex-start; cursor: pointer; padding: 2px 0 6px; }
.toggle { position: relative; width: 32px; height: 18px; flex: none; margin-top: 1px; }
.toggle input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.toggle i { position: absolute; inset: 0; border-radius: 99px; background: var(--bg-3); border: 1px solid var(--line-2); transition: background .15s, border-color .15s; }
.toggle i::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.toggle input:checked + i { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + i::after { transform: translateX(14px); }
.toggle input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text b { display: block; font-weight: 500; color: var(--text-2); }
.toggle-text small { color: var(--muted); font-size: 12px; }

.side-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}

/* ================================================================ detail */
.detail {
  position: fixed; z-index: 11;
  /* right-aligned like the map controls and ending above them, so nothing
     moves or overlaps; the body scrolls when the content is taller */
  top: var(--gap); right: var(--gap);
  width: var(--detail-w); max-height: calc(var(--ctl-top, 100vh) - 2 * var(--gap));
  display: flex; flex-direction: column; overflow: hidden;
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { opacity: 0; transform: translateX(10px); } }
.detail-close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  background: rgba(0,0,0,.45); color: #fff; backdrop-filter: blur(6px);
}
.detail-close:hover { background: rgba(0,0,0,.65); color: #fff; }
.detail.no-media .detail-close { background: var(--bg-3); color: var(--text-2); backdrop-filter: none; }
.detail.no-media .detail-close:hover { background: var(--hover); color: var(--text); }
.detail.no-media .detail-body { padding-top: 16px; }
.detail.no-media .d-kicker, .detail.no-media .d-title { padding-right: 40px; }
.detail-body { min-height: 0; }
.d-note { margin: 8px 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.detail-media {
  position: relative; aspect-ratio: 16 / 9; flex: none;
  background: #0b0c0f; overflow: hidden;
  display: grid; place-items: center;
}
.detail-media img, .detail-media video, .detail-media iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border: 0; background: #0b0c0f;
}
.media-state {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: #fff;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  padding: 3px 8px; border-radius: 5px;
}
.media-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.media-time { position: absolute; right: 10px; bottom: 8px; z-index: 2; font: 500 11px var(--mono); color: rgba(255,255,255,.8); text-shadow: 0 1px 2px rgba(0,0,0,.8); }
.media-msg { position: relative; z-index: 1; text-align: center; color: #b4b8c0; padding: 24px; max-width: 300px; }
.media-msg svg { width: 26px; height: 26px; color: #7b808a; margin-bottom: 8px; }
.media-msg p { margin: 0 0 12px; font-size: 12.5px; }
.media-msg a { color: #fff; font-weight: 500; font-size: 12.5px; text-decoration: none; border: 1px solid rgba(255,255,255,.25); padding: 5px 10px; border-radius: 6px; }
.media-msg a:hover { background: rgba(255,255,255,.08); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); border-top-color: rgba(255,255,255,.7); animation: spin .8s linear infinite; position: absolute; }
@keyframes spin { to { transform: rotate(360deg); } }

.detail-body { padding: 14px 16px 16px; overflow-y: auto; scrollbar-width: thin; }
.d-kicker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; padding: 2px 7px; border-radius: 5px;
  background: var(--bg-2); color: var(--text-2); border: 1px solid var(--line);
}
.chip .swatch { width: 7px; height: 7px; border-radius: 50%; }
.d-title { font-size: 16px; font-weight: 650; margin: 2px 0 2px; letter-spacing: -0.01em; line-height: 1.3; }
.d-loc { color: var(--muted); margin-bottom: 12px; }

.status {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 11px; border-radius: var(--radius-sm); margin-bottom: 12px;
  font-size: 12.5px;
}
.status svg { width: 16px; height: 16px; margin-top: 1px; }
.status b { font-weight: 600; display: block; }
.status span { color: var(--muted); }
.status.ok { background: var(--ok-soft); } .status.ok svg, .status.ok b { color: var(--ok); }
.status.bad { background: var(--bad-soft); } .status.bad svg, .status.bad b { color: var(--bad); }
.status.unk { background: var(--bg-2); } .status.unk svg { color: var(--muted); }
.status.warn { background: var(--warn-soft); } .status.warn svg, .status.warn b { color: var(--warn); }

.meta { margin: 0 0 14px; display: grid; grid-template-columns: 96px 1fr; row-gap: 6px; column-gap: 10px; font-size: 12.5px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.meta .mono { font-family: var(--mono); font-size: 12px; }
.meta a { color: var(--accent-text); text-decoration: none; }
.meta a:hover { text-decoration: underline; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--bg);
  font-size: 12.5px; font-weight: 500; color: var(--text-2); text-decoration: none;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--hover); color: var(--text); }
.btn.primary { grid-column: 1 / -1; background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { opacity: .9; }
.btn.wide { grid-column: 1 / -1; }

.nearby { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.nearby h3 { font-size: 12px; font-weight: 600; margin: 0 0 6px; color: var(--text-2); }
.nearby .sr-item { padding: 6px; margin: 0 -6px; width: calc(100% + 12px); }
.nearby .dist { font-variant-numeric: tabular-nums; color: var(--faint); font-size: 12px; }

/* ================================================================ controls */
.controls {
  position: fixed; z-index: 9; right: var(--gap); bottom: calc(var(--gap) + 32px);
  display: flex; flex-direction: column; gap: 8px;
}
.ctl-group { display: flex; flex-direction: column; overflow: visible; }
.ctl { width: 34px; height: 34px; display: grid; place-items: center; color: var(--text-2); }
.ctl:hover { background: var(--hover); color: var(--text); }
.ctl-group .ctl + .ctl { border-top: 1px solid var(--line); }
.ctl-group .ctl:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.ctl-group .ctl:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.ctl-group .ctl:only-child { border-radius: var(--radius); }
.style-wrap { position: relative; }
.settings {
  position: absolute; right: 44px; bottom: 0; width: min(300px, calc(100vw - 80px)); padding: 14px 14px 12px;
  max-height: calc(100vh - 140px); overflow-y: auto; scrollbar-width: thin;
  box-shadow: var(--shadow-lg);
}
.settings h3 {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.settings h3 + * { margin-top: 0; }
.settings .bm-grid + .hint, .settings .bm-grid { margin-bottom: 14px; }
.zoom-now { text-transform: none; letter-spacing: 0; font-weight: 500; }
.zoom-now b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.bm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.bm-grid button {
  display: flex; align-items: center; gap: 8px; padding: 6px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-2);
}
.bm-grid button:hover { background: var(--hover); }
.bm-grid button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; color: var(--text); }
.bm-grid span { display: flex; flex-direction: column; line-height: 1.25; font-weight: 500; }
.bm-grid small { font-size: 12px; color: var(--muted); font-weight: 400; }
.bm { width: 28px; height: 28px; flex: none; border-radius: 5px; border: 1px solid var(--line); }
.bm-fl { background: linear-gradient(135deg, #f2f2f0 0 55%, #dfe3e6 55%); }
.bm-fd { background: linear-gradient(135deg, #2b2d30 0 55%, #3a3d41 55%); }
.bm-l { background: linear-gradient(135deg, #fafaf8 0 40%, #d5e3ee 40% 60%, #ece9e2 60%); }
.bm-d { background: linear-gradient(135deg, #1c1f24 0 40%, #26303c 40% 60%, #2a2c30 60%); }
.bm-s { background: linear-gradient(135deg, #3d5a3a 0 35%, #6b7a54 35% 60%, #2f4a5c 60%); }
.hint { margin: -6px 0 14px; font-size: 12px; color: var(--muted); }
.range-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin: 10px 0 2px; font-size: 12.5px; color: var(--text-2); }
.range-row output { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.range-row input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); margin: 2px 0 0; }
.range-row.off { opacity: .45; pointer-events: none; }
#clReset { margin-top: 10px; }

.legend-wrap { position: relative; }
.legend {
  position: absolute; right: 44px; bottom: 0; width: max-content; max-width: calc(100vw - 80px);
  padding: 12px 14px; font-size: 12px; color: var(--text-2);
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow-lg);
}
.legend h3 {
  margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.legend-row { display: flex; align-items: center; gap: 8px; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: #D9822B; box-shadow: 0 0 0 1.5px var(--bg); }
.lg-dot.dim { background: #8A919C; opacity: .75; width: 7px; height: 7px; margin: 1px; }
.lg-cluster { width: 13px; height: 13px; border-radius: 50%; background: var(--text); opacity: .85; margin: 0 -2px; }
.lg-alpr { width: 9px; height: 9px; background: #C2413B; transform: rotate(45deg); border-radius: 1.5px; }
.lg-cctv { background: #5B6472; width: 7px; height: 7px; margin: 0 1px; }
.lg-speed { background: #D99A00; }

.updating {
  position: fixed; z-index: 9; top: 18px; left: calc(50% + var(--side-w) / 2); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 5px 11px; border-radius: 99px; font-size: 12px; color: var(--muted);
}
.updating i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--line-2); border-top-color: var(--text); animation: spin .7s linear infinite; }

/* MapLibre chrome */
.maplibregl-ctrl-attrib { font-size: 12px; }
.maplibregl-ctrl-bottom-right { right: 0; }
/* Compact attribution: centred under the map controls, styled like them. */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl.maplibregl-ctrl-attrib {
  margin: 0 calc(var(--gap) + 5px) var(--gap) 0;
}
.maplibregl-ctrl-attrib.maplibregl-compact {
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button { background-color: transparent; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib { background: rgba(23,25,30,.7); color: #9aa0aa; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib a { color: #b6bcc6; }
:root[data-theme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-canvas { outline: none; }

.map-tip {
  position: fixed; z-index: 20; pointer-events: none;
  max-width: 280px; padding: 6px 9px; border-radius: 6px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.35;
  opacity: 0; transition: opacity .08s;
}
.map-tip.show { opacity: 1; }
.map-tip small { display: block; color: var(--muted); font-size: 12px; }

/* ================================================================ overlays */
/* Non-blocking: the basemap loads and can be panned underneath. */
.loading {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%);
  padding: 18px 26px; border-radius: var(--radius);
  background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow);
  pointer-events: none; transition: opacity .35s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--muted); }
.loading-card p { margin: 0; font-size: 12.5px; }
.bar { width: 180px; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--text); transition: width .2s; }

.modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 12, 16, .45);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; width: min(720px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 26px 28px; box-shadow: var(--shadow-lg);
}
.modal-close { position: absolute; top: 14px; right: 14px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; font-weight: 650; letter-spacing: -0.015em; }
.modal h3 { margin: 22px 0 8px; font-size: 13px; font-weight: 600; }
.modal p { color: var(--text-2); margin: 0 0 10px; }
.modal .lead { color: var(--muted); }
.modal .fine { color: var(--muted); font-size: 12px; margin-top: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 16px; }
.stat-grid > div { padding: 10px 12px; }
.stat-grid > div + div { border-left: 1px solid var(--line); }
.stat-grid b { display: block; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-grid span { font-size: 12px; color: var(--muted); }
.fail-table { display: flex; flex-wrap: wrap; gap: 6px; }
.source-table { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.src-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 10px 12px; }
.src-row + .src-row { border-top: 1px solid var(--line); }
.src-row b { font-weight: 600; }
.src-row b a { color: inherit; text-decoration: none; }
.src-row b a:hover { text-decoration: underline; }
.src-row p { grid-column: 1; margin: 0; font-size: 12px; color: var(--muted); }
.src-row .n { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 500; }
.src-row .n small { display: block; color: var(--faint); font-weight: 400; font-size: 12px; }

.toast {
  position: fixed; z-index: 60; bottom: 28px; left: 50%; transform: translate(-50%, 8px);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .18s, transform .18s;
  display: flex; align-items: center; gap: 12px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { color: inherit; font-weight: 600; text-decoration: underline; }

.only-mobile { display: none !important; }

/* ================================================================ responsive */
@media (max-width: 1100px) {
  :root { --side-w: 300px; --detail-w: 360px; }
}
@media (max-width: 820px) {
  :root { --gap: 8px; }
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  #map, html.side-collapsed #map { left: 0; }
  .side, html.side-collapsed .side {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: min(78vh, 640px);
    border: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg);
    transform: translateY(102%); visibility: visible;
    transition: transform .25s ease;
  }
  body.side-open .side, html.side-collapsed body.side-open .side { transform: none; }
  .fab, html.side-collapsed .fab {
    top: auto; left: 12px; bottom: calc(26px + env(safe-area-inset-bottom));
    display: inline-flex;
    height: 40px; padding: 0 14px; border-radius: 99px;
  }
  body.side-open .fab, body.has-detail .fab { opacity: 0; pointer-events: none; }
  .updating { left: 50%; }
  .search kbd { display: none; }
  .detail {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 72vh; border-radius: 14px 14px 0 0;
    animation: rise .2s ease-out;
  }
  @keyframes rise { from { transform: translateY(30px); opacity: 0; } }
  body.has-detail .controls, body.side-open .controls { opacity: 0; pointer-events: none; }
  .controls { bottom: 80px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid > div:nth-child(3) { border-left: 0; }
  .stat-grid > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .modal-card { padding: 22px 18px; }
}

/* Centre the loading card over the map, not the whole window. */
@media (min-width: 821px) {
  html:not(.side-collapsed) .loading { left: calc(50% + var(--side-w) / 2); }
}
@media (max-width: 480px) {
  .summary b { font-size: 14px; }
  .summary span { font-size: 12px; }
  .detail { max-height: 80vh; }
  .modal { padding: 10px; }
  .stat-grid b { font-size: 15px; }
}
