/* ============================================================
   VANISHING CLOUDS — main.css
   Audubon-inspired full-screen map explorer
   ============================================================ */

/* ============================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  --primary:        #1B5E3B;
  --primary-light:  #2E7D52;
  --primary-pale:   #E8F5E9;
  --accent-gold:    #F9A825;
  --accent-red:     #C0392B;
  --text-dark:      #1A1A2E;
  --text-medium:    #4A5568;
  --text-light:     #9AA5B4;
  --white:          #FFFFFF;
  --panel-bg:       rgba(255, 255, 255, 0.78);
  --nav-bg:         rgba(255, 255, 255, 0.74);
  --nav-border:     rgba(255, 255, 255, 0.45);
  --fog-blur:       blur(22px) saturate(1.35);
  --nav-h:          56px;
  --panel-w:        420px;
  --profile-h:      142px;   /* terrain cross-section panel height */
  --data-strip-h:   32px;    /* #data-strip height */
  --shadow-sm:      0 1px 8px rgba(0, 0, 0, 0.08);
  --shadow-md:      0 4px 20px rgba(0, 0, 0, 0.12);
  --shadow-lg:      0 8px 40px rgba(0, 0, 0, 0.18);
  --radius:         10px;
  --radius-lg:      16px;
  --radius-pill:    999px;
  --transition:     0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text-dark);
  background: #E8ECF0;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  line-height: 1.2;
}

h3, h4, h5, h6 {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
}

button {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  cursor: pointer;
  border: none;
  background: none;
}

ul { list-style: none; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); text-decoration: underline; }

/* ============================================================
   3. APP SHELL
   ============================================================ */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   4. FULL-SCREEN MAP
   ============================================================ */
#map-main {
  position: absolute;
  inset: 0;
  z-index: 0;
  /* Zoom diffuse transition — blur fades in on zoomstart, out on zoomend */
  transition: filter 0.28s ease;
  will-change: filter;
}
#map-main.map-zooming {
  filter: blur(9px) brightness(0.97);
}

/* Hillshade GL canvas — z=260: above terrain tile pane (z=200) and detail tiles
   (z=300 is detail, so hillshade at 260 is between terrain and detail which renders
   on top, but that's fine since detail = water/urban bodies).
   mix-blend-mode: multiply darkens shadow faces against the terrain; transparent
   highlight pixels pass through unchanged.  filter nudges contrast very slightly.
   opacity 0.75 keeps the effect visible but not over-powering (user slider overrides inline). */
#hillshade-gl {
  position: absolute;
  inset: 0;
  z-index: 260;
  pointer-events: none;
  opacity: 0.75;
  mix-blend-mode: multiply;
  filter: contrast(1.05) brightness(1.02);
}

#hillshade-gl .maplibregl-canvas-container,
#hillshade-gl canvas {
  pointer-events: none !important;
  background: transparent !important;
  /* Fallback: apply blend directly on canvas if container compositing fails */
  mix-blend-mode: multiply;
}

/* Páramo golden metallic shimmer — pulses brightness and adds a gold glow */
@keyframes paramo-shimmer {
  0%,  100% { filter: brightness(1)    saturate(1)    drop-shadow(0 0 0px transparent); }
  50%        { filter: brightness(1.18) saturate(1.25) drop-shadow(0 0 4px rgba(212,174,56,0.55)); }
}
.paramo-polygon {
  animation: paramo-shimmer 3.5s ease-in-out infinite;
}

/* MapLibre GL vector tile overlay — synced canvas above Leaflet data layers */
#vector-tile-gl {
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
}

#vector-tile-gl .maplibregl-canvas-container,
#vector-tile-gl canvas {
  pointer-events: none !important;
}

/* Detail vector tile overlay — water bodies & urban footprints.
   Sits below Leaflet data overlays (z=400) so the base context stays behind.
   Opacity-gated by JS: fades in at zoom >= DETAIL_MIN_ZOOM. */
#detail-tile-gl {
  position: absolute;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  opacity: 0;                        /* hidden by default; JS sets opacity on zoomend */
  transition: opacity 0.55s ease;
}

#detail-tile-gl .maplibregl-canvas-container,
#detail-tile-gl canvas {
  pointer-events: none !important;
}

/* ============================================================
   5. TOP NAVIGATION
   ============================================================ */
#top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: var(--fog-blur);
  -webkit-backdrop-filter: var(--fog-blur);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: 0 1px 24px rgba(255, 255, 255, 0.3), var(--shadow-sm);
  z-index: 600;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.5rem;
}

/* Left: hamburger + logo */
.tn-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.tn-panel-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text-medium);
  transition: background var(--transition), color var(--transition);
}
.tn-panel-toggle:hover {
  background: var(--primary-pale);
  color: var(--primary);
}

.tn-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
}

.logo-leaf {
  font-size: 1.4rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-title {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
}

.logo-sub {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-light);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Center: nav items */
.tn-center {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex: 1;
  justify-content: center;
}

.tn-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-medium);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.tn-item:hover {
  background: var(--primary-pale);
  color: var(--primary);
}

.tn-item.active {
  background: var(--primary-pale);
  color: var(--primary);
  font-weight: 600;
}

.tn-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

.tn-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Right: layers btn */
.tn-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.tn-layers-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: var(--fog-blur);
  -webkit-backdrop-filter: var(--fog-blur);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary);
  box-shadow: 0 2px 12px rgba(255, 255, 255, 0.25), var(--shadow-sm);
  transition: box-shadow var(--transition), background var(--transition);
  white-space: nowrap;
}

.tn-layers-btn:hover {
  box-shadow: var(--shadow-md);
  background: var(--primary-pale);
}

.tn-layers-btn .chevron {
  transition: transform var(--transition);
}

.tn-layers-btn.open .chevron {
  transform: rotate(180deg);
}

.tn-hamburger {
  display: none;
  font-size: 1.3rem;
  color: var(--text-medium);
  padding: 0.3rem 0.5rem;
}

/* ============================================================
   6. SIDE PANEL
   ============================================================ */
/* Fog-drift animation for the panel interior */
@keyframes panel-fog-drift {
  0%   { transform: translate(0%,    0%)   scale(1);    opacity: 0.10; }
  30%  { transform: translate(6%,  -10%)   scale(1.06); opacity: 0.15; }
  60%  { transform: translate(-4%,   8%)   scale(1.03); opacity: 0.12; }
  100% { transform: translate(0%,    0%)   scale(1);    opacity: 0.10; }
}

#side-panel {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  width: var(--panel-w);
  /* Default: runs to bottom edge (non-overview panels) */
  height: calc(100vh - var(--nav-h));
  /* Layered radial gradients give a subtle cloud-mist feel:
     – bright centre-left glow (the "sky window")
     – secondary warm pocket lower-right
     – solid semi-transparent base behind everything             */
  background:
    radial-gradient(circle at 20% 15%,  rgba(255,255,255,0.95) 0%, rgba(255,255,255,0)   55%),
    radial-gradient(circle at 80% 80%,  rgba(232,245,233,0.70) 0%, rgba(255,255,255,0)   50%),
    rgba(255, 255, 255, 0.78);
  backdrop-filter: var(--fog-blur);
  -webkit-backdrop-filter: var(--fog-blur);
  z-index: 500;
  display: flex;
  flex-direction: row;
  box-shadow: 4px 0 32px rgba(255, 255, 255, 0.25), 3px 0 24px rgba(0, 0, 0, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.55);
  transform: translateX(0);
  transition: transform var(--transition), height var(--transition);
  will-change: transform;
  /* NOTE: no overflow:hidden — the collapse tab is position:absolute;left:100%
     and must not be clipped. The ::before fog uses inset:0 so no overflow needed. */
}

/* Animated misty radial blob drifting behind the panel content */
#side-panel::before {
  content: '';
  position: absolute;
  inset: 0;                    /* stay within panel bounds; gradients fade naturally */
  background:
    radial-gradient(ellipse 70% 50% at 30% 40%, rgba(200,220,210,0.18) 0%, transparent 70%),
    radial-gradient(ellipse 55% 65% at 75% 65%, rgba(230,240,255,0.14) 0%, transparent 65%);
  animation: panel-fog-drift 22s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@media (prefers-reduced-motion: reduce) {
  #side-panel::before { animation: none; }
}

/* When terrain cross-section is visible (overview panel), shorten sidebar
   so the profile panel shows fully beneath it */
body.terrain-active #side-panel {
  height: calc(100vh - var(--nav-h) - var(--profile-h) - var(--data-strip-h));
}

#side-panel.collapsed {
  transform: translateX(calc(-1 * var(--panel-w)));
}

#panel-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  /* Sit above the ::before fog layer (z=0) inside #side-panel */
  position: relative;
  z-index: 1;
  /* Hide scrollbar but keep scrolling */
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}

#panel-scroll::-webkit-scrollbar {
  width: 4px;
}
#panel-scroll::-webkit-scrollbar-track {
  background: transparent;
}
#panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 4px;
}

/* Collapse tab — sits at right edge of panel, always accessible */
#panel-collapse-tab {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 64px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: var(--fog-blur);
  -webkit-backdrop-filter: var(--fog-blur);
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 0 8px 8px 0;
  box-shadow: 4px 0 16px rgba(255, 255, 255, 0.2), 3px 0 10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background var(--transition), width var(--transition);
}

