/* Shared by the station map, profile and public information pages. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--ink); cursor: pointer;
  touch-action: manipulation;
}
.theme-toggle:hover { background: var(--line); }
.theme-toggle:focus-visible { outline: 3px solid #ab720e; outline-offset: 3px; }
.theme-toggle[hidden], .theme-sun { display: none; }
:root[data-theme=dark] .theme-moon { display: none; }
:root[data-theme=dark] .theme-sun { display: block; }

:root[data-theme=dark] {
  color-scheme: dark;
  --ink: #e2eee8; --muted: #a1b6ac; --green: #83d6b3;
  --line: #354b42; --paper: #111e19;
  --accent: #83d6b3; --bg: #111e19; --soft: #233a2e; --amber: #f3cd83;
  --surface: #1a2b23; --raised: #243b30;
  background: #111e19;
}
:root[data-theme=dark] body { background: var(--bg); color: var(--ink); }
:root[data-theme=dark] :is(.topbar, .explorer, .leaderboard-card, .station-row, .favorite-open, .my-photo, dialog, .profile-card, .profile-page .profile-section, .profile-page .profile-identity, .document, .skip) {
  background: var(--surface); color: var(--ink);
}
:root[data-theme=dark] :is(input, select, .filters input, .filters select, .button.secondary, .map-search, .leaflet-bar a, .leaflet-control-attribution) {
  background: var(--surface); color: var(--ink); border-color: var(--line);
}
:root[data-theme=dark] input::placeholder { color: var(--muted); opacity: 1; }
:root[data-theme=dark] .button:not(.secondary):not(.map-search) { background: #267a59; color: #fff; }
:root[data-theme=dark] .button:not(.secondary):not(.map-search):hover { background: #2d8c67; }
:root[data-theme=dark] :is(.button.secondary:hover, .map-search:hover, .station-row:hover, .favorite-open:hover, .close-button:hover, .leaderboard-periods button:hover, .photo-file-status:hover, .photo-file-status:focus-visible) { background: var(--raised); }
:root[data-theme=dark] :is(.stat, .profile-avatar, .private-label, .help-step span, .leaderboard-icon, .password-session-note, .photo-preview, .photo-reward-info, .photo-price, .photo-file-available, .company, .note, caption, thead th, .form-example) { background: var(--raised); }
:root[data-theme=dark] :is(.station-tabs, .leaderboard-periods) { background: var(--bg); }
:root[data-theme=dark] :is(.station-tabs button, .leaderboard-periods button) { color: var(--muted); }
:root[data-theme=dark] :is(.station-tabs button[aria-selected=true], .leaderboard-periods button[aria-pressed=true], .map-actions .button[aria-pressed=true], .station-actions .button[aria-pressed=true]) { background: var(--raised); color: var(--green); border-color: var(--line); }
:root[data-theme=dark] :is(.mobile-card, .octanes) { background: linear-gradient(135deg, #223d2e, #1a3035); border-color: var(--line); }
:root[data-theme=dark] :is(.mobile-card p:not(.eyebrow), .app-platform, .octanes-heading .eyebrow, .octanes .octanes-note) { color: var(--muted); }
:root[data-theme=dark] .octanes .stat { background: var(--surface); border-color: var(--line); }
:root[data-theme=dark] .octanes .stat strong { color: #91d8e7; }
:root[data-theme=dark] .notice { background: #283d29; }
:root[data-theme=dark] :is(.notice.error, .photo-status.rejected) { background: #482b26; color: #ffc1b1; }
:root[data-theme=dark] :is(.warning, .age-aging, .history-legend .station, .history-mark.station) { color: #f3cd83; }
:root[data-theme=dark] .age-old { color: #ffb4a6; }
:root[data-theme=dark] :is(.age-fresh, .history-legend .drivers, .history-mark.drivers) { color: var(--green); }
:root[data-theme=dark] .history-chart text { fill: var(--muted); }
:root[data-theme=dark] .history-grid { stroke: var(--line); }
:root[data-theme=dark] .leaderboard-row { border-color: var(--line); }
:root[data-theme=dark] dialog::backdrop { background: #0009; }
/* Keep markers and fuel colors intact; only dim the map tile layer. */
:root[data-theme=dark] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.8) saturate(.7); }
:root[data-theme=dark] :is(#map, #navigation-map) { background: #182b24; }
:root[data-theme=dark] .leaflet-control-attribution a { color: var(--green); }

@media (max-width: 600px) {
  .topbar nav { gap: 8px; }
  .topbar .button.small { padding-inline: 10px; }
}
/* Keep the toggle at the top right even when legal navigation wraps below. */
@media (max-width: 700px) {
  .topbar:has(.topnav) { position: relative; }
  .topbar .topnav { padding-right: 0; flex-wrap: wrap; }
  .topbar .topnav .theme-toggle { position: absolute; top: 20px; right: 0; }
}
@media print { .theme-toggle { display: none; } }
:root[data-theme=dark] .price-action-summary { background: var(--raised); }
:root[data-theme=dark] .trust-confirmed { color: var(--green); }
:root[data-theme=dark] .trust-pending { color: #9cc5ff; }
:root[data-theme=dark] :is(.trust-station, .trust-warning) { color: #f3cd83; }
@media (max-width: 360px) {
  .topbar .brand { font-size: 19px; }
  .topbar .brand-mark { width: 32px; height: 32px; margin-right: 5px; }
  .topbar .button.small { padding-inline: 8px; }
}
