:root {
  --ink: #1d2327;
  --muted: #5d676e;
  --paper: #ffffff;
  --ground: #f4f5f2;
  --line: #d9dcd6;
  --accent: #0b6e69;
  --warn: #9a5b00;
  --stated: #0b6e69;
  --loose: #9a5b00;
  --possible: #6b4fa3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e7eaec;
    --muted: #a3acb2;
    --paper: #1c2125;
    --ground: #14181b;
    --line: #333b40;
    --accent: #5cc6bd;
    --warn: #e0a64a;
    --stated: #5cc6bd;
    --loose: #e0a64a;
    --possible: #b59be6;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; inset: 0; }

#bar { position: absolute; top: calc(8px + env(safe-area-inset-top, 0px)); left: 8px; right: 8px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; }
#bar > * { pointer-events: auto; }
#bar h1 { margin: 0; font-size: 15px; font-weight: 600; background: var(--paper); padding: 6px 10px;
  border-radius: 6px; box-shadow: 0 1px 3px rgb(0 0 0 / .2); max-width: 60vw; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
#toggle-panel { width: 36px; height: 34px; border: 0; border-radius: 6px; background: var(--paper);
  color: var(--ink); font-size: 18px; box-shadow: 0 1px 3px rgb(0 0 0 / .2); cursor: pointer; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--paper);
  border: 1px solid var(--line); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.chip.ok { color: var(--accent); }
.chip.warn { color: var(--warn); }

#panel { position: absolute; top: calc(52px + env(safe-area-inset-top, 0px)); left: 8px; bottom: 32px;
  width: min(340px, calc(100vw - 16px)); background: var(--paper); border-radius: 8px;
  box-shadow: 0 2px 10px rgb(0 0 0 / .2); display: flex; flex-direction: column; overflow: hidden; }
#panel[hidden] { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 9px 4px; color: var(--muted);
  font: inherit; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab { padding: 10px 14px 16px; overflow-y: auto; }
.tab h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  margin: 14px 0 6px; }
.tab h2:first-child { margin-top: 2px; }
.row { display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.plain { list-style: none; margin: 4px 0; padding: 0; }
.plain li { padding: 3px 0; color: var(--muted); font-size: 13px; }
.leg, .item { border-left: 3px solid var(--line); padding: 4px 0 4px 10px; margin: 6px 0; }
.leg.stated { border-color: var(--stated); }
.leg.loose { border-color: var(--loose); }
.leg.possible { border-color: var(--possible); }
.leg .when, .item .meta { color: var(--muted); font-size: 12px; }
.cert { font-size: 11px; padding: 0 6px; border-radius: 999px; border: 1px solid currentColor; margin-left: 4px; }
.cert.stated { color: var(--stated); }
.cert.loose { color: var(--loose); }
.cert.possible { color: var(--possible); }
.src { color: var(--muted); font-size: 12px; }

.maplibregl-popup-content { font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #1d2327; max-width: 280px; }
.probe h3 { margin: 0 0 4px; font-size: 14px; }
.probe .meta { color: #5d676e; font-size: 12px; }
.probe ul { margin: 6px 0; padding-left: 16px; max-height: 160px; overflow-y: auto; }
.probe code { font-size: 12px; }
.probe.place { max-height: 62vh; overflow-y: auto; font-size: 12px; }
.place-type { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.chips.small { margin: 4px 0; gap: 3px; }
.chip-flag { font-size: 10px; padding: 1px 6px; border-radius: 999px; border: 1px solid #0b6e69; color: #0b6e69; }
.chip-flag.act { border-color: #6b4fa3; color: #6b4fa3; }
.place-desc { margin: 6px 0; white-space: pre-line; }
.place-reviews .review { border-top: 1px solid #e3e5e0; padding: 4px 0; }
.place-photos { display: flex; gap: 4px; overflow-x: auto; margin: 6px 0; }
.place-photos img { height: 64px; border-radius: 3px; display: block; }
.opt.lang { font-size: 10px; padding: 1px 7px; }
.hover-tip .maplibregl-popup-content { padding: 6px 9px; font-size: 12px; pointer-events: none; }
.hover-tip-body .meta { color: #5d676e; font-size: 11px; }
.hover-tip-body .hint { font-style: italic; }

@media (max-width: 520px) {
  #panel { top: auto; bottom: 8px; height: 45vh; }
  #bar h1 { max-width: 45vw; }
}

.linkish { border: 0; background: none; padding: 2px 0; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }

/* ---- managed layers, per-layer controls, and the data/query panel ---- */
.card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; background: var(--ground); }
.card h3 { margin: 0 0 4px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.card .meta { color: var(--muted); font-size: 12px; }
.badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); }
.badge.problem { color: #c0392b; border-color: #c0392b; }
.badge.derived { color: var(--warn); border-color: var(--warn); }
.caveat { color: var(--muted); font-size: 11px; border-left: 2px solid var(--line); padding-left: 6px; margin-top: 4px; }
.ctl { display: flex; align-items: center; gap: 6px; margin: 5px 0; font-size: 12px; }
.ctl > label { min-width: 74px; color: var(--muted); }
.ctl select, .ctl input[type=number] { font: inherit; font-size: 12px; padding: 1px 4px; }
.ctl input[type=range] { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.opt { border: 1px solid var(--line); background: var(--paper); color: var(--muted); border-radius: 999px;
  padding: 2px 8px; font: inherit; font-size: 11px; cursor: pointer; }
.opt[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.counts { font-size: 12px; color: var(--muted); margin: 6px 0; }
.counts b { color: var(--ink); }
.hist { display: flex; align-items: flex-end; gap: 1px; height: 54px; margin: 4px 0 2px; }
.hist .bar { flex: 1; background: var(--accent); min-height: 1px; border-radius: 1px 1px 0 0; }
.hist-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.type-list { list-style: none; margin: 4px 0; padding: 0; font-size: 12px; }
.type-list li { display: flex; align-items: center; gap: 6px; padding: 1px 0; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.opt .swatch { margin-right: 4px; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 11px; margin: 2px 0 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.type-group { align-items: flex-start; }
.type-group > label .linkish { text-align: left; }
.query { font: 11px/1.4 ui-monospace, Consolas, monospace; background: var(--ground); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.prov { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 6px 0; font-size: 12px; }
.prov a { color: var(--accent); word-break: break-all; }
.prov .meta { color: var(--muted); font-size: 11px; }
.near { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 4px 6px; align-items: center; font-size: 12px; margin: 6px 0; }
.near input { font: inherit; font-size: 12px; padding: 2px 4px; width: 100%; }
.qs-list { display: flex; flex-direction: column; gap: 3px; margin: 4px 0; }
.qs { text-align: left; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.qs:hover { border-color: var(--accent); }
.qs small { display: block; color: var(--muted); font-size: 11px; }
