/* ============================================================================
   OcioCultura — styles.css
   Estética: carácter andaluz moderno (terracota + crema en claro,
   oliva profundo + ámbar en oscuro). Tipografía: DM Serif Display + Manrope.
   ============================================================================ */

/* ------------ TOKENS DE TEMA ------------ */
:root {
  /* v2.5: declaramos los esquemas de color que la app soporta. Esto hace que
   * inputs nativos, scrollbars, autocompletados, etc. adopten el tema correcto
   * cuando el usuario esté en modo oscuro del sistema. */
  color-scheme: light dark;

  /* Tema claro (por defecto) */
  --bg:           #faf6f0;
  --bg-elev:     #ffffff;
  --bg-soft:     #f1ebe1;
  --ink:         #2a1f18;
  --ink-soft:    #5a4a3d;
  --muted:       #8a7a6c;
  --line:        #e6dccb;
  --line-strong: #d3c5ad;
  --accent:      #b8553b;     /* terracota cordobés */
  --accent-2:    #8a3d27;
  --accent-soft: #f3dccd;
  --shadow:      0 1px 2px rgba(42,31,24,.04), 0 12px 30px -12px rgba(42,31,24,.18);
  --radius:      14px;
  --radius-sm:   8px;
  --radius-lg:   22px;
  --topbar-h:    62px;
  --sidebar-w:   360px;

  --font-display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-sans:    "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="dark"] {
  --bg:           #16140f;
  --bg-elev:     #1f1c16;
  --bg-soft:     #25211a;
  --ink:         #f3ead9;
  --ink-soft:    #cdbfa6;
  --muted:       #8c8170;
  --line:        #2f2a21;
  --line-strong: #423c30;
  --accent:      #d89758;     /* ámbar cálido */
  --accent-2:    #f0b478;
  --accent-soft: #3a2f20;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 14px 40px -10px rgba(0,0,0,.55);
}

/* ------------ RESET MÍNIMO ------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* el mapa lleva su propio scroll */
  /* v2.5: 100vh en iOS/Android incluye la barra del navegador, lo que da un
   * viewport más grande del real y causa scroll fantasma. Con 100dvh el
   * navegador ajusta dinámicamente. Mantenemos 100vh como fallback. */
  min-height: 100vh;
  min-height: 100dvh;
  transition: background-color .25s ease, color .25s ease;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: -.01em; line-height: 1.15; margin: 0 0 .5rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.15rem; }
button { font-family: inherit; }
a { color: var(--accent); }

/* Ocultos */
[hidden] { display: none !important; }

/* ------------ TOPBAR ------------ */
.topbar {
  position: fixed; inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
  z-index: 1500;   /* por encima de Leaflet (≈700) pero por debajo del modal (9999) */
  backdrop-filter: saturate(140%) blur(8px);
}
.brand { display: flex; align-items: baseline; gap: 8px; flex: 1; min-width: 0; }
.brand__mark {
  font-size: 22px; color: var(--accent);
  transform: translateY(2px);
}
.brand__name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand__name span { color: var(--accent); font-style: italic; }

.topbar__actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--ink);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.icon-btn:hover { background: var(--bg-soft); border-color: var(--line); }
.icon-btn:active { transform: scale(.96); }
.icon-btn svg { width: 20px; height: 20px; }

#btn-toggle-sidebar { display: none; }

/* ------------ BOTONES ------------ */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--ink);
  font-weight: 600; font-size: .92rem;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--accent) 50%, transparent);
}
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 10px; font-size: .82rem; }

/* User pill */
.user-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
  font-size: .82rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
[data-theme="dark"] .user-pill { color: var(--accent-2); }

/* ------------ LAYOUT ------------ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  /* v2.5: dvh dinámico para evitar saltos en móvil cuando la barra de URL
   * aparece o desaparece. 100vh queda como fallback. */
  height: 100vh;
  height: 100dvh;
  padding-top: var(--topbar-h);
}

/* ------------ SIDEBAR ------------ */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.panel { padding: 20px 22px 28px; }
.panel__title {
  font-family: var(--font-display);
  font-size: 1.65rem;
  margin-bottom: 4px;
}
.panel__sub { color: var(--muted); margin-top: 0; font-size: .92rem; }
.link-back {
  background: none; border: none;
  color: var(--accent); cursor: pointer;
  padding: 0 0 10px; font-weight: 600;
  font-size: .88rem;
}

/* Lista de ciudades */
.city-list, .poi-list, .route-list, .chip-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }

.city-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-elev);
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
  display: flex; flex-direction: column; gap: 4px;
}
.city-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.city-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0;
}
.city-card .meta { color: var(--muted); font-size: .82rem; }

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: none; border: none;
  padding: 10px 12px;
  font-size: .92rem; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-panel { padding-top: 12px; }

/* POI item */
.poi-item, .route-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.poi-item:hover, .route-item:hover { border-color: var(--accent); transform: translateX(2px); }
.poi-item__icon, .route-item__icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-2);
  display: grid; place-items: center;
  font-size: 1.15rem;          /* emojis legibles */
  line-height: 1;
  flex-shrink: 0;
}
.poi-item h4, .route-item h4 {
  margin: 0 0 2px; font-family: var(--font-sans);
  font-size: .98rem; font-weight: 700;
}
.poi-item .chip, .route-item .meta { font-size: .78rem; color: var(--muted); }

/* Chips */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: .76rem; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.chip-list { flex-direction: row; flex-wrap: wrap; }
.chip-list li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .85rem;
}

/* ------------ MAPA ------------ */
.map-wrap { position: relative; height: 100%; }
#map { width: 100%; height: 100%; background: var(--bg-soft); }

/* Marcadores personalizados con emoji.
   Antes era una "lágrima rotada con letra"; ahora es un círculo blanco
   con borde de color de marca y un emoji centrado, mucho más amigable. */
.marker-emoji {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  display: grid; place-items: center;
  font-size: 22px;
  line-height: 1;
  border: 3px solid var(--accent);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
.marker-emoji:hover { transform: scale(1.12); }
.marker-emoji--city {
  width: 48px; height: 48px;
  font-size: 26px;
  border-color: var(--accent-2);
}

/* Popup leaflet refinado */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm) !important;
  background: var(--bg-elev) !important;
  color: var(--ink) !important;
  box-shadow: var(--shadow) !important;
}
.leaflet-popup-tip { background: var(--bg-elev) !important; }
.leaflet-popup-content { font-family: var(--font-sans); margin: 14px 18px !important; }
.leaflet-popup-content strong { font-family: var(--font-display); font-size: 1.05rem; }

/* Aviso de proximidad (toast) */
.toast {
  position: absolute; left: 50%; top: 18px;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: min(560px, calc(100vw - 24px));
  animation: toastIn .35s cubic-bezier(.2,.8,.2,1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.toast__inner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 12px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.toast__dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 14px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.toast p { margin: 0; font-size: .92rem; }
.toast__close {
  background: none; border: none; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 6px;
}

/* ------------ MODALES ------------
   IMPORTANTE: Leaflet usa internamente z-index hasta ~700 para popups,
   tooltips y controles. Por eso el modal va a 9999, para garantizar que
   nada del mapa quede por encima.
*/
.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 9999;
  padding: 16px;
}
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 16, 12, .55);
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal__panel {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%; max-width: 580px;
  max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow);
  animation: panelIn .28s cubic-bezier(.2,.8,.2,1);
}
.modal__panel--small { max-width: 420px; }
.modal__panel--wide  { max-width: 920px; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal__close {
  position: absolute; top: 12px; right: 14px;
  width: 34px; height: 34px;
  border: none; background: transparent;
  font-size: 24px; color: var(--muted);
  cursor: pointer; border-radius: 8px;
}
.modal__close:hover { background: var(--bg-soft); }

/* Galería de medios dentro del POI */
.media-grid {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
  margin-top: 18px;
}
.media-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--bg);
}
.media-card h4 {
  margin: 0 0 6px; font-family: var(--font-sans);
  font-weight: 700; font-size: .95rem;
}
.media-card .chip { margin-bottom: 8px; }
.media-card img, .media-card video, .media-card iframe {
  width: 100%; max-width: 100%; border-radius: 8px;
  display: block;
}
.media-card iframe { aspect-ratio: 16/9; height: auto; border: 0; }
.media-card audio { width: 100%; }
.media-card .text-blob { color: var(--ink-soft); white-space: pre-wrap; }

