:root {
  --bg: #EEF2F6;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #475569;
  --line: #E2E8F0;
  --accent: #2563EB;
  --temp: #EA580C;
  --sun: #D97706;
  --cloud: #64748B;
  --rain: #2563EB;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B0F14;
    --card: #151B23;
    --text: #F1F5F9;
    --muted: #94A3B8;
    --line: #263241;
    --accent: #60A5FA;
    --temp: #FB923C;
    --sun: #FBBF24;
    --cloud: #94A3B8;
    --rain: #60A5FA;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#view {
  max-width: 560px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; }
h1, h2 { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.status { padding: 8px 4px; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
}

/* ---------------------------------------------------------------- Icons */

.icon { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon .i-sun { stroke: var(--sun); }
.icon .i-cloud { stroke: var(--cloud); }
.icon .i-rain { stroke: var(--rain); }
.icon .i-fill { fill: currentColor; stroke: none; }

/* ---------------------------------------------------------------- Location list */

.list-header { padding: 28px 20px 12px; display: flex; flex-direction: column; gap: 16px; }
.list-title-row { display: flex; align-items: baseline; justify-content: space-between; }
.list-title-row h1 { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 30px; font-weight: 600; letter-spacing: -0.5px; }

.search-link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}

.cards { display: flex; flex-direction: column; gap: 12px; }
#view > .cards { padding: 4px 20px 20px; }

.place-card { display: flex; flex-direction: column; gap: 14px; padding: 16px 18px; text-decoration: none; }
.place-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.place-card-name { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.place-name { font-size: 18px; font-weight: 600; }
.condition { font-size: 14px; margin-top: 4px; }
.current-label { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.6px; }
.place-card-now { display: flex; align-items: center; gap: 8px; }
.temp-large { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 44px; font-weight: 500; letter-spacing: -1.5px; line-height: 1; }
.place-card-bottom { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); }
.high-low { display: flex; gap: 14px; white-space: pre; }
.rain-chance { display: flex; align-items: center; gap: 4px; color: var(--rain); }
.spark { display: flex; align-items: center; gap: 6px; }
.sparkline path { fill: none; stroke: var(--temp); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.attribution { margin-top: auto; padding: 16px 20px 24px; font-size: 11px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- Place detail */

.detail-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 4px; }
.detail-title { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; text-align: center; }
.detail-title h1 { font-size: 17px; font-weight: 600; }
.tiny-plus { font-size: 12px; }
.detail-status { padding: 24px 20px; }

.icon-button {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: none;
  border: 0;
  border-radius: 22px;
  color: var(--text);
  cursor: pointer;
}
.icon-button[hidden] { visibility: hidden; display: flex; }
.save-button { color: var(--muted); }
.save-button.is-saved { color: var(--accent); }
.save-button.is-saved .icon path { fill: currentColor; }

.now { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 20px 20px; }
.now .icon { stroke-width: 1.2; }
.temp-hero { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 96px; font-weight: 500; letter-spacing: -4px; line-height: 1; }
.now-condition { font-size: 18px; font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 0 16px 16px; }
.stat { border-radius: 16px; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-size: 17px; font-weight: 600; }

.section { margin: 0 16px 16px; padding: 16px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 8px; }
.section-title h2 { font-size: 14px; font-weight: 600; }

.hourly-card { padding: 16px 0 14px; }
.hourly-card .section-title { padding: 0 16px 10px; }
.hourly-scroll { overflow-x: auto; padding: 0 8px; scrollbar-width: none; }
.hourly { width: calc(var(--hours) * 52px); }
.hour-row { display: grid; grid-template-columns: repeat(var(--hours), 52px); }
.hour { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hour-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.hour-label.is-marker { color: var(--text); }
.hour-temp { font-size: 15px; font-weight: 600; }
.hour-rain { margin-top: 6px; text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); }
.hour-rain.is-likely { color: var(--rain); }
.hourly-graph { display: block; margin-top: 4px; }
.hourly-area { fill: var(--temp); fill-opacity: 0.12; }
.hourly-line { fill: none; stroke: var(--temp); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hourly-bars { fill: var(--rain); fill-opacity: 0.55; }
.hourly-base { stroke: var(--line); }

.day { display: flex; align-items: center; gap: 10px; height: 52px; border-top: 1px solid var(--line); }
.day.is-today { border-top: 0; }
.day-name { width: 52px; font-size: 15px; font-weight: 500; }
.day.is-today .day-name { font-weight: 600; }
.day-icon { width: 28px; display: flex; justify-content: center; }
.day-rain { width: 36px; font-size: 12px; font-weight: 600; color: var(--rain); }
.day-low, .day-high { width: 30px; text-align: right; font-size: 15px; }
.day-high { font-weight: 600; }
.range-bar { flex: 1; height: 6px; min-width: 60px; }
.range-track { fill: var(--line); }
.range-fill { fill: var(--temp); }

.sun-arc { display: block; width: 100%; height: auto; margin-top: 8px; }
.sun-path { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 3 5; stroke-linecap: round; }
.sun-trail { fill: none; stroke: var(--sun); stroke-width: 3; stroke-linecap: round; }
.sun-horizon { stroke: var(--line); }
.sun-glow { fill: var(--sun); fill-opacity: 0.2; }
.sun-dot { fill: var(--sun); }
.sun-times { display: flex; justify-content: space-between; margin-top: 4px; }
.sun-times > div { display: flex; flex-direction: column; gap: 2px; }
.sun-times .is-end { align-items: flex-end; }
.sun-time { font-size: 20px; font-weight: 600; }