#panel-collapse-tab:hover {
  background: var(--primary-pale);
  width: 28px;
}

.collapse-arrow {
  color: var(--text-light);
  transition: transform var(--transition), color var(--transition);
}

#side-panel.collapsed .collapse-arrow {
  transform: rotate(180deg);
}

#panel-collapse-tab:hover .collapse-arrow {
  color: var(--primary);
}

/* ============================================================
   7. PANEL CONTENT — SHARED
   ============================================================ */
.panel-section {
  padding: 2rem 1.75rem 3rem;
}

.panel-eyebrow {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.panel-title {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 900;
  color: var(--text-dark);
  line-height: 1.15;
  margin-bottom: 0.9rem;
}

.panel-lead {
  font-size: 0.92rem;
  color: var(--text-medium);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.panel-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.07);
  margin: 1.75rem 0;
}

/* Panel loading state */
.panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: var(--text-light);
  font-size: 0.85rem;
}

.panel-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   8. OVERVIEW PANEL
   ============================================================ */
.panel-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.pstat {
  background: var(--primary-pale);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.pstat-num {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.pstat-label {
  font-size: 0.72rem;
  color: var(--text-medium);
  line-height: 1.3;
}

.panel-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: #FFF8E1;
  border: 1px solid #F9A82540;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  color: var(--text-medium);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.hint-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

.panel-about h3 {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.72rem;
}

.panel-about p {
  font-size: 0.83rem;
  color: var(--text-medium);
  line-height: 1.65;
  margin-bottom: 0.5rem;
}

.cta-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform 0.15s;
}

.btn-primary:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  background: transparent;
  color: var(--text-medium);
  border: 1.5px solid rgba(0,0,0,0.15);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}

/* ============================================================
   9. SPECIES PANEL
   ============================================================ */
.species-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-btn {
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1.5px solid rgba(0,0,0,0.15);
  color: var(--text-medium);
  background: transparent;
  transition: all 0.2s;
  cursor: pointer;
}

.filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}

.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.species-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.species-card {
  background: #FAFAFA;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius);
  padding: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  animation: cardIn 0.3s ease both;
}

.species-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--primary);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Species card photo strip (replaces the old 40×40 emoji icon) ── */
.species-card-photo-wrap {
  /* negative margins to bleed to card edges, then padding resumes below */
  width: calc(100% + 1.8rem);
  margin: -0.9rem -0.9rem 0.75rem;
  height: 110px;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.species-card-photo-bg {
  /* shown while photo loads — coloured by kingdom */
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.species-card-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.species-card-photo.loaded { opacity: 1; }

/* Keep the old .species-icon for the modal header — it uses a different size */
.species-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 0.15rem;
}

.species-info { display: flex; flex-direction: column; flex: 1; }

.species-badges {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 0.3rem;
}

.badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  text-transform: uppercase;
}

.endemic-badge {
  background: #FFF8E1;
  color: #B8860B;
  border-color: #F9A82555;
}

.species-common-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.25;
  margin-bottom: 0.1rem;
}

.species-scientific-name {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--text-light);
  line-height: 1.2;
  margin-bottom: 0.2rem;
}

.species-description-short {
  font-size: 0.72rem;
  color: var(--text-medium);
  line-height: 1.45;
  margin-top: auto;
}

.no-results, .species-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--text-medium);
  font-size: 0.88rem;
}

/* ============================================================
   9b. SPECIES PANEL — MAP THEME SELECTOR & HEX LEGEND
   ============================================================ */

/* Small uppercase label used as sub-section headings inside the species panel */
.species-section-label {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

/* Wrapper card for the map-theme selector + legend */
.species-map-section {
  background: #F8F9FA;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

/* Three theme-picker pills */
.species-theme-selector {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.theme-btn {
  padding: 0.28rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 500;
  border: 1.5px solid rgba(0,0,0,0.14);
  color: var(--text-medium);
  background: white;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
}

.theme-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}

.theme-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Generic hidden utility (JS toggles .hidden to show/hide sub-sections) */
.hidden { display: none !important; }

/* Animal / Plant sub-filter — shown only when "Species Points" theme is active */
.species-points-filter {
  margin-bottom: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(0,0,0,0.07);
}

.points-filter-btns {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.pts-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.73rem;
  font-weight: 500;
  border: 1.5px solid rgba(0,0,0,0.14);
  color: var(--text-medium);
  background: white;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
}

.pts-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-pale);
}

.pts-btn.active {
  background: var(--text-dark);
  color: white;
  border-color: var(--text-dark);
}

/* Tiny circle swatch inside the pts-btn */
.pts-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Hex theme time slider (below legend, for richness/count/decade themes) ── */
.hex-time-section {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(0,0,0,0.07);
}

/* ── GBIF hex marker — override Leaflet's default icon wrapper ── */
.gbif-hex-marker {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  /* Fixes Leaflet adding a white square behind divIcons */
  box-shadow: none !important;
}

/* ── Time slider (inside #species-points-filter) ── */
.timeslider-section {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(0,0,0,0.07);
}

.ts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.ts-decade-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-pale);
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.55rem;
  letter-spacing: 0.01em;
}

.ts-track-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

/* Range input track */
.ts-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(0,0,0,0.14);
  outline: none;
  cursor: pointer;
  accent-color: var(--primary);
}

.ts-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.18);
  cursor: pointer;
}

.ts-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.18);
  cursor: pointer;
}

/* Tick labels under the slider */
.ts-marks {
  display: flex;
  justify-content: space-between;
  font-size: 0.63rem;
  color: var(--text-light);
  padding: 0 1px;
}

/* Play / Pause button */
.ts-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.6rem;
  padding: 0.28rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.73rem;
  font-weight: 600;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: white;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  letter-spacing: 0.02em;
}

.ts-play-btn:hover,
.ts-play-btn.playing {
  background: var(--primary);
  color: white;
}

/* Legend container — fades in when theme changes */
.species-hex-legend {
  transition: opacity 0.22s ease;
}

/* Horizontal ramp for class-break themes */
.hex-legend-ramp,
.hex-legend-unique {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.7rem;
  align-items: center;
}

.hex-legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hex-legend-swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.12);
  flex-shrink: 0;
}

.hex-legend-label {
  font-size: 0.72rem;
  color: var(--text-medium);
  white-space: nowrap;
}

/* ============================================================
   10. TIMELINE PANEL
   ============================================================ */
.time-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.time-btn {
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1.5px solid rgba(0,0,0,0.15);
  color: var(--text-medium);
  background: transparent;
  transition: all 0.2s;
  cursor: pointer;
}

.time-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.time-btn.active {
  color: white;
  border-color: transparent;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  font-size: 0.74rem;
  color: var(--text-medium);
  margin: 0.75rem 0;
  align-items: center;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 3px;
  vertical-align: middle;
}

#record-count {
  font-size: 0.82rem;
  color: var(--text-medium);
  margin: 0.25rem 0 0.75rem;
}

.chart-container {
  width: 100%;
  position: relative;
  height: 180px;
  margin-bottom: 1.25rem;
}

.insight-box {
  background: var(--primary-pale);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  margin-top: 0.5rem;
}

.insight-box h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.insight-box p {
  font-size: 0.8rem;
  color: var(--text-medium);
  line-height: 1.6;
}

/* ============================================================
   11. THREATS PANEL
   ============================================================ */
.layer-controls {
  background: #FAFAFA;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.layer-controls h4 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-medium);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  transition: color 0.2s;
}

.layer-toggle:last-child { border-bottom: none; }

.layer-toggle:hover { color: var(--text-dark); }

