:root {
  --bg: #0f1c2e;
  --bg2: #1d3557;
  --card: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f7fa;
  --muted: #a9b6c8;
  --rain: #6cb4ff;
  --warm: #ffb454;
  --cool: #7fd1ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg2) 0%, var(--bg) 60%) fixed;
  background-color: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 84px);
}

.topbar { text-align: center; }
.tab-title { font-size: 1.6rem; font-weight: 700; margin: 12px 0 14px; }
.note { color: var(--muted); font-size: 0.8rem; text-align: center; margin: 0 8px 12px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(15, 28, 46, 0.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.tabbar button {
  flex: 1; max-width: 180px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 0.7rem; font-weight: 500;
}
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button[aria-selected="true"] { color: var(--text); }
.tabbar button[aria-selected="true"] svg { color: var(--warm); }

.hgroup { margin-bottom: 14px; }
.hrow {
  display: grid; grid-template-columns: 3.6em 1.9em 2.6em 1fr auto;
  align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line);
}
.hrow:first-of-type { border-top: 0; }
.hrow .t { color: var(--muted); }
.hrow .t.now { color: var(--text); font-weight: 600; }
.hrow .i { font-size: 1.35rem; text-align: center; }
.hrow .temp { font-weight: 600; font-size: 1.05rem; }
.hrow .rain { color: var(--rain); font-size: 0.85rem; }
.hrow .w { color: var(--muted); font-size: 0.85rem; text-align: right; white-space: nowrap; }

.hero { text-align: center; padding: 12px 0 24px; }
.place {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; color: var(--text);
  font: inherit; font-size: 1.5rem; font-weight: 600; cursor: pointer;
}
.place svg { width: 14px; height: 14px; color: var(--muted); }
.now-row { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0 6px; }
.now-icon { font-size: 3.6rem; line-height: 1; }
.now-temp { font-size: 4.6rem; font-weight: 200; line-height: 1; }
.now-desc { font-size: 1.15rem; }
.now-hilo { color: var(--muted); margin-top: 2px; }
.now-source { color: var(--muted); font-size: 0.75rem; margin-top: 6px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
  backdrop-filter: blur(8px);
}
.card h2 {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

.details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; }
.detail .k { color: var(--muted); font-size: 0.8rem; }
.detail .v { font-size: 1.15rem; font-weight: 500; }
.detail .s { color: var(--muted); font-size: 0.8rem; }

.hourly {
  display: flex; gap: 4px; overflow-x: auto; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}
.hour {
  flex: 0 0 58px; text-align: center; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0;
}
.hour.day-break { border-left: 1px solid var(--line); }
.hour .t { font-size: 0.82rem; color: var(--muted); }
.hour .t.now { color: var(--text); font-weight: 600; }
.hour .i { font-size: 1.5rem; line-height: 1; }
.hour .p { font-size: 0.75rem; color: var(--rain); min-height: 1em; }
.hour .temp { font-weight: 500; }
.hour .w { font-size: 0.72rem; color: var(--muted); }

.day {
  display: grid; grid-template-columns: 4.2em 1.8em 2.8em 2.6em 1fr 2.6em;
  align-items: center; gap: 6px; padding: 9px 0;
  border-top: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-bottom: 0;
  width: 100%; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.day:first-child { border-top: 0; }
.day .d { font-weight: 500; line-height: 1.15; }
.day .d small { display: block; color: var(--muted); font-size: 0.72rem; font-weight: 400; }
.day .i { font-size: 1.35rem; text-align: center; }
.day .p { font-size: 0.78rem; color: var(--rain); }
.day .lo { color: var(--muted); text-align: right; }
.day .hi { text-align: left; }
.bar { position: relative; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.1); }
.bar span {
  position: absolute; top: 0; bottom: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--cool), var(--warm));
}

.status { text-align: center; color: var(--muted); font-size: 0.85rem; min-height: 1.2em; }
.status.error { color: #ff9b8a; }
.foot { text-align: center; color: var(--muted); font-size: 0.75rem; margin-top: 8px; }
.foot a { color: var(--muted); }

.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px;
  background: #16263d; color: var(--text); border-radius: 18px 18px 0 0;
}
.sheet::backdrop { background: rgba(0, 0, 0, 0.5); }
.sheet-body { position: relative; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px); }
.sheet h3 { margin: 0 0 4px; font-size: 1.3rem; }
.sheet .sub { color: var(--muted); margin-bottom: 14px; }
.close {
  position: absolute; right: 12px; top: 12px; width: 32px; height: 32px;
  border-radius: 50%; border: 0; background: var(--card); color: var(--text); font-size: 1rem;
}


.sensor { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); }
.sensor:first-child { border-top: 0; }
.sensor .n { font-weight: 500; }
.sensor .n small { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.sensor .t { font-size: 1.25rem; font-weight: 600; }
.sensor .h { color: var(--rain); font-size: 0.85rem; min-width: 3.2em; text-align: right; }

.alert {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 0; border-radius: 14px; padding: 12px 14px; margin: 0 0 14px;
  font: inherit; color: #1b1205; background: #ffb454;
}
.alert.severe { background: #ff6b5b; color: #fff; }
.alert.minor { background: #ffd98a; }
.alert b { display: block; font-size: 1rem; }
.alert span { font-size: 0.82rem; opacity: 0.9; }
.sheet .alert-body { white-space: pre-wrap; font-size: 0.9rem; line-height: 1.45; max-height: 60vh; overflow-y: auto; }
.sheet .alert-body h4 { margin: 12px 0 4px; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.aqi-dot { display: inline-block; width: 0.7em; height: 0.7em; border-radius: 50%; margin-right: 6px; vertical-align: 0.05em; }
.pollen-row { display: grid; grid-template-columns: 1fr auto; padding: 8px 0; border-top: 1px solid var(--line); }
.pollen-row:first-child { margin-top: 10px; }
.pollen-row .n small { display: block; color: var(--muted); font-size: 0.75rem; }
.pollen-row .lvl { font-weight: 600; align-self: center; }

.retry { margin-top: 10px; padding: 8px 18px; border-radius: 18px; border: 0; background: var(--warm); color: #1b1205; font: inherit; font-weight: 600; }
.now-desc small { color: var(--muted); }

.search input {
  width: 100%; margin: 6px 0 12px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: 16px;
}
.plist { display: flex; flex-direction: column; }
.plist:empty { display: none; }
#search-results { margin-bottom: 14px; }
.prow { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.prow:first-child { border-top: 0; }
.prow .pick {
  flex: 1; text-align: left; background: none; border: 0; color: var(--text); font: inherit;
  padding: 11px 0; cursor: pointer;
}
.prow .pick small { display: block; color: var(--muted); font-size: 0.78rem; }
.prow.active .pick { font-weight: 700; }
.prow .pick .mark { color: var(--warm); margin-left: 6px; }
.prow .del, .prow .add {
  background: var(--card); border: 0; color: var(--muted); border-radius: 50%;
  width: 30px; height: 30px; font-size: 0.9rem; cursor: pointer;
}
.prow .add { color: var(--warm); font-size: 1.2rem; }
.plist .hint { color: var(--muted); font-size: 0.85rem; padding: 6px 0; }
