/* ═══════════════════════════════════════════════════════════════
   Registro Arbóreo del Parque
   Mobile-first · Bottom Sheet · Syne + Nunito
═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────────── */
:root {
  --bg:          #0F2319;
  --surface:     #162D21;
  --surface-2:   #1D3829;
  --surface-3:   #254535;
  --emerald:     #34D399;
  --emerald-dim: #1a8060;
  --amber:       #FBBF24;
  --rose:        #F87171;
  --sky:         #38BDF8;
  --text:        #E8F5EE;
  --text-muted:  #78A892;
  --text-faint:  #3D6652;

  --font-display: 'Syne', sans-serif;
  --font-body:    'Nunito', sans-serif;

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-pill: 999px;

  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.22s;

  --sheet-peek-h: 64px;
  --sheet-half-h: 52vh;
  --sheet-full-h: 92vh;
  --topbar-h:     56px;

  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════════════════════
   MAPA
═══════════════════════════════════════════════════════════════ */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* ═══════════════════════════════════════════════════════════════
   BARRA SUPERIOR FLOTANTE
═══════════════════════════════════════════════════════════════ */
#topbar {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 12px;
  right: 12px;
  height: var(--topbar-h);
  background: rgba(15, 35, 25, 0.88);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(52, 211, 153, 0.15);
  border-radius: var(--radius-lg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

#topbar-brand { display: flex; align-items: center; gap: 10px; }
#topbar-emoji {
  font-size: 26px; line-height: 1;
  filter: drop-shadow(0 0 8px rgba(52,211,153,0.5));
}
#topbar-text  { display: flex; flex-direction: column; gap: 1px; }
#topbar-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  color: var(--text); letter-spacing: 0.01em; line-height: 1.2;
}
#topbar-sub { font-size: 11px; color: var(--text-muted); letter-spacing: 0.05em; }

#topbar-actions { display: flex; gap: 6px; align-items: center; }

#btn-fit-all,
#btn-collapse-sheet {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
  flex-shrink: 0;
}
#btn-fit-all:hover,    #btn-fit-all:active    { color: var(--emerald); background: var(--surface-3); }
#btn-collapse-sheet:hover, #btn-collapse-sheet:active { color: var(--amber);   background: var(--surface-3); }

/* ═══════════════════════════════════════════════════════════════
   BOTTOM SHEET
═══════════════════════════════════════════════════════════════ */
#sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  display: flex; flex-direction: column;
  transition: transform 0.38s var(--ease);
  height: var(--sheet-full-h);
  border-top: 1px solid rgba(52,211,153,0.12);
  padding-bottom: var(--safe-bottom);
}

.sheet-peek { transform: translateY(calc(100% - var(--sheet-peek-h))); }
.sheet-half { transform: translateY(calc(100% - var(--sheet-half-h))); }
.sheet-full { transform: translateY(calc(100% - var(--sheet-full-h))); }

/* Handle */
#sheet-handle-wrap {
  flex-shrink: 0;
  padding: 10px 0 4px;
  display: flex; justify-content: center; align-items: center;
  cursor: pointer; outline: none; touch-action: none;
  position: relative;
  z-index: 210;  /* encima del topbar cuando sheet-full */
}
#sheet-handle {
  width: 36px; height: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background var(--duration) var(--ease), width var(--duration) var(--ease);
}
#sheet-handle-wrap:hover #sheet-handle,
#sheet-handle-wrap:focus #sheet-handle { background: var(--emerald-dim); width: 48px; }

/* ═══════════════════════════════════════════════════════════════
   PESTAÑAS
═══════════════════════════════════════════════════════════════ */
#tab-bar {
  flex-shrink: 0;
  display: flex; gap: 4px;
  padding: 0 10px 8px;
}