.layer-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-label { font-size: 0.85rem; }
.toggle-label.agriculture { color: #E65100; }
.toggle-label.fire        { color: var(--accent-red); }
.toggle-label.urban       { color: #455A64; }
.toggle-label.mining      { color: #795548; }

.threat-stats-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.threat-stat {
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  color: var(--text-medium);
  line-height: 1.5;
  border-left: 4px solid transparent;
}

.threat-stat strong {
  display: block;
  font-size: 1.25rem;
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.threat-stat.agriculture { background: #FFF8E1; border-color: #F9A825; }
.threat-stat.agriculture strong { color: #E65100; }
.threat-stat.fire        { background: #FDECEA; border-color: #C0392B; }
.threat-stat.fire strong { color: #C0392B; }
.threat-stat.urban       { background: #ECEFF1; border-color: #455A64; }
.threat-stat.urban strong { color: #455A64; }
.threat-stat.mining      { background: #EFEBE9; border-color: #795548; }
.threat-stat.mining strong { color: #795548; }

/* ============================================================
   12. URGENCY PANEL
   ============================================================ */
.urgency-legend-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-medium);
}

.legend-color {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
}

.chart-wrapper { position: relative; height: 200px; }

.risk-profiles { margin-top: 1.25rem; }

.risk-profiles h4 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.risk-card {
  background: #FAFAFA;
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}

.risk-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.risk-badge.very-high { background: #FDECEA; color: #C0392B; }
.risk-badge.high      { background: #FEF3E2; color: #E67E22; }
.risk-badge.moderate  { background: #E8F8EF; color: #1B5E3B; }

.risk-card h5 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.3rem;
}

.risk-card p {
  font-size: 0.8rem;
  color: var(--text-medium);
  line-height: 1.55;
  margin-bottom: 0.5rem;
}

.risk-threats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.risk-threats span {
  font-size: 0.72rem;
  background: rgba(0,0,0,0.05);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  color: var(--text-medium);
}

/* ============================================================
   13. ABOUT PANEL
   ============================================================ */
.data-source-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-source-item {
  display: flex;
  flex-direction: column;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: white;
}

.data-source-item:last-child { border-bottom: none; }
.data-source-item:nth-child(even) { background: #FAFAFA; }

.data-source-item strong {
  font-size: 0.82rem;
  color: var(--text-dark);
  font-weight: 600;
  margin-bottom: 0.1rem;
}

.data-source-item span {
  font-size: 0.75rem;
  color: var(--text-light);
}

.about-panel h4 {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

.limitation-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.limitation-item {
  background: #FAFAFA;
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  border-left: 3px solid rgba(0,0,0,0.1);
}

.limitation-item strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dark);
  margin-bottom: 0.2rem;
}

.limitation-item p {
  font-size: 0.78rem;
  color: var(--text-medium);
  line-height: 1.55;
}

.citation-box {
  background: var(--primary-pale);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.78rem;
  color: var(--text-medium);
  line-height: 1.6;
}

.citation-box em { color: var(--primary); font-style: normal; font-weight: 600; }

/* ============================================================
   14. MAP LAYERS DROPDOWN
   ============================================================ */
#layers-dropdown {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  right: 16px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: var(--fog-blur);
  -webkit-backdrop-filter: var(--fog-blur);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  width: 278px;
  box-shadow: 0 8px 40px rgba(255, 255, 255, 0.2), var(--shadow-lg);
  z-index: 580;
  border: 1px solid rgba(255, 255, 255, 0.5);
  animation: dropIn 0.2s ease;
}

#layers-dropdown.hidden { display: none; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.layers-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(0,0,0,0.07);
}

.layers-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0;
  cursor: default;
  font-size: 0.83rem;
  color: var(--text-medium);
  border-radius: 6px;
  transition: color 0.2s;
  position: relative;
}

.layer-row:hover { color: var(--text-dark); }

/* ── Drag handle ── */
.drag-handle {
  font-size: 14px;
  line-height: 1;
  color: #bbb;
  cursor: grab;
  flex-shrink: 0;
  padding: 0 1px;
  transition: color 0.15s;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.layer-row:hover .drag-handle { color: #888; }

/* ── Dragging state ── */
.layer-row.dragging {
  opacity: 0.35;
}

/* ── Drop insertion indicators ── */
.layer-row.drag-over-top {
  box-shadow: 0 -2px 0 0 #C8A840;
}
.layer-row.drag-over-bot {
  box-shadow: 0 2px 0 0 #C8A840;
}

/* ── Label (swatch + text) fills remaining space ── */
.layer-row-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.layer-row-label span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.layer-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

/* ── Per-layer opacity slider — hidden until row is hovered ── */
.layer-opacity-slider {
  width: 52px;
  flex-shrink: 0;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0,0,0,0.18);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.layer-row:hover .layer-opacity-slider { opacity: 1; }

.layer-opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #C8A840;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
}
.layer-opacity-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #C8A840;
  border: none;
  cursor: pointer;
}

/* Auto-zoom badge on layer rows (e.g. "zoom 8+") */
.layer-zoom-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  color: #9AA5B4;
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  padding: 1px 5px;
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-left: 3px;
  white-space: nowrap;
}

/* Section divider inside the layers dropdown (e.g. "Basemap") */
.layers-divider {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9AA5B4;
  padding: 10px 0 4px;
  border-top: 1px solid rgba(0,0,0,0.07);
  margin-top: 6px;
}

/* ============================================================
   15. BOTTOM DATA STRIP
   ============================================================ */
#data-strip {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 32px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: var(--fog-blur);
  -webkit-backdrop-filter: var(--fog-blur);
  border-top: 1px solid rgba(255, 255, 255, 0.5);
  z-index: 490;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-medium);
}

.data-strip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.data-strip-dot.green  { background: var(--primary); }
.data-strip-dot.blue   { background: #2874A6; }
.data-strip-dot.orange { background: #E67E22; }
.data-strip-dot.red    { background: var(--accent-red); }

.data-strip-sep { color: rgba(0,0,0,0.2); }
.data-strip-credits { color: var(--text-light); }

/* ============================================================
   16. SPECIES MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: white;
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 1.1rem;
  right: 1.25rem;
  font-size: 1.6rem;
  color: var(--text-light);
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  z-index: 1;
}
.modal-close:hover { color: var(--text-dark); background: rgba(0,0,0,0.05); }

.mini-map {
  height: 240px;
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 1rem;
  border: 1px solid rgba(0,0,0,0.08);
}

/* Modal species layout */
.modal-species-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.modal-species-icon {
  font-size: 2.2rem;
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-species-title { flex: 1; }
.modal-badges { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.4rem; }

.modal-common-name {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: 1.4rem;
  color: var(--text-dark);
  margin: 0.25rem 0 0.15rem;
  font-weight: 700;
}

.modal-scientific-name {
  font-style: italic;
  color: var(--text-light);
  font-size: 0.92rem;
  font-weight: 400;
}

.modal-description {
  font-size: 0.9rem;
  color: var(--text-medium);
  line-height: 1.75;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.07);
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  background: var(--primary-pale);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.modal-stat { text-align: center; display: flex; flex-direction: column; gap: 0.25rem; }

.modal-stat .stat-val {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.modal-stat .stat-lbl {
  font-size: 0.68rem;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.modal-paramos, .modal-altitude {
  font-size: 0.84rem;
  color: var(--text-medium);
  margin-bottom: 0.5rem;
}

.modal-paramos strong, .modal-altitude strong { color: var(--text-dark); }

.modal-map-heading {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 1rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-occurrence-count {
  font-size: 0.76rem;
  color: var(--text-light);
}

.modal-attribution {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 0.6rem;
  line-height: 1.6;
}

.time-legend {
  display: inline-flex;
  gap: 0.5rem;
  margin-left: 0.4rem;
  flex-wrap: wrap;
  font-size: 0.7rem;
}

/* ============================================================
   17. LEAFLET OVERRIDES
   ============================================================ */
.leaflet-container {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif !important;
}

/* ── Popup/tooltip hoist overlay ─────────────────────────────────────────────
   Lives as the last child of #map-main, after all GL canvases.
   z=9000 guarantees it paints above #vector-tile-gl (z=450) and
   #threats-vt-gl (z=460) whose positive z-indexes would otherwise
   bury .leaflet-map-pane's stacking context (which has z-index:auto).
   pointer-events:none lets map clicks pass through; Leaflet re-enables
   pointer-events on .leaflet-popup itself via its own stylesheet.        */
#map-popup-overlay {
  position: absolute;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  overflow: visible;   /* popups that extend outside the map area must still show */
}

/* Panes inside the overlay are absolute-positioned from the overlay's top-left,
   same coordinate space as they had inside .leaflet-map-pane. */
#map-popup-overlay .leaflet-pane {
  position: absolute;
  top: 0;
  left: 0;
}

/* Re-enable pointer events on the actual popup and tooltip elements so they
   remain interactive even though the parent overlay has pointer-events:none. */
#map-popup-overlay .leaflet-popup,
#map-popup-overlay .leaflet-popup-content-wrapper,
#map-popup-overlay .leaflet-popup-tip-container,
#map-popup-overlay .leaflet-popup-close-button,
#map-popup-overlay .leaflet-tooltip {
  pointer-events: auto;
}

/* Fire point DivIcon — raw SVG cross, no white box or border */
.fire-pt-icon {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  border: none !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif !important;
  font-size: 13px !important;
  line-height: 1.6 !important;
  margin: 0 !important;
  padding: 1px !important;
}

.leaflet-popup-tip-container { display: none; }

.leaflet-bar {
  border-radius: var(--radius) !important;
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  overflow: hidden;
}

.leaflet-bar a {
  color: var(--text-dark) !important;
  font-size: 16px !important;
  line-height: 26px !important;
  border-bottom: 1px solid rgba(0,0,0,0.07) !important;
}

.leaflet-bar a:hover {
  background: var(--primary-pale) !important;
  color: var(--primary) !important;
}

.leaflet-control-zoom {
  margin-right: 12px !important;
  margin-bottom: 40px !important;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,0.75) !important;
  backdrop-filter: blur(4px);
  margin-bottom: 35px !important;
}

/* ── Scale bar ─────────────────────────────────────────────── */
.leaflet-control-scale {
  margin-left: 14px !important;
  margin-bottom: 40px !important;
}

/* When terrain cross-section is open, push scale bar + north arrow above it */
body.terrain-active .leaflet-control-scale {
  margin-bottom: calc(var(--profile-h) + var(--data-strip-h) + 14px) !important;
}

.leaflet-control-scale-line {
  background: rgba(255, 255, 255, 0.82) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: #555 !important;
  border-width: 1.5px !important;
  font-family: system-ui, -apple-system, sans-serif !important;
  font-size: 10px !important;
  color: #222 !important;
  padding: 2px 7px 1px !important;
  box-shadow: 0 1px 6px rgba(0,0,0,0.16);
}

/* Second line (miles) has top border that forms the ruler tick */
.leaflet-control-scale-line:not(:first-child) {
  border-top-color: #555 !important;
  margin-top: 1px;
}

/* ── North arrow ───────────────────────────────────────────── */
.north-arrow-ctrl {
  margin-left: 14px !important;
  /* sits above the scale bar — Leaflet bottomleft stacks upward */
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  padding: 6px 8px 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.14);
  line-height: 0;   /* remove extra space below inline SVG */
}

/* ============================================================
   18. PARAMO POPUP (custom styled)
   ============================================================ */
.paramo-popup {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  min-width: 200px;
  max-width: 260px;
  padding: 0.9rem 1rem;
}

.paramo-popup h3 {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.paramo-popup p {
  font-size: 0.78rem;
  color: var(--text-medium);
  margin-bottom: 0.2rem;
  line-height: 1.45;
}

.paramo-popup .protection-badge {
  display: inline-block;
  margin-top: 0.4rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--primary-pale);
  color: var(--primary);
  border: 1px solid #A5D6A7;
}

/* ============================================================
   19. RESPONSIVE — TABLET (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root { --panel-w: 360px; }

  .tn-center {
    gap: 0;
  }

  .tn-item {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }

  .logo-sub { display: none; }
}

/* ============================================================
   19b. THREATS IN THE NEWS — floating news panel
   Floats in the top-right corner of #map-main while the
   Threats tab is active.  z-index: 451 keeps it above the
   VectorTile GL canvas (z=450) but below the popup overlay (z=9000).
   ============================================================ */

/* Vanishing Clouds palette: cream/pale-green fog glass */
#th-news-panel {
  position: absolute;
  top: calc(var(--nav-h) + 8px);
  right: 12px;
  z-index: 451;
  width: 256px;
  background: rgba(248, 250, 245, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(200, 169, 75, 0.28);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(40, 60, 45, 0.16);
  font-family: var(--font-ui);
  color: var(--text-dark);
  overflow: hidden;
  pointer-events: all;
}

.th-news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.80rem 0.50rem;
  border-bottom: 1px solid rgba(200, 169, 75, 0.18);
  background: rgba(255, 255, 255, 0.42);
}

.th-news-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dark);
}

.th-news-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.th-news-toggle:hover {
  background: rgba(200, 169, 75, 0.14);
  color: var(--primary);
}

.th-news-body {
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(200, 169, 75, 0.25) transparent;
}

.th-news-body::-webkit-scrollbar { width: 4px; }
.th-news-body::-webkit-scrollbar-track { background: transparent; }
.th-news-body::-webkit-scrollbar-thumb {
  background: rgba(200, 169, 75, 0.28);
  border-radius: 2px;
}

/* Category filter row */
.th-news-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid rgba(200, 169, 75, 0.12);
  background: rgba(250, 248, 240, 0.55);
}

.th-news-cat {
  padding: 0.18rem 0.48rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(200, 169, 75, 0.30);
  background: rgba(27, 94, 59, 0.05);
  color: var(--text-medium);
  font-size: 0.64rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.th-news-cat:hover {
  background: rgba(200, 169, 75, 0.12);
  border-color: rgba(200, 169, 75, 0.55);
  color: var(--primary);
}

.th-news-cat.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Article list */
.th-news-list {
  display: flex;
  flex-direction: column;
}

.th-news-item {
  display: block;
  padding: 0.55rem 0.80rem;
  border-bottom: 1px solid rgba(200, 169, 75, 0.10);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}

.th-news-item:last-child {
  border-bottom: none;
}

.th-news-item:hover {
  background: rgba(200, 169, 75, 0.07);
}

.th-news-item-top {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.th-news-icon {
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.th-news-item-title {
  font-size: 0.70rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.35;
}

.th-news-source {
  font-size: 0.62rem;
  color: #A07830;   /* warm gold — matches the Vanishing Clouds accent palette */
  margin-bottom: 0.25rem;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.th-news-desc {
  font-size: 0.65rem;
  color: var(--text-medium);
  line-height: 1.45;
}

.th-news-empty {
  padding: 0.75rem;
  font-size: 0.70rem;
  color: var(--text-light);
  text-align: center;
  margin: 0;
}

/* On mobile, shrink/hide the news panel to avoid covering the sheet */
@media (max-width: 768px) {
  #th-news-panel {
    width: 210px;
    top: calc(var(--nav-h) + 6px);
    right: 8px;
  }

  .th-news-body {
    max-height: 210px;
  }
}

/* ============================================================
   20. RESPONSIVE — TABLET  (max-width: 900px)
   ============================================================ */
@media (max-width: 900px) {
  :root { --panel-w: 340px; }

  .tn-item {
    padding: 0.38rem 0.55rem;
    font-size: 0.76rem;
  }

  .tn-layers-btn {
    padding: 0.38rem 0.75rem;
    font-size: 0.76rem;
  }

  /* Threats mode buttons wrap at tablet */
  .th-mode-group {
    flex-wrap: wrap;
  }
  .th-mode-btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }
}

/* ============================================================
   21. RESPONSIVE — MOBILE  (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* ── Root overrides ─────────────────────────────────────── */
  :root {
    --panel-w:      100vw;
    --nav-h:        96px;   /* 2-row nav: 52px logo row + 44px tab row */
    --mob-peek-h:   68px;   /* height of bottom-sheet peek strip */
    --mob-sheet-h:  62vh;   /* height of fully-expanded bottom sheet */
  }

  /* ── Top navigation — two-row layout ─────────────────────── */
  /* Row 1: logo (.tn-left) + layers (.tn-right)               */
  /* Row 2: horizontally scrollable tab bar (.tn-center)        */
  /*                                                             */
  /* DOM order is: .tn-left → .tn-center → .tn-right           */
  /* CSS order overrides put .tn-right on row 1, tabs on row 2. */
  #top-nav {
    height: auto;           /* allow two rows */
    flex-wrap: wrap;
    padding: 0 0.75rem;
    gap: 0;
    align-items: stretch;
  }

  /* Row 1 items */
  .tn-left {
    order: 1;
    flex: 1;
    min-width: 0;
    height: 52px;
    align-items: center;
  }

  .tn-right {
    order: 2;
    flex-shrink: 0;
    height: 52px;
    align-items: center;
  }

  /* Hamburger is no longer needed — tab bar replaces it */
  .tn-hamburger { display: none !important; }

  /* Row 2: full-width horizontally scrollable tab bar */
  .tn-center {
    order: 3;               /* forces onto its own row after row-1 items */
    display: flex !important;   /* override display:none */
    width: 100%;
    flex: none;
    height: 44px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;      /* Firefox */
    border-top: 1px solid var(--nav-border);
    padding: 0 0.5rem;
    gap: 0;
    align-items: center;
    justify-content: flex-start; /* left-align so tabs scroll */
  }
  .tn-center::-webkit-scrollbar { display: none; }

  /* Tab items: must not shrink so the row stays scrollable */
  .tn-item {
    flex: 0 0 auto;
    padding: 0.32rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 6px;
  }

  /* Map Layers: keep visible but shrink to icon-only pill */
  .tn-layers-btn {
    display: flex;
    padding: 0.38rem 0.55rem;
    gap: 0;
  }
  .tn-layers-btn .layers-btn-label { display: none; }
  .tn-layers-btn .chevron { display: none; }

  /* ── Mobile nav drawer — hidden: scrollable tab bar replaces it ── */
  /* The drawer is still injected by initMobile() JS but is no longer
     needed or accessible (hamburger is hidden). Hide it unconditionally
     so the translateY(-110%) trick cannot leak into the viewport when
     --nav-h is taller than the drawer's own height allows. */
  #mob-nav-drawer {
    display: none !important;
  }

  .mob-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
  }

  .mob-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.7rem 0.4rem 0.6rem;
    border-radius: 10px;
    background: var(--primary-pale);
    border: 1.5px solid transparent;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-medium);
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, color 0.18s;
    line-height: 1.2;
    text-align: center;
  }
  .mob-nav-btn svg { flex-shrink: 0; }
  .mob-nav-btn.active {
    background: rgba(27,94,59,0.13);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
  }
  .mob-nav-btn:active { transform: scale(0.96); }

  /* ── Layers dropdown: full-width on mobile ───────────────── */
  #layers-dropdown {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--nav-h);
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  }

  /* ── Bottom sheet panel ──────────────────────────────────── */
  #side-panel {
    position: fixed;
    top: auto;
    bottom: var(--data-strip-h);
    left: 0;
    right: 0;
    width: 100%;
    height: var(--mob-sheet-h);
    max-height: calc(100vh - var(--nav-h) - var(--data-strip-h) - 8px);
    /* Default: peek state — only mob-peek-h of panel is visible */
    transform: translateY(calc(100% - var(--mob-peek-h)));
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -6px 32px rgba(0,0,0,0.18);
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* Expanded: slide fully into view */
  #side-panel.expanded {
    transform: translateY(0);
  }

  /* .collapsed on mobile also means peek (not hidden off left edge) */
  #side-panel.collapsed {
    transform: translateY(calc(100% - var(--mob-peek-h)));
  }

  /* ── Peek bar (injected by initMobile JS) ────────────────── */
  #mob-peek-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px 0;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    min-height: var(--mob-peek-h);
    justify-content: flex-start;
  }

  #mob-peek-pill {
    width: 38px;
    height: 4px;
    border-radius: 99px;
    background: rgba(0,0,0,0.2);
    margin-bottom: 9px;
    flex-shrink: 0;
  }

  #mob-peek-title {
    font-size: 0.80rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: 0.01em;
  }

  #mob-peek-hint {
    font-size: 0.66rem;
    color: var(--text-light);
    margin-top: 3px;
  }

  /* Desktop collapse tab hidden on mobile (peek bar replaces it) */
  #panel-collapse-tab { display: none; }

  /* Panel scroll: remaining height, touch-friendly */
  #panel-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Data strip ──────────────────────────────────────────── */
  #data-strip {
    font-size: 0.62rem;
    gap: 0.35rem;
    padding: 0 0.6rem;
  }
  .data-strip-credits { display: none; }

  /* ── Popups ──────────────────────────────────────────────── */
  .leaflet-popup-content-wrapper {
    max-width: 280px !important;
  }
  .leaflet-popup-content {
    max-width: 260px !important;
    margin: 8px 10px !important;
    font-size: 13px !important;
  }

  /* ── Scale bar + north arrow above sheet peek ────────────── */
  .leaflet-control-scale {
    margin-bottom: calc(var(--mob-peek-h) + var(--data-strip-h) + 8px) !important;
  }
  /* terrain-active override also applies — sheet peek is always higher */
  body.terrain-active .leaflet-control-scale {
    margin-bottom: calc(var(--mob-peek-h) + var(--data-strip-h) + 8px) !important;
  }

  /* ── Threats controls ────────────────────────────────────── */
  .th-mode-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .th-mode-btn {
    font-size: 0.73rem;
    padding: 0.45rem 0.5rem;
    text-align: left;
  }
  .th-year-group {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .th-year-btn { flex: 1 1 auto; }

  .th-cat-group { flex-wrap: wrap; }
  .th-cat-btn {
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }

  /* ── Build panel ─────────────────────────────────────────── */
  .bp-layer-card-header { flex-wrap: wrap; gap: 0.4rem; }

  /* ── Grids ───────────────────────────────────────────────── */
  .species-grid        { grid-template-columns: 1fr 1fr; }
  .modal-stats-grid    { grid-template-columns: 1fr 1fr; }
  .panel-stats         { grid-template-columns: 1fr 1fr; }

  /* ── Panel padding ───────────────────────────────────────── */
  .panel-section { padding: 1.25rem 1.25rem 2rem; }

  /* ── Terrain profile on mobile ───────────────────────────── */
  #terrain-profile-panel {
    height: 110px;   /* shorter than desktop 142px */
  }
}

