/* ============================================================
   Colombia Amphibian Explorer  —  Glass Frog Palette
   Extracted from Centrolenidae glass frog ventral photograph:

   Near-black    #020A04  — photo void background
   Teal body     #4ABFA0  — translucent glowing skin
   Vivid teal    #6CDCB8  — iridescent highlight
   Yellow-gold   #C8A820  — toe pad pigment
   Coral-salmon  #C87060  — visible organs through skin
   Blood red     #CC2020  — artery
   Pale belly    rgba(160,230,210,0.15) — near-invisible skin

   Design rule: everything is dark glass. Light comes from WITHIN,
   like bioluminescence — teal glows on near-black surfaces.
   The basemap is the only bright thing; UI floats above it.
   ============================================================ */

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

:root {
  /* Core frog palette */
  --aqua:         #4ABFA0;
  --aqua-bright:  #6CDCB8;
  --aqua-dim:     #2E9A7E;
  --aqua-glow:    rgba(74, 191, 160, 0.60);
  --yellow:       #C8A820;
  --yellow-dim:   #A88818;
  --dark-bg:      #020A04;
  --dark-mid:     #061208;
  --dark-surface: #081A0E;
  --blood-red:    #CC2020;
  --coral:        #C87060;

  /* Glass surfaces — dark, translucent, teal-lit */
  --glass-fill:         rgba(74, 191, 160, 0.06);
  --glass-fill-hover:   rgba(74, 191, 160, 0.12);
  --glass-border:       rgba(74, 191, 160, 0.42);
  --glass-border-bright:rgba(108, 220, 184, 0.70);

  /* Sidebar — dark glass */
  --sidebar-bg:   rgba(3, 12, 6, 0.92);
  --sidebar-width: 340px;

  /* Typography — light on dark */
  --text-primary:   rgba(215, 245, 230, 0.95);
  --text-secondary: rgba(160, 215, 190, 0.82);
  --text-muted:     rgba(74, 191, 160, 0.65);
  --border-soft:    rgba(74, 191, 160, 0.16);

  /* Layout */
  --header-height: 56px;
  --slider-height: 76px;

  --radius: 9px;
  --font:   'Inter', 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%; overflow: hidden;
  font-family: var(--font); color: var(--text-primary);
  background: var(--dark-bg);
}

/* ── Header ───────────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--header-height);
  background: rgba(2, 10, 4, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 0 30px rgba(74, 191, 160, 0.10), 0 2px 16px rgba(0,0,0,0.7);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
}
.app-header .logo {
  font-size: 17px; font-weight: 700; color: rgba(215, 245, 230, 0.95);
  letter-spacing: -0.4px; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.logo-img {
  width: 28px; height: 28px; object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(74, 191, 160, 0.70));
}
.app-header .logo span {
  color: var(--aqua-bright);
  text-shadow: 0 0 14px var(--aqua-glow);
}
.app-header .subtitle {
  font-size: 11.5px; color: rgba(74, 191, 160, 0.50); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* ── Layout ───────────────────────────────────────────────────── */
.app-layout {
  position: fixed;
  top: var(--header-height);
  bottom: var(--slider-height);
  left: 0; right: 0;
  display: flex;
}

