:root,
[data-theme="modern-grade"] {
    /* Semantic presentation choices consumed by theme-agnostic component CSS. */
    --page-color-scheme: light;
    --page-background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 16%, transparent), transparent 32%),
        radial-gradient(circle at bottom right, color-mix(in srgb, var(--progress-fill) 12%, transparent), transparent 36%),
        linear-gradient(180deg, var(--bg-page) 0%, color-mix(in srgb, var(--bg-page) 78%, var(--bg-panel) 22%) 100%);
    --site-brand-logo-light-display: block;
    --site-brand-logo-amber-display: none;
    --site-brand-logo-dark-display: none;
    --presence-completed-text: var(--text-primary);
    --hero-box-shadow: 0 18px 40px color-mix(in srgb, var(--shadow-color) 18%, transparent);
    --candidate-home-text: var(--text-on-accent);
    --candidate-home-icon-text: color-mix(in srgb, var(--text-on-accent) 78%, var(--accent-subtle) 22%);
    --candidate-home-helper-text: color-mix(in srgb, var(--text-on-accent) 72%, var(--accent-subtle) 28%);
    --candidate-home-input-text: var(--text-on-accent);
    --candidate-home-placeholder-text: color-mix(in srgb, var(--text-on-accent) 62%, var(--accent-subtle) 38%);
    --role-admin: #334155;
    --role-content-author: #0f766e;
    --role-content-reviewer: #2563eb;
    --role-marker: #7c3aed;
    --role-invigilator: #e8a020;
    --role-candidate: #4a7cb5;
    --brand-surface: #ffffff;
    --sidebar-bg: #ffffff;
    --sidebar-text: #1a1a2a;
    --sidebar-muted: #9c9690;
    --heading-font: inherit;
    --bg-page: #f5f3ef;
    --bg-panel: #ffffff;
    --bg-panel-secondary: #f8fbff;
    --bg-table-header: #1b3f72;
    --bg-input: #ffffff;
    --bg-radio-selected: #d6e6f5;
    --bg-status-live: #dcfce7;
    --bg-badge-draft: #d6e6f5;
    --border-color: #e0dbd3;
    --border-color-emphasis: #4a7cb5;
    --border-width: 1px;
    --border-width-emphasis: 1.5px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 18px;
    --border-radius-pill: 999px;
    --text-primary: #1a1a2a;
    --text-secondary: #4a4a5a;
    --text-muted: #736e66;
    --text-on-accent: #ffffff;
    --text-status-live: #166534;
    --text-badge-draft: #1b3f72;
    --text-role-label: #d6e6f5;
    --accent: #4a7cb5;
    /* AA-compliant text variant of the accent (WCAG 1.4.3): used for link and
       status text where --accent itself fails 4.5:1. --accent stays for
       borders/fills/backgrounds. See Phase 88 platform accessibility audit. */
    --accent-text: #2f5f93;
    --accent-hover: #1b3f72;
    --accent-subtle: #d6e6f5;
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --success-text: #166534;
    --btn-primary-bg: #1b3f72;
    --btn-primary-text: #ffffff;
    --btn-primary-border: none;
    --btn-secondary-bg: #ffffff;
    --btn-secondary-text: #1b3f72;
    --btn-secondary-border: 1px solid #e0dbd3;
    --progress-track: #d6e6f5;
    --progress-fill: #4a7cb5;
    --role-icon-bg: #1b3f72;
    --role-icon-text: #ffffff;
    --question-accent-border: #4a7cb5;
    --question-accent-bg: #f8fbff;
    --bg-notice: #ffffff;
    --bg-error: #fef2f2;
    --border-error: #fecaca;
    --text-error: #b91c1c;
    --warning-bg: #fff7ed;
    --warning-text: #9a3412;
    --bg-status-ready: #f3f7fc;
    --border-status-ready: #a8c4e0;
    --text-status-ready: #1b3f72;
    --bg-status-open: #f0fdf4;
    --border-status-open: #bbf7d0;
    --text-status-open: #166534;
    --bg-status-closed: #fff5df;
    --border-status-closed: #e8a020;
    --text-status-closed: #8c5d10;
    --bg-status-archived: #f8f5f0;
    --border-status-archived: #d9d1c7;
    --text-status-archived: #6b6773;
    /* Warning border companion to --warning-bg / --warning-text. */
    --warning-border: #d6a64a;
    /* Additional status families for badges that are neither ready/open/closed.
       Defined once here as the theme-agnostic default; themes inherit these
       unless a future change tunes them per palette. */
    --bg-status-info: #ede9fe;
    --border-status-info: #8b5cf6;
    --text-status-info: #5b21b6;
    --bg-status-sky: #e0f2fe;
    --border-status-sky: #0ea5e9;
    --text-status-sky: #0c4a6e;
    --bg-status-pink: #fce7f3;
    --border-status-pink: #ec4899;
    --text-status-pink: #831843;
    /* Bespoke gold "attention" highlight used by invigilator help/indicator pills. */
    --highlight-attention: #f4c95d;
    --highlight-attention-text: #3b2b00;
    --shadow-color: #d7d0c7;
}

