:root {
  --bg: #0b1020;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.10);
  --text: #eef2ff;
  --muted: #9aa7c7;
  --accent: #4fc3f7;
  --radius: 18px;
}

* { box-sizing: border-box; }

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

a { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
}

.brand { font-size: 1.25rem; font-weight: 700; white-space: nowrap; }

.search-box { position: relative; flex: 1; max-width: 480px; margin: 0 auto; }

#search {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}
#search:focus { border-color: var(--accent); }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  margin: 0; padding: 6px;
  list-style: none;
  background: #141b33;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  max-height: 320px;
  overflow-y: auto;
}
.search-results li {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.search-results li:hover, .search-results li.active { background: rgba(79, 195, 247, 0.15); }
.search-results .prov { color: var(--muted); font-size: 0.85rem; }

.icon-btn {
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 1.05rem;
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 18px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(8px);
}

.card h2 { margin: 0 0 14px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

/* Hero */
.hero { overflow: hidden; position: relative; transition: background 1s; }
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hero h1 { margin: 0; font-size: 1.6rem; }
.hero-main { display: flex; align-items: center; gap: 22px; margin: 10px 0 14px; flex-wrap: wrap; }
.hero-temp { display: flex; align-items: baseline; gap: 4px; }
.big-icon { font-size: 3.4rem; align-self: center; margin-right: 8px; }
#cur-temp { font-size: 4.4rem; font-weight: 800; line-height: 1; }
.deg { font-size: 1.6rem; color: var(--muted); }
.desc { font-size: 1.15rem; margin: 0 0 6px; text-transform: capitalize; }
#cur-minmax { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* Fondos dinámicos del hero según el estado del cielo */
.sky-clear-day   { background: linear-gradient(135deg, #1565c0 0%, #4fc3f7 60%, #ffe082 130%); }
.sky-clear-night { background: linear-gradient(135deg, #0d1330 0%, #1b2a5e 70%, #3d4b8f 120%); }
.sky-cloudy      { background: linear-gradient(135deg, #37474f 0%, #546e7a 60%, #78909c 120%); }
.sky-rain        { background: linear-gradient(135deg, #1a2a4a 0%, #274b73 60%, #3a6ea5 120%); }
.sky-storm       { background: linear-gradient(135deg, #1a1033 0%, #35255e 60%, #5c3d99 120%); }
.sky-snow        { background: linear-gradient(135deg, #37474f 0%, #607d8b 60%, #b0bec5 120%); }
.sky-fog         { background: linear-gradient(135deg, #263238 0%, #455a64 60%, #78909c 120%); }
.sky-default     { background: linear-gradient(135deg, #14204a 0%, #1e3a6e 60%, #2c5aa0 120%); }

/* Por horas */
.hourly-scroll { overflow-x: auto; padding-bottom: 6px; }
.hourly-curve { display: block; height: 44px; }
.hourly { display: flex; }
.hour-card {
  flex: 0 0 64px;
  width: 64px;
  text-align: center;
  padding: 6px 2px;
  border-radius: 12px;
}
.hour-card.now { background: rgba(79, 195, 247, 0.18); }
.hour-card .h-time { font-size: 0.78rem; color: var(--muted); }
.hour-card .h-icon { font-size: 1.35rem; margin: 3px 0; }
.hour-card .h-temp { font-weight: 700; }
.hour-card .h-rain { font-size: 0.72rem; color: #7fd4ff; min-height: 1em; }

/* Por días */
.daily { display: flex; flex-direction: column; gap: 4px; }
.day-row {
  display: grid;
  grid-template-columns: 92px 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 12px;
}
.day-row:hover { background: rgba(255, 255, 255, 0.05); }
.day-row .d-name { font-weight: 600; text-transform: capitalize; }
.day-row .d-icon { font-size: 1.4rem; text-align: center; }
.day-row .d-rain { font-size: 0.78rem; color: #7fd4ff; }
.range { display: flex; align-items: center; gap: 8px; }
.range .min { color: var(--muted); }
.range .max { font-weight: 700; }
.range-bar {
  position: relative;
  flex: 1;
  height: 5px;
  min-width: 60px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.range-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #4fc3f7, #ffb74d);
}

/* Radar */
.radar-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.radar-head h2 { margin: 0; }
.radar-controls { display: flex; align-items: center; gap: 10px; }
#radar-slider { width: 160px; accent-color: var(--accent); }
.map {
  height: 420px;
  border-radius: 14px;
  margin: 12px 0 8px;
  border: 1px solid var(--card-border);
  background: #0e1526;
}
.leaflet-container { font: inherit; }

.footer { text-align: center; padding: 10px 16px 28px; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a1c28;
  border: 1px solid #b0413e;
  color: #ffd7d7;
  padding: 10px 18px;
  border-radius: 12px;
  z-index: 1000;
  max-width: 90vw;
}

@media (max-width: 640px) {
  #cur-temp { font-size: 3.4rem; }
  .hero-main { gap: 14px; }
  .map { height: 320px; }
  .day-row { grid-template-columns: 72px 30px 1fr auto; gap: 8px; }
  #radar-slider { width: 110px; }
}
