.web-theme-toggle:not([hidden]) {
    position: fixed;
    z-index: 60;
    inset-inline-start: max(16px, env(safe-area-inset-left));
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid #85af91;
    border-radius: 50%;
    background: #123d2b;
    color: #c9ed7a;
    box-shadow: 0 5px 18px #123d2b40;
    cursor: pointer;
}

.web-theme-toggle:focus-visible {
    outline: 3px solid #6eb58c;
    outline-offset: 3px;
}

.web-theme-sun,
[data-theme="dark"] .web-theme-moon {
    display: none;
}

[data-theme="dark"] .web-theme-sun {
    display: block;
}

[data-theme="dark"] {
    color-scheme: dark;
    --theme-background: #101b16;
    --theme-surface: #182820;
    --theme-raised: #20372b;
    --theme-line: #385344;
    --theme-text: #ecf5ee;
    --theme-muted: #b3c8ba;
    --theme-accent: #8bdaa8;
    --cream: var(--theme-background);
    --mint: var(--theme-raised);
    --ink: var(--theme-text);
    --muted: var(--theme-muted);
    --line: var(--theme-line);
    --green: var(--theme-accent);
}

[data-theme="dark"] :is(.site-header, .skip-link) {
    background: #14231bed;
    color: var(--theme-text);
    border-color: var(--theme-line);
}

[data-theme="dark"] :is(.site-header, .footer) .brand-name {
    color: var(--theme-text);
}

/* The phone preview keeps its own light palette. */
[data-theme="dark"] .phone-mockup {
    --green: #238b60;
    color: #1b3025;
}

[data-theme="dark"] :is(.floating-tag, .download-mini-card, .visual-pill) {
    background: var(--theme-raised);
    color: var(--theme-text);
    box-shadow: 0 8px 24px #08140d66;
}

[data-theme="dark"] :is(.nav-links > a:not(.btn), .btn-text, .hero-note, .hero-bottom, .download-caption, .tutorial-info p) {
    color: var(--theme-muted);
}

[data-theme="dark"] .menu-toggle {
    border-color: var(--theme-line);
}

[data-theme="dark"] .menu-toggle span {
    background: var(--theme-text);
}

[data-theme="dark"] .hero {
    background: linear-gradient(135deg, #101b16, #1a3024);
}

[data-theme="dark"] .hero-glow {
    background: radial-gradient(circle, #294e36, transparent 70%);
}

[data-theme="dark"] :is(.purpose-section, .tutorials-section, .feature-card, .donation-box, .download-platform, .tutorial-controls button) {
    background: var(--theme-surface);
    border-color: var(--theme-line);
}

[data-theme="dark"] :is(.features-section, .donation-section, .download-section) {
    background: var(--theme-background);
}

[data-theme="dark"] :is(.eyebrow, .mission, .independent-note, .independent-icon, .feature-large, .feature-icon) {
    background: var(--theme-raised);
    border-color: var(--theme-line);
    color: var(--theme-text);
}

[data-theme="dark"] :is(.mission p, .independent-note p, .download-platform p) {
    color: var(--theme-muted);
}

[data-theme="dark"] :is(.mission .card-index, .independent-note strong, .donation-box .donation-demo, .download-platform h3, .download-qr summary, .tutorial-loading, .tutorial-controls button, .media-placeholder, .feature-label) {
    color: var(--theme-accent);
}

[data-theme="dark"] .tutorial-loading::before {
    border-top-color: var(--theme-accent);
}

[data-theme="dark"] .tutorial-cover {
    background: var(--theme-raised);
}

[data-theme="dark"] .tutorial-card:nth-child(n) .tutorial-cover {
    background: var(--theme-raised);
}

[data-theme="dark"] :is(.hero-bottom, .footer-divider) {
    border-color: var(--theme-line);
}

[data-theme="dark"] .download-qr img {
    background: #fff;
}

[data-theme="dark"] .admin-page {
    background: var(--theme-background);
    color: var(--theme-text);
}

[data-theme="dark"] :is(.admin-card, .admin-report-table-card, .admin-report-gallery, .admin-form input, .admin-form select, .admin-report-filters select, .admin-report-tabs a, .admin-report-gallery-button, .admin-report-gallery button) {
    background: var(--theme-surface);
    color: var(--theme-text);
    border-color: var(--theme-line);
}

[data-theme="dark"] :is(.admin-form .admin-file, .admin-report-table thead, .admin-report-table tbody tr:hover, .admin-report-gallery-loading, .web-empty-state-icon) {
    background: var(--theme-raised);
    color: var(--theme-text);
}

[data-theme="dark"] :is(.admin-report-table td, .admin-report-table th, .admin-publications li) {
    border-color: var(--theme-line);
}

[data-theme="dark"] :is(.admin-report-table tbody th, .web-empty-state-title, .web-empty-state-action, .admin-report-detail summary) {
    color: var(--theme-accent);
}

[data-theme="dark"] :is(.admin-report-description, .admin-report-id, .admin-report-muted, .admin-report-page-disabled, .admin-media-grid p:not(.admin-error), .admin-media-grid small, .web-empty-state-description, .footer p) {
    color: var(--theme-muted);
}

[data-theme="dark"] .admin-report-tabs [aria-current="page"] {
    background: #c9ed7a;
    border-color: #c9ed7a;
    color: #123d2b;
}

[data-theme="dark"] .footer-brand > .brand-name {
    color: var(--theme-text);
}

[data-theme="dark"] .web-page {
    background: var(--theme-background);
    color: var(--theme-text);
}

[data-theme="dark"] .web-page .page-card {
    background: var(--theme-surface);
}

[data-theme="dark"] .web-not-found h1 {
    color: var(--theme-text);
}

[data-theme="dark"] .web-not-found-code {
    color: var(--theme-accent);
}

[data-theme="dark"] .web-not-found a {
    background: #c9ed7a;
    color: #123d2b;
}

[data-theme="dark"] .web-not-found a:hover {
    background: #b9df6a;
}

[data-theme="dark"] .admin-error {
    background: #422728;
    color: #ffd9d5;
    border: 1px solid #875052;
}

[data-theme="dark"] .web-theme-toggle:not([hidden]) {
    background: #c9ed7a;
    color: #123d2b;
    border-color: #c9ed7a;
}

[data-theme="dark"] .nav-links > a:is(:hover, :focus-visible) {
    color: #fff;
}

[data-theme="dark"] .web-page :is(.form-title, .status-title, .field label, .requirements-title, .input-wrapper input, .info-box strong) {
    color: var(--theme-text);
}

[data-theme="dark"] .web-page :is(.subtitle, .requirement-item, .toggle-password, .info-box p),
[data-theme="dark"] .web-page .input-wrapper input::placeholder {
    color: var(--theme-muted);
}

[data-theme="dark"] .web-page :is(.input-wrapper, .requirements, .info-box, .security-notice) {
    background: var(--theme-raised);
    border-color: var(--theme-line);
}

[data-theme="dark"] .web-page .input-wrapper:focus-within {
    border-color: var(--theme-accent);
}

[data-theme="dark"] .web-page :is(.input-icon, .toggle-password:hover, .requirement-item.met, .security-notice) {
    color: var(--theme-accent);
}

[data-theme="dark"] .web-page :is(.success-icon, .requirement-item.met .requirement-icon) {
    background: #193b2b;
    border-color: #508963;
    color: #cef5d8;
}

[data-theme="dark"] .web-page :is(.status-icon, .status-label, .alert-error) {
    background: #422728;
    border-color: #875052;
    color: #ffd9d5;
}

[data-theme="dark"] .web-page .error {
    color: #ffd9d5;
}
