/* Theme controls share the existing navigation and settings patterns. */
:root { color-scheme:light; }
.qr-result-tools { display:flex; justify-content:flex-end; margin-bottom:8px; }
.theme-tools { display:flex; align-items:center; gap:16px; }
[data-theme-toggle] { flex:none; }
.theme-choice { max-width:320px; }
.theme-choice label { display:block; margin-bottom:8px; color:var(--ink); }
.theme-choice select { width:100%; }
.theme-choice .field-note { margin-top:10px; }
@media(max-width:760px) {
  .theme-tools { gap:10px; }
  #authPanel .theme-tools .auth-product-name { display:none; }
}
@media screen {
  :root[data-theme="dark"] {
    color-scheme:dark;
    --ground:#171b18;
    --surface:#202521;
    --raised:#272e28;
    --active:#343d34;
    --ink:#edf0e9;
    --muted:#b0baae;
    --mut:var(--muted);
    --border:#3d483d;
    --rule:#343e35;
    --control:#758371;
    --accent:#f0a063;
    --accent-hover:#ffb77f;
    --accent-pressed:#e38e50;
    --accent-soft:#3c2c20;
    --ok:#8ed5a5;
    --ok-soft:#23392c;
    --bad:#f1a39d;
    --bad-soft:#422b2b;
    --warn:#e8ca81;
    --warn-soft:#3b3423;
    --on-accent:#241a12;
    --on-strong:#171b18;
    --info:#a4c5ff;
    --info-soft:#26374d;
    --selection:#6b4327;
    --selection-ink:#fff2e6;
    --bad-border:#80504d;
    --accent-border:#765036;
    --ok-border:#4b7256;
    --hotspot:#f0a06314;
    --hotspot-hover:#f0a06329;
    --backdrop:#080c09b8;
  }
  [data-theme="dark"] body { background:var(--ground); }
  [data-theme="dark"] ::selection { background:var(--selection); color:var(--selection-ink); }
  [data-theme="dark"] :is(input,select,textarea) { background-color:var(--surface); caret-color:var(--accent); }
  [data-theme="dark"] :is(input,textarea)::placeholder { color:var(--muted); }
  [data-theme="dark"] :is(input,select,textarea):hover { border-color:var(--muted); }
  [data-theme="dark"] :is(button,.btn):active { background:var(--active); }
  [data-theme="dark"] :is(.primary,#bNewEx,.auth-submit),
  [data-theme="dark"] #authPanel :is(.auth-submit,#activateForm .primary) { color:var(--on-accent); }
  [data-theme="dark"] :is(.primary,#bNewEx,.auth-submit):hover {
    background:var(--accent-hover); border-color:var(--accent-hover);
  }
  [data-theme="dark"] :is(.primary,#bNewEx,.auth-submit):active {
    background:var(--accent-pressed); border-color:var(--accent-pressed);
  }
  [data-theme="dark"] :is(.primary,#bNewEx,.auth-submit):disabled,
  [data-theme="dark"] .team-save .primary:disabled,
  [data-theme="dark"] #authPanel .auth-submit:disabled {
    background:var(--active); color:var(--muted); border-color:var(--border);
  }
  [data-theme="dark"] :is(.secondary,.ghost):hover { border-color:var(--muted); }
  [data-theme="dark"] :is(.danger,.load-error,.team-notice.error) { border-color:var(--bad-border); }
  [data-theme="dark"] :is(.danger,.search-field,.context-field select,.types button,
    .kq button,.scan-save-actions,.lesson-practice-note,.lesson-lightbox) { background:var(--surface); }
  [data-theme="dark"] :is(.kq button.on,.toast,.skip-link) { color:var(--on-strong); }
  [data-theme="dark"] .kq button.on { background:var(--ink); }
  [data-theme="dark"] .sidebar button[data-t] { color:var(--muted); }
  [data-theme="dark"] .sidebar button[data-t]:hover { background:var(--active); }
  [data-theme="dark"] .sidebar button[data-t][aria-selected="true"] { color:var(--ink); }
  [data-theme="dark"] .account { border-color:var(--border); }
  [data-theme="dark"] .avatar { background:var(--accent-soft); color:var(--accent); }
  [data-theme="dark"] :is(.breadcrumb>.icon,.upload-icon,.status-tag.neutral,.team-badge.disabled) { color:var(--muted); }
  [data-theme="dark"] :is(.operation-notice,.status.err,.load-error p,.chip.w) { color:var(--bad); }
  [data-theme="dark"] .chip.c { color:var(--ok); }
  [data-theme="dark"] .chip.b { color:var(--info); background:var(--info-soft); }
  [data-theme="dark"] .result-answer-legend>.b::before,
  [data-theme="dark"] .report-response-bar .b { background:var(--info); }
  [data-theme="dark"] .bubble-strip i { border-color:var(--control); }
  [data-theme="dark"] .upload-area { background:var(--raised); border-color:var(--control); }
  [data-theme="dark"] #t-scan.has-scan .upload-area { background:var(--surface); }
  [data-theme="dark"] .canvas-frame { background:var(--ground); }
  /* Printed sheets, camera pixels and lesson screenshots retain their real colors. */
  [data-theme="dark"] .guide-paper { background:#fff; }
  [data-theme="dark"] :is(.team-person[aria-pressed="true"],.overview-focus) { border-color:var(--accent-border); }
  [data-theme="dark"] :is(.team-badge.invited,.team-badge.suspended) { color:var(--warn); }
  [data-theme="dark"] .team-notice { border-color:var(--ok-border); }
  [data-theme="dark"] .overview-focus h2 { color:var(--accent); }
  [data-theme="dark"] #authPanel { --auth-paper-ground:var(--raised); --auth-line:var(--border); }
  [data-theme="dark"] #authPanel .auth-status.error { background:var(--bad-soft); }
  [data-theme="dark"] .lesson-hotspot { background:var(--hotspot); }
  [data-theme="dark"] .lesson-hotspot:hover { background:var(--hotspot-hover); }
  [data-theme="dark"] .lesson-hotspot span { color:var(--on-accent); }
  [data-theme="dark"] .manage-dialog::backdrop,
  [data-theme="dark"] .lesson-lightbox::backdrop,
  [data-theme="dark"] .nav-backdrop { background:var(--backdrop); }
}
@media print { [data-theme-toggle],.theme-choice { display:none!important; } }