[data-theme="slate-command"] {
    --page-color-scheme: dark;
    --page-background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 20%, transparent), transparent 28%),
        radial-gradient(circle at bottom right, color-mix(in srgb, var(--progress-fill) 18%, transparent), transparent 30%),
        linear-gradient(180deg, var(--bg-page) 0%, color-mix(in srgb, var(--bg-page) 90%, var(--bg-panel) 10%) 100%);
    --site-brand-logo-light-display: none;
    --site-brand-logo-dark-display: block;
    --presence-completed-text: var(--text-on-accent);
    --role-admin: #334155;
    --role-content-author: #0f766e;
    --role-content-reviewer: #2563eb;
    --role-marker: #7c3aed;
    --role-invigilator: #d97706;
    --role-candidate: #0891b2;
    --brand-surface: #1b3f72;
    --sidebar-bg: #0f172a;
    --sidebar-text: #f8fafc;
    --sidebar-muted: #cbd5e1;
    --heading-font: inherit;
    --bg-page: #0f172a;
    --bg-panel: #1e293b;
    --bg-panel-secondary: #0f172a;
    --bg-table-header: #0a0f1a;
    --bg-input: #0f172a;
    --bg-radio-selected: #1e3a5f;
    --bg-status-live: #052e16;
    --bg-badge-draft: #052e16;
    --border-color: #334155;
    --border-color-emphasis: #3b82f6;
    --border-width: 1px;
    --border-width-emphasis: 1px;
    --border-radius-sm: 4px;
    --border-radius-md: 4px;
    --border-radius-lg: 8px;
    --border-radius-pill: 3px;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-on-accent: #ffffff;
    --text-status-live: #22c55e;
    --text-badge-draft: #22c55e;
    --text-role-label: #3b82f6;
    --accent: #3b82f6;
    --accent-text: #60a5fa;
    --accent-hover: #2563eb;
    --accent-subtle: #1e3a5f;
    --success: #22c55e;
    --success-bg: #052e16;
    --success-border: #166534;
    --success-text: #ffffff;
    --btn-primary-bg: #3b82f6;
    --btn-primary-text: #ffffff;
    --btn-primary-border: none;
    --btn-secondary-bg: #1e293b;
    --btn-secondary-text: #cbd5e1;
    --btn-secondary-border: 1px solid #475569;
    --progress-track: #334155;
    --progress-fill: #3b82f6;
    --role-icon-bg: #1e3a5f;
    --role-icon-text: #3b82f6;
    --question-accent-border: #3b82f6;
    --question-accent-bg: #1e3a5f;
    --bg-notice: #0f172a;
    --bg-error: #3f1d1d;
    --border-error: #7f1d1d;
    --text-error: #fca5a5;
    --warning-bg: #431407;
    --warning-text: #fdba74;
    --bg-status-ready: #172554;
    --border-status-ready: #1d4ed8;
    --text-status-ready: #93c5fd;
    --bg-status-open: #052e16;
    --border-status-open: #166534;
    --text-status-open: #86efac;
    --bg-status-closed: #431407;
    --border-status-closed: #9a3412;
    --text-status-closed: #fdba74;
    --bg-status-archived: #111827;
    --border-status-archived: #374151;
    --text-status-archived: #cbd5e1;
    --shadow-color: #020617;
}

