:root,
html[data-phase="night"] {
  --bg0: #070b12;
  --bg1: #152238;
  --ink: #f4f1ea;
  --muted: #c5d0da;
  --card: rgba(6, 10, 14, 0.42);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #d7e2f5;
  --glow: rgba(198, 214, 240, 0.22);
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
  color-scheme: dark;
}

html[data-phase="day"] {
  --bg0: #102033;
  --bg1: #1a4664;
  --accent: #f0c27a;
  --glow: rgba(240, 194, 122, 0.42);
}

body.cond-clear {
  --bg0: #0c1624;
  --bg1: #1a4664;
  --glow: rgba(240, 194, 122, 0.42);
  --accent: #f0c27a;
}
body.phase-night.cond-clear {
  --bg0: #070b12;
  --bg1: #152238;
  --glow: rgba(198, 214, 240, 0.2);
  --accent: #d7e2f5;
}
body.cond-partly {
  --bg0: #101a28;
  --bg1: #23445c;
  --glow: rgba(226, 206, 164, 0.32);
  --accent: #e7d3a8;
}
body.phase-night.cond-partly {
  --bg0: #0a1018;
  --bg1: #1a2838;
  --glow: rgba(190, 206, 226, 0.16);
  --accent: #d5deea;
}
body.cond-cloud {
  --bg0: #141a22;
  --bg1: #2c3a4a;
  --glow: rgba(206, 216, 226, 0.24);
  --accent: #d5dee8;
}
body.phase-night.cond-cloud {
  --bg0: #0c1016;
  --bg1: #1c242e;
  --glow: rgba(180, 190, 200, 0.12);
  --accent: #c9d3dc;
}
body.cond-fog {
  --bg0: #161614;
  --bg1: #3a342c;
  --glow: rgba(214, 196, 160, 0.18);
  --accent: #e6d3b0;
}
body.phase-night.cond-fog {
  --bg0: #12110f;
  --bg1: #26221c;
  --glow: rgba(200, 186, 150, 0.1);
  --accent: #ddd0b4;
}
body.cond-rain {
  --bg0: #0d141c;
  --bg1: #16344a;
  --glow: rgba(140, 190, 220, 0.22);
  --accent: #b7dff3;
}
body.phase-night.cond-rain {
  --bg0: #0a1016;
  --bg1: #132838;
  --glow: rgba(120, 170, 200, 0.14);
  --accent: #a9d3ea;
}
body.cond-snow {
  --bg0: #121820;
  --bg1: #2a3c50;
  --glow: rgba(236, 244, 252, 0.32);
  --accent: #e7f1fb;
}
body.phase-night.cond-snow {
  --bg0: #0e141c;
  --bg1: #1e2c3c;
  --glow: rgba(220, 232, 246, 0.16);
  --accent: #e3eef8;
}
body.cond-ice {
  --bg0: #101820;
  --bg1: #1b3c48;
  --glow: rgba(176, 230, 236, 0.24);
  --accent: #c9f4f6;
}
body.phase-night.cond-ice {
  --bg0: #0c1418;
  --bg1: #163038;
  --glow: rgba(160, 220, 226, 0.14);
  --accent: #c4eef2;
}
body.cond-storm {
  --bg0: #120e18;
  --bg1: #2a1c40;
  --glow: rgba(196, 160, 230, 0.28);
  --accent: #e4ccff;
}
body.phase-night.cond-storm {
  --bg0: #0c0a12;
  --bg1: #1c1430;
  --glow: rgba(170, 140, 210, 0.16);
  --accent: #ddc6fb;
}
body.cond-unknown {
  --bg0: #121416;
  --bg1: #24282c;
  --glow: rgba(200, 200, 200, 0.12);
  --accent: #d0d4d8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg0); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg0);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; touch-action: manipulation; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
::selection { background: rgba(240, 194, 122, 0.35); }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(880px 420px at 90% -8%, var(--glow), transparent 58%),
    linear-gradient(180deg, var(--bg1) 0%, var(--bg0) 48%, var(--bg0) 100%);
}
.orb {
  position: absolute;
  width: min(52vw, 260px);
  height: min(52vw, 260px);
  right: -70px;
  top: -90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff 0%, var(--accent) 26%, transparent 70%);
  opacity: 0.5;
}
body.phase-night .orb {
  width: 180px;
  height: 180px;
  top: -70px;
  right: -40px;
  opacity: 0.42;
}
body.cond-rain .orb,
body.cond-fog .orb,
body.cond-storm .orb { opacity: 0.1; }
.atmosphere::before,
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
}
body.cond-rain .atmosphere::before,
body.cond-storm .atmosphere::before {
  background: repeating-linear-gradient(
    112deg,
    transparent 0 18px,
    rgba(186, 214, 232, 0.1) 18px 19px
  );
  animation: drift 10s linear infinite;
}
body.cond-snow .atmosphere::before {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.75) 0 1px, transparent 1.6px);
  background-size: 70px 70px;
  opacity: 0.4;
  animation: fall 16s linear infinite;
}
body.phase-night.cond-clear .atmosphere::after,
body.phase-night.cond-partly .atmosphere::after {
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255, 255, 255, 0.85) 50%, transparent 60%),
    radial-gradient(1.5px 1.5px at 28% 12%, rgba(255, 255, 255, 0.7) 50%, transparent 60%),
    radial-gradient(1px 1px at 46% 28%, rgba(255, 255, 255, 0.5) 50%, transparent 60%),
    radial-gradient(1px 1px at 63% 16%, rgba(255, 255, 255, 0.75) 50%, transparent 60%),
    radial-gradient(1.5px 1.5px at 78% 34%, rgba(255, 255, 255, 0.45) 50%, transparent 60%),
    radial-gradient(1px 1px at 90% 18%, rgba(255, 255, 255, 0.65) 50%, transparent 60%);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  margin: 0 auto;
  padding:
    calc(22px + env(safe-area-inset-top))
    0
    calc(28px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.identity { min-width: 0; }
h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(32px, 8vw, 56px);
  letter-spacing: -0.04em;
  line-height: 0.95;
  text-wrap: balance;
}
.caption, .updated, .sun-times, .readout-label, .stat span, .block-head h2 {
  color: var(--muted);
}
.caption { margin: 8px 0 0; font-size: 13.5px; }
.updated { margin: 6px 0 0; font-size: 13.5px; }
.rule {
  height: 1px;
  margin: 18px 0 0;
  border: 0;
  background: linear-gradient(90deg, var(--accent), transparent 78%);
  opacity: 0.75;
}

