:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --chip: #f1f5f9;
  --accent: #e11d48;
  --accent-ink: #ffffff;
  --shadow: 0 8px 30px rgba(15, 23, 42, .18);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2e; --text: #e5e7eb; --muted: #94a3b8;
    --line: #1f2a44; --chip: #1a2540; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2e; --text: #e5e7eb; --muted: #94a3b8;
  --line: #1f2a44; --chip: #1a2540; --shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
#map { position: fixed; inset: 0; }

.topbar {
  position: fixed; z-index: 3; left: 0; right: 0; top: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(225, 29, 72, .18); }
.search { flex: 1; min-width: 0; }
.search input {
  width: 100%; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 16px;
}
.iconbtn { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; }
.iconbtn.on { color: var(--accent); border-color: var(--accent); }

.chips {
  position: fixed; z-index: 3; left: 0; right: 0; top: calc(58px + env(safe-area-inset-top));
  display: flex; gap: 8px; padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.status {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100% - 120px);
  padding: 8px 14px; border-radius: 999px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); font-size: 14px; text-align: center; pointer-events: none;
}
.status:empty { display: none; }

.fab {
  position: fixed; z-index: 3; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow); display: grid; place-items: center;
}

.sheet {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; max-height: 72vh; overflow-y: auto;
  background: var(--surface); color: var(--text); border-radius: 18px 18px 0 0; box-shadow: var(--shadow);
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .22s ease;
}
.sheet.open { transform: translateY(0); }
@media (min-width: 760px) {
  .sheet { left: 16px; right: auto; bottom: 16px; top: 108px; width: 380px; max-height: none; border-radius: 18px; transform: translateX(-110%); }
  .sheet.open { transform: translateX(0); }
  .grip { display: none; }
}
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-close { position: absolute; right: 10px; top: 8px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); font-size: 26px; }
.sheet h2 { margin: 4px 40px 2px 0; font-size: 19px; }
.sheet .sub { color: var(--muted); margin: 0 0 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--chip); }
.tag.hot { background: rgba(225, 29, 72, .14); color: var(--accent); font-weight: 600; }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.section h3 { margin: 0 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.locked { color: var(--muted); }
.btn { height: 44px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; width: 100%; }
.btn.ghost { background: var(--chip); color: var(--text); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; padding: 8px 0 0; }
.contacts li { padding: 6px 0; border-bottom: 1px solid var(--line); list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.contacts { padding: 0; margin: 0 0 8px; }
.contacts a { color: var(--text); }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(420px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.signin { padding: 20px; display: grid; gap: 12px; }
.signin h2 { margin: 0; }
.signin p { margin: 0; color: var(--muted); }
.signin input { height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
.signin .row { display: flex; gap: 10px; }

.maplibregl-ctrl-attrib { font-size: 11px; }

/* intro card */
.intro {
  position: fixed; z-index: 3; left: 16px; right: 16px; top: calc(104px + env(safe-area-inset-top)); max-width: 380px;
  background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 16px;
}
.intro[hidden] { display: none; }
.intro-title { margin: 0 28px 4px 0; font-weight: 700; font-size: 17px; }
.intro-text { margin: 0 0 12px; color: var(--muted); }
.intro-close { position: absolute; right: 6px; top: 4px; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); font-size: 24px; }

/* legend */
.legend {
  position: fixed; z-index: 3; left: 16px; bottom: calc(40px + env(safe-area-inset-bottom));
  background: var(--surface); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 12px; font-size: 13px; max-width: 220px;
}
.legend summary { cursor: pointer; font-weight: 600; list-style: none; }
.legend summary::-webkit-details-marker { display: none; }
.legend summary::before { content: "◐ "; color: var(--accent); }
.legend ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); flex: none; }
.legend .sq { width: 12px; height: 12px; border-radius: 3px; opacity: .6; flex: none; }
.legend-sub { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

/* footer links */
.foot { position: fixed; z-index: 3; left: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--muted); }
.foot a { color: var(--muted); }

.signin select { height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }

@media (max-width: 520px) {
  .status { bottom: calc(84px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); }
  .legend { bottom: calc(40px + env(safe-area-inset-bottom)); }
}
.foot { background: var(--surface); padding: 3px 10px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.foot a { color: var(--text); text-decoration: none; }