/* ------------ FORMULARIOS ------------ */
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .82rem; color: var(--muted); font-weight: 600;
}
.form input, .form select, .form textarea {
  font-family: inherit; font-size: .95rem;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.form--grid {
  display: grid; gap: 12px;
  grid-template-columns: 1fr 1fr;
}
.form--grid .span-2 { grid-column: span 2; }
.form--inline { flex-direction: row; align-items: end; gap: 10px; }
.form--inline label { flex: 1; }
.form-tipo { flex-wrap: wrap; }
.form-tipo__emoji-label { flex: 0 0 124px !important; }
.emoji-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: center;
}
.emoji-input {
  text-align: center;
  font-size: 1.35rem;
  line-height: 1;
}
.emoji-preview {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}
.form-tipo__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.form__actions { display: flex; justify-content: flex-end; gap: 8px; }

.error {
  background: color-mix(in srgb, #c0392b 15%, transparent);
  color: #c0392b;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: .88rem; margin: 0;
}
/* Variante informativa (NO error): "Sesión cerrada", etc. */
.error.is-info {
  background: var(--accent-soft);
  color: var(--accent-2);
}
.muted { color: var(--muted); }
.muted.small { font-size: .85rem; }

.hint { margin-top: 6px; font-size: .82rem; color: var(--muted); }
.hint summary { cursor: pointer; color: var(--accent); }
.hint code { background: var(--bg-soft); padding: 1px 6px; border-radius: 4px; }
.hint ul { padding-left: 18px; }

/* ------------ TABLAS ADMIN ------------ */
.tabs--admin { margin-bottom: 16px; }
.admin-tab { animation: fadeIn .2s ease; }
.admin-table-wrap { overflow-x: auto; margin-top: 18px; }
.admin-table {
  width: 100%; border-collapse: collapse;
  font-size: .9rem;
}
.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.admin-table th {
  font-weight: 700; color: var(--muted);
  font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
}
.admin-table tbody tr:hover { background: var(--bg-soft); }
.admin-table .row-actions { display: flex; gap: 6px; }

/* ------------ FAB ------------ */
.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 54px; height: 54px;
  border-radius: 50%; border: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px -6px color-mix(in srgb, var(--accent) 60%, transparent);
  z-index: 1300;
  transition: transform .15s ease;
}
.fab:hover { transform: scale(1.08); }
.fab svg { width: 22px; height: 22px; }

/* ============================================================================
   RESPONSIVE — v2.1
   Estrategia móvil:
   - Topbar: solo logo + pill + botón "⋮" (overflow). Las demás acciones
     colapsan en un menú desplegable.
   - Sidebar: drawer lateral.
   - FAB admin: arriba a la izquierda del banner sim para no chocar.
   - Modales: ocupan casi toda la pantalla.
   ============================================================================ */

/* Botón overflow oculto en desktop */
#btn-overflow { display: none; }
.icon-btn__label { display: none; }

@media (max-width: 860px) {
  :root { --sidebar-w: 320px; --topbar-h: 56px; }
  #btn-toggle-sidebar { display: inline-flex; }

  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--topbar-h); left: 0; bottom: 0;
    width: 86vw; max-width: 360px;
    z-index: 1400;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.18);
  }
  .sidebar.is-open { transform: translateX(0); }
  .form--grid { grid-template-columns: 1fr; }
  .form--grid .span-2 { grid-column: span 1; }

  /* ----- Topbar móvil ----- */
  /* Menú "⋮" pasa a ser visible y las acciones se colapsan en un panel. */
  #btn-overflow { display: inline-flex; }

  .topbar__actions {
    position: absolute;
    top: calc(var(--topbar-h) + 6px);
    right: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 200px;
    /* Por defecto oculto. Se muestra con .is-open */
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease;
    z-index: 1500;
  }
  .topbar__actions.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
  /* Cuando colapsa en menú, los iconos pasan a fila con texto. */
  .topbar__actions .icon-btn {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
  }
  .topbar__actions .icon-btn__label {
    display: inline;
    font-size: .92rem;
    font-weight: 600;
  }
  /* User pill: ahora dentro del menú colapsable, sin botón redondo */
  .topbar__actions #user-pill {
    align-self: stretch;
    text-align: center;
    margin-top: 4px;
  }
  /* Logout: ocupa todo el ancho dentro del menú */
  .topbar__actions #btn-logout {
    width: 100%;
    padding: 9px 12px;
    font-size: .9rem;
  }

  .topbar { padding: 0 10px; gap: 8px; }
  .topbar__actions .btn { padding: 8px 12px; font-size: .85rem; }
  .brand__name { font-size: 1.1rem; }
  .nav-mode-pill { font-size: .78rem; padding: 4px 9px; }

  /* ----- FAB admin: arriba a la izquierda del banner sim, NO abajo derecha
       para no taparse con el banner de simulación. ----- */
  .fab {
    bottom: 84px;
    right: 16px;
    width: 50px; height: 50px;
  }
  body.is-simulating .fab { bottom: 100px; }

  /* Modales: prácticamente fullscreen con borde */
  .modal { padding: 8px; }
  .modal__panel {
    padding: 20px 16px;
    max-height: 92vh;
    border-radius: var(--radius);
  }
  .modal__panel--wide { max-width: 100%; }

  .panel { padding: 16px; }

  /* Banner simulación: ocupa el ancho disponible, sin chocar con FAB */
  .sim-banner {
    bottom: 16px;
    left: 12px; right: 12px;
    transform: none;
    max-width: none;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .85rem;
  }

  /* Aviso proximidad: pegado debajo de topbar y full-width */
  .proximity-modal {
    left: 8px; right: 8px;
    transform: none;
    top: calc(var(--topbar-h) + 8px);
    max-width: none;
    width: auto;
  }
  .proximity-modal__inner {
    flex-wrap: wrap;
    padding: 14px 16px;
  }
  .proximity-modal__icon { font-size: 24px; }
  .proximity-modal p { font-size: .9rem; flex-basis: calc(100% - 50px); }
  .proximity-modal__actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 6px;
  }

  /* Tablas admin: scroll horizontal suave */
  .admin-table { font-size: .85rem; }
  .admin-table th, .admin-table td { padding: 8px 10px; }

  /* Tabs admin: scroll horizontal si no caben */
  .tabs--admin {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: thin;
  }
  .tabs--admin .tab { flex-shrink: 0; }
}

@media (max-width: 480px) {
  .panel { padding: 14px; }
  .brand__name { font-size: 1rem; }
  .nav-mode-pill {
    font-size: .72rem;
    padding: 3px 7px;
  }
  .auth-card { padding: 26px 20px; }
  .auth-brand h1 { font-size: 1.45rem; }

  /* Botones del topbar más pequeños */
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 18px; height: 18px; }
}

/* En móviles MUY estrechos (<360px), ocultamos el texto de la marca para
   no romper el layout. El símbolo ◐ se queda. */
@media (max-width: 360px) {
  .brand__name { display: none; }
}

