/* 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.16);
  --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);
  /* Status bar / camera cutout. visualViewport --vv-top is a separate offset. */
  --safe-top: env(safe-area-inset-top, 0px);
  /* Browser chrome overlay (not the home indicator). Set from visualViewport in app.js. */
  --vv-bottom: 0px;
  --vv-top: 0px;
  /* Visible viewport height. 100svh until JS measures; 100dvh still sits under mobile browser chrome. */
  --vvh: 100svh;
  /* Fixed List/Map bar height including home-indicator padding. */
  --tab-bar-block: calc(64px + var(--safe-bottom));
  --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: block;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid rgba(240, 165, 0, 0.35);
  box-shadow: var(--shadow);
  object-fit: cover;
}
img.brand-mark {
  padding: 0;
}
.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.78rem;
  margin: 6px 0 0;
  line-height: 1.4;
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
}

/* 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-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-share {
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.btn-share:active { opacity: 0.85; }

.detail-distance {
  margin: -6px 0 14px;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(240, 165, 0, 0.28);
  border-radius: var(--radius-sm);
}

.well-item-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.well-item-row .well-item {
  flex: 1;
  min-width: 0;
}
.well-item-remove {
  flex: 0 0 var(--tap);
  width: var(--tap);
  min-height: var(--tap);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  align-self: center;
}
.well-item-remove:active {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.5);
}
.well-item-distance {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.well-item-distance[hidden] { display: none !important; }

.directions-label {
  margin: 0 0 2px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.share-toast {
  margin: 0 0 20px;
  padding: 10px 12px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 650;
  color: #0b0f14;
  background: var(--accent);
  border-radius: var(--radius-sm);
}

.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 {
  /* Clear the fixed tab bar and any browser toolbar that overlays the layout viewport. */
  padding-bottom: calc(72px + var(--safe-bottom) + var(--vv-bottom, 0px));
}
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;
}
/* Phone Map tab: hide soft-launch banner so map + tab bar fit in viewport */
body.map-mode:not(.desktop-split) .sample-banner {
  display: none;
}
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;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  flex-shrink: 0;
  z-index: 1200;
  pointer-events: auto;
  width: 100%;
  max-width: none;
}

.tab-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--vv-bottom, 0px);
  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: 8px 10px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 500;
}
.map-toolbar .search-wrap {
  margin-bottom: 6px;
}
.map-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.btn-map-filters {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
}
.btn-map-filters[aria-expanded="true"],
.btn-map-filters.has-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-map-filters:active { opacity: 0.85; }
.map-filters-summary {
  display: inline-block;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.65rem;
  font-weight: 650;
  color: var(--text-muted);
  opacity: 0.95;
}
.btn-map-filters.has-active .map-filters-summary {
  color: var(--accent);
}

.basemap-toggle {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 4px;
  margin: 0;
  min-width: 0;
}
.basemap-toggle .basemap-chip {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  font-size: 0.68rem;
  padding: 6px 8px;
  min-height: 36px;
}
.basemap-toggle .basemap-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1200;
}

/* Phone: type/state filters live in bottom sheet — not in toolbar */
.map-filters-sheet {
  position: absolute;
  inset: 0;
  z-index: 1100;
  pointer-events: none;
}
.map-filters-sheet:not([hidden]) {
  pointer-events: auto;
}
.map-filters-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.map-filters-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(70vh, 420px);
  overflow: auto;
  padding: 12px 14px calc(14px + var(--safe-bottom));
  background: var(--bg-elev);
  border-top: 1px solid var(--border-strong);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.45);
  transform: translateY(0);
}
.map-filters-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.map-filters-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.map-filters-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  min-width: 40px;
  min-height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.map-filters-close:active {
  color: var(--text);
  background: var(--bg-card);
}
.map-filters-sheet .state-filter {
  margin-bottom: 10px;
}
.map-filters-sheet .type-filter {
  margin: 0;
  flex-wrap: wrap;
}
.map-filters-sheet .type-filter .chip {
  flex: 1 1 auto;
}

.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;
  position: relative;
  isolation: isolate;
}
/* Phone Map: map pane fills remaining space under toolbar; must shrink so tab bar stays visible */
body.map-mode:not(.desktop-split) .overview-map {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
body.map-mode:not(.desktop-split) .map-toolbar {
  position: relative;
  z-index: 500;
  /* Keep the 6px gap, then clear the status bar. --vv-top already shifts #app, so do not add it here. */
  padding: calc(6px + var(--safe-top, env(safe-area-inset-top, 0px))) 10px 6px;
}
body.map-mode:not(.desktop-split) .map-toolbar .search-wrap {
  margin-bottom: 6px;
}
body.map-mode:not(.desktop-split) .map-toolbar #map-search-input {
  height: 40px;
}
body.map-mode:not(.desktop-split) .map-filters-sheet {
  /* sit above tab bar inside map view */
  bottom: 0;
}
body.map-mode:not(.desktop-split) .btn-locate {
  bottom: calc(12px + var(--safe-bottom));
}
body.map-mode:not(.desktop-split) .map-legend {
  bottom: calc(12px + var(--safe-bottom));
}
body.map-mode:not(.desktop-split) .locate-error {
  bottom: calc(76px + var(--safe-bottom));
}
.overview-map .leaflet-container {
  /* Keep Leaflet inside map pane stacking; do not cover #tab-bar */
  z-index: 0;
}

