:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d1c1b;
  --surface: #11282c;
  --ink: #edf2ea;
  --muted: #a1b8b5;
  --line: #294348;
  --lake: #9cdbc5;
  --lake-soft: #1d3e3b;
  --forest: #b6d9a8;
  --terracotta: #efaf8c;
  --warning: #f3a28e;
  --gold: #e6c58d;
  --on-accent: #102e2e;
  --glass: rgba(13, 28, 27, .9);
  --shadow: 0 22px 64px rgba(0, 0, 0, .3);
}

:root[data-theme="dark"] body { background: var(--paper); color: var(--ink); }
:root[data-theme="dark"] .topbar {
  border-bottom-color: rgba(222, 236, 220, .1);
  background: rgba(9, 24, 29, .86);
}
:root[data-theme="dark"] .wordmark span,
:root[data-theme="dark"] .topbar .primary-navigation__ledger,
:root[data-theme="dark"] .travel-navigation summary { color: var(--muted); }
:root[data-theme="dark"] .travel-navigation summary { border-color: var(--line); background: var(--surface); }
:root[data-theme="dark"] .travel-navigation-menu { border-color: var(--line); background: rgba(25, 37, 38, .98); }
:root[data-theme="dark"] .topbar .travel-navigation-menu a { color: var(--muted); background: #202f30; }
:root[data-theme="dark"] .topbar .travel-navigation-menu a:hover,
:root[data-theme="dark"] .topbar .travel-navigation-menu a:focus-visible { color: #fff; background: #31504a; }
:root[data-theme="dark"] .hero { box-shadow: 0 30px 80px rgba(0, 0, 0, .36); }
:root[data-theme="dark"] .trip-notices { border-color: #66543a; background: #302a20; }
:root[data-theme="dark"] .trip-notices summary,
:root[data-theme="dark"] .trip-notices ul { color: #e4d0a9; }
:root[data-theme="dark"] .flight-arrow,
:root[data-theme="dark"] .day-chevron { border-color: var(--line); color: var(--ink); background: var(--surface); }
:root[data-theme="dark"] .route-section { border-color: var(--line); background: var(--surface); box-shadow: 0 12px 34px rgba(0, 0, 0, .18); }
:root[data-theme="dark"] .day-navigation { background: rgba(9, 24, 29, .92); }
:root[data-theme="dark"] .day-navigation button { border-color: var(--line); background: var(--surface); }
:root[data-theme="dark"] .day-navigation button[aria-current="true"] { color: var(--on-accent); background: var(--lake); border-color: var(--lake); box-shadow: 0 6px 22px rgba(102, 186, 155, .18); }
:root[data-theme="dark"] .day-navigation button[aria-current="true"] span { color: #31574b; }
:root[data-theme="dark"] .schedule-item::before { background: var(--line); }
:root[data-theme="dark"] .schedule-item::after { background: var(--paper); }
:root[data-theme="dark"] .schedule-map-link { border-color: #3b5b5d; color: #b0dfe0; background: #203538; }
:root[data-theme="dark"] .schedule-map-link:hover { background: #294548; }
:root[data-theme="dark"] .schedule-ticket { border-color: #684c3c; background: #30251f; }
:root[data-theme="dark"] .schedule-ticket summary,
:root[data-theme="dark"] .schedule-ticket__body p { color: #edb89e; }
:root[data-theme="dark"] .schedule-ticket.is-purchased { border-color: #3d5b44; background: #202e25; }
:root[data-theme="dark"] .schedule-ticket.is-purchased summary { color: #acd0a9; }
:root[data-theme="dark"] .detail-note { color: #d0b6a8; background: rgba(229, 154, 123, .1); }
:root[data-theme="dark"] .cost-tag { color: #c2cfca; background: #263332; }
:root[data-theme="dark"] .ticket-filters button { border-color: var(--line); background: #1b292a; }
:root[data-theme="dark"] .ticket-filters button.is-active { color: var(--on-accent); border-color: var(--lake); background: var(--lake); }
:root[data-theme="dark"] .ticket-card { border-color: var(--line); background: #192526; }
:root[data-theme="dark"] .ticket-card.is-purchased { background: #1d2b23; }
:root[data-theme="dark"] .ticket-uncertainties { color: #c1ceca; background: #253130; }
:root[data-theme="dark"] .return-deadline { color: #f0c1a5; background: #382820; border-color: #a65e43; }
:root[data-theme="dark"] .return-deadline.is-urgent { color: #ffc1b2; background: #3d2422; border-color: #bd5c50; }
:root[data-theme="dark"] .accordion { border-color: var(--line); background: #192526; }
:root[data-theme="dark"] .accordion ul { color: #c7d2ce; }
:root[data-theme="dark"] .todo-form input { border-color: var(--line); color: var(--ink); background: #192526; }
:root[data-theme="dark"] .todo-item:focus-within { background: #20332f; }
:root[data-theme="dark"] .todo-progress-track,
:root[data-theme="dark"] .packing-progress { background: #2b3a37; }
:root[data-theme="dark"] .todo-import { border-color: #3e6258; color: #b7dfcd; background: #20352f; }
:root[data-theme="dark"] .todo-import:hover { background: #2a453b; }
:root[data-theme="dark"] .todo-import span { color: #c3d7ce; background: rgba(12, 25, 23, .5); }
:root[data-theme="dark"] .packing-item input { border-color: #718984; }
:root[data-theme="dark"] .mobile-dock {
  border-color: rgba(210, 230, 221, .13);
  background: rgba(15, 38, 42, .92);
  box-shadow: 0 12px 42px rgba(0, 0, 0, .38);
}
:root[data-theme="dark"] .mobile-dock a { color: #adbfba; }
:root[data-theme="dark"] .mobile-dock a:hover,
:root[data-theme="dark"] .mobile-dock a.is-active { color: #e8d4ac; background: #2b4544; }
:root[data-theme="dark"] .runtime-notice { border-color: #766044; color: #eed7b1; background: #302a20; }
:root[data-theme="dark"] .loading-error { color: #ffe7df; background: #713e36; }
:root[data-theme="dark"] .page-loader {
  color: var(--ink);
  background:
    radial-gradient(ellipse at 50% 43%, rgba(33, 54, 51, .96) 0%, rgba(24, 42, 41, .78) 31%, transparent 68%),
    radial-gradient(ellipse at 10% 15%, rgba(48, 88, 75, .58), transparent 46%),
    radial-gradient(ellipse at 92% 82%, rgba(82, 65, 46, .45), transparent 43%),
    #09181d;
}
:root[data-theme="dark"] .page-loader__content h2 { color: #e5efeb; }
:root[data-theme="dark"] .page-loader__eyebrow { color: #9ac7b7; }
:root[data-theme="dark"] .page-loader__caption { color: #b2c2bc; }

/* Route diagrams remain readable against the dark canvas. */
:root[data-theme="dark"] .geo-view-tabs button,
:root[data-theme="dark"] .geo-stop-list button { border-color: #344945; color: var(--ink); background: #1d2b29; }
:root[data-theme="dark"] .geo-view-tabs button[aria-pressed="true"] { border-color: var(--lake); color: var(--on-accent); background: var(--lake); }
:root[data-theme="dark"] .geo-stop-list button:hover,
:root[data-theme="dark"] .geo-stop-list button[aria-expanded="true"],
:root[data-theme="dark"] .geo-stop-list button.is-linked { border-color: #527968; background: #263b34; }
:root[data-theme="dark"] .geo-city-plot { border-color: #354641; background: radial-gradient(circle at 50% 50%, #273530, #1b2927); }
:root[data-theme="dark"] .is-geographic .travel-map-scroll { border-color: #364944; background: #202e2c; }
:root[data-theme="dark"] .geo-city-pin__label { color: #e8f0eb; background: rgba(25, 37, 38, .95); }
:root[data-theme="dark"] .geo-city-attribution { color: #c0d0ca; background: rgba(25, 37, 38, .88); }
:root[data-theme="dark"] .day-route-map { border-color: var(--line); background: #172322; }
:root[data-theme="dark"] .geo-stop-list time { color: #c1e5d3; background: #27453a; }
:root[data-theme="dark"] .geo-map-hint,
:root[data-theme="dark"] .geo-city-legend,
:root[data-theme="dark"] .geo-map-scale,
:root[data-theme="dark"] .geo-stop-main small { color: #a8beb5; }

/* Shared expense ledger surfaces and fields. */
:root[data-theme="dark"] .ledger-view,
:root[data-theme="dark"] body[data-active-view="ledger"],
:root[data-theme="dark"] body[data-active-view="ledger"] .topbar { background: var(--paper); }
:root[data-theme="dark"] .ledger-entry-card,
:root[data-theme="dark"] .ledger-list-section,
:root[data-theme="dark"] .ledger-stats-overview,
:root[data-theme="dark"] .ledger-transfer-row,
:root[data-theme="dark"] .ledger-member-stat { border-color: var(--line); background: var(--surface); box-shadow: 0 10px 28px rgba(0, 0, 0, .16); }
:root[data-theme="dark"] .ledger-select,
:root[data-theme="dark"] .ledger-input,
:root[data-theme="dark"] .ledger-dialog,
:root[data-theme="dark"] .ledger-currency-select-button,
:root[data-theme="dark"] .ledger-currency-result,
:root[data-theme="dark"] .ledger-currency-menu,
:root[data-theme="dark"] .ledger-bill-note-form input { border-color: var(--line); color: var(--ink); background: #202e2e; }
:root[data-theme="dark"] .ledger-category-choice,
:root[data-theme="dark"] .ledger-onboarding,
:root[data-theme="dark"] .ledger-currency-dropdown summary,
:root[data-theme="dark"] .ledger-field-amount .ledger-amount-input,
:root[data-theme="dark"] .ledger-converted-input-wrap { border-color: var(--line); color: #c4d3ce; background: #202e2e; }
:root[data-theme="dark"] .ledger-category-choice:has(input:checked),
:root[data-theme="dark"] .ledger-currency-option:hover,
:root[data-theme="dark"] .ledger-currency-option[aria-current="true"] { color: #c2e7dc; background: #29453e; }
:root[data-theme="dark"] .ledger-currency-chip,
:root[data-theme="dark"] .ledger-currency-search { border-color: var(--line); color: #c6d4cf; background: #1b2929; }
:root[data-theme="dark"] .ledger-currency-option { color: var(--ink); }
:root[data-theme="dark"] .ledger-icon-button,
:root[data-theme="dark"] .ledger-confirm-actions button { border-color: var(--line); color: var(--ink); background: #202e2e; }
:root[data-theme="dark"] .ledger-text-button:hover,
:root[data-theme="dark"] .ledger-icon-button:hover { background: #293a38; }
:root[data-theme="dark"] .ledger-tab { color: #9aadaa; }
:root[data-theme="dark"] .ledger-tab.ledger-is-active { color: var(--ink); }
:root[data-theme="dark"] .ledger-member-chevron { color: var(--ink); }
:root[data-theme="dark"] .ledger-bill-payer b,
:root[data-theme="dark"] .ledger-bill-participants b { color: #c6d3cf; }
:root[data-theme="dark"] .ledger-bill-note-trigger span:last-child { color: #bacbc5; }
:root[data-theme="dark"] .ledger-bill-note-trigger:hover { background: #263533; }
:root[data-theme="dark"] .ledger-bill-note-form button { color: #bfe4d9; background: #29433d; }
:root[data-theme="dark"] .ledger-bill-note-form button:last-child { color: #bdc9c5; background: #2b3534; }
:root[data-theme="dark"] .ledger-avatar-stack .ledger-avatar + .ledger-avatar { border-color: var(--surface); }
:root[data-theme="dark"] .ledger-person-input:checked + .ledger-person-visual .ledger-avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--lake); }
:root[data-theme="dark"] .ledger-person-check { border-color: var(--surface); }
:root[data-theme="dark"] .ledger-dialog-close { color: var(--ink); background: #2a3937; }
:root[data-theme="dark"] .ledger-transfer-row + .ledger-transfer-row,
:root[data-theme="dark"] .ledger-member-stat + .ledger-member-stat { border-top-color: var(--line); }

/* Accent controls need their own foreground: the link color becomes light at night. */
:root[data-theme="dark"] :is(.todo-form button, .ticket-actions button, .food-contact--web, .ledger-primary-button, .ledger-secondary-button) {
  color: var(--on-accent);
  background: var(--lake);
  border-color: var(--lake);
}
:root[data-theme="dark"] :is(.todo-form button, .ticket-actions button, .ledger-primary-button, .ledger-secondary-button):hover {
  color: #172c29;
  background: #c3e8d6;
  border-color: #c3e8d6;
}
:root[data-theme="dark"] .food-contact--web:hover { color: #172c29; background: #c3e8d6; }
:root[data-theme="dark"] :is(.route-region-tabs button[aria-pressed="true"], .popup-place-options button[aria-pressed="true"], .ledger-category-choice:has(input:checked), .ledger-currency-option[aria-current="true"]) {
  border-color: var(--lake);
  color: var(--on-accent);
  background: var(--lake);
}
:root[data-theme="dark"] .ledger-category-choice:has(input:focus-visible),
:root[data-theme="dark"] .ledger-person-choice:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 4px; }
:root[data-theme="dark"] .packing-item input:checked { border-color: var(--lake); background: var(--lake); }
:root[data-theme="dark"] .packing-item input::after,
:root[data-theme="dark"] .ledger-person-check,
:root[data-theme="dark"] .schedule-ticket.is-purchased .schedule-ticket__check,
:root[data-theme="dark"] .todo-item.is-complete .todo-check { color: var(--on-accent); }
:root[data-theme="dark"] .flight-arrow:not(:disabled):hover { color: var(--on-accent); background: var(--lake); border-color: var(--lake); }
:root[data-theme="dark"] .skip-link { color: var(--on-accent); background: var(--lake); }
:root[data-theme="dark"] .topbar .travel-navigation-menu a:active { color: var(--on-accent); background: var(--lake); }

/* Supporting information keeps a softer, but still readable, contrast. */
:root[data-theme="dark"] :is(.section-kicker, .day-route-map__heading small) { color: #b5c8ae; }
:root[data-theme="dark"] :is(.soft-label, .section-index, .schedule-copy-address) { color: var(--muted); }
:root[data-theme="dark"] .schedule-copy-address { border-color: #49615f; }
:root[data-theme="dark"] .food-contact { border-color: var(--line); background: #1b3638; }
:root[data-theme="dark"] .food-contact--web { color: var(--on-accent); border-color: var(--lake); background: var(--lake); }
:root[data-theme="dark"] :is(.food-badge--booked, .schedule-status--confirmed) { color: #c2e1b6; background: #294234; }
:root[data-theme="dark"] .schedule-status-toggle.schedule-status--pending { color: #e8c999; background: #332d22; }
:root[data-theme="dark"] .food-badge--required { color: #f1bcaa; background: #4b302b; }
:root[data-theme="dark"] .food-badge--recommended { color: #ebd1a3; background: #443b2b; }
:root[data-theme="dark"] .food-badge--walk-in { color: #b0d7e7; background: #243c47; }
:root[data-theme="dark"] .food-badge--stroll { color: #d4bfeb; background: #382f48; }
:root[data-theme="dark"] .copy-address { border-color: #49615f; }
:root[data-theme="dark"] .copy-toast { border: 1px solid #496962; color: var(--ink); background: #193a3d; }
:root[data-theme="dark"] input::placeholder { color: #8da7a3; opacity: 1; }
:root[data-theme="dark"] :is(.todo-form input, .ledger-input, .ledger-select, .ledger-amount-input):focus {
  border-color: var(--lake);
  box-shadow: 0 0 0 3px rgba(156, 219, 197, .13);
}

/* The driving card is an intentionally dark surface in both themes. */
:root[data-theme="dark"] .rental-panel { color: var(--ink); background: #102c32; border: 1px solid var(--line); }
:root[data-theme="dark"] .rental-countdown { color: #f4efdf; background: #254b48; }
:root[data-theme="dark"] :is(.rental-countdown span, .rental-countdown small) { color: #c6dfd3; }
:root[data-theme="dark"] .rental-stop__label { color: var(--gold); }
:root[data-theme="dark"] :is(.rental-sub, .rental-stop span, .rental-price) { color: #b3c7c3; }

/* Map popovers are HTML surfaces; preserve the original map and route colors. */
:root[data-theme="dark"] #map-dialog { border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
:root[data-theme="dark"] :is(.route-popover, .transport-popover) {
  border-color: #3c5757;
  color: var(--ink);
  background: #132c31;
  box-shadow: 0 22px 64px rgba(0, 0, 0, .4), 0 1px 0 rgba(255, 255, 255, .04) inset;
}
:root[data-theme="dark"] :is(.dialog-close, .route-popover-close, .transport-popover > button, .ticket-dialog > header button) {
  border: 1px solid #405954;
  color: var(--ink);
  background: #25423f;
}
:root[data-theme="dark"] :is(.popup-place-options button, .transport-pin) { border-color: #446360; color: var(--ink); background: #173638; }
:root[data-theme="dark"] .transport-pin[aria-expanded="true"] { color: #fff; background: #285b58; }
:root[data-theme="dark"] .popup-place-options button[aria-pressed="true"] { color: var(--on-accent); background: var(--lake); }
:root[data-theme="dark"] .geo-city-pin { border-color: #dbe9d8; }
:root[data-theme="dark"] .geo-city-pin:is(:hover, :focus-visible, [aria-expanded="true"], .is-linked) {
  box-shadow: 0 0 0 4px rgba(230, 197, 141, .35), 0 3px 15px rgba(0, 0, 0, .5);
}
:root[data-theme="dark"] :is(.place-map-sheet iframe, .route-place-popover iframe) { background: #152d33; }
:root[data-theme="dark"] .place-map-sheet { border: 1px solid var(--line); }
:root[data-theme="dark"] .place-map-sheet > header { border-bottom: 1px solid var(--line); }

/* Document previews retain white paper; the viewer controls use the night palette. */
:root[data-theme="dark"] .ticket-dialog { color: var(--ink); background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
:root[data-theme="dark"] .ticket-dialog__guidance { color: #bfd0c9; }
:root[data-theme="dark"] .ticket-dialog__links a { border-color: #466660; color: #c4e7d8; background: #1f3e3d; }
:root[data-theme="dark"] .ticket-dialog__links a:hover { border-color: var(--lake); background: #2b5148; }
:root[data-theme="dark"] .ticket-dialog__preview { border-color: #49605d; }
:root[data-theme="dark"] :is(.ticket-dialog, .ledger-dialog, .ledger-confirm-dialog)::backdrop { background: rgba(2, 12, 18, .76); }

/* Expense forms, destructive actions and secondary labels. */
:root[data-theme="dark"] :is(.ledger-section-kicker, .ledger-field-label, .ledger-fieldset legend, .ledger-person-static, .ledger-person-choice, .ledger-split-summary) { color: #a9bdb7; }
:root[data-theme="dark"] :is(.ledger-soft-count, .ledger-field-help, .ledger-members-strip-heading span, .ledger-empty-state, .ledger-stats-overview > span) { color: #a0b5b0; }
:root[data-theme="dark"] :is(.ledger-tabs, .ledger-bill-row, .ledger-member-metrics, .ledger-member-bill, .ledger-dialog-header, .ledger-add-member-form, .ledger-setting-group + .ledger-setting-group) { border-color: var(--line); }
:root[data-theme="dark"] :is(.ledger-form-error, .ledger-danger-button, .ledger-transfer-amount, .ledger-negative strong, .ledger-member-metrics dd.ledger-negative) { color: #f0a58d; }
:root[data-theme="dark"] .ledger-setting-note { color: #d9b199; }
:root[data-theme="dark"] .ledger-confirm-actions .ledger-confirm-danger { border-color: #8f594b; color: #ffcdba; background: #512f2a; }
:root[data-theme="dark"] .ledger-color-picker { border-color: var(--surface); box-shadow: 0 0 0 1px #62746b; }
:root[data-theme="dark"] .ledger-currency-dropdown[open] summary { border-color: var(--lake); box-shadow: 0 0 0 3px rgba(156, 219, 197, .13); }
:root[data-theme="dark"] .ledger-converted-field .ledger-input { color: var(--lake); background: transparent; }
:root[data-theme="dark"] .ledger-currency-option:hover { color: #dcece3; background: #294b47; }
:root[data-theme="dark"] .ledger-currency-option[aria-current="true"]:hover { color: var(--on-accent); background: #c3e8d6; }
:root[data-theme="dark"] .page-loader__footnote { color: #b6cabc; }
:root[data-theme="dark"] .page-loader__progress { background: #243f3d; }

.theme-toggle {
  min-width: 76px;
  min-height: 44px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .2s ease;
}
.theme-toggle:hover { transform: translateY(-1px); border-color: var(--lake); }
.theme-toggle:active { transform: scale(.96); }
.theme-toggle:focus-visible { outline: 3px solid var(--lake); outline-offset: 3px; }
.theme-toggle__icon { display: inline-flex; flex: 0 0 18px; align-items: center; justify-content: center; width: 18px; height: 18px; font: 700 17px/1 system-ui, sans-serif; }
.theme-toggle__icon svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.theme-toggle__label { white-space: nowrap; }
:root[data-theme="dark"] .theme-toggle { border-color: #53645a; color: var(--gold); background: #183337; }

@media (max-width: 760px) {
  .theme-toggle { min-width: 69px; min-height: 44px; padding: 0 10px; gap: 5px; font-size: 12px; }
  :root[data-theme="dark"] .travel-navigation-menu { background: var(--surface); }
}

html[data-theme-transition="reveal"]::view-transition-old(root),
html[data-theme-transition="reveal"]::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html[data-theme-transition="reveal"]::view-transition-old(root) { z-index: 1; }
html[data-theme-transition="reveal"]::view-transition-new(root) { z-index: 2; }
html[data-theme-transition="reveal"]::view-transition-group(root) { animation-duration: .6s; }
:root[data-theme="dark"] .hero__art img { filter: brightness(.82) saturate(.8); }
:root[data-theme="dark"] .hero-title-accent { color: #f1d6a8; }
:root[data-theme="dark"] .hero__glow { opacity: .6; }
:root[data-theme="dark"] .day-card { background: var(--surface); }
:root[data-theme="dark"] .prep-section { background: var(--surface); }
:root[data-theme="dark"] .stay-dates b { background: var(--lake-soft); }


@media print {
  :root[data-theme="dark"] { color-scheme: light; --paper: #fff; --surface: #fff; --ink: #17292f; --muted: #526166; --line: #d7dfdc; }
  .theme-toggle { display: none !important; }
}