/* Modo horizontal en móvil: el menú overflow no puede ser tan alto */
@media (max-height: 500px) and (orientation: landscape) {
  .modal__panel { max-height: 96vh; padding: 14px 16px; }
}

/* ============================================================================
   AJUSTES DE TEMA OSCURO PARA LEAFLET
   ============================================================================ */
[data-theme="dark"] .leaflet-tile {
  filter: brightness(.7) contrast(1.1) hue-rotate(-10deg);
}
[data-theme="dark"] .leaflet-control-zoom a {
  background: var(--bg-elev) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}
[data-theme="dark"] .leaflet-control-attribution {
  background: var(--bg-elev) !important;
  color: var(--muted) !important;
}

/* ============================================================================
   ADICIONES v2.0
   ============================================================================ */

/* ------------ PANTALLA DE AUTENTICACIÓN BLOQUEANTE ------------ */
.auth-screen {
  position: fixed; inset: 0;
  z-index: 10000;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 60%),
    var(--bg);
  overflow-y: auto;
}
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow);
  animation: panelIn .35s cubic-bezier(.2,.8,.2,1);
}
.auth-brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0;
}
.auth-brand h1 span { color: var(--accent); font-style: italic; }
.auth-tagline {
  color: var(--muted);
  margin: 0 0 22px;
  font-size: .92rem;
}
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.auth-tab {
  background: none; border: none;
  padding: 10px 14px;
  font-weight: 700; font-size: .92rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  font-family: inherit;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.auth-form { margin-top: 18px; }

/* ------------ PILL DE MODO DE NAVEGACIÓN (topbar) ------------ */
.nav-mode-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
  font-size: .82rem;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ------------ MODAL DE PROXIMIDAD (pueblo cercano con botón Visitar) ------------ */
.proximity-modal {
  position: absolute;
  left: 50%; top: 18px;
  transform: translateX(-50%);
  z-index: 2000;
  max-width: min(520px, calc(100vw - 24px));
  width: 100%;
  animation: toastIn .35s cubic-bezier(.2,.8,.2,1);
}
.proximity-modal__inner {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.proximity-modal__icon {
  font-size: 28px;
  flex-shrink: 0;
}
.proximity-modal p {
  margin: 0;
  font-size: .95rem;
  flex: 1;
}
.proximity-modal__actions {
  display: flex; gap: 8px;
  flex-shrink: 0;
}
.proximity-modal__actions .btn { padding: 7px 14px; font-size: .85rem; }

/* ------------ BANNER DE SIMULACIÓN ------------ */
.sim-banner {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 10px 16px;
  background: color-mix(in srgb, #f1c40f 90%, var(--bg-elev));
  color: #5a4500;
  border: 1px solid color-mix(in srgb, #f1c40f 50%, transparent);
  border-radius: 999px;
  display: flex; align-items: center; gap: 10px;
  font-size: .9rem;
  box-shadow: var(--shadow);
  font-weight: 600;
}
.sim-banner button {
  background: none; border: none;
  color: #5a4500; font-size: 18px;
  cursor: pointer; padding: 0 0 0 4px;
  line-height: 1;
}
[data-theme="dark"] .sim-banner {
  background: color-mix(in srgb, #f1c40f 30%, var(--bg-elev));
  color: #ffd75a;
  border-color: color-mix(in srgb, #f1c40f 40%, transparent);
}
[data-theme="dark"] .sim-banner button { color: #ffd75a; }

/* Cursor especial en el mapa cuando la simulación está activa */
body.is-simulating #map { cursor: crosshair; }

/* ------------ MARCADOR DE POSICIÓN SIMULADA (distinto del real) ------------ */
.user-marker-sim {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #f1c40f;
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, #f1c40f 35%, transparent);
}

/* ------------ Subtítulo dentro del admin ------------ */
.admin-h3 {
  font-family: var(--font-sans);
  font-size: 1rem; font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ============================================================================
   v2.1 — GESTIÓN DE PUEBLOS Y ADMINS
   ============================================================================ */

/* Vista previa de imagen al editar un pueblo */
.ciudad-imagen-preview-wrap {
  display: flex; align-items: center; gap: 14px;
  padding: 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
}
#ciudad-imagen-preview {
  width: 96px; height: 96px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* Thumbnail dentro de la tabla de pueblos */
.ciudad-thumb {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  display: grid; place-items: center;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
}
.ciudad-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Pill de número de admins */
.admin-count-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 700;
  font-size: .78rem;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  transition: background .15s, transform .12s;
}
.admin-count-pill:hover { transform: translateY(-1px); }
.admin-count-pill--warn {
  background: color-mix(in srgb, #e67e22 18%, transparent);
  color: #d35400;
  border-color: color-mix(in srgb, #e67e22 30%, transparent);
}
[data-theme="dark"] .admin-count-pill--warn {
  background: color-mix(in srgb, #e67e22 24%, transparent);
  color: #ffb37c;
}

/* Lista de admins del modal de un pueblo */
.ciudad-admins-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.ciudad-admins-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.ciudad-admins-list .ca-info { flex: 1; min-width: 0; }
.ciudad-admins-list .ca-info strong { display: block; font-size: .95rem; }
.ciudad-admins-list .ca-info span { color: var(--muted); font-size: .82rem; }

.ciudad-admins-list--vacia {
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  padding: 14px;
}

/* Mensaje warning amarillo */
.warn {
  background: color-mix(in srgb, #f1c40f 22%, transparent);
  color: #806300;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: .85rem; margin: 10px 0 0;
  border-left: 3px solid #f1c40f;
}
[data-theme="dark"] .warn {
  background: color-mix(in srgb, #f1c40f 18%, var(--bg-elev));
  color: #ffd75a;
}
.warn.small { font-size: .82rem; }

/* ============================================================================
   v2.1 — INDICADOR ESTADO PUSH (botón 🔔)
   ============================================================================ */
.icon-btn.is-on {
  color: var(--accent);
  background: var(--accent-soft);
}
.icon-btn.is-on::after {
  content: "";
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #2ecc71;
  top: 4px; right: 4px;
  border: 2px solid var(--bg-elev);
}
.icon-btn { position: relative; }

/* ============================================================================
   v2.1 — Panel de DEBUG Push
   Se activa tocando 5 veces el logo. Pensado para depurar en MÓVIL,
   donde no hay DevTools cómoda. Discreto, no rompe el layout.
   ============================================================================ */
.debug-panel {
  position: fixed;
  bottom: 90px;
  left: 16px;
  z-index: 1450;
  width: min(360px, calc(100vw - 32px));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font-sans);
  font-size: .82rem;
  animation: fadeIn .15s ease;
}
.debug-panel__head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.debug-panel__head strong { flex: 1; }
.debug-panel__body {
  margin: 0; padding: 10px 14px;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
}
.debug-panel__body dt {
  color: var(--muted);
  font-size: .78rem;
}
.debug-panel__body dd {
  margin: 0;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .8rem;
  word-break: break-all;
}
.debug-panel__body dd.ok   { color: #2c7a2c; }
.debug-panel__body dd.fail { color: #c0392b; }
.debug-panel__body dd.warn { color: #b8860b; }
[data-theme="dark"] .debug-panel__body dd.ok   { color: #6fcf6f; }
[data-theme="dark"] .debug-panel__body dd.fail { color: #ff7a6a; }
[data-theme="dark"] .debug-panel__body dd.warn { color: #ffd75a; }


/* ------------ Tabs ocultas según rol ------------ */
.tab[data-superonly] { display: none; }
body.is-super .tab[data-superonly] { display: inline-block; }

/* ------------ Botón logout ------------ */
#btn-logout { font-size: .82rem; }

/* ------------ Responsive auth ------------ */
@media (max-width: 480px) {
  .auth-card { padding: 28px 22px; }
  .auth-brand h1 { font-size: 1.5rem; }
  .nav-mode-pill { font-size: .76rem; padding: 4px 9px; }
  .proximity-modal__inner { flex-wrap: wrap; }
  .proximity-modal__actions { width: 100%; justify-content: flex-end; }
}

/* ============================================================================
   IMPORTADOR GPX (v2.2)
   Bloque dentro del formulario de rutas que permite cargar archivos .gpx
   ============================================================================ */
.gpx-import {
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
}
.gpx-import__label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: .9em;
  color: var(--ink-soft);
}
.gpx-import input[type="file"] {
  font-size: .85em;
}


/* ============================================================================
   v2.3 — Mejoras UX panel de administración para admins locales
   ============================================================================ */

/* ============================== TOASTS ============================== */
.toast-container {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 16px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: .92em;
  box-shadow: var(--shadow);
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in .22s ease;
}
.toast--ok    { border-left-color: #2e9c5b; }
.toast--err   { border-left-color: #c0392b; }
.toast--warn  { border-left-color: #d39e22; }
.toast--info  { border-left-color: var(--accent); }
.toast__icon  { font-size: 1.15em; line-height: 1.1; flex-shrink: 0; }
.toast__body  { flex: 1; }
.toast.fading { opacity: 0; transform: translateX(20px); transition: all .25s ease; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================== MODAL CONFIRM ============================== */
.modal__panel--narrow {
  max-width: 440px;
}
.btn--danger {
  background: #c0392b;
  color: #fff;
  border: 1px solid #a83321;
}
.btn--danger:hover { background: #a83321; }

/* ============================== DASHBOARD ============================== */
.dashboard { padding: 4px 0 8px; }
.dashboard__hero h3 {
  font-size: 1.7rem;
  margin-bottom: 4px;
}
.dashboard__hero .muted { font-size: .95em; }

.dashboard__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 20px 0 26px;
}
.stat-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card__num {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-card__lbl {
  font-size: .85em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.dashboard__h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin: 18px 0 12px;
  font-weight: 400;
}
.dashboard__actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.action-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: inherit;
  color: var(--ink);
  transition: all .15s ease;
}
.action-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.action-card__icon {
  font-size: 2rem;
  line-height: 1;
}
.action-card__title {
  font-weight: 700;
  font-size: 1.05em;
}
.action-card__sub {
  font-size: .85em;
  color: var(--muted);
}

.dashboard__tip {
  margin-top: 26px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: .9em;
  color: var(--ink-soft);
}

/* ============================== FORMULARIOS GUIADOS ============================== */
.form-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.form-section:first-child { margin-top: 4px; }
.form-section__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: .9em;
}
.form-section__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink);
}

.hint-small {
  display: block;
  font-size: .8em;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
}

.btn--large {
  padding: 12px 22px;
  font-size: 1em;
  min-height: 46px;
}
.btn--secondary {
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: .92em;
  transition: all .15s ease;
}
.btn--secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Bloque "elige una opción para ubicación" */
.location-helper {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--line);
}
.location-helper__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Sección colapsable "Opciones avanzadas" */
.form-advanced {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  background: transparent;
}
.form-advanced summary {
  cursor: pointer;
  padding: 8px 0;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .92em;
  user-select: none;
}
.form-advanced summary:hover { color: var(--accent); }
.form-advanced[open] summary { color: var(--accent); }
.form-advanced__body {
  padding-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Importador GPX prominente */
.gpx-import--prominente {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-style: dashed;
}
.gpx-import--prominente strong { color: var(--accent-2); }

/* ============================== MEDIA TYPE PICKER ============================== */
.media-type-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.media-type-picker label {
  display: block;
  cursor: pointer;
}
.media-type-picker input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.media-type-picker label span {
  display: block;
  text-align: center;
  padding: 14px 10px;
  background: var(--bg-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .9em;
  transition: all .15s ease;
}
.media-type-picker label:hover span {
  border-color: var(--accent);
}
.media-type-picker input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-2);
  font-weight: 700;
}

/* ============================== TOOLBAR + SEARCH ============================== */
.admin-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}
.admin-search {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--ink);
  font-family: inherit;
  font-size: .95em;
}
.admin-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.empty-state {
  text-align: center;
  padding: 30px 16px;
  color: var(--muted);
  font-style: italic;
}

/* ============================== TABLAS MEJORADAS ============================== */
.admin-table .row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.admin-table .btn--icon {
  padding: 6px 9px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
}
.admin-table .btn--icon:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.admin-table .btn--icon[data-action="del"]:hover {
  background: #fde6e3;
  border-color: #c0392b;
}

/* ============================== MAP PICKER ============================== */
.map-picker {
  width: 100%;
  height: 50vh;
  min-height: 320px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin: 14px 0;
}
.map-picker-marker {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3));
}

/* ============================== CHIPS EDITABLES (TIPOS) ============================== */
.chip-list--editable li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 4px 6px 12px;
}
.tipo-chip__emoji {
  min-width: 1.35em;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1;
}
.tipo-chip__title { max-width: 180px; overflow-wrap: anywhere; }
.chip-list--editable .chip-edit,
.chip-list--editable .chip-del {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: .9em;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: .7;
}
.chip-list--editable .chip-edit:hover { opacity: 1; background: var(--accent-soft); }
.chip-list--editable .chip-del:hover  { opacity: 1; background: #fde6e3; color: #c0392b; }

/* ============================== TABS CON ICONO ============================== */
.tabs--admin .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tabs--admin .tab > span {
  display: inline;
}

/* ============================== RESPONSIVE (móvil/tablet) ============================== */
@media (max-width: 720px) {
  .modal__panel--wide {
    padding: 16px;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    height: 100dvh;
    overflow-y: auto;
  }
  .tabs--admin {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tabs--admin::-webkit-scrollbar { display: none; }
  .tabs--admin .tab {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: .9em;
  }
  .tabs--admin .tab > span {
    /* En móvil, escondemos el texto y dejamos solo el emoji para ahorrar espacio.
       En la tab activa, lo volvemos a mostrar para que se entienda dónde estás. */
    display: none;
  }
  .tabs--admin .tab.is-active > span {
    display: inline;
  }
  .form-advanced__body {
    grid-template-columns: 1fr;
  }
  .location-helper__btns {
    flex-direction: column;
  }
  .location-helper__btns .btn--secondary { width: 100%; }
  .btn--large {
    width: 100%;
  }
  .form__actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .form__actions .btn { width: 100%; }
  .admin-table {
    font-size: .88em;
  }
  .admin-table .row-actions {
    flex-direction: column;
    gap: 3px;
  }
  .dashboard__hero h3 { font-size: 1.4rem; }
  .stat-card__num { font-size: 1.6rem; }
  .action-card { padding: 14px; }
  .action-card__icon { font-size: 1.6rem; }
}


/* ============================================================================
   v2.4 — REDISEÑO TURISTA
   Filosofía: ligero, elegante, imágenes protagonistas, info clara,
   patrón "bottom sheet" en móvil, accesible a personas mayores.
   ============================================================================ */

/* ============================== BÚSQUEDA Y ORDEN ============================== */
.panel__head {
  margin-bottom: 14px;
}
.search-bar {
  position: relative;
  margin: 0 0 12px;
}
.search-bar__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-bar input {
  width: 100%;
  padding: 12px 14px 12px 40px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: inherit;
  font-size: .95em;
  transition: all .18s ease;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.search-bar input::placeholder { color: var(--muted); }

.sort-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: .85em;
}
.sort-bar__label {
  color: var(--muted);
}
.segmented {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: 100px;
  padding: 3px;
  border: 1px solid var(--line);
}
.segmented__opt {
  background: transparent;
  border: none;
  padding: 5px 12px;
  border-radius: 100px;
  font-family: inherit;
  font-size: .9em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s ease;
}
.segmented__opt:hover { color: var(--ink); }
.segmented__opt.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  font-weight: 600;
}

/* ============================== CITY CARDS (lista pueblos) ============================== */
/* Sustituimos las city-card existentes por un diseño con imagen protagonista */
.city-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.city-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .15s ease;
  animation: card-in .35s ease both;
}
.city-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px -10px rgba(0,0,0,.18);
  border-color: var(--accent);
}
.city-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  overflow: hidden;
}
.city-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s ease;
}
.city-card:hover .city-card__media img {
  transform: scale(1.04);
}
.city-card__media--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-soft));
  color: var(--accent-2);
}
.city-card__distance {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  padding: 5px 10px;
  border-radius: 100px;
  font-size: .78em;
  font-weight: 600;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  gap: 4px;
}
.city-card__body {
  padding: 14px 16px 16px;
}
.city-card__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 4px;
  color: var(--ink);
  font-weight: 600;
}
.city-card__provincia {
  font-size: .82em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.city-card__desc {
  font-size: .9em;
  color: var(--ink-soft);
  margin-top: 8px;
  line-height: 1.45;
  /* Cortar a 2 líneas con elipsis.
   * v2.5: declaramos ambas: la propiedad estándar (line-clamp) y la prefijada
   * (-webkit-line-clamp). VS Code avisa porque la estándar ya existe; los
   * navegadores que aún no la soportan caen al prefix. */
  display: -webkit-box;
  display: box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================== HERO CIUDAD (al entrar) ============================== */
.city-hero {
  position: relative;
  width: calc(100% + 32px);
  margin: -16px -16px 14px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-soft);
}
.city-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.city-hero__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 18px;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent 55%);
  color: #fff;
}
.city-hero__title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 2px 12px rgba(0,0,0,.45);
}
.city-hero__provincia {
  font-size: .85em;
  opacity: .92;
  margin-top: 2px;
  text-shadow: 0 1px 6px rgba(0,0,0,.45);
}
.city-head-noimg {
  margin-bottom: 12px;
}
.ciudad-desc {
  color: var(--ink-soft);
  font-size: .92em;
  line-height: 1.55;
  margin: 0 0 16px;
}

/* ============================== ACCIONES DE CIUDAD (botones rápidos) ============================== */
.city-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.btn--icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn--icon-text svg {
  flex-shrink: 0;
}

/* ============================== TABS SEGMENTADAS ============================== */
.tabs--segmented {
  background: var(--bg-soft);
  border-radius: 100px;
  padding: 4px;
  display: inline-flex;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  width: 100%;
}
.tabs--segmented .tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 9px 14px;
  border-radius: 100px;
  font-family: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .18s ease;
  font-size: .92em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tabs--segmented .tab:hover { color: var(--ink); }
.tabs--segmented .tab.is-active {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  font-weight: 600;
}
.tab__emoji {
  font-size: 1.05em;
}

/* ============================== CHIPS FILTRO POR CATEGORÍA ============================== */
.filtros-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  /* Pequeño "edge fade" para indicar scroll horizontal.
   * v2.5: -webkit-mask-image necesario para Safari < 15.4 */
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
}
.filtros-chips::-webkit-scrollbar { display: none; }
.filtro-chip {
  flex-shrink: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: .85em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.filtro-chip:hover {
  border-color: var(--accent);
}
.filtro-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ============================== POI LIST CARDS (lugares dentro de un pueblo) ============================== */
.poi-list, .route-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.poi-item, .route-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s ease;
  animation: card-in .3s ease both;
}
.poi-item:hover, .route-item:hover {
  border-color: var(--accent);
  transform: translateX(2px);
  box-shadow: 0 4px 14px -6px rgba(0,0,0,.12);
}
.poi-item__icon, .route-item__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.poi-item__body, .route-item__body {
  flex: 1;
  min-width: 0;
}
.poi-item__title, .route-item__title {
  font-weight: 600;
  font-size: 1em;
  color: var(--ink);
  margin: 0 0 2px;
  /* Cortar a una línea */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.poi-item__meta, .route-item__meta {
  font-size: .82em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.poi-item__meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}
.poi-item__chev {
  color: var(--muted);
  opacity: .5;
  font-size: 1.1em;
  flex-shrink: 0;
}

/* ============================== MODAL POI REDISEÑADO ============================== */
.modal__panel--poi {
  padding: 0;
  max-width: 580px;
  overflow: hidden;
}
.modal__close--floating {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  background: rgba(0,0,0,.55);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .15s ease;
}
.modal__close--floating:hover {
  background: rgba(0,0,0,.75);
}

.poi-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  overflow: hidden;
}
.poi-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.poi-hero__gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 50%, rgba(0,0,0,.4));
  pointer-events: none;
}
.poi-body {
  padding: 18px 22px 22px;
}
.poi-body__head {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chip--accent {
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 600;
}
.chip--muted {
  background: var(--bg-soft);
  color: var(--ink-soft);
}
.poi-titulo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}
.poi-desc {
  color: var(--ink-soft);
  font-size: .95em;
  line-height: 1.55;
  margin: 0 0 16px;
}
.poi-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