.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;
}

/* Selected / focused well pin — larger + brief flash (no map pan) */
.site-marker.is-selected {
  z-index: 700 !important;
}
.site-pin.is-selected {
  border-width: 2.5px;
  border-color: #fff;
  box-shadow:
    0 0 0 2px rgba(240, 165, 0, 0.95),
    0 0 14px rgba(240, 165, 0, 0.7),
    0 2px 8px rgba(0, 0, 0, 0.55);
}
.site-pin-fac.is-selected {
  border-radius: 4px;
}
@keyframes site-pin-pulse {
  0% {
    transform: scale(1);
    box-shadow:
      0 0 0 2px rgba(240, 165, 0, 0.95),
      0 0 10px rgba(240, 165, 0, 0.55),
      0 2px 8px rgba(0, 0, 0, 0.55);
  }
  35% {
    transform: scale(1.45);
    box-shadow:
      0 0 0 4px rgba(255, 220, 120, 0.95),
      0 0 22px rgba(240, 165, 0, 0.9),
      0 2px 10px rgba(0, 0, 0, 0.5);
  }
  100% {
    transform: scale(1);
    box-shadow:
      0 0 0 2px rgba(240, 165, 0, 0.95),
      0 0 14px rgba(240, 165, 0, 0.7),
      0 2px 8px rgba(0, 0, 0, 0.55);
  }
}
.site-pin.is-selected.site-pin-pulse {
  animation: site-pin-pulse 0.55s ease-out 1;
  transform-origin: center center;
}
@media (prefers-reduced-motion: reduce) {
  .site-pin.is-selected.site-pin-pulse {
    animation: none;
  }
}

/* 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); }

/* Phone map pin info card — fixed bottom, no map pan */
.map-pin-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  pointer-events: none;
  padding: 0 10px calc(10px + var(--safe-bottom));
}
.map-pin-sheet:not([hidden]) {
  pointer-events: auto;
}
.map-pin-card {
  position: relative;
  max-height: min(42vh, 320px);
  overflow: auto;
  padding: 12px 14px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.4);
}
.map-pin-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  min-width: 40px;
  min-height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.map-pin-close:active {
  color: var(--text);
  background: var(--bg-card);
}
.map-pin-body {
  padding-right: 28px;
}
.map-pin-body .map-popup-title {
  /* used as #map-pin-title */
}
body.map-mode:not(.desktop-split) .btn-locate.map-pin-open {
  bottom: calc(12px + var(--safe-bottom) + min(42vh, 320px) + 8px);
}
body.map-mode:not(.desktop-split) .map-legend.map-pin-open {
  bottom: calc(12px + var(--safe-bottom) + min(42vh, 320px) + 8px);
}
/* Tablet/desktop: floating info card on the map (not full-width bottom sheet) */
body.desktop-split .map-pin-sheet {
  display: block;
  left: auto;
  right: 12px;
  bottom: 12px;
  width: min(340px, calc(100% - 24px));
  max-width: 340px;
  padding: 0;
  z-index: 1060;
}
body.desktop-split .map-pin-sheet[hidden] {
  display: none !important;
}
body.desktop-split .map-pin-card {
  max-height: min(48vh, 380px);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-strong);
  padding: 14px 16px 16px;
}
body.desktop-split .map-pin-close {
  min-width: 44px;
  min-height: 44px;
}
/* Keep Locate on the map pane; raise above the floating card when open */
body.desktop-split .btn-locate.map-pin-open {
  right: 12px;
  bottom: calc(12px + min(48vh, 380px) + 10px);
}
body.desktop-split .map-legend.map-pin-open {
  bottom: 12px;
  left: 12px;
}

/* List row selected from map pin (tablet/desktop) */
.well-item.is-map-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(240, 165, 0, 0.25);
}
.well-item.is-map-selected .well-item-name {
  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: 768px) {
  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;
    padding-top: calc(7px + var(--safe-top));
    padding-bottom: 7px;
  }

  .main-stage {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(360px, 420px) 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 calc(20px + var(--safe-bottom));
    border-right: 1px solid var(--border);
    background: var(--bg);
  }

  /* Cap line length in the list column */
  body.desktop-split #view-home .well-item-name,
  body.desktop-split #view-home .well-item-meta,
  body.desktop-split #view-home .empty-hint,
  body.desktop-split #view-detail .detail-body {
    max-width: 36rem;
  }

  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(420px, 42vw);
    z-index: 1100;
    display: none;
    overflow: auto;
    /* below soft-launch banner (+ safe-area) */
    padding: calc(36px + var(--safe-top)) 20px calc(28px + var(--safe-bottom));
    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: calc(36px + var(--safe-top));
    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;
    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;
  }

  /* Desktop: Filters button opens a popover panel (same sheet markup) */
  body.desktop-split .map-toolbar-actions {
    flex: 0 0 auto;
    gap: 10px;
  }

  body.desktop-split .btn-map-filters {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 0.8rem;
  }

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

  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-filters-sheet {
    position: absolute;
    inset: auto;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    pointer-events: none;
  }
  body.desktop-split .map-filters-sheet:not([hidden]) {
    pointer-events: auto;
  }
  body.desktop-split .map-filters-backdrop {
    background: rgba(0, 0, 0, 0.25);
  }
  body.desktop-split .map-filters-panel {
    left: auto;
    right: 16px;
    bottom: auto;
    top: 72px;
    width: min(360px, calc(100% - 32px));
    max-height: min(70vh, 480px);
    border-radius: 14px;
    border: 1px solid var(--border-strong);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
    padding: 14px 16px 16px;
  }
  body.desktop-split .map-filters-sheet .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: 767px) {
  #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;
  }
}