/* ============================================================
   22. RESPONSIVE — PHONE  (max-width: 600px)
   ============================================================ */
@media (max-width: 600px) {
  :root {
    --mob-peek-h:  64px;
    --mob-sheet-h: 65vh;
  }

  /* Tighten logo */
  .logo-sub  { display: none; }
  .logo-leaf { width: 26px; height: 26px; }
  .logo-title { font-size: 0.88rem; }

  /* Nav left side tighter */
  .tn-left { gap: 0.35rem; }

  /* Panel padding: tighter on small phones */
  .panel-section { padding: 1rem 1rem 1.75rem; }

  /* Threats modes: single column on smallest phones */
  .th-mode-group { grid-template-columns: 1fr; }

  /* Year selector: horizontally scrollable strip */
  .th-year-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .th-year-group::-webkit-scrollbar { display: none; }
  .th-year-btn { flex-shrink: 0; }

  /* Popup: even tighter */
  .leaflet-popup-content-wrapper { max-width: 260px !important; }
  .leaflet-popup-content         { max-width: 240px !important; }

  /* Species grid: single column */
  .species-grid { grid-template-columns: 1fr; }

  /* Layers dropdown full-width */
  #layers-dropdown { left: 0; right: 0; }

  /* Nav mobile grid: 2 columns instead of 3 */
  .mob-nav-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   23. TOUCH DEVICES — disable expensive hover effects
   ============================================================ */
@media (hover: none) {
  /* Tap feedback replaces hover */
  .tn-item:hover,
  .tn-layers-btn:hover,
  .th-mode-btn:hover,
  .th-year-btn:hover,
  .th-cat-btn:hover,
  .theme-btn:hover,
  .filter-btn:hover,
  .pts-btn:hover   { background: unset; color: unset; border-color: unset; }

  .tn-item:active         { background: var(--primary-pale); color: var(--primary); }
  .th-mode-btn:active     { background: rgba(27,94,59,0.08); }
  .th-year-btn:active     { background: rgba(200,168,64,0.12); }
  .mob-nav-btn:hover      { background: var(--primary-pale); }

  /* Skip zoom-blur on pinch — there is no scroll zoom on touch */
  #map-main.map-zooming { filter: none; }
}

/* ============================================================
   22. GBIF SPECIES PANEL EXTRAS
   ============================================================ */

/* Small description shown below theme selector for hex themes */
.theme-description {
  font-size: 0.76rem;
  color: var(--text-medium);
  font-style: italic;
  line-height: 1.5;
  margin: 0.45rem 0 0.55rem;
  padding: 0.5rem 0.7rem;
  background: rgba(27,94,59,0.055);
  border-left: 2px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── Species legend toggle section ── */
.species-legend-section {
  margin-top: 0.75rem;
  border-top: 1px solid rgba(0,0,0,0.07);
  padding-top: 0.6rem;
}

.species-legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--primary);
  padding: 0.3rem 0;
  cursor: pointer;
  background: none;
  border: none;
  letter-spacing: 0.01em;
}
.species-legend-toggle:hover { color: var(--primary-light); }