/* ── Sidebar — dark glass, teal-lit ──────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1.5px solid var(--glass-border);
  box-shadow: 4px 0 24px rgba(0,0,0,0.50), inset -1px 0 0 rgba(74,191,160,0.08);
  display: flex; flex-direction: column;
  overflow: hidden; flex-shrink: 0; z-index: 100;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(2, 10, 4, 0.60);
}
.sidebar-header-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 9px;
}
.sidebar-search input {
  width: 100%; padding: 8px 14px;
  border: 1.5px solid var(--glass-border);
  border-radius: 20px; font-size: 13px; outline: none;
  background: rgba(74, 191, 160, 0.06);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.sidebar-search input:focus {
  border-color: var(--aqua-bright);
  background: rgba(74, 191, 160, 0.10);
  box-shadow: 0 0 0 3px rgba(74, 191, 160, 0.12), 0 0 10px rgba(74, 191, 160, 0.18);
}
.sidebar-search input::placeholder { color: rgba(74, 191, 160, 0.40); }

.species-list { flex: 1; overflow-y: auto; padding: 4px 0; }
.species-list::-webkit-scrollbar { width: 3px; }
.species-list::-webkit-scrollbar-thumb { background: rgba(74,191,160,0.28); border-radius: 4px; }

.species-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 16px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.species-item:hover { background: rgba(74, 191, 160, 0.07); }
.species-item.active {
  background: rgba(74, 191, 160, 0.12);
  border-left-color: var(--aqua-bright);
  box-shadow: inset 3px 0 10px rgba(74, 191, 160, 0.12);
}
.species-thumb {
  width: 46px; height: 46px; border-radius: 8px;
  object-fit: cover; flex-shrink: 0;
  border: 1px solid rgba(74, 191, 160, 0.20);
  box-shadow: 0 2px 8px rgba(0,0,0,0.50);
}
.species-thumb-placeholder {
  width: 46px; height: 46px; border-radius: 8px;
  background: linear-gradient(135deg, #0D2A1C, #061208);
  border: 1px solid rgba(74, 191, 160, 0.20);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.species-item-text { min-width: 0; flex: 1; }
.species-item-common {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.species-item-sci {
  font-size: 11px; color: var(--text-muted); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}
.iucn-badge {
  margin-left: 4px; flex-shrink: 0;
  font-size: 9.5px; font-weight: 700; padding: 2px 6px;
  border-radius: 4px; color: #fff; letter-spacing: 0.3px;
}
.species-audio-btn {
  flex-shrink: 0;
  background: none; border: none; cursor: pointer;
  font-size: 13px; padding: 2px 4px; line-height: 1;
  border-radius: 4px; color: var(--aqua);
  opacity: 0.75; transition: opacity 0.2s, background 0.2s;
  z-index: 2; position: relative;
}
.species-audio-btn:hover { opacity: 1; background: rgba(74,191,160,0.12); }
.species-audio-btn.playing { opacity: 1; color: #fff; background: rgba(74,191,160,0.25); }

/* ── Species detail panel ──────────────────────────────────────── */
.species-detail {
  display: none; flex-direction: column;
  background: var(--sidebar-bg); overflow-y: auto; flex: 1;
}
.species-detail::-webkit-scrollbar { width: 3px; }
.species-detail::-webkit-scrollbar-thumb { background: rgba(74,191,160,0.28); border-radius: 4px; }

.detail-back {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 16px; cursor: pointer;
  font-size: 11px; font-weight: 700;
  color: var(--aqua-dim); letter-spacing: 0.5px; text-transform: uppercase;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(2, 10, 4, 0.60);
  transition: background 0.12s, color 0.12s;
}
.detail-back:hover {
  background: rgba(74, 191, 160, 0.10);
  color: var(--aqua-bright);
}
.detail-back svg { width: 14px; height: 14px; }

/* Hero — pure black like the frog photo background */
.detail-hero {
  position: relative; height: 220px; background: #020A04;
  overflow: hidden; flex-shrink: 0;
}
.detail-hero img { width: 100%; height: 100%; object-fit: cover; }
.detail-hero-placeholder {
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, #081A0E 0%, #020A04 70%);
  display: flex; align-items: center; justify-content: center;
  font-size: 72px; opacity: 0.70;
}
.detail-hero::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 90px;
  background: linear-gradient(to top, rgba(2,10,4,0.80) 0%, transparent 100%);
  pointer-events: none;
}
.detail-hero::before {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 1.5px;
  background: linear-gradient(90deg, transparent 0%, var(--aqua-bright) 50%, transparent 100%);
  box-shadow: 0 0 12px var(--aqua-glow);
  z-index: 2; pointer-events: none;
}
.detail-iucn-badge {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: 5px; color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6); letter-spacing: 0.3px;
  backdrop-filter: blur(6px);
}

.detail-body { padding: 18px 18px 24px; }
.detail-common {
  font-size: 23px; font-weight: 700; line-height: 1.15;
  color: var(--text-primary); letter-spacing: -0.3px;
}
.detail-sci {
  font-size: 13px; font-style: italic; color: var(--text-muted); margin-top: 3px;
}

.detail-description {
  margin-top: 13px; padding-top: 13px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px; line-height: 1.65; color: var(--text-secondary);
}

