:root {
  color-scheme: light;
  --bg: var(--color-base-200, #f5f7f8);
  --panel: var(--color-base-100, #ffffff);
  --ink: var(--color-base-content, #1f2933);
  --muted: color-mix(in oklab, var(--ink) 62%, transparent);
  --line: var(--color-base-300, #d8dee6);
  --accent: var(--color-primary, #0f766e);
  --accent-content: var(--color-primary-content, #ffffff);
  --card: color-mix(in oklab, var(--panel) 94%, var(--line));
  --good-soft: color-mix(in oklab, var(--color-success, #137333) 14%, var(--panel));
  --warn-soft: color-mix(in oklab, var(--color-warning, #a15c00) 18%, var(--panel));
  --bad-soft: color-mix(in oklab, var(--color-error, #b42318) 14%, var(--panel));
  --highlight: color-mix(in oklab, var(--accent) 10%, var(--panel));
  --highlight-line: color-mix(in oklab, var(--accent) 34%, var(--line));
  --map-bg: var(--line);
  --warn: var(--color-warning, #a15c00);
  --bad: var(--color-error, #b42318);
  --good: var(--color-success, #137333);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #172033;
    --ink: #e5edf6;
    --muted: #9ba8ba;
    --line: #334155;
    --accent: #2dd4bf;
    --accent-soft: #123f3d;
    --card: #111827;
    --pill: #233044;
    --good-soft: #12351f;
    --warn-soft: #3d2b0a;
    --bad-soft: #3f1d1a;
    --highlight: #123331;
    --highlight-line: #1f6f67;
    --map-bg: #1f2937;
    --warn: #fbbf24;
    --bad: #f87171;
    --good: #4ade80;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 20px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

h3 {
  font-size: 15px;
}

.fa-solid {
  width: 1em;
  text-align: center;
}

.subtle,
.label-text {
  color: var(--muted);
}

.subtle {
  font-size: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.form-field {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.form-field input,
.form-field select {
  width: 126px;
}

.toolbar .btn {
  align-self: end;
}

section {
  margin-top: 16px;
}

.accordion-section {
  margin-top: 16px;
}

.panel {
  border-radius: 8px;
  padding: 16px;
}

.accordion-section > summary {
  cursor: pointer;
  list-style: none;
}

.accordion-section > summary::-webkit-details-marker {
  display: none;
}

.accordion-section > summary h2 {
  margin-bottom: 0;
}

.accordion-section[open] > summary {
  margin-bottom: 12px;
}

.advisory-panel .toolbar {
  justify-content: flex-start;
  margin-bottom: 12px;
}

.source-status-list {
  margin-top: 12px;
}

.source-status-list:empty {
  display: none;
}

.source-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  line-height: 1.3;
  padding-inline-end: 3.5rem;
}

.source-summary-name,
.source-summary-meta {
  min-width: 0;
}

.source-summary-name {
  font-weight: 700;
}

.source-summary-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.update-toast {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  border-radius: 8px;
  padding: 10px 12px;
}

.update-toast[hidden] {
  display: none;
}

.update-toast button {
  min-height: 34px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a {
  color: var(--accent);
  font-weight: 700;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 112px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 14px;
  background: var(--card);
}

.metric.comfort-good {
  border-left-color: var(--good);
  background: var(--good-soft);
}

.metric.comfort-caution {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.metric.comfort-poor {
  border-left-color: var(--bad);
  background: var(--bad-soft);
}

.metric.comfort-good strong {
  color: var(--good);
}

.metric.comfort-caution strong {
  color: var(--warn);
}

.metric.comfort-poor strong {
  color: var(--bad);
}

.metric span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.metric small {
  display: block;
  color: var(--muted);
  margin-top: 10px;
}

.forecast-grid,
.agri-grid,
.family-grid,
.sports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.insight-panel,
.source-comparison {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--card);
}

.insight-panel:empty,
.source-comparison:empty {
  display: none;
}

.insight-panel dl {
  display: grid;
  grid-template-columns: minmax(130px, 180px) 1fr;
  gap: 7px 12px;
  margin: 10px 0 0;
  font-size: 13px;
}

.day,
.agri-card,
.family-card,
.sports-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--card);
}

.day {
  background: rgba(var(--confidence-color, 15, 118, 110), .12);
  border-left: 5px solid rgba(var(--confidence-color, 15, 118, 110), .62);
}

.day time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.family-card h3 + .reasons,
.family-card h3 + dl {
  margin-top: 10px;
}

.family-card .reasons + h3,
.family-card dl + h3 {
  margin-top: 16px;
}

.day strong {
  display: block;
  font-size: 23px;
  margin-top: 8px;
}

.score {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
  margin-top: 10px;
}

.reasons {
  list-style: disc;
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.reasons li + li {
  margin-top: 4px;
}

.card-note {
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.hourly-chart-wrap {
  position: relative;
  height: 360px;
}

.window-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.window-card {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--card);
  font-size: 13px;
}

.window-card.good {
  border-left-color: var(--good);
}

.window-card.caution {
  border-left-color: var(--warn);
}

.window-card.poor {
  border-left-color: var(--bad);
}

.window-card strong {
  display: block;
  margin-bottom: 4px;
}

.window-card span {
  color: var(--muted);
}

.domain-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.domain-tabs .fa-solid {
  margin-right: 6px;
}

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

.map-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.map-head h2 {
  margin-bottom: 0;
}

.map-frame {
  width: 100%;
  height: min(62vh, 560px);
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--map-bg);
}

.day dl,
.agri-card dl,
.family-card dl,
.providers dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  margin: 10px 0 0;
  font-size: 13px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.providers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.provider {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--card);
}

.provider .error {
  color: var(--bad);
  font-weight: 700;
  margin-top: 8px;
}

.provider .error.alert {
  color: inherit;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

details + details {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 800;
}

pre {
  margin: 0;
  padding: 14px;
  max-height: 420px;
  overflow: auto;
  border-top: 1px solid var(--line);
  background: #101923;
  color: #d9e2ec;
  font-size: 12px;
  line-height: 1.5;
}

.note {
  color: var(--warn);
  font-size: 13px;
  margin-top: 10px;
}

.note.alert {
  color: inherit;
}

@media (max-width: 760px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  header {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: stretch;
  }

  .form-field,
  .form-field input,
  .form-field select,
  .toolbar .btn {
    width: 100%;
  }

  .update-toast {
    align-items: stretch;
    flex-direction: column;
  }

  .update-toast button {
    width: 100%;
  }

  .today-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-summary {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .source-summary-meta {
    grid-column: 2;
    text-align: left;
  }

  .insight-panel dl {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .today-grid {
    grid-template-columns: 1fr;
  }
}
