:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #1b2740;
  --text: #eef2f9;
  --muted: #93a0bd;
  --line: #243049;
  --accent: #ffd23f;      /* amarillo bandera VE — confianza/atención */
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

/* ---------- Mapa ocupa toda la pantalla ---------- */
#map {
  position: fixed;
  inset: 0;
}

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(180deg, rgba(11,18,32,0.96), rgba(11,18,32,0.0));
  pointer-events: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  letter-spacing: 0.3px;
  pointer-events: auto;
}
.top-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
  pointer-events: auto;
}
.brand-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 210, 63, 0.18);
}
.brand-ve { color: var(--accent); }
.version {
  font-size: 10px;
  font-weight: 300;
  color: var(--muted);
  align-self: flex-end;
  margin-bottom: 3px;
  letter-spacing: 0.5px;
}
.status {
  font-size: 13px;
  color: var(--muted);
  background: rgba(19, 28, 46, 0.85);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  pointer-events: auto;
}
.status #reportCount { color: var(--text); font-weight: 700; }
.help-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 210, 63, 0.5);
  background: rgba(19, 28, 46, 0.92);
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

/* ---------- Aviso legal ---------- */
.disclaimer {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 58px);
  left: 12px; right: 12px;
  z-index: 19;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.35;
}
.disclaimer p { margin: 0; color: var(--muted); }
.disclaimer strong { color: var(--text); }
.disclaimer button {
  flex: 0 0 auto;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}
.disclaimer.hidden { display: none; }

/* ---------- Botones flotantes ---------- */
.locate-btn {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  z-index: 18;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(36, 48, 73, 0.75);
  background: rgba(19, 28, 46, 0.94);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.locate-btn svg {
  display: block;
  width: 22px;
  height: 22px;
}
.report-fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(78vw, 245px);
  justify-content: center;
  background: linear-gradient(180deg, #ffe173, var(--accent));
  color: #1a1300;
  font-size: clamp(15px, 4vw, 17px);
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 15px 24px;
  box-shadow: 0 14px 28px rgba(255, 210, 63, 0.32), 0 6px 18px rgba(0, 0, 0, 0.24);
}
.report-fab .plus { font-size: 22px; line-height: 1; }

.hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  z-index: 17;
  background: rgba(19, 28, 46, 0.92);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
.hint.show { opacity: 1; }

/* ---------- Hoja inferior (reporte) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 8px 18px calc(env(safe-area-inset-bottom) + 18px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(110%);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet.open { transform: translateY(0); }
.sheet-handle {
  width: 44px; height: 5px;
  border-radius: 999px;
  background: var(--line);
  margin: 8px auto 14px;
}
.sheet-title {
  margin: 0 0 16px;
  font-size: 19px;
  text-align: center;
}

/* Cuadrícula de categorías */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px;
  background: var(--panel-2);
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  min-height: 86px;
}
.type-btn .emoji { font-size: 26px; line-height: 1; }
.type-btn.selected {
  border-color: var(--accent);
  background: #20304d;
}

/* Stepper de personas */
.people {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 2px 4px;
}
.people-label { font-size: 15px; color: var(--muted); }
.stepper {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stepper button {
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
}
.stepper #peopleValue {
  min-width: 36px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
}

/* Acciones */
.sheet-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.btn-ghost, .btn-primary {
  flex: 1;
  padding: 16px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  border: 1px solid var(--line);
}
.btn-ghost {
  background: #22304b;
  color: var(--text);
}
.btn-primary {
  background: var(--accent);
  color: #1a1300;
  border: none;
}
.btn-primary:disabled { opacity: 0.4; }