.detail-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px;
}
.stat-card {
  background: rgba(74, 191, 160, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 11px 13px;
  backdrop-filter: blur(8px);
  transition: background 0.15s, box-shadow 0.15s;
}
.stat-card:hover {
  background: rgba(74, 191, 160, 0.11);
  box-shadow: 0 0 14px rgba(74, 191, 160, 0.14);
}
.stat-label {
  font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted); font-weight: 600;
}
.stat-value { font-size: 20px; font-weight: 700; margin-top: 3px; line-height: 1; color: var(--aqua-bright); }
.stat-sub   { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.detail-inat-link {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 14px; padding: 10px;
  background: transparent;
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 12.5px; font-weight: 700;
  color: var(--aqua-dim); text-decoration: none;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.detail-inat-link:hover {
  background: rgba(74, 191, 160, 0.10);
  border-color: var(--aqua-bright);
  color: var(--aqua-bright);
  box-shadow: 0 0 18px rgba(74, 191, 160, 0.22), inset 0 0 8px rgba(74, 191, 160, 0.06);
}

/* ── Map area ─────────────────────────────────────────────────── */
.map-area { flex: 1; position: relative; overflow: hidden; }
#viewDiv  { width: 100%; height: 100%; }

/* ── Layers panel — dark glass ────────────────────────────────── */
.layers-panel {
  position: absolute; top: 14px; right: 14px; z-index: 50;
  background: rgba(3, 12, 6, 0.84);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.60), 0 0 0 1px rgba(74,191,160,0.10),
              inset 0 1px 0 rgba(108,220,184,0.08);
  width: 256px; overflow: hidden;
}
.layers-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer; user-select: none;
  background: rgba(2, 10, 4, 0.50);
}
.layers-panel-header span:first-child { font-size: 12.5px; font-weight: 700; color: var(--text-primary); }
.layers-panel-header span:last-child  { font-size: 11px; color: var(--text-muted); }
.layers-panel-body {
  padding: 10px 12px 12px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(74,191,160,0.35) transparent;
}
.layers-panel-body::-webkit-scrollbar { width: 4px; }
.layers-panel-body::-webkit-scrollbar-track { background: transparent; }
.layers-panel-body::-webkit-scrollbar-thumb { background: rgba(74,191,160,0.35); border-radius: 2px; }
.layers-panel-body::-webkit-scrollbar-thumb:hover { background: rgba(74,191,160,0.60); }

.layer-toggle-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.layer-toggle-row:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.layer-info { flex: 1; min-width: 0; padding-right: 8px; }
.layer-name { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.layer-desc { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }

/* ── Ecosystem legend ─────────────────────────────────────────── */
.eco-legend {
  display: flex; flex-direction: column; gap: 3px; margin-top: 7px;
}
.eco-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: var(--text-secondary); line-height: 1.3;
}
.eco-sw {
  width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.18);
}

