/* Oilfield Well Locator — mobile-first dark UI */
:root {
  --bg: #0b0f14;
  --bg-elev: #141a22;
  --bg-card: #1a222d;
  --bg-card-hover: #222b38;
  --border: #2a3441;
  --border-strong: #3a4656;
  --text: #e8eef4;
  --text-muted: #8b96a5;
  --accent: #f0a500;
  --accent-dim: #c48400;
  --accent-soft: rgba(240, 165, 0, 0.14);
  --fav: #f0a500;
  --fav-glow: rgba(240, 165, 0, 0.35);
  --tx: #5b9fd4;
  --tx-bg: rgba(91, 159, 212, 0.16);
  --nm: #6ecf8e;
  --nm-bg: rgba(110, 207, 142, 0.14);
  --danger: #f85149;
  --tap: 48px;
  --radius: 14px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 4px 16px rgba(0,0,0,0.25);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  padding-bottom: calc(20px + var(--safe-bottom));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* Sample banner */
.sample-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: linear-gradient(90deg, #5c3d00, #6b4a08);
  color: #ffd980;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 12px;
  border-bottom: 1px solid #8a5a00;
}

.view { display: none; padding: 0 16px 28px; }
.view.active { display: block; }

/* Header / branding */
.app-header {
  padding: 18px 0 14px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.15rem;
  border: 1px solid rgba(240, 165, 0, 0.28);
  box-shadow: var(--shadow);
}
.brand-text h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.subtitle {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

/* Search */
.search-wrap {
  position: relative;
  margin: 0 0 12px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.15rem;
  pointer-events: none;
  line-height: 1;
}
#search-input,
#map-search-input {
  width: 100%;
  height: var(--tap);
  padding: 0 44px 0 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow);
}
#search-input:focus,
#map-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#search-input::placeholder,
#map-search-input::placeholder {
  color: var(--text-muted);
}
#search-clear,
#map-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 8px;
}
#search-clear:active,
#map-search-clear:active { color: var(--text); background: var(--bg-card); }

/* State filter chips */
.state-filter {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}
.chip {
  flex: 1;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip:active { opacity: 0.85; }
.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chip[data-state="TX"].active {
  background: var(--tx-bg);
  border-color: var(--tx);
  color: var(--tx);
}
.chip[data-state="NM"].active {
  background: var(--nm-bg);
  border-color: var(--nm);
  color: var(--nm);
}

/* Type filter chips */
.type-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -8px 0 16px;
}
.type-filter .chip {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}
.type-filter .chip.active {
  background: rgba(125, 168, 255, 0.16);
  border-color: #7da8ff;
  color: #a8c6ff;
}

/* Facility / site type badges */
.type-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.type-badge.type-well {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.35);
}
.type-badge.type-compressor {
  background: rgba(251, 146, 60, 0.16);
  color: #fdba74;
  border-color: rgba(251, 146, 60, 0.4);
}
.type-badge.type-terminal {
  background: rgba(167, 139, 250, 0.16);
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.4);
}
.type-badge.type-pump {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.4);
}
.type-badge.type-disposal {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
  border-color: rgba(248, 113, 113, 0.35);
}
.type-badge.type-battery {
  background: rgba(250, 204, 21, 0.14);
  color: #fde047;
  border-color: rgba(250, 204, 21, 0.4);
}
.type-badge.type-plant {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.4);
}
.type-badge.type-other {
  background: rgba(148, 163, 184, 0.14);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.3);
}

.section-title {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}
.section-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  min-height: 28px;
}
.home-block {
  margin-top: 22px;
}
.results-panel {
  margin-top: 4px;
}
.results-panel .section-title {
  margin-bottom: 10px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 36px;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 8px;
}
.btn-text:active { opacity: 0.7; background: var(--accent-soft); }

/* Empty states */
.empty-state {
  text-align: center;
  padding: 20px 16px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  border: 1px dashed var(--border-strong);
}
.empty-state.compact {
  padding: 16px 14px;
}
.empty-icon {
  display: block;
  font-size: 1.6rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: 6px;
  line-height: 1;
}
.empty-icon.star { color: var(--accent); opacity: 0.55; }
.empty-msg {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  margin: 0;
}
.empty-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 4px 0 0;
  line-height: 1.35;
}

