:root {
  --bg-1: #0a1a3a;
  --bg-2: #1a2f5a;
  --text: #fff;
  --text-soft: rgba(255, 255, 255, 0.78);
  --text-mute: rgba(255, 255, 255, 0.55);
  --surface: rgba(255, 255, 255, 0.10);
  --surface-strong: rgba(255, 255, 255, 0.18);
  --border: rgba(255, 255, 255, 0.10);
  --accent: #ffd166;
  --rain: #5dade2;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="day-clear"] { --bg-1: #2c8eff; --bg-2: #ffb74d; }
[data-theme="day-partly"] { --bg-1: #4a90c2; --bg-2: #8bb6d6; }
[data-theme="day-cloudy"] { --bg-1: #5d7589; --bg-2: #8a9bab; }
[data-theme="day-rain"] { --bg-1: #3e5161; --bg-2: #5d7589; }
[data-theme="day-storm"] { --bg-1: #1c2530; --bg-2: #3e5161; }
[data-theme="night-clear"] { --bg-1: #08153d; --bg-2: #1a2a5a; }
[data-theme="night-partly"] { --bg-1: #0e1a40; --bg-2: #243358; }
[data-theme="night-cloudy"] { --bg-1: #1a2332; --bg-2: #2c3e50; }
[data-theme="night-rain"] { --bg-1: #1a2332; --bg-2: #34495e; }
[data-theme="night-storm"] { --bg-1: #0a0f18; --bg-2: #1c2530; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding-top: var(--safe-top);
  background: #0072BC;
  z-index: 1000;
  color: #fff;
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  gap: 24px;
}
@media (max-width: 768px) {
  .site-header-inner { padding: 0 8px; }
}
.logo-link {
  position: relative;
  display: inline-block;
  color: #fff;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-link svg { height: 32px; width: auto; display: block; }
.logo-brand {
  position: absolute;
  right: 0;
  bottom: -2px;
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  opacity: .85;
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(170deg, var(--bg-1) 0%, var(--bg-2) 100%);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background 0.8s ease;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }
a { color: inherit; }

#app {
  max-width: 540px;
  margin: 0 auto;
  /* El header unificado lo inyecta el site-router (reserva 60px en body). */
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  gap: 8px;
}
.prov-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px 9px 12px;
  background: var(--surface);
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 40px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s;
}
.prov-btn:active { background: var(--surface-strong); }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.15s, transform 0.6s ease;
}
.icon-btn:active { background: var(--surface-strong); }

.main { flex: 1; padding: 0 16px 32px; display: flex; flex-direction: column; }

.hero {
  text-align: center;
  padding: 24px 0 28px;
}
.hero-icon { display: flex; justify-content: center; margin-bottom: 4px; min-height: 124px; }
.hero-icon svg { width: 124px; height: 124px; filter: drop-shadow(0 6px 16px rgba(0,0,0,0.18)); }
.temp {
  font-size: 5.6rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.045em;
  margin-bottom: 6px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.condition {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 10px;
}
.hilo {
  font-size: 0.92rem;
  color: var(--text-soft);
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
}
.hilo strong { color: var(--text); font-weight: 600; }
.hilo .dot { opacity: 0.45; }

.bulletin {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-soft);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-left: 3px solid rgba(255,255,255,0.25);
}
.bulletin:empty { display: none; }
.bulletin strong { color: var(--text); font-weight: 600; }
.bulletin .warn {
  display: block;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.12);
  color: var(--accent);
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.tab {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: var(--surface-strong);
  color: var(--text);
}

.panel.hidden { display: none; }
.panel-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 700;
  margin-bottom: 10px;
  padding-left: 4px;
}

.hourly {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 6px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scroll-padding-left: 16px;
}
.hourly::-webkit-scrollbar { display: none; }
.hour {
  flex: 0 0 auto;
  width: 66px;
  padding: 14px 4px;
  background: var(--surface);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.hour .h-time { font-size: 0.78rem; color: var(--text-soft); font-weight: 600; }
.hour .h-icon svg { width: 30px; height: 30px; }
.hour .h-temp { font-size: 1.05rem; font-weight: 600; }
.hour .h-pop {
  font-size: 0.72rem;
  color: var(--rain);
  font-weight: 600;
  min-height: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
}
.hour.now {
  background: var(--surface-strong);
}

.daily { display: flex; flex-direction: column; gap: 6px; }
.day {
  display: grid;
  grid-template-columns: 64px 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.day .d-name { font-weight: 600; font-size: 0.95rem; text-transform: capitalize; }
.day .d-icon { display: grid; place-items: center; }
.day .d-icon svg { width: 28px; height: 28px; }
.day .d-bar {
  position: relative;
  height: 6px;
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}
.day .d-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(90deg, #5dade2 0%, #ffd166 50%, #e67e3c 100%);
  border-radius: 999px;
}
.day .d-range {
  display: flex;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-soft);
  min-width: 72px;
  justify-content: flex-end;
}
.day .d-range .d-max { color: var(--text); font-weight: 600; }
.day .d-pop {
  position: absolute;
  top: -14px;
  font-size: 0.65rem;
  color: var(--rain);
  font-weight: 600;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detail {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.detail .d-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-mute);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.detail .d-label svg { width: 14px; height: 14px; }
.detail .d-value {
  font-size: 1.7rem;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.detail .d-value small { font-size: 0.55em; font-weight: 500; color: var(--text-soft); margin-left: 2px; }
.detail .d-sub {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-top: auto;
  padding-top: 6px;
}

.foot {
  margin-top: 24px;
  padding: 16px 4px 0;
  font-size: 0.75rem;
  color: var(--text-mute);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.foot a { text-decoration: underline; text-decoration-color: rgba(255,255,255,0.25); }

.prov-sheet {
  position: fixed;
  inset: 0;
  z-index: 1100;
}
.prov-sheet.hidden { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  animation: fade 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sheet-content {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: #14213d;
  border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(16px + var(--safe-bottom));
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 540px;
  margin: 0 auto;
}
.sheet-handle {
  width: 38px;
  height: 4px;
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
  margin: 0 auto 10px;
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.sheet-header h2 { font-size: 1.1rem; font-weight: 700; }
.geo-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  background: rgba(255,209,102,0.15);
  border-radius: 999px;
  color: var(--accent);
}
.geo-btn:active { background: rgba(255,209,102,0.25); }
.prov-list {
  overflow-y: auto;
  flex: 1;
  margin: 0 -4px;
}
.prov-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 12px;
}
.prov-item:last-child { border-bottom: 0; }
.prov-item:active { background: rgba(255,255,255,0.05); }
.prov-item.selected .p-name { color: var(--accent); }
.prov-item .p-name { font-weight: 600; font-size: 0.96rem; }
.prov-item .p-cap { font-size: 0.75rem; color: var(--text-mute); margin-top: 2px; }
.prov-item .p-right { display: flex; align-items: center; gap: 10px; }
.prov-item .p-icon svg { width: 24px; height: 24px; }
.prov-item .p-temp { font-size: 1.05rem; font-weight: 600; min-width: 36px; text-align: right; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.loading-text { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

.spin { transform: rotate(360deg); transition: transform 0.6s ease; }

@media (max-width: 360px) {
  .temp { font-size: 4.6rem; }
  .hero-icon svg { width: 104px; height: 104px; }
  .hour { width: 58px; }
  .details-grid { gap: 8px; }
  .detail { padding: 12px; }
}
