:root {
  --bg1: #1d5fa8; --bg2: #4b9be0; --bg3: #e9f1fa;
  --card: #ffffff; --text: #16233a; --muted: #5f6f86; --line: #e3e9f1;
  --accent: #1d6fd1; --rain: #2f86e8; --warm: #f08a24; --cold: #3a8fd6;
  --chip: #eef4fb; --shadow: 0 2px 10px rgba(16, 40, 80, .08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg1: #0c1d33; --bg2: #13304f; --bg3: #0b1422;
    --card: #142235; --text: #e8eef7; --muted: #95a6be; --line: #22344d;
    --accent: #5aa6ff; --rain: #4ea2ff; --chip: #1b2d45; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg1: #0c1d33; --bg2: #13304f; --bg3: #0b1422;
  --card: #142235; --text: #e8eef7; --muted: #95a6be; --line: #22344d;
  --accent: #5aa6ff; --rain: #4ea2ff; --chip: #1b2d45; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg1) 0, var(--bg2) 320px, var(--bg3) 640px) no-repeat, var(--bg3);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

/* Header */
.top { position: sticky; top: 0; z-index: 1000; padding: calc(env(safe-area-inset-top) + 10px) 16px 8px; background: var(--bg1); }
.search-row { display: flex; gap: 8px; align-items: center; max-width: 720px; margin: 0 auto; }
.icon-btn { flex: none; width: 42px; height: 42px; border-radius: 12px; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 22px; display: grid; place-items: center; }
.icon-btn.on { color: #ffd34d; }
.search-box { position: relative; flex: 1; }
#search { width: 100%; height: 42px; border-radius: 12px; border: 0; padding: 0 14px; font-size: 16px; background: rgba(255,255,255,.95); color: #16233a; outline: none; }
.results { position: absolute; left: 0; right: 0; top: 46px; margin: 0; padding: 4px; list-style: none; background: var(--card); color: var(--text); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); max-height: 60vh; overflow: auto; }
.results li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.results li:hover, .results li.sel { background: var(--chip); }
.results small { color: var(--muted); display: block; }
.favs { display: flex; gap: 6px; overflow-x: auto; max-width: 720px; margin: 8px auto 0; scrollbar-width: none; }
.favs:empty { display: none; }
.favs::-webkit-scrollbar { display: none; }
.fav { flex: none; border: 0; border-radius: 999px; padding: 5px 12px; background: rgba(255,255,255,.18); color: #fff; font-size: 13px; white-space: nowrap; }
.fav.cur { background: #fff; color: #1d5fa8; font-weight: 600; }

main { max-width: 720px; margin: 0 auto; padding: 8px 16px calc(env(safe-area-inset-bottom) + 24px); }
.card { background: var(--card); border-radius: 18px; padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }

/* Hero */
.hero { background: transparent; box-shadow: none; color: #fff; padding: 8px 4px 4px; margin-top: 0; }
.place { font-size: 22px; font-weight: 600; }
.place small { display: block; font-size: 13px; font-weight: 400; opacity: .85; }
.now-main { display: flex; align-items: center; gap: 16px; margin: 8px 0; }
.now-icon { font-size: 72px; line-height: 1; }
.now-temp { font-size: 64px; font-weight: 200; line-height: 1; }
.now-text { font-size: 18px; }
.now-feels { opacity: .85; font-size: 14px; }
.now-today { font-size: 14px; opacity: .95; margin-bottom: 10px; }
.now-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.now-grid div { background: rgba(255,255,255,.14); border-radius: 12px; padding: 8px; text-align: center; font-size: 12px; }
.now-grid b { display: block; font-size: 15px; }
.updated { font-size: 11px; opacity: .7; margin-top: 8px; text-align: right; }

/* Warnings */
.warn { border-radius: 14px; padding: 12px 14px; margin: 8px 0; color: #1a1a1a; box-shadow: var(--shadow); }
.warn.l1 { background: #ffe14d; } .warn.l2 { background: #ff9a2e; } .warn.l3 { background: #ff4d4d; color: #fff; }
.warn summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.warn summary::-webkit-details-marker { display: none; }
.warn .wi { font-size: 26px; }
.warn b { display: block; }
.warn small { opacity: .85; }
.warn .wtext { margin-top: 8px; font-size: 14px; white-space: pre-line; }

/* Nowcast */
.nowcast-text { margin: 0 0 10px; font-size: 16px; font-weight: 500; }
.nowcast-bars { display: flex; align-items: flex-end; gap: 3px; height: 64px; border-bottom: 1px solid var(--line); }
.nowcast-bars i { flex: 1; background: var(--rain); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .9; }
.nowcast-bars i.zero { background: var(--line); }
.nowcast-bars i.snow { background: #9fc3ea; }
.nowcast-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.src { display: block; color: var(--muted); font-size: 11px; margin-top: 8px; }

/* Hourly */
.hourly { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 6px; scroll-snap-type: x proximity; }
.hour { flex: none; width: 58px; text-align: center; padding: 6px 0; border-radius: 12px; scroll-snap-align: start; }
.hour.daybreak { border-left: 1px dashed var(--line); border-radius: 0 12px 12px 0; }
.hour .t { font-size: 12px; color: var(--muted); }
.hour .i { font-size: 26px; margin: 4px 0; }
.hour .tp { font-weight: 600; font-size: 16px; }
.hour .p { font-size: 11px; color: var(--rain); min-height: 15px; }
.hour.now-h { background: var(--chip); }

/* 3 days */
.three { display: grid; gap: 10px; }
.tday { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.tday-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.tday-head b { font-size: 16px; }
.tday-head span { color: var(--muted); font-size: 13px; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; }
.slots .sl { font-size: 11px; color: var(--muted); }
.slots .si { font-size: 28px; }
.slots .st { font-weight: 600; }
.slots .sp { font-size: 11px; color: var(--rain); min-height: 15px; }
.tday-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }

/* 14 days */
.day { display: grid; grid-template-columns: 74px 34px 44px 1fr 32px 52px; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.day:last-child { border-bottom: 0; }
.day .dn small { display: block; color: var(--muted); font-size: 11px; }
.day .di { font-size: 24px; text-align: center; }
.day .dmin { color: var(--muted); text-align: right; }
.day .dmax { font-weight: 600; }
.day .dp { color: var(--rain); font-size: 12px; text-align: right; }
.bar { position: relative; height: 6px; background: var(--chip); border-radius: 3px; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; background: linear-gradient(90deg, var(--cold), var(--warm)); }
.trend-note { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Radar */
.radar-head { display: flex; justify-content: space-between; align-items: center; }
.radar-head h2 { margin: 0; }
.radar-ctrl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pill { border: 0; background: var(--chip); border-radius: 999px; width: 34px; height: 30px; }
.radar { height: 360px; border-radius: 12px; overflow: hidden; margin-top: 10px; background: var(--chip); }
.basemap { filter: saturate(.6) brightness(1.03); }
@media (prefers-color-scheme: dark) { .basemap { filter: invert(1) hue-rotate(180deg) brightness(.85) saturate(.5); } }
.slider { width: 100%; margin-top: 8px; accent-color: var(--accent); }

/* More */
.more summary { list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 600; font-size: 16px; }
.more summary::-webkit-details-marker { display: none; }
.chev { transition: transform .2s; color: var(--muted); }
.more[open] .chev { transform: rotate(180deg); }
.more-body { margin-top: 12px; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kv div { background: var(--chip); border-radius: 12px; padding: 10px; }
.kv span { display: block; font-size: 12px; color: var(--muted); }
.kv b { font-size: 17px; }
.kv em { font-style: normal; font-size: 12px; color: var(--muted); }
.more h3 { font-size: 14px; margin: 16px 0 8px; }
.pollen { display: grid; gap: 6px; }
.pollen div { display: grid; grid-template-columns: 90px 1fr 70px; gap: 8px; align-items: center; font-size: 13px; }
.lvl { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.lvl i { display: block; height: 100%; border-radius: 4px; }

.foot { font-size: 11px; color: var(--muted); text-align: center; margin-top: 16px; }
.foot a { color: inherit; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); background: #16233a; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 2000; max-width: 90vw; }
.loading { opacity: .5; transition: opacity .2s; }

@media (max-width: 420px) {
  .now-icon { font-size: 60px; } .now-temp { font-size: 56px; }
  .now-grid { grid-template-columns: repeat(2, 1fr); }
  .day { grid-template-columns: 64px 30px 36px 1fr 30px 44px; gap: 4px; font-size: 13px; }
  .radar { height: 300px; }
}
