/*
 * Dark theme is intentionally isolated in this file and loaded after both the
 * global and CSS-isolated component styles. The light theme remains unchanged.
 */

:root[data-bs-theme="dark"] {
    color-scheme: dark;

    --vs-color-canvas: #0b1120;
    --vs-color-canvas-soft: #0f172a;
    --vs-color-surface: #111827;
    --vs-color-surface-raised: #182235;
    --vs-color-surface-subtle: #172033;
    --vs-color-text: #e5edf8;
    --vs-color-text-strong: #f8fafc;
    --vs-color-text-secondary: #cbd5e1;
    --vs-color-text-muted: #94a3b8;
    --vs-color-border: #2a3850;
    --vs-color-control-border: #3a4a63;
    --vs-color-primary: #60a5fa;
    --vs-color-primary-hover: #93c5fd;
    --vs-color-primary-focus: #2563eb;
    --vs-color-success: #34d399;
    --vs-color-danger: #fca5a5;
    --vs-shadow-card: 0 10px 28px rgba(0, 0, 0, 0.24);
    --vs-shadow-primary: 0 8px 22px rgba(37, 99, 235, 0.3);
    --vs-focus-primary: 0 0 0 4px rgba(96, 165, 250, 0.2);

    --bs-body-color: #e5edf8;
    --bs-body-color-rgb: 229, 237, 248;
    --bs-body-bg: #0b1120;
    --bs-body-bg-rgb: 11, 17, 32;
    --bs-emphasis-color: #f8fafc;
    --bs-emphasis-color-rgb: 248, 250, 252;
    --bs-secondary-color: #cbd5e1;
    --bs-secondary-color-rgb: 203, 213, 225;
    --bs-secondary-bg: #172033;
    --bs-secondary-bg-rgb: 23, 32, 51;
    --bs-tertiary-color: #94a3b8;
    --bs-tertiary-bg: #182235;
    --bs-border-color: #2a3850;
    --bs-border-color-translucent: rgba(226, 232, 240, 0.16);
    --bs-link-color: #93c5fd;
    --bs-link-color-rgb: 147, 197, 253;
    --bs-link-hover-color: #bfdbfe;
    --bs-link-hover-color-rgb: 191, 219, 254;
}

