:root {
  --sidebar-w: 360px;
  --detail-w: 420px;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e8eaed;
  --border-subtle: #f0f1f3;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --accent-subtle: #dbeafe;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
}
body.dark {
  --bg: #0c0d0e;
  --card: #141517;
  --border: #232528;
  --border-subtle: #1a1c1e;
  --text: #d4d6d9;
  --text-secondary: #7a7d82;
  --text-tertiary: #474a50;
  --accent: #4c8bf5;
  --accent-hover: #3b7cf5;
  --accent-light: #111a2a;
  --accent-subtle: #0f1e35;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.6), 0 1px 3px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.7), 0 2px 6px rgba(0,0,0,0.5);
}
body.dark #map { background: #080c12; }
body.dark .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
body.dark .importance-primary { background: #0d1f15; color: #4ade80; }
body.dark .importance-secondary { background: #1f1608; color: #fbbf24; }
body.dark .importance-tertiary { background: #18191c; color: #7a7d82; }
body.dark .detail-header { background: linear-gradient(180deg, var(--bg) 0%, var(--card) 100%); }
body.dark .detail-footer { background: var(--bg); }
body.dark .detail-link { background: var(--accent); }
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif; color: var(--text); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
#map { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 1; background: #e8e8e8; }

/* Loading overlay */
#loading-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }
#loading-overlay .spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================
   Full-page Filter Overlay
   ============================ */
#filter-overlay {
  position: fixed; inset: 0; z-index: 1500;
  background: var(--bg);
  transition: opacity 0.35s ease, transform 0.35s ease;
  overflow-y: auto;
}
#filter-overlay.hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.filter-page {
  max-width: 900px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
}

/* Filter header */
.filter-header {
  padding: 28px 4px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}
.filter-logo {
  width: 44px; height: 44px;
  border-radius: 8px; flex-shrink: 0;
}
.filter-header-text h2 {
  font-size: 22px; font-weight: 800;
  letter-spacing: -0.5px; color: var(--text);
}
.filter-header-text .subtitle {
  font-size: 12px; color: var(--text-tertiary);
  margin-top: 3px; font-weight: 500; letter-spacing: 0.2px;
}

/* Tabs */
.filter-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  gap: 8px;
  flex-shrink: 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  flex: 0 0 auto;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-tertiary);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  text-align: center;
  font-family: inherit;
}
.filter-tab:hover { color: var(--text-secondary); }
.filter-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Tab content */
.filter-tab-content {
  display: none;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.filter-tab-content.active { display: flex; }
.filter-tab-content::-webkit-scrollbar { width: 6px; }
.filter-tab-content::-webkit-scrollbar-track { background: transparent; }
.filter-tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Section labels */
.section-label {
  padding: 16px 4px 8px; font-size: 10px; font-weight: 700;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 1.2px;
}

/* Country chips */
.country-chips {
  padding: 6px 4px 16px; display: flex; flex-wrap: wrap; gap: 8px;
  border-bottom: 1px solid var(--border);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 100px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: 2px solid var(--border);
  background: var(--card); transition: all 0.2s ease;
  user-select: none; letter-spacing: 0.1px; white-space: nowrap;
  color: var(--text-tertiary);
}
.chip::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.chip.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
  font-weight: 700; box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}
.chip.active::before {
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}
.chip:hover:not(.active) { border-color: var(--accent); background: var(--accent-light); color: var(--text); }

/* Search */
.search-box {
  margin: 10px 4px 8px; position: relative;
}
.search-box input {
  width: 100%; padding: 10px 12px 10px 38px; border: 1.5px solid var(--border);
  border-radius: var(--radius-md); font-size: 14px; outline: none;
  transition: all 0.2s ease; background: var(--card); font-family: inherit;
  color: var(--text);
}
.search-box input::placeholder { color: var(--text-tertiary); }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-tertiary);
}

/* Mineral list — two columns on wide screens */
#mineral-filters {
  overflow-y: auto; flex: 1; padding: 4px 0;
  min-height: 80px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
}
#mineral-filters::-webkit-scrollbar { width: 6px; }
#mineral-filters::-webkit-scrollbar-track { background: transparent; }
#mineral-filters::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#mineral-filters::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
.filter-item {
  display: flex; align-items: center; padding: 12px 12px; cursor: pointer;
  font-size: 13px; gap: 10px; transition: background 0.15s ease;
  border-radius: var(--radius-sm); min-height: 44px;
}
.filter-item:hover { background: var(--card); }
.filter-item input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.filter-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1); box-shadow: 0 0 0 1px rgba(255,255,255,0.5) inset;
}
.filter-label { flex: 1; font-weight: 500; }
.filter-count {
  font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums;
  font-weight: 500; background: var(--bg); padding: 2px 8px; border-radius: 100px;
}

