:root {
  color-scheme: light;
  --paper: #f6f8fa;
  --ink: #1d2733;
  --muted: #5b6b7a;
  --sky: #2f6f9f;
  --rule: #d5dee6;
  --today-bg: #e6eff6;
  --surface: #fbfcfd;
  --art-sun: #b87400;
  --art-moon: #6f7f8e;
  --art-cloud: #5b6b7a;
  --art-rain: #2f6f9f;
  --art-snow: #3f82bb;
  --art-fog: #8a98a6;
  --art-storm: #4d5b69;
  --art-downpour: #2748a8;
  --alert-ink: #8a3d00;
  --alert-bg: #fff2e0;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #121d27;
    --ink: #e4ebf1;
    --muted: #98a9b8;
    --sky: #82b8e0;
    --rule: #2a3a48;
    --today-bg: #1a2b3a;
    --surface: #1a2734;
    --art-sun: #f2c14e;
    --art-moon: #c9d4de;
    --art-cloud: #a9b8c6;
    --art-rain: #82b8e0;
    --art-snow: #dce9f5;
    --art-fog: #7d8d9c;
    --art-storm: #8a9aaa;
    --art-downpour: #6f94f2;
    --alert-ink: #f4bd7a;
    --alert-bg: #36260f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--serif);
}
.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}
a { color: var(--sky); }
a:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
p { margin: 0 0 0.9rem; }
.meta {
  font: 0.875rem/1.45 var(--sans);
  color: var(--muted);
  margin: 0 0 0.75rem;
}
.stale { color: var(--alert-ink); }

/* Masthead: date on the left, current conditions on the right */
.masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem 2.5rem;
  padding-bottom: 1.5rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--rule);
}
.date { margin: 0; font-weight: 600; }
.weekday {
  display: block;
  font-size: clamp(2.8rem, 7vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: -0.015em;
}
.monthday {
  display: block;
  margin-top: 0.45rem;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  line-height: 1.2;
  font-weight: 400;
  color: var(--muted);
}

/* Weather: alert (if any), then the Today card as the lead, then the forecast discussion teaser */
.weather { margin-bottom: 3.5rem; }
.glance {
  display: grid;
  gap: 1.5rem 3rem;
}
@media (min-width: 56rem) {
  .glance { grid-template-columns: 1.15fr 1fr; align-items: start; }
}
#today:empty { display: none; }
.headline {
  font-size: clamp(1.2rem, 2.4vw, 1.4rem);
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 0.25rem;
  text-wrap: balance;
}
.alert {
  background: var(--alert-bg);
  color: var(--alert-ink);
  font: 600 0.95rem/1.5 var(--sans);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
}
.no-alert { font: 0.9rem/1.5 var(--sans); color: var(--muted); margin: 0.75rem 0 0; }
.now {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: end;
  gap: 0.75rem 1.5rem;
}
.now[hidden] { display: none; }
.art {
  margin: 0;
  font: 0.93rem/1.15 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted);
}
.a-sun { color: var(--art-sun); }
.a-moon { color: var(--art-moon); }
.a-cloud { color: var(--art-cloud); }
.a-rain, .a-star { color: var(--art-rain); }
.a-storm { color: var(--art-storm); }
.a-downpour { color: var(--art-downpour); font-weight: 700; }
.a-snow { color: var(--art-snow); }
.a-bolt { color: var(--art-sun); font-weight: 700; }
.a-fog { color: var(--art-fog); }
/* Temperature and sky mirror the weekday and date sizes so both sides line up */
.now-main { margin: 0; }
.now-temp {
  display: block;
  font-size: clamp(2.8rem, 7vw, 4.25rem);
  line-height: 0.95;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
}
.now-desc {
  display: block;
  margin: 0.45rem 0 0;
  font-size: clamp(1.25rem, 2.6vw, 1.6rem);
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
}
.now .meta { margin: 0; }
.now-details { white-space: nowrap; }
.now-error { grid-column: 1 / -1; }
@media (max-width: 46rem) {
  .now { grid-template-columns: auto auto; gap: 0.75rem 1.25rem; }
  .now-details { grid-column: 1 / -1; white-space: normal; }
}
@media (max-width: 30rem) {
  .art { font-size: 0.8rem; }
}
.today {
  background: var(--today-bg);
  border-radius: 8px;
  padding: 1.25rem 1.5rem 0.5rem;
  font-size: 1.15rem;
}
.today h3 { margin: 0 0 0.5rem; font-size: 1.35rem; color: var(--sky); }

/* Section headings */
.section-title {
  font-size: 1.6rem;
  line-height: 1.2;
  font-weight: 600;
  margin: 0 0 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}

