/* Cielo de día, nubes y sol */

:root {
  --bg-0: #d6eefb;
  --bg-1: #f8fcff;
  --bg-2: #e7f5fc;
  --bg-3: #d3ecf9;
  --border: #9dcee8;
  --text: #13405f;
  --text-dim: #4e7d99;
  --accent: #3ec0f0;
  --accent-2: #ffc857;
  --warn: #f0a202;
  --danger: #e06a4f;
  --ok: #2f9e6b;
  --crit: #e2554a;
  --low: #2b9fe0;
  --med: #f0a202;
  --high: #ef7d3c;
  --glow-sky: rgba(120, 196, 240, 0.7);
  --glow-sun: rgba(255, 214, 110, 0.75);
  --radius: 12px;
  --shadow: 0 8px 24px rgba(40, 120, 170, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg-0: #e8f6ff;
  --bg-1: #ffffff;
  --bg-2: #f3faff;
  --bg-3: #e1f3fc;
  --border: #b7dcf0;
  --text: #0f3d5c;
  --text-dim: #4d7c98;
  --accent: #49c6f5;
  --accent-2: #ffd36a;
  --glow-sky: rgba(150, 210, 245, 0.85);
  --glow-sun: rgba(255, 220, 120, 0.8);
  --shadow: 0 8px 22px rgba(40, 120, 170, 0.1);
  --surface: #ffffff;
  --header-a: rgba(255, 255, 255, 0.92);
  --header-b: rgba(232, 246, 255, 0.88);
}

[data-theme="dark"] {
  --bg-0: #07131c;
  --bg-1: #102433;
  --bg-2: #163044;
  --bg-3: #1c3d56;
  --border: #2c5874;
  --text: #e7f4fb;
  --text-dim: #8eb6cc;
  --accent: #49c6f5;
  --accent-2: #ffd36a;
  --glow-sky: rgba(36, 96, 140, 0.42);
  --glow-sun: rgba(255, 196, 90, 0.16);
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.38);
  --surface: #102433;
  --header-a: rgba(10, 24, 36, 0.94);
  --header-b: rgba(14, 36, 54, 0.92);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background:
    radial-gradient(1200px 640px at 8% -16%, var(--glow-sky), transparent 58%),
    radial-gradient(900px 520px at 100% -8%, var(--glow-sun), transparent 52%),
    var(--bg-0);
  color: var(--text);
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #041018;
  padding: 0.6rem 1rem;
  z-index: 1000;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- Header ---------- */
.header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.7rem 1.35rem;
  background:
    linear-gradient(180deg, var(--header-a), var(--header-b));
  border-bottom: 1px solid rgba(157, 206, 232, 0.7);
  box-shadow: 0 10px 28px rgba(40, 120, 170, 0.08);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
  animation: barra-entrar 0.7s ease both;
}

.header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #7ec8ef 18%, #ffd36a 50%, #7ec8ef 82%, transparent);
  transform-origin: left center;
  animation: brillo-sol 1.1s ease 0.15s both;
}

.header.is-scrolled {
  padding-block: 0.45rem;
  box-shadow: 0 14px 32px rgba(19, 64, 95, 0.14);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}
.header__logo { display: grid; place-items: center; }
.header__logo img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: block;
  box-shadow: 0 6px 16px rgba(73, 198, 245, 0.28);
  animation: nube-suave 4.5s ease-in-out infinite;
}
.header__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
}
.header__subtitle {
  margin: 0.12rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.header__clocks {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 6.4rem;
  padding: 0.28rem 0.7rem 0.32rem;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid rgba(183, 220, 240, 0.9);
  border-radius: 12px;
}
.clock__label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
}
.clock__time {
  font-family: var(--mono);
  font-size: 0.98rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.header__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
}
.header .btn {
  display: inline-flex;
  align-items: center;
  height: 2.15rem;
  padding: 0 0.95rem;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(40, 120, 170, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.header .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(40, 120, 170, 0.14);
}
.header-logout { margin: 0; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.status-badge--demo { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.status-badge--live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.status-badge__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.theme-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.theme-toggle__track {
  width: 38px; height: 20px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  position: relative;
  display: block;
}
.theme-toggle__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s ease;
}
.theme-toggle input:checked + .theme-toggle__track .theme-toggle__thumb {
  transform: translateX(18px);
}
.theme-toggle input:focus-visible + .theme-toggle__track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.25rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: subir 0.55s ease both;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.stat-card:nth-child(2) { animation-delay: 0.08s; }
.stat-card:nth-child(3) { animation-delay: 0.16s; }
.stat-card:nth-child(4) { animation-delay: 0.24s; }
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px rgba(40, 120, 170, 0.16);
}
.stat-card__icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
}
.icono-clima {
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
}
.weather-hero__icon .icono-clima {
  width: 64px;
  height: 64px;
}
.stat-card__value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-card__label {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: relative;
  z-index: 1100;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  overflow: visible;
}

