@media screen {
  .theme-toggle:focus-visible {
    outline: 3px solid #e97b24;
    outline-offset: 2px;
  }

  html[data-theme="dark"] {
    color-scheme: dark;
    --app-bg: #0f141c;
    --surface: #171e29;
    --surface-raised: #1d2633;
    --surface-panel: #222c3a;
    --surface-hover: #273343;
    --surface-disabled: #202936;
    --field: #131a23;
    --ink: #f2f5f8;
    --charcoal: #f2f5f8;
    --charcoal-2: #dce3ea;
    --slate: #b4bfcc;
    --muted: #b4bfcc;
    --border: #364355;
    --line: #364355;
    --panel: #222c3a;
    --white: #171e29;
    --purple: #c39bde;
    --purple-deep: #8250a7;
    --purple-soft: #30233e;
    --orange: #ff9a50;
    --orange-soft: #3a291e;
    --green: #63caa5;
    --green-soft: #17342b;
    --red: #f18a8a;
    --red-soft: #3b2328;
    --amber: #f1bd69;
    --amber-soft: #392e1d;
    --blue: #72b4e2;
    --blue-soft: #1b3040;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .32);
    --shadow-sm: 0 8px 22px rgba(0, 0, 0, .3);
    --shadow-md: 0 18px 44px rgba(0, 0, 0, .42);
  }

  html[data-theme="dark"] body,
  html[data-theme="dark"] .workspace,
  html[data-theme="dark"] .main-content {
    background: var(--app-bg);
    color: var(--ink);
  }

  html[data-theme="dark"] ::selection { background: rgba(195, 155, 222, .32); }
  html[data-theme="dark"] ::placeholder { color: #8996a5; opacity: 1; }

  html[data-theme="dark"] .topbar {
    background: rgba(23, 30, 41, .94);
    border-color: var(--border);
  }
  html[data-theme="dark"] .global-search input,
  html[data-theme="dark"] .search-hint,
  html[data-theme="dark"] .icon-button,
  html[data-theme="dark"] .top-user,
  html[data-theme="dark"] .btn,
  html[data-theme="dark"] .row-icon-btn,
  html[data-theme="dark"] .prompt-button,
  html[data-theme="dark"] .input,
  html[data-theme="dark"] .select,
  html[data-theme="dark"] .date-input,
  html[data-theme="dark"] .textarea,
  html[data-theme="dark"] .toolbar-search input,
  html[data-theme="dark"] .filter-select,
  html[data-theme="dark"] .ask-input input {
    background: var(--field);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] .global-search input:focus,
  html[data-theme="dark"] input:focus,
  html[data-theme="dark"] select:focus,
  html[data-theme="dark"] textarea:focus {
    border-color: #a978c8;
    box-shadow: 0 0 0 3px rgba(195, 155, 222, .2);
  }
  html[data-theme="dark"] .icon-button:hover,
  html[data-theme="dark"] .top-user:hover,
  html[data-theme="dark"] .btn:hover:not(:disabled),
  html[data-theme="dark"] .row-icon-btn:hover,
  html[data-theme="dark"] .prompt-button:hover {
    background: var(--surface-hover);
    border-color: #526278;
  }
  html[data-theme="dark"] .theme-toggle[aria-pressed="true"] {
    background: #30233e;
    border-color: #8d62aa;
    color: #e3c6f4;
  }
  html[data-theme="dark"] .btn.primary {
    background: #704092;
    border-color: #8250a7;
    color: #fff;
  }
  html[data-theme="dark"] .btn.primary:hover { background: #8150a4; border-color: #9465b5; }
  html[data-theme="dark"] .btn.orange { background: #b85e20; border-color: #cf702d; color: #fff; }
  html[data-theme="dark"] .btn.danger { background: #2d2025; border-color: #75414b; color: var(--red); }

  html[data-theme="dark"] .job-tabbar {
    background: #111923;
    border-color: #303c4d;
  }
  html[data-theme="dark"] .job-tab {
    background: #1a2330;
    border-color: #364355;
    color: var(--slate);
  }
  html[data-theme="dark"] .job-tab:hover,
  html[data-theme="dark"] .job-tab.active {
    background: var(--surface-raised);
    border-color: #526075;
    color: var(--ink);
  }
  html[data-theme="dark"] .tab-close:hover { background: var(--surface-hover); }

  html[data-theme="dark"] :where(
    .card, .metric-card, .stage-card, .kpi-card, .job-hero, .stage-node-card,
    .info-block, .day-column, .doc-card, .ask-messages, .ask-input,
    .chat-bubble.ros, .modal, .toast, .integration-note, .flow-step,
    .scan-card, .scan-upload-form .file-field
  ) {
    background: var(--surface);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] .stage-card { background: linear-gradient(180deg, var(--surface-raised), var(--surface)); }
  html[data-theme="dark"] :where(.card-header, .card-footer, .modal-footer, .day-head, .table-toolbar) { border-color: var(--border); }
  html[data-theme="dark"] :where(.section-tabs, .badge.p4, .badge.grey, .pill.grey) { background: var(--surface-panel); border-color: var(--border); color: var(--slate); }
  html[data-theme="dark"] :where(.section-tab.active, .badge.outline, .check-chip span, .readiness-ring::after, .task-checkbox, .check-box, .upload-zone, .upload-zone-icon) {
    background: var(--surface-raised);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] :where(.priority-item:hover, .data-table tbody tr:hover, button.activity-item:hover, .check-row:hover) { background: var(--surface-hover); }
  html[data-theme="dark"] :where(.data-table th, .day-head) { background: var(--surface-panel); color: var(--slate); border-color: var(--border); }
  html[data-theme="dark"] :where(.data-table td, .priority-item, .activity-item, .stage-card .stage-next, .stage-node-foot) { border-color: var(--border); }
  html[data-theme="dark"] .notification-dot { border-color: var(--surface); }
  html[data-theme="dark"] .modal-backdrop { background: rgba(3, 7, 12, .76); }
  html[data-theme="dark"] .mobile-scrim { background: rgba(2, 5, 9, .72); }

  html[data-theme="dark"] :where(.au-shell, .bk-shell, .comms-shell, .gantt-shell, .gantt-admin, .kp-shell, .rs-shell, .wf-shell) {
    --au-ink: var(--ink); --au-muted: var(--slate); --au-line: var(--border); --au-panel: var(--surface-panel);
    --bk-ink: var(--ink); --bk-muted: var(--slate); --bk-border: var(--border); --bk-panel: var(--surface-panel);
    --comms-ink: var(--ink); --comms-muted: var(--slate); --comms-border: var(--border);
    --gantt-ink: var(--ink); --gantt-muted: var(--slate); --gantt-border: var(--border);
    --kp-ink: var(--ink); --kp-muted: var(--slate); --kp-line: var(--border); --kp-panel: var(--surface-panel);
    --rs-ink: var(--ink); --rs-ink-2: #dce3ea; --rs-muted: var(--slate); --rs-line: var(--border); --rs-panel: var(--surface-panel);
    --wf-ink: var(--ink); --wf-muted: var(--slate); --wf-border: var(--border);
  }
  html[data-theme="dark"] :where(.au-shell, .bk-shell, .comms-shell, .gantt-shell, .gantt-admin, .kp-shell, .rs-shell, .wf-shell) {
    --au-green: var(--green); --au-green-soft: var(--green-soft); --au-red: var(--red); --au-red-soft: var(--red-soft); --au-blue: var(--blue); --au-blue-soft: var(--blue-soft); --au-amber: var(--amber); --au-amber-soft: var(--amber-soft);
    --bk-green: var(--green); --bk-green-soft: var(--green-soft); --bk-blue: var(--blue); --bk-blue-soft: var(--blue-soft); --bk-red: var(--red); --bk-red-soft: var(--red-soft); --bk-amber: var(--amber); --bk-amber-soft: var(--amber-soft);
    --comms-green: var(--green); --comms-green-soft: var(--green-soft); --comms-blue: var(--blue); --comms-blue-soft: var(--blue-soft); --comms-red: var(--red); --comms-red-soft: var(--red-soft); --comms-amber: var(--amber); --comms-amber-soft: var(--amber-soft);
    --kp-green: var(--green); --kp-green-soft: var(--green-soft); --kp-blue: var(--blue); --kp-blue-soft: var(--blue-soft); --kp-red: var(--red); --kp-red-soft: var(--red-soft); --kp-amber: var(--amber); --kp-amber-soft: var(--amber-soft);
    --rs-green: var(--green); --rs-green-soft: var(--green-soft); --rs-blue: var(--blue); --rs-blue-soft: var(--blue-soft); --rs-red: var(--red); --rs-red-soft: var(--red-soft); --rs-amber: var(--amber); --rs-amber-soft: var(--amber-soft);
  }

  html[data-theme="dark"] .ac-shell {
    --ac-purple: #c39bde; --ac-purple-deep: #8250a7; --ac-purple-soft: #30233e;
    --ac-orange: #ff9a50; --ac-orange-soft: #3a291e; --ac-navy: var(--ink);
    --ac-slate: var(--slate); --ac-border: var(--border); --ac-green: var(--green);
    --ac-green-soft: var(--green-soft); --ac-red: var(--red); --ac-red-soft: var(--red-soft);
    --ac-shadow: var(--shadow-sm);
  }
  html[data-theme="dark"] .rc-shell { --rc-purple:#c39bde; --rc-purple-soft:#30233e; --rc-orange:#ff9a50; --rc-red:var(--red); --rc-green:var(--green); --rc-ink:var(--ink); --rc-muted:var(--slate); --rc-line:var(--border); }
  html[data-theme="dark"] .rp-shell { --rp-purple:#c39bde; --rp-orange:#ff9a50; --rp-red:var(--red); --rp-green:var(--green); --rp-blue:var(--blue); --rp-ink:var(--ink); --rp-muted:var(--slate); --rp-line:var(--border); }
  html[data-theme="dark"] .pc-shell { --pc-ink:var(--ink); --pc-line:var(--border); --pc-soft:var(--surface-panel); --pc-blue:var(--blue); --pc-mint:var(--green); --pc-amber:var(--amber); --pc-red:var(--red); }

  html[data-theme="dark"] :where(
    .au-metric, .au-card, .au-role, .au-editor, .au-check, .au-tabs button.active,
    .ac-card, .ac-channel, .ac-metric, .ac-assistant-card, .ac-latest > div,
    .ac-prompt-preview, .ac-flow li, .ac-trace > div, .ac-approval, .ac-audit article > div,
    .bk-boundary, .bk-filters, .bk-queue, .bk-draft, .bk-audit, .bk-draft-empty,
    .bk-job, .bk-plot-bar, .bk-metric, .bk-stop-card, .bk-immutable, .bk-explain,
    .comms-boundary, .comms-stat, .comms-toolbar, .comms-hub, .comms-rail,
    .comms-inbox, .comms-thread-card, .comms-detail, .comms-detail-head,
    .comms-message-bubble, .comms-composer, .comms-job-main, .comms-side-card, .comms-modal,
    .gantt-metric, .gantt-board-card, .gantt-audit-card, .gantt-recipe-detail,
    .gantt-recipe-list, .gantt-empty, .gantt-board-key, .gantt-calendar-row,
    .gantt-task-head, .gantt-task-cell, .gantt-recipe-card, .gantt-recipe-list-item,
    .gantt-recipe-facts, .gantt-modal,
    .kp-metric, .kp-card, .kp-report-item, .kp-query-plan, .kp-citations > article,
    .kp-integrity, .kp-client-safe-note,
    .rs-card, .rs-type-card, .rs-output-card, .rs-governance-card, .rs-followup,
    .rs-start-card, .rs-session-ribbon, .rs-register-head, .rs-service-grid article,
    .rs-prompt-card, .rs-prompt-meta > div, .rs-prompt-columns section,
    .rs-workbench-grid section, .rs-execution-components > section, .rs-version-history,
    .rs-first-output, .rs-brief-grid > aside, .rs-fact-grid > section,
    .rs-stage-positions > section, .rs-issue-columns > section, .rs-question-list label,
    .rs-question-list > li > div,
    .wf-metrics article, .wf-lane, .wf-intake-card, .wf-detail, .wf-work-card,
    .wf-detail-status, .wf-evidence > div, .wf-source, .wf-name-preview,
    .wf-fieldset, .wf-review-summary, .wf-review-grid > section
  ) {
    background: var(--surface);
    border-color: var(--border);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
  }

  html[data-theme="dark"] :where(
    .au-btn, .au-row-btn, .au-close, .au-toolbar input, .au-toolbar select,
    .au-role-select select, .au-field input, .au-field select, .au-field textarea,
    .ac-btn, .ac-form input, .ac-form select,
    .bk-btn, .bk-shell select, .bk-shell input[type="date"], .bk-shell input[type="time"],
    .comms-btn, .comms-field input, .comms-field select, .comms-field textarea,
    .comms-pref-controls select,
    .gantt-btn, .gantt-icon-btn, .gantt-text-btn, .gantt-start-field input,
    .gantt-field input, .gantt-field select, .gantt-field textarea,
    .kp-shell input, .kp-shell select, .kp-shell textarea, .kp-btn,
    .rs-btn, .rs-readonly-prompt textarea, .rs-issue-resolution textarea,
    .rs-issue-resolution input, .rs-response-field textarea, .rs-governance-card input,
    .rs-command input,
    .wf-btn, .wf-icon-btn, .wf-field input, .wf-field select, .wf-field textarea
  ) {
    background: var(--field);
    border-color: var(--border);
    color: var(--ink);
  }

  html[data-theme="dark"] :where(
    .au-table thead th, .au-matrix thead th, .ac-rule-groups > section > header,
    .bk-job-list, .bk-metrics, .comms-compose-tab, .gantt-audit-card > header,
    .gantt-recipe-table th, .kp-table th, .rs-table th, .rs-gates > footer
  ) { background: var(--surface-panel); border-color: var(--border); color: var(--slate); }

  html[data-theme="dark"] :where(
    .au-table tbody tr:hover, .au-check-group label:hover, .bk-job:hover,
    .comms-thread-card:hover, .gantt-task-row:hover .gantt-task-cell,
    .gantt-recipe-table tr:hover td, .kp-table tbody tr:hover td,
    .kp-report-item:hover, .wf-work-card:hover
  ) { background: var(--surface-hover); }

  html[data-theme="dark"] :where(
    .uf-metric, .uf-card, .uf-tab.active, .uf-area, .uf-room, .uf-preset-items,
    .uf-preset-item, .uf-total, .uf-proposal, .uf-check, .uf-select-job,
    .uf-override, .uf-wo-flow, .uf-wo-flow > div, .uf-wo-supplier,
    .ct-lifecycle, .ct-record-tabs button, .ct-boundary, .ct-card, .ct-empty,
    .ct-denied, .ct-sign-panel, .ct-sign-panel > main > section, .ct-sign-panel form,
    .ct-sign-panel dl div,
    .ev-upload, .ev-bulk, .ev-room-head, .ev-photo-card, .ev-ai-panel,
    .ev-analysis-limitations, .ev-gates, .ev-editor-boundary, .ev-editor,
    .sp-metric, .sp-boundary, .sp-toolbar, .sp-list-panel, .sp-detail-panel,
    .sp-panel-head, .sp-supplier-row, .sp-tabs, .sp-detail-body, .sp-card,
    .sp-rating-card, .sp-service-grid > div, .sp-business-grid > div,
    .sp-record-head, .sp-contact-list article, .sp-document-list article,
    .sp-modal, .sp-modal-body, .sp-modal fieldset, .sp-coverage-picker, .sp-coverage-state,
    .sp-portal-hero, .sp-portal-metrics article, .sp-portal-user, .sp-portal-history,
    .sp-portal-role-guide, .sp-invite-success, .sp-invite-person,
    .wm-panel, .wm-source > div, .wm-assumptions, .wm-drafts, .wm-scenario,
    .wm-pack-list article, .wm-empty-pack, .wm-denied,
    .rc-boundary, .rc-metrics article, .rc-card, .rc-gate, .rc-area,
    .rc-list-check, .rc-handover-body > div,
    .rp-boundary, .rp-metrics article, .rp-card, .rp-filters, .rp-item,
    .rp-item-head, .rp-account > div, .rp-evidence > div, .rp-empty,
    .pc-decision, .pc-metrics article, .pc-card, .pc-mode, .pc-integration,
    .pc-admin-callout, .pc-channel, .pc-safety, .pc-denied
  ) {
    background: var(--surface);
    border-color: var(--border);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
  }

  html[data-theme="dark"] :where(
    .uf-field input, .uf-field select, .uf-field textarea, .uf-table input,
    .uf-table select, .uf-btn, .uf-override textarea, .uf-wo-commitment input,
    .uf-wo-supplier select,
    .ct-hero button, .ct-card button, .ct-empty button, .ct-form-grid input,
    .ct-form-grid select, .ct-form-grid textarea, .ct-clause textarea,
    .ct-review textarea, .ct-sign-panel input, .ct-sign-panel > header button,
    .ev-icon-btn, .ev-filter, .ev-field input, .ev-field select, .ev-field textarea,
    .ev-report-picker select, .ev-bulk select, .ev-btn,
    .sp-btn, .sp-toolbar select, .sp-search, .sp-icon-btn,
    .sp-field input:not([type="checkbox"]), .sp-field select, .sp-field textarea,
    .sp-check-grid label, .sp-statewide-choice,
    .wm-assumption-grid input, .wm-scenario > footer button,
    .rc-btn, .rc-defect-form input, .rc-defect-form select, .rc-check,
    .rc-warranty-select, .rp-filters select, .rp-actions button,
    .pc-gate-actions select, .pc-integration select, .pc-channel-switch button
  ) {
    background: var(--field);
    border-color: var(--border);
    color: var(--ink);
  }

  html[data-theme="dark"] :where(
    .uf-tabs, .uf-plan, .uf-toolbar, .uf-table th, .uf-preset-head,
    .ct-card > header, .ct-card > footer, .ct-table-wrap th, .ct-sign-panel > header,
    .ev-photo-actions, .sp-modal-foot, .rp-item footer, .pc-audit-row.head
  ) { background: var(--surface-panel); border-color: var(--border); color: var(--slate); }

  html[data-theme="dark"] :where(.uf-area:hover, .uf-preset-item:hover, .ct-hero button:hover, .ct-card button:hover, .ev-btn:hover, .sp-btn:hover:not(:disabled), .sp-supplier-row:hover, .rp-actions button:hover, .pc-mode:hover) {
    background: var(--surface-hover);
  }

  html[data-theme="dark"] :where(.uf-area.active, .uf-room.active, .ct-record-tabs button.active, .sp-supplier-row.active, .pc-mode.selected) {
    background: #30233e;
    border-color: #8d62aa;
  }

  html[data-theme="dark"] :where(.ct-form-grid input:disabled, .ct-form-grid textarea:disabled, .ct-form-grid select:disabled, .ct-clause textarea:disabled, .uf-wo-commitment input:disabled, .wf-field textarea[readonly], .wf-field input[readonly]) {
    background: var(--surface-disabled);
    color: #9ca8b6;
  }

  html[data-theme="dark"] :where(.uf-page-head p, .uf-card-head p, .uf-field label, .uf-total span, .uf-total small, .ct-hero p, .ct-card header p, .ct-form-grid label > span, .ct-form-grid label > small, .ct-table-wrap th, .ct-table-wrap td small, .ct-card > footer, .ct-attachment small, .ct-attachment a, .ct-checks small) {
    color: var(--slate) !important;
  }

  html[data-theme="dark"] :where(.ct-form-grid .ct-confirm, .ct-review > label, .ct-sign-boundary, .uf-alert, .comms-alert, .ev-analysis-block.inference) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }

  html[data-theme="dark"] :where(.ct-stale, .ct-rule-warning, .uf-alert.danger, .wm-hard-stop, .rc-gate.blocked, .rp-item.critical) {
    background: #38251f;
    border-color: #744837;
    color: #f4c29f;
  }

  html[data-theme="dark"] :where(.wm-backdrop, .ct-sign-overlay) { background-color: rgba(3, 7, 12, .78); }

  html[data-theme="dark"] :where(
    .sp-coverage-picker > legend,
    .sp-coverage-group > strong,
    .sp-coverage-state > summary,
    .sp-coverage-state > summary strong
  ) { color: var(--ink); }

  html[data-theme="dark"] :where(
    .sp-coverage-picker > small,
    .sp-coverage-group .sp-check-grid small,
    .sp-coverage-state > summary small,
    .sp-coverage-state > summary::after,
    .sp-coverage-state-body > p,
    .sp-statewide-choice small
  ) { color: var(--slate); }

  html[data-theme="dark"] .sp-coverage-state > summary em { color: var(--purple); }
  html[data-theme="dark"] .sp-coverage-state-body { border-color: var(--border); }
  html[data-theme="dark"] :where(.sp-portal-hero p, .sp-portal-person small, .sp-portal-role small, .sp-portal-state small, .sp-portal-state em, .sp-portal-history small, .sp-portal-role-guide span, .sp-invite-success p, .sp-invite-person small) { color: var(--slate); }
  html[data-theme="dark"] :where(.sp-portal-person strong, .sp-portal-role strong, .sp-portal-metrics strong, .sp-invite-success strong, .sp-invite-person strong) { color: var(--ink); }
  html[data-theme="dark"] :where(.sp-portal-boundary, .sp-portal-modal-boundary) {
    background: #382f1f;
    border-color: #6f5b32;
    color: #e7d7b0;
  }
  html[data-theme="dark"] .sp-modal.large .sp-modal-head {
    background: var(--surface);
    border-color: var(--border);
    color: var(--ink);
  }

  /* Feature-level surfaces use explicit specificity so their light palettes cannot
     override the dark theme after a component becomes selected or contextual. */
  html[data-theme="dark"] :is(
    .gantt-head, .gantt-admin-head, .comms-hero, .au-head, .bk-hero,
    .kp-head, .rs-head, .rs-job-head
  ) {
    background:
      radial-gradient(circle at 90% 5%, rgba(255, 154, 80, .12), transparent 32%),
      linear-gradient(135deg, #1d2633 0%, #202936 68%, #29251f 100%);
    border-color: #455267;
    color: var(--ink);
    box-shadow: var(--shadow-sm);
  }
  html[data-theme="dark"] :is(
    .gantt-head, .gantt-admin-head, .comms-hero, .au-head, .bk-hero,
    .kp-head, .rs-head, .rs-job-head
  ) :is(h1, h2, h3, strong) { color: var(--ink); }
  html[data-theme="dark"] :is(
    .gantt-head, .gantt-admin-head, .comms-hero, .au-head, .bk-hero,
    .kp-head, .rs-head, .rs-job-head
  ) :is(p, small) { color: var(--slate); }

  html[data-theme="dark"] :is(
    .gantt-control-card, .gantt-boundary, .gantt-link-banner, .ac-boundary,
    .au-boundary, .kp-boundary, .rs-boundary, .bk-boundary, .bk-boundary-mini, .backend-banner
  ) {
    background: var(--surface-raised);
    border-color: var(--border);
    color: var(--ink);
    box-shadow: var(--shadow-xs);
  }
  html[data-theme="dark"] :is(
    .gantt-control-card, .gantt-boundary, .gantt-link-banner, .ac-boundary,
    .au-boundary, .kp-boundary, .rs-boundary, .bk-boundary, .bk-boundary-mini, .backend-banner
  ) :is(p, span, small, strong) { color: var(--slate); }

  html[data-theme="dark"] :is(.au-tabs, .ac-tabs, .kp-tabs, .rs-tabs) {
    background: var(--surface-panel);
    border-color: var(--border);
  }
  html[data-theme="dark"] :is(
    .au-tabs button.active, .ac-tab.active, .gantt-recipe-list-item.active,
    .kp-tabs button.active, .kp-report-item.active, .rs-tabs button.active,
    .rs-prompt-card.active
  ) {
    background: #30233e;
    border-color: #8d62aa;
    color: #f2e6fa;
  }
  html[data-theme="dark"] .bk-job.selected {
    background: #30233e;
    border-color: #9b70b8;
    color: var(--ink);
    box-shadow: inset 4px 0 #c39bde;
  }
  html[data-theme="dark"] .comms-thread-card.active {
    background: #30233e;
    border-color: #8d62aa;
    color: var(--ink);
  }

  html[data-theme="dark"] :is(
    .gantt-task-row:hover .gantt-task-cell,
    .gantt-task-row.link-target .gantt-task-cell,
    .gantt-task-row.link-target:hover .gantt-task-cell
  ) { background: #30233e; color: var(--ink); }
  html[data-theme="dark"] :is(
    .gantt-task-row.link-candidate .gantt-task-cell,
    .gantt-task-row.link-candidate:hover .gantt-task-cell
  ) { background: #3a2c20; color: var(--ink); }
  html[data-theme="dark"] :is(
    .gantt-task-row.link-blocked .gantt-task-cell,
    .gantt-task-row.link-blocked:hover .gantt-task-cell
  ) { background: #202733; color: var(--slate); }
  html[data-theme="dark"] :is(.gantt-link-button, .gantt-dependency-chip, .gantt-dependencies label) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.gantt-link-button:hover, .gantt-link-button.active, .gantt-dependencies label:hover) {
    background: #30233e;
    border-color: #8d62aa;
    color: #f2e6fa;
  }
  html[data-theme="dark"] .gantt-link-button.candidate { background: #3a2c20; color: #ffc18f; }
  html[data-theme="dark"] :is(.gantt-dependencies label span, .gantt-dependencies label small) { color: var(--slate); }

  html[data-theme="dark"] .bk-stop.conflict .bk-stop-card {
    background: #352128;
    border-color: #75414b;
    color: var(--ink);
  }

  html[data-theme="dark"] :is(
    .au-editor, .au-editor > header, .au-permission-group > div:first-child,
    .au-permission.locked, .au-form-actions, .au-matrix thead th,
    .au-check-group legend, .au-editor form > footer
  ) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] .au-matrix .au-matrix-group th {
    background: linear-gradient(90deg, #30233e, var(--surface-panel));
    color: #d9b8ed;
  }
  html[data-theme="dark"] :is(.au-check-group label:hover, .au-table tbody tr:hover) { background: #262f3c; }

  html[data-theme="dark"] .rs-execution-components > section { background: var(--surface-panel); border-color: var(--border); }
  html[data-theme="dark"] .rs-execution-components .rs-readonly-prompt.derived textarea {
    background: #382f1f;
    border-color: #6f5b32;
    color: var(--ink);
  }

  html[data-theme="dark"] .kp-prompts button {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--slate);
  }
  html[data-theme="dark"] .kp-prompts button:hover {
    background: #30233e;
    border-color: #8d62aa;
    color: #f2e6fa;
  }
  html[data-theme="dark"] :is(.kp-table tbody tr:hover td, .kp-report-item:hover) { background: #262f3c; }

  html[data-theme="dark"] .comms-thread-card:hover { background: #262f3c; }
  html[data-theme="dark"] .comms-thread-card p { color: var(--slate); }

  html[data-theme="dark"] :is(
    .au-card-head, .au-card-foot, .au-table thead th,
    .kp-composer > header, .kp-report-detail > header, .kp-table td,
    .rs-head-metrics > div, .rs-job-status, .rs-type-card > footer,
    .gantt-recipe-table td
  ) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] .gantt-recipe-table tr:hover td { background: #262f3c; }

  html[data-theme="dark"] .ac-result.safe {
    background: var(--green-soft);
    border-color: #346653;
    color: var(--ink);
  }
  html[data-theme="dark"] .ac-result.review {
    background: var(--amber-soft);
    border-color: #6f5b32;
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.ac-result.handoff, .ac-result.blocked) {
    background: var(--red-soft);
    border-color: #75414b;
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.ac-result-title > span, .ac-trace > div) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }

  html[data-theme="dark"] .comms-message.outbound .comms-message-bubble {
    background: #30233e;
    border-color: #795495;
    color: var(--ink);
  }
  html[data-theme="dark"] .comms-message.internal .comms-message-bubble {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.comms-attachment, .comms-preference, .comms-context) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }

  html[data-theme="dark"] .rs-governance-card.success {
    background: var(--green-soft);
    border-color: #346653;
    color: var(--ink);
  }
  html[data-theme="dark"] .rs-governance-card.warning {
    background: var(--amber-soft);
    border-color: #6f5b32;
    color: var(--ink);
  }
  html[data-theme="dark"] :is(.rs-start-card aside, .rs-step, .rs-output-summary) {
    background: var(--surface-panel);
    border-color: var(--border);
    color: var(--ink);
  }

  html[data-theme="dark"] :is(
    .gantt-recipe-list-item strong, .gantt-recipe-table td,
    .ac-form label > span, .ac-prompt-preview p, .ac-approval-main > p, .ac-audit p,
    .bk-insured, .bk-alert span, .bk-stop-copy > span,
    .comms-message-bubble p, .kp-table td, .kp-draft ul,
    .kp-report-detail ul, .kp-narrative, .rs-type-meta
  ) { color: var(--slate); }
  html[data-theme="dark"] :is(
    .gantt-recipe-list-item strong, .bk-job strong, .bk-stop-copy strong,
    .comms-message-bubble strong, .kp-table td strong, .rs-type-card strong
  ) { color: var(--ink); }

  html[data-theme="dark"] .rs-print-sheet,
  html[data-theme="dark"] .rs-print-notice {
    background: #fff !important;
    color: #172235 !important;
    border-color: #d8dce2 !important;
  }
  html[data-theme="dark"] .rs-print-sheet :where(h1, h2, h3, h4, p, span, strong, small, td, th, li) { color: inherit; }
  html[data-theme="dark"] .rs-print-sheet th { background: #f7f8fa !important; color: #65717e !important; }
}
