:root {
  --bg: #ffffff; --ink: #14202e; --mute: #5b6878; --line: #dde2e8;
  --accent: #0b4f8a; --accent-ink: #ffffff; --soft: #e6eff8;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1620; --ink: #e6ecf2; --mute: #97a5b6; --line: #27384b;
    --accent: #5aa6ea; --accent-ink: #0e1620; --soft: #16304a;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1620; --ink: #e6ecf2; --mute: #97a5b6; --line: #27384b;
  --accent: #5aa6ea; --accent-ink: #0e1620; --soft: #16304a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--mute); margin: 0; font-size: 14px; }
button, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .4; cursor: default; }
.icon-btn { font-size: 22px; line-height: 1; padding: 4px 12px; }

.top { position: fixed; top: 0; left: 0; right: 0; z-index: 500; padding: 12px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font-size: 18px; }
.status { margin: 2px 0 0; font-size: 13px; color: var(--mute); }

main#map { position: fixed; top: 64px; bottom: 0; left: 0; right: 0; }

.panel { position: fixed; z-index: 600; background: var(--bg); color: var(--ink); padding: 16px; overflow-y: auto; box-shadow: 0 -4px 16px rgba(0,0,0,.15); left: 0; right: 0; bottom: 0; max-height: 85vh; border-radius: 16px 16px 0 0; }
.panel[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.panel h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.panel select { width: 100%; margin: 12px 0 6px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.grid button.thumb { padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--soft); }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.empty { grid-column: 1 / -1; color: var(--mute); padding: 24px 0; text-align: center; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }

@media (min-width: 720px) {
  .panel { left: auto; top: 64px; bottom: 0; right: 0; width: 440px; max-height: none; border-radius: 0; }
}

.lb { position: fixed; inset: 0; z-index: 900; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lb[hidden] { display: none; }
.lb img { max-width: 100%; max-height: 90vh; object-fit: contain; border-radius: 6px; }
.lb button { position: absolute; background: rgba(255,255,255,.15); color: #fff; border: 0; }
.lb-close { top: 12px; right: 12px; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 28px; padding: 4px 14px; }
.lb-prev { left: 8px; } .lb-next { right: 8px; }

.popup { font-family: var(--font); font-size: 13px; max-width: 220px; }
.popup strong { display: block; margin-bottom: 2px; }
.popup img { width: 100%; border-radius: 6px; margin: 6px 0; display: block; }
.popup button { width: 100%; background: var(--accent); color: var(--accent-ink); border: 0; padding: 8px; }
.popup a { color: var(--accent); }
