.header-inner { column-gap: clamp(.45rem, 1.9vw, 1.65rem); }
.header-inner > .site-nav { margin-inline-start: auto; }
.theme-switch {
    flex: none; order: 3; inline-size: 2.75rem; block-size: 2.75rem; padding: .45rem;
    border-color: var(--line); color: var(--ink-deep);
}
.theme-switch[hidden], .theme-sun, [data-theme="dark"] .theme-moon { display: none; }
.layout-marketing .theme-switch[hidden] { display: inline-grid; visibility: hidden; }
[data-theme="dark"] .theme-sun { display: block; }
@media (max-width: 700px) {
    .theme-switch { inline-size: 2.4rem; block-size: 2.4rem; min-height: 2.4rem; }
    .header-inner > .mobile-site-menu { order: 4; }
    .header-inner:has(.mobile-site-menu) > .theme-switch { margin-inline-start: auto; }
}
@media (max-width: 380px) {
    .header-inner:has(.mobile-site-menu) { flex-wrap: nowrap; }
    .header-inner:has(.mobile-site-menu) .brand { gap: .36rem; }
    .header-inner:has(.mobile-site-menu) .brand-mark { width: 1.9rem; }
    .header-inner:has(.mobile-site-menu) .brand-wordmark strong { font-size: 1.04rem; }
    .header-inner:has(.mobile-site-menu) .brand-wordmark > span { font-size: .55rem; }
    .header-inner > .mobile-site-menu > summary { gap: .34rem; padding-inline: .5rem; font-size: .82rem; }
    .layout-portal .header-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; }
    .layout-portal .header-inner > .site-nav { margin: 0; gap: .32rem; flex-wrap: nowrap; }
    .layout-portal .header-inner .brand { gap: .35rem; }
    .layout-portal .header-inner .brand-mark { width: 1.7rem; }
    .layout-portal .header-inner .brand-wordmark strong { font-size: .95rem; }
    .layout-portal .header-inner .brand-wordmark > span { font-size: .53rem; }
    .layout-portal .header-inner .sign-out > button { padding-inline: .42rem; font-size: .76rem; }
}

[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e4edf7;
    --ink-deep: #f0f6ff;
    --brand-blue: #8fcaff;
    --brand-soft: #223b56;
    --brand-orange: #ffb760;
    --paper: #0c1725;
    --canvas: #111f30;
    --surface: #18283b;
    --line: #334b62;
    --muted: #b5c6d8;
    --focus: #ffc980;
    --border-control: #647e98;
    --shadow-panel: 0 12px 26px -15px #040a12;
}
[data-theme="dark"] .hero:not(.web-tone-light):not(.web-tone-soft),
[data-theme="dark"] .auth-intro, [data-theme="dark"] .site-footer,
[data-theme="dark"] .web-page-heading,
[data-theme="dark"] .web-tone-dark, [data-theme="dark"] .guidance-band:not(.web-tone-light):not(.web-tone-soft) {
    background: #08182a; color: #f1f7ff;
}
[data-theme="dark"] .overview-heading { background: linear-gradient(115deg, #10233c, #1b456e); color: #f1f7ff; }
[data-theme="dark"] .web-tone-soft { background: #132437; color: var(--ink); }
[data-theme="dark"] .site-footer .footer-main nav a { color: #e6f2ff; }
[data-theme="dark"] .hero-secondary { color: #daeaff; }
[data-theme="dark"] .button, [data-theme="dark"] button {
    background: #1263a9; color: #fff;
}
[data-theme="dark"] .button:hover, [data-theme="dark"] button:hover { background: #2373b4; }
[data-theme="dark"] .button-subtle, [data-theme="dark"] .theme-switch {
    background: transparent; color: var(--ink); border-color: var(--border-control);
}
[data-theme="dark"] .button-subtle:hover, [data-theme="dark"] .theme-switch:hover {
    background: var(--brand-soft); color: var(--ink-deep);
}
[data-theme="dark"] .button-on-dark { background: transparent; color: #edf5ff; border-color: #708ca7; }
[data-theme="dark"] .button-on-dark:hover { background: #22405c; }
[data-theme="dark"] .button-danger { background: #382631; color: #ffb7b6; border-color: #875463; }
[data-theme="dark"] .button-lime, [data-theme="dark"] .skip-link { background: var(--brand-orange); color: #172536; }
[data-theme="dark"] .menu a:hover, [data-theme="dark"] .menu a[aria-current],
[data-theme="dark"] .menu-group > summary:hover, [data-theme="dark"] .menu-group[open] > summary,
[data-theme="dark"] .page-guide > summary:hover, [data-theme="dark"] .metric:hover,
[data-theme="dark"] .inbox-link[aria-current], [data-theme="dark"] .record-table tbody tr:hover {
    background: var(--brand-soft); color: var(--ink);
}
[data-theme="dark"] :is(.page-guide, .editor-setup, .editor-condition, .seo-preview, .seo-consent,
    .unified-day.is-outside, .record-table thead, .billing-table thead, .dialog-heading, .dialog-content,
    .notification-blade, .notification-blade-header, .conversation-scroll, .ledger-details, .voice-timer,
    .report-check, .map-status, .map-note, .notification-preview-item, .notification-bell > summary) {
    background: var(--canvas); color: var(--ink); border-color: var(--line);
}
[data-theme="dark"] :is(.editor-card, .page-guide-content, .notification-blade-footer, .notification-preview-item) { border-color: var(--line); }
[data-theme="dark"] :is(.drawing-viewport, .map-canvas, .report-photo img) { background: #20344b; border-color: var(--line); }
[data-theme="dark"] :is(.notification-blade-header h2, .notification-preview-item small, .report-context span,
    .report-photo small, .seo-preview small, .seo-preview span) { color: var(--muted); }
[data-theme="dark"] :is(.notification-preview-item:hover, .notification-unread, .message.is-mine,
    .calendar-day.is-today h2, .calendar-visit:hover, .unified-event:hover) { background: var(--brand-soft); color: var(--ink); }
[data-theme="dark"] :is(.status, .ref, .seo-preview strong) { background: #223c51; color: #c3e4ff; }
[data-theme="dark"] :is(.status-success, .notice, .report-state) { background: #203e34; color: #bde8cb; border-color: #416b55; }
[data-theme="dark"] :is(.status-attention, .connection-status, [data-visit-failure]) {
    background: #392f22; color: #ffdda5; border-color: #8c6740;
}
[data-theme="dark"] .form-alert { background: #3c2630; color: #ffcbcb; border-color: #885963; }
[data-theme="dark"] .calendar-view-tabs [aria-current], [data-theme="dark"] .mobile-site-menu nav > .button {
    background: #1263a9; color: #fff;
}
[data-theme="dark"] .calendar-reminder-row > .toolbar button { background: var(--surface); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] :is(.leaflet-popup-content-wrapper, .leaflet-popup-tip) { color: #16283c; background: #f2f6fa; }
[data-theme="dark"] .leaflet-popup-content a { color: #004d99; }
[data-theme="dark"] .seo-cookie-settings { background: transparent; color: inherit; }
[data-theme="dark"] .notification-preview-item { justify-content: start; }
[data-theme="dark"] .brand-mark { filter: drop-shadow(0 0 3px #88baff33); }

@media print {
    .theme-switch { display: none !important; }
    [data-theme="dark"] {
        color-scheme: light;
        --ink: #252525; --ink-deep: #0b2643; --brand-blue: #004d99; --muted: #4e5f70;
        --paper: #fff; --canvas: #fff; --surface: #fff; --line: #c5cdd4;
    }
}