.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px;
  background: none; border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em; cursor: pointer;
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tab-icon { width: 20px; height: 20px; flex-shrink: 0; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { color: var(--emerald); background: rgba(52,211,153,0.1); }
.tab.active .tab-icon { stroke: var(--emerald); }

/* ═══════════════════════════════════════════════════════════════
   CONTENIDO DE PANELES
═══════════════════════════════════════════════════════════════ */
#sheet-content { flex: 1; overflow: hidden; position: relative; }

.panel {
  display: none;
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 4px 16px 24px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.panel.active {
  display: flex; flex-direction: column; gap: 12px;
  animation: panelIn 0.2s var(--ease) both;
}

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

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   PANEL EXPLORAR
═══════════════════════════════════════════════════════════════ */
#tree-count-bar { font-size: 13px; color: var(--text-muted); padding-top: 2px; }

#search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-faint); pointer-events: none;
}
#search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-pill);
  padding: 11px 16px 11px 36px;
  color: var(--text);
  font-family: var(--font-body); font-size: 14px;
  outline: none;
  transition: border-color var(--duration) var(--ease);
  -webkit-appearance: none;
}
#search-input:focus { border-color: var(--emerald-dim); }
#search-input::placeholder { color: var(--text-faint); }

#tree-list { display: flex; flex-direction: column; gap: 8px; }

