/* Theme palettes override the shared workspace tokens, never business states. */
:root[data-theme="light"] .portal-workspace {
    --workspace-bg: #f3f5f8;
    --workspace-surface: #ffffff;
    --workspace-raised: #e7edf4;
    --workspace-border: #c4cdd9;
    --workspace-text: #202c3c;
    --workspace-muted: #526175;
    --workspace-accent: #27633e;
    --workspace-on-accent: #ffffff;
    --workspace-focus: #2459a8;
    --workspace-input-border: #7a899e;
    --workspace-info: #2459a8;
    --workspace-success: #27633e;
    --workspace-warning: #865800;
    --workspace-danger: #b4233e;
    --workspace-on-status: #ffffff;
    color-scheme: light;
}
:root[data-theme="ocean"] .portal-workspace {
    --workspace-bg: #101f2c;
    --workspace-surface: #172c3b;
    --workspace-raised: #203b4c;
    --workspace-border: #3d5b70;
    --workspace-text: #e0edf5;
    --workspace-muted: #adbfce;
    --workspace-accent: #80d5dc;
    --workspace-on-accent: #102c31;
    --workspace-focus: #a4d8ff;
    --workspace-input-border: #607f94;
}
:root[data-theme="plum"] .portal-workspace {
    --workspace-bg: #251c2c;
    --workspace-surface: #302638;
    --workspace-raised: #3d3147;
    --workspace-border: #63516d;
    --workspace-text: #f0e5f3;
    --workspace-muted: #c6b6cf;
    --workspace-accent: #d9b3ef;
    --workspace-on-accent: #31203b;
    --workspace-focus: #edc5ff;
    --workspace-input-border: #8c7599;
}
.portal-workspace { scrollbar-color: var(--workspace-input-border) var(--workspace-surface); }
.portal-workspace .btn:disabled { background: var(--workspace-raised); }
.portal-workspace input::placeholder, .portal-workspace textarea::placeholder { color: var(--workspace-muted); }
:root[data-theme="light"] .sidebar-logo { filter: brightness(.38) saturate(1.4); }
.portal-workspace .theme-options { display: flex; flex-wrap: wrap; gap: 12px; border: 0; padding: 0; margin: 16px 0; }
.portal-workspace .theme-options legend { margin-bottom: 10px; font-weight: 600; }
.portal-workspace .theme-option { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 14px; border: 1px solid var(--workspace-input-border); border-radius: 8px; cursor: pointer; background: var(--workspace-bg); }
.portal-workspace .theme-option:has(:checked) { border-color: var(--workspace-accent); box-shadow: inset 0 0 0 1px var(--workspace-accent); }
.portal-workspace .theme-swatch { display: inline-block; width: 28px; height: 28px; border: 1px solid var(--workspace-input-border); border-radius: 50%; }
.theme-swatch-dark { background: linear-gradient(135deg, #252936 50%, #afd59e 50%); }
.theme-swatch-light { background: linear-gradient(135deg, #ffffff 50%, #27633e 50%); }
.theme-swatch-ocean { background: linear-gradient(135deg, #172c3b 50%, #80d5dc 50%); }
.theme-swatch-plum { background: linear-gradient(135deg, #302638 50%, #d9b3ef 50%); }
.theme-swatch-system { background: linear-gradient(90deg, #252936 50%, #ffffff 50%); }
#theme-status { min-height: 1.5em; color: var(--workspace-muted); }
@media (forced-colors: active) {
    .portal-workspace .theme-option:has(:checked) { outline: 2px solid Highlight; }
}

:root[data-theme="light"] .portal-workspace .rodada-action { background: var(--workspace-surface); }
:root[data-theme="light"] .portal-workspace .rodada-action:disabled { background: var(--workspace-raised); }
:root[data-theme="light"] .portal-workspace :is(.btn-danger, .btn-warning):hover { filter: brightness(.9); }
:root:not([data-theme="dark"]) .portal-workspace {
    --study-surface: var(--workspace-surface);
    --study-surface-raised: var(--workspace-raised);
    --study-border: var(--workspace-border);
    --study-focus: var(--workspace-focus);
}
:root[data-theme="light"] .portal-workspace .btn-danger:hover { background: var(--workspace-danger); }
:root[data-theme="light"] .portal-workspace .btn-warning:hover { background: var(--workspace-warning); }
:root[data-theme="light"] .portal-workspace .new-estudos-banner { background: #e3f2e5; }
:root[data-theme="light"] .portal-workspace .badge-origem-upload { color: var(--workspace-info); }
:root[data-theme="light"] .portal-workspace .badge-origem-importado { color: #67409a; }
