:root{color-scheme:light;--surface:#fff;--canvas:#fff;--text:#28303a;--subtle:#f8f9fb;--accent:#2563eb}
.theme-control{width:88px;flex-shrink:0;font-size:12px;cursor:pointer}.login-card>.theme-control{float:right;margin-bottom:12px}
:root[data-theme=dark]{color-scheme:dark;--surface:#171d26;--canvas:#101419;--subtle:#202733;--text:#e5edf8;--line:#303b4a;--muted:#a7b4c7;--accent:#89b4ff;--green:#89b4ff;background:var(--canvas);color:var(--text)}
html[data-theme=dark] body,html[data-theme=dark] .main{background:var(--canvas);color:var(--text)}
html[data-theme=dark] :is(.topbar,.panel,.modal,.drawer,.record-sheet,.record-grid,.conversation-index,.contact-context,.chat-head,.composer,.settings-grid>section,.command-menu,.menu-popover,.login-card,.view-config,.project-editor){background:var(--surface);color:var(--text);border-color:var(--line)}
html[data-theme=dark] :is(.sidebar,.login-form,.inbox-heading,.kanban-column,.context-section summary,.panelhead,.drawerhead,.drawerbody,.record-footer,.record-table th,.record-table th:last-child,.record-table td:last-child){background:var(--surface);color:var(--text);border-color:var(--line)}
html[data-theme=dark] :is(h1,h2,h3,h4,strong,.logo,.sidebar .logo,.user,.task-title,.project-card h3,.chat-title strong,.record-property>div,.context-field strong,.conversation-title strong){color:var(--text)}
html[data-theme=dark] :is(.muted,.breadcrumbs,.subtitle,.note-text,.nav-label,.side-bottom,.stat-label,.stat-note,.context-field>span,.record-property>label,.conversation-meta,.message-footer,.record-view-note,.record-footer,.preview,.login-card p,.column-choice){color:var(--muted)}
html[data-theme=dark] :is(input,select,textarea,.rich-input,.button,.global-search){background:var(--subtle);color:var(--text);border-color:var(--line)}
html[data-theme=dark] :is(a,.enum-cell,.project-card a){color:var(--accent)}
html[data-theme=dark] :is(.nav-button.active,.nav-button:hover,.module-nav .selected,.inbox-groups .selected,.editor-modes .selected,.record-tabs .selected,.conversation.active,.conversation:hover,.command-result:hover,.button.soft,.badge,.bulk-toolbar){background:#203555;color:#b4d0ff;border-color:#3b5881}
html[data-theme=dark] :is(.nav-count,.avatar,.badge.gray,.count,.tag-choice){background:#29374a;color:#c4d5ec}
html[data-theme=dark] :is(.button.primary,.mark){background:#2563eb;color:#fff;border-color:#2563eb}
html[data-theme=dark] :is(.stat,.kanban-card,.project-card,.contact-note,.record-details,.table,.column-config-row,.settings-row,.mini-row,.task-row,.note-card,.timeline-item){background:var(--surface);color:var(--text);border-color:var(--line)}
html[data-theme=dark] :is(.table th,.table td,.panelhead,.chat-head,.composer,.context-section,.context-section summary,.record-tabs,.messages,.conversation,.record-property,.kanban-header,.project-card,.inbox-groups,.editor-toolbar){border-color:var(--line)}
html[data-theme=dark] .table th{background:var(--surface);color:var(--muted)}
html[data-theme=dark] :is(.messages,.chat-pane,.empty,.records-kanban,.project-grid){background:var(--canvas);color:var(--muted)}
html[data-theme=dark] .message{background:#253143;color:var(--text);border-color:var(--line)}
html[data-theme=dark] .message.outgoing{background:#193b61;color:#e3efff}
html[data-theme=dark] :is(.message.note,.note-composer,.sync-conflict,.badge.warn){background:#332b1c;color:#f4dfa7;border-color:#685a38}
html[data-theme=dark] .message.activity{background:transparent;color:var(--muted)}
html[data-theme=dark] :is(.quoted-message,.reply-context,.file-chip){background:#263449;color:#d0e2fb;border-color:#54739b}
html[data-theme=dark] :is(.form-error,.button.danger){color:#ffabab}
html[data-theme=dark] .view-remove-warning{background:#3e2425;border-color:#805051;color:#ffd0ce}
html[data-theme=dark] :is(.status-DONE,.project-status-done){background:#183e30;color:#a4e7c6}
html[data-theme=dark] .progress{background:#2e3a4a}html[data-theme=dark] .progress span{background:#7ba8ff}
html[data-theme=dark] .record-table th .button{background:transparent;color:#b2c1d7}
html[data-theme=dark] .record-table tr:hover td{background:#24334a}
html[data-theme=dark] #toast{background:#24354c;color:#e7f0ff;border:1px solid #4c6383}
html[data-theme=dark] .login-brand{background:#142846}html[data-theme=dark] .login-screen{background:var(--canvas)}
html[data-theme=dark] :is(button,a,input,select,textarea):focus-visible{outline:2px solid #89b4ff;outline-offset:2px}
@media(max-width:750px){.theme-control{width:62px;font-size:11px;padding:6px 3px}.topbar{gap:6px}.topbar .user>div{display:block}.topbar .user>div>div{display:none}.topbar .user{gap:5px}.topbar .user>.avatar{display:none}.topbar .global-search{min-width:0;flex:1;white-space:nowrap;padding:7px 5px;font-size:11px}.topbar .logout{padding:5px}.login-card>.theme-control{width:80px}}

:root{--border:var(--line);--panel:var(--surface);--panel2:var(--subtle);--blue:var(--accent);--bg:var(--subtle)}
