html[data-admin-theme="dark"] {
    color-scheme: dark;
    --accent: #C8C8C8;
    --accent-hover: #E2E2E2;
    --page-bg: #000000;
    --card-bg: #1F1F1F;
    --canvas: #000000;
    --text: #CCCCCC;
    --muted: #9D9D9D;
    --line: #3C3C3C;
    --hairline: #2B2B2B;
    --fill: #313131;
    --fill-hover: #3C3C3C;
    --fill-subtle: #222222;
    --focus-ring: 0 0 0 3px rgba(200, 200, 200, .28);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .32), 0 8px 24px rgba(0, 0, 0, .18);
    --shadow-raised: 0 16px 48px rgba(0, 0, 0, .48);
    --danger: #F85149;
    --danger-text: #F85149;
    --success-text: #3FB950;
    background: var(--page-bg);
    color: var(--text);
}

html[data-admin-theme="dark"] body {
    --page-bg: #000000;
    --canvas: #000000;
    --card-bg: #111111;
    --fill-subtle: #151515;
    --fill: #202020;
    --fill-hover: #272727;
    --hairline: #242424;
    --line: #333333;
}
html[data-admin-theme="dark"] .topbar,
html[data-admin-theme="dark"] .sidenav,
html[data-admin-theme="dark"] .dashboard-main,
html[data-admin-theme="dark"] .dashboard-shell { background: #000000 !important; }
html[data-admin-theme="dark"] .admin-sidebar:is(.is-hover-expanded, :hover, :focus-within) { background: #090909 !important; }

.theme-toggle {
    height: 30px !important;
    min-height: 30px !important;
    gap: 7px;
    padding: 0 11px !important;
    border: 1px solid var(--line) !important;
}
.theme-toggle-icon { width: 15px; height: 15px; flex: 0 0 15px; }
.theme-toggle-sun { display: none; }
html[data-admin-theme="dark"] .theme-toggle-moon { display: none; }
html[data-admin-theme="dark"] .theme-toggle-sun { display: block; }

html[data-admin-theme="dark"],
html[data-admin-theme="dark"] body,
html[data-admin-theme="dark"] .app-page,
html[data-admin-theme="dark"] .dashboard-shell,
html[data-admin-theme="dark"] .content,
html[data-admin-theme="dark"] .dashboard-main,
html[data-admin-theme="dark"] .login-page {
    background: var(--page-bg) !important;
    color: var(--text);
}

html[data-admin-theme="dark"] h1,
html[data-admin-theme="dark"] h2,
html[data-admin-theme="dark"] h3,
html[data-admin-theme="dark"] .page-title,
html[data-admin-theme="dark"] .brand-wordmark {
    color: #FFFFFF !important;
}

html[data-admin-theme="dark"] .topbar {
    border-color: var(--hairline) !important;
    background: rgba(0, 0, 0, .88) !important;
}
html[data-admin-theme="dark"] .sidenav { border-color: var(--hairline) !important; }
html[data-admin-theme="dark"] .admin-sidebar:is(.is-hover-expanded, :hover, :focus-within) {
    background: #090909 !important;
    box-shadow: 12px 0 30px rgba(0, 0, 0, .34) !important;
}
html[data-admin-theme="dark"] .admin-content-loading::before { background: rgba(24, 24, 24, .82); }
html[data-admin-theme="dark"] .admin-content-loading::after { border-color: #CCCCCC; border-top-color: transparent; }

html[data-admin-theme="dark"] .nav-link,
html[data-admin-theme="dark"] .nav-sub-link { color: var(--text); }
html[data-admin-theme="dark"] .nav-link:hover,
html[data-admin-theme="dark"] .nav-sub-link:hover,
html[data-admin-theme="dark"] .settings-module-link:hover { background: #2B2B2B; }
html[data-admin-theme="dark"] .nav-link.active,
html[data-admin-theme="dark"] .settings-module-link.active { background: #313131 !important; box-shadow: var(--shadow-card); }
html[data-admin-theme="dark"] .nav-sub-link.active { background: #3C3C3C; color: #FFFFFF; }
html[data-admin-theme="dark"] .nav-link.active svg,
html[data-admin-theme="dark"] .nav-sub-link.active .nav-sub-icon { color: #D7D7D7; }
html[data-admin-theme="dark"] .nav-badge,
html[data-admin-theme="dark"] .section-switcher .count,
html[data-admin-theme="dark"] .label { background: #313131; color: var(--muted); }

html[data-admin-theme="dark"] .btn { color: #181818; }
html[data-admin-theme="dark"] .btn:hover { color: #181818; }
html[data-admin-theme="dark"] .btn-default,
html[data-admin-theme="dark"] .btn-quiet { background: #313131 !important; color: #CCCCCC !important; }
html[data-admin-theme="dark"] .btn-default:hover,
html[data-admin-theme="dark"] .btn-quiet:hover { background: #3C3C3C !important; }
html[data-admin-theme="dark"] .btn-danger,
html[data-admin-theme="dark"] .btn-danger:hover { color: #FFFFFF; }
html[data-admin-theme="dark"] .playground-send { color: #181818; }

html[data-admin-theme="dark"] input,
html[data-admin-theme="dark"] select,
html[data-admin-theme="dark"] textarea,
html[data-admin-theme="dark"] .input,
html[data-admin-theme="dark"] .select,
html[data-admin-theme="dark"] .textarea,
html[data-admin-theme="dark"] .dashboard-select,
html[data-admin-theme="dark"] .playground-input,
html[data-admin-theme="dark"] .profile-form input,
html[data-admin-theme="dark"] .profile-form .input {
    border-color: #3C3C3C !important;
    background-color: #313131 !important;
    color: #CCCCCC !important;
}
html[data-admin-theme="dark"] input::placeholder,
html[data-admin-theme="dark"] textarea::placeholder { color: #989898 !important; }
html[data-admin-theme="dark"] :where(a, button, input, select, textarea):focus-visible {
    outline: 1px solid #C8C8C8 !important;
    outline-offset: 2px;
}
html[data-admin-theme="dark"] input:focus,
html[data-admin-theme="dark"] select:focus,
html[data-admin-theme="dark"] textarea:focus { border-color: #C8C8C8 !important; box-shadow: var(--focus-ring) !important; outline: none; }
html[data-admin-theme="dark"] input:disabled,
html[data-admin-theme="dark"] input[readonly] { background: #2B2B2B !important; color: #868686 !important; }
html[data-admin-theme="dark"] .switch-line input[type="checkbox"] {
    background-color: #3C3C3C !important;
}
html[data-admin-theme="dark"] .switch-line input[type="checkbox"]:checked {
    background-color: #C8C8C8 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23181818'/%3E%3C/svg%3E");
}

html[data-admin-theme="dark"] .dashboard-card,
html[data-admin-theme="dark"] .profile-card,
html[data-admin-theme="dark"] .profile-meta-item,
html[data-admin-theme="dark"] .summary-block,
html[data-admin-theme="dark"] .panel,
html[data-admin-theme="dark"] .jarviswidget,
html[data-admin-theme="dark"] .card,
html[data-admin-theme="dark"] .login-card,
html[data-admin-theme="dark"] .model-editor,
html[data-admin-theme="dark"] .drawer,
html[data-admin-theme="dark"] .playground-settings,
html[data-admin-theme="dark"] .plan-form,
html[data-admin-theme="dark"] .setup-card,
html[data-admin-theme="dark"] .paypal-checkout {
    border-color: var(--hairline) !important;
    background: var(--card-bg) !important;
    color: var(--text);
    box-shadow: var(--shadow-card);
}

html[data-admin-theme="dark"] .section-switcher { background: #2B2B2B; }
html[data-admin-theme="dark"] .section-switcher button { color: var(--text); }
html[data-admin-theme="dark"] .section-switcher button:hover { color: #FFFFFF; }
html[data-admin-theme="dark"] .section-switcher button.active { background: #3C3C3C; color: #FFFFFF; }
html[data-admin-theme="dark"] .section-switcher button.active .count { background: #616161; color: #FFFFFF; }

html[data-admin-theme="dark"] .editor-actions,
html[data-admin-theme="dark"] .playground-composer { background: rgba(31, 31, 31, .9); }
html[data-admin-theme="dark"] .profile-password-grid { background: #222222; }
html[data-admin-theme="dark"] .paypal-checkout-close,
html[data-admin-theme="dark"] .playground-settings-close { background: #313131; color: var(--text); }
html[data-admin-theme="dark"] .profile-avatar { background: #C8C8C8; color: #181818; }

html[data-admin-theme="dark"] th,
html[data-admin-theme="dark"] td { border-color: var(--hairline) !important; }
html[data-admin-theme="dark"] tbody tr:hover,
html[data-admin-theme="dark"] tbody tr:hover td { background: #252525 !important; }
html[data-admin-theme="dark"] .state-box { border-color: #3C3C3C; }
html[data-admin-theme="dark"] .metadata,
html[data-admin-theme="dark"] .playground-model-logo,
html[data-admin-theme="dark"] .playground-empty-mark,
html[data-admin-theme="dark"] .playground-avatar,
html[data-admin-theme="dark"] .playground-msg-user { background: #313131; }
html[data-admin-theme="dark"] .playground-typing i { background: #9D9D9D; }

html[data-admin-theme="dark"] .modal-backdrop,
html[data-admin-theme="dark"] .drawer-backdrop { background: rgba(0, 0, 0, .58); }
html[data-admin-theme="dark"] .playground-settings-backdrop { background: rgba(0, 0, 0, .42); }

html[data-admin-theme="dark"] .profile-notice.success,
html[data-admin-theme="dark"] .dashboard-error.profile-success,
html[data-admin-theme="dark"] .notice.success,
html[data-admin-theme="dark"] .gift-success { background: rgba(46, 160, 67, .16); color: #56D364; }
html[data-admin-theme="dark"] .profile-notice.error,
html[data-admin-theme="dark"] .dashboard-error,
html[data-admin-theme="dark"] .notice.error,
html[data-admin-theme="dark"] .login-error,
html[data-admin-theme="dark"] .error-box { background: rgba(248, 81, 73, .14); color: #FF7B72; }
html[data-admin-theme="dark"] .label-info { background: #3C3C3C; color: #D7D7D7; }
html[data-admin-theme="dark"] .label-warning { color: #FFA657; }
html[data-admin-theme="dark"] .label-on,
html[data-admin-theme="dark"] .label-admin,
html[data-admin-theme="dark"] .verified,
html[data-admin-theme="dark"] .profile-status { color: #56D364 !important; }

html[data-admin-theme="dark"] ::selection { background: rgba(200, 200, 200, .34); }

@media (max-width: 700px) {
    .theme-toggle-label { display: none; }
    .theme-toggle { width: 30px; padding: 0 !important; }
}

@media (prefers-reduced-motion: no-preference) {
    body, .topbar, .sidenav, .content, .dashboard-main, .dashboard-card, .profile-card, .summary-block, .panel, .jarviswidget, .card {
        transition: color .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
    }
}
