/* Night mode: loaded after the other style sheets and active only when the page root carries data-theme="dark". */
html[data-theme=dark]{color-scheme:dark}
html[data-theme=dark] body{background:#0e1320;color:#e6eaf3}
html[data-theme=dark] a{color:#a5b4fc}
html[data-theme=dark] header,html[data-theme=dark] aside{background:#151b2b;border-color:#262f45;color:#e6eaf3}
html[data-theme=dark] .muted,html[data-theme=dark] aside h2,html[data-theme=dark] .hdr-section h3,html[data-theme=dark] .am-label,html[data-theme=dark] .notify-time,html[data-theme=dark] .pc-day,html[data-theme=dark] .pc-facts dt{color:#8b97b1}
html[data-theme=dark] .row,html[data-theme=dark] .oe-box,html[data-theme=dark] .pc-card,html[data-theme=dark] .pc-evidence,html[data-theme=dark] .panel,html[data-theme=dark] section,html[data-theme=dark] .kb-card,html[data-theme=dark] .kb-create-panel,html[data-theme=dark] .kb-create form,html[data-theme=dark] .kb-step,html[data-theme=dark] .kc-chart,html[data-theme=dark] .kc-hit,html[data-theme=dark] .kc-stat,html[data-theme=dark] .status-card,html[data-theme=dark] .grp-card,html[data-theme=dark] .bf-job,html[data-theme=dark] .inbox-block,html[data-theme=dark] .llm-card,html[data-theme=dark] .llm-advanced,html[data-theme=dark] .llm-topbar,html[data-theme=dark] .step,html[data-theme=dark] .table-wrap,html[data-theme=dark] dialog.app-dialog,html[data-theme=dark] .ctx-chip,html[data-theme=dark] .badge{background:#171e30;border-color:#2a3550;color:#e6eaf3;box-shadow:none}
html[data-theme=dark] .pc-manual,html[data-theme=dark] .empty-hint,html[data-theme=dark] .bd-root pre,html[data-theme=dark] .notify-item,html[data-theme=dark] .dt th{background:#1c2438;border-color:#2a3550;color:#e6eaf3}
html[data-theme=dark] .notify-item.unread,html[data-theme=dark] nav button[aria-current=true],html[data-theme=dark] .kb-scope.selected{background:#27305a;color:#c7d2fe}
html[data-theme=dark] .dt,html[data-theme=dark] .pc-table td,html[data-theme=dark] .pc-table th,html[data-theme=dark] .dt td{background:#171e30;border-color:#2a3550;color:#e6eaf3}
html[data-theme=dark] .dt tbody tr:hover{background:#1c2438}
html[data-theme=dark] input,html[data-theme=dark] select,html[data-theme=dark] textarea{background:#101626;color:#e6eaf3;border-color:#33405f}
html[data-theme=dark] input::placeholder,html[data-theme=dark] textarea::placeholder{color:#6b7893}
html[data-theme=dark] button,html[data-theme=dark] a.action{background:#1c2438;color:#e6eaf3;border-color:#33405f}
html[data-theme=dark] button:hover{background:#25304a}
html[data-theme=dark] button.primary,html[data-theme=dark] a.action.primary{background:#4f46e5;color:#fff;border-color:#4f46e5}
html[data-theme=dark] nav button{background:transparent;color:#cbd5e6}
html[data-theme=dark] .pc-pill{background:#222b42;color:#cbd5e6}
html[data-theme=dark] .pc-pill.ok{background:#12372a;color:#86efac}html[data-theme=dark] .pc-pill.warn{background:#3d2e10;color:#fcd34d}html[data-theme=dark] .pc-pill.bad{background:#451a17;color:#fca5a5}
html[data-theme=dark] .notice{background:#1b2540;color:#c7d2fe;border-color:#33405f}html[data-theme=dark] .notice.error{background:#3b1c1a;color:#fecaca}
html[data-theme=dark] .hdr-icon,html[data-theme=dark] .toast{background:#171e30;border-color:#2a3550;color:#e6eaf3}
html[data-theme=dark] .hdr-icon:hover{background:#25304a}
html[data-theme=dark] .hdr-panel{background:#151b2b;border-color:#2a3550;color:#e6eaf3;box-shadow:0 16px 40px #00000080}
html[data-theme=dark] .hdr-section,html[data-theme=dark] .hdr-actions{border-color:#262f45}
html[data-theme=dark] .toast.tone-error{background:#3b1c1a}html[data-theme=dark] .toast-count{background:#27305a;color:#c7d2fe}html[data-theme=dark] .toast-close:hover{background:#25304a}html[data-theme=dark] .toast-bar{background:#ffffff1a}
html[data-theme=dark] .language-switch button[aria-pressed=true]{background:#e8f0fa;color:#163b62}
html[data-theme=dark] hr{border-color:#262f45}
html[data-theme=dark] code,html[data-theme=dark] pre{background:#101626;color:#e6eaf3}
html[data-theme=dark] .avatar-pick,html[data-theme=dark] .swatch{border-color:#33405f}
html[data-theme=dark] .avatar-pick[aria-pressed=true]{background:#27305a;border-color:#818cf8}

html[data-theme=dark] .mm-workbench .pp-row{background:#171e30;border-color:#2a3550}html[data-theme=dark] .mm-workbench .pc-pill{background:#27305a;color:#c7d2fe}

html[data-theme=dark] .mm-stats>div{border-color:#2a3550}

html[data-theme=dark] .mm-workbench .kc-tab.selected{color:#c7d2fe;border-bottom-color:#a79aff;background:#27305a}

/* Keep component semantics when generic dark controls would override them. */
html[data-theme=dark] :is(.kc-tabs,.pc-tabs,.ah-tabs,.gs-tabs){border-color:var(--border)}
html[data-theme=dark] :is(.kc-tab,.pc-tab,.gs-tab,.dt-sort){background:transparent;color:var(--muted);border-color:transparent}
html[data-theme=dark] :is(.kc-tab.selected,.pc-tab.selected,.gs-tab[aria-selected=true]){background:transparent;color:var(--accent);border-bottom-color:var(--accent)}
html[data-theme=dark] :is(.kc-tab,.pc-tab,.gs-tab):hover{color:var(--accent);background:var(--accent-soft)}
html[data-theme=dark] .theme-switch button[aria-pressed=true]{background:var(--accent-soft);color:var(--accent);border-color:var(--accent-line)}
html[data-theme=dark] .language-switch{color:var(--muted)}
html[data-theme=dark] .language-switch button[aria-pressed=true]{background:var(--accent-soft);color:var(--text)}
html[data-theme=dark] :is(.kc-alert,.status-card,.llm-banner,.llm-chip,.llm-savestate,.grp-tag,.plg-badge).ok,html[data-theme=dark] .kc-alert:not(.warn):not(.bad){background:var(--success-soft);color:var(--success);border-color:var(--success-line)}
html[data-theme=dark] :is(.kc-alert,.status-card,.llm-banner,.llm-chip,.llm-savestate,.grp-tag).warn{background:var(--warning-soft);color:var(--warning);border-color:var(--warning-line)}
html[data-theme=dark] :is(.kc-alert,.llm-banner,.llm-chip,.llm-savestate,.inbox-block).bad,html[data-theme=dark] .inbox-block.failed{background:var(--danger-soft);color:var(--danger);border-color:var(--danger-line)}
html[data-theme=dark] :is(.status-card.ok,.status-card.warn) p{color:inherit}
html[data-theme=dark] :is(.gs-section,.md-secondary,.kb-section){background:transparent;border-color:transparent}
html[data-theme=dark] :is(.gs-dialog,.pc-dialog,.oe-dialog){background:var(--surface);color:var(--text);border-color:var(--border)}
html[data-theme=dark] :is(.gs-dialog input,.gs-row,.gs-more,.gs-chip){color:var(--text)}
html[data-theme=dark] :is(.gs-row.active,.gs-row:hover,.gs-chip:hover){background:var(--accent-soft)}
html[data-theme=dark] :is(.kc-hit,.gs-dialog) mark{background:#665323;color:#fff0b5}
html[data-theme=dark] .app-dialog-body{color:var(--text-secondary)}
html[data-theme=dark] :is(.plg-badge-on){color:var(--success)}html[data-theme=dark] :is(.plg-badge-merchantOff){color:var(--warning)}
html[data-theme=dark] :is(.plg-badge-merchant,.plg-badge-space){color:var(--accent)}
html[data-theme=dark] :is(.llm-field>label,.llm-label,.llm-card-title span,.llm-foot,.llm-draftbar){color:var(--text-secondary)}
html[data-theme=dark] :is(.md-menu-popover,.md-menu-popover button){background:var(--surface);color:var(--text);border-color:var(--border)}
html[data-theme=dark] .md-menu-popover button:hover{background:var(--surface-soft)}
html[data-theme=dark] :is(.md-card-preview p,.md-date,.md-item-menu>summary){color:var(--muted)}
html[data-theme=dark] button:focus-visible,html[data-theme=dark] summary:focus-visible,html[data-theme=dark] a:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.theme-toggle{font-size:21px;line-height:1;flex:none}.theme-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:3px}

header .language-switch{color:var(--muted)}
html[data-theme=dark] .pc-card.selected{box-shadow:0 0 0 2px var(--accent-line)}

html[data-theme=dark] input::placeholder,html[data-theme=dark] textarea::placeholder{color:var(--muted)}