/* Well list cards */
.well-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.well-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 12px 12px 12px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: var(--shadow);
  transition: background 0.12s, border-color 0.12s;
}
.well-item:active {
  background: var(--bg-card-hover);
  border-color: var(--accent-dim);
}
.well-item-fav {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--fav);
  font-size: 1.05rem;
  text-align: center;
  text-shadow: 0 0 10px var(--fav-glow);
}
.well-item-fav:empty::before {
  content: "";
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}
.well-item-body {
  flex: 1;
  min-width: 0;
}
.well-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.well-item-name {
  font-weight: 650;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.well-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.well-item-chevron {
  color: var(--text-muted);
  font-size: 1.25rem;
  flex-shrink: 0;
  opacity: 0.55;
  padding-left: 2px;
}

/* State badges */
.state-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 20px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
}
.state-badge.tx {
  background: var(--tx-bg);
  color: var(--tx);
  border: 1px solid rgba(91, 159, 212, 0.35);
}
.state-badge.nm {
  background: var(--nm-bg);
  color: var(--nm);
  border: 1px solid rgba(110, 207, 142, 0.35);
}

#results-count {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

/* Detail */
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  position: sticky;
  top: 31px; /* below sample banner */
  background: var(--bg);
  z-index: 50;
  margin: 0 -16px;
  padding-left: 8px;
  padding-right: 8px;
  border-bottom: 1px solid transparent;
}
.btn-back, .btn-fav {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  padding: 0 14px;
  box-shadow: var(--shadow);
}
.btn-back:active, .btn-fav:active { opacity: 0.85; }
.btn-fav {
  font-size: 1.45rem;
  color: var(--text-muted);
  padding: 0;
  width: var(--tap);
  transition: color 0.15s, text-shadow 0.15s, transform 0.12s;
}
.btn-fav.is-fav {
  color: var(--fav);
  text-shadow: 0 0 12px var(--fav-glow);
  border-color: rgba(240, 165, 0, 0.4);
  background: var(--accent-soft);
}
.btn-fav:active { transform: scale(0.94); }

.detail-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
  flex-wrap: wrap;
}
.sample-tag {
  display: inline-block;
  margin: 0;
  padding: 4px 9px;
  background: #5c3d00;
  color: #ffd980;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-radius: 6px;
  border: 1px solid #8a5a00;
}
.detail-body h1 {
  margin: 0 0 14px;
  font-size: 1.4rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.detail-meta {
  margin: 0 0 16px;
  display: grid;
  gap: 8px;
}
.detail-meta > div {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px;
  padding: 11px 12px;
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.detail-meta dt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  align-self: center;
}
.detail-meta dd {
  margin: 0;
  font-weight: 650;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.map-wrap {
  margin-bottom: 14px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-elev);
  position: relative;
}
.map-wrap::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
.map-box {
  height: 260px;
  width: 100%;
  border: none;
  border-radius: 0;
  overflow: hidden;
  margin: 0;
  background: var(--bg-elev);
  z-index: 1;
}

.directions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.btn-dir {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 16px;
  background: var(--accent);
  color: #1a1200;
  font-weight: 750;
  font-size: 1rem;
  text-decoration: none;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 4px 14px rgba(240, 165, 0, 0.28);
}
.btn-dir:active { background: var(--accent-dim); }
.btn-dir-secondary {
  background: var(--bg-elev);
  color: var(--text);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow);
}
.btn-dir-secondary:active {
  border-color: var(--accent);
}

/* Leaflet dark tweaks */
.leaflet-container {
  background: #1a1f28;
  font: inherit;
}
.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(13,17,23,0.85) !important;
  color: var(--text-muted) !important;
}
.leaflet-control-attribution a { color: var(--accent) !important; }
.leaflet-control-zoom a {
  background: var(--bg-elev) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
}