/* ============================== SHEET HANDLE (móvil) ============================== */
/* Botón inferior, tipo "tirador", para abrir el sidebar como sheet en móvil. */
.sheet-handle {
  display: none;            /* solo móvil */
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: 10px 22px 10px 18px;
  box-shadow: 0 6px 20px -4px rgba(0,0,0,.2);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: .92em;
  color: var(--ink);
  align-items: center;
  gap: 10px;
  transition: all .18s ease;
}
.sheet-handle:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 10px 24px -4px rgba(0,0,0,.25);
}
.sheet-handle__grip {
  display: inline-block;
  width: 26px;
  height: 4px;
  background: var(--ink-soft);
  border-radius: 2px;
  opacity: .55;
}
.sheet-handle__text {
  /* v2.5: la regla antes estaba vacía (warning VS Code). Le damos estilos
   * reales para mantener consistencia tipográfica con el resto de botones. */
  white-space: nowrap;
  letter-spacing: .01em;
}

/* ============================== ESTADOS VACÍOS AMABLES ============================== */
.empty-discover {
  padding: 36px 18px;
  text-align: center;
  color: var(--muted);
}
.empty-discover__icon {
  font-size: 2.6rem;
  margin-bottom: 10px;
  opacity: .65;
}
.empty-discover h3 {
  margin: 4px 0 6px;
  color: var(--ink);
  font-size: 1.05rem;
}
.empty-discover p {
  margin: 0 0 14px;
  font-size: .92em;
}

