.header-actions { display: flex; align-items: center; gap: 12px; }
.theme-picker { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.theme-picker .icon { width: 17px; height: 17px; }
.theme-picker select { min-height: 40px; max-width: 116px; padding: 6px 8px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; font-size: .8125rem; cursor: pointer; }
.login-main { position: relative; padding-top: 84px; }
.login-theme { position: absolute; top: 24px; right: 28px; }
@media (max-width: 700px) {
  .header-actions { gap: 4px; }
  .topbar { gap: 8px; padding-inline: 16px; }
  .header-actions .theme-picker .icon { display: none; }
  .theme-picker select { max-width: 100px; font-size: .75rem; }
  .header-actions .btn { padding-inline: 6px; font-size: .75rem; gap: 5px; }
  .header-actions .btn .icon { width: 16px; }
  .login-theme { top: 16px; right: 20px; }
}
@media print { .theme-picker { display: none; } }

@media screen {
  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #121b1a;
    --paper: #1b2927;
    --ink: #edf3ef;
    --muted: #abbdb7;
    --line: #344541;
    --navy: #86cbbb;
    --navy2: #a4dfd1;
    --teal: #83caba;
    --red: #f2a1a7;
    --blue: #a1c4ec;
    --surface-soft: #233631;
    --surface-selected: #2b4940;
  }
  html[data-theme="dark"] :is(.sidebar, .topbar, .bottom-nav, .login-card, .panel, .metric, .exam-row, .exam-filter-body, .ops-metrics section, .release-batch-save, .video-course-card, .video-lesson-row, .video-admin-course-list>button, .answer-summary-grid>div, .skip) {
    background: var(--paper); color: var(--ink); border-color: var(--line); box-shadow: none;
  }
  html[data-theme="dark"] .login-main { background: var(--bg); }
  html[data-theme="dark"] .exam-list { background: transparent; }
  html[data-theme="dark"] :is(.input, .icon-btn, .btn.secondary, .answer-option span, .teacher-mobile-menu select) {
    background: #16221f; color: var(--ink); border-color: #4e655c;
  }
  html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #9cb0a8; opacity: 1; }
  html[data-theme="dark"] input { accent-color: var(--teal); }
  html[data-theme="dark"] .btn:not(.secondary):not(.text):not(.deletion-danger) { color: #112522; }
  html[data-theme="dark"] :is(.btn.text:hover, .btn.secondary:hover, .icon-btn:hover, .exam-row:hover, .video-lesson-row:hover, .sidebar .navitem:hover) { background: var(--surface-soft); color: var(--ink); }
  html[data-theme="dark"] :is(.sidebar .navitem, .profile small, .roster-heading p, .roster-person p, .roster-count, .solution-body, .metric.primary label, .metric.primary p, .metric.primary strong small) { color: var(--muted); }
  html[data-theme="dark"] :is(.sidebar .navitem.active, .bottom-nav .navitem.active, .video-admin-course-list>button.active, .video-admin-course-list>button:hover, .video-group-choice:has(input:checked), .video-course-card[open] .video-course-toggle, .roster-groups button[aria-pressed="true"], [data-action="upload-round"][aria-pressed="true"]) {
    background: var(--surface-selected); color: #b9efda; border-color: #5f9984;
  }
  html[data-theme="dark"] :is(.sidebar .brand, .topbar .brand, .profile strong) { color: var(--ink); }
  html[data-theme="dark"] .sidebar .mark { background: #326b5b; color: #f0fff8; }
  html[data-theme="dark"] :is(.profile .avatar, .filter, .notice, .manual-answer-item, .manual-preview, .upload-zone, .import-cards>div, .activation-card code, .score-metrics>div, .item-analysis tbody th, .video-group-choice, .answer-summary-grid span, .solution-body p:first-child, .formula) {
    background: var(--surface-soft); color: var(--ink); border-color: var(--line);
  }
  html[data-theme="dark"] .filter button.active { background: #3a564b; color: #f0fff8; }
  html[data-theme="dark"] :is(.metric.primary, .submission-callout, .exam-name-preview, .study-note, .answer-pair>div+div, .item-key, .correction-changed, .receipt-icon) {
    background: #203c32; color: var(--ink); border-color: #3c6352;
  }
  html[data-theme="dark"] :is(.exam-name-preview span, .submission-callout p, .study-note) { color: #b6dbc8; }
  html[data-theme="dark"] :is(.exam-symbol, .exam-row:nth-child(1) .exam-symbol) { color: #b6dbc8; background: #294237; border-color: #426151; }
  html[data-theme="dark"] .badge { background: #253630; color: #dbe8df; border-color: #4d6357; }
  html[data-theme="dark"] .badge.teal { background: #29473a; color: #b3e8cf; border-color: #4d7663; }
  html[data-theme="dark"] .badge.blue { background: #293d50; color: #c2dcf7; border-color: #49667e; }
  html[data-theme="dark"] .badge.orange { background: #493e26; color: #f3d591; border-color: #7c6b43; }
  html[data-theme="dark"] :is(.error, .clear-answer:hover) { color: #ffc1c6; background: #462c30; }
  html[data-theme="dark"] :is(.release-exam.release-unsaved, .ops-alert) { background: #3c3524; border-color: #a88d4e; color: #f1d491; }
  html[data-theme="dark"] .release-unsaved .release-status { color: #f1d491; }
  html[data-theme="dark"] :is(.result-top, .continue-card) { background: #23483e; color: #f0fff8; }
  html[data-theme="dark"] .qbtn { background: #29473a; color: #b3e8cf; border-color: #4d7663; }
  html[data-theme="dark"] .qbtn.wrong { background: #482e33; color: #ffc1c6; border-color: #965f69; }
  html[data-theme="dark"] .qbtn.invalid { background: #303c3a; color: #c1cfca; border-color: #596963; }
  html[data-theme="dark"] .qbtn.selected { outline-color: var(--teal); box-shadow: 0 0 0 2px var(--teal); }
  html[data-theme="dark"] .answer-option input:checked+span { color: #112522; background: var(--teal); border-color: var(--teal); }
  html[data-theme="dark"] .answer-summary-grid .blank { border-color: #965f69; }
  html[data-theme="dark"] .answer-summary-grid .blank span { background: #482e33; color: #ffc1c6; }
  html[data-theme="dark"] :is(.bar-track, .score-bars i, .item-rate span, .ops-progress>span) { background: #354740; }
  html[data-theme="dark"] .bar-fill { background: #687d74; }
  html[data-theme="dark"] :is(.bar-row.key .bar-fill, .score-bars b) { background: #75ba9c; }
  html[data-theme="dark"] .bar-row.mine:not(.key) .bar-fill { background: #85a9d6; }
  html[data-theme="dark"] .bar-note { color: var(--ink); background: #23483e; }
  html[data-theme="dark"] .content svg text { fill: var(--muted); }
  html[data-theme="dark"] .content svg line { stroke: var(--line); }
  html[data-theme="dark"] .content svg circle[fill="white"] { fill: var(--paper); }
  html[data-theme="dark"] .content svg polyline { stroke: var(--teal); }
  html[data-theme="dark"] .content svg circle[fill="#168575"] { fill: var(--teal); }
  html[data-theme="dark"] :is(.trend-table td, .trend-table th, .roster-person, .mapping>div, .review-row, .toggle-row) { border-color: var(--line); }
  html[data-theme="dark"] :is(#correction-dialog, #deletion-dialog) { color: var(--ink); background: var(--paper); border-color: var(--line); }
  html[data-theme="dark"] :is(#correction-dialog, #deletion-dialog)::backdrop { background: #050c0bc9; }
  html[data-theme="dark"] .deletion-danger { background: #a83843; color: #fff; }
  html[data-theme="dark"] .deletion-danger:hover { background: #bf4350; }
  html[data-theme="dark"] .upload-file-input::file-selector-button { color: var(--ink); background: var(--surface-soft); border-color: var(--line); }
  html[data-theme="dark"] .upload-zone input::file-selector-button { color: #112522; }
  html[data-theme="dark"] #toast { background: #d5e9df; color: #162d24; }
  html[data-theme="dark"] .submission-summary progress::-webkit-progress-bar { background: #354740; }
}
