:root {
  color-scheme: light;
  overscroll-behavior-y: none;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-synthesis: none;
  --page: #f0f1eb;
  --card: #f9faf6;
  --highlight: #e5ebe1;
  --ink: #23322b;
  --accent: #36584a;
  --muted: #56635b;
  --line: #d8dfd6;
  --rain: #d6e1dc;
  --rain-stroke: #849b95;
  --gust: #78857b;
  --sun: #b59d69;
  --button: #fdfdf9;
  --overlay: #fffefa;
  --tabs: #e9ede7;
  --shadow: #23322b19;
}
:root[data-theme="blue"] {
  --page: #edf1f4;
  --card: #f8fafb;
  --highlight: #e2eaf0;
  --ink: #26343f;
  --accent: #375b72;
  --muted: #4c616e;
  --line: #d3dde4;
  --rain: #d6e4ec;
  --rain-stroke: #68869a;
  --gust: #72818e;
  --sun: #9f824c;
  --button: #fafcfd;
  --overlay: #fcfdfe;
  --tabs: #e4ecf2;
}
:root[data-theme="amber"] {
  --page: #f5efe5;
  --card: #fcf8f0;
  --highlight: #efe1cc;
  --ink: #3c3025;
  --accent: #80502c;
  --muted: #675747;
  --line: #e5d9c8;
  --rain: #ead9c3;
  --rain-stroke: #9a714a;
  --gust: #8b7867;
  --sun: #a87739;
  --button: #fdf9f2;
  --overlay: #fffdf7;
  --tabs: #f0e5d5;
  --shadow: #3c302519;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1a2020;
  --card: #242a2a;
  --highlight: #2e3937;
  --ink: #e8ede8;
  --accent: #b3cec1;
  --muted: #b5c0bb;
  --line: #46514e;
  --rain: #384d48;
  --rain-stroke: #88afa6;
  --gust: #a0a8b1;
  --sun: #d6bb86;
  --button: #293231;
  --overlay: #27302e;
  --tabs: #2d3634;
  --shadow: #00000046;
}
* { box-sizing: border-box; }
body { margin: 0; padding-block: env(safe-area-inset-top) env(safe-area-inset-bottom); }
h1, h2, p, dl, dd, ul { margin: 0; }
button, select { color: inherit; font: inherit; }
button:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.status-bar-surface { display: none; }
@media (display-mode: standalone) {
  @supports (-webkit-touch-callout: none) {
    /* iOS can use a solid fixed surface at the top edge for its status bar. */
    .status-bar-surface {
      display: block;
      position: fixed;
      inset: 0 0 auto;
      block-size: max(12px, env(safe-area-inset-top));
      background-color: var(--page);
      pointer-events: none;
    }
  }
}
.dashboard {
  max-inline-size: 440px;
  block-size: min(840px, calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  block-size: min(840px, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  min-block-size: 670px;
  margin-inline: auto;
  padding: 9px clamp(12px, 4.55vw, 20px) 5px;
  display: grid;
  grid-template-rows: 44px minmax(115px, 149fr) minmax(104px, 117fr) minmax(142px, 213fr) minmax(193px, 244fr) 14px;
  gap: clamp(6px, 1.05dvh, 10px);
}
.topbar, .section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar { position: relative; padding-inline-start: 3px; }
#pull-hint {
  position: absolute;
  z-index: 1;
  inset-block-start: calc(100% + 2px);
  inset-inline: 0;
  inline-size: max-content;
  margin-inline: auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}
h1 { font-size: clamp(19px, 5.7vw, 24px); letter-spacing: .055em; line-height: 1; }
.actions { display: flex; gap: 11px; }
.icon-button {
  inline-size: 44px;
  block-size: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--button);
}
.icon-button[aria-expanded="true"] { background: var(--highlight); }
.icon { display: block; inline-size: 24px; block-size: 24px; flex: none; }
@media (prefers-reduced-motion: no-preference) {
  #refresh-control[aria-busy="true"] .icon { animation: refresh-turn 1s linear infinite; }
  @keyframes refresh-turn { to { transform: rotate(1turn); } }
}
.card {
  min-inline-size: 0;
  min-block-size: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
}
.hero {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: 10px 16px 7px;
  background: var(--highlight);
}
.current { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 0; }
.place h2 { font-size: clamp(24px, 6.1vw, 28px); line-height: 1.05; font-weight: 620; }
.current-temperature { font-size: clamp(46px, 13vw, 58px); font-weight: 300; line-height: .94; letter-spacing: -.07em; }
.condition {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 1px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
}
.condition strong { color: var(--ink); font-size: 16px; }
.hero-icon { display: block; width: 43px; height: 43px; margin-right: 5px; }
.sun-times, .metrics-extra {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 13px;
  align-items: center;
  border-top: 1px solid var(--line);
}
.sun-times { padding-block: 6px 2px; }
.sun-times div, .metrics-extra div { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; }
.sun-times div + div { border-inline-start: 1px solid var(--line); padding-inline-start: 12px; }
.sun-times dt { font-size: clamp(10.5px, 2.8vw, 13px); color: var(--muted); white-space: nowrap; }
.sun-times dd { color: var(--accent); font-size: 14px; font-weight: 650; }
.metrics { display: grid; grid-template-rows: minmax(0, 1fr) auto; padding: 8px 15px 6px; }
.metrics-main { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 12px; }
.metrics-main h2 { margin-block-end: 3px; color: var(--muted); font-size: 13px; line-height: 1.05; font-weight: 550; }
.precipitation p { display: flex; gap: 9px; align-items: baseline; }
.precipitation strong { font-size: 24px; font-weight: 650; }
.precipitation span { font-size: 14px; color: var(--muted); }
.wind { border-inline-start: 1px solid var(--line); padding-inline-start: 12px; }
.wind p { font-size: clamp(11.5px, 3.1vw, 13.5px); line-height: 1.12; white-space: nowrap; }
.wind .wind-speed { font-size: clamp(13px, 3.6vw, 16px); }
.direction { color: var(--muted); }
.metrics-extra { padding-block-start: 5px; }
.metrics-extra dt { font-size: 12.5px; color: var(--muted); }
.metrics-extra dd { font-size: clamp(13px, 3.4vw, 15px); font-weight: 650; white-space: nowrap; }