.controls { display: flex; align-items: center; gap: 8px; flex: none; }
.units {
  display: flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}
.units button {
  min-width: 44px;
  min-height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.units button[aria-pressed="true"] {
  background: var(--ink);
  color: #14202a;
  font-weight: 600;
}
.refresh {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  cursor: pointer;
}
.refresh:disabled { opacity: 0.7; }
.refresh.is-refreshing svg { animation: spin 0.8s linear infinite; }

.banner, .toast {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 14px;
}
.banner {
  background: rgba(240, 194, 122, 0.14);
  color: var(--accent);
}
.toast {
  background: rgba(255, 180, 168, 0.14);
  color: #ffd2cb;
}

.condition {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}
.condition-icon { width: 48px; height: 48px; flex: none; }
.condition-label {
  margin: 0;
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -0.03em;
  line-height: 1;
}
.sun-times { margin: 4px 0 0; font-size: 13.5px; }

.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 18px;
}
.readout + .readout {
  padding-left: clamp(12px, 3vw, 28px);
  border-left: 1px solid var(--line);
}
.degree-row { display: flex; align-items: flex-start; }
.num {
  font-family: var(--serif);
  font-weight: 560;
  font-size: clamp(56px, 16vw, 108px);
  line-height: 0.86;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}
.feels .num { color: var(--accent); }
.deg {
  margin-top: 0.16em;
  font-family: var(--serif);
  font-size: clamp(22px, 5vw, 36px);
  color: var(--muted);
}
.readout-label {
  margin: 10px 0 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
}
.stat {
  min-height: 74px;
  padding: 12px 12px 11px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.stat span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.stat b {
  display: block;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.block { margin-top: 28px; }
.block-head h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.hourly-scroller {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 2px 2px 8px 0;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 28px), transparent);
}
.hourly-scroller::-webkit-scrollbar { display: none; }
.hour {
  flex: 0 0 76px;
  scroll-snap-align: start;
  padding: 12px 6px 10px;
  border-radius: 18px;
  border: 1px solid transparent;
  text-align: center;
}
.hour.is-now {
  border-color: var(--line);
  background: var(--card);
}
.hour time { display: block; font-size: 12px; color: var(--muted); }
.hour .ico { width: 28px; height: 28px; margin: 8px auto; }
.hour .t {
  margin: 0;
  font-size: 16px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
}
.hour .feels, .hour .pop {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.day {
  display: grid;
  grid-template-columns: auto 28px minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 8px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.day-when strong, .day-cond { display: block; font-weight: 560; }
.day-when span, .day-feels, .day-cond span { color: var(--muted); font-size: 13px; font-weight: 400; }
.day-temp {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.day-temp .hi { text-align: right; }
.track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
.fill {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.45), var(--accent));
}
.ico svg { width: 100%; height: 100%; display: block; }

.error {
  max-width: 460px;
  margin-top: 28px;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--card);
}
.error h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-weight: 560;
  font-size: 30px;
  letter-spacing: -0.03em;
}
.error p { margin: 0; color: var(--muted); }
.error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}
.btn.primary { background: var(--ink); color: #14202a; border-color: transparent; font-weight: 600; }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 28px;
  color: var(--muted);
  font-size: 12px;
}
.footer p { margin: 0; }
.footer a { color: inherit; }
.noscript { margin-top: 18px; color: var(--muted); }

.skeleton { margin-top: 22px; }
.sk {
  border-radius: 16px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-line { width: 46%; height: 28px; }
.sk-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.sk-temp { height: 84px; }
.sk-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.sk-stats .sk { height: 72px; }

@media (min-width: 800px) {
  .shell { width: min(980px, calc(100% - 64px)); }
  .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .day {
    grid-template-columns: 92px 28px minmax(160px, 1fr) minmax(190px, 240px);
    column-gap: 14px;
  }
  .day-temp { grid-column: auto; }
  .sk-stats { grid-template-columns: repeat(6, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .refresh.is-refreshing svg,
  .sk,
  .atmosphere::before { animation: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes drift {
  from { transform: translateY(-6%); }
  to { transform: translateY(6%); }
}
@keyframes fall {
  from { background-position: 0 -40px; }
  to { background-position: 24px 180px; }
}
