:root{--surface:#fff;--surface-soft:#f7f7f9;--surface-hover:#e8e9ed;--text-main:#20242a;--text-muted:#778293;--line:#e1e5ec;--accent:#226ce1;--overlay:rgba(18,30,48,.34)}
html[data-theme=dark]{color-scheme:dark;--surface:#212121;--surface-soft:#181818;--surface-hover:#303030;--text-main:#ececec;--text-muted:#aaaeb7;--line:#404044;--accent:#8db9ff;--overlay:rgba(0,0,0,.65)}
#theme-toggle{width:36px;height:36px;display:grid;place-items:center;border:0;border-radius:10px;background:var(--surface-soft);color:var(--text-main);cursor:pointer;margin-left:auto;flex-shrink:0}
#theme-toggle:hover{background:var(--surface-hover)}#theme-toggle svg{width:22px;height:22px}.topbar{gap:14px}.topbar-brand{margin-right:auto}
.topbar-brand{min-width:0;flex:1}#conversation-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.account-nav{flex-shrink:0}#account-name{max-width:110px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#open-manual-review{padding-left:35px;font-size:13px}.admin-tabs{display:flex;gap:8px;margin:0 0 22px}.admin-tabs button,.manual-primary,.manual-secondary,.manual-review-row button{border:1px solid var(--line);border-radius:10px;padding:9px 16px;background:var(--surface);color:var(--text-main);cursor:pointer}.admin-tabs .active,.admin-toolbar .active,.manual-primary{background:#286bd1;color:#fff;border-color:#286bd1}
.library-upload-panel,.community-manuals{max-width:1000px;margin:0 auto 24px}.library-upload-panel{border:1px solid var(--line);border-radius:16px;padding:18px 20px;background:var(--surface)}.library-upload-top{display:flex;align-items:center;justify-content:space-between;gap:14px}.library-upload-top h2{font-size:16px;margin:0 0 7px}.library-upload-top p,.community-manuals>p{font-size:12px;color:var(--text-muted);line-height:1.7;margin:0}.library-upload-top>div:last-child{display:flex;gap:8px;flex-shrink:0}.manual-list-notice{font-size:13px;line-height:1.6;color:var(--text-muted);margin-top:12px}.manual-own-row{display:flex;align-items:center;flex-wrap:wrap;gap:10px;border-top:1px solid var(--line);padding:12px 0;font-size:13px}.manual-own-row small{margin-left:auto;color:var(--text-muted)}.manual-own-row p{width:100%;margin:0;color:var(--text-muted);line-height:1.6}#manual-my-submissions h3{font-size:14px;margin:18px 0 8px}.manual-status{display:inline-block;font-size:12px;border-radius:6px;padding:4px 8px;background:var(--surface-soft);color:var(--text-muted)}.status-pending{color:#ad7824;background:#fff6dc}.status-approved{color:#26714b;background:#edf8f0}.status-rejected{color:#b34242;background:#fff0f0}.manual-form-dialog{width:min(620px,calc(100vw - 28px));padding:28px;border:1px solid var(--line);border-radius:20px;background:var(--surface);color:var(--text-main);max-height:90vh;overflow:auto}.manual-form-dialog h2{font-size:22px;margin:0 0 12px}.manual-form-dialog p{line-height:1.7;color:var(--text-muted);font-size:13px}.manual-form-dialog label{display:block;font-size:14px;margin:18px 0 7px}.manual-form-dialog input:not([type=checkbox]),.manual-form-dialog textarea{display:block;width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text-main);font:inherit}.manual-form-dialog textarea{resize:vertical;min-height:80px}.manual-form-dialog label.manual-consent{display:flex;align-items:flex-start;gap:9px;font-size:12px;line-height:1.7}.manual-consent input{margin-top:4px}.manual-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.manual-form-error{color:#ba4545!important;min-height:18px}.manual-form-dialog button:disabled{opacity:.55;cursor:wait}.manual-review-preview{white-space:pre-wrap;word-break:break-word;background:var(--surface-soft);border:1px solid var(--line);padding:15px;max-height:35vh;overflow:auto;line-height:1.8;font-size:13px;font-family:inherit}.manual-review-row{padding:20px;border:1px solid var(--line);border-radius:14px;margin-bottom:12px;background:var(--surface)}.manual-review-row h3{margin:0 0 10px;font-size:16px}.manual-review-row p{font-size:13px;line-height:1.7;color:var(--text-muted)}.manual-review-row>button{display:block;margin-top:13px}.community-manuals h2{font-size:20px}.community-manuals .supplement-grid{margin-top:18px}
/* Dark surfaces are explicit; original media keeps its native colours. */
html[data-theme=dark] body,html[data-theme=dark] #app-shell,html[data-theme=dark] #main,html[data-theme=dark] .topbar,html[data-theme=dark] #chat-scroll,html[data-theme=dark] #library-view,html[data-theme=dark] #admin-view{background:var(--surface);color:var(--text-main)}
html[data-theme=dark] #sidebar{background:var(--surface-soft);border-color:var(--line);color:var(--text-main)}
html[data-theme=dark] :is(button,input,textarea,select){color:inherit}html[data-theme=dark] :is(input,textarea,select){background:var(--surface);border-color:var(--line)}
html[data-theme=dark] :is(.sidebar-library.active,.sidebar-library:hover,.history-row.active,.history-row:hover,.new-chat:hover){background:var(--surface-hover)}
html[data-theme=dark] :is(.mini-logo,.hero-logo,.assistant-avatar){background:#262626;border-color:var(--line);color:#e3e7ef}
html[data-theme=dark] :is(#composer,.diagnosis-card,.detail-panel,.feature-cards article,.supplement-card,.summary-cell,.file-chip,.manual-section,.manual-case-header,.manual-card,.manual-evidence-panel,.industrial-artifact,.admin-stats>div,.personal-record){background:var(--surface);border-color:var(--line);color:var(--text-main)}
html[data-theme=dark] #composer-dock{background:linear-gradient(transparent,var(--surface) 28%)}
html[data-theme=dark] :is(.user-bubble,.conclusion,.restored-plot,.manual-evidence-frame,.manual-source-excerpt,.manual-review-preview){background:#2b2b2d;color:var(--text-main);border-color:var(--line)}
html[data-theme=dark] :is(dialog,#add-menu,#chat-model-menu,.history-context-menu,.history-menu,.manual-source-detail,#composer-notice){background:var(--surface);color:var(--text-main);border-color:var(--line)}
html[data-theme=dark] dialog::backdrop{background:var(--overlay)}
html[data-theme=dark] :is(.history-menu-item:hover,#add-menu button:hover,#chat-model-menu button:hover,#chat-model-menu button[aria-selected=true]){background:var(--surface-hover);color:var(--accent)}
html[data-theme=dark] :is(#library-cases button,#add-menu .sample-picker-row button,.conversation-action-buttons button,.restored-switch button,.plain-button,.admin-toolbar button,.admin-pagination button,.admin-table-wrap button,.manual-secondary){background:#29292b;border-color:var(--line);color:var(--text-main)}
html[data-theme=dark] #library-cases button.active{background:#253752;color:#b1ceff;border-color:#5275a9}
html[data-theme=dark] :is(.sample-picker-row,.feature-cards article,.admin-table-wrap,th,td,.manual-section,.sandbox-account-actions,.header-tag,.topbar){border-color:var(--line)}
html[data-theme=dark] :is(th,.admin-table-wrap thead,.sandbox-stats>div){background:#29292b;color:var(--text-main)}
html[data-theme=dark] :is(.manual-safety,.manual-safety-note){background:#352b23;color:#d5bb9d;border-color:#68513b}
html[data-theme=dark] :is(.header-tag,.history-heading,.history-group-title,.manual-source-meta,.manual-subtitle,.manual-caption,.manual-step-text,.manual-evidence-description,.limitations,.summary-cell h3,.file-chip small,#chat-model-trigger,.admin-heading p){color:var(--text-muted)}
html[data-theme=dark] :is(a,.manual-source-chip,.restored-signal h3,.industrial-result-heading h2){color:var(--accent)}
html[data-theme=dark] .manual-page{--ink:#ececec;--text:#ececec;--muted:#aaaeb7;--muted-soft:#aaaeb7;--surface:#212121;--surface-alt:#29292b;--border:#404044;--primary:#8db9ff;--line:#404044;--olive:#b2c6a5}
html[data-theme=dark] :is(.manual-panel,.manual-selector,.manual-evidence-tabs button,.manual-excerpt blockquote,.manual-evidence-image,.restored-switch,.restored-industrial .industrial-artifact-caption,.portal-close,.admin-delete-dialog button){background:#29292b;border-color:var(--line);color:var(--text-main);box-shadow:none}
html[data-theme=dark] :is(.manual-case-intro h2,.manual-case-title,.manual-safety h4,.manual-steps-panel li,.manual-panel-heading h2,.restored-signal,.restored-analysis-nav button.active,.account-dialog label){color:var(--text-main)}
html[data-theme=dark] #admin-view .admin-tabs button.active,html[data-theme=dark] #admin-view .admin-toolbar button.active{background:#286bd1;color:white;border-color:#286bd1}
html[data-theme=dark] #admin-view button{background:#29292b;color:var(--text-main);border-color:var(--line)}html[data-theme=dark] #admin-view button:hover{background:#343437}
html[data-theme=dark] .restored-plot svg text{fill:#c0c2c8}html[data-theme=dark] .restored-plot svg path{stroke:#e5e5e5}html[data-theme=dark] .restored-plot svg line{stroke:#525257}
html[data-theme=dark] :is(.manual-status.status-pending){background:#40351f;color:#e4c171}html[data-theme=dark] .status-approved{background:#20382b;color:#90d5ac}html[data-theme=dark] .status-rejected{background:#402626;color:#f0a1a1}
@media(max-width:650px){.library-upload-top{align-items:flex-start;flex-direction:column}.library-upload-panel{padding:16px}.manual-form-dialog{padding:20px}.topbar{gap:8px}#theme-toggle{width:32px;height:32px}.manual-dialog-actions{flex-wrap:wrap}.manual-own-row small{margin-left:0}}
@media(max-width:450px){#account-name{display:none}.topbar-brand{gap:6px;font-size:16px}.account-nav{gap:4px}.account-logout{white-space:nowrap;max-width:none;padding:5px;font-size:10px}.topbar{padding:0 10px;gap:5px}.account-space{padding:3px}.topbar-brand #expand-sidebar{width:28px;flex-shrink:0}}

.manual-review-row,.supplement-card{overflow-wrap:anywhere}

html[data-theme=dark] .manual-button{background:#29292b;border-color:var(--line);color:var(--accent)}
html[data-theme=dark] .manual-steps li::before{background:#253752;color:#b1ceff;border-color:#5275a9}
