/* Shared appearance control */
.theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:42px;min-height:42px;padding:7px 11px;border:1px solid #dfe3ee;border-radius:12px;background:#fff;color:#505b78;box-shadow:0 4px 12px #2730520b;font-size:12px;font-weight:700;white-space:nowrap;transition:background .2s,color .2s,border-color .2s,transform .2s}
.theme-toggle:hover{transform:translateY(-2px);border-color:#afa9ee;color:#5149c2}
.theme-toggle:focus-visible{outline:3px solid #aaa3ff;outline-offset:2px}
.theme-toggle:disabled{opacity:.6;cursor:wait;transform:none}
.theme-toggle-icon{font-size:21px;line-height:1;display:grid;place-items:center;width:21px;height:21px}
.theme-sun{display:none}
.theme-toggle-label{display:none}
.appearance-panel{display:flex;align-items:center;justify-content:space-between;gap:20px}
.appearance-panel h2{margin:0 0 4px}.appearance-panel p{margin:0;font-size:12px}
.appearance-panel .theme-toggle{min-width:132px}.appearance-panel .theme-toggle-label{display:inline}

/* Theme values and surfaces */
html[data-theme="dark"]{color-scheme:dark;--ink:#eef1ff;--muted:#a5afc8;--primary:#9088ff;--primary-dark:#766de9;--line:#323b54;--bg:#101423;--white:#1b2235;--shadow:0 16px 40px #05081735}
html[data-theme="dark"] body{background:#101423;color:#eef1ff}
html[data-theme="dark"] :is(.site-header,.app-header,.sidebar,.auth-card,.panel,.stat-card,.subject-card,.feature-card,.step,.preview-window,.spotlight-card,.faq-wrap details,.profile-dropdown,.toast:not(.success):not(.warning)){background:#1b2235;border-color:#323b54;color:#eef1ff}
html[data-theme="dark"] :is(.brand,.site-footer .brand,.app-header-title,.page-heading h1,.panel h2,.panel h3,.stat-card strong,.feature-card h3,.step h3,.subject-card h2,.lesson-heading h1,.question-card h2,.exam-card h2,.answer-card h3,.auth-card h1,.chat-welcome h2,.chapter-head h2,.recent-row strong,.preview-greeting,.section-heading h2,.how-grid h2,.spotlight-grid h2,.faq-wrap summary,.appearance-panel h2){color:#eef1ff}
html[data-theme="dark"] :is(.site-header,.app-header,.sidebar){box-shadow:none}
html[data-theme="dark"] .app-body{background:#101423}
html[data-theme="dark"] :is(.hero,.auth-section){background:radial-gradient(circle at 30% 30%,#24215b 0,transparent 45%),linear-gradient(180deg,#141a2b,#101423)}
html[data-theme="dark"] .hero-glow{background:radial-gradient(circle,#3e367c,transparent 67%)}
html[data-theme="dark"] .trust-strip{background:#151c2e;border-color:#303950}
html[data-theme="dark"] .how-section{background:#151b2d}
html[data-theme="dark"] .spotlight{background:#101423}
html[data-theme="dark"] .spotlight-card{background:#202542;border-color:#3e4269}
html[data-theme="dark"] .final-cta{background:linear-gradient(125deg,#171b42,#302d83 60%,#493fa4)}
html[data-theme="dark"] .site-footer{background:#0b1020;border-color:#252e45}
html[data-theme="dark"] .footer-bottom{border-color:#2b344c}
html[data-theme="dark"] :is(.public-nav a,.nav-login,.footer-grid p,.footer-grid a:not(.brand),.footer-bottom,.trust-row,.trust-row b,.hero-copy>p,.section-heading p,.how-grid p,.spotlight-grid p,.feature-card p,.step p,.faq-wrap details p,.auth-card>p,.page-heading p,.muted,.tiny-muted,.hint,.stat-card small,.stat-card>span:last-child,.subject-card p,.subject-meta,.lesson-heading p,.lesson-content,.chapter-head p,.lesson-list small,.exam-card p,.exam-meta,.recent-row small,.ai-tip p,.preview-greeting small,.preview-stats small,.preview-lesson small,.preview-ai p,.chat-welcome p,.chat-top small,.task-row small,.answer-card p,.subject-progress small,.result-hero>p,.intro-stats span,.result-stats span){color:#aab5ce}
html[data-theme="dark"] .public-nav a:hover,html[data-theme="dark"] .nav-login:hover{color:#bbb5ff}
html[data-theme="dark"] :is(.feature-card,.subject-card,.stat-card,.panel,.preview-window,.auth-card,.step){box-shadow:0 14px 38px #05081724}
html[data-theme="dark"] :is(.preview-stats div,.preview-ai,.preview-lesson,.ai-tip,.assistant-panel,.answer-explanation,.exam-note){background:#252d46;border-color:#3b4563}
html[data-theme="dark"] .preview-ai{background:#2a2850;border-color:#474073}
html[data-theme="dark"] :is(.eyebrow,.pill,.auth-icon,.feature-icon.violet,.stat-icon.lavender,.chapter-number,.avatar){background:#312d59;border-color:#4d4777;color:#b8b2ff}
html[data-theme="dark"] .pill.warning{background:#49391f;color:#ffda91}
html[data-theme="dark"] .pill.success{background:#1b463d;color:#8be6c1}
html[data-theme="dark"] :is(.feature-icon.blue,.stat-icon.blue){background:#233c59;color:#9fc7ff}
html[data-theme="dark"] :is(.feature-icon.mint,.stat-icon.mint){background:#21453f;color:#8ee0c1}
html[data-theme="dark"] :is(.feature-icon.amber,.stat-icon.amber){background:#4a3822;color:#f4c87b}
html[data-theme="dark"] :is(.text-link,.feature-card a,.lesson-nav,.subject-progress>div:first-child>span:last-child,.recent-row b){color:#aca5ff}
html[data-theme="dark"] .btn-primary{background:#776de8;color:#fff;box-shadow:0 8px 20px #14135a55}
html[data-theme="dark"] .btn-primary:hover{background:#9189f7}
html[data-theme="dark"] :is(.btn-outline,.btn-ghost,.theme-toggle){background:#252c43;border-color:#424a68;color:#d8dcf7}
html[data-theme="dark"] :is(.btn-outline:hover,.btn-ghost:hover,.theme-toggle:hover){border-color:#8981ef;color:#fff}
html[data-theme="dark"] .btn-light{background:#f0efff;color:#38318e}
html[data-theme="dark"] :is(.form-control,input:not([type=radio]):not([type=checkbox]),select,textarea){background:#171d30;border-color:#424a64;color:#eff1ff}
html[data-theme="dark"] :is(input,textarea)::placeholder{color:#8490ac}
html[data-theme="dark"] :is(.form-control,input,select,textarea):focus{border-color:#938bff;box-shadow:0 0 0 3px #7871e533}
html[data-theme="dark"] :is(.form-group label,.auth-links,.auth-links span){color:#c6cce0}
html[data-theme="dark"] .form-error{background:#512936;color:#ffc4ce}
html[data-theme="dark"] .error{color:#ff9cad}
html[data-theme="dark"] .auth-links a{color:#b6afff}
html[data-theme="dark"] .dashboard-hero{background:linear-gradient(115deg,#24205c,#453da6 65%,#6255cf)}
html[data-theme="dark"] .dashboard-hero :is(h2,p,.hero-label){color:#fff}
html[data-theme="dark"] :is(.side-nav a,.sidebar-bottom a,.sidebar-bottom button,.sidebar-label,.header-date,.profile-chip){color:#aeb7cf}
html[data-theme="dark"] :is(.side-nav a:hover,.sidebar-bottom a:hover,.sidebar-bottom button:hover,.side-nav a.active){background:#302d55;color:#c4beff}
html[data-theme="dark"] .sidebar-bottom{border-color:#303950}
html[data-theme="dark"] :is(.profile-dropdown a,.profile-dropdown button){color:#c2c9dd}
html[data-theme="dark"] :is(.profile-dropdown a:hover,.profile-dropdown button:hover){background:#302d55;color:#fff}
html[data-theme="dark"] .profile-dropdown .profile-admin-link{background:#373263;color:#d2cdff}
html[data-theme="dark"] :is(.continue-card,.compact-subjects a,.lesson-list,.lesson-list a,.quick-list a,.history-item,.choice,.recent-row,.task-row,.answer-card,.chapter-card,.subject-progress,.chat-top,.chat-form,.lesson-heading,.lesson-actions,.answer-explanation){border-color:#353e58}
html[data-theme="dark"] :is(.continue-card,.compact-subjects a,.quick-list a,.history-item,.choice){background:#20283d;color:#dce1f6}
html[data-theme="dark"] :is(.history-item:hover,.history-item.selected,.quick-list a:hover,.choice:has(input:checked)){background:#312e58;border-color:#6862b8;color:#eeeaff}
html[data-theme="dark"] .subject-icon{background:#2b3650}
html[data-theme="dark"] .subject-banner{background:linear-gradient(110deg,var(--accent),#252d58)}
html[data-theme="dark"] .subject-banner :is(h1,p,.section-kicker){color:#fff}
html[data-theme="dark"] .lesson-content{color:#d3d9ee}
html[data-theme="dark"] .progress-track{background:#303950}
html[data-theme="dark"] .progress-track span{background:var(--accent,#938aff)}
html[data-theme="dark"] .preview-stats b{color:#b1aaff}
html[data-theme="dark"] .floating-note{background:#292d4b;color:#d2ccff}
html[data-theme="dark"] .ai-bubble{background:#292d4b;color:#e4e6fb}
html[data-theme="dark"] .user-bubble,html[data-theme="dark"] .message.mine{background:#6860cf;color:#fff}
html[data-theme="dark"] .message.assistant{background:#2b2e52;color:#e7e5ff}
html[data-theme="dark"] .ai-thinking{background:linear-gradient(135deg,#292d50,#242843);border-color:#454672;box-shadow:0 12px 30px #05081735}
html[data-theme="dark"] .message .thinking-title{color:#c1bbff}
html[data-theme="dark"] .message .thinking-spark{background:#413b75;color:#d0cbff}
html[data-theme="dark"] .thinking-body{color:#c0c7dd}
html[data-theme="dark"] .typing-dots i{background:#aaa2ff}
html[data-theme="dark"] .chat-form.is-sending textarea{background:#151a2b;color:#8994ad}
html[data-theme="dark"] .ai-error-message{background:#4b2937;border-color:#704052;color:#ffc5d0}
html[data-theme="dark"] .ai-error-message span{color:#ff9fb0}
html[data-theme="dark"] .chat-media-strip :is(img,video){background:#151b2d}
html[data-theme="dark"] .chat-media-strip figure{background:#20283d;border-color:#3a435d}
html[data-theme="dark"] .prompt-grid button,html[data-theme="dark"] .question-dots button{background:#242c42;border-color:#3e4864;color:#d8ddf4}
html[data-theme="dark"] .question-dots button.active,html[data-theme="dark"] .question-dots button.answered{background:#373362;border-color:#786fce;color:#f2efff}
html[data-theme="dark"] .timer{background:#262e45;border-color:#465171;color:#c1bbff}
html[data-theme="dark"] .timer.urgent{background:#4b2937;color:#ffc1cb}
html[data-theme="dark"] .score-ring{border-color:#4a4575;border-right-color:#9c94ff;border-top-color:#9c94ff}
html[data-theme="dark"] .score-ring strong{color:#b9b2ff}
html[data-theme="dark"] .weak-chapter{border-color:#35405a;color:#b9c2d8}
html[data-theme="dark"] .weak-chapter b{color:#b6afff}
html[data-theme="dark"] .check{background:#222b40;border-color:#65708c}
html[data-theme="dark"] .check.done{background:#268a6b;border-color:#268a6b}
html[data-theme="dark"] .theme-sun{display:inline}
html[data-theme="dark"] .theme-moon{display:none}
html[data-theme="dark"] .toast{background:#2a3150;color:#f1f2ff}
html[data-theme="dark"] :is(.section-kicker,.question-count,.ai-bubble span){color:#b6afff}
html[data-theme="dark"] :is(.preview-top,.preview-dots,.hero-proof,.spotlight-points,.ai-bubble p){color:#bdc6df}
html[data-theme="dark"] .preview-top{border-color:#3a4360}
html[data-theme="dark"] .mini-pills span{background:#2e3551;border-color:#49516d;color:#d4d9f0}
html[data-theme="dark"] .lesson-status{border-color:#515b78;color:#c0baff}
html[data-theme="dark"] :is(.usage-icon,.overview-numbers span){background:#252d46;color:#b9b2ff}
html[data-theme="dark"] .overview-numbers b{color:#eef1ff}
html[data-theme="dark"] .progress-donut{background:radial-gradient(circle at center,#1b2235 0 57%,transparent 58%),conic-gradient(var(--primary) var(--value),#303950 0)}
html[data-theme="dark"] .line-chart .chart-guides line{stroke:#3a435d}
html[data-theme="dark"] .line-chart circle{fill:#1b2235}
html[data-theme="dark"] .subject-analysis{border-color:#353e58}
html[data-theme="dark"] .lesson-media-stage{background:#151b2d}
html[data-theme="dark"] .lesson-media-card{background:#1b2235;border-color:#353e58}

@media(max-width:800px){html[data-theme="dark"] .site-header .public-nav{background:#1b2235;box-shadow:0 15px 30px #05081755}}
@media(max-width:560px){.nav-actions .theme-toggle{min-width:36px;min-height:36px;padding:5px}.appearance-panel{align-items:flex-start;flex-direction:column}.appearance-panel .theme-toggle{width:100%}}
@media(prefers-reduced-motion:reduce){.theme-toggle{transition:none}}

html[data-theme="dark"] .exam-topic-options .btn.selected{background:var(--primary);color:#fff;border-color:var(--primary)}

html[data-theme="dark"] .chat-form.is-sending textarea{background:#1b2235;color:#eef1ff}html[data-theme="dark"] .chat-stop-button{background:#392334;color:#ffa7bc;border-color:#6b3b50}
html[data-theme="dark"] .chat-messages{background:linear-gradient(180deg,#1b2234,#192032)}
html[data-theme="dark"] .message.assistant{background:#252d43;border-color:#3b4561;color:#e8edfc}
html[data-theme="dark"] .answer-content :is(h2,h3,h4),html[data-theme="dark"] .answer-content strong{color:#c9c5ff}
html[data-theme="dark"] .answer-content :is(ul,ol),html[data-theme="dark"] .answer-math{background:#20283d;border-color:#3a435d}
html[data-theme="dark"] .answer-content hr{border-color:#3a435d}
html[data-theme="dark"] .answer-caret{background:#b9b0ff}
html[data-theme="dark"] .chat-visual{background:#20283d;border-color:#3a435d}
html[data-theme="dark"] .chat-visual figcaption{background:#252d43}
html[data-theme="dark"] .chat-visual figcaption strong{color:#a6e0c9}
html[data-theme="dark"] .chat-source-picker{background:#20283d;border-color:#3a435d}
html[data-theme="dark"] .chat-source-options label{background:#252d43;border-color:#3a435d;color:#e8edfc}
html[data-theme="dark"] .chat-source-options label:has(input:checked){background:#34345d;border-color:#756cbb}
html[data-theme="dark"] .tutor-focus-toggle{background:#252d43;border-color:#3b4561;color:#c9c5ff}
html[data-theme="dark"] .learning-flow{background:linear-gradient(135deg,#1d3a38,#1e3045);border-color:#3e6860;color:#e2f4ec}
html[data-theme="dark"] .learning-flow-heading strong{color:#b4ecd8}
html[data-theme="dark"] .learning-flow-play,html[data-theme="dark"] .learning-flow-step,html[data-theme="dark"] .learning-flow-detail{background:#263b43;border-color:#476d64;color:#e2f4ec}
html[data-theme="dark"] .learning-flow-step.is-active{background:#31584f;border-color:#6ed0a8}
html[data-theme="dark"] .history-menu{background:#252d43;border-color:#3b4561}
html[data-theme="dark"] .history-row:has(>.history-item.selected){background:#37335e;box-shadow:inset 0 0 0 1px #756cbb}
html[data-theme="dark"] .history-row>.history-item.selected{background:transparent;color:#f0edff}
html[data-theme="dark"] .history-menu>button,html[data-theme="dark"] .history-menu>form[data-history-delete]>button{color:#e8edfc}
html[data-theme="dark"] .history-menu>form[data-history-delete]>button.history-delete{color:#ff9cae}
html[data-theme="dark"] .history-menu>button:hover,html[data-theme="dark"] .history-menu>form[data-history-delete]>button:hover,html[data-theme="dark"] .history-actions summary:hover{background:#34345d}
html[data-theme="dark"] .history-rename-form input[name="title"]{background:#1c2438;border-color:#46516c;color:#eef1ff}
html[data-theme="dark"] body.tutor-focus .tutor-history-toggle{background:#252d43;border-color:#3b4561;color:#e8edfc}