.forecast {
  padding: 7px 15px 6px;
  display: grid;
  grid-template-rows: auto 40px minmax(41px, 1fr) auto;
  gap: 4px;
}
.section-header h2, .week-heading h2 { font-size: 20px; font-weight: 650; line-height: 1.15; }
.local-time { color: var(--muted); font-size: 12px; }
.segments {
  display: grid;
  grid-template-columns: .88fr 1.09fr 1.19fr .84fr;
  padding: 3px;
  border-radius: 11px;
  background: var(--tabs);
}
.segments button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 2px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(10px, 2.95vw, 13px);
  font-weight: 620;
  white-space: nowrap;
}
.segments button[aria-selected="true"] { color: var(--ink); border-color: var(--line); background: var(--overlay); }
.chart-panel { min-block-size: 0; }
#chart { display: block; width: 100%; height: 100%; }
.legend { display: flex; align-items: center; gap: clamp(6px, 2.8vw, 12px); min-height: 14px; line-height: 1; }
.legend-item { display: flex; align-items: center; min-inline-size: 0; gap: 4px; font-size: clamp(10px, 2.8vw, 12px); color: var(--muted); }
.legend-item span:last-child { white-space: nowrap; }
.swatch { height: 0; width: 13px; border: 1px solid var(--accent); border-radius: 2px; flex: none; }
.swatch.rain, .swatch.amount { height: 8px; border-color: var(--rain-stroke); background: var(--rain); }
.swatch.probability { border-color: var(--rain-stroke); }
.swatch.gust { border-style: dashed; border-color: var(--gust); }

