/* Shared theme control. The saved theme is restored before styles load. */
html{color-scheme:light}
.theme-toggle{width:38px;min-height:38px;display:grid;place-items:center;border:1px solid var(--line);border-radius:11px;background:#f7f8fa;color:#697685;transition:background .2s,color .2s,border-color .2s}
.theme-toggle:hover{background:#edf3e7;color:#486335;border-color:#c6d6b4}
.theme-toggle .icon{width:18px;height:18px}
.breadcrumb{min-width:0}
.breadcrumb strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.topbar-actions{flex-shrink:0}
html[data-theme="dark"]{color-scheme:dark;--bg:#0d0e1e;--white:#171834;--ink:#e9e9f2;--muted:#a4a6c5;--line:#24274a;--navy:#1b1d3e;--green:#bfe964;--lavender:#2c2b47;--surface-raised:#1c1f42;--surface-deep:#12142a;--soft:#a4a6c5;--positive-bg:#25273c;--positive-text:#d2ef92}
html[data-theme="dark"] body{background-color:var(--bg);background-image:radial-gradient(ellipse at 80% 6%,#292c5920,transparent 53%),radial-gradient(circle at 24px 43px,#d8d9e922 1px,transparent 1.5px),radial-gradient(circle at 89px 126px,#d8d9e914 .8px,transparent 1.3px);background-size:auto,233px 211px,307px 271px;background-attachment:fixed}
html[data-theme="dark"] :is(.sidebar,.topbar){background:#121329}
html[data-theme="dark"] :is(.deck-card,.rail-card,.stat-card,.chart-card,.mastery-card,.modal,.modal-footer,.study-top,.study-controls,.study-sentence,.empty-state){background:var(--white);border-color:var(--line)}
html[data-theme="dark"] :is(.nav-link,.breadcrumb,.breadcrumb strong,.help-link,.eyebrow,.nav-caption,.page-heading p,.text-link,.tab,.deck-meta,.deck-footer,.deck-description,.rail-title button,.goal-caption,.streak-big small,.streak-message,.week-day,.footer-note,.level-card small,.level-meta,.field small,.study-top-row small,.study-progress small,.study-hint,.study-controls small,.storage-note,.chart-card p,.stat-card small,.chart-col span,.detail-card small,.detail-info,.goal-number small,.goal-number span,.goal-option small,.summary-stats small,.card-preview.invalid,.help-content p,.confirm-body p,.explore-hero p){color:var(--soft)}
html[data-theme="dark"] .nav-link:hover{background:#1a1c3d;color:#e9e9f2}
html[data-theme="dark"] .nav-link.active{background:#26273a;color:#dbf3a9}
html[data-theme="dark"] .nav-link.active .nav-dot{background:#c9ec7c;box-shadow:0 0 9px #c9ec7c33}
html[data-theme="dark"] .nav-link .small-badge{background:#26294e;color:#bbbdd9}
html[data-theme="dark"] .level-card{background:linear-gradient(135deg,#171932,#171935);border-color:#2a2c45}
html[data-theme="dark"] .level-icon{background:#302d4b;color:#beb0e2}
html[data-theme="dark"] .progress-track,html[data-theme="dark"] .deck-card .progress-track{background:#282a4c}
html[data-theme="dark"] .progress-track>span{background:#c6eb75}
html[data-theme="dark"] .avatar{background:#303143;border-color:#181a38;color:#e0f4b5}
html[data-theme="dark"] .top-stat.flame{color:#e6b580}
html[data-theme="dark"] .top-stat.xp{color:#c2afe6}
html[data-theme="dark"] .theme-toggle{color:#d2f092;background:#1c1e3b;border-color:#343545}
html[data-theme="dark"] .theme-toggle:hover{background:#2a2b3d;color:#e5f7bf}
html[data-theme="dark"] .button.secondary{background:var(--surface-raised);border-color:#34375c;color:#d5d6e7;box-shadow:0 2px 0 #0d0e1e}
html[data-theme="dark"] .button.secondary:hover{background:#252853;border-color:#535687}
html[data-theme="dark"] .button.ghost{color:#b2b4d0}
html[data-theme="dark"] .button.danger{background:#442d34;color:#f0b3af}
html[data-theme="dark"] .button.navy{background:#292c5b;color:#f5f5f9}
html[data-theme="dark"] .hero{background:#1b1d3e;box-shadow:inset 0 0 0 1px #36396a66,0 8px 35px #00000012}
html[data-theme="dark"] .hero:after{background:radial-gradient(ellipse at 82% 55%,#8274b02e,transparent 64%),radial-gradient(ellipse at 37% 100%,#4446631a,transparent 55%)}
html[data-theme="dark"] .hero-small-star{color:#c3ea6e}
html[data-theme="dark"] .hero p{color:#b5b7d5}
html[data-theme="dark"] .hero-time{color:#acafd1}
html[data-theme="dark"] .tab:hover{background:#1c1f42;color:#e2e2ee}
html[data-theme="dark"] .tab.active{background:#242647;border-color:#3c3d50;color:#e3f5bc;box-shadow:0 2px 6px #0002}
html[data-theme="dark"] .view-toggle{background:#161834}
html[data-theme="dark"] .view-toggle button{color:#9598c0}
html[data-theme="dark"] .view-toggle button.active{background:#30335a;color:#e7e7f1}
html[data-theme="dark"] .deck-card:hover{border-color:#515264;box-shadow:0 10px 28px #0003}
html[data-theme="dark"] .mint{--art-bg:#23253c;--art-ink:#c0e967}
html[data-theme="dark"] .lavender{--art-bg:#302e4c;--art-ink:#c1b4e6}
html[data-theme="dark"] .peach{--art-bg:#44332f;--art-ink:#e0b292}
html[data-theme="dark"] .blue{--art-bg:#262954;--art-ink:#aeb1d2}
html[data-theme="dark"] .deck-art:before,html[data-theme="dark"] .deck-art:after{border-color:#ffffff0d}
html[data-theme="dark"] .deck-lang{background:#12142abb;color:#d4d5e7}
html[data-theme="dark"] .deck-footer .icon{color:#caed7e}
html[data-theme="dark"] .add-deck-card{background:#12142ab3;border-color:#35364b;color:#d2f093}
html[data-theme="dark"] .add-deck-card span{background:#25273c}
html[data-theme="dark"] .add-deck-card small{color:#c0e966}
html[data-theme="dark"] .context-banner{background:linear-gradient(115deg,#202135,#1b1c2f);border-color:#333446}
html[data-theme="dark"] .context-icon{background:#303249;color:#cfee8b}
html[data-theme="dark"] .context-banner h3{color:#e5f6c1}
html[data-theme="dark"] .context-banner p{color:#c9ec7d}
html[data-theme="dark"] .context-banner .text-link{color:#d2f092}
html[data-theme="dark"] .context-example{background:#171827;color:#d7f1a0;box-shadow:0 3px 9px #0002}
html[data-theme="dark"] .context-example span{background:#2e3045;border-color:#bbe85b;color:#ddf3ad}
html[data-theme="dark"] .goal-ring circle{stroke:#292b48}
html[data-theme="dark"] .goal-ring circle:last-child{stroke:#ceee88;filter:drop-shadow(0 0 4px #ceee8812)}
html[data-theme="dark"] .goal-card .button{background:#292a3e;border-color:#3b3c51;color:#dbf2a8}
html[data-theme="dark"] .rail-title>.icon{color:#a2a4c2}
html[data-theme="dark"] .day-dot{background:#232548;color:#b6e64e}
html[data-theme="dark"] .week-day.today .day-dot{border-color:#92784e;background:#3a332c;color:#e5be87}
html[data-theme="dark"] .week-day.done .day-dot{background:#32344b;color:#d9f2a4}
html[data-theme="dark"] .tip-card{background:#25263e;border-color:#3b3b57}
html[data-theme="dark"] .tip-card h3{color:#dfd9f5}
html[data-theme="dark"] .tip-card p{color:#bcb8d0}
html[data-theme="dark"] .tip-label{color:#b8acd4}
html[data-theme="dark"] .tip-star{color:#a69ac6}
html[data-theme="dark"] :is(.search-input input,.field input,.field textarea,.field select,.study-answer input){background:var(--surface-deep);color:var(--ink);border-color:#36395d}
html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:#8688ab;opacity:1}
html[data-theme="dark"] .search-input>.icon{color:#9a9dc3}
html[data-theme="dark"] .empty-state{border-color:#3a3b4b}
html[data-theme="dark"] .explore-hero{background:linear-gradient(125deg,#1e2147,#242843);border:1px solid #353861}
html[data-theme="dark"] .explore-hero .mini-space{color:#abaed0}
html[data-theme="dark"] .stat-card .icon{color:#c8ec79}
html[data-theme="dark"] .chart-bar{background:#32344b}
html[data-theme="dark"] .chart-col.today .chart-bar{background:#c8ec7a}
html[data-theme="dark"] .chart-col strong{color:#cdee86}
html[data-theme="dark"] .badge-row{background:#222337;border:1px solid #35364b}
html[data-theme="dark"] .badge-row p{color:#c9ec7c}
html[data-theme="dark"] .modal-backdrop{background:#070811b5;backdrop-filter:blur(7px)}
html[data-theme="dark"] .modal{box-shadow:0 25px 90px #0008}
html[data-theme="dark"] .icon-button{color:#b1b3d2}
html[data-theme="dark"] .icon-button:hover{background:#2a2c4e;color:#def4b0}
html[data-theme="dark"] .editor-explainer{background:#25263b;border-color:#393a4f;color:#d6f19d}
html[data-theme="dark"] .card-editor{background:#191b3a;border-color:#31345c}
html[data-theme="dark"] .card-editor-header strong{color:#cbed81}
html[data-theme="dark"] .card-preview{background:#232437;color:#def4b0}
html[data-theme="dark"] .card-preview .gap{background:#323453;border-color:#c6ec76;color:#def4af}
html[data-theme="dark"] .color-choice{border-color:#171834;box-shadow:0 0 0 1px #5f6177}
html[data-theme="dark"] .color-choice.selected{box-shadow:0 0 0 2px #cfee8c}
html[data-theme="dark"] .field-error{color:#f1aca5}
html[data-theme="dark"] .detail-hero .icon-button{background:#12142abb}
html[data-theme="dark"] .detail-card-number{color:#9c9ec0}
html[data-theme="dark"] .detail-card mark{background:#30324a;color:#def4af}
html[data-theme="dark"] .study-modal{background:#111227}
html[data-theme="dark"] .study-kicker{color:#caed7f}
html[data-theme="dark"] .study-sentence .blank{background:#2c2e43;color:#d5f19a;border-color:#c5eb72}
html[data-theme="dark"] .hint-text{color:#d6f19b}
html[data-theme="dark"] .study-feedback{background:#292a3f;color:#def3ae}
html[data-theme="dark"] .study-feedback.wrong{background:#44332f;color:#f0c4aa}
html[data-theme="dark"] .summary-emblem{background:#292a3e;color:#d1ef8f}
html[data-theme="dark"] .goal-option{background:#171834}
html[data-theme="dark"] .goal-option.selected{background:#2b2c3e;border-color:#b7e652}
html[data-theme="dark"] .help-content code,html[data-theme="dark"] .help-content .sample{background:#2a2b40;color:#daf2a7}
html[data-theme="dark"] .save-notice{background:#42372b;border-color:#725f46;color:#f2cd9c}
html[data-theme="dark"] #toast{background:#daf2a6;color:#1c1e35;box-shadow:0 5px 30px #0004}
html[data-theme="dark"] .skip-link{color:#1e203b}
@media(max-width:760px){.topbar{gap:10px}.breadcrumb{flex:1;gap:6px}.topbar-actions{gap:9px}.theme-toggle{width:34px;min-height:44px;border-radius:9px}.theme-toggle .icon{width:17px;height:17px}}
@media(max-width:380px){.topbar-actions{gap:7px}.theme-toggle{width:31px}.breadcrumb strong{font-size:9px}}