/* News */
.news { margin-bottom: 3.5rem; }
.news-grid {
  display: grid;
  gap: 2rem 3rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
}
.source-name {
  font: 600 1rem/1.3 var(--sans);
  margin: 0 0 1rem;
  color: var(--muted);
}
.story {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
/* Every story reserves this tile, with or without a photo, so headlines share one column. */
.thumb {
  aspect-ratio: 3 / 2;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--today-bg);
  overflow: hidden;
}
.thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story h4 {
  font-size: 1.08rem;
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 0.35rem;
}
.story h4 a { color: var(--ink); text-decoration: none; }
.story h4 a:hover { text-decoration: underline; }
.story p { font-size: 0.97rem; line-height: 1.5; margin: 0 0 0.3rem; }
.story .meta { margin: 0; }
@media (max-width: 30rem) {
  .story { grid-template-columns: 6rem 1fr; gap: 0.8rem; }
}

/* Astronomy Picture of the Day */
.apod-card, .sky { display: grid; gap: 1.5rem 3rem; align-items: start; }
@media (min-width: 56rem) {
  .apod-card, .sky { grid-template-columns: 1.3fr 1fr; }
}
.sky { margin-top: 2.5rem; }
.apod-image {
  display: block;
  width: 100%;
  max-height: 36rem;
  object-fit: contain;
  border-radius: 8px;
  background: var(--today-bg);
}
.apod-title { font-size: 1.35rem; line-height: 1.25; font-weight: 600; margin: 0 0 0.3rem; }
.apod-title a { color: var(--ink); text-decoration: none; }
.apod-title a:hover { text-decoration: underline; }
.apod-card p { font-size: 0.97rem; line-height: 1.55; }
.apod-card p.meta { font-size: 0.875rem; }

/* Next launch and moon, under the picture */
.story .countdown { margin: 0.5rem 0 0.15rem; font-size: 1.35rem; line-height: 1.2; font-weight: 600; color: var(--sky); }
.launch-later { margin: 0.25rem 0 0.9rem; padding: 0; list-style: none; font: 0.9rem/1.5 var(--sans); color: var(--muted); }
.launch-later li { margin-bottom: 0.2rem; }
.launch-later strong { color: var(--ink); font-weight: 600; }
.moon-card { display: flex; gap: 1.5rem; align-items: flex-start; }
.moon-card .art { flex: none; }
.moon-phase { margin: 0 0 0.2rem; font-size: 1.35rem; line-height: 1.2; font-weight: 600; }
.moon-card p.meta { margin: 0 0 0.35rem; }
@media (max-width: 30rem) {
  .moon-card { gap: 1rem; }
}

/* Comics: each at its natural size, shrunk to fit, so a small xkcd stays small and a wide strip fills the row */
.apod { margin-bottom: 3.5rem; }
.comic { margin-bottom: 2.5rem; }
.comic-body { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-start; }
.comic-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  background: #fff;
}
.comic-text { flex: 1 1 14rem; max-width: 32rem; }
.comic-title { margin: 0 0 0.3rem; font-size: 1.2rem; line-height: 1.25; font-weight: 600; }
.comic-title a { color: var(--ink); text-decoration: none; }
.comic-title a:hover { text-decoration: underline; }
.comic-text p { font-size: 0.97rem; line-height: 1.5; margin: 0 0 0.5rem; }
.comic-text p.meta { font-size: 0.875rem; }

.open-discussion {
  margin-top: 1rem;
  font: 600 0.95rem/1.4 var(--sans);
  color: var(--sky);
  background: none;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}
.open-discussion:hover { background: var(--today-bg); }
.open-discussion:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }

/* Forecast discussion dialog */
.discussion {
  width: min(44rem, calc(100vw - 2rem));
  max-height: min(85vh, 60rem);
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(10, 20, 30, 0.35);
}
.discussion[open] { display: flex; flex-direction: column; }
.discussion::backdrop { background: rgba(15, 25, 35, 0.55); }
body:has(.discussion[open]) { overflow: hidden; }
.discussion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.discussion-head h2 { margin: 0; font-size: 1.35rem; font-weight: 600; }
.close-discussion {
  font: 600 0.9rem/1 var(--sans);
  color: var(--ink);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
}
.close-discussion:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.discussion-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem 1.5rem 1.5rem;
}
.discussion-body h3 { font-size: 1.2rem; font-weight: 600; margin: 2rem 0 0.4rem; }
@media (max-width: 30rem) {
  .discussion { width: 100vw; max-width: none; max-height: 92vh; margin: auto 0 0; border-radius: 12px 12px 0 0; }
  .discussion-head, .discussion-body { padding-left: 1.1rem; padding-right: 1.1rem; }
}
.bottom-line {
  margin-top: 2rem;
  padding-left: 1rem;
  border-left: 3px solid var(--sky);
  font-size: 1.15rem;
}
.source-note {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font: 0.85rem/1.5 var(--sans);
  color: var(--muted);
}
