/* The light theme keeps existing brand colors; these tokens cover both shells. */
:root{color-scheme:light}
.theme-control{position:relative;display:block;flex-shrink:0;margin:0;z-index:40}
.theme-control>summary{display:grid;place-items:center;list-style:none;width:42px;height:42px;padding:0;border:1px solid #dce3ed;border-radius:10px;background:#f2f5f9;color:#536780;cursor:pointer}
.theme-control>summary::-webkit-details-marker{display:none}
.theme-control svg{width:19px;height:19px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;pointer-events:none;flex-shrink:0}
.theme-control [data-theme-icon]{display:none}.theme-control [data-theme-icon=system]{display:block}
:root[data-theme-preference] .theme-control [data-theme-icon]{display:none}
:root[data-theme-preference=system] .theme-control [data-theme-icon=system],:root[data-theme-preference=light] .theme-control [data-theme-icon=light],:root[data-theme-preference=dark] .theme-control [data-theme-icon=dark]{display:block}
.theme-options{position:absolute;right:0;top:calc(100% + 8px);width:185px;max-width:calc(100vw - 32px);padding:6px;border:1px solid #dce3ed;border-radius:12px;background:#fff;box-shadow:0 10px 32px #172b4d26}
.theme-options button{display:flex;align-items:center;gap:12px;width:100%;min-height:44px;padding:10px;border:0;border-radius:7px;background:transparent;color:#536780;text-align:left;font-size:14px;cursor:pointer}
.theme-options button:hover{background:#edf3fd;color:#254f91}.theme-options button[aria-pressed=true]{background:#e8f0fc;color:#254f91;font-weight:650}
.theme-control>summary:focus-visible,.theme-options button:focus-visible{outline:2px solid #668bc5;outline-offset:2px}
.auth-theme{display:flex;justify-content:flex-end;margin-bottom:24px}
:root[data-theme=dark]{color-scheme:dark;--ink:#e6edf7;--muted:#aab9cd;--brand:#a9c8ff;--brand-soft:#253752;--paper:#111923;--line:#334256;--accent:#f9cb42;--surface:#1b2635;--soft:#233145;--hover:#2b3b50;--danger-bg:#40282f;--danger-ink:#ffb8c2;--success-bg:#1d382e;--success-ink:#a4e2b7;--warning-bg:#3b3322;--warning-ink:#f5d787}
:root[data-theme=dark] body{background:var(--paper);color:var(--ink)}
:root[data-theme=dark] :is(input,select,textarea){background-color:var(--surface);border-color:var(--line);color:var(--ink)}
:root[data-theme=dark] input::placeholder,:root[data-theme=dark] textarea::placeholder{color:#96a8bf;opacity:1}
:root[data-theme=dark] :is(.topbar,.class-card,.folder-card,.empty,.profile-panel,.login-form-wrap,.login-layout,.table-scroll,#recording-table,.admin-card,.admin-section,.class-switcher-panel,.preview-recordings article,.admin-dialog,.small-button,.skip,.navigation-loading>span){background:var(--surface);border-color:var(--line);color:var(--ink)}
:root[data-theme=dark] :is(.login-story,.profile-aside,.detail-heading,.class-cover,.class-filters,.admin-tabs,.admin-sidebar){background:var(--soft);border-color:var(--line)}
:root[data-theme=dark] :is(.login-story p,.story-caption,.card-date,.table-toolbar label,.class-filters a,.class-choice,.admin-page-intro,.admin-breadcrumb>a,.admin-breadcrumb>span,.admin-breadcrumb>.admin-current-section,.admin-shell .table-tools label,.admin-shell .class-switcher-panel label,.admin-upload-zone>span:not(.upload-icon)){color:var(--muted)}
:root[data-theme=dark] :is(.accent,.card-link,.back-link,.admin-main summary){color:var(--brand)}
:root[data-theme=dark] :is(.button,.admin-shell .button){background:#315e9f;color:#fff;border-color:#668fcc;box-shadow:none}
:root[data-theme=dark] :is(.button:hover,.admin-shell .button:hover){background:#3a6eb7}
:root[data-theme=dark] :is(.outline-button,.small-button,.admin-row-button,.admin-shell .outline-button,.admin-shell .table-pager button,.class-switcher>summary,.admin-shell .topbar .text-button,.admin-dialog-close,.menu-toggle,.upload-icon){background:var(--soft);border-color:var(--line);color:var(--brand)}
:root[data-theme=dark] :is(.outline-button:hover,.small-button:hover,.admin-row-button:hover,.admin-shell .outline-button:hover,.admin-shell .table-pager button:hover:enabled,.class-switcher>summary:hover,.folder-card:hover,.class-choice:hover,.class-choice:focus-visible,.class-filters a:hover,.admin-menu-links>a:hover){background:var(--hover);border-color:#607b9f;color:var(--brand)}
:root[data-theme=dark] :is(.class-filters a[aria-current],.admin-tabs button[aria-pressed=true],.admin-tabs a[aria-current=page],.class-choice[aria-current=page]){background:#304766;color:#c5daff;box-shadow:none}
:root[data-theme=dark] :is(.admin-shell,.admin-shell .admin-main){background:var(--paper);color:var(--ink);--admin-line:var(--line)}
:root[data-theme=dark] :is(.admin-shell h1,.admin-shell h2,.admin-shell h3){color:var(--ink)}
:root[data-theme=dark] :is(.admin-table th,.recordings-table th){background:var(--soft);color:#bccce2}
:root[data-theme=dark] :is(.admin-table th,.admin-table td,.recordings-table td,.table-pagination,.form-actions,.admin-editor>.admin-actions,.login-account-help,.login-story,.admin-sidebar,.topbar,.login-help>div){border-color:var(--line)}
:root[data-theme=dark] :is(.admin-shell .admin-table tr:hover td,.recordings-table tbody tr:hover){background:var(--hover)}
:root[data-theme=dark] :is(.admin-shell input,.admin-shell select,.admin-shell textarea,.admin-shell .table-tools input,.admin-shell .table-tools select,.search-controls input){background-color:var(--surface);border-color:var(--line);color:var(--ink);box-shadow:none}
:root[data-theme=dark] :is(input:focus,select:focus,textarea:focus,.admin-shell input:focus,.admin-shell select:focus,.admin-shell textarea:focus){outline:2px solid #9bbfff;outline-offset:2px;border-color:#9bbfff;box-shadow:none}
:root[data-theme=dark] :is(.admin-upload-zone,.admin-upload-status,.admin-import-summary,.admin-action,.preview-banner){background:var(--soft);border-color:var(--line);color:var(--brand)}
:root[data-theme=dark] .admin-upload-status p{color:var(--brand)}
:root[data-theme=dark] .admin-shell input::file-selector-button{background:var(--hover);color:var(--brand)}
:root[data-theme=dark] .badge{background:var(--soft);border-color:#536780;color:#c1cddd}
:root[data-theme=dark] :is(.badge.ended,.badge.inactive,.class-note,.admin-status.draft,.admin-action.skip,.admin-shell .admin-action.skip){background:var(--soft);border-color:#536780;color:#c1cddd}
:root[data-theme=dark] :is(.badge.active,.admin-status.published,.notice.success){background:var(--success-bg);border-color:#49785d;color:var(--success-ink)}
:root[data-theme=dark] .badge.upcoming{background:#352a47;border-color:#72568c;color:#dfbdf4}
:root[data-theme=dark] :is(.badge.locked,.notice.error,.admin-shell .notice.error,.admin-row-button.danger,.admin-row-button.danger:hover,.admin-action.blocked,.admin-shell .admin-action.blocked){background:var(--danger-bg);border-color:#85505e;color:var(--danger-ink)}
:root[data-theme=dark] .recording-reason{color:var(--danger-ink)}
:root[data-theme=dark] .notice:not(.error):not(.success),:root[data-theme=dark] .folder-icon{background:var(--warning-bg);border-color:#7d6a3a;color:var(--warning-ink)}
:root[data-theme=dark] .status-tooltip{background:#e3ebf6;color:#172536;box-shadow:0 8px 24px #0005}
:root[data-theme=dark] .banner-mark,:root[data-theme=dark] .story-art span:nth-child(2){color:#244777}
:root[data-theme=dark] .learning-banner,:root[data-theme=dark] .story-art span:first-child{background:#254b82}
:root[data-theme=dark] .admin-dialog::backdrop{background:#030912b3}
:root[data-theme=dark] input:-webkit-autofill{-webkit-text-fill-color:var(--ink);box-shadow:0 0 0 1000px var(--surface) inset}
@media(max-width:640px){#primary-nav .theme-control{align-self:flex-start;margin:8px 12px}.theme-control>summary{width:44px;height:44px}.auth-theme{margin-bottom:20px}}
:root[data-theme=dark] :is(.admin-sort,.admin-tabs button,.admin-tabs a,.admin-sidebar p){color:#bacbe1}
:root[data-theme=dark] :is(.admin-tabs button[aria-pressed=true],.admin-tabs a[aria-current=page]){color:#d2e2ff}
:root[data-theme=dark] .admin-shell .table-tools select{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23bacbe1' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")}

:root[data-theme=dark] .theme-control>summary,:root[data-theme=dark] .theme-options{background:var(--surface);border-color:var(--line);color:#b7c9e2}
:root[data-theme=dark] .theme-options button{color:#b7c9e2}
:root[data-theme=dark] .theme-options button:hover{background:var(--hover);color:#e2edff}
:root[data-theme=dark] .theme-options button[aria-pressed=true]{background:#365073;color:#e2edff}
