/* color-scheme tells Chrome and dark-mode extensions the page already has a dark theme, so they don't invert it a second time. */
html { color-scheme: light; }

.theme-toggle {
  grid-area: theme;
  margin: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font: 600 13px/1 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Beats each page's `header .wrap { height: 64px }`, which is what let the switch hang over the headline. */
header .wrap.wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "logo nav theme";
  align-items: center;
  column-gap: 12px;
  height: auto;
  min-height: 64px;
  padding-top: 10px;
  padding-bottom: 10px;
}
header .logo { grid-area: logo; }
header nav { grid-area: nav; justify-self: end; display: flex; align-items: center; gap: 18px; }
header nav a { margin-left: 0; }
header .wrap > .btn { grid-area: nav; justify-self: end; }

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e8eef6;
  --muted: #a9b7c8;
  --line: #2c3a4a;
  --bg: #0e141b;
  --brand: #2dd4bf;
  --brand-dark: #5eead4;
  --accent: #fbbf24;
  --card: #17202a;
}

html[data-theme="dark"] .btn:not(.ghost) { background: #0f766e; color: #fff !important; }
html[data-theme="dark"] .btn:not(.ghost):hover { background: #0d9488; }

html[data-theme="dark"] .hero {
  background: linear-gradient(180deg, #13261f 0%, var(--bg) 100%);
}
html[data-theme="dark"] .eyebrow,
html[data-theme="dark"] .step::before,
html[data-theme="dark"] .stage::before {
  background: #134e4a;
  color: #5eead4;
}
html[data-theme="dark"] .redact { background: #3b4b5e; }
html[data-theme="dark"] th { background: #132e2b; color: #5eead4; }
html[data-theme="dark"] .pill { display: inline-block; width: auto; background: #14532d; color: #86efac; }
html[data-theme="dark"] section.band,
html[data-theme="dark"] #how,
html[data-theme="dark"] #pricing {
  background: #121a23 !important;
}
html[data-theme="dark"] a.lead:hover,
html[data-theme="dark"] .map-hit.on { background: #132e2b; }
html[data-theme="dark"] .sample { box-shadow: 0 18px 40px -22px rgba(0, 0, 0, .8); }
html[data-theme="dark"] #map,
html[data-theme="dark"] .ntl-map { background: #1b2633; }
html[data-theme="dark"] .final {
  background: #070b10;
  border: 1px solid var(--line);
  color: #e2e8f0;
}
html[data-theme="dark"] .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.95);
}
html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
  background: var(--card);
  color: var(--ink);
}
html[data-theme="dark"] .leaflet-popup-content a,
html[data-theme="dark"] .leaflet-control-attribution a { color: #5eead4; }
html[data-theme="dark"] .leaflet-bar a {
  background: var(--card);
  color: var(--ink);
  border-bottom-color: var(--line);
}
html[data-theme="dark"] .leaflet-bar a:hover { background: #1e2a36; }
html[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(23, 32, 42, .92);
  color: var(--muted);
}

@media (max-width: 900px) {
  header .wrap.wrap {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "logo nav" "theme theme";
    row-gap: 8px;
  }
  .theme-toggle { justify-self: start; }
}
