:root {
  --bg: #000000;          /* nero */
  --bg2: #0c0c0a;
  --card: #141310;
  --card2: #1c1a16;
  --line: #2c2a24;
  --txt: #f4ecd8;         /* avorio */
  --muted: #9c9580;
  --accent: #e6d7a8;      /* avorio dorato */
  --warn: #ffb84d;
  --danger: #ff5d5d;
  --ok: #6fd39a;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a1813 0%, var(--bg) 55%);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 500;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(12px);
  padding: env(safe-area-inset-top) 16px 12px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.loc { display: flex; flex-direction: column; }
.loc h1 { font-size: 1.4rem; margin: 0; font-weight: 700; letter-spacing: -.02em; }
.sub { color: var(--muted); font-size: .82rem; }
.actions {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px;
  display: flex; gap: 8px; align-items: center;
}
.icon-btn, .unit-toggle {
  background: var(--card); color: var(--txt); border: 1px solid var(--line);
  border-radius: 12px; height: 40px; min-width: 40px; padding: 0 12px;
  font-size: 1.1rem; cursor: pointer; display: grid; place-items: center;
}
.unit-toggle { font-weight: 700; font-size: .95rem; }
.icon-btn:active, .unit-toggle:active { transform: scale(.94); }

.search { position: relative; margin-top: 12px; }
.search input {
  width: 100%; background: var(--card); border: 1px solid var(--line);
  color: var(--txt); border-radius: 12px; padding: 11px 14px; font-size: 1rem;
}
.search input:focus { outline: none; border-color: var(--accent); }
.results {
  list-style: none; margin: 6px 0 0; padding: 6px; position: absolute;
  left: 0; right: 0; background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; max-height: 50vh; overflow: auto; z-index: 600;
}
.results li { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: .95rem; }
.results li:hover, .results li.sel { background: var(--accent); color: #04122a; }
.results .r-sub { color: var(--muted); font-size: .8rem; }
.results li:hover .r-sub, .results li.sel .r-sub { color: #04122a; }

/* ---------- Tabs ---------- */
main { padding: 14px; max-width: 720px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- Oggi ---------- */
.current { padding: 18px 6px 6px; }
.current-main { display: flex; align-items: center; gap: 18px; }
.cur-icon { font-size: 4.2rem; line-height: 1; }
.cur-temp { font-size: 3.6rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.cur-desc { font-size: 1.1rem; margin-top: 4px; }
.cur-feels { color: var(--muted); font-size: .9rem; margin-top: 2px; }

.grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px;
}
@media (min-width: 480px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px;
}
.cell .k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.cell .v { font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.cell .v small { font-size: .75rem; color: var(--muted); font-weight: 500; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-top: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1rem; color: var(--muted); font-weight: 600; }
.chart-box { position: relative; height: 150px; }
.nws-text { line-height: 1.5; font-size: .95rem; }
.nws-period { padding: 8px 0; border-bottom: 1px solid var(--line); }
.nws-period:last-child { border-bottom: none; }
.nws-period b { color: var(--accent); }

/* ---------- 7 giorni ---------- */
.week-list { display: flex; flex-direction: column; gap: 10px; }
.day {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden;
}
.day-head {
  display: grid; grid-template-columns: 84px 36px 62px 1fr auto; align-items: center;
  gap: 8px; padding: 14px; cursor: pointer;
}
.day-head .dname { font-weight: 700; }
.day-head .dname small { display: block; color: var(--muted); font-weight: 400; font-size: .75rem; }
.day-head .dicon { font-size: 1.6rem; text-align: center; }
.day-head .dpop { color: var(--accent); font-size: .8rem; white-space: nowrap; }
.drange {
  display: flex; align-items: center; gap: 8px; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.drange .min { color: var(--muted); font-weight: 500; font-size: .9rem; }
.drange .max { font-size: .95rem; }
.rbar {
  flex: 1; height: 5px; border-radius: 99px; background: var(--card2);
  position: relative; min-width: 40px;
}
.rfill {
  position: absolute; top: 0; bottom: 0; border-radius: 99px;
  background: linear-gradient(90deg, #7fb0f9, var(--accent), #ffb84d);
}
.day-head .chev { color: var(--muted); transition: transform .2s; }
.day.open .chev { transform: rotate(90deg); }
.day-detail { display: none; padding: 0 14px 14px; }
.day.open .day-detail { display: block; }
.day-detail .drow {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-top: 1px solid var(--line); font-size: .9rem;
}
.day-detail .dh-hours { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0 2px; }
.dh-hour { text-align: center; min-width: 56px; font-size: .8rem; color: var(--muted); }
.dh-hour .t { color: var(--txt); font-weight: 700; font-size: .95rem; }
.dh-hour .i { font-size: 1.2rem; }
.dh-hour .p { color: var(--accent); }

/* ---------- Radar ---------- */
#map { height: 56vh; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.leaflet-container { background: #0a0f1c; }
.radar-controls {
  display: flex; align-items: center; gap: 12px; margin-top: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.play-btn {
  background: var(--accent); color: #04122a; border: none; border-radius: 50%;
  width: 42px; height: 42px; font-size: 1.1rem; cursor: pointer; flex: none;
}
#frameSlider { flex: 1; accent-color: var(--accent); }
.frame-time { font-variant-numeric: tabular-nums; font-size: .85rem; color: var(--muted); min-width: 64px; text-align: right; }
.radar-legend { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.radar-hint { color: var(--muted); font-size: .78rem; }

/* ---------- Allerte ---------- */
.alerts-list { display: flex; flex-direction: column; gap: 12px; }
.alert {
  background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--muted);
  border-radius: 12px; padding: 14px;
}
.alert.sev-extreme, .alert.sev-severe { border-left-color: var(--danger); }
.alert.sev-extreme { background: linear-gradient(90deg, rgba(255,93,93,.14), var(--card)); }
.alert.sev-moderate { border-left-color: var(--warn); }
.alert.sev-minor { border-left-color: var(--accent); }
.alert h3 { margin: 0 0 4px; font-size: 1.02rem; }
.alert .meta { color: var(--muted); font-size: .8rem; margin-bottom: 8px; }
.alert .tag {
  display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  padding: 2px 8px; border-radius: 99px; margin-right: 6px;
}
.alert.sev-extreme .tag, .alert.sev-severe .tag { background: var(--danger); color: #fff; }
.alert.sev-moderate .tag { background: var(--warn); color: #3a2400; }
.alert.sev-minor .tag { background: var(--accent); color: #04122a; }
.alert details summary { cursor: pointer; color: var(--accent); font-size: .85rem; margin-top: 6px; }
.alert .desc { white-space: pre-wrap; font-size: .88rem; line-height: 1.5; margin-top: 8px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 3rem; }

/* ---------- Banner errori ---------- */
.banner {
  background: rgba(255,184,77,.12); border: 1px solid var(--warn); color: var(--warn);
  border-radius: 12px; padding: 10px 14px; font-size: .88rem; margin-bottom: 12px;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(0,0,0,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbtn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 10px 4px; font-size: .72rem; display: flex; flex-direction: column;
  align-items: center; gap: 3px; position: relative;
}
.tabbtn span { font-size: 1.25rem; }
.tabbtn.active { color: var(--accent); }
.badge {
  position: absolute; top: 2px; right: calc(50% - 26px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); border-radius: 99px;
  color: #fff; font-size: .62rem; font-weight: 700; font-style: normal;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Qualita' dell'aria ---------- */
.aqi-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 5px; vertical-align: baseline;
}
.cell-sub { color: var(--muted); font-size: .72rem; margin-top: 3px; }

/* ---------- Skeleton ---------- */
.loading { opacity: .5; }