/* Logo + polish 2026-10 */
.brand-row {
  gap: 14px;
}
.brand-text h1 {
  color: var(--text);
}
.chip.active {
  box-shadow: 0 0 0 1px rgba(240, 165, 0, 0.2);
}
.tab-btn.active .tab-icon {
  opacity: 1;
}
.btn-locate[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}


/* ========== Map search results dropdown (Map tab) ========== */
.map-search-results {
  margin: 0 0 8px;
  max-height: min(42vh, 320px);
  overflow: auto;
  background: rgba(13, 17, 23, 0.96);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  z-index: 600;
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.map-search-results[hidden] { display: none !important; }
.map-search-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 4px;
  position: sticky;
  top: 0;
  background: rgba(13, 17, 23, 0.98);
  z-index: 1;
}
.map-search-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}
.map-search-to-list {
  font-size: 0.72rem !important;
  min-height: 32px;
  padding: 4px 8px;
}
.map-search-list {
  list-style: none;
  margin: 0;
  padding: 4px 6px 8px;
}
.map-search-list .well-item-row {
  margin: 0;
}
.map-search-list .well-item {
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 10px;
}
.map-search-empty {
  margin: 0;
  padding: 12px 14px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
}
body.map-mode:not(.desktop-split) .map-search-results {
  margin: 0 0 8px;
}
body.desktop-split .map-search-results {
  margin: 0 0 8px;
  max-height: min(36vh, 280px);
}

/* Phone Map: browser toolbars overlay 100dvh. Size the app to the visual
   viewport and pin the List/Map bar above that chrome. Do not hide the tab bar. */
@media (max-width: 767px) {
  body.map-mode:not(.desktop-split) {
    height: var(--vvh, 100svh);
    max-height: var(--vvh, 100svh);
    padding-bottom: 0;
  }
  body.map-mode:not(.desktop-split) #app {
    position: fixed;
    top: var(--vv-top, 0px);
    left: 0;
    right: 0;
    width: 100%;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    height: var(--vvh, 100svh);
    max-height: var(--vvh, 100svh);
    box-sizing: border-box;
    /* Fixed tab bar is out of flow; keep the map above it inside the visible area. */
    padding-bottom: var(--tab-bar-block);
  }
  body.map-mode:not(.desktop-split) .tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--vv-bottom, 0px);
    transform: none;
    width: 100%;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    z-index: 1200;
    pointer-events: auto;
    flex-shrink: 0;
    padding: 6px 8px calc(6px + var(--safe-bottom));
  }
}
@media (min-width: 600px) and (max-width: 767px) {
  body.map-mode:not(.desktop-split) #app,
  body.map-mode:not(.desktop-split) .tab-bar {
    max-width: 640px;
  }
}


/* Phone landscape (width still < 768): keep tabbed layout, tighten vertical chrome */
@media (max-width: 767px) and (max-height: 480px) and (orientation: landscape) {
  .sample-banner {
    padding: 4px 10px;
    font-size: 10px;
  }
  .app-header {
    padding: 8px 0 6px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
  }
  .brand-text h1 {
    font-size: 1.2rem;
  }
  .subtitle {
    display: none;
  }
  #search-input {
    height: 42px;
  }
  .state-filter {
    margin-bottom: 8px;
  }
  .chip {
    min-height: 34px;
  }
  body.map-mode:not(.desktop-split) .map-toolbar {
    padding-top: calc(4px + var(--safe-top, env(safe-area-inset-top, 0px)));
    padding-bottom: 4px;
  }
  body.map-mode:not(.desktop-split) .map-toolbar #map-search-input {
    height: 36px;
  }
  .map-pin-card {
    max-height: min(48vh, 220px);
  }
  .tab-bar {
    padding-top: 2px;
    padding-bottom: calc(2px + var(--safe-bottom));
  }
}


/* Larger tablets / desktop: slightly roomier split panel */
@media (min-width: 1024px) {
  body.desktop-split .main-stage {
    grid-template-columns: minmax(380px, 420px) 1fr;
  }
  body.desktop-split .chip {
    min-height: 42px;
    font-size: 0.92rem;
  }
  body.desktop-split .well-item {
    min-height: 56px;
    padding: 12px 14px;
  }
  body.desktop-split .tab-btn {
    /* unused but keep consistent if shown */
    min-height: 52px;
  }
}