[data-theme="civic-clear"] {
    --hero-box-shadow: none;
    --role-admin: #334155;
    --role-content-author: #0f766e;
    --role-content-reviewer: #2563eb;
    --role-marker: #7c3aed;
    --role-invigilator: #d97706;
    --role-candidate: #0891b2;
    --brand-surface: #ffffff;
    --sidebar-bg: #003078;
    --sidebar-text: #ffffff;
    --sidebar-muted: #93c5fd;
    --sidebar-card-bg: #1a4080;
    --sidebar-card-border: #2a5298;
    --sidebar-card-label: #93c5fd;
    --sidebar-card-text: #ffffff;
    --heading-font: inherit;
    --bg-page: #ffffff;
    --bg-panel: #f3f2f1;
    --bg-panel-secondary: #ffffff;
    --bg-table-header: #003078;
    --bg-input: #ffffff;
    --bg-radio-selected: #f0f4fa;
    --bg-status-live: #00703c;
    --bg-badge-draft: #f3f2f1;
    --border-color: #b1b4b6;
    --border-color-emphasis: #003078;
    --border-width: 2px;
    --border-width-emphasis: 2px;
    --border-radius-sm: 0px;
    --border-radius-md: 0px;
    --border-radius-lg: 0px;
    --border-radius-pill: 0px;
    --text-primary: #0b0c0e;
    --text-secondary: #505a5f;
    --text-muted: #505a5f;
    --text-on-accent: #ffffff;
    --text-status-live: #ffffff;
    --text-badge-draft: #505a5f;
    --text-role-label: #ffffff;
    --accent: #003078;
    /* --accent already clears 4.5:1 as text on this theme; keep them equal. */
    --accent-text: #003078;
    --accent-hover: #001f53;
    --accent-subtle: #f0f4fa;
    --success: #00703c;
    --success-bg: #f3f2f1;
    --success-border: #b1b4b6;
    --success-text: #0b0c0e;
    --btn-primary-bg: #00703c;
    --btn-primary-text: #ffffff;
    --btn-primary-border: none;
    --btn-secondary-bg: #ffffff;
    --btn-secondary-text: #0b0c0e;
    --btn-secondary-border: 2px solid #0b0c0e;
    --progress-track: #b1b4b6;
    --progress-fill: #003078;
    --role-icon-bg: #003078;
    --role-icon-text: #ffffff;
    --question-accent-border: #ffdd00;
    --question-accent-bg: #faf9f8;
    --bg-notice: #ffffff;
    --bg-error: #ffffff;
    --border-error: #d4351c;
    --text-error: #d4351c;
    --warning-bg: #fff7bf;
    --warning-text: #0b0c0e;
    --bg-status-ready: #f0f4fa;
    --border-status-ready: #003078;
    --text-status-ready: #003078;
    --bg-status-open: #00703c;
    --border-status-open: #00703c;
    --text-status-open: #ffffff;
    --bg-status-closed: #fff7bf;
    --border-status-closed: #ffdd00;
    --text-status-closed: #0b0c0e;
    --bg-status-archived: #f3f2f1;
    --border-status-archived: #b1b4b6;
    --text-status-archived: #505a5f;
    --shadow-color: #b1b4b6;
}