.sp-legend-arrow {
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 0.2s;
  color: var(--text-light);
}

/* ── Species rows inside the legend list ── */
.gbif-species-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 0.4rem;
  padding-right: 2px;
  /* thin scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.18) transparent;
}
.gbif-species-list::-webkit-scrollbar { width: 4px; }
.gbif-species-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 2px; }

.gbif-sp-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.gbif-sp-row:hover { background: rgba(27,94,59,0.07); }

.gbif-sp-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.gbif-sp-names {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.gbif-sp-common {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gbif-sp-sci {
  font-size: 0.67rem;
  font-style: italic;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gbif-sp-iucn {
  font-size: 0.63rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  flex-shrink: 0;
  white-space: nowrap;
}

.sp-list-loading {
  font-size: 0.74rem;
  color: var(--text-light);
  font-style: italic;
  padding: 0.4rem 0;
}

/* ── Modal species photo — contained image, no negative-margin bleed ── */
.modal-photo-wrap {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
  background: #dce8dc;
  position: relative;
  /* height is driven by the <img> — no fixed height so portrait photos show fully */
}

.modal-photo-spinner {
  padding: 2rem 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
}

.modal-species-photo {
  width: 100%;
  height: auto;
  max-height: 300px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius);
}

.modal-photo-credit {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.44);
  color: rgba(255,255,255,0.9);
  font-size: 0.65rem;
  padding: 3px 8px;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── GBIF point modal info section ── */
.modal-gbif-name {
  font-size: 1.15rem;
  font-weight: 700;
  font-style: italic;
  margin-bottom: 0.8rem;
  line-height: 1.3;
}

.modal-gbif-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.modal-gbif-table td {
  padding: 4px 0;
  vertical-align: top;
}
.modal-gbif-table td:first-child {
  color: var(--text-light);
  width: 40%;
}
.modal-gbif-table td:last-child {
  font-weight: 600;
  color: var(--text-dark);
}

/* ============================================================
   23. SCROLL REVEAL (panel content)
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   24. TERRAIN CROSS-SECTION EXPLORER
   Draggable gold crosshair + scientific elevation profile panel
   ============================================================ */

/* Outer wrapper — pointer-events none so the Leaflet map stays fully interactive */
#terrain-explorer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 460;
  transition: opacity 0.3s;
}

#terrain-explorer.hidden {
  display: none;
}

/* ── Draggable crosshair line ── */
#terrain-crosshair {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;           /* Zero-height — children positioned relative to this */
  pointer-events: none;
}

#terrain-crosshair-line {
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent            0%,
    rgba(200,169,107,0.10) 3%,
    rgba(200,169,107,0.65) 8%,
    #C8A96B                18%,
    #C8A96B                82%,
    rgba(200,169,107,0.65) 92%,
    rgba(200,169,107,0.10) 97%,
    transparent            100%
  );
  cursor: ns-resize;
  pointer-events: all;
  transition: box-shadow 0.2s, opacity 0.2s;
}

#terrain-crosshair-line:hover,
#terrain-crosshair-line.dragging {
  box-shadow: 0 0 0 5px rgba(200,169,107,0.12), 0 0 12px rgba(200,169,107,0.20);
}

/* Left / right end tick marks */
#terrain-crosshair::before,
#terrain-crosshair::after {
  content: '';
  position: absolute;
  top: -5px;
  width: 1px;
  height: 10px;
  background: rgba(200,169,107,0.55);
  pointer-events: none;
}
#terrain-crosshair::before { left: 0; }
#terrain-crosshair::after  { right: 0; }

/* Latitude badge — positioned right of the crosshair line */
#terrain-crosshair-handle {
  position: absolute;
  top: -14px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(10,14,18,0.88);
  border: 1px solid rgba(200,169,107,0.65);
  border-radius: 4px;
  padding: 3px 9px 3px 6px;
  cursor: ns-resize;
  pointer-events: all;
  user-select: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#terrain-crosshair-handle:hover,
#terrain-crosshair-handle.dragging {
  border-color: #C8A96B;
  box-shadow: 0 2px 12px rgba(200,169,107,0.25);
}

