[data-palette="default"] {
  --palette-first: #1f7a4d;
  --palette-second: #e8f5ee;
  --palette-third: #fff;
}
:root[data-app-theme="forest-soil"],
[data-palette="forest-soil"] {
  --palette-first: #173b30;
  --palette-second: #ab4d30;
  --palette-third: #f1dec3;
}
:root[data-app-theme="slate-walnut"],
[data-palette="slate-walnut"] {
  --palette-first: #385664;
  --palette-second: #c7c7c0;
  --palette-third: #633e30;
}
:root[data-app-theme="dew-garden"],
[data-palette="dew-garden"] {
  --palette-first: #dac9b1;
  --palette-second: #747f35;
  --palette-third: #a7b58f;
  --palette-fourth: #2a4431;
  --palette-fifth: #7e6f60;
}
:root[data-app-theme="slate-night"],
[data-palette="slate-night"] {
  --palette-first: #385664;
  --palette-second: #c7c7c0;
  --palette-third: #633e30;
}
:root[data-app-theme="olive-sand"],
[data-palette="olive-sand"] {
  --palette-first: #dab38b;
  --palette-second: #54552b;
  --palette-third: #252626;
}

:root[data-app-theme="forest-soil"] {
  --bg: #f5e9d8;
  --card: #fff8ee;
  --text: var(--palette-first);
  --muted: #615546;
  --green: var(--palette-first);
  --green2: #f0e1cb;
  --border: #d5bc9c;
  --theme-wash: var(--palette-third);
  --theme-accent: var(--palette-second);
  --theme-current: #f7e5d3;
}
:root[data-app-theme="slate-walnut"] {
  --bg: #e7e9e7;
  --card: #f8f7f3;
  --text: #233640;
  --muted: #52606a;
  --green: var(--palette-first);
  --green2: #e1eaed;
  --border: #bfc8cb;
  --theme-wash: var(--palette-second);
  --theme-accent: var(--palette-third);
  --theme-current: #eef0ee;
}
:root[data-app-theme="dew-garden"] {
  --bg: #f3eddf;
  --card: #f9f5e9;
  --text: #203425;
  --muted: #6a5c50;
  --green: var(--palette-fourth);
  --green2: #e3ead2;
  --border: #c6c3ae;
  --theme-wash: var(--palette-first);
  --theme-accent: var(--palette-fourth);
  --theme-current: #e0e8d0;
  --theme-chart: var(--palette-second);
}
:root[data-app-theme="slate-night"] {
  --bg: #172a33;
  --card: #263f4b;
  --text: #f1f3f2;
  --muted: #c7d1d3;
  --green: #dbe5e7;
  --green2: #304b57;
  --border: #697f87;
  --theme-wash: var(--palette-first);
  --theme-accent: var(--text);
  --theme-current: #365765;
  --theme-chart: #e3ebec;
  --theme-action: var(--palette-third);
}
:root[data-app-theme="olive-sand"] {
  --bg: #f3e6d2;
  --card: #fff5e7;
  --text: var(--palette-third);
  --muted: #685743;
  --green: var(--palette-second);
  --green2: #f0dfc5;
  --border: #d4b895;
  --theme-wash: var(--palette-first);
  --theme-accent: var(--palette-second);
  --theme-current: #f4e4cc;
  --theme-chart: var(--palette-second);
}
:root[data-app-theme] {
  --ink: var(--text);
  --surface: var(--card);
  --theme-border: var(--border);
  --shadow: 0 8px 24px color-mix(in srgb, var(--text) 10%, transparent);
}
:root[data-app-theme] body {
  background: radial-gradient(ellipse at 88% 0, var(--theme-wash), transparent 48rem), var(--bg);
}
:root[data-app-theme] .topbar,
:root[data-app-theme] .bottom-nav {
  background: var(--bg);
  border-color: var(--border);
}
:root[data-app-theme] .topbar #topLocationCard,
:root[data-app-theme] #infoDialog:has(.settings-form) #closeDialog {
  background: var(--green2);
  border-color: var(--border);
  color: var(--green);
}
:root[data-app-theme] .topbar :is(#settingsBtn, #helpBtn, #topLocationName, #topLocationCoords, .top-location-icon, .top-location-caret) {
  color: var(--green);
}
:root[data-app-theme] :is(.section-title, .settings-head, .settings-section:not(.membership-section) h3) {
  color: var(--text);
}
:root[data-app-theme] :is(#agriModeBar, #forecastGrid .forecast-card, #forecastChart, #todayInGarden, #plantVpdPanel, #plant72Outlook, .garden-form-card, .settings-section:not(.membership-section)) {
  background: var(--card);
  border-color: var(--border);
}
:root[data-app-theme] #currentCard:not(.current-night) {
  --text: var(--ink);
  --muted: inherit;
  --border: var(--theme-border);
  --current-needle: var(--theme-accent);
  background: linear-gradient(155deg, var(--theme-current), var(--card) 65%);
  color: var(--ink);
  border-color: var(--border);
}
:root[data-app-theme] #currentCard:not(.current-night) .current-temp {
  color: var(--theme-accent);
}
:root[data-app-theme] #agriModeBar .view-tab.active {
  background: var(--theme-action, var(--green));
  border-color: var(--theme-action, var(--green));
  color: white;
}
:root[data-app-theme] #agriModeBar .view-tab:not(.active) {
  background: var(--green2);
  color: var(--green);
}
:root[data-app-theme] #infoDialog:has(.settings-form) {
  background: var(--bg);
  color: var(--text);
}
:root[data-app-theme] .settings-save-bar {
  background: var(--bg);
}
:root[data-app-theme] .settings-save {
  background: var(--theme-action, var(--green));
  color: white;
}