[data-theme="amber-ledger"] {
    --site-brand-logo-light-display: none;
    --site-brand-logo-amber-display: block;
    --presence-completed-text: var(--text-on-accent);
    --role-admin: #334155;
    --role-content-author: #0f766e;
    --role-content-reviewer: #2563eb;
    --role-marker: #7c3aed;
    --role-invigilator: #d97706;
    --role-candidate: #0891b2;
    --brand-surface: #fffdf9;
    --sidebar-bg: #78350f;
    --sidebar-text: #fff7ed;
    --sidebar-muted: #fed7aa;
    --sidebar-card-bg: #92400e;
    --sidebar-card-border: #b45309;
    --sidebar-card-label: #fdba74;
    --sidebar-card-text: #fff7ed;
    --heading-font: var(--font-serif);
    --bg-page: #fdf8f0;
    --bg-panel: #ffffff;
    --bg-panel-secondary: #fef3c7;
    --bg-table-header: #451a03;
    --bg-input: #ffffff;
    --bg-radio-selected: #fff7ed;
    --bg-status-live: #14532d;
    --bg-badge-draft: #451a03;
    --border-color: #e7d5bb;
    --border-color-emphasis: #ea580c;
    --border-width: 1px;
    --border-width-emphasis: 1.5px;
    --border-radius-sm: 4px;
    --border-radius-md: 5px;
    --border-radius-lg: 8px;
    --border-radius-pill: 999px;
    --text-primary: #451a03;
    --text-secondary: #78350f;
    --text-muted: #b45309;
    --text-on-accent: #fff7ed;
    --text-status-live: #86efac;
    --text-badge-draft: #fed7aa;
    --text-role-label: #fed7aa;
    --accent: #ea580c;
    --accent-text: #b8480b;
    --accent-hover: #c2410c;
    --accent-subtle: #fff7ed;
    --success: #4ade80;
    --success-bg: #14532d;
    --success-border: #166534;
    --success-text: #fff7ed;
    --btn-primary-bg: #ea580c;
    --btn-primary-text: #fff7ed;
    --btn-primary-border: none;
    --btn-secondary-bg: #ffffff;
    --btn-secondary-text: #78350f;
    --btn-secondary-border: 1px solid #e7d5bb;
    --progress-track: #e7d5bb;
    --progress-fill: #ea580c;
    --role-icon-bg: #92400e;
    --role-icon-text: #fed7aa;
    --question-accent-border: #ea580c;
    --question-accent-bg: #fff7ed;
    --bg-notice: #fffaf2;
    --bg-error: #fff1f2;
    --border-error: #fdba74;
    --text-error: #9a3412;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --bg-status-ready: #ffedd5;
    --border-status-ready: #fdba74;
    --text-status-ready: #9a3412;
    --bg-status-open: #14532d;
    --border-status-open: #166534;
    --text-status-open: #bbf7d0;
    --bg-status-closed: #fef3c7;
    --border-status-closed: #f59e0b;
    --text-status-closed: #92400e;
    --bg-status-archived: #451a03;
    --border-status-archived: #78350f;
    --text-status-archived: #fed7aa;
    --shadow-color: #b45309;
}