.lugar-pick {
  position: relative;
  flex: 1 1 320px;
  max-width: 520px;
}
.lugar-pick__campo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
}
.lugar-pick__campo:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.lugar-pick__lupa {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--accent);
}
.lugar-pick__campo input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.35rem 0;
}
.lugar-pick__campo input:focus { outline: none; }
.lugar-pick__clear {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.lugar-lista {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: min(360px, 55vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(19, 64, 95, 0.12);
}
.lugar-lista li {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
}
.lugar-lista li:hover,
.lugar-lista li:focus {
  background: color-mix(in srgb, var(--accent) 16%, white);
}
.lugar-lista__icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: block;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 3px 9px rgba(19, 64, 95, 0.16);
}
.lugar-lista__icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lugar-lista__nombre,
.lugar-lista__detalle { display: block; }
.lugar-lista__nombre { font-weight: 700; font-size: 0.88rem; }
.lugar-lista__detalle { color: var(--text-dim); font-size: 0.72rem; }

.toolbar__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.toolbar__lugar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  flex: 1 1 320px;
}

.toolbar__lugar input {
  min-width: 180px;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--text);
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92rem;
}

.filter--grow { flex: 1 1 180px; }

.filter {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.filter--inline { text-transform: none; letter-spacing: 0; }
.filter select {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
  min-width: 8rem;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #041018;
  border: none;
}

/* ---------- Tabs ---------- */
.tabs {
  display: none;
  gap: 0.35rem;
  padding: 0 1.25rem 0.5rem;
  overflow-x: auto;
}
.tabs__btn {
  flex: 0 0 auto;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tabs__btn.is-active,
.tabs__btn[aria-selected="true"] {
  color: #041018;
  background: var(--accent);
  border-color: transparent;
}

/* ---------- Layout principal ---------- */
.main-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: auto auto;
  gap: 0.85rem;
  padding: 0 1.25rem 1.5rem;
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem 1rem;
  min-height: 0;
}
.panel--map {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  flex-wrap: wrap;
}
.panel__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.panel__subtitle {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.panel__meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Mapa */
.map-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.55rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.map-controls label { display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer; }

.map {
  flex: 1;
  min-height: 380px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #c5e6f6;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.8rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 25%, transparent);
}
.dot--low { background: var(--low); color: var(--low); }
.dot--med { background: var(--med); color: var(--med); }
.dot--high { background: var(--high); color: var(--high); }
.dot--crit { background: var(--crit); color: var(--crit); }
.dot--tsunami { background: #00d4ff; color: #00d4ff; }
.dot--weather { background: var(--accent-2); color: var(--accent-2); }

/* Marcadores Leaflet personalizados */
.quake-marker {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.25);
}
.quake-marker--crit { animation: pulse-crit 1.6s infinite; }
@keyframes pulse-crit {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 92, 0.7); }
  50% { box-shadow: 0 0 0 12px rgba(255, 59, 92, 0); }
}
.tsunami-zone {
  border-radius: 50%;
  background: rgba(0, 212, 255, 0.25);
  border: 2px solid #00d4ff;
  animation: pulse-tsunami 2.2s infinite;
}
@keyframes pulse-tsunami {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 0.55; }
}
.weather-pin {
  width: 14px; height: 14px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--accent-2);
  border: 2px solid #fff8e6;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.leaflet-container { background: #c5e6f6; font: inherit; }