@media (min-width: 480px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* Source badges (REAL vs SAMPLE) */
.source-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
}
.source-badge.real {
  background: rgba(110, 207, 142, 0.18);
  color: #8fefad;
  border: 1px solid rgba(110, 207, 142, 0.4);
}
.source-badge.sample {
  background: rgba(240, 165, 0, 0.14);
  color: #ffd980;
  border: 1px solid rgba(240, 165, 0, 0.35);
}
.well-item-badges {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.sample-tag.real-tag {
  background: #0f3d24;
  color: #8fefad;
  border-color: #2a7a4a;
}
.browse-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.35;
}


/* Soft-launch banner tweak */
.soft-launch-banner {
  text-transform: none;
  letter-spacing: 0.02em;
}

/* Footer disclaimer */
.app-footer {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--text-muted, #8b949e);
  text-align: center;
  border-top: 1px solid var(--border, #30363d);
}

/* ========== Map tab + bottom nav ========== */
body {
  padding-bottom: calc(72px + var(--safe-bottom));
}
body.map-mode {
  overflow: hidden;
  height: 100%;
  padding-bottom: 0;
}
body.map-mode #app {
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.map-mode .sample-banner {
  flex-shrink: 0;
}
body.map-mode .view-map.active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
body.map-mode .tab-bar {
  position: relative;
  flex-shrink: 0;
}

.tab-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  z-index: 1200;
  display: flex;
  gap: 0;
  background: rgba(13, 17, 23, 0.96);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + var(--safe-bottom));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 12px;
  padding: 6px 8px;
}
.tab-btn .tab-icon {
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.85;
}
.tab-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}
.tab-btn:active { opacity: 0.85; }

.view-map {
  padding: 0 !important;
}
.map-toolbar {
  flex-shrink: 0;
  padding: 10px 12px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 500;
}
.map-toolbar .search-wrap {
  margin-bottom: 8px;
}
.map-toolbar .state-filter {
  margin-bottom: 6px;
}
.map-toolbar .type-filter {
  margin: 0 0 6px;
}