.tree-list-item {
  background: var(--surface-2);
  border: 1px solid var(--surface-3);
  border-radius: var(--radius-md);
  padding: 12px 14px; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  animation: itemIn 0.18s var(--ease) both;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
@keyframes itemIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.tree-list-item:hover,
.tree-list-item:active { background: var(--surface-3); }
.tree-list-item.selected {
  background: rgba(52,211,153,0.08);
  border-color: rgba(52,211,153,0.35);
}

.tli-emoji  { font-size: 24px; line-height: 1; flex-shrink: 0; }
.tli-body   { flex: 1; min-width: 0; }
.tli-name   {
  font-family: var(--font-display); font-size: 15px; font-weight: 600;
  color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tli-species {
  font-size: 12px; color: var(--text-muted); font-style: italic;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.tli-photos    { font-size: 12px; color: var(--text-faint); flex-shrink: 0; }
.tli-state-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   PANEL DETALLE
═══════════════════════════════════════════════════════════════ */
#detail-gallery { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.gallery-thumb {
  width: 88px; height: 72px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid transparent; cursor: pointer;
  transition: border-color var(--duration) var(--ease), transform 0.15s var(--ease);
}
.gallery-thumb:hover, .gallery-thumb:active { border-color: var(--emerald); transform: scale(1.04); }
.gallery-empty { font-size: 13px; color: var(--text-muted); font-style: italic; padding: 4px 0; }

#detail-meta { margin-top: 4px; }
#d-name {
  font-family: var(--font-display); font-size: 22px; font-weight: 700;
  color: var(--text); line-height: 1.2;
}
#d-species-line { font-style: italic; font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* Badges de estado */
.state-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; margin-top: 8px;
}
.state-healthy    { background: rgba(52,211,153,0.12);  color: #34D399; border: 1px solid rgba(52,211,153,0.3);  }
.state-concerning { background: rgba(251,191,36,0.12);  color: #FBBF24; border: 1px solid rgba(251,191,36,0.3);  }
.state-sick       { background: rgba(248,113,113,0.12); color: #F87171; border: 1px solid rgba(248,113,113,0.3); }
.state-dead       { background: rgba(100,100,100,0.15); color: #9CA3AF; border: 1px solid rgba(100,100,100,0.3); }
.state-unknown    { background: rgba(120,168,146,0.12); color: #78A892; border: 1px solid rgba(120,168,146,0.25);}

/* Grid de datos */
#detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.data-cell {
  background: var(--surface-2); border: 1px solid var(--surface-3);
  border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
/* Una celda que ocupa ambas columnas */
.data-cell-wide { grid-column: 1 / -1; }

.data-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}
.data-val { font-size: 14px; font-weight: 500; color: var(--text); }

/* Notas */
#d-notes-block {
  background: var(--surface-2);
  border-left: 3px solid var(--emerald-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
}
#d-notes { font-size: 14px; color: var(--text); line-height: 1.6; margin-top: 4px; }

/* Agregar fotos */
#add-photo-section {
  background: var(--surface-2); border: 1px solid var(--surface-3);
  border-radius: var(--radius-md); padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   PANEL REGISTRAR — Controles de ubicación
═══════════════════════════════════════════════════════════════ */
.panel-intro h3 {
  font-family: var(--font-display); font-size: 18px; font-weight: 700;
  color: var(--text); margin-bottom: 6px;
}
.panel-intro p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

#location-controls {
  display: flex; flex-direction: column; gap: 8px;
}

#btn-use-gps {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px 16px;
  background: rgba(52,211,153,0.1);
  border: 1.5px solid rgba(52,211,153,0.35);
  border-radius: var(--radius-md);
  color: var(--emerald);
  font-family: var(--font-body); font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
#btn-use-gps:hover  { background: rgba(52,211,153,0.18); border-color: var(--emerald); }
#btn-use-gps:active { transform: scale(0.98); }
#btn-use-gps:disabled {
  opacity: 0.55; cursor: not-allowed; transform: none;
  background: var(--surface-2); border-color: var(--surface-3); color: var(--text-muted);
}

.location-or {
  text-align: center; font-size: 12px; color: var(--text-faint);
  letter-spacing: 0.03em;
}

/* ── Caja de estado GPS ───────────────────────────────────── */
.gps-status-box {
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 13px; line-height: 1.5;
}
.gps-acquiring { background: rgba(56,189,248,0.08); border: 1.5px solid rgba(56,189,248,0.3); color: var(--sky);   }
.gps-timeout   { background: rgba(251,191,36,0.08); border: 1.5px solid rgba(251,191,36,0.3); color: var(--amber); }
.gps-error     { background: rgba(248,113,113,0.08);border: 1.5px solid rgba(248,113,113,0.3);color: var(--rose);  }
.gps-unsupported { background: var(--surface-2); border: 1px solid var(--surface-3); color: var(--text-muted); }

.gps-acquiring-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}

/* Spinner */
.gps-spinner {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(56,189,248,0.3);
  border-top-color: var(--sky);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.gps-live-acc { font-weight: 700; color: var(--sky); }

/* Barra de progreso GPS */
.gps-progress-track {
  width: 100%; height: 4px; background: rgba(56,189,248,0.15);
  border-radius: var(--radius-pill); overflow: hidden;
}
.gps-progress-bar {
  height: 100%; background: var(--sky);
  border-radius: var(--radius-pill);
  transition: width 0.2s linear;
}

/* ── Indicador de pin ─────────────────────────────────────── */
#pin-status {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; line-height: 1.4;
}
.pin-empty  { background: var(--surface-2); border: 1.5px dashed var(--surface-3); color: var(--text-muted); }
.pin-placed { background: rgba(52,211,153,0.08); border: 1.5px solid rgba(52,211,153,0.35); color: var(--emerald); }

/* Badge de precisión GPS dentro del indicador de pin */
.accuracy-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  vertical-align: middle; margin-left: 4px;
}
.acc-good { background: rgba(52,211,153,0.15); color: var(--emerald); border: 1px solid rgba(52,211,153,0.4); }
.acc-ok   { background: rgba(251,191,36,0.15);  color: var(--amber);   border: 1px solid rgba(251,191,36,0.4);  }
.acc-poor { background: rgba(248,113,113,0.15); color: var(--rose);    border: 1px solid rgba(248,113,113,0.4); }

/* ═══════════════════════════════════════════════════════════════
   MODO ÁRBOL EXISTENTE (MERGE)
═══════════════════════════════════════════════════════════════ */
#merge-mode { display: flex; flex-direction: column; gap: 14px; }

#merge-tree-card {
  background: var(--surface-2);
  border: 1.5px solid rgba(52,211,153,0.25);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
#merge-card-header { display: flex; align-items: center; gap: 12px; }

/* PNG icon en la tarjeta de merge */
.merge-card-icon {
  width: 42px; height: 42px;
  object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.merge-card-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--emerald); margin-bottom: 2px;
}
#merge-card-header strong {
  font-family: var(--font-display); font-size: 17px; color: var(--text); display: block;
}
#merge-card-species { font-style: italic; font-size: 13px; color: var(--text-muted); }
#merge-card-dist-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.merge-card-badge { padding: 3px 10px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; }
#merge-card-dist-text { font-size: 12px; color: var(--text-muted); }