.leaflet-popup-content-wrapper {
  background: var(--bg-2);
  color: var(--text);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--bg-2); }
.leaflet-control-zoom a {
  background: var(--bg-1) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Clima */
.globo {
  position: relative;
  margin: 0 0 0.8rem;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 46%, #1a4668 0%, #07131f 58%, #04070c 100%);
  box-shadow: inset 0 0 0 1px rgba(120, 190, 230, 0.18);
}

.presentadora {
  margin: 0 0 0.75rem;
  display: flex;
  justify-content: center;
}

.presentadora__marco {
  width: 200px;
  height: 300px;
  overflow: hidden;
}

.presentadora__video {
  display: block;
  width: 200px;
  height: 300px;
}

.globo__barra {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  align-items: center;
  justify-content: space-between;
}

.globo__filtros,
.globo__zoom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
}

.globo__filtros label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.45rem;
  color: #13405f;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 246, 216, 0.92);
  border-radius: 999px;
  cursor: pointer;
}

.globo__pantalla {
  padding: 0.35rem 0.75rem;
  color: #13405f;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  background: #fff6d8;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.globo:fullscreen,
.globo:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
}

.globo canvas {
  display: block;
  width: 100%;
  height: 340px;
  cursor: grab;
  touch-action: none;
}

.globo canvas.is-giro {
  cursor: grabbing;
}

.globo:fullscreen canvas,
.globo:-webkit-full-screen canvas,
.globo.globo--completo canvas {
  width: 100%;
  height: calc(100vh - 2.4rem);
}

.globo__nota {
  margin: 0;
  padding: 0 0.9rem 0.75rem;
  color: rgba(214, 232, 244, 0.72);
  font-size: 0.72rem;
}