[data-theme="forest-authority"] {
    --presence-completed-text: var(--text-on-accent);
    --role-admin: #334155;
    --role-content-author: #0f766e;
    --role-content-reviewer: #2563eb;
    --role-marker: #7c3aed;
    --role-invigilator: #d97706;
    --role-candidate: #0891b2;
    --brand-surface: #f8fdf9;
    --sidebar-bg: #14532d;
    --sidebar-text: #f0fdf4;
    --sidebar-muted: #86efac;
    --sidebar-card-bg: #166534;
    --sidebar-card-border: #15803d;
    --sidebar-card-label: #4ade80;
    --sidebar-card-text: #f0fdf4;
    --heading-font: inherit;
    --bg-page: #f7fdf9;
    --bg-panel: #ffffff;
    --bg-panel-secondary: #f0fdf4;
    --bg-table-header: #052e16;
    --bg-input: #ffffff;
    --bg-radio-selected: #dcfce7;
    --bg-status-live: #052e16;
    --bg-badge-draft: #052e16;
    --border-color: #bbf7d0;
    --border-color-emphasis: #15803d;
    --border-width: 1px;
    --border-width-emphasis: 1.5px;
    --border-radius-sm: 5px;
    --border-radius-md: 5px;
    --border-radius-lg: 8px;
    --border-radius-pill: 999px;
    --text-primary: #052e16;
    --text-secondary: #166534;
    --text-muted: #15803d;
    --text-on-accent: #f0fdf4;
    --text-status-live: #4ade80;
    --text-badge-draft: #4ade80;
    --text-role-label: #f0fdf4;
    --accent: #15803d;
    /* --accent already clears 4.5:1 as text on this theme; keep them equal. */
    --accent-text: #15803d;
    --accent-hover: #14532d;
    --accent-subtle: #dcfce7;
    --success: #4ade80;
    --success-bg: #052e16;
    --success-border: #166534;
    --success-text: #f0fdf4;
    --btn-primary-bg: #15803d;
    --btn-primary-text: #f0fdf4;
    --btn-primary-border: none;
    --btn-secondary-bg: #ffffff;
    --btn-secondary-text: #166534;
    --btn-secondary-border: 1px solid #bbf7d0;
    --progress-track: #bbf7d0;
    --progress-fill: #15803d;
    --role-icon-bg: #14532d;
    --role-icon-text: #86efac;
    --question-accent-border: #15803d;
    --question-accent-bg: #f0fdf4;
    --bg-notice: #f0fdf4;
    --bg-error: #fef2f2;
    --border-error: #fecaca;
    --text-error: #991b1b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --bg-status-ready: #dcfce7;
    --border-status-ready: #86efac;
    --text-status-ready: #166534;
    --bg-status-open: #052e16;
    --border-status-open: #166534;
    --text-status-open: #86efac;
    --bg-status-closed: #ecfccb;
    --border-status-closed: #84cc16;
    --text-status-closed: #3f6212;
    --bg-status-archived: #14532d;
    --border-status-archived: #166534;
    --text-status-archived: #bbf7d0;
    --shadow-color: #166534;
}