/* ── Precipitation legend ─────────────────────────────────────── */
.precip-legend {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
  margin-top: 7px;
}
.precip-row {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text-secondary);
}
.precip-sw {
  width: 14px; height: 10px; border-radius: 2px; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

/* Legend — hex density: gold graduated dots matching AGOL symbology */
.legend-hex-grad {
  display: flex; flex-direction: column; gap: 4px; margin-top: 8px;
}
.legend-hex-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; color: var(--text-muted);
}
.hex-dot {
  border-radius: 50%; flex-shrink: 0;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
.hex-dot.s1 { width: 8px;  height: 7px;  background: #7A6A1A; opacity: 0.70; }
.hex-dot.s2 { width: 12px; height: 10px; background: #9E8820; opacity: 0.80; }
.hex-dot.s3 { width: 16px; height: 14px; background: #C4AA28; opacity: 0.88; }
.hex-dot.s4 { width: 20px; height: 17px; background: #D4B830; opacity: 0.94; }
.hex-dot.s5 { width: 24px; height: 21px; background: #C89A00; opacity: 1.00; }

.legend-range-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; color: var(--text-secondary); margin-top: 5px; line-height: 1.3;
}
.legend-range-swatch { width: 16px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* Protection areas legend — muted green with dot pattern */
.legend-protection-swatch {
  width: 16px; height: 12px; border-radius: 3px; flex-shrink: 0;
  background-color: rgba(90, 140, 100, 0.30);
  border: 1.5px solid rgba(90, 140, 100, 0.75);
  background-image: radial-gradient(circle, rgba(90,140,100,0.80) 1.2px, transparent 1.2px);
  background-size: 4px 4px;
}

/* Observation point pin — Tear Pin 2: dark green tear, bright yellow circle */
.legend-point-pin {
  position: relative;
  width: 14px; height: 14px; flex-shrink: 0;
  background: #1E4020;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 0 5px rgba(30,64,32,0.60);
  margin-right: 3px;
}
.legend-point-pin::after {
  content: '';
  position: absolute;
  width: 7px; height: 7px;
  background: #C8DE00;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}
.legend-point-note {
  font-size: 9.5px; color: var(--text-muted);
  margin-top: 5px; font-style: italic; line-height: 1.4;
  padding-left: 2px;
}

/* Toggle switch */
.toggle-switch {
  position: relative; width: 36px; height: 20px;
  flex-shrink: 0; margin-top: 2px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: rgba(74, 191, 160, 0.08);
  border: 1.5px solid rgba(74, 191, 160, 0.35);
  border-radius: 20px; transition: 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute;
  width: 12px; height: 12px; left: 3px; bottom: 3px;
  background: rgba(200, 240, 220, 0.60);
  border-radius: 50%; transition: 0.2s;
}
input:checked + .toggle-slider {
  background: rgba(74, 191, 160, 0.18);
  border-color: var(--aqua-bright);
  box-shadow: 0 0 10px rgba(74, 191, 160, 0.30);
}
input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: var(--aqua-bright);
  box-shadow: 0 0 8px rgba(74, 191, 160, 0.70);
}

/* ── Hover tooltip ─────────────────────────────────────────────── */
.map-tooltip {
  position: absolute; z-index: 60; pointer-events: none;
  background: rgba(2, 10, 4, 0.90);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--aqua-bright);
  padding: 7px 13px; border-radius: 7px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5), 0 0 14px rgba(74, 191, 160, 0.10);
  display: none;
}

/* ── Time slider ──────────────────────────────────────────────── */
.time-slider-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 150;
  height: var(--slider-height);
  background: rgba(2, 10, 4, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--glass-border);
  box-shadow: 0 0 30px rgba(74, 191, 160, 0.07), 0 -4px 24px rgba(0,0,0,0.6);
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; user-select: none;
}

.play-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--glass-border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--aqua-bright); font-size: 14px; flex-shrink: 0;
  backdrop-filter: blur(6px);
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s, transform 0.1s;
}
.play-btn:hover {
  background: rgba(74, 191, 160, 0.10);
  border-color: var(--aqua-bright);
  box-shadow: 0 0 20px rgba(74, 191, 160, 0.40);
  transform: scale(1.06);
}
.play-btn:active { transform: scale(0.95); }

.slider-wrap { flex: 1; position: relative; padding-top: 6px; }

.week-label {
  position: absolute; top: -22px; transform: translateX(-50%);
  background: rgba(2, 10, 4, 0.80);
  backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  color: var(--aqua-bright);
  font-size: 10.5px; font-weight: 800;
  padding: 3px 11px; border-radius: 5px; white-space: nowrap;
  pointer-events: none; letter-spacing: 0.5px;
  box-shadow: 0 0 14px rgba(74, 191, 160, 0.22);
}

.slider-track {
  width: 100%; height: 3px;
  background: rgba(74, 191, 160, 0.10);
  border-radius: 2px; position: relative; cursor: pointer;
}
.slider-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--aqua-dim), var(--aqua-bright));
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(74, 191, 160, 0.60);
}
.slider-thumb {
  position: absolute; top: 50%; width: 18px; height: 18px;
  background: rgba(74, 191, 160, 0.08);
  border: 2px solid var(--aqua-bright);
  border-radius: 50%;
  transform: translate(-50%, -50%); cursor: grab;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 16px rgba(74, 191, 160, 0.55), 0 2px 6px rgba(0,0,0,0.60);
  transition: box-shadow 0.15s, background 0.15s;
}
.slider-thumb:active {
  cursor: grabbing;
  background: rgba(74, 191, 160, 0.22);
  box-shadow: 0 0 26px rgba(74, 191, 160, 0.80);
}

