:root { color-scheme:light; --surface:#fff; --surface-soft:#edf3ee; }
#theme-toggle { white-space:nowrap; min-height:44px; }
:root[data-theme="dark"] {
  color-scheme:dark; --ink:#e4eee9; --muted:#adbbb5; --line:#3b5049;
  --canvas:#111b18; --surface:#1b2924; --surface-soft:#25372f;
  --green:#8bd5b7; --purple:#bca5f6; --blue:#90b9f4; --orange:#efb078;
  --surface-shadow:0 8px 24px #0003; --control-shadow:0 1px 3px #0003;
}
html[data-theme="dark"] :is(.topbar,.panel,.side-panel,.account-panel,.map-card,.stat-card,.domain-tile,.vocab-card,.glossary-item,.guided-study-frame,.guided-word-card,.guided-concept-card,.guided-question,.tutor-main,.tutor-form,.tutor-widget,.tutor-chart,.chat-study-card,.path-unit,.lesson-definitions,.lesson-settings,.ring-inner,.study-context-menu,.lesson-nav,.lesson-content,.quiz-shell) { background:var(--surface); color:var(--ink); border-color:var(--line); }
html[data-theme="dark"] :is(.path-next,.path-step,.path-picker .guided-select-label,.lesson-progress-panel,.compare-card,.guided-definition,.guided-definition-example,.guided-inline-help,.vocab-meaning,.vocab-example,.vocab-memory,.lesson-definition,.definition-example,.term-help,.memory-hook,.chat-study-tool,.tutor-context,.segmented,.lab-tabs,.intro-words details,.chat-message,.guide-hero,.account-notice,.study-session-toolbar) { background:var(--surface-soft); color:var(--ink); border-color:var(--line); }
html[data-theme="dark"] :is(input,textarea,select,.path-picker select,.btn.light,.icon-button,.answer-option,.segment.selected,.lesson-dot,.tutor-prompts button,.tutor-followups button,.meaning-flow span,.mini-flow span,kbd) { background-color:var(--surface); color:var(--ink); border-color:var(--line); }
html[data-theme="dark"] :is(.btn:not(.light):not(.ghost):not(.review):not(.know),.nav-link.active,.brand-mark,.study-context-step.current) { background:var(--lime); color:#142b2b; }
html[data-theme="dark"] .sidebar { background:#10251f; color:#e4eee9; }
html[data-theme="dark"] :is(.card-back,.toast,.lesson-dot[title]:hover::after,.lesson-dot[title]:focus-visible::after) { background:#18392f; color:#e4eee9; border-color:var(--line); }
html[data-theme="dark"] .card-front { background:linear-gradient(120deg,#293c28,#23382e); color:var(--ink); border-color:var(--line); }
html[data-theme="dark"] :is(.pill,.pill.tone,.topic-icon,.card-top .pill) { background:#34483b; color:#d3fa68; }
html[data-theme="dark"] :is(.btn.know,.answer-option.correct,.feedback,.lesson-dot.rated) { background:#214936; color:#b6efcf; border-color:#5d9978; }
html[data-theme="dark"] :is(.btn.review,.lesson-caution,.lesson-dot.again) { background:#493921; color:#f4ce95; border-color:#a17e43; }
html[data-theme="dark"] :is(.answer-option.wrong,.feedback.incorrect,.account-error,.sync-conflict) { background:#482d2c; color:#ffbcb3; border-color:#ad746c; }
html[data-theme="dark"] :is(.study-intro,.card-code,.card-topic,.card-bottom,.mini-flow,.guided-memory,.guided-definition>span,.guided-definition-example>span,.path-picker .guided-select-label>span,.study-rewards,.study-context-step,.study-exit,.path-next p,.path-count>span,.path-step small,.meaning-flow,.term-meaning) { color:var(--muted); }
html[data-theme="dark"] :is(.guided-correct-answer,.eyebrow,.inline-term) { color:var(--green); }
html[data-theme="dark"] :is(.btn.light,.answer-option,.segment,.lesson-link,.tutor-prompts button,.tutor-followups button):hover:not(:disabled) { background:var(--surface-soft); color:var(--ink); border-color:#819b8f; }
html[data-theme="dark"] .domain-tile .tile-top { color:var(--ink); }
html[data-theme="dark"] .chart-marker { stroke:var(--surface); }
html[data-theme="dark"] :is(.topbar-progress-row,.lesson-check,.takeaway,.chat-toolbar,.note-strip) { background:var(--surface-soft); color:var(--ink); border-color:var(--line); }
html[data-theme="dark"] main .panel[style] { background:var(--surface-soft)!important; }
html[data-theme="dark"] .study-context-steps { background:var(--surface-soft); border-color:var(--line); }
html[data-theme="dark"] .study-context-step:not(.current) { background:transparent; color:var(--ink); }
html[data-theme="dark"] .study-context-step span { color:#142b2b; }
html[data-theme="dark"] .study-context-step:not(.current):not(.done) span { background:var(--surface); color:var(--muted); border-color:var(--line); }
html[data-theme="dark"] progress::-webkit-progress-bar { background:#3b5049; }
/* Lesson navigation is also visible when the optional lesson list is expanded. */
html[data-theme="dark"] .lesson-link.selected { background:var(--surface-soft); color:var(--ink); border-color:var(--green); }
html[data-theme="dark"] .lesson-number { background:var(--surface-soft); color:var(--green); }
html[data-theme="dark"] .lesson-link.selected .lesson-number { background:var(--lime); color:#142b2b; }
html[data-theme="dark"] main[data-view="learn"] .lesson-content { background:transparent; }
html[data-theme="dark"] .lesson-intro { color:var(--muted); }
html[data-theme="dark"] .compare-card.compare-1 .eyebrow { color:var(--purple); }
/* Allow the whole lesson frame to travel, with room for its shadow. */
.lesson-workspace { min-width:0; }
.lesson-workspace > *, .topbar-account, .study-stage-content { min-width:0; }
.guided-study-frame { overflow:visible; }
.guided-stage-actions, .deck-footer, .vocab-deck-navigation, .concept-stepper { flex-wrap:wrap; gap:12px; }
.source-tag { overflow-wrap:anywhere; }
@media(max-width:680px) {
  .topbar-account { flex-wrap:wrap; gap:8px; }
  .topbar-account .local-badge { flex-basis:100%; }
  .lesson-workspace .guided-study-frame { padding:16px; }
  .lesson-workspace :is(.guided-word-card,.guided-concept-card,.guided-question) { padding:16px; }
  .rating-row .btn { min-width:0; flex:1 1 140px; }
  .page-heading { flex-wrap:wrap; }
}
@media(prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation-duration:.01ms!important; animation-iteration-count:1!important; transition-duration:.01ms!important; scroll-behavior:auto!important; }
}
