.theme-control{position:relative;flex:none}
.theme-switch{display:flex;gap:2px;align-items:center;padding:4px;border:1px solid var(--line);border-radius:30px;background:#eee5f7;color:#432060;min-width:88px;min-height:44px}
.theme-switch span{display:grid;place-items:center;width:34px;height:34px;border-radius:50%;font-size:1.4rem;line-height:1}
.theme-switch[aria-checked=false] .theme-sun{background:white;box-shadow:0 1px 5px #43206033}
.theme-switch[aria-checked=true] .theme-moon{background:#bd9cf4;color:#201332;box-shadow:0 1px 5px #0005}
.theme-error{position:absolute;right:0;top:100%;width:240px;padding:12px;background:var(--panel);color:var(--text);border:1px solid var(--line);z-index:30}
@media screen{
  :root[data-theme=dark]{color-scheme:dark;--bg:#15101f;--panel:#211a2d;--surface:#2b2239;--line:#534463;--text:#f2eaf9;--muted:#c2b4d1;--heading:#dfc6ff;--purple:#c8a6ff;--gold:#ffd36c;--green:#95e2bc;--family-blue:#202d42;--family-lilac:#30243f;--shadow:0 12px 35px #0003}
  [data-theme=dark] body{background:var(--bg);color:var(--text)}
  [data-theme=dark] :is(.topbar,.nav-group>div,.auth-panel,.panel,.stat,.question-panel,.result-panel,.tool-card,.content-card,.preview-question,.composer-selection>li,.composer-results>article,.school-media,.pei-step,.family-rule){background:var(--panel);border-color:var(--line);color:var(--text)}
  [data-theme=dark] :is(.dashboard-hero,.student-hero,.help-hero,.subject-card,.prediction-band,.prediction-student,.knowledge-ruler,.ruler-topic,.access-mode,.filter-bar,.report-filters,.advanced-filters,.floating-note,.selection-item,.paper-notice,.guidance-note,.student-writing,.pei-goal,.history-card,.dialogue-preview blockquote){background:var(--surface);border-color:var(--line);color:var(--text)}
  [data-theme=dark] :is(h1,h2,h3,h4,.page-heading h1,.dashboard-hero h1,.brand strong){color:var(--heading)}
  [data-theme=dark] :is(label,legend,th,td,.tag,.hero-badge,.context-pill,.context-pill span,.section-tabs,.form-stack,.prediction-current,.prediction-progress strong){color:var(--text);border-color:var(--line)}
  [data-theme=dark] :is(input,select,textarea){background:#191322;color:var(--text);border-color:#75618b}
  [data-theme=dark] input::placeholder,[data-theme=dark] textarea::placeholder{color:#b7a8c5}
  [data-theme=dark] :is(input[type=checkbox],input[type=radio],progress){accent-color:#c8a6ff}
  [data-theme=dark] :is(.muted,.data-note,.environment-label,.footer,.stat small,.page-heading p,.student-hero p,.brand small,.guidance-note span,.subject-discipline,.family-snapshot small){color:var(--muted)}
  [data-theme=dark] .page a:not(.button):not(.tool-card),[data-theme=dark] :is(.text-button,.subtle-link,.back-link,.round-link,.section-tabs a,.topbar nav a,.nav-group summary,.help-faq summary,details summary){color:#d7b5ff}
  [data-theme=dark] .button{background:#c9a5f7;color:#21112f;border-color:#c9a5f7}
  [data-theme=dark] .button.secondary{background:#322540;color:#ead9ff;border-color:#806096}
  [data-theme=dark] :is(.tag,.hero-badge,.section-tabs a,.theme-switch){background:#30243f;color:#e1c7ff;border-color:#725782}
  [data-theme=dark] :is(.eyebrow,.brand em,.subject-progress strong){color:#e3c0ff}
  [data-theme=dark] :is(.notice,.notice.success){background:#23382f;color:#c5f6dc;border-color:#547e69}
  [data-theme=dark] :is(.notice.error,.notice.danger){background:#432735;color:#ffd1da;border-color:#a76379}
  [data-theme=dark] .notice.warning{background:#3e3321;color:#ffe1a1;border-color:#947a45}
  [data-theme=dark] :is(.band.critical,.prediction-band.critical .band){color:#ffadb9}
  [data-theme=dark] :is(.band.attention,.prediction-band.attention .band){color:#ffda99}
  [data-theme=dark] :is(.band.developing,.prediction-band.developing .band){color:#9de7c1}
  [data-theme=dark] :is(.band.proficient,.prediction-band.proficient .band){color:#dcc0ff}
  [data-theme=dark] .table-scroll{border-color:var(--line)}
  [data-theme=dark] :is(.context-pill,.footer,thead,th,.topbar nav a[aria-current=page],.stat-icon){background:var(--surface);color:var(--text)}
  [data-theme=dark] :is(.stat>strong,.prediction-band>strong,.performance-band>strong,.result-percent){color:var(--heading)}
  [data-theme=dark] :is(.stat>span,.dashboard-hero p,.student-name small,.subject-meta small){color:var(--muted)}
  [data-theme=dark] progress,[data-theme=dark] progress::-webkit-progress-bar{background:#493952}
  [data-theme=dark] :is(.journey-stage,.riasec-card,.leveling-card,.riasec-legend div,.map-card,.map-empty,.character-placeholder,.character-portrait,.round-link,.ruler-track span,.report-metrics article,.prediction-no-data,.current-journey-position){background:var(--surface);border-color:var(--line);color:var(--text)}
  [data-theme=dark] :is(.compact-metrics dd,.journey-topic-list strong,.riasec-legend dd,.report-metrics strong,.guidance-note strong){color:var(--heading)}
  [data-theme=dark] :is(.stage-kicker,.journey-stage>p,.journey-stage>small,.journey-topic-list small,.topic-source,.leveling-position dt,.riasec-legend dt,.prediction-progress>span,.assessment-empty){color:var(--muted)}
  [data-theme=dark] .ruler-track .selected{background:#8660b1;color:white}
  [data-theme=dark] tr:hover td{background:#32273f}
  [data-theme=dark] a:focus-visible,[data-theme=dark] button:focus-visible{outline-color:#ffd36c}
}
@media print{.theme-control{display:none!important}}
