:root {
  color-scheme: light dark;
  --background: #fff;
  --text: #171717;
  --secondary-text: #656565;
  --border: #c9c9c9;
  --soft-background: rgba(127, 127, 127, 0.1);
  --alert: #9a351f;
  --alert-background: #f8ece8;
  --focus: #075ec8;
  --error: #a51d1d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #1e1e1e;
    --text: #f0f0f0;
    --secondary-text: #aaa;
    --border: #555;
    --soft-background: rgba(255, 255, 255, 0.08);
    --alert: #ffad99;
    --alert-background: #382722;
    --focus: #83b9ff;
    --error: #ff9a9a;
  }
}

:root[data-theme="dark"] {
  --background: #1e1e1e;
  --text: #f0f0f0;
  --secondary-text: #aaa;
  --border: #555;
  --soft-background: rgba(255, 255, 255, 0.08);
  --alert: #ffad99;
  --alert-background: #382722;
  --focus: #83b9ff;
  --error: #ff9a9a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  min-width: 280px;
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
}

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

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 60%, transparent);
  outline-offset: 2px;
}

main,
footer {
  width: min(100% - 40px, 600px);
  margin-inline: auto;
}

main { margin-top: 20px; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--text);
  transform: translateY(-150%);
}

.skip-link:focus { transform: none; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.site-title { min-width: 0; }

.header-controls {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
}

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

h1 {
  margin-bottom: 1px;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h2 {
  font-size: 1rem;
  line-height: 1.3;
}

.location,
.muted { color: var(--secondary-text); }

.location {
  margin-bottom: 0;
  font-size: 0.875rem;
}

label,
legend { font-size: 0.875rem; }

.segmented-picker {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 6px;
  background: var(--soft-background);
}

.segmented-picker legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.segmented-picker label {
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--secondary-text);
  cursor: pointer;
}

.segmented-picker label:has(input:checked) {
  background: var(--background);
  color: var(--text);
}

.segmented-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-picker label:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--focus) 60%, transparent);
  outline-offset: 2px;
}

.theme-toggle,
.text-button {
  min-height: 32px;
  padding: 4px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--secondary-text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.theme-toggle:hover:not(:disabled),
.text-button:hover:not(:disabled) {
  background: var(--soft-background);
  color: var(--text);
}

.theme-toggle:disabled,
.text-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.status-line,
.update-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-line {
  justify-content: space-between;
  min-height: 32px;
}

.status-line p {
  margin-bottom: 0;
  font-size: 0.875rem;
}

.stale-badge {
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--alert) 35%, transparent);
  border-radius: 999px;
  background: var(--alert-background);
  color: var(--alert);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}

.error-message {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  color: var(--error);
}

.error-message p { margin-bottom: 0; }
.error-message .text-button { color: inherit; }

.notice-list { margin-top: 12px; }

.notice-list p {
  margin-bottom: 6px;
  color: var(--secondary-text);
  font-size: 0.875rem;
}

.alert-summary {
  margin-top: -12px;
  margin-bottom: 36px;
  border: 1px solid color-mix(in srgb, var(--alert) 42%, var(--border));
  border-radius: 6px;
  background: var(--alert-background);
}

.alert-summary summary {
  position: relative;
  padding: 12px 42px 12px 16px;
  cursor: pointer;
  list-style: none;
}

.alert-summary summary::-webkit-details-marker { display: none; }

.alert-summary summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 16px;
  color: var(--secondary-text);
  font-size: 1.25rem;
  transform: translateY(-50%);
}

.alert-summary[open] summary::after { content: "−"; }

.alert-summary summary strong {
  display: block;
  color: var(--alert);
}

.alert-summary > p {
  margin: 0;
  padding: 0 42px 14px 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--secondary-text);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.current {
  display: flex;
  align-items: center;
  gap: 32px;
  margin: 30px 0 36px;
}

.condition-icon {
  width: 160px;
  height: 160px;
  flex: 0 0 auto;
}

.current-copy { min-width: 0; }

.temperature {
  margin: 0 0 -2px;
  font-size: clamp(3.75rem, 14vw, 5.5rem);
  font-weight: 600;
  letter-spacing: -0.07em;
  line-height: 1;
}

.condition {
  margin-bottom: 2px;
  font-size: 1.1rem;
  font-weight: 600;
}

.current-copy .muted { margin-bottom: 0; }

.summary-grid,
.measurement-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 28px;
  margin: 0;
}

