/* Loaded last: restores Tenpo dark mode after final desktop/mobile styling overrides. */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1218;
    --bg-soft: #141d27;
    --bg-light: #1e2936;
    --surface: #121a24;
    --text: #f5f7fa;
    --muted: #b8c2cf;
    --border: rgba(255, 255, 255, .14);
}

html[data-theme="dark"] body {
    background: #0d1218 !important;
    color: #f5f7fa !important;
}

html[data-theme="dark"] .site-header,
html[data-theme="dark"] .masthead,
html[data-theme="dark"] .header-nav-row,
html[data-theme="dark"] .tempo-top-ad,
html[data-theme="dark"] .topic-ledger {
    background: #101923 !important;
    border-color: rgba(255, 255, 255, .12) !important;
}

html[data-theme="dark"] .masthead-product-nav a,
html[data-theme="dark"] .tempo-menu-trigger,
html[data-theme="dark"] .search-box,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .profile-button,
html[data-theme="dark"] .menu-btn {
    background: #172231 !important;
    border-color: rgba(255, 255, 255, .16) !important;
    color: #f5f7fa !important;
}

html[data-theme="dark"] .desktop-nav a,
html[data-theme="dark"] .masthead-product-nav a,
html[data-theme="dark"] .search-box input {
    color: #f5f7fa !important;
}

html[data-theme="dark"] .issue-cover__grid,
html[data-theme="dark"] .cover-story,
html[data-theme="dark"] .cover-index,
html[data-theme="dark"] .perspective-card,
html[data-theme="dark"] .aside-panel,
html[data-theme="dark"] .ledger-item,
html[data-theme="dark"] .latest-ledger .ledger-item,
html[data-theme="dark"] .newsletter-card,
html[data-theme="dark"] .article-content,
html[data-theme="dark"] .article-sidebar .sidebar-widget {
    background: #121a24 !important;
    border-color: rgba(255, 255, 255, .14) !important;
    color: #f5f7fa !important;
}

html[data-theme="dark"] .cover-story h1 a,
html[data-theme="dark"] .cover-index h2,
html[data-theme="dark"] .section-heading h2,
html[data-theme="dark"] .ledger-item h3,
html[data-theme="dark"] .article-content h1,
html[data-theme="dark"] .article-content h2,
html[data-theme="dark"] .article-content h3,
html[data-theme="dark"] .article-content h4 {
    color: #f5f7fa !important;
}

html[data-theme="dark"] .newsletter-card input,
html[data-theme="dark"] .mobile-search-panel,
html[data-theme="dark"] .mobile-search-panel input,
html[data-theme="dark"] .tempo-drawer__search,
html[data-theme="dark"] .tempo-drawer__search input {
    background: #0d1218 !important;
    border-color: rgba(255, 255, 255, .16) !important;
    color: #f5f7fa !important;
}

@media (max-width: 900px) {
    html[data-theme="dark"] .site-header,
    html[data-theme="dark"] .masthead,
    html[data-theme="dark"] .header-nav-row {
        background: #101923 !important;
        border-color: rgba(255, 255, 255, .12) !important;
    }

    html[data-theme="dark"] .header-actions .theme-toggle {
        align-items: center !important;
        display: inline-flex !important;
        justify-content: center !important;
    }

    html[data-theme="dark"] .mobile-bottom-nav,
    html[data-theme="dark"] .mobile-bottom-nav a,
    html[data-theme="dark"] .mobile-bottom-nav button {
        background: #101923 !important;
        border-color: rgba(255, 255, 255, .13) !important;
        color: #c7d1dc !important;
    }

    html[data-theme="dark"] #mobileNav .tempo-drawer__panel,
    html[data-theme="dark"] #mobileNav .tempo-drawer__head {
        background: #121a24 !important;
        border-color: rgba(255, 255, 255, .12) !important;
        color: #f5f7fa !important;
    }

    html[data-theme="dark"] #mobileNav .tempo-drawer__head strong,
    html[data-theme="dark"] #mobileNav .tempo-drawer__home,
    html[data-theme="dark"] #mobileNav .tempo-drawer__section a,
    html[data-theme="dark"] #mobileNav .tempo-drawer__section-title,
    html[data-theme="dark"] #mobileNav .tempo-drawer__label {
        color: #f5f7fa !important;
    }
}
