/* Color-only themes over the existing Clearpath layout. Emerald intentionally
 * has no page overrides: it is the current production presentation. Root data
 * selectors outrank page-local token defaults without changing dimensions.
 * Math paper and semantic states have separate roles from decorative accents.
 */
:root { --ap-on-primary:#fff; --ap-paper:#fff; --ap-paper-ink:#102333; --ap-paper-muted:#536781; --ap-paper-line:#d3dfdf; --ap-error-bg:#fff0f2; --ap-error-ink:#8c1c2c; --ap-error-line:#d72a3d; }
html[data-theme="oxford"] body.clearpath {
  --cp-bg:#f3f6fa; --cp-surface:#fff; --cp-soft:#eaf1fa; --cp-ink:#132238;
  --cp-muted:#526178; --cp-primary:#24559a; --cp-primary-hover:#193f77; --cp-line:#bdcce0; --cp-focus:#895519;
}
html[data-theme="sunshine"] body.clearpath {
  --cp-bg:#fff9e9; --cp-surface:#fff; --cp-soft:#fff0bd; --cp-ink:#27245b;
  --cp-muted:#5d5773; --cp-primary:#373078; --cp-primary-hover:#272259; --cp-line:#d8c98f; --cp-focus:#755600;
}
html[data-theme="lilac"] body.clearpath {
  --cp-bg:#f4f0ff; --cp-surface:#fff; --cp-soft:#eae2ff; --cp-ink:#25203e;
  --cp-muted:#605779; --cp-primary:#5b3aa5; --cp-primary-hover:#452a84; --cp-line:#cfc1e8; --cp-focus:#8b4d0d;
}
html[data-theme="autumn"] body.clearpath {
  --cp-bg:#fbf6ed; --cp-surface:#fff; --cp-soft:#efe4d2; --cp-ink:#382c23;
  --cp-muted:#6e5b4b; --cp-primary:#895122; --cp-primary-hover:#6a3b18; --cp-line:#d3bea5; --cp-focus:#285a48;
}
html[data-theme="spring"] body.clearpath {
  --cp-bg:#f5f8ef; --cp-surface:#fff; --cp-soft:#e5eddc; --cp-ink:#24352a;
  --cp-muted:#526650; --cp-primary:#3d6248; --cp-primary-hover:#2a4b34; --cp-line:#bfcdb3; --cp-focus:#925019;
}
html[data-theme="paper"] body.clearpath {
  --cp-bg:#fff; --cp-surface:#fff; --cp-soft:#f1f3f5; --cp-ink:#111827;
  --cp-muted:#374151; --cp-primary:#172b4d; --cp-primary-hover:#0b192e; --cp-line:#64748b; --cp-focus:#005b59;
  --ap-paper-ink:#111827; --ap-paper-muted:#374151; --ap-paper-line:#64748b;
}
html[data-theme="midnight"] body.clearpath {
  --cp-bg:#101923; --cp-surface:#192733; --cp-soft:#243a4a; --cp-ink:#f3f6fa;
  --cp-muted:#bfcedc; --cp-primary:#67d6e5; --cp-primary-hover:#9ce9f2; --cp-line:#6c879b; --cp-focus:#ffda79;
  --ap-on-primary:#102333;
  color-scheme:dark;
}
/* Legacy colors are aliases, not a second theme system. Avoid filtering the
 * entire page: filters would recolor graphs, uploaded pages and math images. */
html[data-theme]:not([data-theme="emerald"]) body.clearpath { --cp-green:var(--cp-primary); --blue:var(--cp-primary); --green-dark:var(--cp-primary-hover); --cp-danger:#b93243; }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.cp-problem-header,.card,.question-box,.solution-box,.visual-aid-box,.graph-box,.quiz-question,.subscription-plan,.subscription-current,.exam-card,.exam-question-nav,.cp-admin-nav,.section,.login-box) { background:var(--cp-surface); color:var(--cp-ink); border-color:var(--cp-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.cp-set-progress,.realtime-controls,.cp-feedback-options,.cp-quiz-resume,#exam-cost-note,.subscription-simulation,.editor-tools .button,.cp-equation-top .equation-builder,.pricing-featured-badge) { background:var(--cp-soft); color:var(--cp-ink); border-color:var(--cp-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]),select,textarea) { color:var(--cp-ink); background:var(--cp-surface); border-color:var(--cp-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.cp-brand-mark,.cp-signup,.button.primary,.primary-button,.referral-copy-button.copied) { color:var(--ap-on-primary); background:var(--cp-primary); border-color:var(--cp-primary); }
html[data-theme="midnight"] body.clearpath :is(button,.cp-question-dot[aria-current="step"]) { color:var(--ap-on-primary); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.button.secondary,.secondary-button,.cp-quiet-button,.cp-question-dot:not([aria-current="step"]),.saved-exam-list a) { background:var(--cp-surface); color:var(--cp-ink); border-color:var(--cp-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.cp-logout,.logout-btn,.appearance-toggle,.appearance-close,.referral-copy-button:not(.copied),#package-refresh,#package-cancel,#realtime-settings-refresh) { background:var(--cp-surface); color:var(--cp-ink); border-color:var(--cp-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.delete-btn,.danger-button) { background:#fff0f2; color:#8c1c2c; border-color:#bd5264; }
html[data-theme]:not([data-theme="emerald"]) body.clearpath.cp-admin button:hover { background:var(--cp-primary-hover); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath button:is(.delete-btn,.danger-button):hover { background:#fce3e7; color:#8c1c2c; }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(#quick-math-tools,#math-palette,#equation-templates,.editor-tools) button { color:var(--cp-ink); background:var(--cp-soft); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(#reveal-step-hint,#reveal-attempt-hint) { background:transparent; color:var(--cp-primary); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.tier-account-status,.tier-lock-note,.excluded,.exam-note) { color:var(--cp-muted); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(th,thead) { color:var(--cp-ink); background:var(--cp-soft); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(td,tr) { border-color:var(--cp-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath .cp-icon-stars { background:var(--cp-primary); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath .cp-skip-link { background:var(--cp-surface); color:var(--cp-ink); border-color:var(--cp-primary); }
/* State colors stay independent of theme accents. Every marked step still has
 * the existing icon/text and controller-owned class; theming never marks work. */
html[data-theme]:not([data-theme="emerald"]) body.clearpath .work-line.work-line-issue { background:var(--ap-error-bg); border-color:var(--ap-error-line); color:var(--ap-error-ink); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath .work-line.work-line-issue::after { background:var(--ap-error-line); }
html[data-theme]:not([data-theme="emerald"]) body.clearpath :is(.error-msg,.auth-alert) { background:#fff0f2; color:#8c1c2c; border-color:#bd5264; }
/* Midnight surrounds bright math paper, like the approved mock. Variables are
 * scoped inside the paper so MathLive prose, caret, fractions and line numbers
 * all stay dark/readable, including a focused equation and the hint gutter. */
html[data-theme="midnight"] body.clearpath :is(.editor-shell,.cp-problem-header .question-card) {
  --cp-ink:var(--ap-paper-ink); --cp-muted:var(--ap-paper-muted); --cp-line:var(--ap-paper-line);
  --cp-primary:#176b57; --cp-primary-hover:#115340; --cp-soft:#e7f0eb; --cp-surface:var(--ap-paper);
  color:var(--ap-paper-ink); background:var(--ap-paper); color-scheme:light;
}
html[data-theme="midnight"] body.clearpath :is(#student-work,#line-hint-rail) { color:var(--ap-paper-ink); background:var(--ap-paper); }
html[data-theme="midnight"] body.clearpath :is(#rich-work math-field,.equation-preview math-field) { color:inherit; --caret-color:#176b57; --selection-background-color:#c3e4d2; }
html[data-theme="midnight"] body.clearpath #rich-work math-field:focus-within { background:#e7f0eb; }
html[data-theme="midnight"] body.clearpath .tier-locked { color:#c4d0d9 !important; background:#2b3a46 !important; border-color:#8296a5 !important; }
html[data-theme="midnight"] body.clearpath :is(.cp-feedback-rail:has(#practice-progress[data-state="revision"]) #realtime-panel[data-status="needs_revision"],.cp-feedback-rail:has(#practice-progress[data-state="revision"]) #feedback-panel) { --cp-ink:#8c1c2c; --cp-muted:#713340; --cp-primary:#155d4a; --cp-primary-hover:#104936; --cp-surface:#fff; --cp-soft:#fce3e7; --ap-on-primary:#fff; background:#fff0f2; color:#8c1c2c; }
html[data-theme="midnight"] body.clearpath :is(.cp-feedback-rail:has(#practice-progress[data-state="revision"]) #realtime-panel[data-status="needs_revision"],.cp-feedback-rail:has(#practice-progress[data-state="revision"]) #feedback-panel) :is(p,h3,strong) { color:#8c1c2c; }
html[data-theme="midnight"] body.clearpath .annotation-note { color:#ffb8c3; }
html[data-theme="midnight"] body.clearpath.cp-admin tr:nth-child(even) td { background:var(--cp-soft); }
html[data-theme="midnight"] body.clearpath #practice-visual-dialog { background:var(--cp-surface); }
html[data-theme="midnight"] body.clearpath .teacher-note h3 { color:#ffc8ae; }
html[data-theme="midnight"] body.clearpath .feedback-inline[data-assessment="correct"] .teacher-note h3 { color:#87dfb6; }
html[data-theme="midnight"] body.clearpath .success-msg { background:#173d32; color:#a1e8cb; }
/* Dialogs use the surrounding theme, but the ink canvas remains white: its
 * pixels are recognized/uploaded and must not be inverted by appearance. */
html[data-theme]:not([data-theme="emerald"]) body.clearpath #handwriting-dialog { background:var(--cp-surface); color:var(--cp-ink); border-color:var(--cp-line); }
html[data-theme="midnight"] body.clearpath #handwriting-preview { background:#fff; color:#102333; color-scheme:light; }
/* Appearance is a compact disclosure in the existing header, never another
 * page section. The native modal is bounded for small screens and zoom. */
body.clearpath .appearance-toggle,body.clearpath .appearance-close { width:auto; min-height:36px; margin:0; padding:6px 10px; border:1px solid var(--cp-line); background:var(--cp-surface); color:var(--cp-ink); border-radius:7px; font:600 .78rem/1.4 "Segoe UI",system-ui,sans-serif; white-space:nowrap; }
body.clearpath .appearance-toggle:hover,body.clearpath .appearance-close:hover { background:var(--cp-soft); color:var(--cp-ink); border-color:var(--cp-primary); }
body.clearpath #appearance-dialog { width:min(570px,calc(100vw - 24px)); max-height:85dvh; margin:auto; padding:20px; border:1px solid var(--cp-line); border-radius:12px; background:var(--cp-surface); color:var(--cp-ink); overflow:auto; box-sizing:border-box; font:15px/1.5 "Segoe UI",system-ui,sans-serif; text-align:left; }
body.clearpath #appearance-dialog::backdrop { background:rgb(8 20 28 / .5); }
body.clearpath #appearance-dialog .appearance-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; }
body.clearpath #appearance-title { margin:0; font-size:1.25rem; color:var(--cp-ink); }
body.clearpath #appearance-description,body.clearpath #appearance-status { margin:10px 0; color:var(--cp-muted); font-size:.82rem; }
body.clearpath .appearance-choices { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
body.clearpath #appearance-dialog fieldset { min-width:0; border:0; margin:0; padding:0; }
body.clearpath #appearance-dialog legend { font-weight:650; color:var(--cp-ink); padding:0 0 5px; font-size:.85rem; }
body.clearpath #appearance-dialog .appearance-choice { display:flex; align-items:center; gap:8px; min-height:60px; margin:0 0 6px; padding:8px; border:1px solid var(--cp-line); border-radius:7px; background:var(--cp-surface); color:var(--cp-ink); cursor:pointer; box-sizing:border-box; }
body.clearpath #appearance-dialog .appearance-choice:has(input:checked) { background:var(--cp-soft); border-color:var(--cp-primary); }
body.clearpath #appearance-dialog .appearance-choice:focus-within { outline:3px solid var(--cp-focus); outline-offset:2px; }
body.clearpath #appearance-dialog input { flex:0 0 auto; width:16px; height:16px; min-height:0; margin:0; padding:0; accent-color:var(--cp-primary); }
body.clearpath .appearance-choice strong { display:block; font-size:.82rem; line-height:1.4; }
body.clearpath .appearance-choice small { display:block; color:var(--cp-muted); font-size:.7rem; line-height:1.4; }
body.clearpath .appearance-swatch { flex:0 0 14px; width:14px; height:28px; border-radius:3px; border:1px solid currentColor; }
.appearance-swatch-emerald { background:#176b57; }.appearance-swatch-oxford { background:#24559a; }
.appearance-swatch-sunshine { background:#f2c94c; }.appearance-swatch-lilac { background:#a58bdb; }
.appearance-swatch-autumn { background:#895122; }.appearance-swatch-spring { background:#729877; }
.appearance-swatch-paper { background:#172b4d; }.appearance-swatch-midnight { background:#67d6e5; }
@media(max-width:460px) { body.clearpath #appearance-dialog { padding:16px; } body.clearpath .appearance-choices { grid-template-columns:1fr; gap:10px; } }