.basemap-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}
.basemap-toggle .basemap-chip {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 0.72rem;
  padding: 6px 10px;
}
.basemap-toggle .basemap-chip.active {
  background: var(--accent, #3b82f6);
  border-color: var(--accent, #3b82f6);
  color: #fff;
}

.map-cap-note {
  margin: 0;
  padding: 6px 8px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.overview-map {
  flex: 1;
  min-height: 240px;
  width: 100%;
  background: #1a1f28;
  z-index: 1;
}

.map-legend {
  position: absolute;
  left: 10px;
  bottom: calc(64px + var(--safe-bottom));
  z-index: 800;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 6px 10px;
  background: rgba(13, 17, 23, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 650;
  pointer-events: none;
  max-width: calc(100% - 20px);
}
body.map-mode .map-legend {
  bottom: calc(10px + var(--safe-bottom));
  /* legend sits above tab via view layout — place inside map area */
  position: absolute;
}
.view-map {
  position: relative;
}
.view-map .map-legend {
  bottom: 10px;
  left: 10px;
}
.leg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  border: 1px solid rgba(255,255,255,0.35);
}
.leg-well { background: #5b9fd4; }
.leg-compressor { background: #fb923c; }
.leg-terminal { background: #a78bfa; }
.leg-pump { background: #38bdf8; }
.leg-disposal { background: #f87171; }

.site-marker {
  background: transparent !important;
  border: none !important;
}
.site-pin {
  display: block;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.75);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.4);
}
.site-pin-fac {
  border-radius: 3px;
  border-width: 2px;
}

/* MarkerCluster dark */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(240, 165, 0, 0.28) !important;
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(240, 165, 0, 0.85) !important;
  color: #1a1200 !important;
  font-weight: 800 !important;
  font-family: var(--font) !important;
}

/* Popup (dark) */
.oilfield-popup .leaflet-popup-content-wrapper {
  background: var(--bg-card);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.oilfield-popup .leaflet-popup-tip {
  background: var(--bg-card);
  border: none;
}
.oilfield-popup .leaflet-popup-content {
  margin: 12px 14px;
  min-width: 200px;
}
.oilfield-popup a.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  padding: 6px 8px 0 0 !important;
}
.map-popup-title {
  font-weight: 750;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  line-height: 1.25;
}
.map-popup-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.map-popup-meta {
  margin: 0 0 10px;
  display: grid;
  gap: 4px;
}
.map-popup-meta > div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 6px;
  font-size: 0.78rem;
}
.map-popup-meta dt {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  align-self: center;
}
.map-popup-meta dd {
  margin: 0;
  font-weight: 650;
  word-break: break-word;
}
.map-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-popup-detail {
  min-height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1200;
  font-weight: 750;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: inherit;
}
.map-popup-detail:active { opacity: 0.9; }
.map-popup-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 650;
}
.map-popup-link:active { border-color: var(--accent); }

/* Hide list footer padding clash with tab bar */
.app-footer {
  padding-bottom: calc(24px + 56px + var(--safe-bottom));
}
body.map-mode .app-footer {
  display: none;
}

/* ========== Live user location (Map tab) ========== */
.btn-locate {
  position: absolute;
  right: 12px;
  bottom: 56px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 52px;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong, #484f58);
  border-radius: 14px;
  background: rgba(13, 17, 23, 0.94);
  color: var(--text, #e6edf3);
  font: inherit;
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn-locate:hover,
.btn-locate:focus-visible {
  border-color: #3b82f6;
  color: #93c5fd;
  outline: none;
}
.btn-locate:active { transform: scale(0.97); }
.btn-locate-icon {
  font-size: 1.25rem;
  line-height: 1;
  color: #60a5fa;
}
.btn-locate.is-locating .btn-locate-icon {
  animation: locate-pulse 1s ease-in-out infinite;
}
.btn-locate.is-active {
  border-color: #3b82f6;
  background: rgba(30, 58, 110, 0.92);
  color: #bfdbfe;
}
.btn-locate.is-active .btn-locate-icon {
  color: #60a5fa;
}
@keyframes locate-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.9); }
}

.locate-error {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 118px;
  z-index: 950;
  margin: 0;
  padding: 10px 12px;
  font-size: 0.75rem;
  line-height: 1.4;
  font-weight: 600;
  color: #fecaca;
  background: rgba(69, 10, 10, 0.94);
  border: 1px solid #991b1b;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
}

.user-loc-marker {
  background: transparent !important;
  border: none !important;
}
.user-loc-dot {
  display: block;
  width: 16px;
  height: 16px;
  margin: 6px;
  border-radius: 50%;
  background: #3b82f6;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35), 0 2px 8px rgba(0, 0, 0, 0.45);
}
.user-loc-dot::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.25);
  animation: user-loc-ring 2s ease-out infinite;
}
@keyframes user-loc-ring {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45); }
  100% { box-shadow: 0 0 0 14px rgba(59, 130, 246, 0); }
}

/* Main stage wraps list + map (identity on mobile) */
.main-stage {
  display: contents; /* children participate in #app as before on mobile */
}

