:root {
  --bg: #f3f6f9;
  --card: #ffffff;
  --line: #e2e8ee;
  --text: #1c2833;
  --muted: #66727e;
  --accent: #1f7ae0;
  --accent-soft: #e6f0fc;
  --shadow: 0 1px 3px rgba(20, 40, 60, .08), 0 4px 16px rgba(20, 40, 60, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c; --card: #1a2129; --line: #2a333d; --text: #e6e9ec;
    --muted: #93a0ad; --accent: #4a9df0; --accent-soft: #1d2d40;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
.muted { color: var(--muted); }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }

/* ---------- cabecera ---------- */
header { background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 16px 0; position: sticky; top: 0; z-index: 2000; }
.brand { display: flex; align-items: center; gap: 12px; max-width: 1400px; margin: 0 auto; }
.logo { line-height: 0; }
h1 { font-size: 20px; margin: 0; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }
nav { display: flex; gap: 4px; max-width: 1400px; margin: 10px auto 0; overflow-x: auto; }
nav a { flex: none; border-bottom: 3px solid transparent; color: var(--muted); padding: 10px 14px; font-weight: 600; text-decoration: none; }
nav a:hover { color: var(--text); }
nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.logo img { display: block; }

main { max-width: 1400px; margin: 0 auto; padding: 16px; }
.tab { display: none; }
.tab.active { display: block; }
.tab-intro { margin-bottom: 16px; }
.tab-intro h2 { margin: 0 0 4px; font-size: 22px; }
.tab-intro p { margin: 0 0 12px; color: var(--muted); }
.subtitulo { margin: 24px 0 12px; }

/* ---------- resumen ---------- */
.resumen { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; background: var(--card); border-radius: 14px; padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 16px; border-left: 6px solid var(--accent); }
.resumen.seco { border-left-color: #4cc38a; }
.resumen.llueve { border-left-color: #f5b82e; }
.resumen.fuerte { border-left-color: #e5484d; }
.resumen-icono { font-size: 48px; line-height: 1; }
.resumen-texto { flex: 1 1 280px; }
.resumen-texto h2 { margin: 0; font-size: 22px; }
.resumen-texto p { margin: 4px 0 0; color: var(--muted); }
.resumen-datos { display: flex; gap: 10px; flex-wrap: wrap; }
.dato { background: var(--bg); border-radius: 10px; padding: 8px 14px; text-align: center; min-width: 96px; }
.dato b { display: block; font-size: 22px; }
.dato span { font-size: 12px; color: var(--muted); }

/* ---------- mapa ---------- */
.layout-mapa { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.mapa-wrap { background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
#map { height: 62vh; min-height: 380px; }
.tiles-oscuros { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9); }

.player { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-top: 1px solid var(--line); }
.btn-play, .btn { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn-play:hover, .btn:hover { filter: brightness(1.1); }
.player-tiempo { flex: 1; }
#slider { width: 100%; accent-color: var(--accent); }
.player-etiquetas { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
#frame-time { font-weight: 600; color: var(--text); font-size: 13px; }

.panel { background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); max-height: calc(62vh + 64px); overflow: auto; }
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.panel h3:not(:first-child) { margin-top: 20px; }

.opciones { display: grid; gap: 8px; }
.opcion { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.opcion:hover { border-color: var(--accent); }
.opcion.on { border-color: var(--accent); background: var(--accent-soft); }
.opcion input { display: none; }
.opcion .ico { font-size: 22px; line-height: 1.2; }
.opcion b { display: block; font-size: 14px; }
.opcion small { color: var(--muted); font-size: 12px; line-height: 1.35; display: block; }
.opcion .check { margin-left: auto; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 12px; color: #fff; }
.opcion.on .check { background: var(--accent); border-color: var(--accent); }
.opcion.on .check::after { content: "✓"; }
.fondo { display: flex; gap: 6px; margin-top: 4px; }
.fondo button { flex: 1; border: 2px solid var(--line); background: none; color: var(--text); border-radius: 8px; padding: 6px; font: inherit; font-size: 13px; cursor: pointer; }
.fondo button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.leyenda { margin-top: 16px; background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.leyenda summary { cursor: pointer; font-weight: 600; }
.leyenda p { margin: 8px 0 4px; }
.gradiente { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #7fd3f7, #2e8ef0, #33c26a, #f5e02e, #f5902e, #e5484d, #b43cc8); }
.gradiente-etq { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.puntos { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.puntos i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; border: 1px solid rgba(0,0,0,.25); }

.zonas { list-style: none; padding: 0; margin: 0; }
.zonas li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.zonas li:last-child { border: 0; }
.chip { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }

/* popups */
.leaflet-popup-content { font: 14px/1.45 system-ui, sans-serif; min-width: 200px; }
.pop h4 { margin: 0 0 2px; font-size: 15px; }
.pop .lugar { color: #66727e; font-size: 12px; margin-bottom: 8px; }
.pop .filas { display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; }
.pop .filas b { text-align: right; }
.pop .nota { color: #66727e; font-size: 11px; margin-top: 8px; }

/* ---------- tarjetas ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.card h4 { margin: 0 0 8px; font-size: 16px; }
.card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; background: var(--bg); cursor: zoom-in; }
.card p { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* pronóstico */
#zona-select { font: inherit; padding: 8px 12px; border-radius: 8px; border: 2px solid var(--line); background: var(--card); color: var(--text); min-width: 240px; }
.pron-dias { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.pron-dia h4 { display: flex; justify-content: space-between; align-items: baseline; }
.temp { font-size: 14px; color: var(--muted); font-weight: 400; }
.temp b { color: var(--text); }
.franjas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.franja { background: var(--bg); border-radius: 10px; padding: 8px 4px; }
.franja .e { font-size: 26px; display: block; }
.franja small { display: block; font-size: 11px; color: var(--muted); }
.franja .p { font-size: 12px; font-weight: 600; }
.principal .franja .e { font-size: 34px; }
.principal .pron-dia { border: 2px solid var(--accent); }
.p-BAJA { color: #2f9e6a; } .p-MEDIA { color: #c98a00; } .p-ALTA { color: #d6363b; }

/* visor */
.visor { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 5000; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 16px 16px; }
.visor[hidden] { display: none; }
.visor img { max-width: 100%; max-height: calc(100vh - 130px); border-radius: 8px; object-fit: contain; }
.visor p { color: #ccc; margin: 10px 0 0; text-align: center; font-size: 14px; }
.visor-barra { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: 12px 16px; color: #fff; font-weight: 600; }
.visor-barra span { flex: 1; }
.visor-barra a { color: #9cc9ff; font-weight: 400; font-size: 14px; }
.visor-cerrar { background: none; border: 0; color: #fff; font-size: 28px; cursor: pointer; line-height: 1; }
.visor-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.15); color: #fff; border: 0; width: 48px; height: 64px; font-size: 36px; border-radius: 8px; cursor: pointer; }
.visor-nav:hover { background: rgba(255,255,255,.3); }
.visor-nav.prev { left: 12px; } .visor-nav.next { right: 12px; }
.visor-nav[hidden] { display: none; }
.card .acciones { display: flex; gap: 8px; margin-top: 10px; }
.btn-sec { flex: 1; text-align: center; border: 2px solid var(--line); background: none; color: var(--text); border-radius: 8px; padding: 7px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-sec:hover { border-color: var(--accent); color: var(--accent); }
.temp-label { background: #fff; border-radius: 999px; padding: 2px 7px; font: 700 12px system-ui, sans-serif; color: #1c2833; box-shadow: 0 1px 4px rgba(0,0,0,.35); white-space: nowrap; border: 2px solid; }

/* dev */
dialog { border: 0; border-radius: 14px; max-width: 760px; width: calc(100% - 32px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.5); }
#api-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
#api-table td, #api-table th { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; }
.ok { color: #2f9e6a; } .err { color: #d6363b; }
footer { margin-top: 24px; padding: 16px 0; text-align: center; font-size: 13px; color: var(--muted); }
footer p { margin: 6px 0 0; }
.footer-nav { display: block; margin: 0; overflow: visible; }
.footer-nav a { color: var(--accent); }

/* información / preguntas frecuentes */
.info { margin-top: 32px; background: var(--card); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.info h2 { font-size: 19px; margin: 0 0 12px; }
.info h2:not(:first-child) { margin-top: 24px; }
.info > p { color: var(--muted); margin: 0; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 20px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq h3 { font-size: 15px; margin: 0; }
.faq p { margin: 8px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  .layout-mapa { grid-template-columns: 1fr; }
  #map { height: 55vh; }
  .panel { max-height: none; }
  .resumen-icono { font-size: 38px; }
  .resumen-texto h2 { font-size: 19px; }
}
