:root {
  --bg: rgba(255, 255, 255, .92);
  --fg: #1a1a1a;
  --accent: #0b5fff;
  --line: rgba(0, 0, 0, .15);
  --strip-h: 76px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: rgba(28, 28, 30, .92); --fg: #f2f2f2; --accent: #6ea3ff; --line: rgba(255, 255, 255, .2); }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.3 system-ui, sans-serif; color: var(--fg); background: #ddd; overflow: hidden; }
#map { position: fixed; inset: 0; bottom: var(--strip-h); }
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2; pointer-events: none;
  padding: max(8px, env(safe-area-inset-top)) 16px 0;
}
header > * { pointer-events: auto; }
h1 {
  display: inline-block; margin: 0 0 6px; padding: 4px 10px; font-size: 1.1rem;
  background: var(--bg); border-radius: 8px;
}
nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav button, #basemap {
  flex: none; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
nav button.on, #basemap[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
nav .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
#basemap { position: fixed; right: 10px; bottom: calc(var(--strip-h) + 34px); z-index: 2; }
footer#strip {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--strip-h); z-index: 2;
  display: flex; gap: 4px; align-items: center; overflow-x: auto;
  padding: 6px 8px max(6px, env(safe-area-inset-bottom)); background: var(--bg);
}
#strip button {
  flex: none; position: relative; height: 100%; aspect-ratio: 1; padding: 0; border: 0;
  border-radius: 4px; overflow: hidden; background: #888; cursor: pointer;
}
#strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
#strip .play { position: absolute; right: 3px; bottom: 1px; color: #fff; font-size: 12px; text-shadow: 0 0 3px #000; }
.maplibregl-popup-content { color: #1a1a1a; font: 13px/1.4 system-ui, sans-serif; padding: 8px 10px; }
.maplibregl-popup-content b { display: block; }
.pswp__caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px; color: #fff; text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, .6)); pointer-events: none; font-size: 15px;
}
.pswp__caption:empty { display: none; }
.pswp-video { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.pswp-video video { max-width: 100%; max-height: 100%; background: #000; }

/* map thumbnails: --thumb is set from the zoom level */
.tm {
  --d: var(--thumb, 28px);
  width: var(--d); height: var(--d); padding: 0; border: 2px solid #fff; border-radius: 4px;
  background: #555; box-shadow: 0 1px 4px rgba(0, 0, 0, .55); cursor: pointer;
  /* no position here: .maplibregl-marker supplies position:absolute (also the anchor for ::after/.count) */
}
.tm img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 2px; pointer-events: none; }
.tm.cluster, .tm.multi { width: calc(var(--d) * 1.15); height: calc(var(--d) * 1.15); }
.tm[data-video]::after {
  content: '▶'; position: absolute; left: 2px; bottom: 0; font-size: max(7px, calc(var(--d) * .22)); color: #fff;
  text-shadow: 0 0 3px #000; pointer-events: none;
}
.tm .count {
  position: absolute; right: -6px; top: -6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #1a1a1a; color: #fff; font: 600 10px/16px system-ui, sans-serif; text-align: center; border: 1px solid #fff;
}
/* gallery: a floating panel so the map stays visible */
#viewer {
  position: fixed; z-index: 5; display: none; overflow: hidden; background: #000; border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  top: 96px; right: 12px; bottom: calc(var(--strip-h) + 12px); width: min(44vw, 600px);
}
#viewer.open { display: block; }
#viewer .pswp { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (max-width: 700px) {
  #viewer { top: auto; left: 8px; right: 8px; width: auto; height: 52vh; bottom: calc(var(--strip-h) + 8px); }
}
