/* Explicit portal preference wins over operating-system media rules. */
:root[data-theme="light"]{color-scheme:light;--bg:#f5f8fd;--panel:#fff;--surface:#fff;--surface-2:#f1f5fb;--surface-3:#e9eff7;--raised:#f1f5fb;--text:#14263e;--text-soft:#263e59;--muted:#526882;--line:#ccd8e5;--input:#fff;--table-head:#edf3fa;--table-hover:#eaf1f9;--error:#962d3c;--recovery-info-bg:#edf5ff;--recovery-info-text:#234d78;--recovery-error-bg:#fff0f2;--recovery-error-text:#8c2336}
:root[data-theme="dark"]{color-scheme:dark;--bg:#0b1629;--panel:#14243b;--surface:#14243b;--surface-2:#1a2e49;--surface-3:#203752;--raised:#1a2e49;--text:#edf4fc;--text-soft:#d6e3f1;--muted:#b2c4da;--line:#3b526d;--input:#0e1e33;--table-head:#1c304c;--table-hover:#203752;--error:#ffbdc7;--recovery-info-bg:#162d49;--recovery-info-text:#cfdef3;--recovery-error-bg:#3c2331;--recovery-error-text:#ffd3db}
:root[data-theme] body{background-color:var(--bg);color:var(--text)}
/* Components used to choose their own OS theme, independently of the switch. */
:root[data-theme] :is(.w6110,.logistics6100,.openroster690,.campaign6141,.kn6140,.knowledge680-hero,.knowledge680-card,.ka6120,.e6120,.r6110,.di6110,.dh6120,.h6120,.mc6130,.cs6130,.w6120-panel,.cf6100,.p6100-panel,.advisor6110){--panel:var(--surface);--muted:inherit;color:var(--text)}
:root[data-theme="light"] :is(.w6110,.ka6120,.di6110,.dh6120,.h6120){--panel:#fff;--muted:#526882;--line:#ccd8e5;color:#14263e}
:root[data-theme="dark"] :is(.w6110,.ka6120,.di6110,.dh6120,.h6120){--panel:#14243b;--muted:#b2c4da;--line:#3b526d;color:#edf4fc}
:root[data-theme] :is(.panel,.card,.empty,.t450-dialog,.t450-content,.t450-header,.t510-card,.t510-box,.t500-card,.t530-card,.t460-pool,.w6110 .panel,.l6100-week,.l6100-candidate,.l6100-summary,.t690-card,.knowledge680-card,.ka6120-stats>div,.e6120-card,.r6110-panel,.di6110-card,.di6110-kpis>div,.dh-card,.h6120-topic,.mc6130-card,.mc6130-panel,.kn6140-card,.w6120-panel){background-color:var(--surface);color:var(--text);border-color:var(--line)}
:root[data-theme] :is(input,select,textarea,button:not(.primary):not(.theme-toggle):not(.mc6130-primary):not(.kn6140-primary),.btn.secondary,.button:not(.primary)){background-color:var(--input);color:var(--text);border-color:var(--line)}
:root[data-theme] :is(input,textarea)::placeholder{color:var(--muted);opacity:1}
:root[data-theme] :is(th,thead){background-color:var(--table-head);color:var(--text-soft)}
:root[data-theme] :is(td,th,fieldset,hr){border-color:var(--line)}
:root[data-theme] tbody tr:hover{background-color:var(--table-hover)}
:root[data-theme] :is(.muted,.meta,.sub,.hint,.t7-footnote,.cs6130-muted,.op6130-hint){color:var(--muted)}
:root[data-theme] :is(.notice,.t7-alert,.ka6120-warning,.campaign6141-warning,.t690-note,.w6120-notice){background-color:var(--recovery-info-bg);color:var(--recovery-info-text);border-color:var(--line)}
:root[data-theme] :is(.alert,.error,.a6110-error){background-color:var(--recovery-error-bg);color:var(--recovery-error-text);border-color:var(--error)}
:root[data-theme] :is(button.primary,.btn.primary,.button.primary,.mc6130-primary,.kn6140-primary){color:#102111}
:root[data-theme] .w6110 button.primary{color:var(--accent-ink,#14280d)}
:root[data-theme] :is(#context,.topbar,.sidebar){color:var(--text);border-color:var(--line)}
:root[data-theme] .topbar{background-color:var(--surface)}
:root[data-theme="light"] .sidebar{background:linear-gradient(180deg,#fff,#f1f5fb)}
:root[data-theme="dark"] .sidebar{background:linear-gradient(180deg,#0b1629,#14243b)}
:root[data-theme] .theme-toggle{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:1px solid var(--line);border-radius:999px;padding:7px 12px;background-color:var(--surface-2);color:var(--text);min-height:42px;cursor:pointer;font:inherit;font-weight:700;white-space:nowrap}
:root[data-theme] .theme-toggle:focus-visible{outline:3px solid #4699cc;outline-offset:3px}
:root[data-theme] .theme-toggle[aria-checked="true"]{border-color:#7ab743}
:root[data-theme] .theme-toggle-text{color:var(--text)}
@media(max-width:640px){.theme-toggle [data-theme-label]{display:none}:root[data-theme] .theme-toggle{padding:7px 10px}.top-actions{gap:7px;flex-wrap:wrap}}
@media(prefers-reduced-motion:reduce){.theme-toggle-thumb{transition:none!important}}

/* Legacy components share the explicit portal theme even before newer body markers are present. */
:root[data-theme]{--panel:var(--surface);--surface-alt:var(--surface-2);--soft:var(--surface-2);--border:var(--line);--danger:var(--error);--button:var(--surface-2);--button-text:var(--text)}

/* RC2: older portal shells still refer to the former logo and portal links. */
:root[data-theme] .brand img.brand-logo{background:#fff;padding:8px;border-radius:9px;filter:none;object-fit:contain;height:auto;max-height:60px}
:root[data-theme] .legacy-link,:root[data-theme] .sidebar-foot [data-t="legacy"],:root[data-theme] .page-head a[href="/"],:root[data-theme] .page-head a[href="https://planner.cursuscompleet.nl/"]{display:none!important}
:root[data-theme] .page-head .t6145-head-actions{margin-left:auto;display:flex;justify-content:flex-end;align-self:flex-start;gap:10px;flex-wrap:wrap}