.slider-month-labels { display: flex; justify-content: space-between; margin-top: 9px; }
.slider-month-labels span {
  font-size: 9.5px; color: rgba(74, 191, 160, 0.38);
  font-weight: 700; letter-spacing: 0.8px;
}
.slider-sublabel {
  font-size: 9px; color: rgba(74,191,160,0.35);
  text-align: center; margin-top: 3px; letter-spacing: 0.3px; font-style: italic;
}

.migration-band {
  position: absolute; top: -3px; height: 10px;
  background: rgba(74, 191, 160, 0.10);
  border: 1px solid rgba(74, 191, 160, 0.22);
  border-radius: 2px; pointer-events: none;
}
.migration-band-label {
  position: absolute; top: -20px; transform: translateX(-50%);
  font-size: 8.5px; font-weight: 700; letter-spacing: 0.6px;
  color: rgba(74, 191, 160, 0.45); white-space: nowrap; pointer-events: none;
}

/* ── Loading ───────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: var(--dark-bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
}
.loading-overlay.hidden { display: none; }
.loading-spinner {
  width: 46px; height: 46px;
  border: 2px solid rgba(74, 191, 160, 0.12);
  border-top-color: var(--aqua-bright);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  box-shadow: 0 0 22px rgba(74, 191, 160, 0.28);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: rgba(74, 191, 160, 0.70); font-weight: 500; }

/* ── Layer sliders ────────────────────────────────────────────── */
.layer-sliders {
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 6px;
}
.layer-slider-row {
  display: flex; align-items: center; gap: 8px;
}
.slider-label {
  font-size: 10.5px; color: var(--text-muted); width: 62px; flex-shrink: 0;
}
.slider-val {
  font-size: 10.5px; color: var(--aqua); width: 34px; text-align: right; flex-shrink: 0;
}
.layer-range {
  flex: 1; height: 3px; appearance: none; -webkit-appearance: none;
  background: rgba(74,191,160,0.20); border-radius: 2px; outline: none; cursor: pointer;
}
.layer-range::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--aqua-bright); border: 2px solid rgba(2,10,4,0.8);
  box-shadow: 0 0 6px rgba(74,191,160,0.60); cursor: pointer;
}