.summary-grid div,
.measurement-list div { min-width: 0; }

.summary-grid dt,
.measurement-list dt {
  color: var(--secondary-text);
  font-size: 0.8rem;
}

.summary-grid dd,
.measurement-list dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 600;
}

.tonight { margin-top: 28px; }
.tonight h3 {
  margin: 0 0 7px;
  font-size: 1rem;
  line-height: 1.3;
}
.tonight p:last-child { margin-bottom: 0; }

.detail-section {
  padding: 22px 0;
  border-top: 1px solid var(--border);
}

.detail-section h2 { margin: 0 0 16px; }

.section-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
}

.scroll-hint {
  margin-bottom: 16px;
  color: var(--secondary-text);
  font-size: 0.78rem;
}

.hourly-row {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.hour-card {
  flex: 0 0 108px;
  min-height: 180px;
  padding: 0 12px;
  scroll-snap-align: start;
}

.hour-card:first-child { padding-left: 0; }
.hour-card + .hour-card { border-left: 1px solid var(--border); }
.hour-card p { margin-bottom: 5px; }

.hour-time {
  color: var(--secondary-text);
  font-size: 0.8rem;
}

.hour-temp {
  font-size: 1.3rem;
  font-weight: 600;
}

.hour-condition,
.hour-rain,
.hour-wind { font-size: 0.78rem; }

.hour-icon {
  width: 34px;
  height: 34px;
  margin: 3px 0 6px;
}

.daily-list { margin: 0; }
.daily-item + .daily-item { border-top: 1px solid var(--border); }

.daily-item summary {
  display: grid;
  grid-template-columns: minmax(105px, 0.7fr) 64px minmax(130px, 1.4fr) 28px;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  cursor: pointer;
  list-style: none;
}

.daily-item summary::-webkit-details-marker { display: none; }

.daily-item summary::after {
  content: "+";
  justify-self: end;
  color: var(--secondary-text);
  font-size: 1.25rem;
}

.daily-item[open] summary::after { content: "−"; }

.daily-name,
.daily-temp { font-weight: 600; }

.daily-condition {
  color: var(--secondary-text);
  font-size: 0.875rem;
}

.daily-detail {
  padding: 0 40px 14px 0;
  color: var(--secondary-text);
  font-size: 0.9rem;
}

.daily-detail p:last-child { margin-bottom: 0; }

.alert-card {
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--alert) 35%, var(--border));
  border-radius: 6px;
  background: var(--alert-background);
}

.alert-card summary {
  padding: 12px 14px;
  cursor: pointer;
}

.alert-card summary strong,
.alert-card summary span { display: block; }

.alert-card summary span {
  margin-top: 3px;
  color: var(--secondary-text);
  font-size: 0.82rem;
}

.alert-body {
  padding: 0 14px 14px;
  white-space: pre-line;
}

.alert-body h3 {
  margin: 18px 0 5px;
  font-size: 0.95rem;
}

.empty-state {
  margin: 0;
  padding: 4px 0;
  color: var(--secondary-text);
}

.skeleton-text {
  width: 2.5ch;
  border-radius: 4px;
  background: var(--soft-background);
  color: transparent;
}

footer {
  margin-top: 40px;
  margin-bottom: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--secondary-text);
  font-size: 0.875rem;
}

footer p { margin-bottom: 6px; }
footer p:last-child { margin-bottom: 0; }

footer a {
  color: inherit;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.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;
}

@media (max-width: 520px) {
  .page-header { align-items: flex-start; }

  .header-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .current {
    align-items: flex-start;
    gap: 18px;
  }

  .condition-icon {
    width: 120px;
    height: 120px;
  }

  .temperature { font-size: 4rem; }

  .daily-item summary {
    grid-template-columns: minmax(90px, 0.8fr) 54px minmax(90px, 1fr) 24px;
    gap: 8px;
  }
}

@media (max-width: 380px) {
  .page-header { flex-wrap: wrap; }
  .header-controls { margin-left: auto; }

  .current {
    align-items: center;
    gap: 14px;
  }

  .condition-icon {
    width: 88px;
    height: 88px;
  }

  .temperature { font-size: 3.5rem; }

  .summary-grid,
  .measurement-list { gap: 18px; }

  .daily-condition { display: none; }

  .daily-item summary {
    grid-template-columns: minmax(105px, 1fr) 54px 24px;
  }

  .error-message {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }
}

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