/* Actions bar */
.actions-bar {
  padding: 12px 4px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}
.actions-bar button {
  padding: 8px 20px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--card); transition: all 0.2s ease;
  font-family: inherit; color: var(--text-secondary); letter-spacing: 0.1px;
}
.actions-bar button:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ============================
   Railway Options (radio cards)
   ============================ */
.railway-options {
  padding: 16px 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.railway-option {
  display: block;
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
}
.railway-option:hover { border-color: var(--text-tertiary); }
.railway-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.railway-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}

.railway-option-content {
  padding: 16px 18px;
}

.railway-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.railway-option-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.railway-radio-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.2s;
}
.railway-option.selected .railway-radio-dot {
  border-color: var(--accent);
}
.railway-option.selected .railway-radio-dot::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.railway-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}

/* Railway legend (hidden by default, shown when selected) */
.railway-legend {
  display: none;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-direction: column;
  gap: 6px;
}
.railway-option.selected .railway-legend {
  display: flex;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.legend-line {
  width: 24px; height: 3px;
  border-radius: 1.5px;
  flex-shrink: 0;
}
.legend-line.legend-dashed {
  background: repeating-linear-gradient(
    90deg,
    currentColor 0, currentColor 5px,
    transparent 5px, transparent 8px
  ) !important;
  background-color: transparent !important;
  height: 3px;
}

/* Railway scope toggle */
.railway-scope-toggle {
  margin: 8px 4px 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--card);
}

/* ============================
   Pipeline Options
   ============================ */
/* Pipeline layer toggles */
.pipeline-layers {
  padding: 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pipeline-layer {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.pipeline-layer:hover { border-color: var(--text-tertiary); }
.pipeline-layer:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}
.pipeline-layer input { position: absolute; opacity: 0; width: 0; height: 0; }
.pipeline-layer-swatch {
  width: 20px; height: 3px;
  border-radius: 1.5px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.pipeline-layer:has(input:not(:checked)) .pipeline-layer-swatch { opacity: 0.3; }
.pipeline-layer-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.pipeline-layer-count {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: auto;
}
/* Pipeline legend */
.pipeline-legend {
  padding: 0 2px 12px;
}
.pipeline-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.pipeline-legend-row .legend-line { width: 18px; }
.pipeline-legend-row span:nth-child(2),
.pipeline-legend-row span:nth-child(4) { margin-right: 8px; }
/* Pipeline attribution */
.pipeline-attribution {
  padding: 4px 2px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.pipeline-attribution a {
  color: var(--text-secondary);
  text-decoration: none;
}
.pipeline-attribution a:hover {
  text-decoration: underline;
}

/* ============================
   Power Plant Grid
   ============================ */
.power-plant-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 8px 0;
}

/* Triangle swatch (matches map marker shape) */
.pp-swatch {
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid #999;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.pipeline-layer:has(input:not(:checked)) .pp-swatch { opacity: 0.3; }

/* Triangle legend markers */
.pp-legend-triangle {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid var(--text-tertiary);
  flex-shrink: 0;
}
.pp-legend-md {
  border-left-width: 5px;
  border-right-width: 5px;
  border-bottom-width: 9px;
}
.pp-legend-lg {
  border-left-width: 7px;
  border-right-width: 7px;
  border-bottom-width: 12px;
}

/* Select all / deselect all buttons for power plants */
.pp-action-btn {
  padding: 6px 16px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--card); transition: all 0.2s ease;
  font-family: inherit; color: var(--text-secondary); letter-spacing: 0.1px;
}
.pp-action-btn:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ============================
   Military & Border Legends
   ============================ */
/* 2x2 grid for military operator toggles */
.mil-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Square swatch (matches map marker shape) */
.mil-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.6);
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: opacity 0.15s;
}
.pipeline-layer:has(input:not(:checked)) .mil-swatch { opacity: 0.3; }

/* Military legend squares */
.mil-legend-square {
  width: 12px; height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1.5px solid #fff;
}
.mil-legend-closed {
  opacity: 0.5;
  border-color: #999;
  position: relative;
}
.mil-legend-closed::after {
  content: '\00d7';
  position: absolute;
  top: -3px; left: 1px;
  font-size: 11px; line-height: 1;
  color: #fff; font-weight: bold;
}
.mil-legend-construction {
  position: relative;
}
.mil-legend-construction::after {
  content: '\25B3';
  position: absolute;
  top: -2px; left: 1px;
  font-size: 9px; line-height: 1;
  color: #fff; font-weight: bold;
}