.week {
  --day-columns: 81px minmax(0, 1fr) 40px 80px 48px;
  --day-column-gap: 4px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 7px 12px 6px;
}
.week-heading, .day {
  display: grid;
  grid-template-columns: var(--day-columns);
  column-gap: var(--day-column-gap);
}
.week-heading {
  align-items: baseline;
  padding-block-end: 5px;
}
.week-heading h2 { grid-column: span 2; }
.week-heading span { color: var(--muted); font-weight: 550; font-size: 11px; white-space: nowrap; }
.days { display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); list-style: none; padding: 0; }
.day {
  align-items: center;
  border-top: 1px solid var(--line);
  font-size: clamp(11.5px, 3.14vw, 13.5px);
}
.day-date { font-weight: 550; white-space: nowrap; }
.today { font-weight: 700; }
.day-weather { display: flex; align-items: center; gap: 2px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.day-weather .icon { width: 19px; height: 19px; }
.day-rain, .day-temp, .day-wind { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.day-rain, .day-temp, .day-temp > span, .day-wind-value { justify-self: end; }
.day-temp { inline-size: 76px; }
.week-heading .day-temp { text-align: center; }
.day-wind { justify-self: center; }
.day :is(.day-rain, .day-temp, .day-wind) { font-size: 13px; font-weight: 400; }
.day .day-temp { display: grid; grid-template-columns: 35px 33px; }
.day .day-wind {
  display: grid;
  grid-template-columns: 2ch 15px;
  align-items: center;
  column-gap: 4px;
}
.day-wind-arrow { justify-self: center; font-size: 15px; line-height: 1; }
footer { align-self: end; padding-inline-start: 3px; color: var(--muted); font-size: 11.5px; }

.popover {
  position: absolute;
  z-index: 2;
  top: 49px;
  right: 0;
  width: min(94%, 280px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--overlay);
  box-shadow: 0 5px 18px var(--shadow);
  font-size: 14px;
}
.popover h2 { margin-bottom: 6px; font-size: 17px; }
.popover p, .popover dt { color: var(--muted); }
.popover dl div { display: flex; justify-content: space-between; gap: 8px; }
.popover button { display: block; margin-block-start: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--highlight); }
.visually-hidden {
  position: absolute;
  margin: -1px;
  padding: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-height: 780px) {
  .dashboard { padding-block: 7px 4px; gap: 6px; }
  .hero { padding-block: 6px 4px; }
  .hero-icon { width: 35px; height: 35px; }
  .current-temperature { font-size: 49px; }
  .metrics { padding-block: 6px 5px; }
  .forecast { grid-template-rows: auto 36px minmax(40px, 1fr) auto; }
}
@media (max-width: 385px) {
  .card { border-radius: 16px; }
  .hero, .metrics, .forecast, .week { padding-inline: 11px; }
  .week { --day-column-gap: 3px; }
  .day-weather { font-size: 11px; }
}

.place { min-inline-size: 0; }
.place-title, .condition strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-title { max-inline-size: 100%; }
.condition { min-inline-size: 0; }
.condition strong { max-inline-size: 100%; }
.day-when { min-inline-size: 0; display: grid; grid-template-columns: 1.95rem auto; column-gap: 3px; }
.day-when .day-date { font-weight: 400; color: var(--muted); text-align: left; }
.day-when.today { display: flex; gap: 4px; font-weight: 700; }
.day-when.today .day-date { font-weight: 700; color: var(--ink); }
.day-weather { overflow: hidden; }
.day-condition { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; }
footer { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
footer [role=status] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
footer a, .popover a { color: var(--muted); }
.popover { max-block-size: min(63dvh, 455px); overflow: auto; overscroll-behavior: contain; }
#settings-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#settings-panel > :is(h2, button) { flex: none; }
#settings-panel > button { align-self: flex-start; }
.settings-content {
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior: contain;
  margin-inline: -4px;
  padding: 0 4px 4px;
}
.popover h3 { margin: 0 0 7px; font-size: 14px; }
.theme-field { display: grid; gap: 4px; margin-block-start: 12px; }
.theme-field label { font-weight: 550; }
.theme-field select {
  inline-size: 100%;
  min-block-size: 38px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  font-size: 16px;
}
.popover ul:empty { display: none; }
.popover .places { list-style: none; padding: 0; }
.popover .places li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 0;
  border-block-end: 1px solid var(--line);
}
.popover .places button { margin: 0; max-width: 100%; text-align: start; }
.popover .places .choose-place { flex: 1; min-inline-size: 0; }
.place-caption { min-inline-size: 0; overflow-wrap: anywhere; }
.place-caption small { display: block; color: var(--muted); }
.panel-action { width: 100%; text-align: left; }
.panel-message, .location-source { margin-top: 6px; font-size: 12px; }
#place-search { margin-top: 9px; }
.search-line { display: flex; gap: 5px; align-items: stretch; margin-top: 4px; }
.search-line input {
  inline-size: 100%;
  min-inline-size: 0;
  font: inherit;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 6px;
  background: var(--card);
  color: var(--ink);
}
.search-line button { margin: 0; }

.icon-button:disabled { opacity: .55; }
.places [aria-current='true'] { background: var(--highlight); font-weight: 650; }
.forecast-empty { color: var(--muted); font-size: 13px; padding-block: 8px; grid-row: 1 / -1; }
.rain-interval { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.15; }