/* ── Basemap switcher ─────────────────────────────────────────── */
.basemap-switcher {
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--border-soft);
}
/* ── Available Maps cards ─────────────────────────────────────── */
.map-options-section { margin-bottom: 4px; }
.map-option-cards { display: flex; gap: 6px; }
.map-option-card {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 5px; padding: 8px 4px 7px;
  background: rgba(74,191,160,0.04);
  border: 1.5px solid rgba(74,191,160,0.18);
  border-radius: 8px; cursor: pointer; text-align: center;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.map-option-card:hover  { border-color: rgba(74,191,160,0.45); background: rgba(74,191,160,0.09); }
.map-option-card.active { border-color: var(--aqua-bright); background: rgba(74,191,160,0.15); }
.map-option-card.disabled { opacity: 0.45; cursor: default; pointer-events: none; }
.map-option-icon  { font-size: 18px; line-height: 1; }
.map-option-title { font-size: 9px; font-weight: 700; color: var(--text-secondary); line-height: 1.3; }
/* Species distribution legend (shown under Conservation Pressure option) */
.dist-legend-item {
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0;
}
.dist-legend-swatch {
  width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
}
.dist-legend-name {
  flex: 1; font-size: 8.5px; color: var(--text-secondary);
  font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dist-legend-pct {
  font-size: 8.5px; color: var(--text-muted); flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.map-option-soon  {
  position: absolute; top: 4px; right: 4px;
  font-size: 7.5px; font-weight: 700; letter-spacing: 0.3px;
  background: rgba(74,191,160,0.20); color: var(--aqua);
  padding: 1px 4px; border-radius: 3px;
}

.basemap-btn-row { display: flex; gap: 6px; }
.basemap-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(74,191,160,0.04); border: 1.5px solid rgba(74,191,160,0.18);
  border-radius: 7px; padding: 5px 4px; cursor: pointer;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  transition: border-color 0.15s, background 0.15s;
}
.basemap-btn:hover  { border-color: rgba(74,191,160,0.50); background: rgba(74,191,160,0.08); }
.basemap-btn.active { border-color: var(--aqua-bright); background: rgba(74,191,160,0.14); color: var(--aqua); }
.basemap-thumb { width: 100%; height: 26px; border-radius: 4px; }
.basemap-thumb-custom { background: linear-gradient(135deg,#6a9a78 0%,#a8a080 50%,#5a8a6a 100%); }
.basemap-thumb-gray   { background: linear-gradient(135deg,#c0c0c0 0%,#e0e0e0 50%,#a8a8a8 100%); }
.basemap-thumb-dark   { background: linear-gradient(135deg,#1a2a1e 0%,#2a3a2a 50%,#0a1a0e 100%); }
.basemap-thumb-topo   { background: linear-gradient(135deg,#8ab090 0%,#d0c898 50%,#a09060 100%); }

/* ── Map hint overlay ─────────────────────────────────────────── */
.map-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 10;
}
.map-hint-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: rgba(2, 10, 4, 0.80);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1.5px solid var(--glass-border);
  border-radius: 18px; padding: 32px 40px; max-width: 360px; text-align: center;
  box-shadow: 0 0 50px rgba(74, 191, 160, 0.16), 0 8px 40px rgba(0,0,0,0.7),
              inset 0 1px 0 rgba(108,220,184,0.10);
}
.map-hint-frog {
  width: 72px; height: 72px; object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(74, 191, 160, 0.80));
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0);    }
  50%       { transform: translateY(-8px); }
}
.map-hint-title {
  font-size: 18px; font-weight: 700;
  color: rgba(215, 245, 230, 0.95); letter-spacing: -0.3px;
}
.map-hint-text {
  font-size: 13px; color: rgba(74, 191, 160, 0.72); line-height: 1.58;
}
.map-hint-arrow {
  font-size: 12px; font-weight: 600; color: var(--aqua-bright); letter-spacing: 0.5px;
  animation: pulse-opacity 2s ease-in-out infinite;
}
@keyframes pulse-opacity {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── Responsive ───────────────────────────────────────────────── */
.mobile-toggle { display: none; }

/* ── Sidebar backdrop — plain dark veil, no blur on the drawer ── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 999;   /* one below the drawer */
  background: rgba(0, 0, 0, 0.55);
  /* NO backdrop-filter — blur bleeds through semi-transparent drawer */
}
.sidebar-backdrop.active {
  display: block;
  animation: backdropIn 0.22s ease forwards;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Drawer close button — visible on mobile only ────────────── */
.drawer-close-row {
  display: none;   /* hidden on desktop */
}

/* ── Tablet + Mobile  ≤ 768px ─────────────────────────────────── */
@media (max-width: 768px) {
  /* Prevent horizontal overflow */
  html, body, .app-layout { overflow-x: hidden; }

  /* Header — hide subtitle, reveal hamburger */
  .app-header { padding: 0 12px; gap: 8px; }
  .app-header .subtitle { display: none; }
  .mobile-toggle {
    display: flex !important;
    align-items: center; justify-content: center;
    width: 44px !important; height: 44px !important; min-width: 44px !important;
    border-radius: 8px !important;
    background: rgba(74,191,160,0.07) !important;
    border: 1.5px solid rgba(74,191,160,0.25) !important;
    color: var(--aqua-bright) !important;
    font-size: 18px !important;
    transition: background 0.15s, border-color 0.15s !important;
    cursor: pointer !important;
  }
  .mobile-toggle:hover  { background: rgba(74,191,160,0.14) !important; }
  .mobile-toggle.active { background: rgba(74,191,160,0.18) !important;
                          border-color: var(--aqua-bright) !important; }

  /* ── Drawer — slides from left, covers full viewport height ── */
  .sidebar {
    position: fixed;
    top: 0; left: 0;          /* start from very top */
    height: 100dvh;            /* cover header + content + timeline */
    bottom: auto;
    width: min(86vw, 360px);
    transform: translateX(-100%);
    transition: transform 250ms ease;
    z-index: 1000;             /* above map, header, layers panel, timeline */
    display: flex !important;
    overflow: hidden;          /* species-list scrolls internally */
    /* Fully opaque background — no see-through blur artifact */
    background: #061208;
    border-right: 1.5px solid var(--glass-border);
    box-shadow: 6px 0 32px rgba(0,0,0,0.70);
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* Drawer close row — shown only on mobile */
  .drawer-close-row {
    display: flex;
    align-items: center; justify-content: space-between;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: rgba(2, 10, 4, 0.80);
    flex-shrink: 0;
  }
  .drawer-close-title {
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    letter-spacing: -0.2px;
  }
  .drawer-close-btn {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: rgba(74,191,160,0.08);
    border: 1.5px solid rgba(74,191,160,0.28);
    border-radius: 7px;
    color: var(--aqua-bright);
    font-size: 15px; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }
  .drawer-close-btn:hover { background: rgba(74,191,160,0.18);
                             border-color: var(--aqua-bright); }

  /* Species list — scrollable with momentum on iOS */
  .species-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    pointer-events: auto;
  }
  /* Species detail scroll */
  .species-detail {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Intro card — tappable on mobile to open species drawer */
  .map-hint { pointer-events: none; }
  .map-hint-inner {
    pointer-events: auto;
    cursor: pointer;
    transition: box-shadow 0.15s;
  }
  .map-hint-inner:active {
    box-shadow: 0 0 50px rgba(74,191,160,0.26), 0 8px 40px rgba(0,0,0,0.7),
                inset 0 1px 0 rgba(108,220,184,0.15);
  }
  /* Replace the ← arrow hint with a mobile-appropriate one */
  .map-hint-arrow { font-size: 0; }
  .map-hint-arrow::after {
    content: "☰  Tap to choose a species";
    font-size: 12px; font-weight: 600;
    color: var(--aqua-bright); letter-spacing: 0.5px;
    animation: pulse-opacity 2s ease-in-out infinite;
  }

  /* Bigger touch targets — species list items */
  .species-item {
    padding: 13px 16px; min-height: 52px;
    touch-action: manipulation;   /* no 300ms delay on tap */
    pointer-events: auto;
    cursor: pointer;
  }

  /* IUCN filter chips */
  .iucn-chip { padding: 7px 11px; font-size: 11px; min-height: 38px; }

  /* Detail back button */
  .detail-back { padding: 13px 16px; font-size: 12px; min-height: 44px; }

  /* Layers panel — bottom sheet */
  .layers-panel {
    position: fixed;
    bottom: var(--slider-height);
    left: 0; right: 0; top: auto;
    width: 100%;
    max-height: 65vh;
    border-radius: 14px 14px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    z-index: 50;
  }
  .layers-panel-body {
    max-height: calc(65vh - 48px);
    -webkit-overflow-scrolling: touch;
  }
  .layers-panel-header { padding: 14px 16px; min-height: 48px; }

  /* Toggle switches — larger pill */
  .toggle-switch { width: 44px; height: 26px; min-width: 44px; }
  .toggle-slider::before { width: 18px; height: 18px; left: 4px; bottom: 4px; }
  input:checked + .toggle-slider::before { transform: translateX(18px); }

  /* Range slider thumbs */
  .layer-range::-webkit-slider-thumb { width: 18px; height: 18px; }
  .layer-range::-moz-range-thumb     { width: 18px; height: 18px; border: none; }

  /* Play / pause button */
  .play-btn { width: 44px; height: 44px; min-width: 44px; }

  /* Slider drag thumb */
  .slider-thumb { width: 24px; height: 24px; }
}

/* ── Small phones ≤ 480px ─────────────────────────────────────── */
@media (max-width: 480px) {
  :root { --slider-height: 64px; }

  /* Full-width drawer on narrow phones */
  .sidebar { width: 100vw; }

  /* Compact timeline — drop decorative labels */
  .time-slider-bar { padding: 0 10px; gap: 8px; }
  .slider-sublabel      { display: none; }
  .migration-band-label { display: none; }
}

/* ── Item 2: IUCN filter chips ────────────────────────────────── */
.iucn-chips {
  display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 8px;
}
.iucn-chip {
  display: flex; align-items: center;
  background: rgba(74,191,160,0.05);
  border: 1.5px solid rgba(74,191,160,0.22);
  border-left: 3px solid var(--chip-color, #4ABFA0);
  border-radius: 5px;
  color: var(--text-secondary);
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px; cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.iucn-chip:hover {
  background: rgba(74,191,160,0.10);
  color: var(--text-primary);
}
.iucn-chip.active {
  background: rgba(74,191,160,0.14);
  border-color: var(--chip-color, #4ABFA0);
  color: var(--text-primary);
  box-shadow: 0 0 8px rgba(74,191,160,0.18);
}

/* ── Item 2: Sort row ─────────────────────────────────────────── */
.sort-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.sort-label {
  font-size: 10.5px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0;
}
.species-sort-select {
  flex: 1;
  background: rgba(74,191,160,0.07);
  border: 1.5px solid rgba(74,191,160,0.30);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px; font-weight: 600;
  padding: 4px 8px; outline: none; cursor: pointer;
}
.species-sort-select:focus {
  border-color: var(--aqua-bright);
  box-shadow: 0 0 0 2px rgba(74,191,160,0.12);
}
.species-sort-select option {
  background: #061208; color: var(--text-primary);
}

/* ── Item 7: Obs count bar ────────────────────────────────────── */
.species-item { position: relative; overflow: hidden; }
.obs-bar {
  position: absolute; bottom: 0; left: 0;
  height: 3px;
  background: rgba(74,191,160,0.35);
  border-radius: 0 2px 0 0;
  pointer-events: none;
  transition: width 0.3s;
}


/* ── Item 9: Sound button ─────────────────────────────────────── */
.detail-sound {
  margin-top: 10px;
}
.sound-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 10px;
  background: transparent;
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius);
  font-size: 12.5px; font-weight: 700;
  color: var(--aqua-dim); cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.sound-btn:hover {
  background: rgba(74,191,160,0.10);
  border-color: var(--aqua-bright);
  color: var(--aqua-bright);
  box-shadow: 0 0 18px rgba(74,191,160,0.22), inset 0 0 8px rgba(74,191,160,0.06);
}

/* ── Item 11: Panel divider ───────────────────────────────────── */
.panel-divider {
  border: none;
  border-top: 1px solid rgba(74,191,160,0.15);
  margin: 10px 0;
}

/* ── Scale bar — discrete & transparent ──────────────────────── */
.esri-scale-bar {
  opacity: 0.55;
  transition: opacity 0.2s;
}
.esri-scale-bar:hover { opacity: 0.90; }
.esri-scale-bar__label {
  color: rgba(200,222,180,0.90) !important;
  font-size: 10px !important;
  text-shadow: 0 1px 3px rgba(0,0,0,0.80);
}
.esri-scale-bar__line { border-color: rgba(200,222,180,0.70) !important; }
.esri-scale-bar__line--bottom { border-color: rgba(200,222,180,0.70) !important; }

/* ── Compass / North arrow — top-left, green glass ──────────── */
.esri-compass {
  background: rgba(4,30,12,0.70) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  border: 1.5px solid rgba(74,191,160,0.45) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.50), 0 0 8px rgba(74,191,160,0.15) !important;
  border-radius: 7px !important;
  opacity: 0.75;
  transition: opacity 0.2s, box-shadow 0.2s;
  width: 30px !important; height: 30px !important;
}
.esri-compass:hover {
  opacity: 1;
  box-shadow: 0 2px 12px rgba(0,0,0,0.55), 0 0 12px rgba(74,191,160,0.30) !important;
}
.esri-compass__container { width: 30px !important; height: 30px !important; }
.esri-icon-compass { font-size: 15px !important; color: #4ABFA0 !important; }

/* ── Work-in-progress banner ─────────────────────────────────── */
.wip-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 40; pointer-events: none;
  background: rgba(2, 10, 4, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(200, 168, 32, 0.40);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.4px;
  color: rgba(200, 168, 32, 0.85);
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

/* ── Corine Land Cover legend ─────────────────────────────────── */
.corine-legend {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 0;
}
.corine-group {
  margin-bottom: 7px;
}
.corine-group:last-child { margin-bottom: 0; }
.corine-group-hdr {
  display: flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 3px;
}
.corine-sub {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; color: var(--text-muted);
  padding-left: 6px; margin-bottom: 2px; line-height: 1.3;
}
.corine-sw {
  width: 10px; height: 10px; border-radius: 2px;
  flex-shrink: 0; border: 1px solid rgba(255,255,255,0.15);
}
.corine-sw.sm {
  width: 8px; height: 8px;
}