.crosshair-handle-icon {
  width: 11px;
  height: 11px;
  opacity: 0.8;
  flex-shrink: 0;
}

#terrain-crosshair-lat {
  font-size: 0.70rem;
  font-family: 'Courier New', Courier, monospace;
  color: #C8A96B;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Profile panel — scientific elevation cross-section ── */
#terrain-profile-panel {
  position: absolute;
  bottom: var(--data-strip-h);   /* sit flush above #data-strip */
  left: 0;
  right: 0;
  height: var(--profile-h);
  /* Pale green-cream — matches the site's Audubon palette */
  background: rgba(245, 248, 242, 0.94);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  border-top: 1px solid rgba(190,170,100,0.30);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.07);
  pointer-events: all;
  display: flex;
  flex-direction: column;
  transition: opacity 0.25s;
}

#terrain-profile-panel.tp-loading {
  opacity: 0.65;
}

/* Header */
#terrain-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px 4px;
  border-bottom: 1px solid rgba(90,110,90,0.10);
  flex-shrink: 0;
}

.tp-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

#terrain-profile-title {
  font-size: 0.66rem;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-medium);
  opacity: 0.75;
}

.tp-sep {
  color: rgba(90,110,90,0.30);
  font-size: 0.7rem;
}

.tp-lat-readout {
  font-size: 0.68rem;
  font-family: 'Courier New', Courier, monospace;
  color: #8B7035;   /* darker gold — readable on light background */
  letter-spacing: 0.04em;
}

#terrain-profile-close {
  background: none;
  border: none;
  color: rgba(74,85,104,0.35);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}
#terrain-profile-close:hover {
  color: rgba(74,85,104,0.80);
}

/* SVG canvas area */
#terrain-profile-svg-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#terrain-profile-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Loading overlay */
#terrain-profile-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(139,112,53,0.65);
  pointer-events: none;
  background: rgba(245,248,242,0.55);
}

#terrain-profile-loading.hidden {
  display: none;
}

/* ============================================================
   25. BUILD A PÁRAMO PANEL
   Interactive environmental suitability builder
   ============================================================ */

/* ── Intro card ── */
.bp-intro-card {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(232,245,233,0.90), rgba(255,248,225,0.80));
  border: 1px solid rgba(200,169,107,0.28);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.bp-intro-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.bp-intro-text strong {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.3rem;
}

.bp-intro-text p {
  font-size: 0.80rem;
  color: var(--text-medium);
  line-height: 1.6;
}

/* ── Status bar (layer count + reset) ── */
.bp-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.bp-layer-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.bp-layer-count[data-count="1"],
.bp-layer-count[data-count="2"],
.bp-layer-count[data-count="3"],
.bp-layer-count[data-count="4"] {
  color: var(--primary);
}

.bp-reset-btn {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-light);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0,0,0,0.12);
  background: transparent;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
  letter-spacing: 0.01em;
}

.bp-reset-btn:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background: rgba(192,57,43,0.06);
}

/* ── Environmental layer cards ── */
.bp-layers-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
}

.bp-layer-card {
  background: white;
  border: 1.5px solid rgba(0,0,0,0.08);
  border-left: 3px solid rgba(0,0,0,0.09);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem 0;
  transition: border-color 0.22s, box-shadow 0.22s, background 0.22s;
  overflow: hidden;
}

.bp-layer-card:hover {
  border-color: rgba(0,0,0,0.14);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.bp-layer-card.active {
  border-left-color: var(--layer-color, var(--primary));
  background: rgba(245,250,245,0.70);
  border-color: rgba(0,0,0,0.11);
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

/* Header row: icon | name+label | toggle switch */
.bp-layer-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.bp-layer-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.bp-layer-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding-top: 1px;
}

.bp-layer-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
  margin-bottom: 0.15rem;
}

.bp-layer-label {
  font-size: 0.71rem;
  color: var(--text-light);
  line-height: 1.3;
  white-space: normal;
}

/* Description paragraph */
.bp-layer-desc {
  font-size: 0.78rem;
  color: var(--text-medium);
  line-height: 1.65;
  margin-bottom: 0.75rem;
}

/* Thin colored bottom swatch bar — inherits --layer-color from .bp-layer-card */
.bp-layer-swatch {
  height: 3px;
  background: var(--layer-color, var(--primary));
  opacity: 0.18;
  margin: 0 -0.9rem;   /* bleed to card edges */
  transition: opacity 0.22s;
}

.bp-layer-card.active .bp-layer-swatch {
  opacity: 0.65;
}

/* ── Climate Match Score — derived-layer formula display ── */
.bp-layer-formula {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 4px;
}

.bp-formula-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-medium);
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  white-space: nowrap;
}

.bp-formula-chip.bp-formula-result {
  background: rgba(106, 27, 154, 0.08);
  border-color: rgba(106, 27, 154, 0.22);
  color: #4A148C;
}

.bp-formula-op {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  flex-shrink: 0;
}

/* ── iOS-style toggle switch ── */
.bp-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 3px;
}

.bp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.bp-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: rgba(0,0,0,0.18);
  transition: background 0.22s;
  display: flex;
  align-items: center;
  padding: 0 3px;
}

.bp-switch input:checked ~ .bp-switch-track {
  background: var(--primary);
}

.bp-switch-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.28);
  transition: transform 0.22s cubic-bezier(0.34,1.2,0.64,1);
  flex-shrink: 0;
}

.bp-switch input:checked ~ .bp-switch-track .bp-switch-thumb {
  transform: translateX(16px);
}

/* ── Composite section ── */
.bp-composite-section {
  margin-bottom: 0.75rem;
}

.bp-composite-desc {
  font-size: 0.80rem;
  color: var(--text-medium);
  line-height: 1.6;
  margin-bottom: 0.85rem;
}

.bp-composite-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.75rem 1.1rem;
  background: var(--primary-pale);
  border: 2px solid rgba(27,94,59,0.22);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  transition: background 0.22s, border-color 0.22s, color 0.22s, box-shadow 0.22s;
  letter-spacing: 0.01em;
  margin-bottom: 0.9rem;
  text-align: left;
}

.bp-composite-btn:disabled {
  opacity: 0.40;
  cursor: not-allowed;
}

.bp-composite-btn:not(:disabled):not(.active):hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 3px 14px rgba(27,94,59,0.22);
}

/* Active (composite is currently shown) */
.bp-composite-btn.active {
  background: linear-gradient(135deg, #B8940C, #D4AE38);
  color: white;
  border-color: #A88018;
  box-shadow: 0 3px 16px rgba(200,160,40,0.30);
}

.bp-composite-icon {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

/* Compare label row */
.bp-compare-label {
  margin-top: 0.1rem;
  font-size: 0.83rem;
}

.bp-compare-note {
  font-size: 0.73rem;
  color: var(--text-light);
  line-height: 1.5;
  margin-top: 0.3rem;
  padding-left: 1.85rem;  /* align with toggle text */
  font-style: italic;
}

/* ── Interpretation panel ── */
.bp-interpretation {
  margin-top: 0.85rem;
}

/* Suitability gradient legend */
.bp-suitability-legend {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.9rem;
  padding: 0 0.1rem;
}

.bp-suit-ramp {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(
    to right,
    #3E7D52,
    #7DBE8A,
    #D4C56A,
    #C8A040,
    #D4AE38
  );
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.10);
}

.bp-suit-label {
  font-size: 0.67rem;
  color: var(--text-light);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ── Placeholder notice ── */
.bp-placeholder-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  background: rgba(249,168,37,0.07);
  border: 1px solid rgba(249,168,37,0.22);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  font-size: 0.73rem;
  color: var(--text-medium);
  line-height: 1.55;
  margin-top: 1.1rem;
}

.bp-placeholder-icon {
  flex-shrink: 0;
  font-size: 0.85rem;
  margin-top: 1px;
}

.bp-placeholder-notice code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.68rem;
  background: rgba(0,0,0,0.07);
  padding: 0 4px;
  border-radius: 3px;
  color: var(--text-dark);
}

/* ── Equatorial Influence context card (permanent, non-toggleable) ── */
.bp-eq-context-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(200, 168, 64, 0.07);
  border: 1px solid rgba(200, 168, 64, 0.25);
  border-left: 3px solid #C8A840;
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-top: 0.75rem;
}

.bp-eq-context-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
  padding-top: 2px;
}

.bp-eq-context-text strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #8B6914;
  margin-bottom: 3px;
}

.bp-eq-context-text p {
  font-size: 0.76rem;
  color: var(--text-medium);
  line-height: 1.5;
  margin: 0;
}

/* ── Composite callout cluster markers ── */
.bp-composite-callout {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}

.bp-callout-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(27, 94, 59, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(27, 94, 59, 0.50);
}

.bp-callout-label {
  font-size: 9.5px;
  font-weight: 600;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: rgba(10, 60, 30, 0.90);
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow:
    0 1px 3px rgba(255, 255, 255, 0.95),
    0 0  8px rgba(255, 255, 255, 0.80);
}

/* ── Zoom control repositioning in Build a Páramo mode ──
   When #map-main has .map-build-mode, the Leaflet zoom control is re-added
   at 'topright' by maps.js. We push it below the nav bar (--nav-h) so it
   doesn't overlap the Map Layers button, and add a safe-guard right margin. */