.merge-mode-hint {
  font-size: 13px; color: var(--text-muted); line-height: 1.6;
  background: var(--surface-2);
  border-left: 3px solid var(--emerald-dim);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 8px 12px;
}

/* ═══════════════════════════════════════════════════════════════
   FORMULARIO DE ÁRBOL NUEVO
═══════════════════════════════════════════════════════════════ */
#register-form-wrap { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-body); }

.field-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-muted);
}
.field-label .required { color: var(--emerald); font-style: normal; }

.field input,
.field select,
.field textarea {
  background: var(--surface-2);
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  font-family: var(--font-body); font-size: 14px;
  outline: none; width: 100%;
  transition: border-color var(--duration) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--emerald-dim);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-faint); }

/* Fecha */
.field input[type="date"] { color-scheme: dark; cursor: pointer; }

/* Selector */
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2378A892' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px; cursor: pointer;
}
.field textarea { resize: vertical; min-height: 80px; }

/* Grid de 3 y de 2 columnas */
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr;     gap: 8px; }

/* Input file — oculto, con etiqueta personalizada */
input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.file-label {
  display: flex; align-items: center; justify-content: center;
  padding: 9px 16px;
  background: var(--surface-2); border: 1.5px dashed var(--surface-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: center; width: 100%;
  transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}
.file-label:hover, .file-label:active { border-color: var(--emerald-dim); color: var(--emerald); }

.file-names-preview {
  font-size: 12px; color: var(--text-faint); font-style: italic;
  line-height: 1.4; word-break: break-all;
}

/* Etiquetas de sección */
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px;
}

/* Mensaje vacío */
.empty-msg {
  color: var(--text-muted); font-size: 14px;
  text-align: center; padding: 32px 0; line-height: 1.7;
}

/* ═══════════════════════════════════════════════════════════════
   BOTONES
═══════════════════════════════════════════════════════════════ */
button {
  font-family: var(--font-body); cursor: pointer; border: none;
  transition: background var(--duration) var(--ease), transform 0.1s var(--ease), opacity var(--duration) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

#btn-submit-tree,
#btn-upload-photos,
#btn-update-existing {
  width: 100%; padding: 14px;
  background: var(--emerald); color: #0a1f14;
  border-radius: var(--radius-md);
  font-size: 15px; font-weight: 700; letter-spacing: 0.03em;
}
#btn-submit-tree:hover, #btn-upload-photos:hover, #btn-update-existing:hover { background: #5ee8af; }
#btn-submit-tree:active, #btn-upload-photos:active, #btn-update-existing:active { transform: scale(0.98); }
#btn-submit-tree:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  width: 100%; padding: 12px;
  background: transparent;
  border: 1.5px solid rgba(248,113,113,0.4);
  border-radius: var(--radius-md);
  color: var(--rose); font-size: 14px; font-weight: 600; margin-top: 4px;
}
.btn-danger:hover, .btn-danger:active { background: rgba(248,113,113,0.08); border-color: var(--rose); }

.btn-secondary {
  width: 100%; padding: 11px;
  background: transparent;
  border: 1.5px solid var(--surface-3);
  border-radius: var(--radius-md);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: border-color var(--duration), color var(--duration);
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

/* Resultados del registro */
#register-result { border-radius: var(--radius-md); padding: 12px 14px; font-size: 14px; line-height: 1.5; }
.result-success { background: rgba(52,211,153,0.08);  border: 1px solid rgba(52,211,153,0.3);  color: var(--emerald); }
.result-merge   { background: rgba(251,191,36,0.08);  border: 1px solid rgba(251,191,36,0.3);  color: var(--amber);   }
.result-error   { background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.3); color: var(--rose);    }

/* ═══════════════════════════════════════════════════════════════
   OVERLAY GALERÍA
═══════════════════════════════════════════════════════════════ */
#gallery-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#gallery-overlay.hidden { display: none; }