/* ========== Desktop / wide: list + map split ========== */
@media (min-width: 900px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  body {
    padding-bottom: 0;
  }

  body.desktop-split {
    overflow: hidden;
    height: 100%;
  }

  #app {
    max-width: none;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: none;
    position: relative;
  }

  .sample-banner {
    flex-shrink: 0;
    z-index: 1300;
  }

  .main-stage {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(360px, 440px) 1fr;
    grid-template-rows: 1fr;
    overflow: hidden;
  }

  /* Both panes visible on desktop */
  body.desktop-split #view-home,
  body.desktop-split #view-home.active {
    display: block !important;
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0 20px 20px;
    border-right: 1px solid var(--border);
    background: var(--bg);
  }

  body.desktop-split #view-map,
  body.desktop-split #view-map.active {
    display: flex !important;
    flex-direction: column;
    grid-column: 2;
    grid-row: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 0 !important;
    position: relative;
  }

  /* Detail overlays the list column; map stays */
  body.desktop-split.detail-open .main-stage {
    position: relative;
  }

  body.desktop-split.detail-open #view-home {
    visibility: hidden;
    pointer-events: none;
  }

  body.desktop-split #view-detail,
  body.desktop-split #view-detail.active {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(440px, 42vw);
    z-index: 1100;
    display: none;
    overflow: auto;
    padding: 36px 20px 28px; /* below soft-launch banner */
    background: var(--bg);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.35);
  }

  body.desktop-split.detail-open #view-detail.active {
    display: block !important;
  }

  body.desktop-split #view-detail .detail-header {
    top: 36px;
    margin: 0 -20px;
    padding-left: 12px;
    padding-right: 12px;
  }

  /* Better header + search on wide list pane */
  body.desktop-split .app-header {
    padding: 20px 0 16px;
    flex-shrink: 0;
  }

  body.desktop-split .brand-mark {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
    border-radius: 14px;
  }

  body.desktop-split .brand-text h1 {
    font-size: 1.65rem;
  }

  body.desktop-split .subtitle {
    font-size: 0.85rem;
  }

  body.desktop-split .search-wrap {
    margin-bottom: 14px;
    flex-shrink: 0;
  }

  body.desktop-split #search-input {
    height: 52px;
    font-size: 1.05rem;
    padding-left: 44px;
    border-radius: 16px;
  }

  body.desktop-split .search-icon {
    left: 16px;
    font-size: 1.25rem;
  }

  body.desktop-split .state-filter {
    flex-shrink: 0;
    margin-bottom: 10px;
  }

  body.desktop-split .type-filter {
    flex-shrink: 0;
    margin: -2px 0 14px;
  }

  body.desktop-split .chip:hover {
    border-color: var(--border-strong);
    color: var(--text);
  }

  body.desktop-split .well-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-dim);
  }

  /* Map toolbar: compact horizontal on desktop */
  body.desktop-split .map-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 16px;
    background: rgba(11, 15, 20, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  body.desktop-split .map-toolbar .map-search {
    flex: 1 1 220px;
    margin: 0;
    min-width: 180px;
  }

  body.desktop-split .map-toolbar #map-search-input {
    height: 42px;
    border-radius: 12px;
  }

  body.desktop-split .map-toolbar .state-filter,
  body.desktop-split .map-toolbar .type-filter,
  body.desktop-split .map-toolbar .basemap-toggle {
    margin: 0;
    flex: 0 0 auto;
  }

  body.desktop-split .map-toolbar .state-filter .chip,
  body.desktop-split .map-toolbar .basemap-toggle .basemap-chip {
    flex: 0 0 auto;
    min-width: 52px;
    min-height: 36px;
    padding: 0 14px;
  }

  body.desktop-split .map-toolbar .type-filter .chip {
    min-height: 32px;
  }

  body.desktop-split .map-cap-note {
    flex: 1 1 100%;
    margin: 0;
  }

  body.desktop-split .overview-map {
    flex: 1;
    min-height: 0;
    height: auto;
  }

  body.desktop-split .map-legend {
    bottom: 16px;
    left: 16px;
  }

  body.desktop-split .btn-locate {
    right: 16px;
    bottom: 16px;
    min-width: 56px;
    min-height: 56px;
  }

  body.desktop-split .locate-error {
    bottom: 84px;
    left: 16px;
    right: auto;
    max-width: 320px;
  }

  /* Tab bar unused on desktop — both panes always shown */
  body.desktop-split .tab-bar {
    display: none !important;
  }

  body.desktop-split .app-footer {
    display: none;
  }

  body.desktop-split .detail-body .map-box {
    height: 280px;
  }

  body.desktop-split .directions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  body.desktop-split .btn-dir {
    flex: 1 1 180px;
  }
}

/* Mid-wide polish before full split (tablet landscape) */
@media (min-width: 600px) and (max-width: 899px) {
  #app {
    max-width: 640px;
  }

  .tab-bar,
  .app-footer {
    max-width: 640px;
  }

  .app-header {
    padding-top: 22px;
  }

  .brand-text h1 {
    font-size: 1.55rem;
  }

  #search-input {
    height: 50px;
  }

  .map-box {
    height: 300px;
  }
}