#map-main.map-build-mode .leaflet-top.leaflet-right {
  top: calc(var(--nav-h) + 12px);
  right: 4px;
}

/* ── Floating layer legend — bottom-right of map, above zoom controls ── */
.bp-legend {
  position: fixed;
  bottom: 72px;
  right: 16px;
  z-index: 450;
  min-width: 158px;
  max-width: 196px;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 8px;
  padding: 10px 12px 9px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.13);
  pointer-events: none;   /* legend never intercepts map clicks */
  transition: opacity 0.22s ease;
}

.bp-legend-title {
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.bp-legend-bar {
  height: 8px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.bp-legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.63rem;
  color: var(--text-light);
  margin-bottom: 5px;
}

.bp-legend-desc {
  font-size: 0.67rem;
  color: var(--text-medium);
  line-height: 1.45;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  padding-top: 5px;
  margin-top: 3px;
}

/* ── Equator reference label (DivIcon on the map) ── */
.bp-equator-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.bp-equator-label span {
  display: block;
  font-size: 10px;
  font-weight: 600;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: rgba(200, 168, 64, 0.90);
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
  text-shadow:
    0 1px 4px rgba(0, 0, 0, 0.50),
    0 0 10px rgba(0, 0, 0, 0.30);
}

/* ── Threats VectorTileServer GL canvas ──
   Dedicated MapLibre GL overlay for ArcGIS VectorTileServer threat layers.
   Z=460: above Leaflet overlay pane (400) and the site's label/road
   vector tiles (450) so threat polygons draw on top of everything.
   IMPORTANT: never set display:none here — MapLibre GL initialises its
   WebGL canvas with the element's current dimensions; display:none gives
   a 0×0 canvas that never renders.  Visibility is controlled via opacity
   only; threats.js calls _thGlMap.resize() after the first show. */
#threats-vt-gl {
  position: absolute;
  inset: 0;
  z-index: 460;
  pointer-events: none;
  /* NO display:none — see note above */
  opacity: 0;
  transition: opacity 0.35s ease;
}

#threats-vt-gl .maplibregl-canvas-container,
#threats-vt-gl canvas {
  pointer-events: none !important;
}

/* ============================================================
   26. THREATS PANEL
   Land-cover change timeline and threat category explorer
   (MapBiomas Colombia — Phase 5)
   ============================================================ */

/* ── Intro card ── */
.th-intro-card {
  background: rgba(192, 57, 43, 0.05);
  border: 1px solid rgba(192, 57, 43, 0.15);
  border-left: 3px solid rgba(192, 57, 43, 0.50);
  border-radius: var(--radius);
  padding: 0.80rem 1rem;
  margin-bottom: 1.1rem;
}

.th-intro-card p {
  font-size: 0.79rem;
  color: var(--text-medium);
  line-height: 1.65;
  margin: 0;
}

/* ── Section labels ── */
.th-section-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text-light);
  text-transform: uppercase;
  margin: 0.95rem 0 0.42rem;
}

/* ── View mode buttons (full-width column) ── */
.th-mode-group {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.th-mode-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.50rem 0.85rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(0, 0, 0, 0.09);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--text-medium);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
  text-align: left;
  line-height: 1.3;
  width: 100%;
}

.th-mode-btn:hover {
  background: rgba(27, 94, 59, 0.06);
  border-color: rgba(27, 94, 59, 0.28);
  color: var(--primary);
}

.th-mode-btn.active {
  background: rgba(27, 94, 59, 0.10);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

/* ── Year selector pills ── */
.th-year-group {
  display: flex;
  gap: 0.30rem;
  flex-wrap: wrap;
}

.th-year-btn {
  padding: 0.27rem 0.70rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.68);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-medium);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.th-year-btn:hover {
  background: rgba(200, 168, 64, 0.12);
  border-color: #C8A840;
  color: #8B6914;
}

.th-year-btn.active {
  background: linear-gradient(135deg, #C8A840, #D4AE38);
  border-color: #A88018;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(200, 168, 64, 0.32);
}

/* ── Category selector — 2 × 2 grid ── */
.th-cat-section {
  /* display toggled by threats.js */
}

.th-cat-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.32rem;
}

.th-cat-btn {
  padding: 0.40rem 0.65rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(0, 0, 0, 0.09);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-medium);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
  line-height: 1.3;
}

.th-cat-btn:hover {
  border-color: var(--cat-color, #999);
  color: var(--cat-color, #555);
  background: rgba(255, 255, 255, 0.88);
}

/* Active state: solid fill using the category's --cat-color */
.th-cat-btn.active {
  background: var(--cat-color, #888);
  border-color: var(--cat-color, #888);
  color: #fff;
  font-weight: 700;
}

/* ── Mode context card ── */
.th-mode-context {
  margin-top: 0.90rem;
  padding: 0.72rem 0.90rem;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--radius);
  /* display toggled by threats.js */
}

.th-mode-context p {
  font-size: 0.79rem;
  color: var(--text-medium);
  line-height: 1.62;
  margin: 0;
}

/* ── Coming-soon card (fire placeholder) ── */
.th-coming-soon {
  text-align: center;
  padding: 0.4rem 0.2rem;
}

.th-coming-soon-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.th-coming-soon strong {
  display: block;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.42rem;
}

.th-coming-soon p {
  font-size: 0.77rem;
  color: var(--text-medium);
  line-height: 1.60;
  margin: 0;
}

/* ── Floating threat legend (position: fixed, bottom-right) ── */
.th-legend {
  position: fixed;
  bottom: 72px;
  right: 16px;
  z-index: 450;
  min-width: 165px;
  max-width: 208px;
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 8px;
  padding: 10px 12px 9px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.13);
  pointer-events: none;    /* legend never intercepts map clicks */
  display: none;           /* shown/hidden by threats.js */
  transition: opacity 0.22s ease;
}

.th-legend-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.th-legend-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 5px;
}

/* Muted rows used when layer is not yet published */
.th-legend-rows--muted {
  opacity: 0.45;
}

.th-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.67rem;
  color: var(--text-medium);
  line-height: 1.3;
}

.th-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Empty swatch: transparent box with border */
.th-swatch--empty {
  background: transparent !important;
  border: 1px solid #ccc;
}

.th-legend-note {
  font-size: 0.64rem;
  color: var(--text-light);
  line-height: 1.45;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  padding-top: 5px;
  margin-top: 3px;
}

/* Pending / layer-not-published note variant */
.th-legend-note--pending {
  color: #b03a30;
  font-style: italic;
  border-top-color: rgba(192, 57, 43, 0.15);
}

/* Land-cover legend — wider box + scrollable rows (18 MapBiomas classes) */
.th-legend--landcover {
  max-width: 252px;
  min-width: 210px;
}
.th-legend--landcover .th-legend-rows {
  max-height: min(55vh, 300px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
  padding-right: 2px;
}

/* ============================================================
   THREATS — FIRE PRESSURE UI
   Sub-mode buttons, year slider, play/pause
   ============================================================ */

/* Sub-mode button group */
.th-fire-mode-group {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.75rem;
}

.th-fire-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.40rem 0.75rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(0, 0, 0, 0.09);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-medium);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  text-align: left;
  line-height: 1.3;
  width: 100%;
}

.th-fire-btn:hover {
  background: rgba(194, 65, 12, 0.07);
  border-color: rgba(194, 65, 12, 0.35);
  color: #9a2d07;
}

.th-fire-btn.active {
  background: rgba(194, 65, 12, 0.11);
  border-color: #C2410C;
  color: #9a2d07;
  font-weight: 700;
}

/* Year slider row (range input + play button side by side) */
.th-fire-slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.28rem;
}

.th-fire-slider-row input[type="range"] {
  flex: 1;
  accent-color: #C2410C;
  height: 4px;
  cursor: pointer;
}

/* Play/pause button */
.th-play-btn {
  padding: 0.28rem 0.60rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid rgba(194, 65, 12, 0.45);
  background: rgba(194, 65, 12, 0.08);
  color: #9a2d07;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.th-play-btn:hover {
  background: rgba(194, 65, 12, 0.17);
  border-color: #C2410C;
}

/* Year range label below slider */
.th-fire-year-range {
  font-size: 0.67rem;
  color: var(--text-light);
  text-align: center;
  letter-spacing: 0.04em;
}

/* Fire points on/off toggle button */
.th-layer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.45rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.th-layer-toggle--on {
  border: 1.5px solid rgba(27, 94, 59, 0.40);
  background: rgba(27, 94, 59, 0.08);
  color: var(--accent-green);
}
.th-layer-toggle--on:hover  { background: rgba(27, 94, 59, 0.16); }
.th-layer-toggle--off {
  border: 1.5px solid rgba(150, 100, 60, 0.35);
  background: rgba(150, 100, 60, 0.07);
  color: var(--text-medium);
}
.th-layer-toggle--off:hover { background: rgba(150, 100, 60, 0.14); }

/* Circle swatch for fire points legend */
.th-swatch--circle {
  border-radius: 50%;
  width: 10px;
  height: 10px;
  min-width: 10px;
}

/* ── Build tip card ────────────────────────────────────────── */
.bp-tip-card {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: rgba(27,94,59,0.07);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
  padding: 0.65rem 0.9rem;
  margin-bottom: 1rem;
}
.bp-tip-card .bp-tip-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.bp-tip-card p {
  margin: 0;
  font-size: 0.80rem;
  color: var(--text-medium);
  line-height: 1.5;
}

