*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0e14;
  color: #d4dae3;
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#map {
  position: absolute;
  inset: 0;
  background: #0a0e14;
}

/* Topbar */
#topbar {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  gap: 8px;
  padding: 8px;
  background: linear-gradient(to bottom, rgba(10,14,20,0.92), rgba(10,14,20,0.6) 80%, transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

#mapSelect {
  flex: 1;
  min-width: 0;
  background: rgba(20, 26, 36, 0.92);
  color: #d4dae3;
  border: 1px solid #2a3142;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  backdrop-filter: blur(8px);
}

#layerToggle {
  display: flex;
  background: rgba(20, 26, 36, 0.92);
  border: 1px solid #2a3142;
  border-radius: 10px;
  overflow: hidden;
  backdrop-filter: blur(8px);
}
#layerToggle button {
  background: transparent;
  border: 0;
  color: #8a96ab;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#layerToggle button.active {
  background: #2d5cf6;
  color: white;
}

#filtersBtn {
  background: rgba(20, 26, 36, 0.92);
  color: #d4dae3;
  border: 1px solid #2a3142;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

/* Filters panel */
#filtersPanel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  z-index: 1100;
  background: rgba(15, 20, 28, 0.97);
  backdrop-filter: blur(12px);
  border-left: 1px solid #2a3142;
  padding: env(safe-area-inset-top, 12px) 0 env(safe-area-inset-bottom, 12px);
  overflow-y: auto;
  transform: translateX(0);
  transition: transform .2s ease;
}
#filtersPanel[hidden] {
  display: block;
  transform: translateX(100%);
  pointer-events: none;
}
#filtersPanel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #2a3142;
  position: sticky;
  top: 0;
  background: rgba(15, 20, 28, 0.97);
}
#closeFilters {
  background: transparent;
  border: 0;
  color: #d4dae3;
  font-size: 28px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
}

#categoryList {
  padding: 8px 0;
}
.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
}
.cat-row:active { background: rgba(255,255,255,0.04); }
.cat-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-name {
  flex: 1;
  font-weight: 500;
  text-transform: capitalize;
}
.cat-count {
  color: #8a96ab;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cat-row input[type=checkbox] {
  width: 20px;
  height: 20px;
  accent-color: #2d5cf6;
}

.panel-section {
  padding: 16px;
  border-top: 1px solid #2a3142;
  margin-top: 8px;
}
#preloadBtn {
  width: 100%;
  background: #1b2435;
  color: #d4dae3;
  border: 1px solid #2a3142;
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#preloadBtn:disabled {
  opacity: 0.6;
  cursor: progress;
}
#preloadBtn:active:not(:disabled) {
  background: #243049;
}
.panel-hint {
  margin-top: 8px;
  color: #8a96ab;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Status */
#status {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(15, 20, 28, 0.95);
  border: 1px solid #2a3142;
  color: #d4dae3;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  backdrop-filter: blur(8px);
}

/* POI markers */
.poi-marker {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #0a0e14;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.35);
}

/* Leaflet overrides for dark theme */
.leaflet-container {
  background: #0a0e14;
  font-family: inherit;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(15, 20, 28, 0.97);
  color: #d4dae3;
  border: 1px solid #2a3142;
}
.leaflet-popup-content {
  margin: 10px 14px;
  font-size: 13px;
}
.leaflet-control-zoom a {
  background: rgba(20, 26, 36, 0.92);
  color: #d4dae3;
  border-color: #2a3142;
}
.leaflet-control-attribution {
  background: rgba(15, 20, 28, 0.85) !important;
  color: #8a96ab !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: #5a8df0 !important; }
