/* B19 appearance. Light keeps the existing white/pastel design; dark is opt-in.
   Keep this file last. Screen-only overrides never recolor photos or documents. */
:root {
    --chart-primary: #788bd1;
    --chart-secondary: #ca8fa8;
    --chart-secondary-readable: #b46e8c;
    --chart-tertiary: #dba57e;
    --chart-grid: #ece8ef;
    --chart-text: #6a6e80;
    --chart-point: #ffffff;
    --chart-fill-top: rgba(120,139,209,.17);
    --chart-fill-bottom: rgba(120,139,209,0);
}
.appearance-card .settings-form > p:first-child {margin: 0 0 17px; font-size: 14px; line-height: 1.65; color: var(--muted);}
.appearance-choices {display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0;}
.appearance-choices label {position: relative; min-width: 0; cursor: pointer;}
.appearance-choices input {position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0;}
.appearance-choices label > span {display: flex; min-height: 80px; align-items: center; justify-content: center; flex-direction: column; gap: 8px; padding: 12px 6px; border: 1px solid #cfc6df; border-radius: 12px; background: #fff; color: #625174;}
.appearance-choices svg {width: 21px; height: 21px;}
.appearance-choices strong {font-size: 13px; font-weight: 600;}
.appearance-choices input:checked + span {border-color: #8061a4; background: #f0e9f8; color: #563a76; box-shadow: inset 0 0 0 1px #8061a4;}
.appearance-choices input:focus-visible + span {outline: 3px solid #8061a4; outline-offset: 3px;}
.appearance-choices:disabled label {cursor: default; opacity: .65;}
.appearance-status {margin: 14px 0 0; font-size: 13px; line-height: 1.65; color: var(--muted);}

@media screen {
    /* Leave breathing room when native validation scrolls an auth field into view. */
    html:has(.auth-panel) {scroll-padding-top: 24px;}
    html[data-theme="dark"] {
        color-scheme: dark;
        --ink: #efedf6;
        --muted: #bdc0d0;
        --subtle: #afb4c8;
        --line: #41475b;
        --canvas: #171922;
        --card: #222632;
        --nav: #1d202b;
        --nav-soft: #302b43;
        --green: #c0a8e8;
        --green-dark: #d4bdf7;
        --green-soft: #363048;
        --purple: #dfa8c5;
        --purple-soft: #422e3f;
        --amber: #e6be88;
        --amber-soft: #3f3328;
        --coral: #f0b0a8;
        --coral-soft: #472e32;
        --mint: #273e36;
        --mint-ink: #a9d6bd;
        --lavender: #332d46;
        --peach: #3d302a;
        --shadow: 0 8px 30px #00000020;
        --night-surface: #222632;
        --night-soft: #2b3040;
        --night-control: #1c202c;
        --night-link: #d4bdf7;
        --night-focus: #ceb4f2;
        --night-success: #afdfbf;
        --night-warning: #f1cb98;
        --night-error: #ffbeb8;
        --chart-primary: #b0bdf4;
        --chart-secondary: #e4b0cc;
        --chart-secondary-readable: #e4b0cc;
        --chart-tertiary: #edc099;
        --chart-grid: #41475b;
        --chart-text: #c1c5d5;
        --chart-point: #222632;
        --chart-fill-top: rgba(176,189,244,.20);
        --chart-fill-bottom: rgba(176,189,244,0);
        background: var(--canvas);
    }
    html[data-theme="dark"] :is(body,.app-body,.marketing-body,.auth-body,.app-shell,.app-content,.main-content,.buyer-public) {background: var(--canvas); color: var(--ink);}
    html[data-theme="dark"] :is(.dashboard-overview,.equipment-page,.household-page,.home-landing,.fleetie-demo,.buyer-page,.buyer-public,.documents-page,.garage-archive-page,.imports-page,.receipt-page,.handoff-page,.metric-evidence) {
        --overview-muted: var(--muted); --overview-line: var(--line);
        --eq-ink: var(--ink); --eq-muted: var(--muted); --eq-line: var(--line);
        --hh-ink: var(--ink); --hh-muted: var(--muted); --hh-line: var(--line);
        --home-ink: var(--ink); --home-muted: var(--muted); --home-purple: var(--night-link); --home-border: var(--line);
        --b04-ink: var(--ink); --b04-muted: var(--muted); --b04-line: var(--line);
        --b05-ink: var(--ink); --b05-muted: var(--muted); --b05-line: var(--line); --b05-soft: var(--night-soft);
        --imports-ink: var(--ink); --imports-muted: var(--muted); --imports-line: var(--line);
        color: var(--ink);
    }
    /* Existing page styles use local text colors. Restore consistent contrast
       without changing any layout, native control behavior, or content. */
    html[data-theme="dark"] :is(h1,h2,h3,h4,h5,h6,strong,b,dd) {color: var(--ink) !important;}
    html[data-theme="dark"] :is(p,small,dt,figcaption,time,label,legend) {color: var(--muted) !important;}
    html[data-theme="dark"] :is(.plain-page,.safety-panel,.plan-panel,.support-panel,.imports-page,.buyer-page,.buyer-public,.handoff-page,.receipt-page,.documents-page,.garage-archive-page,.dashboard-overview,.home-landing,.fleetie-demo,.equipment-page,.household-page) li {color: var(--muted);}
    html[data-theme="dark"] :is(.card-kicker,.eyebrow,.nav-label,.marketing-eyebrow,.metric-label,.metric-foot,.block-muted,.unit,.field-hint,.field-help,.input-prefix i,.input-suffix i,.topbar-title small,.sidebar-user small,.card-subtitle,.legend,.cost-legend,.timeline-note,.type-label,.timeline-date,.comparison-note,.section-row > span,.privacy-chip,.guidance-chip,.public-profile-hero small,.ownership-stat > span,.ownership-cost-table span,.high-low-list span,.value-badge small,.report-summary span,.report-header small,.community-method-note,.community-sample,.community-computer,.community-vehicle-body > small,.community-vehicle-body h3 > span,.community-card-metrics > span,.leaderboard-card li > b,.hero-trust,.marketing-proof,.marketing-proof > span,.feature-number,.feature-tags span,.preview-chapters span,.preview-private,.preview-tools small,.vehicle-chapter-dates,.vehicle-facts small,.vehicle-quick-links a,.empty-icon,.journal-event-kind,.journal-event-date,.journal-event-notes summary,.journal-pagination,.history-pagination,.expense-category > span,.expense-category > small,.report-table small,.report-disclaimer) {color: var(--muted) !important;}
    html[data-theme="dark"] :is(div,section,article,header,footer,aside,nav,table,td,th,li,details,summary,form,fieldset,label,p,span) {border-color: var(--line);}
    html[data-theme="dark"] a:not(.button):not(.home-primary):not(.support-donate-button) {color: var(--night-link) !important;}
    html[data-theme="dark"] a:not(.button):not(.home-primary):not(.support-donate-button):hover {color: #e5d5ff !important;}
    html[data-theme="dark"] :is(a,button) :is(span,strong,b,small) {color: inherit !important;}
    html[data-theme="dark"] :is(a,button,summary,input,select,textarea):focus-visible {outline-color: var(--night-focus) !important;}
    html[data-theme="dark"] .modal-panel :is(h1,h2,h3)[tabindex]:focus {outline: 2px solid var(--night-focus); outline-offset: 4px;}
    html[data-theme="dark"] :is(.profile-photo-control,.upload-field):focus-within {outline-color: var(--night-focus) !important;}
    html[data-theme="dark"] .support-contact a:focus-visible {outline: none !important; color: #e5d5ff !important; text-decoration-color: currentColor;}
    html[data-theme="dark"] ::selection {background: #65557d; color: #fff;}

    /* Shells, primary surfaces, dialogs, and native input fields. */
    html[data-theme="dark"] :is(.sidebar,.topbar,.marketing-nav,.marketing-footer,.app-footer,.auth-panel,.modal-panel,.modal-header,.modal-actions,.shell-context) {background: var(--nav) !important; border-color: var(--line); color: var(--ink);}
    html[data-theme="dark"] .topbar {background: #1d202bf5 !important;}
    html[data-theme="dark"] :is(.brand,.brand-light,.marketing-brand,.topbar-title,.nav-item,.sidebar-user strong,.marketing-signin,.marketing-mobile-menu summary) {color: var(--ink) !important;}
    html[data-theme="dark"] .nav-item.active {background: #342e47; color: #e3d2ff !important; box-shadow: none;}
    html[data-theme="dark"] .nav-item:hover {background: #2a2d3e;}
    html[data-theme="dark"] .sidebar-card {background: #2a253b; border-color: #483d5d;}
    html[data-theme="dark"] .sidebar-card:after {border-color: #64507e;}
    html[data-theme="dark"] .sidebar-card strong {color: #e4d7f7 !important;}
    html[data-theme="dark"] .sidebar-card > span:not(.sidebar-card-icon) {color: #c5bdd6 !important;}
    html[data-theme="dark"] :is(.sidebar-card-icon,.avatar,.settings-avatar,.leader-avatar,.public-avatar,.owner-monogram) {background: #453853; color: #ebd6ff;}
    html[data-theme="dark"] .sidebar .icon-button:hover {background: #373142; color: #f4eaff;}
    html[data-theme="dark"] :is(.card,.metric-card,.vehicle-card,.empty-list-card,.empty-page,.empty-garage,.ownership-stat,.journal-toolbar,.journal-timeline,.expense-category,.report-sheet,.community-filters,.community-vehicle-grid > article,.leaderboard-card,.public-profile-stats article,.public-vehicle-grid > article,.home-community-grid > a,.overview-card,.overview-metric,.overview-details,.comparison-values > div,.plan-library-card,.plan-panel,.plan-filters,.plan-vehicle-picker,.support-panel,.support-history-item,.safety-panel,.membership-plan,.demo-garage-card,.demo-table-scroll,.demo-filters,.demo-empty,.buyer-report,.b05-public-card,.household-invite-chooser,.household-role-options label,.equipment-interval,.household-interval,.home-preview-window,.home-public-garage) {background: var(--card) !important; border-color: var(--line) !important; color: var(--ink); box-shadow: var(--shadow);}
    /* Dashboard sections stay flat in both themes; only attention/setup needs a panel. */
    html[data-theme="dark"] .dashboard-overview :is(.overview-card:not(.overview-attention):not(.overview-first-record),.overview-details) {background: transparent !important; box-shadow: none;}
    html[data-theme="dark"] .dashboard-overview .overview-metric {box-shadow: none;}
    html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),select,textarea) {background: var(--night-control) !important; color: var(--ink) !important; border-color: #69728b !important; caret-color: var(--ink);}
    html[data-theme="dark"] :is(input,textarea)::placeholder {color: #aeb4c8 !important; opacity: 1;}
    html[data-theme="dark"] :is(input,select,textarea):focus {border-color: #c2a4e6 !important; box-shadow: 0 0 0 3px #b69ad633 !important;}
    html[data-theme="dark"] :is(input,select,textarea):disabled {color: #b3b8c9 !important; -webkit-text-fill-color: #b3b8c9 !important; background: #292e3c !important; opacity: 1;}
    html[data-theme="dark"] :is(input,select,textarea)[aria-invalid="true"] {border-color: var(--night-error) !important;}
    html[data-theme="dark"] input[type="file"]::file-selector-button {background: #3b3451 !important; color: #e4d5f7 !important; border-color: #67577e !important;}
    html[data-theme="dark"] :is(input[type="checkbox"],input[type="radio"],input[type="range"]) {accent-color: #b9a0dd;}
    html[data-theme="dark"] option {background: #222632; color: var(--ink);}
    html[data-theme="dark"] .field {color: var(--ink) !important;}
    html[data-theme="dark"] .field > span:first-child {color: var(--ink) !important;}
    html[data-theme="dark"] :is(.input-prefix i,.input-suffix i) {color: #c2b5d5 !important;}
    html[data-theme="dark"] .modal-backdrop {background: #080911b8;}
    html[data-theme="dark"] :is(.mobile-backdrop.active,.mobile-backdrop) {background-color: #080911b8;}
    html[data-theme="dark"] :is(.modal-close,.icon-button,.password-wrap button,.table-action) {color: #d9caed !important;}
    html[data-theme="dark"] .modal-close {background: #383047;}
    html[data-theme="dark"] .modal-actions {box-shadow: 0 -8px 24px #00000025;}
    html[data-theme="dark"] .check-card > span {background: var(--night-control); border-color: #727991; color: var(--ink);}
    html[data-theme="dark"] .check-card > span > i {border-color: #9ca7bf;}
    html[data-theme="dark"] .check-card input:checked + span {background: #363049; border-color: #bfa2e0;}
    html[data-theme="dark"] .check-card input:checked + span > i {background: #a98acd; border-color: #c9adeb;}
    html[data-theme="dark"] .check-card input:checked + span > i:after {border-color: #21152f;}
    html[data-theme="dark"] .privacy-toggle > span {background: #292634; border-color: #5f556f;}
    html[data-theme="dark"] .privacy-toggle input:checked + span {background: #342c47; border-color: #aa8cce;}
    html[data-theme="dark"] .privacy-toggle i {background: #6c738a;}
    html[data-theme="dark"] .privacy-toggle input:checked + span i {background: #bfa2e0;}
    html[data-theme="dark"] .privacy-toggle input:checked + span i:after {background: #282036;}
    html[data-theme="dark"] :is(.check-card input:focus-visible + span,.privacy-toggle input:focus-visible + span) {outline-color: var(--night-focus);}
    html[data-theme="dark"] :is(.upload-field,.csv-drop) {background: #262937; border-color: #817394;}
    html[data-theme="dark"] :is(.upload-field:hover,.csv-drop:hover) {background: #302b42; border-color: #bca1da;}

    /* Explicit semantic tones keep danger, guidance, and success distinguishable. */
    html[data-theme="dark"] :is(.alert,.alert-info,.record-save-state,.draft-banner,.draft-notice,.save-state,.receipt-notice,.b04-notice,.b05-notice,.h06-notice,.imports-notice,.household-notice,.support-notice,.service-context-note,.service-context-notice,.fuel-distance-review,.metric-evidence-notice) {background: #292b40 !important; border-color: #6b628b !important; color: #ddd4f3 !important;}
    html[data-theme="dark"] :is(.alert-error,.equipment-errors,.household-errors,.imports-errors,.receipt-errors,.receipt-extraction-errors,.b04-errors,.b05-errors,.h06-errors,.safety-errors,.support-errors,.b04-danger) {background: #422b32 !important; border-color: #a46773 !important; color: var(--night-error) !important;}
    html[data-theme="dark"] :is(.alert-error,.equipment-errors,.household-errors,.imports-errors,.receipt-errors,.receipt-extraction-errors,.b04-errors,.b05-errors,.h06-errors,.safety-errors,.support-errors,.b04-danger) :is(p,li,h2,strong,a) {color: #ffd0c9 !important;}
    html[data-theme="dark"] :is(.button-danger,.danger-link,.equipment-remove,.household-danger,.b04-danger-link,.receipt-danger,.remove-rule,.service-context-rule-actions .remove-rule) {color: #ffc0b9 !important;}
    html[data-theme="dark"] .button-danger {background: #4a2e36 !important; border-color: #986675 !important;}
    html[data-theme="dark"] .button-danger:hover {background: #5a3540 !important;}
    html[data-theme="dark"] :is(.network-alert,.equipment-notice,.guidance-note,.plan-notice-warning,.service-candidates-guidance,.support-privacy,.import-tip,.overview-attention) {background: #393125 !important; border-color: #776344 !important; color: var(--night-warning) !important;}
    html[data-theme="dark"] :is(.network-alert,.equipment-notice,.guidance-note,.plan-notice-warning,.service-candidates-guidance,.support-privacy,.import-tip,.overview-attention) :is(p,small) {color: #e1caac !important;}
    html[data-theme="dark"] :is(.status-badge.overdue,.service-icon.overdue,.equipment-status.overdue,.household-status.overdue,.overview-status-overdue,.import-status.invalid,.imports-badge.is-error,.support-status-closed) {background: #4c2e36 !important; color: #ffc0b9 !important;}
    html[data-theme="dark"] :is(.status-badge.soon,.service-icon.soon,.equipment-status.soon,.household-status.soon,.overview-status-soon,.import-status.duplicate,.imports-badge.is-review) {background: #483a27 !important; color: #f6d099 !important;}
    html[data-theme="dark"] :is(.status-badge.later,.service-icon.later,.equipment-status.later,.household-status.later,.household-role.owner,.overview-kind-maintenance,.import-status.ready,.imports-badge.is-ready,.button-saved,.support-status-resolved,.b04-success,.receipt-success,.household-notice.success) {background: #2a4137 !important; color: #b6e7c6 !important;}
    html[data-theme="dark"] :is(.equipment-status,.household-status,.household-role,.overview-status-review,.trend-pill,.privacy-chip,.guidance-chip,.safety-badge,.plan-version,.plan-tag-owner,.plan-tag-neutral,.b04-status,.b05-status,.h06-status,.receipt-status,.imports-badge,.support-status,.demo-badge,.equipment-kind,.equipment-archived-tag,.vehicle-year,.vehicle-ownership-status,.community-photo > span,.vehicle-type-tag,.membership-badge,.membership-plan-state,.support-reference) {background: #393249; color: #e1d2f7 !important; border-color: #6a5984;}
    html[data-theme="dark"] :is(.field-error,.receipt-field-error,.b04-field-error,.imports-field-error,.imports-row-errors,.import-error,.vin-lookup[data-state="error"] .vin-lookup-status) {color: var(--night-error) !important;}
    html[data-theme="dark"] :is(.field-error,.receipt-field-error,.b04-field-error,.imports-field-error) * {color: inherit !important;}

    /* Buttons are styled last within their group to preserve action contrast. */
    html[data-theme="dark"] :is(.button,.home-primary,.support-donate-button) {background: #302e40 !important; border-color: #79688d !important; color: #e8def8 !important; box-shadow: none !important;}
    html[data-theme="dark"] :is(.button,.home-primary,.support-donate-button):hover {background: #3b354d !important; border-color: #b097cf !important; color: #fff !important;}
    html[data-theme="dark"] :is(.button-primary,.home-primary,.support-donate-button) {background: #c0a7e1 !important; border-color: #c0a7e1 !important; color: #251932 !important;}
    html[data-theme="dark"] :is(.button-primary,.home-primary,.support-donate-button):hover {background: #d4bef0 !important; border-color: #d4bef0 !important; color: #20112d !important;}
    html[data-theme="dark"] .button-ghost {background: #2c2939 !important; border-color: #595067 !important; color: #ded5ec !important;}
    html[data-theme="dark"] .button-danger {background: #4a2e36 !important; border-color: #986675 !important; color: #ffc0b9 !important;}
    html[data-theme="dark"] .button-saved {background: #2a4137 !important; border-color: #597b67 !important; color: #b6e7c6 !important;}
    html[data-theme="dark"] :is(.button,.home-primary,.support-donate-button) :is(span,strong,b,small) {color: inherit !important;}
    html[data-theme="dark"] :is(.rule-actions button,.rule-actions a,.vehicle-edit-link,.vin-lookup-option,.imports-decision,.receipt-suggestion,.service-context-rule-actions > a) {background: #353047; color: #dbc8f2 !important; border-color: #665777;}
    html[data-theme="dark"] :is(.rule-actions .remove-rule,.service-context-rule-actions .remove-rule) {background: #4a2e36; color: #ffc0b9 !important;}

    /* Records, metrics, tables, and SVG/canvas chart surroundings. */
    html[data-theme="dark"] :is(.table-wrap td,.table-wrap th,.report-table td,.report-table th,.import-preview-table th,.import-preview-table td,.demo-table-scroll th,.demo-table-scroll td) {color: var(--muted); border-color: var(--line);}
    html[data-theme="dark"] :is(.table-wrap th,.report-table th,.import-preview-table th,.demo-table-scroll th) {background: #282b3a; color: #d4c7e5 !important;}
    html[data-theme="dark"] :is(.table-wrap tbody tr:hover,.support-history-item summary:hover) {background: #2b2f3e;}
    html[data-theme="dark"] :is(.ownership-cost-table > div:first-child,.ownership-ledger-top > div,.ownership-stat-grid > div,.value-badge,.report-summary > div,.report-summary > article,.expense-category,.overview-comparison-values > div,.metric-interval-anchor,.comparison-values > .comparison-own,.demo-metrics > div,.demo-ownership,.home-preview-metrics > div,.home-preview-bottom,.feature-tags span) {background: #2d293e !important; border-color: #514762 !important; color: var(--ink);}
    html[data-theme="dark"] :is(.ownership-ledger-top > div.featured,.metric-featured,.overview-metric-mpg,.home-preview-metrics > .home-preview-economy,.demo-metrics > div:nth-child(2)) {background: #253a32 !important; border-color: #456552 !important;}
    html[data-theme="dark"] :is(.ownership-stat:nth-child(1),.insight-card,.demo-metrics > div:nth-child(3),.overview-first-record) {background: #302b40 !important; border-color: #50425f !important;}
    html[data-theme="dark"] :is(.ownership-stat:nth-child(2),.insight-card:nth-child(2)) {background: #283b33 !important; border-color: #42634f !important;}
    html[data-theme="dark"] :is(.insight-card:nth-child(3),.demo-metrics > div:nth-child(4)) {background: #3c3028 !important; border-color: #6c5240 !important;}
    html[data-theme="dark"] :is(.metric-icon,.metric-icon.purple,.large-icon,.service-icon,.guide-icon,.upload-icon,.vehicle-cell i,.vehicle-dot,.mpg-badge,.preview-chapters b,.feature-icon,.home-icon,.overview-note-symbol,.overview-welcome-icon,.setup-step-number,.household-mark,.equipment-empty-icon,.journal-event-icon,.vehicle-form-chapter > span) {background: #3d3250; color: #d8c2f1;}
    html[data-theme="dark"] .metric-icon.amber {background: #443628; color: #efc99b;}
    html[data-theme="dark"] .metric-icon.coral {background: #462f3a; color: #ebbad0;}
    html[data-theme="dark"] .mpg-value {color: #cbb5eb !important;}
    html[data-theme="dark"] :is(.benchmark-list > div > i,.driving-mix-bar) {background: #4a3850;}
    html[data-theme="dark"] .benchmark-list em {background: #ba9cde;}
    html[data-theme="dark"] .benchmark-list em.muted {background: #8994ac;}
    html[data-theme="dark"] .benchmark-list em.purple {background: #d797b9;}
    html[data-theme="dark"] .driving-mix-bar i {background: #9aaae5;}
    html[data-theme="dark"] .highway-dot {background: #9aaae5;}
    html[data-theme="dark"] .city-dot {background: #d797b9;}
    html[data-theme="dark"] :is(.legend-green,.overview-real-dot) {background: var(--chart-primary);}
    html[data-theme="dark"] :is(.legend-purple,.overview-computer-dot) {background: var(--chart-secondary);}
    html[data-theme="dark"] .legend-peach {background: var(--chart-tertiary);}
    html[data-theme="dark"] :is(.schedule-row,.timeline-row,.form-section,.journal-event,.metric-record,.metric-evidence-card > header,.metric-pagination,.metric-cost-breakdown,.comparison-method,.comparison-discovery,.overview-attention-list li + li,.overview-attention-footer,.overview-records li + li,.overview-assets-list li + li,.household-person,.equipment-record) {border-color: var(--line);}
    html[data-theme="dark"] .timeline-marker:before {background: var(--line);}
    html[data-theme="dark"] .timeline-marker {border-color: #8a839f;}
    html[data-theme="dark"] .timeline-marker.completed {border-color: #bb9edc;}
    html[data-theme="dark"] .timeline-marker.planned {border-color: #dcba89;}

    /* Optional details, notices, tools, Household, plans, and import/recovery. */
    html[data-theme="dark"] :is(.privacy-explainer,.import-tip,.import-help > .card,.logging-guide,.journal-note,.journal-export,.live-value-note,.onboarding-prompt,.overview-early-note,.overview-welcome,.health-list li,.household-intro-note,.household-interval,.household-invite-verification,.household-invite-chooser > summary,.household-role-options label:has(input:checked),.plan-notice,.plan-source-box,.plan-helper,.plan-summary,.plan-adopt-panel,.plan-public-facts,.plan-intervals,.plan-fit,.plan-category,.plan-empty,.schedule-first-interval,.recommendation-item .schedule-unknown,.equipment-unknown,.equipment-section-note,.equipment-existing-file,.b04-notice,.b05-progress,.h06-progress,.handoff-context,.h06-provenance,.imports-context,.imports-progress,.imports-source-metadata pre,.imports-source-metadata dl,.receipt-destination,.receipt-progress,.receipt-reuse,.receipt-extraction,.receipt-extraction-budget,.receipt-suggestion-used,.service-reuse,.service-candidates,.vehicle-optional,.vin-lookup,.vin-lookup-option:has(input:checked),.safety-note,.feedback-inbox-context,.support-history-message,.beta-thank-you,.membership-beta-note,.membership-unavailable,.support-side-note) {background: #2a293b !important; border-color: #514963 !important; color: var(--muted);}
    html[data-theme="dark"] :is(.equipment-interval,.household-interval,.recommendation-item,.plan-item,.household-home [data-household-invite-item]) {background: #252936 !important; border-color: var(--line) !important;}
    html[data-theme="dark"] .household-home [data-household-invite-item]:hover {background: #343047 !important;}
    html[data-theme="dark"] :is(.garage-tabs,.equipment-tabs,.household-tabs,.community-tabs,.import-steps li,.imports-steps li) {background: #282835; color: var(--muted);}
    html[data-theme="dark"] :is(.garage-tabs a[aria-current],.equipment-tabs a[aria-current],.household-tabs a[aria-current],.community-tabs a.active,.import-steps [aria-current],.imports-steps [aria-current]) {background: #443654; color: #efddff !important; border-color: #7b608f; box-shadow: none;}
    html[data-theme="dark"] :is(.detail-chips span,.detail-chips a,.community-hero-tags span,.plan-tag-neutral,.household-count,.overview-count,.feedback-inbox-count,.imports-namespace,.imports-totals > span,.import-summary > span) {background: #353045; color: #d4c7e5 !important;}
    html[data-theme="dark"] .community-hero-tags span:nth-child(2) {background: #2c4036; color: #b0d4bf !important;}
    html[data-theme="dark"] .community-hero-tags span:nth-child(3) {background: #423329; color: #edc6a0 !important;}
    html[data-theme="dark"] :is(.storage-meter,.b04-progress,.imports-progress progress) {accent-color: #b49ad6;}
    html[data-theme="dark"] meter::-webkit-meter-bar {background: #363447; border-color: #675e76;}
    html[data-theme="dark"] meter::-webkit-meter-optimum-value {background: #ad91d1;}
    html[data-theme="dark"] meter::-moz-meter-bar {background: #ad91d1;}
    html[data-theme="dark"] .valuation-actions > .refresh-limit {background: #43303d; color: #f1bfd9 !important;}

    /* Public profiles, demo garages, marketing, and authentication. */
    html[data-theme="dark"] :is(.community-photo,.vehicle-art,.equipment-art,.equipment-detail-art,.household-art,.household-overview-art,.public-vehicle-photo,.community-car-thumb,.demo-vehicle-art,.home-public-photo,.preview-car,.empty-garage-art) {background: #302d41; color: #c6b0db;}
    html[data-theme="dark"] :is(.vehicle-art-2,.discovery-color-2 .community-photo,.equipment-card:nth-child(3n+2) .equipment-art,.demo-tone-2) {background: #293e34; color: #b2d1bd;}
    html[data-theme="dark"] :is(.vehicle-art-3,.discovery-color-3 .community-photo,.equipment-card:nth-child(3n+3) .equipment-art,.demo-tone-3) {background: #3c3028; color: #d9bea3;}
    html[data-theme="dark"] :is(.vehicle-art,.community-photo,.public-vehicle-photo,.community-car-thumb,.empty-garage-art) > svg {fill: #29283a; stroke: #c4aadf;}
    html[data-theme="dark"] .vehicle-art:after {border-color: #ffffff09;}
    html[data-theme="dark"] .add-vehicle-card {background: #24212f; border-color: #756581; color: #cfbeda;}
    html[data-theme="dark"] .add-vehicle-card:hover {background: #302a40;}
    html[data-theme="dark"] .add-vehicle-card > span {background: #3c304d; color: #d5b9f0;}
    html[data-theme="dark"] :is(.community-invite,.home-feature.home-mint,.feature-card.mint,.home-preview-car,.home-preview-economy,.overview-equipment .overview-section-heading) {background: #273b32 !important; border-color: #496451 !important; color: #b4d8bf;}
    html[data-theme="dark"] :is(.leaderboard-card header,.home-community,.public-garage,.marketing-proof,.marketing-cta,.ownership-promise,.ownership-preview,.hero-window-bar,.hero-chart,.hero-metrics article,.hero-float-card,.home-sharing,.home-start,.home-preview,.home-feature.home-lavender,.feature-card.lavender,.overview-shared .overview-section-heading,.membership-plan-plus,.support-donate,.demo-disclosure,.demo-method,.demo-footer) {background: #2c263b !important; border-color: #554360 !important; color: var(--ink);}
    html[data-theme="dark"] :is(.home-feature.home-peach,.feature-card.peach) {background: #3c3028 !important; border-color: #6c5240 !important;}
    html[data-theme="dark"] :is(.home-icon,.feature-icon,.beta-thank-you-icon,.support-coffee-icon) {background: #ffffff0d; color: #d1b8e9;}
    html[data-theme="dark"] .home-peach .home-icon {color: #edc2a0;}
    html[data-theme="dark"] .home-mint .home-icon {color: #b3d9bc;}
    html[data-theme="dark"] :is(.home-preview-bottom,.home-preview-metrics > div,.hero-metrics article) {background: #292e3c !important;}
    /* The public introduction uses the same flat hierarchy as the signed-in app. */
    html[data-theme="dark"] .home-landing :is(.home-feature,.home-preview,.home-sharing,.home-start,.home-preview-metrics > div,.home-preview-bottom) {background: transparent !important; border-color: var(--line) !important; box-shadow: none;}
    html[data-theme="dark"] .home-landing .home-preview-window {box-shadow: none;}
    html[data-theme="dark"] .membership-page[aria-labelledby="membership-title"] .membership-beta-note {background: transparent !important;}
    html[data-theme="dark"] .home-landing .home-chart text {fill: var(--muted);}
    html[data-theme="dark"] .home-landing .home-chart-grid {stroke: var(--line);}
    html[data-theme="dark"] .home-landing .home-chart-area {fill: #2a3d34;}
    html[data-theme="dark"] .home-landing .home-chart-real {stroke: #b1d9bd;}
    html[data-theme="dark"] .home-landing .home-chart-computer {stroke: #d0b0eb;}
    html[data-theme="dark"] .home-landing .home-chart-points {fill: #222632; stroke: #b1d9bd;}
    html[data-theme="dark"] .home-landing .home-chart-legend i {background: #b1d9bd;}
    html[data-theme="dark"] .home-landing .home-chart-legend span + span i {background: transparent; border-color: #d0b0eb;}
    html[data-theme="dark"] .auth-showcase {background: radial-gradient(circle at 80% 30%, #433245 0, transparent 34%), linear-gradient(145deg,#2c283e,#22333a 70%,#35293e); color: var(--ink);}
    html[data-theme="dark"] :is(.showcase-copy h1 em,.hero-copy h1 em,.community-hero h1 em,.home-hero h1 span) {color: #d1b3e8;}
    html[data-theme="dark"] .showcase-orbit {border-color: #b994da20;}
    html[data-theme="dark"] .road-lines i {background: linear-gradient(transparent,#ac91c8);}
    html[data-theme="dark"] .car-body {fill: #363044;}
    html[data-theme="dark"] .car-window {fill: #65516f;}
    html[data-theme="dark"] .car-wheel {fill: #ad90c3; stroke: #363044;}
    html[data-theme="dark"] .car-hub {fill: #ddd0e8;}
    html[data-theme="dark"] .car-shadow {fill: #211c2d;}
    html[data-theme="dark"] .preview-orbit {border-color: #62506f;}
    html[data-theme="dark"] :is(.hero-grid,.home-chart-grid) {stroke: var(--line);}
    html[data-theme="dark"] .marketing-skip {background: #302840 !important; color: #f2e8ff !important; border-color: #c6a5e6 !important;}
    html[data-theme="dark"] :is(.beta-thank-you-label,.demo-disclosure,.demo-vehicle-art > span,.demo-card-body .demo-badge,.demo-ownership dt,.demo-section-heading > span,.home-chart-legend,.home-preview-kicker,.home-public-make,.home-preview figcaption,.home-preview-metrics span,.home-preview-bottom span,.home-asset-types > span,.home-sharing-note,.membership-plan-state,.membership-unavailable,.support-eyebrow,.support-history-meta,.support-submit-row span,.plan-card-meta,.plan-section-heading > span,.plan-card-owner,.plan-card-conditions,.plan-card-vehicle,.plan-version,.plan-category,.receipt-help,.receipt-meta,.receipt-kicker,.b05-row-meta,.b05-eyebrow,.h06-status,.h06-provenance,.imports-kicker,.imports-namespace,.import-hint,.import-summary,.imports-pagination > span,.safety-label,.safety-actions > span,.household-meta,.household-asset-footer,.household-record-date,.household-kicker,.shell-asset-context > span,.overview-eyebrow,.overview-metric > span,.overview-chart-legend,.overview-attention-body > span,.overview-due,.overview-record-kind,.overview-assets-list span,.equipment-private,.equipment-current > span,.equipment-card-reading span,.equipment-status,.metric-evidence-eyebrow,.metric-record-title span,.metric-formula span,.metric-cost-amount span,.metric-period-form label,.metric-pagination span,.fuel-distance-source,.fuel-calculation-status,.service-context-note > span,.service-context-list span,.vin-lookup > summary span) {color: var(--muted) !important;}
    html[data-theme="dark"] :is(.overview-text-link,.metric-inline-link,.metric-explanation-links a,.metric-explanation > summary,.comparison-method > summary,.service-reuse > summary,.log-details > summary,.vehicle-optional > summary,.vehicle-more-options > summary,.vin-lookup > summary,.b04-details summary,.b04-cancel summary,.receipt-preview summary,.receipt-options summary,.receipt-discard summary,.household-record-notes summary,.household-remove-details summary,.plan-card-link,.safety-preview summary,.safety-audit summary) {color: var(--night-link) !important;}
    html[data-theme="dark"] :is(.preview-tool-icon.mint,.journal-event-fuel .journal-event-icon) {background: #2d4539; color: #b4ddc1;}
    html[data-theme="dark"] :is(.preview-tool-icon.peach,.journal-event-maintenance .journal-event-icon) {background: #4b392d; color: #eac3a3;}
    html[data-theme="dark"] .receipt-preview img {background: #fff;}
    html[data-theme="dark"] .receipt-pdf {background: #252836; border-color: var(--line); color: var(--muted);}
    html[data-theme="dark"] .setup-body {background: var(--canvas); color: var(--ink);}
    html[data-theme="dark"] .setup-body .main {background: var(--canvas);}
    html[data-theme="dark"] .setup-body .panel {background: var(--card); border-color: var(--line); box-shadow: var(--shadow);}
    html[data-theme="dark"] .setup-body .side {background: linear-gradient(145deg,#252135,#203139);}
    html[data-theme="dark"] .setup-body .ring {border-color: #9b81bb24;}
    html[data-theme="dark"] .setup-body .step {background: #2b2d3b;}
    html[data-theme="dark"] .setup-body .step i {background: #3c3450; color: #dac5f3;}
    html[data-theme="dark"] .setup-body .alert:not(.success) {background: #422b32 !important; border-color: #a46773 !important; color: #ffd0c9 !important;}
    html[data-theme="dark"] .setup-body .alert.success {background: #2a4137 !important; border-color: #597b67 !important; color: #b6e7c6 !important;}
    html[data-theme="dark"] .setup-body .button {background: #c0a7e1 !important; border-color: #c0a7e1 !important; color: #251932 !important;}

    /* Scoped components found in the full-page contrast audit. */
    html[data-theme="dark"] .vehicle-year {background: #393249 !important; color: #e1d2f7 !important;}
    html[data-theme="dark"] :is(.care-metrics > article,.support-history-empty) {background: var(--card); border-color: var(--line);}
    html[data-theme="dark"] .plan-item .plan-condition {background: #302b40; color: var(--muted) !important;}
    html[data-theme="dark"] :is(.service-reuse > summary span,.support-history-header > span,.membership-price span,.community-filters label > span) {color: var(--muted) !important;}
    html[data-theme="dark"] .imports-field > span:not(.imports-field-error) {color: var(--ink) !important;}
    html[data-theme="dark"] :is(.equipment-record-notes > summary,.community-more-filters > summary,.community-more-filters > summary span) {color: var(--night-link) !important;}
    html[data-theme="dark"] .guide-steps i {color: #d4c7e5; border-color: #8f7da3;}
    html[data-theme="dark"] .empty-community {background: var(--card); border-color: var(--line);}
    html[data-theme="dark"] .empty-community-icon {background: #393249; color: #d9c5ef;}
    html[data-theme="dark"] .vehicle-setup-page :is(.vehicle-optional > summary,.vehicle-section-heading) {background: #302b40 !important; border-color: var(--line);}
    html[data-theme="dark"] .vehicle-setup-page .vehicle-optional > summary::before {color: var(--night-link);}
    html[data-theme="dark"] :is(.metric-interval-anchor > span,.demo-metrics span,.public-profile-missing > span,.feedback-inbox-meta) {color: var(--muted) !important;}
    html[data-theme="dark"] .modal-form[data-draft-form^="maintenance:"] .schedule-rule-picker .field-hint {color: var(--muted) !important;}
    html[data-theme="dark"] .imports-row-errors {background: #422b32; color: var(--night-error) !important;}
    html[data-theme="dark"] .imports-row-errors li {color: var(--night-error) !important;}
    html[data-theme="dark"] .imports-row-warnings {background: #393125; color: var(--night-warning);}
    html[data-theme="dark"] .imports-row-warnings li {color: var(--night-warning) !important;}

    /* Theme chooser uses native radio semantics and keeps focus visible. */
    html[data-theme="dark"] .appearance-choices label > span {background: #262a38; border-color: #747087; color: #d1c4e2;}
    html[data-theme="dark"] .appearance-choices input:checked + span {background: #413451; border-color: #d0acef; color: #f0dfff; box-shadow: inset 0 0 0 1px #d0acef;}
    html[data-theme="dark"] .appearance-choices input:focus-visible + span {outline-color: #d0acef;}
    html[data-theme="dark"] .appearance-choices label > span strong {color: inherit !important;}
}

/* Printed histories retain their existing light palette regardless of screen theme. */
@media print {
    html[data-theme] {
        color-scheme: light !important; background: #fff !important;
        --chart-primary: #788bd1; --chart-secondary: #ca8fa8; --chart-secondary-readable: #b46e8c;
        --chart-tertiary: #dba57e; --chart-grid: #ece8ef; --chart-text: #6a6e80; --chart-point: #ffffff;
        --chart-fill-top: rgba(120,139,209,.17); --chart-fill-bottom: rgba(120,139,209,0);
    }
    .appearance-card {display: none !important;}
}