/* ============================================================
   360° FIELD VIEW MARKERS
   ============================================================ */

/* Remove Leaflet's default white box around divIcon */
.v360-icon {
  background: none !important;
  border: none !important;
}

.v360-marker {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px 2px 4px;
  background: rgba(10, 30, 18, 0.78);
  border: 1px solid rgba(249, 168, 37, 0.52);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
  backdrop-filter: blur(3px);
}

.v360-marker:hover {
  background: rgba(10, 30, 18, 0.92);
  border-color: rgba(249, 168, 37, 0.9);
  transform: scale(1.12);
}

.v360-label {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #F9A825;
  line-height: 1;
}

/* At zoom ≥ 10, scale the icon up slightly so it's still readable when zoomed in */
#map-main.v360-z-high .v360-icon {
  transform: scale(1.18);
  transform-origin: center bottom;
}

/* Subtle pulse on the SVG circle — draws attention without being annoying */
.v360-marker svg circle:first-child {
  animation: v360Pulse 2.8s ease-in-out infinite;
  transform-origin: center;
}

@keyframes v360Pulse {
  0%,100% { opacity: 1;   r: 4; }
  50%      { opacity: 0.5; r: 5; }
}

/* ============================================================
   360° FIELD VIEW MODAL
   ============================================================ */

.v360-modal {
  position: absolute;
  bottom: calc(var(--data-strip-h) + 1rem);   /* always above data strip */
  right: 1.4rem;
  z-index: 8500;
  width: 280px;
  background: rgba(248, 250, 245, 0.97);
  border: 1px solid rgba(200, 169, 75, 0.35);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(20, 40, 28, 0.22);
  backdrop-filter: blur(10px);
  padding: 1.1rem 1.2rem 1.2rem;

  /* Slide-up entrance */
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.v360-modal--hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

/* Bump modal above terrain cross-section panel when it's open */
body.terrain-active .v360-modal {
  bottom: calc(var(--data-strip-h) + var(--profile-h) + 1rem);
}

.v360-modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 0.85rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.v360-modal-close:hover {
  color: var(--text-dark);
  background: rgba(0,0,0,0.06);
}

.v360-modal-kicker {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #A07830;
  margin: 0 0 0.35rem;
}

.v360-modal-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0 0 0.55rem;
  line-height: 1.2;
}

.v360-modal-desc {
  font-size: 0.76rem;
  color: var(--text-medium);
  line-height: 1.55;
  margin: 0 0 1rem;
}

.v360-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: background 0.18s, transform 0.15s;
}

.v360-modal-btn:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

/* On mobile: modal goes to bottom of screen, full width */
@media (max-width: 768px) {
  .v360-modal {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
  }
}

/* ============================================================
   URGENCY PROTOTYPE DASHBOARD
   ============================================================ */

/* Work-in-progress banner */
.urgency-proto-banner {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: rgba(200, 169, 75, 0.09);
  border: 1px solid rgba(200, 169, 75, 0.28);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.9rem;
}
.urgency-proto-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.urgency-proto-banner strong {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
}
.urgency-proto-banner p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-medium);
  line-height: 1.45;
}

/* Small "prototype" pill tag next to chart titles */
.urgency-proto-tag {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  background: rgba(200, 169, 75, 0.15);
  color: #9A7A20;
  border: 1px solid rgba(200, 169, 75, 0.30);
  border-radius: 999px;
  padding: 1px 6px;
  vertical-align: middle;
  margin-left: 6px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* Dashboard chart cards */
.urgency-chart-card {
  background: rgba(248, 250, 245, 0.70);
  border: 1px solid rgba(27, 94, 59, 0.10);
  border-radius: 10px;
  padding: 0.85rem 1rem 1rem;
  margin-bottom: 0.85rem;
}
.urgency-chart-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 0.18rem;
  letter-spacing: 0.01em;
}
.urgency-chart-sub {
  font-size: 0.68rem;
  color: var(--text-light);
  margin: 0 0 0.7rem;
  line-height: 1.35;
}

/* Zoom hint shown in the overview panel when zoom < VIEWS360_MIN_ZOOM */
.v360-zoom-hint {
  font-size: 0.72rem;
  color: var(--text-light);
  background: rgba(200, 169, 75, 0.08);
  border: 1px solid rgba(200, 169, 75, 0.2);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  margin: 0.5rem 0 0;
  opacity: 0.85;
  transition: opacity 0.2s;
}

/* ============================================================
   WELCOME / LANDING OVERLAY
   ============================================================ */

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  /* Dark-green fallback — JS overlays the B&W photo on top of this */
  background-color: #090F0B;
  /* Gradient wash set here; photo URL injected by initWelcomeScreen() in main.js
     so the path resolves relative to the HTML document, not the stylesheet. */
  background-size: cover;
  background-position: center 30%;

  /* Exit transition — opacity + blur + slight scale */
  transition:
    opacity 1.5s cubic-bezier(0.4, 0, 0.2, 1),
    filter  1.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: opacity, filter, transform;
}

/* Leaving state — triggered by JS */
.welcome-screen.leaving {
  opacity: 0;
  filter: blur(22px) brightness(1.6);
  transform: scale(1.04);
  pointer-events: none;
}

/* ── Fog layers ─────────────────────────────────────────── */
.welcome-fog {
  position: absolute;
  inset: -15%;
  pointer-events: none;
}

.welcome-fog--1 {
  background:
    radial-gradient(ellipse at 18% 25%, rgba(255,255,255,0.13) 0%, transparent 38%),
    radial-gradient(ellipse at 82% 68%, rgba(255,255,255,0.09) 0%, transparent 42%),
    radial-gradient(ellipse at 50% 80%, rgba(255,255,255,0.07) 0%, transparent 35%);
  animation: fogDrift1 20s ease-in-out infinite alternate;
}

.welcome-fog--2 {
  background:
    radial-gradient(ellipse at 70% 20%, rgba(255,255,255,0.08) 0%, transparent 40%),
    radial-gradient(ellipse at 30% 75%, rgba(255,255,255,0.06) 0%, transparent 35%);
  animation: fogDrift2 26s ease-in-out infinite alternate;
  opacity: 0.7;
}

@keyframes fogDrift1 {
  from { transform: translateX(-2.5%) translateY(1.5%) scale(1.01); }
  to   { transform: translateX( 2.5%) translateY(-1.5%) scale(0.99); }
}

@keyframes fogDrift2 {
  from { transform: translateX(1.5%) translateY(-2%) scale(0.98); }
  to   { transform: translateX(-1.5%) translateY(2%) scale(1.02); }
}

/* ── Content block ──────────────────────────────────────── */
.welcome-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 2rem 2.5rem;
  max-width: 680px;
  width: 100%;
}

.welcome-kicker {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: rgba(249, 168, 37, 0.80);   /* --accent-gold at 80% */
  text-transform: uppercase;
  margin: 0 0 1.2rem;
}

.welcome-title {
  font-family: "Helvetica Neue", HelveticaNeue, Helvetica, Arial, sans-serif;
  font-size: clamp(3.2rem, 10vw, 7rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.03em;
  color: #F5F0E8;   /* warm off-white */
  margin: 0 0 1rem;
  text-shadow: 0 2px 40px rgba(0,0,0,0.45);
}

.welcome-subtitle {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.1rem, 3.2vw, 1.55rem);
  font-weight: 400;
  font-style: italic;
  color: rgba(249, 168, 37, 0.90);
  letter-spacing: 0.04em;
  margin: 0 0 1.4rem;
}

.welcome-desc {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: clamp(0.80rem, 2vw, 0.95rem);
  font-weight: 400;
  color: rgba(240, 238, 230, 0.72);
  line-height: 1.7;
  letter-spacing: 0.02em;
  margin: 0 0 2.6rem;
}

/* Hide the <br> on very narrow screens so text reflows naturally */
.welcome-br { display: inline; }

/* ── Enter button ──────────────────────────────────────── */
.welcome-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 2.2rem;
  border-radius: 999px;
  border: 1.5px solid rgba(249, 168, 37, 0.60);
  background: rgba(249, 168, 37, 0.10);
  color: #F9E8A0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s, transform 0.2s, box-shadow 0.25s;
  box-shadow: 0 0 28px rgba(249, 168, 37, 0.08);
}

.welcome-btn:hover {
  background: rgba(249, 168, 37, 0.22);
  border-color: rgba(249, 168, 37, 0.90);
  box-shadow: 0 0 40px rgba(249, 168, 37, 0.22);
  transform: translateY(-2px);
}

.welcome-btn:active {
  transform: translateY(0);
}

.welcome-btn-arrow {
  font-size: 1rem;
  transition: transform 0.2s;
}

.welcome-btn:hover .welcome-btn-arrow {
  transform: translateX(4px);
}

/* ── Bottom credit ─────────────────────────────────────── */
.welcome-credit {
  position: absolute;
  bottom: 1.2rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.10em;
  color: rgba(255,255,255,0.28);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  pointer-events: none;
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .welcome-content {
    padding: 1.5rem 1.8rem;
  }
  .welcome-desc .welcome-br {
    display: none;
  }
  .welcome-btn {
    padding: 0.78rem 1.8rem;
    font-size: 0.82rem;
  }
  .welcome-credit {
    font-size: 0.58rem;
    bottom: 0.8rem;
  }
}