/* Diamond swatch for border crossings */
.bc-swatch {
  width: 12px; height: 12px;
  flex-shrink: 0;
  position: relative;
  transition: opacity 0.15s;
}
.bc-swatch-bri {
  background: #2e7d32;
  transform: rotate(45deg);
  border-radius: 1px;
  border: 1.5px solid rgba(255,255,255,0.5);
}
.pipeline-layer:has(input:not(:checked)) .bc-swatch { opacity: 0.3; }

/* Diamond legend markers */
.bc-legend-diamond {
  width: 10px; height: 10px;
  transform: rotate(45deg);
  border-radius: 1px;
  flex-shrink: 0;
}

/* ============================
   Display Options
   ============================ */
.display-options {
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.display-option {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--card);
}
.display-option:last-child { border-bottom: 1px solid var(--border-subtle); }

.display-option-info { flex: 1; }
.display-option-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.display-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.5;
}

/* Toggle switch */
.toggle-switch {
  position: relative; width: 36px; height: 20px; cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--border); border-radius: 10px;
  transition: background 0.2s ease;
}
.toggle-track::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; background: #fff; border-radius: 50%;
  transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-track {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(16px);
}

/* ============================
   Filter Footer
   ============================ */
.filter-footer {
  padding: 16px 4px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#stats {
  font-size: 12px; color: var(--text-tertiary); text-align: center;
  font-variant-numeric: tabular-nums; font-weight: 500;
  letter-spacing: 0.2px;
}

.view-map-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  letter-spacing: 0.2px;
}
.view-map-btn:hover { background: var(--accent-hover); }
.view-map-btn:active { transform: scale(0.98); }
.view-map-btn svg { flex-shrink: 0; }

/* ============================
   Floating Filters Button
   ============================ */
#open-filters {
  position: fixed;
  bottom: 20px; left: 20px;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all 0.2s ease, opacity 0.35s ease, transform 0.35s ease;
}
#open-filters:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 4px 10px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
#open-filters svg { color: var(--accent); flex-shrink: 0; }
#open-filters.hidden {
  opacity: 0; transform: translateY(12px);
  pointer-events: none;
}

/* ============================
   Detail Panel (right side)
   ============================ */
#detail-panel {
  position: absolute; top: 0; right: 0; z-index: 1001;
  background: var(--card); width: var(--detail-w);
  max-height: 100vh; overflow-y: auto; overflow-x: hidden;
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  border-left: 1px solid var(--border);
}
#detail-panel.open { transform: translateX(0); }
#detail-panel::-webkit-scrollbar { width: 6px; }
#detail-panel::-webkit-scrollbar-track { background: transparent; }
#detail-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.detail-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg) 0%, var(--card) 100%);
  position: sticky; top: 0; z-index: 2;
}
.detail-header-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.detail-close {
  background: none; border: none; cursor: pointer; color: var(--text-tertiary);
  padding: 6px; border-radius: 8px; transition: all 0.15s; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.detail-close:hover { background: var(--border-subtle); color: var(--text); }
.detail-header h3 {
  font-size: 22px; font-weight: 800; color: var(--text);
  letter-spacing: -0.5px; line-height: 1.25;
}
.detail-country-tag {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-light); padding: 4px 12px; border-radius: 100px;
  margin-top: 10px; letter-spacing: 0.4px; text-transform: uppercase;
}

.detail-body { padding: 0; }

.detail-section {
  padding: 18px 28px; border-bottom: 1px solid var(--border-subtle);
}
.detail-section:last-child { border-bottom: none; }
.detail-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-tertiary); margin-bottom: 14px;
}
.detail-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 20px;
  align-items: baseline;
}
.detail-grid .label {
  font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}
.detail-grid .value {
  font-size: 14px; color: var(--text); font-weight: 500;
}

