.topbar-actions{display:flex;gap:12px;align-items:center;justify-self:end;}
.theme-toggle{flex:none;position:relative;width:72px;height:38px;min-width:72px;display:inline-flex;align-items:center;justify-content:space-between;padding:0 9px!important;border:1px solid var(--line);border-radius:24px;background:var(--ink2);color:var(--paper);cursor:pointer;isolation:isolate;}
.theme-toggle svg{position:relative;width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;pointer-events:none;}
.theme-thumb{position:absolute;left:3px;top:3px;width:30px;height:30px;border-radius:50%;background:#d0f184;box-shadow:0 1px 4px #0003;transform:translateX(34px);transition:transform .18s ease;pointer-events:none;}
.theme-toggle[aria-checked=true] .theme-thumb{transform:translateX(0);background:#fff4ce;box-shadow:0 1px 4px #0003,inset 0 0 0 1px #b3924d66;}
.theme-toggle[aria-checked=false] .theme-moon{color:#24321b;}
.theme-toggle[aria-checked=true] .theme-sun{color:#704b0c;}
@media(prefers-reduced-motion:reduce){.theme-thumb{transition:none;}}
.theme-toggle:hover{border-color:var(--signal);}.theme-toggle:focus-visible{outline:2px solid var(--signal);outline-offset:3px;}
dialog>.theme-toggle{float:right;margin:6px;}.extraction-heading .theme-toggle{margin:0;}
:root[data-theme=light]{color-scheme:light;--ink:#f5f3eb;--ink2:#e9e9df;--paper:#202d26;--paper2:#45534b;--signal:#b93720;--acid:#355d19;--line:rgba(32,45,38,.2);--muted:#59645c;--danger:#b02822;--shadow:0 22px 65px #24332322;}
:root[data-theme=light] :is(.tool-rail,.editor-rail,.side-panel,.editor-topbar,.statusbar,.extractor-header,.extractor-controls,.extractor-preview-panel,.modal,.text-style-controls,.element-color-controls){background:#f5f3eb;color:#202d26;}
:root[data-theme=light] :is(.editor,.extractor,.file-card,.tool-grid button,.history-top-button,.export-name-field>span,.element-color-header>button,.eq-matrix-dimensions){background:#e9e9df;color:#202d26;}
:root[data-theme=light] :is(.rail-tool:hover,.rail-tool:focus-visible,.rail-tool.active,.editor-tool:hover,.editor-tool.active,.drop-card:hover,.drop-card.dragging,.extractor-upload-button){background:#e0e8d5;color:#202d26;}
:root[data-theme=light] :is(.stage-scroller,.visual-export-preview,.extractor-stage,.mark-crop-stage){background-color:#dce1d6;background-image:radial-gradient(#73806f33 1px,transparent 1px);}
:root[data-theme=light] :is(.brand small,.privacy-strip,.rail-label,.panel-kicker,.rail-tool,.rail-tool>span,.rail-tool small,.security-note p,.security-note strong,.intro-copy p,.drop-copy>small,.proof-row,.process-panel p,.side-panel>header,.panel-view h3,.panel-explainer,.field-label,.file-card small,.scan-result small,.mini-upload small,.model-note,.empty-note,.export-note,.tool-grid button span,.mark-editor>label,.selection-controls label,.editor-topbar span,.top-actions output,.history-row button,.segmented button,.statusbar,.modal li,.modal-warning,.compact p,.export-preview-card small,.size-meter p,.extractor-header small,.extractor-upload-button small,.extractor-hint,.extractor-status,.extract-range,.extractor-colour-row,.extractor-empty,.crop-workspace footer,.extractor-preview-panel p,.extractor-result-meta,.inline-edit-note,.library-name-field>span,.page-navigation-hint,.lift-tool-card>p,.modal-range,.modal-switch,.lift-enhancement-row>span,.text-style-controls>label,.text-colour-label,.text-custom-colour output,.mark-crop-entry small,.mark-crop-intro,.mark-crop-meta,.page-order-guide p,.elements-shortcut>p,.element-color-header small,.element-color-body>p,.element-color-body>small,.element-color-modes>button,.custom-element-color>label){color:#526047;}
:root[data-theme=light] :is(.selection-controls input[type=text],.size-fields input,.side-panel select,.library-name-field>input,.export-name-field>input,.text-custom-colour input,.element-color-controls input,.element-color-swatch output){background:#fffef8;color:#202d26;border-color:#8c998a;}
:root[data-theme=light] :is(.rich-format-row button,#textSymbols button,.math-templates button,.item-context-menu,.item-context-menu button,.eq-library-tabs button,.eq-library-grid button,.eq-recents button,.eq-edit-actions button,.selection-toolbar>button,.library-menu button){background:#f5f3eb;color:#202d26;border-color:#8c998a;}
:root[data-theme=light] :is(.text-symbols summary,.eq-dialog-heading>p:last-child,.eq-library-panel label,.eq-library-panel>small,.eq-help,#equationRecentArea>small,#mathAdvanced summary,#mathAdvanced p,.eq-dialog-footer>span){color:#526047;}
:root[data-theme=light] :is(.danger-button,.field-error,.size-meter p.fail,.remove-library-item,.selection-toolbar .floating-delete,.eq-workspace #mathError){color:#a12620;}
:root[data-theme=light] .page-thumb{color:#202d26;}
:root[data-theme=light] #extractionEditor{background:#f5f3eb;color:#202d26;}
:root[data-theme=light] #extractionEditor :is(.extraction-image-area,.extraction-viewport){background:#e2e6dc;border-color:#adb7a6;}
:root[data-theme=light] #extractionEditor :is(.workspace-popover,.extraction-proposal){background:#edf1e6;color:#202d26;border-color:#adb7a6;}
:root[data-theme=light] #extractionEditor :is(.extraction-field,.extraction-hint,small,summary,.extraction-link,.extraction-comparison strong,.workspace-popover p){color:#46583e;}
:root[data-theme=light] #extractionEditor :is(button:not(.primary-button),select,textarea,input[type=number],input[type=text],input:not([type])){background:#fffef8;color:#202d26;border-color:#91a084;}
:root[data-theme=light] #extractionEditor :is(button[aria-pressed=true],#flowAccept,#flowContinue,#flowDownload,#flowFinish,#sharpenApply){background:#d1e6b5;color:#18311b;border-color:#71934e;}
:root[data-theme=light] #sharpenPanel{background:#e2ebd6;border-color:#91a084;}
/* Explicit preview backgrounds and page/annotation pixels intentionally retain their colours. */
:root[data-theme=light] .drop-card{background:#e9e9df;color:#202d26;}
:root[data-theme=light] .drop-copy>strong{color:#202d26;}
#extractionEditor .theme-toggle{font-size:26px;}
@media(max-width:680px){.topbar-actions{gap:6px;}.topbar-actions .cloud-button{font-size:11px;padding:6px;}}