/* ============================== SKELETON LOADING ============================== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--line) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.skeleton-card__media { width: 100%; aspect-ratio: 16/9; }
.skeleton-card__body { padding: 14px 16px 16px; }
.skeleton-card__line { height: 14px; margin-bottom: 8px; }
.skeleton-card__line--short { width: 60%; height: 12px; }

/* ============================== FAB MÁS DISCRETO ============================== */
/* El FAB de admin ya existía; aquí lo refinamos para que sea más sutil
   y no compita visualmente con el contenido turístico. */
.fab {
  bottom: 70px !important;   /* deja sitio al sheet-handle en móvil */
  width: 52px;
  height: 52px;
  background: var(--bg-elev);
  color: var(--accent-2);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px -4px rgba(0,0,0,.25);
  transition: all .18s ease;
}
.fab:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-2px) scale(1.05);
}

/* ============================================================================
   v2.5 — SCROLL EN MÓVIL ROBUSTO
   Arregla los siguientes problemas que se daban en la v2.4:
   - Doble scroll: al llegar al final del sheet, scrolleaba el body de fondo
   - Mapa capturaba pan/zoom cuando se arrastraba dentro del sheet
   - 100vh fantasma en iOS con la barra de URL
   - Saltos al abrir/cerrar el sheet
   ============================================================================ */
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    /* dvh = dynamic vh, descuenta automáticamente la barra del navegador móvil */
    height: 80vh;
    height: 80dvh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
    z-index: 900;
    box-shadow: 0 -8px 28px -8px rgba(0,0,0,.25);
    overflow-y: auto;
    /* v2.5: clave para evitar "scroll chaining" — cuando llegas al final del
     * sheet, el scroll NO se transfiere al body de fondo. */
    overscroll-behavior: contain;
    /* v2.5: indicamos al navegador que solo aceptamos pan vertical aquí, así
     * Leaflet (que es el contenedor padre) no roba el gesto. */
    touch-action: pan-y;
    /* v2.5: padding inferior para iPhone con notch/home-bar */
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  }
  .sidebar.is-open {
    transform: translateY(0);
  }

  /* Pequeño grip en la parte superior del sheet */
  .sidebar::before {
    content: "";
    display: block;
    width: 44px;
    height: 5px;
    background: var(--line-strong);
    border-radius: 3px;
    margin: 10px auto 6px;
    opacity: .6;
    /* v2.5: el grip no debe ser scroll-target */
    flex-shrink: 0;
    /* Indicación visual de que es agarrable (gesture hint) */
    cursor: grab;
  }

  .sheet-handle {
    display: inline-flex;
    /* v2.5: respetar safe-area para iPhone */
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar.is-open ~ .sheet-handle { display: none; }

  /* v2.5: el mapa sí acepta todos los gestos */
  #map {
    touch-action: pan-x pan-y pinch-zoom;
  }

  /* Modal POI ocupa toda la pantalla en móvil, como apps nativas */
  .modal__panel--poi {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    /* v2.5: mismas protecciones que el sheet */
    overscroll-behavior: contain;
    touch-action: pan-y;
    /* v2.5: el último botón no debe quedar tapado por la home-bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .poi-hero { aspect-ratio: 4 / 3; }
  .poi-body { padding: 16px 18px 28px; }
  .poi-titulo { font-size: 1.4rem; }

  /* En móvil, las city-actions y poi-actions son botones grandes apilables */
  .city-actions .btn,
  .poi-actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 42px;
    font-size: .92em;
  }

  /* Hide del FAB cuando la sidebar/sheet está abierta para no competir */
  .sidebar.is-open ~ .fab { display: none; }

  .sheet-handle__text { font-size: .88em; }
}