/* ---------- Modal informativo ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(0, 0, 0, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
.info-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 40;
  width: min(92vw, 520px);
  max-height: min(82vh, 720px);
  overflow: auto;
  transform: translate(-50%, -46%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  transition: opacity 0.2s, transform 0.2s;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 210, 63, 0.65) rgba(19, 28, 46, 0.75);
}
.info-modal::-webkit-scrollbar {
  width: 10px;
}
.info-modal::-webkit-scrollbar-track {
  background: rgba(19, 28, 46, 0.75);
  border-radius: 999px;
  margin: 14px 0;
}
.info-modal::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255, 210, 63, 0.85), rgba(255, 210, 63, 0.45));
  border: 2px solid var(--panel);
  border-radius: 999px;
}
.info-modal::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
.info-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}
.info-modal h2 {
  margin: 0 42px 14px 0;
  font-size: 22px;
}
.info-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.info-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.info-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--accent);
}
.info-section p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}
.info-list {
  display: grid;
  gap: 8px;
}
.info-list p {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: start;
}
.icon-grid, .phone-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.icon-grid span, .phone-grid a {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  border: 1px solid rgba(36, 48, 73, 0.75);
}
.small-note {
  margin-top: 10px !important;
  font-size: 12px !important;
}

/* Aviso breve (toast) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 92px);
  transform: translate(-50%, 12px);
  z-index: 45;
  max-width: min(90vw, 360px);
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Enlace al Twitter del autor en el top del modal */
.author-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.author-link:hover { color: var(--text); border-color: rgba(255, 210, 63, 0.5); }
.author-link svg { display: block; }

/* Botón de voz (TTS) dentro del modal de guía */
.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 14px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 63, 0.5);
  background: rgba(255, 210, 63, 0.12);
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
}
.speak-btn.speaking {
  background: rgba(255, 210, 63, 0.24);
}
.speak-btn[disabled] {
  opacity: 0.5;
  border-color: var(--line);
  color: var(--muted);
}

/* Modal de confirmación (quitar reporte) */
.confirm-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 41;
  width: min(90vw, 380px);
  transform: translate(-50%, -46%) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px;
  box-shadow: var(--shadow);
  transition: opacity 0.2s, transform 0.2s;
  text-align: center;
}
.confirm-modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}
.confirm-modal h3 { margin: 0 0 10px; font-size: 18px; }
.confirm-modal p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  border: 1px solid var(--line);
}
.btn-danger { background: var(--danger); color: #fff; border: none; }

.install-chip {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 156px);
  z-index: 18;
  border: 1px solid rgba(255, 210, 63, 0.45);
  background: rgba(19, 28, 46, 0.95);
  color: var(--accent);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.install-chip.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 420px) {
  .topbar {
    align-items: flex-start;
    padding-left: 12px;
    padding-right: 12px;
  }
  .brand {
    font-size: 18px;
  }
  .status {
    font-size: 12px;
    padding: 6px 10px;
  }
  .help-btn {
    width: 32px;
    height: 32px;
  }
  .report-fab {
    min-width: calc(100vw - 116px);
    padding: 14px 18px;
  }
  .locate-btn {
    width: 44px;
    height: 44px;
    right: 12px;
  }
  .sheet-actions {
    gap: 10px;
  }
  .btn-ghost, .btn-primary {
    padding: 15px 10px;
    font-size: 15px;
  }
  .icon-grid, .phone-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Marcadores en el mapa ---------- */
.marker {
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(45deg);
  border: 2px solid rgba(255,255,255,0.95);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  cursor: pointer;
  touch-action: none;                 /* evita que el pellizco haga zoom de página */
}
.marker span { transform: rotate(-45deg); font-size: 18px; }
.marker-temp { background: #475569; }
.marker-multi { box-shadow: 0 0 0 3px rgba(220,38,38,0.25), 0 4px 10px rgba(0,0,0,0.3); }

/* Punto azul de "mi ubicación" */
.me-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.25);
}

/* Popup de un reporte */
/* touch-action: none evita que el pellizco (zoom de 2 dedos) escale el popup */
.maplibregl-popup { touch-action: none; max-width: 280px !important; }
.maplibregl-popup-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.maplibregl-popup-tip { border-top-color: var(--panel) !important; }
.popup-title { font-weight: 800; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.popup-meta { color: var(--muted); font-size: 12.5px; margin: 6px 0 12px; }
.popup-actions { display: flex; gap: 8px; }
.popup-actions button {
  flex: 1;
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
}
.popup-confirm { background: rgba(22,163,74,0.15); color: #4ade80; }
.popup-gone { background: rgba(220,38,38,0.12); color: #f87171; }