/* The temperature series follows the new themes. Precipitation and alert colors retain their meaning. */
:root:is([data-app-theme="dew-garden"], [data-app-theme="slate-night"], [data-app-theme="olive-sand"]) :is(.fc-temp-line, .fc-temp-dot) {
  stroke: var(--theme-chart);
}
:root:is([data-app-theme="dew-garden"], [data-app-theme="slate-night"], [data-app-theme="olive-sand"]) .legend-swatch.temp-line {
  background: var(--theme-chart);
}
:root[data-app-theme="slate-night"] #homeBrand .terrasky-wordmark {
  background-color: #eef0ea;
  border: 1px solid var(--palette-second);
  border-radius: 12px;
  padding: 4px;
}
:root[data-app-theme="slate-night"] #currentCard.current-night {
  --text: var(--ink);
  --muted: inherit;
  --border: var(--theme-border);
  --current-needle: var(--theme-chart);
  background: linear-gradient(155deg, var(--theme-current), var(--card) 65%);
  color: var(--ink);
  border-color: var(--border);
}
:root[data-app-theme="slate-night"] #currentCard .current-metrics .metric-card {
  background: var(--card);
  border-color: var(--border);
  color: var(--ink);
}
:root[data-app-theme="slate-night"] :is(.settings-grid label, .settings-switch-row, .settings-form .settings-weather-push-toggle) {
  color: var(--text);
}
:root[data-app-theme="slate-night"] :is(.settings-grid select, .settings-grid input[type="number"], .settings-grid input[type="time"], .settings-switch-row, .forecast-layer-toggle, #forecastChartToggle, .forecast-zoom-dialog) {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
:root[data-app-theme="slate-night"] .forecast-svg :is(.fc-axis, .fc-x-day, .fc-x-hour) {
  fill: var(--muted);
}
:root[data-app-theme="slate-night"] :is(.forecast-card .card-head, .forecast-card h4, .forecast-card .temp, .forecast-card .weather-line) {
  color: var(--text);
}
:root[data-app-theme="slate-night"] .forecast-card .forecast-card-art {
  opacity: .22;
}
:root[data-app-theme="slate-night"] .forecast-card.weather-art-card::after {
  background: linear-gradient(90deg, var(--card), transparent);
}

.app-theme-settings {
  margin: 0;
  min-inline-size: 0;
}
.app-theme-settings legend {
  padding-inline: 5px;
  color: var(--text);
  font-weight: 750;
}
.app-theme-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.app-theme-option {
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr);
  align-items: center;
  gap: 4px 8px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.app-theme-option:has(:checked) {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}
.app-theme-option input {
  grid-row: 1 / span 2;
  margin: 0;
  accent-color: var(--green);
}
.app-theme-option input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}
.app-theme-swatches {
  display: flex;
  gap: 3px;
}
.app-theme-swatches i {
  width: 20px;
  min-width: 0;
  height: 10px;
  border: 1px solid #14231b30;
  border-radius: 3px;
}
.app-theme-swatches i:nth-child(1) { background: var(--palette-first); }
.app-theme-swatches i:nth-child(2) { background: var(--palette-second); }
.app-theme-swatches i:nth-child(3) { background: var(--palette-third); }
.app-theme-swatches i:nth-child(4) { background: var(--palette-fourth); }
.app-theme-swatches i:nth-child(5) { background: var(--palette-fifth); }

@media (max-width: 360px) {
  .app-theme-options { grid-template-columns: 1fr; }
}
