:root {
  --bg: #eef6fd;
  --card: #ffffff;
  --line: #d6e5f3;
  --ink: #0f2940;
  --muted: #5d6f82;
  --accent: #0a6fd6;
  --accent-soft: #e2f0fd;
  --max: #e8704a;
  --min: #34529a;
  --sun: #f6c343;
  --cloud: #a9b6c6;
  --rain: #5eb1e6;
  --tabbar-h: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

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

h1, h2, h3 { margin: 0; font-weight: 900; line-height: 1.2; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.muted { color: var(--muted); }
.brand { color: var(--accent); font-weight: 900; font-size: 18px; }

/* Icons */
.ic { display: inline-flex; width: 22px; height: 22px; }
.ic svg { width: 100%; height: 100%; }

/* Header */
.header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.loc-row { display: flex; align-items: center; gap: 10px; }
.loc-row .ic { color: var(--accent); width: 26px; height: 26px; }
.loc-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 24px; font-weight: 900; }
.loc-btn .ic { color: var(--muted); width: 18px; height: 18px; }
.loc-row .gear { margin-left: auto; color: var(--ink); }

/* Segmented control */
.seg {
  display: flex; background: var(--accent-soft); border: 1px solid var(--line);
  border-radius: 14px; padding: 4px;
}
.seg a { flex: 1; text-align: center; padding: 10px 0; border-radius: 10px; font-size: 18px; color: var(--muted); font-weight: 600; }
.seg a.on { background: var(--card); color: var(--accent); box-shadow: 0 1px 4px rgba(15, 41, 64, .12); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 16px; margin-bottom: 18px;
}
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 10px; font-size: 14px; color: var(--muted); }
.legend span::before {
  content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 6px; background: var(--c);
}
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.small { height: 220px; }

/* Day cards */
.section-title { margin: 6px 4px 12px; }
.days {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 2px 2px 10px; margin: 0 -16px 18px; padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 132px; scroll-snap-align: start; background: var(--card);
  border: 1px solid var(--line); border-radius: 20px; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.day.today { border: 2px solid var(--accent); }
.day .name { font-weight: 900; font-size: 18px; }
.day .date { color: var(--muted); font-size: 16px; }
.day .wx { width: 64px; height: 56px; margin: 6px 0; }
.day .tmax { color: var(--max); font-weight: 900; font-size: 24px; }
.day .tmin { color: var(--min); font-weight: 700; font-size: 20px; }
.day .meta { display: flex; align-items: center; gap: 6px; font-size: 16px; color: var(--accent); margin-top: 4px; }
.day .meta b { color: var(--ink); }
.day .meta .ic { width: 18px; height: 18px; }

/* Summary */
.summary { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.summary .wx { flex: 0 0 64px; height: 56px; }
.summary .txt { flex: 1; }
.summary p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.summary:not(.open) p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.summary .chev { color: var(--accent); align-self: center; transition: transform .2s; }
.summary.open .chev { transform: rotate(90deg); }

/* Day detail */
.back { display: inline-flex; align-items: center; gap: 8px; font-size: 22px; font-weight: 900; margin-bottom: 14px; }
.hero { display: flex; align-items: center; justify-content: space-between; }
.hero .wx { width: 84px; height: 72px; }
.hero .temps { font-size: 34px; font-weight: 900; }
.hero .temps .lo { color: var(--min); }
.hero .temps .hi { color: var(--max); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.tile .k { color: var(--muted); font-size: 14px; }
.tile .v { font-weight: 900; font-size: 20px; margin-top: 2px; }

/* Map */
.map { height: calc(100vh - 330px); min-height: 340px; border-radius: 20px; overflow: hidden; border: 1px solid var(--line); }
.map-temp {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 1px 6px; font-weight: 900; color: var(--max); white-space: nowrap; transform: translate(-50%, -50%); display: inline-block;
  box-shadow: 0 1px 4px rgba(15, 41, 64, .15); font-size: 13px; text-align: center;
}
.map-temp small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }
.player { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.player button { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.player button .ic { width: 20px; height: 20px; }
.player input { flex: 1; accent-color: var(--accent); }
.player .time { font-weight: 700; min-width: 48px; text-align: right; }

/* Lists / search */
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.search input { flex: 1; border: 0; outline: 0; font: inherit; font-size: 18px; padding: 14px 0; background: transparent; color: var(--ink); }
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.item {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; width: 100%; text-align: left;
}
.item .ic { color: var(--accent); flex: 0 0 auto; }
.item .main { flex: 1; min-width: 0; }
.item .main div { font-weight: 700; font-size: 17px; }
.item .main small { color: var(--muted); }
.item .right { display: flex; align-items: center; gap: 8px; font-weight: 900; color: var(--max); }
.item .right .wx { width: 34px; height: 30px; }
.item .del { color: var(--muted); }
.item.active { border: 2px solid var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }

.alert { border-left: 6px solid var(--c, var(--accent)); }
.alert h3 { font-size: 17px; }
.alert p { margin: 4px 0 0; color: var(--muted); }
.link { color: var(--accent); font-weight: 700; }
.btn { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; padding: 12px 18px; border-radius: 12px; }
.prose p, .prose li { line-height: 1.5; }
.error { background: #fdecea; color: #8a1f11; border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }

/* Tab bar */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px;
  display: flex; justify-content: space-around; background: var(--card);
  border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); z-index: 1000;
  box-shadow: 0 -2px 12px rgba(15, 41, 64, .06);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 14px; color: var(--muted); padding: 6px 0; border-radius: 14px;
}
.tabbar a.on { color: var(--accent); background: var(--accent-soft); font-weight: 900; }
