/* The normal light palette stays unchanged. Theme selection is device-local. */
.site-theme-toggle{display:inline-flex;vertical-align:middle;align-items:center;justify-content:center;width:36px;height:36px;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--card);color:var(--muted);cursor:pointer}
.site-theme-toggle:hover{color:var(--accent);border-color:var(--accent)}
.site-theme-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.site-theme-toggle[hidden],.site-theme-toggle .theme-sun{display:none}
html[data-theme=dark] .site-theme-toggle .theme-sun{display:block}
html[data-theme=dark] .site-theme-toggle .theme-moon{display:none}
html[data-theme=dark]{
  color-scheme:dark;
  --bg:#11181f;--card:#1a242e;--ink:#e2e9ee;--muted:#a4b3be;--line:#34424d;
  --accent:#86bce6;--accent-soft:#233a4d;--green:#8dceb0;--red:#f0a39b;
  --shadow:0 5px 22px #0003;
}
html[data-theme=dark] body::before{filter:invert(1);opacity:.035}
html[data-theme=dark] :is(.site-header,.site-header.is-collapsed,.site-footer,.useful-links,.ask-modal,.stat-card,.stats-section,.selector-group,.session-card,.paper-tab,.form-card,.form-modal,.login-box,.admin-section,.admin-command-panel,.admin-calendar-editor-card,.admin-countdown-list,.admin-calendar-month,.subj-card,.tag-cloud-item,.classify-question-card,.photo-upload-card){background:var(--card);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] .admin-calendar-month.is-active:not([data-wallpaper="october-2026"]):not(.has-custom-wallpaper){background-color:var(--card);background-image:linear-gradient(rgba(26,36,46,.88),rgba(26,36,46,.88)),url('/static/calendar-august-2026.jpg');background-position:center,center 60%;background-repeat:no-repeat;background-size:cover,auto 200%}
html[data-theme=dark] .admin-calendar-month.is-active[data-wallpaper="october-2026"]:not(.has-custom-wallpaper){background-color:var(--card);background-image:linear-gradient(rgba(26,36,46,.88),rgba(26,36,46,.88)),url('/static/calendar-october-2026.webp');background-position:center;background-repeat:no-repeat;background-size:cover}
html[data-theme=dark] .admin-calendar-month:is([data-wallpaper="october-2026"],.has-custom-wallpaper) :is(.admin-calendar-day,.admin-calendar-day-number,.admin-calendar-day-note){color:var(--ink)}
html[data-theme=dark] .admin-calendar-month:is([data-wallpaper="october-2026"],.has-custom-wallpaper) .admin-calendar-day.has-note{background:#273b34}
html[data-theme=dark] .admin-calendar-month:is([data-wallpaper="october-2026"],.has-custom-wallpaper) .admin-calendar-day.is-holiday{background:#49313c}
html[data-theme=dark] .admin-calendar-month:is([data-wallpaper="october-2026"],.has-custom-wallpaper) .admin-calendar-day.is-today{background:#493d26}
html[data-theme=dark] .admin-calendar-month:is([data-wallpaper="october-2026"],.has-custom-wallpaper) button.admin-calendar-day:hover{background:#2a3c46}
html[data-theme=dark] .site-header-handle{background:#6f8798}
html[data-theme=dark] .mode-teacher{background:#30291f;color:#e3bd7e;border-color:#4b4030}
html[data-theme=dark] .mode-student{background:#1c3041;color:#99c5e8;border-color:#354d60}
html[data-theme=dark] .site-footer{color:var(--muted);border-color:var(--line)}
html[data-theme=dark] :is(.footer-disclaimer,.footer-three-col .footer-left,.link-host,.links-hint,.card-notes){color:var(--muted)}
html[data-theme=dark] :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),select,textarea){background:#151e27;color:var(--ink);border-color:#425564;color-scheme:dark}
html[data-theme=dark] :is(input,textarea)::placeholder{color:#91a2af;opacity:1}
html[data-theme=dark] .btn{background:#315775;color:#f0f6fa}
html[data-theme=dark] .btn-outline{background:transparent;color:var(--accent);border-color:var(--accent)}
html[data-theme=dark] .btn-danger{background:transparent;color:var(--red)}
html[data-theme=dark] .btn:hover{filter:brightness(1.12)}
html[data-theme=dark] .card-pinned{border-color:#8b7442;box-shadow:0 0 0 1px #8b744233}
html[data-theme=dark] .pin-badge{background:#3a3020;color:#e3bf7e}
html[data-theme=dark] :is(.tag,.tag-subject,.tag-year,.tag-paper,.tag-session){background:#263747;color:#bdcddd;border-color:#425767}
html[data-theme=dark] :is(.classify-entry-btn,.photo-search-entry-btn){background:linear-gradient(135deg,#1d2b35,#203b3b);border-color:#3b535a;color:#e0eae9;box-shadow:var(--shadow)}
html[data-theme=dark] :is(.classify-entry-sub,.photo-search-scope,.question-entry-copy,.question-entry-copy strong){color:#bdcece}
html[data-theme=dark] .question-entry-vip{background:#3b3023;color:#e3c28e;border-color:#69563e}
html[data-theme=dark] .easter-egg .egg-pop{background:#233a4d;color:#c9e0f2}
html[data-theme=dark] :is(.pika-bg,.pika2-bg){opacity:.12}
html[data-theme=dark] :is(.data-table,.data-table th,.data-table td){border-color:var(--line)}
html[data-theme=dark] .data-table th{background:#23313e;color:var(--ink)}
html[data-theme=dark] .data-table tr:hover{background:#25313c}
html[data-theme=dark] :is(.flash,.q-item,.admin-tool-btn,.admin-calendar-entry,.admin-upload-entry){background:#23313b;color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(.admin-command-heading strong,.admin-tool-btn strong,.admin-calendar-entry strong,.subj-card-label,.subj-group-title,.q-msg){color:var(--ink)}
html[data-theme=dark] :is(.admin-command-heading p,.admin-tool-btn small,.subj-card-cnt,.tag-cloud-cnt){color:var(--muted)}
html[data-theme=dark] :is(.admin-tool-btn.active,.admin-tool-btn.is-primary,.tag-cloud-item.active){background:#315775;color:#f0f6fa}
html[data-theme=dark] :is(.teaching-page,.admin-calendar-page){--tt-ink:#e2e9ee;--tt-accent:#8bc4c3;--calendar-green:#97c3b4}
html[data-theme=dark] :is(.teaching-tool-card,.qs-panel,.qs-layout aside,.s1-input-panel,.s1-output-panel){background:linear-gradient(135deg,#1a242e,#1c2d32);border-color:var(--line);color:var(--ink);box-shadow:var(--shadow)}
html[data-theme=dark] :is(.teaching-back,.teaching-hero>p:last-child,.teaching-tool-card p,.qs-panel>p,.qs-page label,.qs-toolbar label,.qs-layout aside h2,.s1-page label,.s1-help){color:var(--muted)}
html[data-theme=dark] :is(.teaching-eyebrow,.teaching-tool-open,.teaching-tool-icon,.qs-page summary){color:#91c6c5}
html[data-theme=dark] .teaching-tags span{background:#253943;color:#c0d3d8;border-color:#405763}
html[data-theme=dark] .qs-page #qs-modules button{background:transparent;color:#c1d4d3;border-color:transparent}
html[data-theme=dark] .qs-page #qs-modules button[aria-current=true]{background:transparent;border-color:transparent;color:#f3fbf7}
html[data-theme=dark] :is(.qs-page #qs-modules small,#qs-count,#qs-status,.qs-savebar p,.qs-legend){color:#a8beb4}
html[data-theme=dark] :is(.qs-savebar,.qs-grid label){background:#1c2930;color:#c8d6da;border-color:#3c5059}
html[data-theme=dark] .qs-grid label:has(:checked){background:#254136;border-color:#527d67;color:#c0e5cd}
html[data-theme=dark] .qs-grid label.qs-pending-add{background:#243e57;border-color:#719dc4;color:#c2e1fc}
html[data-theme=dark] .qs-grid label.qs-pending-remove{background:#493525;border-color:#b08861;color:#f1cc9f}
html[data-theme=dark] .qs-savebar strong{color:#b4d8c6}
html[data-theme=dark] .qs-page .qs-secondary{background:#24353c;color:#b3d6d5;border-color:#53777b}
html[data-theme=dark] :is(.qs-batch,.qs-toolbar){border-color:var(--line)}
html[data-theme=dark] .qs-page progress::-webkit-progress-bar{background:#34423f}
html[data-theme=dark] .qs-module-row.qs-dragging{background:#29403f}
html[data-theme=dark] #qs-status.error{color:var(--red)}
html[data-theme=dark] .qs-aside-head{border-color:#34474a}
html[data-theme=dark] .qs-aside-head>div>span{color:#78918b}
html[data-theme=dark] .qs-layout aside .qs-aside-head h2{color:#e2eeeb}
html[data-theme=dark] .qs-aside-head>strong{background:#293c3e;color:#9dc8bc}
html[data-theme=dark] .qs-module-row:not(.is-current):hover{background:#243337;border-color:#3b5154;box-shadow:none}
html[data-theme=dark] .qs-module-title{color:#c6d8d4}
html[data-theme=dark] .qs-module-progress{background:#34494a}
html[data-theme=dark] .qs-module-row.is-current{background:linear-gradient(145deg,#245b57,#326f66);border-color:#4c7f76;box-shadow:0 14px 30px #07120f55}
html[data-theme=dark] #qs-create{border-color:#34474a}
html[data-theme=dark] #qs-create>summary:hover{background:#243739}
/* Plot canvases and original question/PDF images intentionally keep their native colors. */
@media(max-width:600px){
  .site-theme-toggle{width:32px;height:32px}
  .site-header nav{display:flex;align-items:center;flex-wrap:wrap;justify-content:flex-end;gap:8px}
  .site-header nav a{margin-left:0}
}
@media print{
  .site-theme-toggle{display:none!important}
}
html[data-theme=dark] :is(.admin-command-center,.admin-upload,.auth-box,.data-table,.drop-zone,.photo-search-form,.photo-upload-dropzone,.photo-camera-row,.photo-preview,.s1-saved-data,.s1-summary,.s1-share-manager,.s1-chart-tabs){background:var(--card);color:var(--ink);border-color:var(--line)}
html[data-theme=dark] :is(.guest-extra-btn,.invite-gate-btn){background:#23313b;color:#bdcbd4;border-color:#405461}
html[data-theme=dark] :is(.guest-extra-btn.on,.invite-gate-btn.on){background:#244238;color:#b6dfca;border-color:#496a59}
html[data-theme=dark] :is(.admin-tool-icon,.admin-access-icon,.admin-calendar-entry-icon){background:#2a454c;color:#acd2d5}
html[data-theme=dark] :is(.admin-calendar-entry-copy>span,.admin-access-copy small,.photo-capture-tip,.s1-conventions summary,.s1-summary strong,.s1-group-table td,.s1-input-title,.s1-share-manager summary,.s1-image-status){color:#afc5ce}
html[data-theme=dark] .photo-capture-tip{background:#352e23;color:#ddc69e}
html[data-theme=dark] .photo-upload-dropzone.has-file{background:#244238;border-color:#496a59}
html[data-theme=dark] .s1-page button{background:#253943;color:#c2d7dd;border-color:#405965}
html[data-theme=dark] .s1-page :is(.s1-slot-tabs [aria-pressed=true],.s1-chart-tabs button[aria-pressed=true]){background:#305951;color:#d1eee2;border-color:#639c8c}
html[data-theme=dark] .s1-page.is-input-collapsed .s1-input-panel{background:#1c2d32}
html[data-theme=dark] .s1-chart-frame{color-scheme:light;color:#254c5d}
html[data-theme=dark] .easter-egg{background:#233a4d;border-color:#425767;color:#c9e0f2}
html[data-theme=dark] .easter-egg .egg-pop{background:transparent}
html[data-theme=dark] .card-pinned{box-shadow:0 0 0 1px #8b744233!important}
html[data-theme=dark] :is(.classify-entry-btn,.photo-search-entry-btn){box-shadow:var(--shadow)!important}
@media(max-width:600px){.pika2-bg{right:12px}}