.weather-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  border-radius: 10px;
  background: linear-gradient(145deg, #8fd4f8 0%, #f4fbff 48%, #ffe7a3 100%);
  border: 1px solid #f3d98a;
  color: #13405f;
  margin-bottom: 0.75rem;
}
[data-theme="light"] .weather-hero {
  background: linear-gradient(145deg, #b7e6fb 0%, #ffffff 50%, #fff1c2 100%);
  color: #0f3d5c;
}
.weather-hero__icon { font-size: 2.8rem; line-height: 1; }
.weather-hero__temp {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.weather-hero__cond { margin: 0.15rem 0 0; color: #3d6f8c; }
[data-theme="light"] .weather-hero__cond { color: #3d6f8c; }
[data-theme="dark"] .weather-hero {
  background: linear-gradient(145deg, #12344c 0%, #0d2232 58%, #3a3018 100%);
  color: #e7f4fb;
  border-color: #3d6480;
}
[data-theme="dark"] .weather-hero__cond { color: #b7d4e6; }
[data-theme="dark"] .notas {
  background: linear-gradient(135deg, #1a3044 0%, #102433 48%, #243044 100%);
  border-color: #c9a24a;
}
.weather-hero__place { margin: 0; font-weight: 600; }

.weather-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.metric {
  padding: 0.65rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-2));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  text-align: center;
}
.metric__label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.metric__value {
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.city-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 280px;
  overflow: auto;
}
.city-list__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.city-list__item:hover,
.city-list__item.is-active {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--bg-3);
}
.city-list__name { font-weight: 600; font-size: 0.9rem; }
.city-list__meta { font-size: 0.78rem; color: var(--text-dim); }
.city-list__temp { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Feeds */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 420px;
  overflow: auto;
}
.feed__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
.feed__item--crit {
  border-color: color-mix(in srgb, var(--crit) 55%, var(--border));
  animation: alert-glow 2s infinite;
}
@keyframes alert-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 92, 0.25); }
  50% { box-shadow: 0 0 12px 0 rgba(255, 59, 92, 0.35); }
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: #041018;
}
.badge--low { background: var(--low); color: #fff; }
.badge--med { background: var(--med); }
.badge--high { background: var(--high); color: #fff; }
.badge--crit { background: var(--crit); color: #fff; }
.badge--level {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: auto;
}
.badge--vigilancia { background: var(--warn); }
.badge--aviso { background: var(--crit); color: #fff; }
.badge--cancelado { background: var(--text-dim); color: #111; }

.feed__title { margin: 0; font-size: 0.9rem; font-weight: 600; }
.feed__meta { margin: 0.15rem 0 0; font-size: 0.75rem; color: var(--text-dim); }
.feed__time {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
}

/* Alertas grid */
.alert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
}
.alert-card {
  padding: 0.85rem;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 120px;
}
.alert-card--critica {
  border-color: color-mix(in srgb, var(--crit) 60%, var(--border));
  animation: alert-glow 2s infinite;
}
.alert-card--alta { border-color: color-mix(in srgb, var(--high) 50%, var(--border)); }
.alert-card__type {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.alert-card__title { margin: 0; font-size: 0.95rem; font-weight: 700; }
.alert-card__desc { margin: 0; font-size: 0.8rem; color: var(--text-dim); flex: 1; }
.alert-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.25rem;
}
.sev {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}
.sev--baja { background: color-mix(in srgb, var(--low) 25%, transparent); color: var(--low); }
.sev--media { background: color-mix(in srgb, var(--med) 25%, transparent); color: var(--med); }
.sev--alta { background: color-mix(in srgb, var(--high) 25%, transparent); color: var(--high); }
.sev--critica { background: color-mix(in srgb, var(--crit) 25%, transparent); color: var(--crit); }


/* ---------- Notas del clima ---------- */
.notas {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1rem 1.15rem 1.15rem;
  background:
    linear-gradient(135deg, #fff6d8 0%, #fff 42%, #e7f6ff 100%);
  border: 2px solid #f0b429;
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(240, 160, 20, 0.18);
}

.notas__lista {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.notas__mas {
  display: block;
  margin: 0.85rem auto 0;
}

.notas__mas[hidden] {
  display: none;
}

.notas__vigencia {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.nota {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  margin: 0;
  padding: 0.85rem 0.95rem;
  text-align: left;
  color: var(--text);
  font: inherit;
  background: var(--surface);
  border: 1px solid #f0b429;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(19, 64, 95, 0.08);
  cursor: pointer;
}

.nota:hover,
.nota:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.nota__hora {
  color: #146f9f;
  font-size: 0.72rem;
  font-weight: 700;
}

.nota__titulo {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.nota__meta {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.84rem;
  line-height: 1.4;
}

.nota__foto,
.nota-modal__foto {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
}

dialog.nota-modal[open] {
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  z-index: 40;
  width: min(680px, calc(100% - 2rem));
  max-width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  margin: 0;
  overflow: auto;
  padding: 1.4rem 1.35rem 1.4rem;
  color: var(--text);
  background: var(--bg-1);
  border: 2px solid #f0b429;
  border-radius: 18px;
  transform: translate(-50%, -50%);
}

.nota-modal::backdrop {
  background: rgba(8, 28, 48, 0.55);
}

.nota-modal__cerrar {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  background: var(--bg-2);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.nota-modal__hora,
.nota-modal__lugar {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.nota-modal__titulo {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.25rem;
}

.nota-modal__cuerpo {
  margin: 0.8rem 0 0;
  line-height: 1.55;
}

.nota-modal__cuerpo p {
  margin: 0 0 0.7rem;
}

.nota-modal__cuerpo ul,
.nota-modal__cuerpo ol {
  margin: 0.4rem 0 0.8rem;
  padding-left: 1.25rem;
}

/* ---------- Newsletter climática ---------- */
.newsletter {
  margin: 0 1.25rem 0.5rem;
  padding: 1.15rem 1.25rem 1.25rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background-image:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 55%);
}

.newsletter__inner {
  display: grid;
  grid-template-columns: minmax(200px, 280px) 1fr;
  gap: 1.25rem 1.75rem;
  align-items: start;
}

.newsletter__title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.newsletter__desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.newsletter__form { display: flex; flex-direction: column; gap: 0.85rem; }

.newsletter__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.field__optional { text-transform: none; letter-spacing: 0; opacity: 0.8; }
.field__req { color: var(--danger); }

.field input,
.field select {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.field input.is-invalid,
.field select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent);
}

.newsletter__interests {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
  align-items: center;
}
.newsletter__interests legend {
  padding: 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
}
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

.newsletter__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.newsletter__feedback {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
}
.newsletter__feedback--ok {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border));
}
.newsletter__feedback--err {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
}

.newsletter__interests.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent);
}

@media (max-width: 900px) {
  .newsletter__inner { grid-template-columns: 1fr; }
  .newsletter__row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .newsletter { margin-inline: 0.85rem; }
}

/* Footer */
.footer {
  text-align: center;
  padding: 1rem 1.25rem 1.75rem;
  color: var(--text-dim);
  font-size: 0.78rem;
}
.footer__herramientas {
  text-align: left;
  margin: 0 auto 1.25rem;
  max-width: 1100px;
}
.footer__lead {
  margin: 0;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer__title {
  margin: 0.2rem 0 0.85rem;
  color: var(--text);
  font-size: 1.15rem;
}
.footer__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}
.herr-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  text-align: left;
}
.herr-card:hover {
  border-color: var(--accent);
}
.herr-card__img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-2);
}
.herr-card__kicker {
  margin-top: 0.35rem;
  color: var(--text-dim);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.herr-card__title {
  font-weight: 700;
  font-size: 0.95rem;
}
.herr-card__text {
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.35;
}
@media (max-width: 800px) {
  .footer__grid { grid-template-columns: 1fr; }
}
.footer p { margin: 0.2rem 0; }
.footer__hint { opacity: 0.75; }
.footer__fuentes a { color: inherit; }
.footer__logo { height: 18px; vertical-align: middle; }
.zona-visitante { margin: 0; color: var(--text-dim); font-size: 0.85rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .panel--map { grid-row: auto; min-height: 420px; }
  .weather-metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tabs { display: flex; }
  .main-grid {
    grid-template-columns: 1fr;
  }
  /* En móvil solo se muestra el panel activo vía [hidden] */
  .panel--map { min-height: 360px; }
  .notas__lista { grid-template-columns: 1fr; }
  .header {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .header__clocks {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .clock { align-items: flex-start; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; padding-inline: 0.85rem; }
  .toolbar, .main-grid, .header, .tabs, .footer { padding-inline: 0.85rem; }
  .stat-card__value { font-size: 1.15rem; }
  .weather-hero { grid-template-columns: 1fr; text-align: center; }
}

.revelar {
  opacity: 0;
  transform: translateY(16px);
  animation: subir 0.6s ease forwards;
  animation-play-state: paused;
}
.revelar.is-visible { animation-play-state: running; }

@keyframes barra-entrar {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: none; }
}
@keyframes brillo-sol {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes nube-suave {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
@keyframes subir {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .header,
  .header::after,
  .header__logo img,
  .stat-card,
  .revelar {
    animation: none;
  }
  .revelar { opacity: 1; transform: none; }
  .header .btn,
  .stat-card { transition: none; }
}

#panel-sismos[hidden],
#panel-tsunami[hidden],
#panel-alertas[hidden],
#notas-clima[hidden],
.tabs__btn[hidden] {
  display: none !important;
}

/* Desktop: mostrar los paneles con información */
@media (min-width: 781px) {
  .tabs { display: none; }
  #panel-mapa {
    display: flex !important;
    flex-direction: column;
  }
  #panel-clima,
  #panel-sismos,
  #panel-tsunami,
  #panel-alertas {
    display: block !important;
  }
  .main-grid {
    grid-template-columns: 1.35fr 1fr;
    grid-template-areas:
      "notas notas"
      "mapa clima"
      "mapa sismos"
      "tsunami alertas";
  }
  #panel-mapa { grid-area: mapa; }
  #panel-clima { grid-area: clima; }
  #panel-sismos { grid-area: sismos; }
  #panel-tsunami { grid-area: tsunami; }
  #panel-alertas { grid-area: alertas; }
  .main-grid:not(:has(#panel-tsunami:not([hidden]))) #panel-alertas:not([hidden]),
  .main-grid:not(:has(#panel-alertas:not([hidden]))) #panel-tsunami:not([hidden]) {
    grid-column: 1 / -1;
  }
  #notas-clima { grid-area: notas; }
  .panel--map { grid-row: span 2; }
}
