:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#map {
  position: fixed;
  inset: 0;
}

#filters {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
  z-index: 10;
}
#filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.chip[aria-pressed="true"] {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.chip .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

#locate-btn {
  position: fixed;
  right: 14px;
  bottom: calc(20px + var(--safe-bottom));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #0ea5e9;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
}
#locate-btn:active { transform: scale(0.96); }
#locate-btn[aria-pressed="true"] { color: #fff; background: #0ea5e9; }

#detail {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--panel);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px 16px calc(16px + var(--safe-bottom));
  max-height: 70vh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 200ms ease-out;
}
#detail[hidden] {
  display: block !important;
  transform: translateY(110%);
  pointer-events: none;
}

#detail-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #f1f5f9;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

#detail-img {
  display: block;
  width: 100%;
  max-height: 40vh;
  object-fit: cover;
  border-radius: 12px;
  background: #f1f5f9;
  margin-bottom: 12px;
  cursor: zoom-in;
}

#detail-body h2 {
  font-size: 18px;
  margin: 6px 0 8px;
  line-height: 1.3;
}
#detail-body p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}
#detail-body p:empty { display: none; }

.debug {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, "Liberation Mono", monospace;
  font-size: 12px !important;
  color: #94a3b8 !important;
  margin-top: -4px !important;
  user-select: text;
  -webkit-user-select: text;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
}

#detail-maps {
  display: inline-block;
  margin-top: 4px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #0ea5e9;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}

#status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 30;
}

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
#lightbox[hidden] { display: none !important; }

#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 200ms ease;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: auto;
}
#lightbox-img.dragging { transition: none; }

#lightbox-close {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: calc(12px + env(safe-area-inset-right, 0px));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#lightbox-hint {
  position: absolute;
  bottom: calc(16px + var(--safe-bottom));
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 300ms ease;
}
#lightbox.zoomed #lightbox-hint { opacity: 0; }

.user-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0ea5e9;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.35);
}