#gallery-img {
  max-width: 92vw; max-height: 78vh;
  object-fit: contain; border-radius: var(--radius-md);
  box-shadow: 0 8px 48px rgba(0,0,0,0.7);
  user-select: none; -webkit-user-drag: none;
}
#gallery-caption {
  position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.6); font-size: 13px; text-align: center;
  max-width: 80vw; background: rgba(0,0,0,0.4);
  padding: 4px 12px; border-radius: var(--radius-pill);
}
#gallery-counter {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.4); font-size: 12px;
}

#gallery-close { top: calc(var(--safe-top) + 16px); right: 16px; }
#gallery-prev  { left: 12px; }
#gallery-next  { right: 12px; }

#gallery-close, #gallery-prev, #gallery-next {
  position: absolute;
  background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.12);
  color: white; border-radius: 50%;
  width: 44px; height: 44px; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--duration) var(--ease);
}
#gallery-close:hover, #gallery-prev:hover, #gallery-next:hover {
  background: rgba(52,211,153,0.25);
}

/* ═══════════════════════════════════════════════════════════════
   MARCADORES EN EL MAPA
═══════════════════════════════════════════════════════════════ */
.emoji-marker-pending {
  font-size: 28px; line-height: 1; display: block;
  user-select: none; cursor: pointer;
  filter: drop-shadow(0 2px 5px rgba(251,191,36,0.6));
  animation: pendingPulse 1.4s ease-in-out infinite;
}
@keyframes pendingPulse {
  0%, 100% { transform: scale(1) translateY(0); }
  50%       { transform: scale(1.15) translateY(-4px); }
}

/* Cursor al registrar */
.placing-pin, .placing-pin * { cursor: crosshair !important; }

/* ═══════════════════════════════════════════════════════════════
   OVERRIDES DE LEAFLET
═══════════════════════════════════════════════════════════════ */
.leaflet-container { background: #142019; font-family: var(--font-body); }

.leaflet-popup-content-wrapper {
  background: var(--surface); color: var(--text);
  border: 1px solid rgba(52,211,153,0.18);
  border-radius: var(--radius-md) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5); padding: 0;
}
.leaflet-popup-tip-container { margin-top: -1px; }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 16px 14px !important; font-size: 14px; line-height: 1.5; }

.popup-name  { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--text); }
.popup-species { font-style: italic; color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.popup-link {
  display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600;
  color: var(--emerald); cursor: pointer; letter-spacing: 0.04em;
}
.popup-link:hover { text-decoration: underline; }

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large  { background-color: rgba(22,45,33,0.75) !important; }

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(52,211,153,0.85) !important;
  color: #0a1f14 !important; font-weight: 800 !important;
  font-family: var(--font-display) !important; font-size: 14px !important;
}

.leaflet-control-zoom a {
  background: var(--surface) !important; color: var(--text-muted) !important;
  border-color: var(--surface-3) !important; font-size: 16px !important;
}
.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important; color: var(--emerald) !important;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--emerald-dim); }

/* ═══════════════════════════════════════════════════════════════
   ESCRITORIO ≥ 768 px — barra lateral clásica
═══════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  #topbar { display: none; }

  #map { position: fixed; left: 380px; right: 0; top: 0; bottom: 0; }

  #sheet {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 380px; height: 100vh;
    border-radius: 0;
    border-right: 1px solid var(--surface-3); border-top: none;
    box-shadow: 4px 0 32px rgba(0,0,0,0.4);
    transform: none !important;
  }

  .sheet-peek, .sheet-half, .sheet-full { transform: none; }
  #sheet-handle-wrap { display: none; }

  #tab-bar { padding: 10px 12px 8px; gap: 6px; }
  .tab { flex-direction: row; justify-content: center; gap: 6px; padding: 9px 6px; font-size: 12px; }
}

/* ═══════════════════════════════════════════════════════════════
   PANTALLAS MUY PEQUEÑAS ≤ 360 px
═══════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .form-row-3 .field:last-child { grid-column: 1 / -1; }
  .form-row-2 { grid-template-columns: 1fr; }
}