/* Theme switch */
.theme-toggle {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 0 14px;
    border: 1px solid #cbd8eb;
    border-radius: 10px;
    background: #fff;
    color: #233451;
    font: inherit;
    font-size: 14px;
    font-weight: 750;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover {
    border-color: #9fb4d1;
    background: #f5f8fd;
}

.theme-toggle:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.theme-toggle--compact {
    width: 42px;
    min-width: 42px;
    padding: 0;
}

.theme-toggle__icon {
    font-size: 18px;
}

/* Keep the running pre-rebuild markup visually aligned with Bootstrap Icons. */
.theme-toggle__icon:not(.bi) {
    font-size: 0;
}

.theme-toggle__icon--dark:not(.bi)::before,
.theme-toggle__icon--light:not(.bi)::before {
    display: inline-block;
    font-family: bootstrap-icons !important;
    font-size: 18px;
    font-style: normal;
    font-weight: 400 !important;
    line-height: 1;
}

.theme-toggle__icon--dark:not(.bi)::before {
    content: "\f497";
}

.theme-toggle__icon--light:not(.bi)::before {
    content: "\f1d2";
}

.theme-toggle__icon--light,
.theme-toggle__label--light {
    display: none;
}

.theme-toggle--menu {
    width: 100%;
    justify-content: flex-start;
    margin-bottom: 4px;
}

[data-bs-theme="dark"] .theme-toggle {
    border-color: #3a4a63;
    background: #182235;
    color: #e5edf8;
}

[data-bs-theme="dark"] .theme-toggle:hover {
    border-color: #526783;
    background: #202c42;
    color: #fff;
}

[data-bs-theme="dark"] .theme-toggle__icon--dark,
[data-bs-theme="dark"] .theme-toggle__label--dark {
    display: none;
}

[data-bs-theme="dark"] .theme-toggle__icon--light,
[data-bs-theme="dark"] .theme-toggle__label--light {
    display: inline-block;
}

/* Page shells and navigation */
[data-bs-theme="dark"] body,
[data-bs-theme="dark"] .page,
[data-bs-theme="dark"] .public-page-shell,
[data-bs-theme="dark"] .main-content,
[data-bs-theme="dark"] .content,
[data-bs-theme="dark"] .home-hero-section,
[data-bs-theme="dark"] .home-copy-section,
[data-bs-theme="dark"] .voice-section,
[data-bs-theme="dark"] .voice-demo-page,
[data-bs-theme="dark"] .blog-page,
[data-bs-theme="dark"] .blog-article-page,
[data-bs-theme="dark"] .tts-page,
[data-bs-theme="dark"] .stt-page,
[data-bs-theme="dark"] .balance-page,
[data-bs-theme="dark"] .support-page,
[data-bs-theme="dark"] .admin-page {
    background-color: var(--vs-color-canvas) !important;
    color: var(--vs-color-text);
}

[data-bs-theme="dark"] .sidebar,
[data-bs-theme="dark"] .topbar,
[data-bs-theme="dark"] .home-public-header,
[data-bs-theme="dark"] .mobile-app-nav {
    border-color: var(--vs-color-border) !important;
    background: rgba(17, 24, 39, 0.96) !important;
    color: var(--vs-color-text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .home-public-brand,
[data-bs-theme="dark"] .home-public-nav a,
[data-bs-theme="dark"] .home-public-mobile-menu a,
[data-bs-theme="dark"] .topbar-title,
[data-bs-theme="dark"] .sidebar-brand-text {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .home-public-login,
[data-bs-theme="dark"] .home-public-mobile-menu summary,
[data-bs-theme="dark"] .home-public-mobile-menu > div {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] .home-public-mobile-menu a:hover {
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] .site-footer {
    background: #070c16 !important;
    color: var(--vs-color-text-secondary);
}

[data-bs-theme="dark"] .site-footer a {
    color: var(--vs-color-text-secondary) !important;
}

/* Typography */
[data-bs-theme="dark"] :where(h1, h2, h3, h4, h5, h6, legend),
[data-bs-theme="dark"] :where([class$="-title"], [class*="-title "], [class$="__title"], [class*="__title "], [class$="-heading"], [class*="-heading "]) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(p, label, dt, dd, li, th, td),
[data-bs-theme="dark"] :where([class$="-subtitle"], [class*="-subtitle "], [class$="-description"], [class*="-description "]) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where([class$="-meta"], [class*="-meta "], [class$="-hint"], [class*="-hint "], [class$="-note"], [class*="-note "]) {
    color: var(--vs-color-text-muted) !important;
}

[data-bs-theme="dark"] a:not(.btn):not([class*="primary"]):not([class*="danger"]) {
    color: #93c5fd;
}

/* Reusable surfaces */
[data-bs-theme="dark"] :where(
    [class$="-card"], [class*="-card "], [class$="__card"], [class*="__card "],
    [class$="-panel"], [class*="-panel "], [class$="__panel"], [class*="__panel "],
    [class$="-section"], [class*="-section "],
    [class$="-box"], [class*="-box "],
    [class$="-item"], [class*="-item "],
    [class$="-sheet"], [class*="-sheet "],
    [class$="-dialog"], [class*="-dialog "],
    .modal-content, .dropdown-menu, .list-group-item, .accordion-item
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(
    [class$="-header"], [class*="-header "],
    [class$="-footer"], [class*="-footer "],
    [class$="-toolbar"], [class*="-toolbar "]
) {
    border-color: var(--vs-color-border) !important;
}

[data-bs-theme="dark"] :where(.table, table) {
    --bs-table-color: var(--vs-color-text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--vs-color-border);
    --bs-table-striped-color: var(--vs-color-text);
    --bs-table-striped-bg: rgba(148, 163, 184, 0.06);
    --bs-table-hover-color: var(--vs-color-text-strong);
    --bs-table-hover-bg: rgba(96, 165, 250, 0.09);
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(table thead, .admin-table thead) {
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] :where(table th, table td, .admin-table-wrap) {
    border-color: var(--vs-color-border) !important;
}

[data-bs-theme="dark"] .blog-article-body table {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] .blog-article-body th {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .blog-article-body td {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
}

/* Forms and interactive controls */
[data-bs-theme="dark"] :where(input, textarea, select, .form-control, .form-select) {
    border-color: var(--vs-color-control-border) !important;
    background-color: var(--vs-color-canvas-soft) !important;
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(input, textarea)::placeholder {
    color: #8493a9 !important;
    opacity: 1;
}

[data-bs-theme="dark"] :where(input, textarea, select, .form-control, .form-select):focus {
    border-color: var(--vs-color-primary) !important;
    background-color: var(--vs-color-surface) !important;
    color: var(--vs-color-text-strong) !important;
    box-shadow: var(--vs-focus-primary) !important;
}

/* Composite searches draw their surface on the wrapper, not on the nested input. */
[data-bs-theme="dark"] :where(.catalog-search, .voice-search, .folder-search) input,
[data-bs-theme="dark"] :where(.catalog-search, .voice-search, .folder-search) input:focus {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
}

[data-bs-theme="dark"] :where(.catalog-search, .voice-search, .folder-search):focus-within {
    border-color: var(--vs-color-primary) !important;
    box-shadow: var(--vs-focus-primary) !important;
}

[data-bs-theme="dark"] :where(input, textarea, select, button):disabled,
[data-bs-theme="dark"] :where(.disabled, [aria-disabled="true"]) {
    border-color: #2a3548 !important;
    background-color: #151d2c !important;
    color: #78869a !important;
    opacity: 1;
}

[data-bs-theme="dark"] :where(.btn-light, .btn-outline-secondary, .secondary-btn, [class*="secondary-btn"], [class*="clear-btn"], [class*="settings-btn"]) {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.btn-primary, .primary-btn, [class*="primary-btn"], [class*="generate-btn"], [class*="pay-btn"]) {
    color: #fff !important;
}

[data-bs-theme="dark"] .stt-page .primary-btn:disabled {
    background: #1c283b !important;
    color: #a8b5c8 !important;
}

[data-bs-theme="dark"] :where(
    .home-auth-btn-secondary,
    .blog-tags a, .blog-card-tags span, .blog-header-badge, .blog-pagination a,
    .model-btn1, .model-btn2, .model-btn3, .model-btn4, .model-btn5,
    .voice-btn, .favorite-folder-btn, .voice-preview-play-btn
) {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] .favorite-folder-btn > span:last-child {
    background: #4a1d2a !important;
    color: #fecdd3 !important;
}

[data-bs-theme="dark"] :where(
    .model-btn1.active, .model-btn2.active, .model-btn3.active,
    .model-btn4.active, .model-btn5.active,
    .voice-btn.active,
    .blog-tags a.active, .blog-pagination a.active
) {
    border-color: #60a5fa !important;
    background: #203253 !important;
    color: #bfdbfe !important;
}

[data-bs-theme="dark"] .voice-preview-main-btn,
[data-bs-theme="dark"] .voice-preview-main-btn-active {
    border-color: transparent !important;
    background: transparent !important;
    color: inherit !important;
}

[data-bs-theme="dark"] .voice-preview-main-text {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .voice-preview-item:hover {
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] .voice-preview-item:has(.voice-preview-main-btn-active) {
    border-color: #60a5fa !important;
    background: #203253 !important;
}

[data-bs-theme="dark"] .voice-preview-main-btn-active .voice-preview-main-text {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(.topup-option, .admin-tab, .account-manage-link) {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.topup-option.selected, .admin-tab.active, .account-manage-link.active) {
    border-color: #60a5fa !important;
    background: #203253 !important;
    color: #bfdbfe !important;
}

[data-bs-theme="dark"] :where(button, a):focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

/* Navigation, lists and overlays */
[data-bs-theme="dark"] .sidebar-section-title,
[data-bs-theme="dark"] .nav-link,
[data-bs-theme="dark"] .mobile-app-nav a,
[data-bs-theme="dark"] .mobile-app-nav button {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .nav-link:hover,
[data-bs-theme="dark"] .nav-link.active,
[data-bs-theme="dark"] .mobile-app-nav .active {
    background: #1e2b42 !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] :where(.sidebar-header, .nav-scrollable, .sidebar-nav) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
}

[data-bs-theme="dark"] .sidebar-promo {
    border-color: #314768 !important;
    background: #16253c !important;
}

[data-bs-theme="dark"] .sidebar-promo-title {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .sidebar-promo-text {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .sidebar-promo-btn,
[data-bs-theme="dark"] .sidebar-promo-btn:hover {
    background: #2563eb !important;
    color: #fff !important;
}

[data-bs-theme="dark"] :where(.modal-backdrop, [class*="-backdrop"]) {
    background-color: rgba(2, 6, 23, 0.72) !important;
}

[data-bs-theme="dark"] :where(.modal-content, [class$="-modal"], [class*="-modal "]) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text);
}

[data-bs-theme="dark"] .site-news-title {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .site-news-text {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .site-news-text a {
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .site-news-text a:hover {
    color: #bfdbfe !important;
}

[data-bs-theme="dark"] .site-news-close {
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .site-news-close:hover {
    background: #1e2b42 !important;
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(.mobile-app-more-sheet, .tts-mobile-sheet) {
    background: var(--vs-color-surface) !important;
}

[data-bs-theme="dark"] :where(
    .tts-mobile-header, .tts-mobile-action-bar, .tts-mobile-bottom-nav,
    .tts-player-card, .tts-player-empty, .tts-player-wave,
    .tts-player-controls button, .tts-player-speed
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.tts-mobile-brand, .tts-mobile-brand strong, .tts-mobile-brand span) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(
    .tts-mobile-header > strong,
    .tts-mobile-sheet > header strong,
    .tts-voice-panel-mobile-header strong,
    .tts-mobile-balance-card strong,
    .tts-mobile-balance-models > span strong
) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(
    .tts-mobile-sheet > header span,
    .tts-voice-panel-mobile-header span,
    .tts-mobile-balance-card small,
    .tts-mobile-balance-models > span small,
    .tts-mobile-voice-pill small
) {
    color: var(--vs-color-text-muted) !important;
}

[data-bs-theme="dark"] :where(.tts-mobile-voice-pill, .tts-mobile-settings-btn) {
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.tts-player-empty, .tts-player-wave) {
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] :where(
    .mobile-app-balance-models > span,
    .tts-mobile-balance-models > span
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.mobile-app-logout, .tts-mobile-logout) {
    border-color: #7f1d1d !important;
    background: #32171d !important;
    color: #fecaca !important;
}

[data-bs-theme="dark"] :where(.mobile-app-sheet-handle, .tts-mobile-sheet-handle) {
    background: #526078 !important;
}

.mobile-app-theme-row,
.tts-mobile-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #e3e9f2;
    border-radius: 12px;
    background: #fafbfd;
    color: #40506a;
    font-size: 12px;
    font-weight: 750;
}

[data-bs-theme="dark"] :where(.mobile-app-theme-row, .tts-mobile-theme-row) {
    border-color: var(--vs-color-border);
    background: var(--vs-color-surface-raised);
    color: var(--vs-color-text-secondary);
}

/* Statuses retain their meaning while remaining readable on dark surfaces. */
[data-bs-theme="dark"] :where(.alert-success, [class*="success"], [class*="completed"]) {
    border-color: #166534 !important;
    background-color: #0d2a21 !important;
    color: #a7f3d0 !important;
}

[data-bs-theme="dark"] :where(.alert-danger, [class*="error"], [class*="failed"], [class*="danger"]) {
    border-color: #7f1d1d !important;
    background-color: #32171d !important;
    color: #fecaca !important;
}

[data-bs-theme="dark"] :where(.alert-warning, [class*="warning"], [class*="pending"]) {
    border-color: #854d0e !important;
    background-color: #30230f !important;
    color: #fde68a !important;
}

[data-bs-theme="dark"] :where(.alert-info, [class*="info-box"], [class*="billing-note"]) {
    border-color: #1e5f8f !important;
    background-color: #102a43 !important;
    color: #bae6fd !important;
}

/* Page-specific layers with large light backgrounds. */
[data-bs-theme="dark"] :where(
    .home-hero-screen, .home-hero-player, .home-top-card, .home-info-card,
    .home-grouped-block, .home-use-cases-panel, .home-voices-panel,
    .voice-browser-pane, .voice-wave-shell, .preview-player,
    .blog-card, .blog-empty, .blog-article-body,
    .tts-workspace, .tts-compose-card, .tts-voice-panel, .tts-player-panel, .tts-tips,
    .tts-mobile-editor-shell, .stt-section, .upload-area, .billing-panel,
    .balance-state-card, .balance-info-card, .promo-code-box,
    .support-chat, .support-new-card, .support-thread-item,
    .admin-section, .admin-stat-card, .admin-model-card, .admin-tab-content,
    .manage-card, .account-card, .legal-page
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
    box-shadow: var(--vs-shadow-card) !important;
}

[data-bs-theme="dark"] :where(.blog-card-image, .blog-article-image) {
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-muted) !important;
}

[data-bs-theme="dark"] :where(
    .tts-overview, .tts-model-info, .voice-search, .folder-search,
    .tts-advanced-player, .advanced-audio-player,
    .tts-speech-settings, .tts-pro-model-settings,
    .tts-mobile-generation-state
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.speed-btn, .pause-btn) {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.speed-btn, .pause-btn):hover:not(:disabled) {
    border-color: #54709a !important;
    background: #1e2b42 !important;
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .speed-btn.active {
    border-color: var(--vs-color-primary) !important;
    background: #203253 !important;
    color: #bfdbfe !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.14) !important;
}

[data-bs-theme="dark"] :where(
    .tts-overview-balance, .tts-overview-models, .tts-overview-last,
    .tts-last-copy, .tts-player-panel > header
) {
    border-color: var(--vs-color-border) !important;
}

[data-bs-theme="dark"] :where(
    .tts-top-card-title, .tts-balance-value, .tts-overview-model strong,
    .tts-last-meta, .tts-last-meta strong, .tts-last-empty,
    .tts-model-info, .tts-model-info-short, .tts-model-info summary,
    .tts-tips summary, .tts-tips-content, .tts-tips-content p,
    .tts-voice-info-name, .model-multiplier, .text-counter
) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .tts-tips-content h3 {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .text-price {
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .tts-step-badge {
    background: #203253 !important;
    color: #bfdbfe !important;
}

[data-bs-theme="dark"] :where(
    .balance-model-name, .balance-model-value,
    .billing-row, .billing-row strong,
    .field-label, .toggle-row,
    .result-text, .empty-result,
    .admin-stat-title, .admin-stat-value, .admin-stat-sub,
    .elevenlabs-balance-state
) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.upload-text, .balance-top-card-text) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.billing-total strong, .main-balance-value) {
    color: #60a5fa !important;
}

[data-bs-theme="dark"] :where(.elevenlabs-balance-state, .admin-empty-state) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] :where(.last-voice-download-btn, .favorite-back-btn) {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] .tts-overview-model.model-one span {
    background: #3a1b2a !important;
    color: #fda4af !important;
}

[data-bs-theme="dark"] .tts-overview-model.model-two span {
    background: #2e2050 !important;
    color: #c4b5fd !important;
}

[data-bs-theme="dark"] .tts-overview-model.model-three span {
    background: #12352e !important;
    color: #6ee7b7 !important;
}

[data-bs-theme="dark"] .tts-overview-model.model-four span {
    background: #263246 !important;
    color: #dbeafe !important;
}

[data-bs-theme="dark"] .tts-overview-model.model-five span {
    background: #28351d !important;
    color: #bef264 !important;
}

[data-bs-theme="dark"] :where(
    .home-card-section, .home-cta-section, .home-speech-recognition-section,
    .voice-browser-section, .audio-section
) {
    background-color: var(--vs-color-canvas-soft) !important;
}

[data-bs-theme="dark"] :where(
    .home-hero-copy, .home-top-card-text, .home-info-card,
    .voice-demo-subtitle, .voice-preview-main-text,
    .blog-header, .blog-card-content, .blog-article-body,
    .tts-card-heading, .tts-field-heading, .tts-model-info,
    .balance-state-text, .support-info, .admin-section-header
) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(
    .home-hero-copy h1, .section-title, .home-panel-heading,
    .voice-demo-title, .voice-browser-heading, .voice-wave-name,
    .blog-header h1, .blog-card h2, .blog-article-body h1, .blog-article-body h2,
    .tts-card-heading h1, .tts-card-heading h2, .tts-text-heading,
    .balance-title, .support-header h1, .admin-header h1
) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(.progress, [class*="progress"]:not([class*="value"])) {
    background-color: #26334a !important;
}

/* Voice catalog */
[data-bs-theme="dark"] .catalog-hero {
    border-color: var(--vs-color-border) !important;
    background:
        radial-gradient(circle at 92% 0%, rgba(96, 165, 250, 0.14), transparent 36%),
        linear-gradient(135deg, #111827 0%, #172033 100%) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] .catalog-search,
[data-bs-theme="dark"] .catalog-tag-group,
[data-bs-theme="dark"] :where(.catalog-tag-group a, .catalog-tag-results a, .catalog-tag-result-current),
[data-bs-theme="dark"] :where(.catalog-back, .catalog-show-all, .catalog-state, .catalog-empty) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.catalog-hero p, .catalog-section-heading span, .catalog-tag-description, .catalog-tag-group h3) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.catalog-tag-group small, .catalog-tag-results small, .catalog-tag-result-current small) {
    color: var(--vs-color-text-muted) !important;
}

[data-bs-theme="dark"] .catalog-section-heading strong {
    background: #203253 !important;
    color: #bfdbfe !important;
}

/* Generated audio history */
[data-bs-theme="dark"] :where(.history-player-shell, .history-task-progress) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] :where(.history-value, .history-voice-name, .myvoices-top-card-title) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(
    .history-label, .history-text, .history-wave-meta,
    .myvoices-top-card-text, .myvoices-subtitle,
    .history-task-progress small
) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .history-text-field {
    border-color: var(--vs-color-border) !important;
}

[data-bs-theme="dark"] .history-file-actions a {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .history-file-missing {
    background: #32171d !important;
    color: #fecaca !important;
}

[data-bs-theme="dark"] .showmore-btn {
    background: #2563eb !important;
    color: #fff !important;
}

/* Support */
[data-bs-theme="dark"] :where(.support-threads, .support-empty) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.support-thread-title, .support-message-author, .support-message-text) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(.support-thread-meta, .support-chat-header p, .support-message-date, .support-form-bottom span) {
    color: var(--vs-color-text-muted) !important;
}

[data-bs-theme="dark"] :where(.support-message, .support-message.admin) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] .support-message.user {
    border-color: #31548a !important;
    background: #203253 !important;
}

[data-bs-theme="dark"] .support-info {
    border-color: #166534 !important;
    background: #0d2a21 !important;
    color: #a7f3d0 !important;
}

/* Prices */
[data-bs-theme="dark"] .prices-hero {
    border-color: var(--vs-color-border) !important;
    background: linear-gradient(135deg, #111827 0%, #172033 100%) !important;
    color: var(--vs-color-text) !important;
    box-shadow: var(--vs-shadow-card) !important;
}

[data-bs-theme="dark"] :where(
    .prices-hero-text, .info-card-text, .state-text,
    .prices-note-text, .seo-text, .example-text, .package-subtitle
) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(
    .info-card-title, .section-title, .example-value,
    .package-symbols, .package-model-value, .coefficient-value
) {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(.package-model-name, .coefficient-name) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.example-box, .package-model-row, .coefficient-item) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
}

[data-bs-theme="dark"] .package-price {
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .coefficient-expiration {
    color: #34d399 !important;
}

/* Account */
[data-bs-theme="dark"] .account-email-top-card-text {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .email-confirmed-badge {
    background: #0d2a21 !important;
    color: #a7f3d0 !important;
}

[data-bs-theme="dark"] .primary-action-btn {
    background: #2563eb !important;
    color: #fff !important;
}

[data-bs-theme="dark"] :where(.catalog-tag-group a:hover, .catalog-tag-group a.active, .catalog-tag-results a:hover, .catalog-tag-result-current) {
    border-color: #60a5fa !important;
    background: #203253 !important;
    color: #bfdbfe !important;
}

[data-bs-theme="dark"] .favorite-voices-hero {
    border-color: var(--vs-color-border) !important;
    background:
        radial-gradient(circle at 92% 0%, rgba(244, 114, 182, 0.11), transparent 36%),
        linear-gradient(135deg, #111827 0%, #25182b 100%) !important;
    color: var(--vs-color-text) !important;
}

[data-bs-theme="dark"] .favorite-voices-hero > span {
    color: #f0abcf !important;
}

[data-bs-theme="dark"] .favorite-voices-hero p {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(
    .favorite-voices-section, .favorite-voices-state,
    .favorite-voices-empty, .favorite-voices-show-all
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .favorite-voices-empty strong {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] :where(.catalog-folder, .catalog-model) {
    background: #203253 !important;
    color: #bfdbfe !important;
}

[data-bs-theme="dark"] :where(.catalog-card-tags a, .catalog-card-tags span) {
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(
    .catalog-player-preview, .catalog-active-player, .catalog-no-audio
) {
    border-color: var(--vs-color-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.catalog-wave-meta, .catalog-player-preview small) {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .catalog-description-toggle {
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .catalog-favorite-button {
    border-color: var(--vs-color-control-border) !important;
    background: var(--vs-color-surface-raised) !important;
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] .catalog-favorite-button:hover:not(:disabled) {
    border-color: #54709a !important;
    background: #1e2b42 !important;
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .catalog-favorite-button.active {
    border-color: #7f1d1d !important;
    background: #32171d !important;
    color: #fecaca !important;
}

/* Speech history */
[data-bs-theme="dark"] .history-file {
    color: var(--vs-color-text-strong) !important;
}

[data-bs-theme="dark"] .history-date {
    color: var(--vs-color-text-secondary) !important;
}

[data-bs-theme="dark"] :where(.history-badge, .history-model) {
    border-color: #365177 !important;
    background: #203253 !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] :where(hr, .divider, [class*="divider"]) {
    border-color: var(--vs-color-border) !important;
    color: var(--vs-color-border) !important;
}

[data-bs-theme="dark"] #blazor-error-ui {
    border-top: 1px solid #7f1d1d;
    background: #32171d;
    color: #fecaca;
}

@media (max-width: 920px) {
    .theme-toggle--menu {
        min-height: 44px;
    }
}
