/* Loaded after the map and organizer styles. Tile imagery keeps its original colors. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 9px 11px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}
.theme-toggle:hover { background: var(--orange-light); }
.theme-toggle [data-theme-icon] { display: inline-flex; width: 18px; height: 18px; }
.theme-toggle svg { display: block; width: 100%; height: 100%; }

:root[data-theme="light"] { color-scheme: light; --orange: #c94c22; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --cream: #171b1a;
  --paper: #202624;
  --ink: #f6f2e9;
  --muted: #b7c1b9;
  --orange: #c94c22;
  --orange-dark: #ffb18a;
  --orange-light: #3b2b23;
  --teal: #68d5bd;
  --line: #3b4540;
  --shadow: 0 9px 35px #00000066;
}

[data-theme="dark"] body { background: var(--cream); }
[data-theme="dark"] .event-label,
[data-theme="dark"] .statusbar,
[data-theme="dark"] .panel-footer,
[data-theme="dark"] .panel-footer .text-button { color: var(--muted); }
[data-theme="dark"] .panel-footer > span { color: #a1b99f; }
[data-theme="dark"] .panel-top h1 span { background: #3b352b; color: #f0d6b1; }
[data-theme="dark"] .button.primary { color: #ffffff; border-color: #f27c4a; box-shadow: none; }
[data-theme="dark"] .button.primary:hover { background: #b33d16; border-color: #ffaf88; }
[data-theme="dark"] .button.secondary { background: #29322d; border-color: #56625a; }
[data-theme="dark"] .button.secondary:hover,
[data-theme="dark"] .icon-button:hover,
[data-theme="dark"] .view-toggle { background: #354037; }
[data-theme="dark"] .filter-chip { background: #29322d; border-color: #56625a; }
[data-theme="dark"] .filter-chip:has(input:checked) { background: #493024; color: #ffd2b5; border-color: #ed9360; }
[data-theme="dark"] .choice,
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: #252d29; border-color: #56625a; color: var(--ink); }
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #aab5ac; opacity: 1; }
[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"] { accent-color: #ed9360; }
[data-theme="dark"] .choice:has(input:checked) { background: #493024; border-color: #ed9360; color: #ffdbbf; }
[data-theme="dark"] .allergen-choice { background: #29312c; border-color: #48534a; color: var(--ink); }
[data-theme="dark"] .allergen-choice:has(input:checked) { background: #513323; border-color: #c47745; color: #ffe8d3; }
[data-theme="dark"] .field-help { color: var(--muted) !important; }
[data-theme="dark"] .tiny-badge { background: #323c35; color: #d5dfd5; }
[data-theme="dark"] .tiny-badge.teal { background: #123d34; color: #8ee6ce; }
[data-theme="dark"] .tiny-badge.open { background: #2b3e20; color: #c5e2a9; }
[data-theme="dark"] .tiny-badge.out { background: #343936; color: #c4cdc6; }
[data-theme="dark"] .allergen-badge { background: #3b3225; color: #f0d7a9; }
[data-theme="dark"] .map-pane,
[data-theme="dark"] .map-pane #map,
[data-theme="dark"] .pin-map-wrap #pin-map { background: #252d2b; }
[data-theme="dark"] .empty-map { background: #202624f5; border-color: #56625a; }
[data-theme="dark"] .locate-button { background: var(--paper); border-color: #56625a; }
[data-theme="dark"] .map-legend { background: #202624ed; border-color: #56625a; color: #cad4cb; }
[data-theme="dark"] .map-notice.error { color: #ffc6ac; }
[data-theme="dark"] .expired-banner { background: #493024 !important; color: #ffd2b5 !important; }
[data-theme="dark"] .detail-panel::before { background: #738078; }
[data-theme="dark"] dialog { border-color: #56625a; box-shadow: 0 20px 80px #00000088; }
[data-theme="dark"] dialog::backdrop { background: #050a09ad; }
[data-theme="dark"] .form-error { background: #422a23; border-color: #8f553c; color: #ffd2bf; }
[data-theme="dark"] .danger { color: #ffa994; }
[data-theme="dark"] .danger-button { color: #ffffff; }
[data-theme="dark"] .danger-button:hover { background: #8f2715; }
[data-theme="dark"] .toast { background: #2e3b33; border: 1px solid #738078; color: #f5f7f3; }
[data-theme="dark"] .lookup-status { color: #9edcc8 !important; }
[data-theme="dark"] .address-candidate { background: #29322d; border-color: #56625a; color: var(--ink); }
[data-theme="dark"] .address-candidate:hover { background: var(--orange-light); border-color: #ed9360; }
[data-theme="dark"] .pin-preview { background: var(--paper); border-color: #56625a; }
[data-theme="dark"] .basemap-switch { background: var(--paper); border-color: #56625a; }
[data-theme="dark"] .basemap-switch button { color: #c4d0c4; }
[data-theme="dark"] .basemap-switch button[aria-pressed="true"] { background: #3d594c; color: #f4fff6; }
[data-theme="dark"] .hidden-badge { background: #473921; color: #f4d494; }

[data-theme="dark"] .leaflet-bar { border-color: #56625a !important; }
[data-theme="dark"] .leaflet-bar a:hover { background: #354037 !important; }
[data-theme="dark"] .leaflet-control-attribution { background: #202624ed !important; color: #c7d2c9; }
[data-theme="dark"] .leaflet-control-attribution a { color: #ffb18a; }
[data-theme="dark"] .leaflet-tooltip,
[data-theme="dark"] .leaflet-popup-content-wrapper,
[data-theme="dark"] .leaflet-popup-tip { background: var(--paper); color: var(--ink); border-color: #56625a; }
[data-theme="dark"] .leaflet-tooltip-top::before { border-top-color: #56625a; }
[data-theme="dark"] .leaflet-tooltip-bottom::before { border-bottom-color: #56625a; }
[data-theme="dark"] .leaflet-tooltip-left::before { border-left-color: #56625a; }
[data-theme="dark"] .leaflet-tooltip-right::before { border-right-color: #56625a; }
[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

[data-theme="dark"] button:focus-visible,
[data-theme="dark"] a:focus-visible,
[data-theme="dark"] summary:focus-visible,
[data-theme="dark"] input:focus-visible,
[data-theme="dark"] select:focus-visible,
[data-theme="dark"] textarea:focus-visible { outline-color: #82dbe8; }

@media (max-width: 700px) {
  .theme-toggle { width: 36px; height: 36px; min-height: 36px; padding: 8px; border-radius: 9px; }
  .theme-toggle-label { display: none; }
  .topbar > .theme-toggle { margin-left: auto; }
  .topbar > .theme-toggle + .button { margin-left: 0; }
}

/* The same friendly Halloween palette after sunset. */
:root[data-theme="light"]{--orange:#c94c22;--cream:#fff2df;--paper:#fffaf0;--ink:#432c42;--muted:#796779;--orange-dark:#9b391f;--orange-light:#ffe6c9;--line:#e2d1bf}
:root[data-theme="dark"]{--cream:#241e2f;--paper:#30273b;--ink:#fff1de;--muted:#cabbd0;--orange:#c94c22;--orange-dark:#ffb28b;--orange-light:#50332e;--teal:#82d9c1;--line:#58475f;--shadow:0 6px 0 #100b171f,0 12px 28px #100b1766}
.theme-toggle{border-radius:13px;border-width:2px;box-shadow:0 2px 0 #54364b0b}
[data-theme="dark"] .button.secondary,[data-theme="dark"] .filter-chip,[data-theme="dark"] .choice{background:#3a3046;border-color:#75607a}
[data-theme="dark"] .button.secondary:hover,[data-theme="dark"] .icon-button:hover,[data-theme="dark"] .view-toggle{background:#493b55}
[data-theme="dark"] .filter-chip:has(input:checked),[data-theme="dark"] .choice:has(input:checked){background:#5c382e;border-color:#dc9970;color:#ffdbba}
[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]),[data-theme="dark"] textarea,[data-theme="dark"] select{background:#292232;border-color:#75607a}
[data-theme="dark"] .panel-top h1 span{background:#563730;border-color:#8a5541;color:#ffd4ab}
[data-theme="dark"] .home-glyph{background:#4c3231}
[data-theme="dark"] .tiny-badge{background:#46384f;color:#e4d5e9}
[data-theme="dark"] .tiny-badge.teal{background:#23443e;color:#a1e4cd}
[data-theme="dark"] .tiny-badge.open{background:#35412a;color:#d0e5a8}
[data-theme="dark"] .tiny-badge.out{background:#433c49;color:#cfc2d6}
[data-theme="dark"] .empty-map{background:#30273bf7;border-color:#82636e;box-shadow:0 5px 0 #100b173b,0 12px 28px #100b1766}
[data-theme="dark"] .map-legend{background:#30273bf2;border-color:var(--line);color:var(--muted)}
[data-theme="dark"] .map-pane,[data-theme="dark"] .map-pane #map,[data-theme="dark"] .pin-map-wrap #pin-map{background:#2d2835}
[data-theme="dark"] .locate-button,[data-theme="dark"] dialog,[data-theme="dark"] .pin-preview,[data-theme="dark"] .basemap-switch{border-color:var(--line)}
[data-theme="dark"] .pin-preview-heading{background:#49332f}
[data-theme="dark"] .shared-hours{border-color:#8c6652}
[data-theme="dark"] .shared-hours>strong{color:#ffc598}
[data-theme="dark"] .allergen-choice{background:#3c3045;border-color:#66526b}
[data-theme="dark"] .allergen-choice:has(input:checked){background:#5c382e;border-color:#c88860}
[data-theme="dark"] .allergen-badge{background:#4a3730;color:#ffe0bd}
[data-theme="dark"] .address-candidate{background:#3a3046;border-color:#75607a}
[data-theme="dark"] .basemap-switch button{color:var(--muted)}
[data-theme="dark"] .basemap-switch button[aria-pressed="true"]{background:#765381;color:#fff3df}
[data-theme="dark"] .leaflet-bar{border-color:var(--line)!important}
[data-theme="dark"] .leaflet-bar a:hover{background:#493b55!important}
[data-theme="dark"] .leaflet-control-attribution{background:#30273bed!important;color:var(--muted)}
[data-theme="dark"] .toast{background:#4b3558;border-color:#887191;color:#fff4e4}
[data-theme="dark"] .theme-toggle{box-shadow:0 2px 0 #100b1740}
[data-theme="dark"] .hidden-badge{background:#50392d;color:#ffdaa9}

.theme-toggle{align-items:center;justify-content:center;line-height:1}
.theme-toggle [data-theme-icon]{display:grid;place-items:center;flex:0 0 18px;width:18px;height:18px;padding:0;margin:0;line-height:0}
.theme-toggle [data-theme-icon]>svg{display:block;width:18px;height:18px;margin:0}
.theme-toggle [data-theme-label]{line-height:1}
@media(max-width:700px){.topbar>.theme-toggle{display:inline-flex;align-items:center;justify-content:center;padding:0}}
