:root {
  --bg: #0b1020;
  --panel: rgba(14, 19, 36, 0.86);
  --panel-solid: #121a30;
  --line: rgba(232, 236, 245, 0.14);
  --text: #e8ecf5;
  --muted: #9aa6c2;
  --accent: #ffb547;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
#video, #view { position: fixed; inset: 0; width: 100vw; height: 100dvh; }
#video { object-fit: cover; background: #000; }
#view { touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }

.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + var(--safe-top)) 10px 8px;
  background: linear-gradient(var(--panel), rgba(14, 19, 36, 0));
}
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { background: var(--accent); color: #1a1205; border-color: transparent; }
.icon-btn:focus-visible, .place:focus-visible, .chip:focus-visible, .primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.place {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 2px 6px; cursor: pointer;
  display: flex; flex-direction: column;
}
#place-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#place-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#progress {
  position: fixed; left: 50%; top: calc(64px + var(--safe-top)); transform: translateX(-50%); z-index: 9;
  width: min(320px, calc(100vw - 32px)); padding: 10px 12px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
#progress .track { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
#progress .fill { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

#cam-hud {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 12px;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(rgba(14, 19, 36, 0), var(--panel));
  text-align: center; font-size: 13px; color: var(--muted);
}
#cam-heading { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; font-size: 15px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; white-space: nowrap;
}

#card {
  position: fixed; z-index: 11; left: 50%; transform: translateX(-50%);
  bottom: calc(44px + var(--safe-bottom)); width: min(360px, calc(100vw - 32px));
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
#card .name { font-size: 18px; font-weight: 700; padding-right: 28px; }
#card .facts { color: var(--muted); margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
#card .osm { color: var(--accent); text-decoration: none; font-size: 14px; }
.close {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 10px;
  border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted);
}
.sheet-head .close { position: static; flex: none; }

#toast {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%);
  top: calc(64px + var(--safe-top)); max-width: calc(100vw - 32px);
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14px;
}

.sheet {
  position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column;
  background: var(--panel-solid);
  padding-top: var(--safe-top);
}
.sheet[hidden], #card[hidden], #toast[hidden], #progress[hidden], #cam-hud[hidden], #video[hidden], #search-results[hidden] { display: none; }
.sheet.small { inset: auto 0 0 0; max-height: 80dvh; border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
@media (min-width: 640px) {
  .sheet.small { left: 50%; right: auto; width: 480px; transform: translateX(-50%); }
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { flex: 1; margin: 0 4px; font-size: 17px; }
#search-form { flex: 1; }
#search {
  width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); padding: 0 12px; font: inherit; font-size: 16px;
}
#search-results { max-height: 40dvh; overflow: auto; border-bottom: 1px solid var(--line); }
#search-results button {
  display: block; width: 100%; text-align: left; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: none; cursor: pointer; font-size: 14px;
}
#search-results button:hover { background: rgba(255, 255, 255, .05); }
#search-results small { color: var(--muted); display: block; }
#map { flex: 1; min-height: 0; background: #1a2238; }
.sheet-foot { padding: 10px 12px calc(10px + var(--safe-bottom)); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.presets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.primary {
  height: 46px; border-radius: 12px; border: 0; background: var(--accent); color: #1a1205;
  font-weight: 700; font-size: 16px; cursor: pointer;
}
.primary:disabled { opacity: .45; cursor: default; }
.settings-body { padding: 14px 16px 18px; overflow: auto; }
.settings-body label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.settings-body select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit;
}
.about { color: var(--muted); font-size: 14px; }
.credits { color: var(--muted); font-size: 12px; }
.credits a, .about a { color: var(--text); }
.leaflet-container { font: inherit; }