[data-theme="obsidian-edge"] {
    --page-color-scheme: dark;
    --page-background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 20%, transparent), transparent 28%),
        radial-gradient(circle at bottom right, color-mix(in srgb, var(--progress-fill) 18%, transparent), transparent 30%),
        linear-gradient(180deg, var(--bg-page) 0%, color-mix(in srgb, var(--bg-page) 90%, var(--bg-panel) 10%) 100%);
    --site-brand-logo-light-display: none;
    --site-brand-logo-dark-display: block;
    --presence-completed-text: var(--text-on-accent);
    /* This palette's accent text tokens are near-black, so the dark candidate
       tile needs its light text tokens for readable copy and access-code input. */
    --candidate-home-text: var(--text-primary);
    --candidate-home-icon-text: var(--text-secondary);
    --candidate-home-helper-text: var(--text-secondary);
    --candidate-home-input-text: var(--text-primary);
    --candidate-home-placeholder-text: var(--text-secondary);
    --role-admin: #334155;
    --role-content-author: #0f766e;
    --role-content-reviewer: #2563eb;
    --role-marker: #7c3aed;
    --role-invigilator: #d97706;
    --role-candidate: #0891b2;
    --brand-surface: #09090b;
    --sidebar-bg: #09090b;
    --sidebar-text: #fafafa;
    --sidebar-muted: #52525b;
    --heading-font: inherit;
    --bg-page: #09090b;
    --bg-panel: #09090b;
    --bg-panel-secondary: #18181b;
    --bg-table-header: #18181b;
    --bg-input: #09090b;
    --bg-radio-selected: #18181b;
    --bg-status-live: #09090b;
    --bg-badge-draft: #09090b;
    --border-color: #27272a;
    --border-color-emphasis: #a3e635;
    --border-width: 1px;
    --border-width-emphasis: 1px;
    --border-radius-sm: 0px;
    --border-radius-md: 0px;
    --border-radius-lg: 2px;
    --border-radius-pill: 0px;
    --text-primary: #fafafa;
    --text-secondary: #d4d4d8;
    --text-muted: #8a8a93;
    --text-on-accent: #09090b;
    --text-status-live: #a3e635;
    /* WCAG 1.4.3 (Phase 88): #71717a was 4.12:1 on the #09090b pill bg; #85858e
       is 5.44:1, keeping the muted-grey intent. Reused by --text-status-archived. */
    --text-badge-draft: #85858e;
    --text-role-label: #a3e635;
    --accent: #a3e635;
    /* Lime on near-black already clears 4.5:1 as text; keep them equal. */
    --accent-text: #a3e635;
    --accent-hover: #84cc16;
    --accent-subtle: #18181b;
    --success: #a3e635;
    --success-bg: #09090b;
    --success-border: #27272a;
    --success-text: #a3e635;
    --btn-primary-bg: #a3e635;
    --btn-primary-text: #09090b;
    --btn-primary-border: none;
    --btn-secondary-bg: #09090b;
    --btn-secondary-text: #71717a;
    --btn-secondary-border: 1px solid #3f3f46;
    --progress-track: #27272a;
    --progress-fill: #a3e635;
    --role-icon-bg: #09090b;
    --role-icon-text: #a3e635;
    --question-accent-border: #a3e635;
    --question-accent-bg: #18181b;
    --bg-notice: #18181b;
    --bg-error: #2b1115;
    --border-error: #7f1d1d;
    --text-error: #fca5a5;
    --warning-bg: #1c1917;
    --warning-text: #fdba74;
    --bg-status-ready: #18181b;
    --border-status-ready: #52525b;
    --text-status-ready: #fafafa;
    --bg-status-open: #09090b;
    --border-status-open: #3f6212;
    --text-status-open: #a3e635;
    --bg-status-closed: #1c1917;
    --border-status-closed: #57534e;
    --text-status-closed: #e7e5e4;
    --bg-status-archived: #09090b;
    --border-status-archived: #27272a;
    /* WCAG 1.4.3 (Phase 88): lightened from #71717a (4.12:1) to clear 4.5:1
       on the #09090b archived-pill background. */
    --text-status-archived: #85858e;
    --shadow-color: #000000;
}
[data-theme="l&da"] {
    --sidebar-bg: #0b3b63;
    --sidebar-text: #ffffff;
    --sidebar-muted: #b6d8ee;
    --sidebar-card-bg: #f4f9fc;
    --sidebar-card-border: #c9dbe8;
    --sidebar-card-label: #5f84a0;
    --sidebar-card-text: #12324a;

    --bg-page: #f4f9fc;
    --bg-panel: #ffffff;
    --bg-panel-secondary: #eef7fc;
    --bg-table-header: #0b3b63;

    --text-primary: #12324a;
    --text-secondary: #3d5d74;
    --text-muted: #577084;
    --text-on-accent: #ffffff;

    --accent: #7bb342;
    /* AA-compliant text variant: lime #7bb342 is only 2.5:1 as text on white;
       #4a7a28 clears 4.5:1. --accent stays for borders/fills/backgrounds. */
    --accent-text: #4a7a28;
    --accent-hover: #5f8f32;
    --accent-subtle: #eef7e8;

    --btn-primary-bg: #7bb342;
    --btn-primary-text: #ffffff;
    --btn-primary-border: none;

    --btn-secondary-bg: #ffffff;
    --btn-secondary-text: #0b3b63;
    --btn-secondary-border: 1px solid #c9dbe8;

    --progress-track: #d9edf8;
    --progress-fill: #7bb342;

    --border-color: #c9dbe8;
    --border-color-emphasis: #7bb342;

    --question-accent-border: #7bb342;
    --question-accent-bg: #eef7e8;

    --role-icon-bg: #0b3b63;
    --role-icon-text: #ffffff;

    --success: #7bb342;
    --success-bg: #eef7e8;
    --success-border: #b9d99a;
    --success-text: #3f6212;

    --shadow-color: rgba(11, 59, 99, 0.12);
}
