:root {
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --fg: #0e1421;
  --fg-muted: #5c6478;
  --border: #e3e7ef;
  --accent: #4f8cff;
  --uv-low: #4caf50;
  --uv-mod: #ffb300;
  --uv-high: #ff7043;
  --uv-vhigh: #e53935;
  --uv-extreme: #8e24aa;
  --uv: var(--uv-low);
  --temp-line: #ff7043;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 18px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --bg-card: #141a2e;
    --fg: #eef1f8;
    --fg-muted: #97a0b8;
    --border: #232a44;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  transition: background 320ms ease;
}

body[data-band="low"]      { background: linear-gradient(180deg, color-mix(in srgb, var(--uv-low) 18%, var(--bg)) 0%, var(--bg) 320px); }
body[data-band="moderate"] { background: linear-gradient(180deg, color-mix(in srgb, var(--uv-mod) 22%, var(--bg)) 0%, var(--bg) 320px); }
body[data-band="high"]     { background: linear-gradient(180deg, color-mix(in srgb, var(--uv-high) 22%, var(--bg)) 0%, var(--bg) 320px); }
body[data-band="very-high"]{ background: linear-gradient(180deg, color-mix(in srgb, var(--uv-vhigh) 26%, var(--bg)) 0%, var(--bg) 320px); }
body[data-band="extreme"]  { background: linear-gradient(180deg, color-mix(in srgb, var(--uv-extreme) 30%, var(--bg)) 0%, var(--bg) 320px); }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8c4 0%, var(--uv) 60%, color-mix(in srgb, var(--uv) 60%, #000) 100%);
  box-shadow: 0 0 16px color-mix(in srgb, var(--uv) 60%, transparent);
}

.icon-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:active { transform: scale(0.96); }

.locator { display: flex; flex-direction: column; gap: 10px; }

.locator-row { display: flex; gap: 8px; }
.locator-row.manual { flex-wrap: wrap; }

input[type="text"] {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

button.primary, button.ghost, button.link {
  appearance: none;
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

button.primary {
  background: var(--uv);
  color: #fff;
  border: 1px solid color-mix(in srgb, var(--uv) 80%, #000);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--uv) 35%, transparent);
}
button.primary:active { transform: translateY(1px); }

button.ghost {
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--border);
}

button.link {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  padding: 8px 4px;
  min-height: 0;
}

.status {
  margin: 0;
  min-height: 1.2em;
  font-size: 14px;
  color: var(--fg-muted);
}
.status.error { color: var(--uv-vhigh); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: 0;
}

.now-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.place { margin: 0; font-size: 18px; font-weight: 600; }
.muted { color: var(--fg-muted); }
.muted.small { font-size: 12px; }

.weather-icon {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.weather-icon svg { width: 100%; height: 100%; }

.now-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: end;
}

.uv-block { display: flex; flex-direction: column; gap: 4px; }
.uv-number {
  font-size: clamp(56px, 18vw, 88px);
  font-weight: 800;
  line-height: 1;
  color: var(--uv);
  letter-spacing: -0.03em;
}
.uv-band {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: color-mix(in srgb, var(--uv) 18%, transparent);
  color: var(--uv);
  width: fit-content;
}

.temp-block { text-align: right; }
.temp-number {
  font-size: clamp(40px, 12vw, 56px);
  font-weight: 700;
  line-height: 1;
}
.temp-number .unit { font-size: 0.5em; color: var(--fg-muted); margin-left: 2px; }

.advice {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 14px;
  color: var(--fg);
}

.chart-wrap {
  width: 100%;
  height: 200px;
}
#hourlyChart { width: 100%; height: 100%; display: block; overflow: visible; }

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--fg-muted);
  margin-top: 6px;
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.uv-dot { background: var(--uv); }
.temp-dot { background: var(--temp-line); }

.week-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.week-row {
  display: grid;
  grid-template-columns: 60px 36px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.week-row:first-child { border-top: none; }
.week-day { font-weight: 600; }
.week-icon { width: 28px; height: 28px; }
.week-uv-badge {
  justify-self: start;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.week-temps { font-variant-numeric: tabular-nums; color: var(--fg); }
.week-temps .lo { color: var(--fg-muted); margin-left: 6px; }

.install-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}
.install-hint p { margin: 0; font-size: 14px; }

.footer { text-align: center; }
.footer a { color: var(--fg-muted); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