.commodity-row {
  display: flex; align-items: center; gap: 12px; padding: 7px 0;
}
.commodity-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.08);
}
.commodity-name { flex: 1; font-weight: 600; font-size: 14px; }
.commodity-importance {
  font-size: 10px; padding: 3px 10px; border-radius: 100px;
  font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
}
.importance-primary { background: #dcfce7; color: #15803d; }
.importance-secondary { background: #fef3c7; color: #b45309; }
.importance-tertiary { background: #f1f5f9; color: #64748b; }

.detail-ref { font-size: 13px; color: var(--text-secondary); margin: 6px 0; line-height: 1.6; }
.detail-ref em { color: var(--text-tertiary); font-style: normal; font-weight: 600; }

.detail-footer {
  padding: 20px 28px 28px; border-top: 1px solid var(--border);
  background: var(--bg); position: sticky; bottom: 0;
}
.detail-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 700; font-size: 13px;
  text-decoration: none; letter-spacing: 0.2px;
  padding: 10px 20px; border-radius: var(--radius-md);
  background: var(--accent); transition: all 0.2s ease;
  width: 100%; justify-content: center;
}
.detail-link:hover { background: var(--accent-hover); text-decoration: none; }

/* Mine dot styling */
.mine-dot {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
  transition: r 0.15s ease;
}
@media (pointer: coarse) {
  .mine-dot { cursor: pointer; }
}

/* Hide default Leaflet popups -- we use the detail panel */
.leaflet-popup { display: none !important; }

/* Selection pin marker */
.selection-pin {
  width: 28px; height: 28px; position: relative;
}
.selection-pin::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 28px; height: 28px;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.2);
  animation: selection-pulse 1.8s ease-out infinite;
}
@keyframes selection-pulse {
  0% { box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.2), 0 0 0 0 rgba(255,255,255,0.5); }
  70% { box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.2), 0 0 0 10px rgba(255,255,255,0); }
  100% { box-shadow: 0 0 0 1px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.2), 0 0 0 0 rgba(255,255,255,0); }
}

/* Detail drag handle */
.detail-drag-handle {
  display: none;
  justify-content: center; padding: 10px 0 0; cursor: grab;
}
.detail-drag-handle span {
  width: 36px; height: 4px; border-radius: 2px; background: var(--border);
}

/* ============================
   Mobile responsive
   ============================ */
@media (max-width: 768px) {
  :root {
    --detail-w: 100vw;
  }

  /* Filter overlay: full-width, smaller padding */
  .filter-page { padding: 0 12px; }
  .filter-header { padding: 16px 4px 14px; }
  .filter-header-text h2 { font-size: 17px; }
  .filter-logo { width: 36px; height: 36px; }
  .filter-tabs { padding: 0 4px; }
  .filter-tab { padding: 12px 14px; font-size: 12px; }

  .section-label { padding: 10px 4px 4px; }
  .country-chips {
    padding: 6px 0 12px; gap: 6px;
    flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .country-chips::-webkit-scrollbar { display: none; }
  .chip { padding: 8px 14px; font-size: 12px; flex-shrink: 0; min-height: 40px; }

  .search-box { margin: 8px 0 6px; }
  .search-box input { font-size: 16px; } /* prevent iOS zoom */
  #mineral-filters { grid-template-columns: 1fr; }
  .filter-item { padding: 8px 10px; font-size: 13px; min-height: 44px; }
  .actions-bar { padding: 10px 0; }

  .railway-options { padding: 12px 0; gap: 8px; grid-template-columns: 1fr; }
  .railway-option-content { padding: 12px 14px; }
  .railway-option-title { font-size: 13px; }
  .railway-option-desc { font-size: 11px; }

  .pipeline-layers { padding: 12px 0; }
  .pipeline-layer { padding: 10px 12px; }
  .power-plant-grid { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .mil-grid { grid-template-columns: 1fr 1fr; gap: 6px; }

  .display-options { padding: 12px 0; }
  .display-option { padding: 14px 16px; min-height: 56px; }
  .display-option-title { font-size: 13px; }
  .display-option-desc { font-size: 11px; }

  .filter-footer { padding: 12px 0 calc(16px + env(safe-area-inset-bottom, 0px)); }
  .view-map-btn {
    padding: 16px 24px;
    font-size: 16px;
    border-radius: var(--radius-lg);
  }
  #stats { font-size: 11px; }

  #open-filters {
    bottom: 16px; left: 16px;
    padding: 10px 16px;
    font-size: 13px;
  }

  /* Detail panel bottom-sheet */
  #detail-panel {
    width: 100vw;
    top: auto; bottom: 0; max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    border-left: none;
  }
  #detail-panel.open { transform: translateY(0); }
  .detail-drag-handle { display: flex; }
  .detail-header { padding: 16px 20px 14px; }
  .detail-header h3 { font-size: 18px; }
  .detail-close { padding: 10px; }
  .detail-section { padding: 14px 20px; }
  .detail-footer { padding: 16px 20px calc(24px + env(safe-area-inset-bottom, 0px)); }

  /* Floating filter button: respect safe area */
  #open-filters { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
