:root {
  color-scheme: light dark;
  --bg: #f3f6f7;
  --surface: #fff;
  --surface-soft: #eaf0f2;
  --text: #142126;
  --muted: #607078;
  --border: #d3dde1;
  --accent: #6654a3;
  --accent-strong: #4f3d8a;
  --focus: #e36f27;
  --shadow: 0 8px 28px rgb(25 49 58 / 8%);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

button, a, input, summary { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.weather-shell {
  width: min(100%, 800px);
  margin: 0 auto;
  padding: 12px 12px calc(40px + env(safe-area-inset-bottom, 0px));
}

.page-header,
.current-section,
.forecast-section,
.resources-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.page-header { padding: 12px 14px 14px; }

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 2px;
  font-size: clamp(24px, 7vw, 30px);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(18px, 5vw, 21px);
  line-height: 1.2;
}

.update-line {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions { display: flex; gap: 6px; }

.quiet-button, .icon-button, .primary-button, .location-button {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
}

.quiet-button, .icon-button, .location-button {
  background: var(--surface);
  color: var(--text);
}

.quiet-button { padding: 0 12px; }
.icon-button { width: 44px; font-size: 22px; }
button:disabled { cursor: not-allowed; opacity: .45; }

.location-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.location-panel[hidden] { display: none; }

label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 750;
}

.search-row { display: flex; gap: 8px; }
.combobox-wrap { position: relative; min-width: 0; flex: 1; }

input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid #9eafb6;
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.primary-button {
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.location-button {
  margin-top: 8px;
  padding: 0 12px;
}

.suggestions {
  position: absolute;
  z-index: 5;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 240px;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.suggestions button {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.suggestions button:hover, .suggestions button[aria-selected="true"] { background: var(--surface-soft); }

.status-message {
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}

.status-message.error {
  border-color: #bc6a62;
  color: #812e27;
}

.current-section, .forecast-section, .resources-section {
  margin-top: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.current-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  align-items: center;
}

.condition-symbol { font-size: clamp(42px, 15vw, 64px); line-height: 1; }
.temperature-wrap { min-width: 0; }
.temperature { font-size: clamp(54px, 19vw, 72px); font-weight: 750; line-height: .9; letter-spacing: -.06em; }
.degree { font-size: .55em; vertical-align: top; }
.condition { margin: 7px 0 0; font-size: 16px; font-weight: 750; text-transform: capitalize; }

.current-side {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted);
  font-size: 14px;
}

.current-side p { margin: 0; }

.cache-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.what-to-know {
  margin: 14px 0 0;
  padding: 10px 11px;
  border-left: 4px solid var(--accent);
  background: var(--surface-soft);
  font-weight: 650;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0 0;
  border-top: 1px solid var(--border);
}

.detail-item {
  min-width: 0;
  padding: 10px 6px 8px 0;
  border-bottom: 1px solid var(--border);
}

.detail-item:nth-child(even) { padding-left: 10px; border-left: 1px solid var(--border); }
.detail-item dt { color: var(--muted); font-size: 12px; font-weight: 750; }
.detail-item dd { margin: 2px 0 0; font-size: 16px; font-weight: 750; }

.more-details { margin-top: 5px; }
.more-details summary { min-height: 44px; padding: 12px 0 4px; cursor: pointer; color: var(--accent-strong); font-weight: 750; }
.detail-grid-secondary { margin-top: 4px; }

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.section-heading span { color: var(--muted); font-size: 12px; text-align: right; }

.hourly-strip {
  display: flex;
  gap: 7px;
  margin: 0 -14px;
  padding: 0 14px 7px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.hour-card {
  flex: 0 0 76px;
  min-height: 116px;
  padding: 9px 5px;
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: 11px;
  text-align: center;
}

.hour-card:first-child { border-color: var(--accent); background: var(--surface-soft); }
.hour-time, .hour-pop { color: var(--muted); font-size: 12px; }
.hour-icon { margin: 5px 0; font-size: 25px; }
.hour-temp { font-size: 18px; font-weight: 800; }

.daily-list {
  min-width: 0;
  margin-inline: -14px;
}

.daily-rail {
  display: flex;
  gap: 9px;
  padding: 2px 14px 10px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  touch-action: pan-x pan-y;
}

.daily-card {
  flex: 0 0 116px;
  display: grid;
  grid-template-areas: "day" "icon" "temps" "pop";
  place-items: center;
  gap: 3px;
  min-height: 114px;
  padding: 9px 8px;
  scroll-snap-align: start;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  cursor: pointer;
}

.daily-card[aria-selected="true"] {
  border-color: var(--accent);
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.daily-day { grid-area: day; font-weight: 800; }
.daily-icon { grid-area: icon; font-size: 26px; text-align: center; }
.daily-condition { display: none; }
.daily-pop { grid-area: pop; min-height: 18px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.daily-temps { grid-area: temps; font-size: 16px; font-weight: 800; white-space: nowrap; }
.daily-low { color: var(--muted); font-weight: 650; }

.daily-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 12px;
  min-height: 62px;
  margin: 0 14px;
  padding: 8px 4px 2px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.daily-detail p { margin: 0; }
.daily-detail p:first-child {
  grid-column: 1 / -1;
  color: var(--text);
  font-weight: 750;
  text-transform: capitalize;
}

.story-grid {
  display: grid;
  gap: 9px;
}

.story-card {
  position: relative;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 96px;
  padding: 10px 38px 10px 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.story-card:hover,
.story-card:focus-visible,
.resource-card:hover,
.resource-card:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--surface-soft) 78%, var(--accent) 22%);
}

.story-visual {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 65%, var(--accent) 35%);
  border-radius: 11px;
  background: color-mix(in srgb, var(--surface-soft) 70%, var(--accent) 30%);
  color: var(--accent-strong);
  font-size: 28px;
}

.story-visual > * { grid-area: 1 / 1; }
.story-fallback { align-self: center; justify-self: center; }

.story-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-copy {
  min-width: 0;
  padding: 0;
}

.story-badge {
  display: inline-flex;
  margin-bottom: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.story-title {
  display: block;
  overflow: hidden;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.story-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.story-card > .external-arrow {
  position: absolute;
  top: 11px;
  right: 12px;
  color: var(--accent-strong);
  font-size: 17px;
}

.resource-grid {
  display: grid;
  gap: 8px;
}

.resource-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}

.resource-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 850;
}

.resource-icon-text { font-size: 11px; letter-spacing: .02em; }
.resource-copy { min-width: 0; }
.resource-copy strong { display: block; font-size: 15px; line-height: 1.25; }
.resource-copy span { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; line-height: 1.3; }
.resource-card .external-arrow { color: var(--accent-strong); font-size: 17px; text-align: right; }

footer { padding: 18px 8px 0; color: var(--muted); font-size: 13px; }

@media (min-width: 560px) {
  .weather-shell { padding: 18px 18px 40px; }
  .page-header, .current-section, .forecast-section, .resources-section { padding: 16px 18px; }
  .current-main { grid-template-columns: auto 1fr auto; }
  .current-side { grid-column: auto; display: block; text-align: right; }
  .current-side p + p { margin-top: 4px; }
  .hourly-strip { margin-inline: -18px; padding-inline: 18px; }
  .daily-list { margin-inline: 0; border-top: 1px solid var(--border); }
  .daily-rail {
    display: block;
    padding: 0;
    overflow: visible;
  }
  .daily-card {
    width: 100%;
    min-height: 52px;
    display: grid;
    grid-template-areas: "day icon condition pop temps";
    grid-template-columns: 76px 34px minmax(130px, 1fr) 54px auto;
    gap: 8px;
    padding: 4px 0;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
  }
  .daily-card[aria-selected="true"] { background: var(--surface-soft); box-shadow: none; }
  .daily-condition { display: block; min-width: 0; color: var(--muted); font-size: 13px; line-height: 1.25; }
  .daily-pop, .daily-temps { text-align: right; }
  .daily-detail { margin: 0; padding: 10px 0 0; border-top: 0; font-size: 13px; }
  .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .resource-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101719;
    --surface: #182226;
    --surface-soft: #223137;
    --text: #eef5f6;
    --muted: #a8b7bd;
    --border: #34464d;
    --accent: #a792ea;
    --accent-strong: #c0b1f3;
    --focus: #ff9a5b;
    --shadow: none;
  }
  .status-message.error { border-color: #d7887f; color: #ffc5be; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
