/* Shared presentation tokens. Never filter images, video, canvas or class colors. */
html[data-theme="light"] {
    --platform-page-bg: #eef3f8;
    --platform-card-bg: #fff;
    --platform-card-soft: #f2f6fa;
    --platform-border: #c6d2de;
    --platform-body-text: #24364b;
    --platform-body-muted: #4d6075;
    --i-muted: #4d6075 !important;
    --i-accent: #08756f !important;
    --c-muted: #4d6075 !important;
    --c-accent: #08756f !important;
    --board-muted: #4d6075 !important;
    --board-accent: #076786 !important;
    --o-muted: #4d6075 !important;
    --o-good: #146333 !important;
    --o-bad: #b42335 !important;
    --o-warn: #885100 !important;
    --g-muted: #4d6075 !important;
}
html[data-theme="dark"] {
    --platform-body-muted: #b0bfd0;
    --theme-error-bg: #3d1e29;
    --theme-error-text: #fecaca;
    --theme-success-bg: #123729;
    --theme-success-text: #bbf7d0;
}
html[data-theme="light"] {
    --theme-error-bg: #fff1ed;
    --theme-error-text: #8e2530;
    --theme-success-bg: #edf9f0;
    --theme-success-text: #165b32;
}

/* These are interface descriptions and status labels, not annotation swatches. */
html[data-theme] body :is(.muted, .subtitle, .upload-hint, .instance-hardware-hint,
    .selection-tip, .category-count, .shortcut-line, .page-jump,
    .selected-image-count, .image-assignee-filter > span,
    .live-stat .label, .live-metric .label, .stat-item .label,
    #lossChartHint, #metricsChartHint, #progressDetail, .progress-info,
    .empty-state p, .no-image-placeholder p, .no-image-message p, .empty-message,
    .dataset-empty p, .upload-placeholder p, #datasetList > p,
    .annotation-table-head > span, .progress-card > .label,
    .progress-bar-container > div:first-child > span,
    #taskHistoryBody td[colspan], #modelRepositoryBody td[colspan]) {
    color: var(--platform-body-muted) !important;
}
html[data-theme="light"] body #taskHistoryLiveStatus { color: #855500 !important; }
html[data-theme="dark"] body .loss-chart-header > span { color: #e5edf7 !important; }
html[data-theme="light"] body :is(small, .empty, .note, .board-note,
    .title p, .upload-text, .setting-card > span, .secondary, .button,
    .training-progress .label):not(.platform-header *):not(:disabled) {
    color: var(--platform-body-muted) !important;
}
html[data-theme="dark"] body :is(.upload-text, .label, .image-assignee-filter > span,
    .no-image-placeholder p, .image-placeholder p, #selectedImageCount) {
    color: var(--platform-body-muted) !important;
}

/* Darker action fills retain white text in both modes. */
html[data-theme] body :is(button.primary, .btn-success, #startTrainingBtn,
    #addImagesBtn, #saveShortcutsBtn):not(:disabled) {
    background: #15733f !important;
    color: #fff !important;
}
html[data-theme] body :is(.workflow-toggle, .project-workflow-toggle, .project-workflow-handle,
    #platformDisplayNameSave):not(:disabled) {
    background: #09669e !important;
    color: #fff !important;
}
html[data-theme="light"] body :is(.btn-secondary, #preflightBtn):not(:disabled) {
    background: #50627a !important;
    color: #fff !important;
}
html[data-theme] body :is(.badge.active, .current-project-badge) {
    color: #146333 !important;
}

/* Preserve disabled behavior while keeping its label readable. */
html[data-theme="light"] body :is(button:disabled, .btn:disabled,
    input:disabled, select:disabled, textarea:disabled) {
    color: #536172 !important;
    background-color: #e6ecf2 !important;
    border-color: #a7b4c3 !important;
    opacity: 1 !important;
    cursor: not-allowed;
}
html[data-theme="dark"] body :is(button:disabled, .btn:disabled,
    input:disabled, select:disabled, textarea:disabled) {
    color: #afbdcd !important;
    background-color: #26364a !important;
    border-color: #53667e !important;
    opacity: 1 !important;
    cursor: not-allowed;
}
html[data-theme] body :is(button:disabled, .btn:disabled) :is(span, small) {
    color: inherit !important;
}

html[data-theme="dark"] body :is(.theme-option, .secondary, .setting-icon,
    #pointInspector, .cap-saved-review, fieldset):not(:disabled) {
    background-color: var(--platform-card-soft) !important;
    color: var(--platform-body-text) !important;
    border-color: var(--platform-border) !important;
}
html[data-theme="dark"] body .theme-option.active {
    background: #12415a !important;
    border-color: #7dd3fc !important;
}
html[data-theme="dark"] body :is(.stat > span, .enterprise-summary,
    .enterprise-summary > span, .setting-card > span, #managePeopleBtn):not(:disabled) {
    color: #b0d7f4 !important;
}
html[data-theme="dark"] body :is(.theme-status, .shortcut-status, .setting-save-status) {
    color: #86efac !important;
}
html[data-theme="dark"] body .connection-test-status {
    background: var(--platform-card-soft) !important;
    color: var(--platform-body-muted) !important;
    border-color: var(--platform-border) !important;
}
html[data-theme="dark"] body .connection-test-status strong { color: inherit !important; }
html[data-theme="dark"] body .connection-test-status.success {
    background: var(--theme-success-bg) !important;
    color: var(--theme-success-text) !important;
}
html[data-theme="dark"] body .connection-test-status.error {
    background: var(--theme-error-bg) !important;
    color: var(--theme-error-text) !important;
}
html[data-theme] body :is(.chart-title, .chart-title > span) {
    color: var(--platform-body-text) !important;
}
html[data-theme] body #capabilityWorkbench button.secondary:not(:disabled) {
    background: #465d74 !important;
    color: #fff !important;
}
html[data-theme="light"] body #capabilityWorkbench :is(button, input, select, textarea):disabled {
    background-color: #e6ecf2 !important;
    color: #536172 !important;
    border-color: #a7b4c3 !important;
}
html[data-theme="dark"] body #capabilityWorkbench :is(button, input, select, textarea):disabled {
    background-color: #26364a !important;
    color: #afbdcd !important;
    border-color: #53667e !important;
}
/* Text outlines keep shortcut badges legible without changing class swatches. */
html[data-theme] .category-index {
    text-shadow: -1px -1px 0 #172033, 1px -1px 0 #172033,
        -1px 1px 0 #172033, 1px 1px 0 #172033 !important;
}
html[data-theme] body .pro-toolbar > button:not(:disabled) {
    background: #09669e !important;
    color: #fff !important;
}
html[data-theme] body .action.test:not(:disabled) {
    background: #09669e !important;
    color: #fff !important;
}
html[data-theme] body .action.save:not(:disabled) {
    background: #15733f !important;
    color: #fff !important;
}
/* Intrinsic form widths must not enlarge the AI library or safety workbench. */
html[data-theme] .platform-header { box-sizing: border-box; }
html[data-theme] body:has(#drop) :is(main, .grid, .card, .field input, .field select),
html[data-theme] body #capabilityWorkbench {
    box-sizing: border-box;
    min-width: 0;
}
html[data-theme] body:has(#drop) main { width: 100%; }
html[data-theme] body:has(#projectList) main button:not(.danger):not(:disabled),
html[data-theme] body #cloudForm .action.save:not(:disabled) {
    background-color: #09669e !important;
    color: #fff !important;
}
html[data-theme] body:has(#drop) .grid { grid-template-columns: minmax(0,420px) minmax(0,1fr); }
@media (max-width: 900px) {
    html[data-theme] body:has(#drop) .grid { grid-template-columns: minmax(0,1fr); }
}
html[data-theme] body #workbenchMessage {
    background: var(--theme-error-bg) !important;
    color: var(--theme-error-text) !important;
    border-color: currentColor !important;
}
html[data-theme] body #workbenchMessage.success {
    background: var(--theme-success-bg) !important;
    color: var(--theme-success-text) !important;
}
html[data-theme="dark"] body :is(.error, .board-error) { color: #fecaca !important; }
html[data-theme="dark"] body #capabilityWorkbench a { color: #7dd3fc !important; }
html[data-theme="light"] body #capabilityWorkbench a { color: #075c91 !important; }
html[data-theme] body :is(input, select, textarea)::placeholder {
    color: var(--platform-body-muted) !important;
    opacity: 1;
}
html[data-theme] body :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid #0876b9 !important;
    outline-offset: 3px !important;
}
html[data-theme="dark"] body :focus-visible { outline-color: #7dd3fc !important; }
@media (max-width: 650px) {
    html[data-theme] body :is(.cap-card, .panel, .card, .setting-card) { min-width: 0; }
    html[data-theme] body:has(#noImageMessage) .main-content { overflow-x: auto !important; }
    html[data-theme] body:has(#noImageMessage) .image-container { min-width: 320px; flex-shrink: 0; }
}