/* Tablet: layout intermedio */
@media (min-width: 861px) and (max-width: 1100px) {
  .sidebar {
    width: 340px;
  }
  .city-hero { aspect-ratio: 21 / 9; }
}

/* ============================== PROXIMITY MODAL CON MÁS PRESENCIA ============================== */
.proximity-modal {
  animation: prox-in .4s cubic-bezier(.34, 1.4, .6, 1) both;
}
@keyframes prox-in {
  from { opacity: 0; transform: translate(-50%, 20px) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ============================== ACCESIBILIDAD ============================== */
/* Foco visible y consistente para teclado */
.btn:focus-visible,
.icon-btn:focus-visible,
.tab:focus-visible,
.segmented__opt:focus-visible,
.filtro-chip:focus-visible,
.city-card:focus-visible,
.poi-item:focus-visible,
.route-item:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* Respetar reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}


/* ============================================================================
   v2.5 — NAVEGACIÓN INTEGRADA (sin Google Maps)
   Componentes visuales para la ruta tipo "Google Maps" que dibujamos con OSRM
   ============================================================================ */

/* Polilínea — usamos clases CSS via Leaflet "className" para que herede
   el color del tema y se pueda re-estilizar fácil. La geometría se aplica
   al SVG path que Leaflet genera. */
.leaflet-route-shadow {
  /* Halo gris oscuro debajo para crear contraste sobre cualquier mapa */
  stroke: rgba(0, 0, 0, .35);
  stroke-width: 9;
  fill: none;
}
.leaflet-route-line {
  /* Línea principal azul, estilo Google Maps */
  stroke: #1976ff;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  /* Pequeña animación de "respiración" en la línea para feedback visual */
  filter: drop-shadow(0 0 4px rgba(25, 118, 255, .35));
}

/* Marcador "destino" estilo pin de Google Maps */
.leaflet-route-dest {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: #1976ff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
  border: 3px solid #fff;
}
.leaflet-route-dest > span {
  transform: rotate(45deg);
}

/* Marcador "origen" — punto azul pulsante en tu ubicación */
.leaflet-route-origin {
  width: 18px;
  height: 18px;
  background: #1976ff;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #1976ff, 0 2px 6px rgba(0, 0, 0, .3);
  position: relative;
}
.leaflet-route-origin::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(25, 118, 255, .25);
  animation: pulse-origin 1.8s ease-out infinite;
}
@keyframes pulse-origin {
  0%   { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ============================== BANNER DE NAVEGACIÓN ACTIVA ============================== */
.nav-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 950;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 36px -8px rgba(0, 0, 0, .25);
  overflow: hidden;
  animation: nav-banner-in .3s cubic-bezier(.34, 1.4, .6, 1) both;
  max-width: 540px;
  margin: 0 auto;
}
@keyframes nav-banner-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nav-banner.fading {
  opacity: 0;
  transform: translateY(20px);
  transition: all .25s ease;
}

.nav-banner__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.nav-banner__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #1976ff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em;
}
.nav-banner__body {
  flex: 1;
  min-width: 0;
}
.nav-banner__title {
  font-weight: 700;
  font-size: 1em;
  color: var(--ink);
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-banner__meta {
  font-size: .85em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.nav-banner__meta strong {
  color: #1976ff;
}
.nav-banner__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: none;
  font-size: 1.2em;
  cursor: pointer;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.nav-banner__close:hover { background: var(--line); }

.nav-banner__actions {
  display: flex;
  gap: 0;
  border-top: 1px solid var(--line);
}
.nav-banner__action {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 8px;
  font-family: inherit;
  font-size: .88em;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s ease;
}
.nav-banner__action + .nav-banner__action {
  border-left: 1px solid var(--line);
}
.nav-banner__action:hover {
  background: var(--bg-soft);
}
.nav-banner__action--primary {
  color: #1976ff;
}

/* En móvil ocupa todo el ancho menos los márgenes y respeta el FAB */
@media (max-width: 860px) {
  .nav-banner {
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  /* Si el banner de nav está visible, el sheet handle se sube */
  body.nav-active .sheet-handle {
    bottom: calc(160px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================== POPUP LEAFLET MEJORADO ============================== */
/* Aplicamos un estilo más limpio y moderno a los popups por defecto de Leaflet */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 6px 20px -6px rgba(0,0,0,.25) !important;
  padding: 2px !important;
}
.leaflet-popup-content {
  margin: 12px 14px !important;
  font-family: var(--font-sans);
  font-size: .92em;
  line-height: 1.4;
}
.leaflet-popup-tip {
  box-shadow: none !important;
}

/* ============================== FALLBACKS / COMPATIBILIDAD ============================== */
/* v2.5: si el navegador no soporta backdrop-filter, garantizamos un fondo
   sólido legible. La detección @supports evita rupturas en Firefox antiguos. */
@supports not (backdrop-filter: blur(1px)) {
  .topbar {
    background: var(--bg-elev);
  }
  .city-card__distance,
  .modal__close--floating {
    background: rgba(0, 0, 0, .85);
  }
}


/* ============================================================================
   v2.6 — CORRECCIONES UX
   ============================================================================ */

/* ============================== BOTÓN "VOLVER" FLOTANTE SOBRE HERO ============================== */
/* v2.6: el botón antes quedaba tapado por el hero (margin negativo del hero).
   Ahora se posiciona absolute encima, con fondo translúcido + blur. */
.city-hero-wrap {
  position: relative;
  /* compensamos el padding del panel para que el hero ocupe el ancho completo */
  margin: -16px -16px 14px;
}
.city-hero-wrap > .city-hero {
  margin: 0;
  width: 100%;
}
.city-head-noimg {
  padding: 16px 18px 0;
}

.link-back--overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;          /* por encima del hero pero por debajo del modal */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 10px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: 100px;
  font-family: inherit;
  font-size: .88em;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all .15s ease;
  /* Aseguramos área táctil mínima de 44x44 para accesibilidad */
  min-height: 38px;
}
.link-back--overlay:hover {
  background: #fff;
  transform: translateX(-2px);
}
.link-back--overlay:active {
  transform: translateX(-2px) scale(.97);
}
[data-theme="dark"] .link-back--overlay {
  background: rgba(31, 28, 22, .92);
  color: var(--ink);
  border-color: rgba(255, 255, 255, .08);
}
[data-theme="dark"] .link-back--overlay:hover {
  background: var(--bg-elev);
}

/* Si NO hay imagen (.city-hero hidden), el botón se mueve a posición normal */
.city-hero-wrap:has(#ciudad-hero[hidden]) .link-back--overlay {
  position: static;
  margin: 0 0 12px;
}

/* ============================== SCROLL EN DESKTOP (panel ciudad + sidebar) ============================== */
/* v2.6: en desktop, si el contenido del pueblo (descripción larga, lista de
   POIs grande) supera el alto del viewport, el sidebar entero debe scrollear.
   El bug anterior: overflow estaba solo en el media query móvil. */
@media (min-width: 861px) {
  .sidebar {
    overflow-y: auto;
    overscroll-behavior: contain;
    /* La sidebar ya tiene height por el grid, pero forzamos para Safari */
    max-height: calc(100dvh - var(--topbar-h));
  }
  /* Modal POI con scroll y altura limitada en desktop */
  .modal__panel--poi {
    max-height: calc(100dvh - 60px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* ============================== DESCRIPCIÓN DE RUTA CON SCROLL FLUIDO ============================== */
.poi-desc--scroll {
  max-height: 50vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* Espacio para que la barra de scroll no se solape con el texto */
  padding-right: 8px;
  /* Texto pre-wrap para respetar saltos de línea en descripciones largas */
  white-space: pre-wrap;
}
/* Scrollbar fina y estética dentro de descripciones */
.poi-desc--scroll::-webkit-scrollbar { width: 6px; }
.poi-desc--scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}
.poi-desc--scroll::-webkit-scrollbar-track { background: transparent; }

/* ============================== MODAL "PEGAR COORDENADAS" ============================== */
.paste-formats {
  list-style: none;
  padding: 0;
  margin: 8px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.paste-formats li {
  font-size: .85em;
  color: var(--ink-soft);
}
.paste-formats code {
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: .92em;
}
#paste-coords-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: .95em;
}
#paste-coords-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============================== ESTILO DE AVISO INLINE EN FORM POI ============================== */
.warn { color: #c0392b; }
[data-theme="dark"] .warn { color: #e87b6d; }

/* ============================== TARJETA DE RUTA: TÍTULO Y META SIN CORTAR ============================== */
.route-item__meta {
  /* v2.6: antes el meta truncaba a 50 chars la descripción. Ahora dejamos
     que ocupe varias líneas con overflow controlado en el contenedor padre. */
  white-space: normal;
}
.route-item__title {
  /* Permitir hasta 2 líneas en lugar de cortar siempre a 1 */
  white-space: normal;
  display: -webkit-box;
  display: box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================== SCROLL FALLBACK GLOBAL EN DESKTOP ============================== */
/* Para que el modal admin también scrollee bien en desktop, sin doble scroll. */
@media (min-width: 861px) {
  .modal__panel--wide {
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}


/* v2.6: preview de descripción en tarjeta de ruta (2 líneas con elipsis).
 * El texto completo se ve en el modal de detalle. */
.route-item__preview {
  margin: 4px 0 0;
  font-size: .82em;
  color: var(--ink-soft);
  line-height: 1.4;
  display: -webkit-box;
  display: box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ============================================================================
   v2.7 — Estado de ruta en tarjetas POI (única fuente de verdad)
   ============================================================================ */
.poi-item__route {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.poi-item__route.is-loading {
  color: var(--muted);
  font-style: italic;
  opacity: .85;
}
.poi-item__route.is-loading::before {
  content: "";
  width: 10px; height: 10px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: 4px;
}
.poi-item__route.is-ok       { color: var(--ink); }
.poi-item__route.is-far      { color: #c87a30; font-style: italic; }
.poi-item__route.is-unavail  { color: var(--muted); font-style: italic; opacity: .8; }

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

/* =============================================================================
   v2.x — AJUSTES, FAVORITOS, PAGINACIÓN
   ============================================================================= */

/* ---- Modal de ajustes: lista de opciones con switch ---- */
.ajustes-lista {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 16px 0 8px;
}
.ajuste-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.ajuste-item:last-child { border-bottom: none; }
.ajuste-item__texto { display: flex; flex-direction: column; gap: 2px; }
.ajuste-item__titulo { font-weight: 600; color: var(--ink); }
.ajuste-item__sub { font-size: .85rem; color: var(--muted); line-height: 1.35; }

.ajustes-seccion {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.ajustes-seccion .admin-h3 { margin: 0 0 6px; }

/* ---- Switch (toggle) accesible, construido sobre un checkbox nativo ---- */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background .2s ease;
  outline-offset: 3px;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--accent); }

/* ---- Botón segmentado a ancho completo (Todos / Favoritos) ---- */
.segmented--full {
  display: flex;
  width: 100%;
  margin: 4px 0 12px;
}
.segmented--full .segmented__opt { flex: 1; text-align: center; }

/* ---- Estrella de favorito en tarjetas de POI ---- */
.poi-item { position: relative; }
.poi-item__fav {
  flex: 0 0 auto;
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--line-strong);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color .15s ease, transform .15s ease;
}
.poi-item__fav:hover { transform: scale(1.15); color: var(--accent); }
.poi-item__fav.is-on { color: #e8a317; }   /* dorado cuando está activo */

/* ---- Botón de favorito en el modal POI (estado activo) ---- */
#btn-poi-favorito.is-on {
  background: var(--accent-soft);
  color: #c8860d;
  border-color: color-mix(in srgb, #e8a317 35%, transparent);
}
#btn-poi-favorito.is-on .ico-fav {
  fill: #e8a317;            /* estrella rellena de dorado cuando es favorito */
  stroke: #e8a317;
}
[data-theme="dark"] #btn-poi-favorito.is-on { color: #e8a317; }

/* ---- Paginación de tablas admin ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pagination__info {
  font-size: .85rem;
  color: var(--muted);
  min-width: 160px;
  text-align: center;
}
.pagination .btn[disabled] {
  opacity: .4;
  pointer-events: none;
}

/* =============================================================================
   v2.x — IMPORTADOR TXT, CENTRO DE NOTIFICACIONES, BANDEJA
   ============================================================================= */

/* ---- Badge de la bandeja en la topbar ---- */
.icon-btn { position: relative; }
.bandeja-badge {
  position: absolute;
  top: 2px; right: 6px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* ---- Bandeja de avisos ---- */
.bandeja-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bandeja-lista { list-style: none; padding: 0; margin: 12px 0 0; max-height: 60vh; overflow-y: auto; }
.bandeja-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); margin-bottom: 8px;
  transition: border-color .15s ease, transform .15s ease;
}
.bandeja-item.is-clickable { cursor: pointer; }
.bandeja-item.is-clickable:hover { border-color: var(--accent); transform: translateX(2px); }
.bandeja-item.is-nueva { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.bandeja-item__body { flex: 1; min-width: 0; }
.bandeja-item__title { margin: 0; font-weight: 600; color: var(--ink); }
.bandeja-item__msg { margin: 2px 0 0; font-size: .9rem; color: var(--ink-soft); }
.bandeja-item__time { font-size: .75rem; color: var(--muted); }
.bandeja-item__chev { color: var(--muted); font-size: 1.3rem; }

/* ---- Importador TXT ---- */
.importar-paso { margin-top: 12px; }
.importar-campo { display: block; margin-bottom: 14px; }
.importar-campo select { width: 100%; }
.importar-formato {
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 12px 14px; margin: 10px 0;
}
.importar-formato__code {
  display: block; margin: 8px 0; padding: 8px 10px;
  background: var(--bg-elev); border: 1px dashed var(--line-strong);
  border-radius: 6px; font-size: .82rem; overflow-x: auto; white-space: nowrap;
}
.importar-dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 28px 16px; margin-top: 8px;
  border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--bg-soft); cursor: pointer; text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.importar-dropzone:hover, .importar-dropzone.is-drag {
  border-color: var(--accent); background: var(--accent-soft);
}
.importar-dropzone__icon { font-size: 2.2rem; }
.importar-dropzone__text { color: var(--muted); font-size: .9rem; }

/* Resumen con chips de estado */
.importar-resumen { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip-stat {
  padding: 5px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  border: 1px solid var(--line);
}
.chip-stat--ok  { background: #e7f6ec; color: #1d7a3e; border-color: #b9e3c6; }
.chip-stat--dup { background: #fdf3e0; color: #9a6a16; border-color: #f0d9a8; }
.chip-stat--err { background: #fdeaea; color: #b3261e; border-color: #f2c4c0; }
.chip-stat--ign { background: var(--bg-soft); color: var(--muted); }
[data-theme="dark"] .chip-stat--ok  { background: #173d27; color: #7fd49b; }
[data-theme="dark"] .chip-stat--dup { background: #3d3115; color: #e8c478; }
[data-theme="dark"] .chip-stat--err { background: #3d1b1a; color: #f0a39c; }

.importar-duplicados {
  background: #fdf3e0; border: 1px solid #f0d9a8; color: #7a5512;
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 4px 0 14px;
}
[data-theme="dark"] .importar-duplicados { background: #332813; border-color: #5c4a1f; color: #e8c478; }
.importar-duplicados .segmented { margin-top: 8px; }

.importar-preview-wrap { max-height: 40vh; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.importar-preview { margin: 0; }
.importar-preview tr.fila-invalida  { background: color-mix(in srgb, #b3261e 8%, transparent); }
.importar-preview tr.fila-duplicada { background: color-mix(in srgb, #9a6a16 8%, transparent); }
.estado-badge { padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.estado-badge--ok  { background: #e7f6ec; color: #1d7a3e; }
.estado-badge--dup { background: #fdf3e0; color: #9a6a16; }
.estado-badge--err { background: #fdeaea; color: #b3261e; }

.importar-resultado { text-align: center; padding: 20px 10px; }
.importar-ok-icon { font-size: 3rem; }
.importar-resultado-lista { list-style: none; padding: 0; margin: 12px 0; display: inline-block; text-align: left; }
.importar-resultado-lista li { padding: 4px 0; }
.text-err { color: #b3261e; }
[data-theme="dark"] .text-err { color: #f0a39c; }

/* ---- Centro de Notificaciones ---- */
.notif-tab { margin-top: 14px; }
.notif-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.notif-grid .span-2 { grid-column: 1 / -1; }
.notif-grid label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.notif-plantillas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.notif-plantillas .chip { cursor: pointer; border: none; }

.notif-preview { margin: 16px 0; }
.notif-preview__label { font-size: .8rem; color: var(--muted); }
.notif-preview__card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-top: 6px;
  box-shadow: var(--shadow);
}
.notif-preview__icon { font-size: 1.5rem; }
.notif-preview__body { display: flex; flex-direction: column; gap: 2px; }
.notif-preview__body strong { color: var(--ink); }
.notif-preview__body span { color: var(--ink-soft); font-size: .9rem; }

@media (max-width: 640px) {
  .notif-grid { grid-template-columns: 1fr; }
}

/* =============================================================================
   v2.x — RESEÑAS Y MODERACIÓN
   ============================================================================= */

/* ---- Media de estrellas en cabecera del POI ---- */
.poi-rating { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.poi-rating__stars { letter-spacing: 1px; }
.poi-rating__num { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* Estrellas decorativas (llena / media / vacía) */
.star { color: var(--line-strong); font-size: 1.05rem; }
.star--full { color: #e8a317; }
.star--half {
  position: relative; color: var(--line-strong);
}
.star--half::before {
  content: "★"; position: absolute; left: 0; top: 0;
  width: 50%; overflow: hidden; color: #e8a317;
}

/* ---- Estrellas en tarjeta de POI (lista) ---- */
.poi-item__rating { color: #c8860d; font-weight: 700; font-size: .8rem; white-space: nowrap; }
.poi-item__rating-count { color: var(--muted); font-weight: 500; margin-left: 2px; }
[data-theme="dark"] .poi-item__rating { color: #e8a317; }

/* ---- Sección de reseñas en el modal POI ---- */
.poi-resenas { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.poi-resenas__titulo { margin: 0 0 12px; font-size: 1.1rem; }

/* Formulario de reseña propia */
.resena-form {
  background: var(--bg-soft); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px;
}
.resena-form__label { margin: 0 0 8px; font-weight: 600; color: var(--ink); }
.resena-form textarea {
  width: 100%; margin-top: 10px; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font: inherit; background: var(--bg-elev); color: var(--ink);
}
.resena-form__actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.resena-form__estado { margin: 8px 0 0; }

/* Selector de estrellas interactivo */
.estrellas-input { display: inline-flex; gap: 4px; }
.estrellas-input .estrella {
  background: none; border: none; cursor: pointer;
  font-size: 1.8rem; line-height: 1; color: var(--line-strong);
  padding: 0; transition: color .12s ease, transform .12s ease;
}
.estrellas-input .estrella:hover { transform: scale(1.15); }
.estrellas-input .estrella.is-on,
.estrellas-input .estrella.is-hover { color: #e8a317; }

/* Lista de reseñas aprobadas */
.resena-lista { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.resena-item {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px;
}
.resena-item__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.resena-item__autor { font-weight: 600; color: var(--ink); }
.resena-item__stars { letter-spacing: 1px; white-space: nowrap; }
.resena-item__texto { margin: 8px 0 4px; color: var(--ink-soft); line-height: 1.45; }
.resena-item__fecha { font-size: .75rem; color: var(--muted); }

/* ---- Badge en pestaña de admin ---- */
.tab-badge {
  display: inline-block; min-width: 16px; height: 16px; padding: 0 4px;
  margin-left: 4px; border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: .65rem; font-weight: 700; line-height: 16px; text-align: center;
}

/* ---- Panel de moderación ---- */
.moderacion-lista { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.moderacion-item {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; background: var(--bg-elev);
}
.moderacion-item__top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.moderacion-item__poi { font-weight: 600; color: var(--ink); font-size: .9rem; }
.moderacion-item__texto { margin: 4px 0 10px; color: var(--ink-soft); line-height: 1.45; }
.moderacion-item__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.moderacion-item__acciones { display: flex; align-items: center; gap: 6px; }

@media (max-width: 640px) {
  .moderacion-item__meta { flex-direction: column; align-items: flex-start; }
}