#settings-dialog { width: min(560px, calc(100% - 32px)); }

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

.theme-choice {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  padding: 0;
  border: 2px solid var(--edge);
  background: var(--paper);
  color: var(--ink);
  font-size: .87rem;
  line-height: 1.1;
}

.theme-choice[aria-pressed="true"] {
  border-color: #6b854d;
  background: var(--lime);
  color: var(--forest);
  box-shadow: 2px 2px 0 #6b854d;
}

.theme-choice img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 20 / 9;
  object-fit: cover;
}

.theme-choice img, #theme-scene { image-rendering: pixelated; }
.theme-choice span { align-self: center; padding: 6px 3px; overflow-wrap: anywhere; }
#theme-scene { object-position: center; }

:root[data-theme]:not([data-theme="greenhouse"]) {
  background: var(--page);
  color: var(--ink);
  --soft-shadow: color-mix(in srgb, var(--edge) 25%, var(--page));
  --tint: color-mix(in srgb, var(--edge) 16%, var(--paper));
  --highlight: color-mix(in srgb, var(--edge) 27%, var(--paper));
  --primary-hover: color-mix(in srgb, var(--forest) 84%, var(--on-forest));
  --secondary: color-mix(in srgb, var(--forest) 92%, var(--on-forest));
  --expense-ink: var(--ink);
  --income-ink: var(--ink);
}

:root[data-theme="pond"] { color-scheme: dark; }

:root[data-theme]:not([data-theme="greenhouse"]) {
  body { background-image: radial-gradient(color-mix(in srgb, var(--edge) 15%, var(--page)) 1px, transparent 1px); }
  :where(a, button, input, select):focus-visible { outline-color: var(--edge); }

  .topbar { background: var(--paper); border-color: var(--edge); box-shadow: 0 3px 0 var(--soft-shadow); }
  .brand, .navigation a, .work-back, .work-header-label, .work-color-choice { color: var(--ink); }
  .brand-mark { color: var(--lime); box-shadow: 3px 3px 0 var(--soft-shadow); }
  .navigation a[aria-current], .switcher button[aria-pressed="true"] {
    border-color: var(--edge);
    background: var(--highlight);
    color: var(--ink);
    box-shadow: 2px 2px 0 var(--soft-shadow);
  }

  .payday, .settings-section, .switcher, .summary-expense, .summary-income, .history-day, .envelope-main {
    border-color: var(--edge);
    background: var(--tint);
    color: var(--ink);
  }
  .breakdown-track { background: var(--tint); }
  .chart-bars { border-color: var(--edge); background: repeating-linear-gradient(to top, var(--tint) 0 1px, transparent 1px 31px); }

  .work-hero, .toast,
  .work-hero h2, .work-active, .work-goal-category-label, .work-goal-details, .work-forgot {
    color: var(--on-forest);
  }
  .garden-window, .toast, .work-goal, .work-session-secondary { border-color: var(--edge); }
  .work-goal, .work-session-secondary, .work-session-controls .button:disabled {
    background: var(--secondary);
    color: var(--on-forest);
  }
  .work-session-secondary:hover:not(:disabled) { background: var(--primary-hover); }
  .work-active.is-running .work-dot { background: var(--lime); }

  progress { border-color: var(--edge); background: var(--secondary); }
  progress::-webkit-progress-bar { background: var(--secondary); }
  progress::-webkit-progress-value { background: repeating-linear-gradient(90deg, var(--lime) 0 8px, var(--edge) 8px 10px); }
  progress::-moz-progress-bar { background: repeating-linear-gradient(90deg, var(--lime) 0 8px, var(--edge) 8px 10px); }

  .button-bright, .work-session-start, .theme-choice[aria-pressed="true"] {
    border-color: var(--edge);
    background: var(--lime);
    color: var(--forest);
  }
  .button-bright:hover, .work-session-start:hover:not(:disabled) { background: color-mix(in srgb, var(--lime) 83%, white); }
  .theme-choice[aria-pressed="true"] { box-shadow: 2px 2px 0 var(--edge); }
  .button-dark { --button-shadow: var(--soft-shadow); border-color: var(--edge); background: var(--forest); color: var(--on-forest); }
  .button-dark:hover:not(:disabled) { background: var(--primary-hover); }
  .button-dark:disabled { border-color: var(--edge); background: var(--tint); color: var(--muted); }

  .icon-button:not(.work-remove), .button-outline, .small-button, .category, .category-chip, .repeat-amount, .amount-keypad button {
    --button-shadow: var(--soft-shadow);
    border-color: var(--edge);
    background: var(--tint);
    color: var(--ink);
    box-shadow: 2px 2px 0 var(--soft-shadow);
  }
  .icon-button:hover:not(.work-remove), .button-outline:hover, .small-button:hover, .category:hover, .category-chip:hover,
  .repeat-amount:hover, .amount-keypad button:hover, .breakdown-button:hover, .breakdown-button[aria-pressed="true"],
  .switcher button:hover, .navigation a:hover, .work-back:hover, .chart-column:hover, .chart-column[aria-pressed="true"] {
    background: var(--highlight);
    color: var(--ink);
  }

  .form-input, .amount-field, .custom-range input { border-color: var(--edge); background: var(--paper); color: var(--ink); }
  .amount-field span, .amount-field input::placeholder { color: var(--muted); }
  dialog { box-shadow: 6px 6px 0 #15201b99, inset 0 0 0 3px var(--tint); }
  dialog::backdrop { background: color-mix(in srgb, var(--forest) 68%, transparent); }

  .work-card-duration { color: var(--forest); }
  .work-card { color: #263a2e; }
  .work-navigation a:not([aria-current]) { color: var(--on-forest); }
  .work-navigation a:hover:not([aria-current]) { background: var(--primary-hover); }
}

@media (max-width: 820px) {
  :root[data-theme]:not([data-theme="greenhouse"]) {
    .navigation { border-color: var(--edge); }
    .navigation a:not([aria-current]) { color: var(--on-forest); }
    .navigation a:hover:not([aria-current]) { background: var(--primary-hover); }
  }
}

@media (max-width: 490px) {
  .theme-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .theme-choice { grid-template: minmax(42px, 1fr) / 36px minmax(0, 1fr); text-align: left; }
  .theme-choice img { height: 100%; aspect-ratio: auto; }
}
