html {
  color-scheme: light;
}

.theme-toggle {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: var(--sage);
  color: var(--ink);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--green-2);
  outline-offset: 2px;
}

html[data-theme="dark"] {
  --ink: #e7f0ed;
  --ink-2: #c2d1cc;
  --muted: #9eafa9;
  --cream: #101714;
  --paper: #18211e;
  --line: #34413d;
  --sage: #263a34;
  --green: #72b69f;
  --green-2: #83c5ae;
  --amber: #e2ad63;
  --red: #df8177;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 90% 0, rgba(73, 123, 105, 0.18), transparent 25rem),
    var(--cream);
}

html[data-theme="dark"] .topbar {
  border-bottom-color: rgba(210, 235, 226, 0.11);
  background: rgba(24, 33, 30, 0.9);
}

html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .button.primary {
  background: #cfe8df;
  color: #13211c;
}

html[data-theme="dark"] .filters select,
html[data-theme="dark"] .listing-card,
html[data-theme="dark"] .metric-grid > div,
html[data-theme="dark"] .stacked-form input,
html[data-theme="dark"] .settings-form input,
html[data-theme="dark"] .inline-form input,
html[data-theme="dark"] .review-note textarea {
  background: #1d2925;
  color: var(--ink);
}

html[data-theme="dark"] .listing-card:hover {
  border-color: #537a6d;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .score-ring {
  background: conic-gradient(var(--green) calc(var(--score) * 1%), #36433f 0);
}

html[data-theme="dark"] .score-ring.uncertain {
  background: conic-gradient(var(--amber) calc(var(--score) * 1%), #36433f 0);
}

html[data-theme="dark"] .score-ring.rejected {
  background: conic-gradient(var(--red) calc(var(--score) * 1%), #36433f 0);
}

html[data-theme="dark"] .score-ring::after {
  background: #1d2925;
}

html[data-theme="dark"] .state-badge.uncertain,
html[data-theme="dark"] .check-box {
  background: #493a24;
  color: #efc787;
}

html[data-theme="dark"] .state-badge.rejected,
html[data-theme="dark"] .button.danger,
html[data-theme="dark"] .notice.error,
html[data-theme="dark"] .warning-box {
  background: #4a2d2a;
  color: #f0aaa2;
}

html[data-theme="dark"] .map-panel #map {
  background: #1b2521;
}

html[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(0.68) saturate(0.7) contrast(1.15);
}

html[data-theme="dark"] .map-caption {
  background: rgba(24, 33, 30, 0.96);
}

html[data-theme="dark"] .map-load-status {
  background: rgba(24, 33, 30, 0.96);
}

html[data-theme="dark"] .map-load-status.is-error {
  border-color: #70423d;
  color: #f0aaa2;
}

html[data-theme="dark"] .map-marker {
  border-color: #d9ebe5;
  color: #fff;
}

html[data-theme="dark"] .detail-score,
html[data-theme="dark"] .route-icon,
html[data-theme="dark"] .token-box {
  background: #123c33;
  color: #f5fbf8;
}

html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
  background: #1d2925;
  color: var(--ink);
}

html[data-theme="dark"] .research-grid > div.is-open {
  border-color: #765a35;
  background: #32281d;
}

html[data-theme="dark"] .research-grid > div.is-estimated {
  border-color: #45685c;
  background: #1d2c27;
}

html[data-theme="dark"] .approximate-location-note {
  border-color: #45685c;
  background: #1d302a;
}

html[data-theme="dark"] .research-caution {
  color: #dfb779;
}

html[data-theme="dark"] .crawler-notice {
  border-color: #765a35;
  background: #382b1c;
  color: #efc889;
}

html[data-theme="dark"] .crawler-status-grid > div {
  background: #1d2925;
}

html[data-theme="dark"] .view-tabs a.active,
html[data-theme="dark"] .filter-tabs a.active {
  background: #cfe8df;
  color: #13211c;
}

html[data-theme="dark"] .kind-filter select {
  background: #1d2925;
  color: var(--ink);
}

html[data-theme="dark"] .personal-status {
  background: #4c402b;
  color: #e8c984;
}

html[data-theme="dark"] .personal-status.mutual {
  background: #403349;
  color: #d5b9e2;
}

html[data-theme="dark"] .personal-status.other {
  background: #293e47;
  color: #abd1df;
}

html[data-theme="dark"] .personal-status.new {
  background: var(--sage);
  color: var(--green);
}

html[data-theme="dark"] .personal-status.automatic {
  background: #4a302d;
  color: #f0aaa0;
}

html[data-theme="dark"] .score-summary-column.positive {
  background: #1d302a;
}

html[data-theme="dark"] .score-summary-column.concern {
  background: #352522;
}

html[data-theme="dark"] .score-summary-column.unknown {
  background: #332d20;
}

html[data-theme="dark"] .detail-score-panel {
  background:
    radial-gradient(circle at 85% 25%, rgba(69, 104, 92, 0.45), transparent 20rem),
    linear-gradient(135deg, #102c26, #1b4d41);
}

html[data-theme="dark"] .listing-hero-image,
html[data-theme="dark"] .decision-card .review-note textarea {
  background: #1d2925;
}

@media (prefers-reduced-motion: no-preference) {
  body,
  .topbar,
  .card,
  .stat,
  .listing-card,
  .results-panel,
  .map-panel,
  input,
  select,
  textarea {
    transition:
      color 0.18s ease,
      background-color 0.18s ease,
      border-color 0.18s ease;
  }
}