:root { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
html[data-theme="dark"] body { background: #050608 !important; color: #e2e8f0; }
html[data-theme="dark"] :is([class~="bg-[#1e293b]"], [class~="bg-slate-800"], [class~="bg-slate-800/50"], [class~="bg-slate-800/80"]) { background-color: #111318 !important; }
html[data-theme="dark"] :is([class~="bg-[#0f172a]"], [class~="bg-[#0f172a]/50"], [class~="bg-[#1e293b]/50"]) { background-color: #090b0f !important; }
html[data-theme="dark"] [class~="bg-[#0f172a]/95"] { background-color: #07090bf2 !important; }
html[data-theme="dark"] :is([class~="from-[#1e293b]"], [class~="from-[#0f172a]"]) { background-image: linear-gradient(145deg, #14171c, #080a0d) !important; }
html[data-theme="dark"] :is(.border-slate-700, .border-slate-600) { border-color: #2a303a !important; }
html[data-theme="dark"] :is(.preferences-card, .home-install, .app-toolbar button, #app-install-help) { background: #111318; border-color: #2a303a; }
html[data-theme="dark"] .preference-option { background: #090b0f; border-color: #2a303a; }
html[data-theme="dark"] .ev { --ev-bg: #090b0f; --ev-card: #111318; --ev-line: #2a303a; }
html[data-theme="dark"] .ev .ev-messages { background: #080a0d; }
html[data-theme="dark"] .ev button:not(.ev-primary):not(.ev-recording) { background: #1b2028; }
html[data-theme="dark"] .ev button:not(.ev-primary):not(.ev-recording):hover { background: #272e39; }
html[data-voice="false"] #orbe-global,
html[data-history="false"] .sidebar-history,
html[data-install="false"] #app-install,
html[data-install="false"] #home-install,
html[data-install="false"] #app-install-help { display: none !important; }

/* Capas decorativas: no reciben clics ni cubren controles. */
html:is([data-theme="dark"], [data-theme="original"])[data-space="true"] body::before {
    content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background: radial-gradient(ellipse at 85% 8%, #9bbcff13, transparent 35%), radial-gradient(ellipse at 10% 55%, #38bdf80b, transparent 40%), radial-gradient(ellipse at 75% 90%, #10b98108, transparent 35%);
}
html:is([data-theme="dark"], [data-theme="original"])[data-space="true"] body::after {
    content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
    background-image: radial-gradient(1px 1px at 25px 35px, #e0f2fe 95%, transparent), radial-gradient(1px 1px at 140px 100px, #9dbfff 95%, transparent), radial-gradient(.7px .7px at 80px 180px, #fff 95%, transparent), radial-gradient(1.5px 1.5px at 290px 75px, #c7e4ff 60%, transparent), radial-gradient(.7px .7px at 180px 250px, #94a3b8 95%, transparent);
    background-size: 317px 283px, 431px 397px, 239px 347px, 587px 463px, 379px 509px;
    animation: star-breathe 12s ease-in-out infinite alternate;
}
@keyframes star-breathe { from { opacity: .35; } to { opacity: .65; } }
.space-moon { display: none; }
html:is([data-theme="dark"], [data-theme="original"])[data-space="true"] .space-moon {
    display: block; position: fixed; right: 26px; top: 86px; width: 96px; height: 96px;
    border-radius: 50%; pointer-events: none; user-select: none; z-index: 0; opacity: .22;
    background: radial-gradient(circle at 38% 32%, #7b8494 0 7%, transparent 8%), radial-gradient(circle at 65% 57%, #727d90 0 11%, transparent 12%), radial-gradient(circle at 32% 68%, #8c96a7 0 6%, transparent 7%), radial-gradient(circle at 48% 48%, #cbd5e1, #94a3b8 70%);
    box-shadow: inset -24px -10px 18px #03050bd9, inset 3px 2px 7px #f8fafc66, 0 0 38px 8px #adcaff18;
}

.preferences-card { position: relative; padding: 24px; background: #1e293be6; border: 1px solid #334155; border-radius: 24px; }
html[data-theme="dark"][data-space="true"] .preferences-card { background: radial-gradient(ellipse at top right, #38bdf80a, transparent 60%), #111318; box-shadow: 0 0 32px #38bdf808; }
.preferences-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.preferences-heading h2 { color: #f8fafc; font-size: 22px; font-weight: 700; margin: 8px 0; }
.preferences-heading p, .preferences-footer p { color: #94a3b8; font-size: 13px; line-height: 1.6; }
.preferences-heading > i { color: #7dd3fc; font-size: 52px; }
.preferences-badge { color: #6ee7b7; font-size: 12px; }
.preference-theme { cursor: default; flex-wrap: wrap; }
.preference-theme select { min-height: 44px; padding: 8px 12px; border-radius: 10px; background: #0f172a; color: #e2e8f0; border: 1px solid #475569; font-size: 14px; }
.preference-theme select:focus-visible { outline: 2px solid #38bdf8; outline-offset: 3px; }
html[data-theme="dark"] .preference-theme select { background: #090b0f; }
html[data-theme="light"] .preference-theme select { background: #f8fafc; color: #1e293b; border-color: #94a3b8; }
.preferences-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.preference-option { position: relative; display: flex; align-items: center; gap: 12px; padding: 16px; background: #0f172a99; border: 1px solid #334155; border-radius: 16px; cursor: pointer; }
.preference-option > i { color: #7dd3fc; font-size: 22px; flex-shrink: 0; }
.preference-copy { flex: 1; min-width: 0; }
.preference-copy strong { display: block; color: #e2e8f0; font-size: 14px; margin-bottom: 4px; }
.preference-copy > span { display: block; color: #94a3b8; font-size: 12px; line-height: 1.5; }
.preference-option input[type="checkbox"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preference-switch { position: relative; flex: 0 0 44px; height: 26px; background: #475569; border: 1px solid #64748b; border-radius: 20px; transition: background .2s; }
.preference-switch::after { content: ''; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; background: #f8fafc; border-radius: 50%; transition: transform .2s; }
.preference-option input:checked + .preference-switch { background: #059669; border-color: #34d399; }
.preference-option input:checked + .preference-switch::after { transform: translateX(18px); }
.preference-option input:focus-visible + .preference-switch { outline: 2px solid #38bdf8; outline-offset: 4px; }
.preferences-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; }
.preferences-footer > p { flex: 1; min-width: 180px; }
.preferences-footer > div { display: flex; gap: 8px; }
.preferences-footer button { min-height: 44px; padding: 10px 14px; color: #cbd5e1; border: 1px solid #475569; border-radius: 12px; font-size: 13px; }
.preferences-footer .preferences-save { color: #0f172a; background: #38bdf8; border-color: #38bdf8; font-weight: 700; }

/* Tema claro: conservar los colores de acciones, alertas y gráficas. */
html[data-theme="light"] body { background: #f1f5f9 !important; color: #334155; }
html[data-theme="light"] :is([class~="bg-[#1e293b]"], [class~="bg-[#1e293b]/50"], [class~="bg-[#0f172a]"], [class~="bg-[#0f172a]/50"], [class~="bg-slate-800"], [class~="bg-slate-800/50"], [class~="bg-slate-800/80"], [class~="bg-[#0f172a]/95"]) { background-color: #fff !important; }
html[data-theme="light"] :is([class~="from-[#1e293b]"], [class~="from-[#0f172a]"]) { background-image: none !important; background-color: #fff !important; }
html[data-theme="light"] :is(.text-white, .text-slate-200, .text-slate-300) { color: #1e293b !important; }
html[data-theme="light"] :is(.text-slate-400, .text-slate-500, .text-slate-600) { color: #526178 !important; }
html[data-theme="light"] :is(.border-slate-700, .border-slate-600) { border-color: #cbd5e1 !important; }
html[data-theme="light"] .ev { --ev-bg: #f8fafc; --ev-card: #fff; --ev-line: #cbd5e1; --ev-muted: #526178; --ev-accent: #0284c7; color: #334155; }
html[data-theme="light"] .ev :is(h1, h2) { color: #1e293b; }
html[data-theme="light"] .ev :is(input, textarea) { color: #1e293b; border-color: #94a3b8; }
html[data-theme="light"] .ev button { color: #334155; background: #e2e8f0; }
html[data-theme="light"] .ev .ev-primary { background: linear-gradient(100deg, #38bdf8, #10b981); color: #0f172a; }
html[data-theme="light"] .ev .ev-messages { background: #f8fafc; }
html[data-theme="light"] .ev :is(.ev-history a, .ev-status) { color: #475569; }
html[data-theme="light"] .ev .ev-body strong { color: #0369a1; }
html[data-theme="light"] .ev .ev-top small { color: #047857; }
html[data-theme="light"] :is(.preferences-card, .preference-option, .home-install, .app-toolbar button, #app-install-help) { background: #fff; border-color: #cbd5e1; color: #334155; }
html[data-theme="light"] :is(.preferences-heading h2, .preference-copy strong, .home-install strong) { color: #1e293b; }
html[data-theme="light"] :is(.preferences-heading p, .preference-copy > span, .preferences-footer p, .home-install p) { color: #526178; }
html[data-theme="light"] .preferences-footer button:not(.preferences-save) { color: #475569; }
html[data-theme="light"] :is(.preferences-badge, .preferences-heading > i, .preference-option > i) { color: #0369a1; }

html[data-motion="reduced"] *, html[data-motion="reduced"] *::before, html[data-motion="reduced"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html[data-motion="reduced"] :is(.aside-anim, .main-anim, .nav-anim, .dashboard-card-anim, .anime-header, .hero-text, .hero-mockup, .login-card, .form-item, .anime-privacy, .footer-anim) { opacity: 1 !important; transform: none !important; }
html[data-motion="reduced"] .loader-bar { display: none; }
@media (prefers-reduced-motion: reduce) { body::after { animation: none !important; } }
@media (max-width: 767px) {
    html:is([data-theme="dark"], [data-theme="original"])[data-space="true"] .space-moon { width: 54px; height: 54px; right: 14px; top: 98px; opacity: .16; box-shadow: inset -14px -6px 12px #03050bd9, 0 0 24px #adcaff18; }
    .preferences-card { padding: 16px; border-radius: 18px; }
    .preferences-options { grid-template-columns: 1fr; gap: 10px; }
    .preference-option { padding: 14px 12px; gap: 10px; }
    .preferences-heading h2 { font-size: 20px; }
    .preferences-heading > i { font-size: 36px; }
    .preferences-footer > div { width: 100%; flex-wrap: wrap; }
    .preferences-footer button { flex: 1; }
    .profile-details { gap: 16px; }
    .profile-details > div { padding: 20px; }
}
