/**
 * Catchie public-site theme adapter.
 *
 * This file deliberately does not replace or edit the MVC portal's existing
 * theme implementation. It maps the same twelve theme IDs and localStorage choice
 * onto the public homepage, protected classroom portals, and newer learning
 * modules. Minimal Dark preserves the modules' established visual style.
 */

:root,
:root[data-theme="minimal_dark"] {
    color-scheme: dark;
    --site-bg: #07111f;
    --site-surface: #101d31;
    --site-surface-solid: #111827;
    --site-surface-soft: #162640;
    --site-surface-muted: #1e293b;
    --site-border: #2b3b55;
    --site-border-strong: #3f5d82;
    --site-text: #f8fafc;
    --site-muted: #b7c5d8;
    --site-primary: #38bdf8;
    --site-secondary: #8b5cf6;
    --site-accent: #facc15;
    --site-good: #4ade80;
    --site-bad: #fb7185;
    --site-primary-soft: rgba(56, 189, 248, .16);
    --site-shadow: 0 24px 70px rgba(0, 0, 0, .34);
    --site-shadow-soft: 0 10px 28px rgba(0, 0, 0, .24);
    --site-background: radial-gradient(circle at 12% 4%, rgba(56,189,248,.19), transparent 31rem), radial-gradient(circle at 90% 2%, rgba(139,92,246,.18), transparent 30rem), linear-gradient(145deg, #030712, #07111f);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --site-bg: #0b1120;
    --site-surface: #111827;
    --site-surface-solid: #0f172a;
    --site-surface-soft: #1e293b;
    --site-surface-muted: #253247;
    --site-border: rgba(148,163,184,.30);
    --site-border-strong: rgba(147,197,253,.48);
    --site-text: #f1f5f9;
    --site-muted: #cbd5e1;
    --site-primary: #60a5fa;
    --site-secondary: #a78bfa;
    --site-accent: #fbbf24;
    --site-good: #4ade80;
    --site-bad: #fb7185;
    --site-primary-soft: rgba(96,165,250,.16);
    --site-shadow: 0 24px 70px rgba(0,0,0,.40);
    --site-shadow-soft: 0 10px 28px rgba(0,0,0,.28);
    --site-background: radial-gradient(circle at 12% 6%, rgba(37,99,235,.22), transparent 31rem), radial-gradient(circle at 88% 5%, rgba(124,58,237,.20), transparent 30rem), linear-gradient(145deg, #020617, #0b1120);
}

:root[data-theme="light"] {
    color-scheme: light;
    --site-bg: #eef4fb;
    --site-surface: #ffffff;
    --site-surface-solid: #ffffff;
    --site-surface-soft: #f1f5f9;
    --site-surface-muted: #e2e8f0;
    --site-border: #cbd5e1;
    --site-border-strong: #93c5fd;
    --site-text: #0f172a;
    --site-muted: #475569;
    --site-primary: #2563eb;
    --site-secondary: #7c3aed;
    --site-accent: #a16207;
    --site-good: #15803d;
    --site-bad: #b91c1c;
    --site-primary-soft: #dbeafe;
    --site-shadow: 0 22px 60px rgba(15,23,42,.13);
    --site-shadow-soft: 0 8px 22px rgba(15,23,42,.09);
    --site-background: radial-gradient(circle at 10% 5%, #dbeafe, transparent 31rem), radial-gradient(circle at 92% 4%, #ede9fe, transparent 29rem), linear-gradient(145deg, #f8fafc, #eef4fb);
}

:root[data-theme="modern"] {
    color-scheme: light;
    --site-bg: #f8fafc;
    --site-surface: #ffffff;
    --site-surface-solid: #ffffff;
    --site-surface-soft: #eef2ff;
    --site-surface-muted: #e0e7ff;
    --site-border: rgba(99,102,241,.28);
    --site-border-strong: rgba(79,70,229,.52);
    --site-text: #0f172a;
    --site-muted: #475569;
    --site-primary: #4f46e5;
    --site-secondary: #0891b2;
    --site-accent: #b45309;
    --site-good: #047857;
    --site-bad: #b91c1c;
    --site-primary-soft: #eef2ff;
    --site-shadow: 0 22px 58px rgba(79,70,229,.14);
    --site-shadow-soft: 0 8px 22px rgba(15,23,42,.08);
    --site-background: radial-gradient(circle at 12% 6%, rgba(79,70,229,.15), transparent 30rem), radial-gradient(circle at 90% 8%, rgba(8,145,178,.14), transparent 30rem), linear-gradient(180deg, #f8fafc, #ffffff);
}

:root[data-theme="minimal"] {
    color-scheme: light;
    --site-bg: #fafafa;
    --site-surface: #ffffff;
    --site-surface-solid: #ffffff;
    --site-surface-soft: #f8fafc;
    --site-surface-muted: #f1f5f9;
    --site-border: #e2e8f0;
    --site-border-strong: #cbd5e1;
    --site-text: #111827;
    --site-muted: #64748b;
    --site-primary: #2563eb;
    --site-secondary: #334155;
    --site-accent: #92400e;
    --site-good: #15803d;
    --site-bad: #b91c1c;
    --site-primary-soft: #eff6ff;
    --site-shadow: 0 12px 32px rgba(15,23,42,.07);
    --site-shadow-soft: 0 5px 16px rgba(15,23,42,.06);
    --site-background: linear-gradient(180deg, #fafafa, #ffffff);
}

:root[data-theme="neon"] {
    color-scheme: dark;
    --site-bg: #070314;
    --site-surface: #10132a;
    --site-surface-solid: #0f1024;
    --site-surface-soft: #181a37;
    --site-surface-muted: #22264b;
    --site-border: rgba(34,211,238,.34);
    --site-border-strong: rgba(236,72,153,.62);
    --site-text: #f8fafc;
    --site-muted: #dbeafe;
    --site-primary: #22d3ee;
    --site-secondary: #ec4899;
    --site-accent: #facc15;
    --site-good: #4ade80;
    --site-bad: #fb7185;
    --site-primary-soft: rgba(34,211,238,.15);
    --site-shadow: 0 22px 68px rgba(0,0,0,.48), 0 0 30px rgba(34,211,238,.12);
    --site-shadow-soft: 0 10px 28px rgba(0,0,0,.32), 0 0 16px rgba(236,72,153,.10);
    --site-background: radial-gradient(circle at 12% 5%, rgba(34,211,238,.24), transparent 31rem), radial-gradient(circle at 90% 8%, rgba(236,72,153,.23), transparent 31rem), linear-gradient(145deg, #05020d, #1b0830);
}

:root[data-theme="genz"] {
    color-scheme: light;
    --site-bg: #fbf7ff;
    --site-surface: rgba(255,255,255,.94);
    --site-surface-solid: #ffffff;
    --site-surface-soft: #f5f3ff;
    --site-surface-muted: #ede9fe;
    --site-border: rgba(168,85,247,.27);
    --site-border-strong: rgba(236,72,153,.48);
    --site-text: #24113d;
    --site-muted: #6b5a7c;
    --site-primary: #8b5cf6;
    --site-secondary: #ec4899;
    --site-accent: #b45309;
    --site-good: #047857;
    --site-bad: #be123c;
    --site-primary-soft: #f5f3ff;
    --site-shadow: 0 20px 54px rgba(139,92,246,.17);
    --site-shadow-soft: 0 8px 22px rgba(236,72,153,.11);
    --site-background: radial-gradient(circle at 8% 4%, #cffafe, transparent 31rem), radial-gradient(circle at 92% 7%, #fce7f3, transparent 31rem), linear-gradient(180deg, #fbf7ff, #ffffff);
}

:root[data-theme="vibrant"] {
    color-scheme: light;
    --site-bg: #fff7ed;
    --site-surface: rgba(255,255,255,.95);
    --site-surface-solid: #ffffff;
    --site-surface-soft: #fff7ed;
    --site-surface-muted: #ffedd5;
    --site-border: rgba(249,115,22,.32);
    --site-border-strong: rgba(37,99,235,.46);
    --site-text: #1f2937;
    --site-muted: #4b5563;
    --site-primary: #ea580c;
    --site-secondary: #2563eb;
    --site-accent: #a16207;
    --site-good: #15803d;
    --site-bad: #b91c1c;
    --site-primary-soft: #ffedd5;
    --site-shadow: 0 20px 54px rgba(234,88,12,.16);
    --site-shadow-soft: 0 8px 22px rgba(37,99,235,.10);
    --site-background: radial-gradient(circle at 8% 4%, #bfdbfe, transparent 31rem), radial-gradient(circle at 92% 7%, #fde68a, transparent 31rem), linear-gradient(180deg, #fff7ed, #ffffff);
}

:root[data-theme="pink"] {
    color-scheme: light;
    --site-bg: #fff5fa;
    --site-surface: rgba(255,255,255,.95);
    --site-surface-solid: #ffffff;
    --site-surface-soft: #fdf2f8;
    --site-surface-muted: #fce7f3;
    --site-border: rgba(219,39,119,.25);
    --site-border-strong: rgba(190,24,93,.48);
    --site-text: #3f1028;
    --site-muted: #7c4962;
    --site-primary: #db2777;
    --site-secondary: #9333ea;
    --site-accent: #9a3412;
    --site-good: #047857;
    --site-bad: #be123c;
    --site-primary-soft: #fce7f3;
    --site-shadow: 0 20px 54px rgba(219,39,119,.16);
    --site-shadow-soft: 0 8px 22px rgba(147,51,234,.10);
    --site-background: radial-gradient(circle at 8% 4%, #fce7f3, transparent 31rem), radial-gradient(circle at 92% 7%, #ede9fe, transparent 31rem), linear-gradient(180deg, #fff5fa, #ffffff);
}

:root[data-theme="pride"] {
    color-scheme: light;
    --site-bg: #f8fafc;
    --site-surface: rgba(255,255,255,.95);
    --site-surface-solid: #ffffff;
    --site-surface-soft: #f8fafc;
    --site-surface-muted: #eef2ff;
    --site-border: rgba(79,70,229,.28);
    --site-border-strong: rgba(147,51,234,.54);
    --site-text: #172033;
    --site-muted: #4b5563;
    --site-primary: #2563eb;
    --site-secondary: #9333ea;
    --site-accent: #a16207;
    --site-good: #15803d;
    --site-bad: #b91c1c;
    --site-primary-soft: #eef2ff;
    --site-shadow: 0 20px 56px rgba(79,70,229,.15);
    --site-shadow-soft: 0 8px 22px rgba(147,51,234,.10);
    --site-background: linear-gradient(118deg, rgba(239,68,68,.12), rgba(249,115,22,.10) 18%, rgba(234,179,8,.10) 35%, rgba(34,197,94,.10) 52%, rgba(59,130,246,.11) 70%, rgba(168,85,247,.12)), #f8fafc;
}

:root[data-theme="village"] {
    color-scheme: light;
    --site-bg: #f3f0dc;
    --site-surface: rgba(255,253,240,.96);
    --site-surface-solid: #fffdf0;
    --site-surface-soft: #edf3df;
    --site-surface-muted: #e1e7d2;
    --site-border: rgba(53,94,59,.20);
    --site-border-strong: rgba(82,125,67,.54);
    --site-text: #253620;
    --site-muted: #526349;
    --site-primary: #355e3b;
    --site-secondary: #527d43;
    --site-accent: #735200;
    --site-good: #315737;
    --site-bad: #8e3e33;
    --site-primary-soft: #edf3df;
    --site-shadow: 0 22px 58px rgba(51,74,40,.16);
    --site-shadow-soft: 0 8px 22px rgba(51,74,40,.10);
    --site-background: radial-gradient(circle at 9% 5%, rgba(120,163,93,.22), transparent 31rem), radial-gradient(circle at 92% 8%, rgba(199,154,47,.20), transparent 30rem), linear-gradient(180deg, #f3f0dc, #fffdf0);
}

:root[data-theme="pattaya"] {
    color-scheme: light;
    --site-bg: #eaf6f8;
    --site-surface: rgba(255,253,246,.96);
    --site-surface-solid: #fffdf6;
    --site-surface-soft: #edf8f8;
    --site-surface-muted: #dcecef;
    --site-border: rgba(34,91,118,.19);
    --site-border-strong: rgba(39,126,167,.52);
    --site-text: #173b4d;
    --site-muted: #466878;
    --site-primary: #225b76;
    --site-secondary: #469dcc;
    --site-accent: #785800;
    --site-good: #176b52;
    --site-bad: #9d382d;
    --site-primary-soft: #e7f7fb;
    --site-shadow: 0 22px 60px rgba(27,86,111,.16);
    --site-shadow-soft: 0 8px 22px rgba(27,86,111,.10);
    --site-background: radial-gradient(circle at 8% 5%, rgba(70,157,204,.23), transparent 31rem), radial-gradient(circle at 92% 8%, rgba(77,190,184,.20), transparent 30rem), radial-gradient(circle at 50% 100%, rgba(223,119,103,.12), transparent 28rem), linear-gradient(180deg, #eaf6f8, #fffdf6);
}

/* Audited foreground tokens. The decorative palette can stay bright, while
   text, links, status messages and action gradients use AA-safe shades. */
:root[data-theme="light"] {
    --site-readable-text: #0f172a;
    --site-readable-muted: #475569;
    --site-link-text: #1d4ed8;
    --site-button-start: #1d4ed8;
    --site-button-end: #6d28d9;
    --site-button-text: #ffffff;
    --site-good-text: #166534;
    --site-bad-text: #991b1b;
    --site-warning-text: #78350f;
}
:root,
:root[data-theme="dark"],
:root[data-theme="minimal_dark"] {
    --site-readable-text: #f1f5f9;
    --site-readable-muted: #cbd5e1;
    --site-link-text: #93c5fd;
    --site-button-start: #1d4ed8;
    --site-button-end: #6d28d9;
    --site-button-text: #ffffff;
    --site-good-text: #86efac;
    --site-bad-text: #fda4af;
    --site-warning-text: #fde68a;
}
:root[data-theme="modern"] {
    --site-readable-text: #0f172a;
    --site-readable-muted: #475569;
    --site-link-text: #3730a3;
    --site-button-start: #4338ca;
    --site-button-end: #0e7490;
    --site-button-text: #ffffff;
    --site-good-text: #065f46;
    --site-bad-text: #991b1b;
    --site-warning-text: #78350f;
}
:root[data-theme="minimal"] {
    --site-readable-text: #111827;
    --site-readable-muted: #475569;
    --site-link-text: #1d4ed8;
    --site-button-start: #1d4ed8;
    --site-button-end: #334155;
    --site-button-text: #ffffff;
    --site-good-text: #166534;
    --site-bad-text: #991b1b;
    --site-warning-text: #78350f;
}
:root[data-theme="neon"] {
    --site-readable-text: #f8fafc;
    --site-readable-muted: #dbeafe;
    --site-link-text: #67e8f9;
    --site-button-start: #0e7490;
    --site-button-end: #9d174d;
    --site-button-text: #ffffff;
    --site-good-text: #86efac;
    --site-bad-text: #fda4af;
    --site-warning-text: #fef08a;
}
:root[data-theme="genz"] {
    --site-readable-text: #24113d;
    --site-readable-muted: #5b456f;
    --site-link-text: #6d28d9;
    --site-button-start: #6d28d9;
    --site-button-end: #9d174d;
    --site-button-text: #ffffff;
    --site-good-text: #065f46;
    --site-bad-text: #9f1239;
    --site-warning-text: #78350f;
}
:root[data-theme="vibrant"] {
    --site-readable-text: #1f2937;
    --site-readable-muted: #4b5563;
    --site-link-text: #9a3412;
    --site-button-start: #c2410c;
    --site-button-end: #1d4ed8;
    --site-button-text: #ffffff;
    --site-good-text: #166534;
    --site-bad-text: #991b1b;
    --site-warning-text: #713f12;
}
:root[data-theme="pink"] {
    --site-readable-text: #401125;
    --site-readable-muted: #6b3d54;
    --site-link-text: #9d174d;
    --site-button-start: #be185d;
    --site-button-end: #831843;
    --site-button-text: #ffffff;
    --site-good-text: #065f46;
    --site-bad-text: #9f1239;
    --site-warning-text: #78350f;
}
:root[data-theme="pride"] {
    --site-readable-text: #111827;
    --site-readable-muted: #4b5563;
    --site-link-text: #6d28d9;
    --site-button-start: #6d28d9;
    --site-button-end: #9d174d;
    --site-button-text: #ffffff;
    --site-good-text: #166534;
    --site-bad-text: #991b1b;
    --site-warning-text: #78350f;
}
:root[data-theme="village"] {
    --site-readable-text: #253620;
    --site-readable-muted: #526349;
    --site-link-text: #315737;
    --site-button-start: #315737;
    --site-button-end: #3f662f;
    --site-button-text: #ffffff;
    --site-good-text: #315737;
    --site-bad-text: #8e3e33;
    --site-warning-text: #735200;
}
:root[data-theme="pattaya"] {
    --site-readable-text: #173b4d;
    --site-readable-muted: #466878;
    --site-link-text: #225b76;
    --site-button-start: #225b76;
    --site-button-end: #176f7d;
    --site-button-text: #ffffff;
    --site-good-text: #176b52;
    --site-bad-text: #9d382d;
    --site-warning-text: #785800;
}

/* Shared aliases used by non-default themes to remap the existing learning-module tokens. Minimal Dark intentionally leaves every module's original variables untouched. */
:root[data-theme]:not([data-theme="minimal_dark"]) {
    --bg: var(--site-bg);
    --page-bg: var(--site-bg);
    --panel: var(--site-surface);
    --panel2: var(--site-surface-soft);
    --panel-soft: var(--site-surface-soft);
    --surface: var(--site-surface);
    --surface-solid: var(--site-surface-solid);
    --surface-soft: var(--site-surface-soft);
    --surface-muted: var(--site-surface-muted);
    --card: var(--site-surface);
    --border: var(--site-border);
    --line: var(--site-border);
    --stroke: var(--site-border);
    --stroke-strong: var(--site-border-strong);
    --text: var(--site-text);
    --muted: var(--site-muted);
    --primary: var(--site-primary);
    --primary2: var(--site-secondary);
    --portal-accent: var(--site-primary);
    --portal-accent-2: var(--site-secondary);
    --primary-soft: var(--site-primary-soft);
    --cyan: var(--site-primary);
    --purple: var(--site-secondary);
    --yellow: var(--site-accent);
    --green: var(--site-good);
    --red: var(--site-bad);
    --good: var(--site-good);
    --bad: var(--site-bad);
    --shadow: var(--site-shadow);
    --shadow2: var(--site-shadow-soft);
}

:root[data-theme]:not([data-theme="minimal_dark"]) body {
    color: var(--site-text) !important;
    background: var(--site-background) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(h1,h2,h3,h4,h5,h6,strong,label) { color: var(--site-text); }
:root[data-theme]:not([data-theme="minimal_dark"]) :where(p,small,.source,.source-note,.form-help) { border-color: var(--site-border); }
:root[data-theme]:not([data-theme="minimal_dark"]) a { color: var(--site-link-text); }

/* Public homepage and protected resource portal surfaces. */
:root[data-theme]:not([data-theme="minimal_dark"]) :where(
    .hero,.access-card,.portal-hero,.resource-card,.portal-empty-state,
    .directory-hero,.token-admin-hero,.token-form-card,.token-output-card,
    .cr-published-resources,.cr-published-section,.cr-resource-folder,
    .cr-published-file,.security-note
) {
    color: var(--site-text) !important;
    background: var(--site-surface) !important;
    border-color: var(--site-border) !important;
    box-shadow: var(--site-shadow-soft);
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.portal-topbar,.topbar,.course-topbar) {
    color: var(--site-text) !important;
    background: color-mix(in srgb, var(--site-surface-solid) 92%, transparent) !important;
    border-color: var(--site-border) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(
    .viewer-chip,.viewer,.viewer-badge,.admin-badge,.count-chip,
    .course-topnav a,.course-back,.access-notes,.portal-link-card,
    .cr-published-count,.cr-resource-folder > summary
) {
    color: var(--site-muted) !important;
    background: var(--site-surface-soft) !important;
    border-color: var(--site-border) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.brand,.course-brand,.viewer-chip strong,.cr-published-heading h2,.cr-published-section h3,.cr-published-file-copy strong,.cr-resource-folder strong) {
    color: var(--site-text) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(
    .hero p,.portal-hero p,.portal-subtitle,.access-description,.resource-card p,
    .portal-empty-state p,.directory-hero p,.token-admin-hero p,.token-output-card p,
    .cr-published-heading p,.cr-published-section p,.cr-published-file-copy span,
    .cr-published-file-copy small,.security-note,.portal-link-card small
) { color: var(--site-muted) !important; }

:root[data-theme]:not([data-theme="minimal_dark"]) :where(input,select,textarea) {
    color: var(--site-text) !important;
    background: var(--site-surface-solid) !important;
    border-color: var(--site-border) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.portal-link-card,.card) {
    background: linear-gradient(145deg, color-mix(in srgb, var(--site-primary) 8%, var(--site-surface-soft)), var(--site-surface)) !important;
}

/* MEP 1 and MEP 3 self-guided learning modules. Minimal Dark matches the
   original module design; other themes map the same component hierarchy. */
:root[data-theme]:not([data-theme="minimal_dark"]) :where(
    .course-hero,.lesson-hero,.week-card,.content-card,.lesson-sidebar,
    .portal-feature,.stat-card,.term-card,.objective-list li,.practice-list li,
    .quiz-option,.project-card,.progress-row,.lesson-nav a,.glossary-entry,
    .terms article,.side.card,.question label,.progress-list label
) {
    color: var(--site-text) !important;
    background: var(--site-surface) !important;
    border-color: var(--site-border) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.course-hero,.lesson-hero,.portal-feature,.week-card) {
    background: linear-gradient(145deg, color-mix(in srgb, var(--site-primary) 9%, var(--site-surface-soft)), var(--site-surface)) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(
    .course-hero p,.lesson-hero p,.week-card p,.content-card p,.portal-feature p,
    .stat-card span,.term-card p,.lesson-sidebar a,.project-card ul,.progress-row .status
) { color: var(--site-muted) !important; }

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.lab,.lab-panel,.challenge,.challenge-box) {
    color: var(--site-text) !important;
    background: color-mix(in srgb, var(--site-secondary) 11%, var(--site-surface)) !important;
    border-color: var(--site-border-strong) !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.lab-output,.output-box,.code-shell,.code-shell pre,.lab-canvas) {
    color: color-mix(in srgb, var(--site-good) 85%, var(--site-text)) !important;
    background: color-mix(in srgb, var(--site-bg) 88%, #000) !important;
    border-color: var(--site-border) !important;
}

:root[data-theme] :where(
    .button:not(.secondary),
    .verification-form button,
    .token-form-card button,
    .token-output-heading button,
    .student-account-card .account-button:not(.secondary):not(.danger),
    .student-account-card .student-account-form button,
    .projector-picker-form button,
    .projector-resource-card button,
    .projector-button
) {
    color: var(--site-button-text) !important;
    background: linear-gradient(135deg, var(--site-button-start), var(--site-button-end)) !important;
    border-color: transparent !important;
}

:root[data-theme]:not([data-theme="minimal_dark"]) :where(.button.secondary,.course-home-link) {
    color: var(--site-text) !important;
    background: var(--site-surface-soft) !important;
    border-color: var(--site-border) !important;
}

:root[data-theme] :where(.notice,.status-success,.feedback.correct) {
    color: var(--site-good-text) !important;
    background: color-mix(in srgb, var(--site-good-text) 11%, var(--site-surface)) !important;
    border-color: color-mix(in srgb, var(--site-good-text) 38%, var(--site-border)) !important;
}
:root[data-theme] :where(.alert,.status-error,.feedback.wrong) {
    color: var(--site-bad-text) !important;
    background: color-mix(in srgb, var(--site-bad-text) 11%, var(--site-surface)) !important;
    border-color: color-mix(in srgb, var(--site-bad-text) 38%, var(--site-border)) !important;
}
:root[data-theme] :where(.security-note,.shared-access-help,.alert-banner) {
    color: var(--site-warning-text) !important;
}

/* Tailwind-based MEP 2 learning labs. These adapters intentionally target only
   visual utility classes and do not alter layout, animation, or game logic. */
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.bg-slate-950,.bg-slate-950\/80) { background-color: var(--site-bg) !important; }
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.bg-slate-900,.bg-slate-900\/80,.bg-slate-900\/90) { background-color: var(--site-surface) !important; }
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.bg-slate-800,.bg-slate-800\/80) { background-color: var(--site-surface-soft) !important; }
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.bg-white) { background-color: var(--site-surface-solid) !important; }
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.text-white,.text-slate-100,.text-slate-200) { color: var(--site-text) !important; }
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.text-slate-300,.text-slate-400,.text-slate-500,.text-slate-600) { color: var(--site-muted) !important; }
:root[data-theme]:not([data-theme="minimal_dark"]) body :where(.border-slate-900,.border-slate-800,.border-slate-700,.border-slate-200) { border-color: var(--site-border) !important; }

/* Unified copyright line. */
.site-copyright,
.portal-footer,
body > footer {
    margin: 0;
    padding: 24px 18px;
    color: var(--site-muted) !important;
    background: color-mix(in srgb, var(--site-surface-solid) 74%, transparent) !important;
    border-top: 1px solid var(--site-border) !important;
    text-align: center;
    font-size: .84rem;
    font-weight: 650;
}

/* Exact switcher structure is created by the unchanged main-portal script. */
.theme-switcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 900;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.theme-toggle {
    position: static !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    border: 1px solid var(--site-border) !important;
    border-radius: 999px !important;
    padding: 10px 14px !important;
    background: var(--site-surface-solid) !important;
    color: var(--site-text) !important;
    box-shadow: var(--site-shadow-soft) !important;
    font: 800 .88rem Inter, ui-sans-serif, system-ui, sans-serif !important;
    cursor: pointer;
    user-select: none;
}
.theme-toggle:hover { border-color: var(--site-primary) !important; color: var(--site-primary) !important; }
.theme-toggle__icon,.theme-toggle__chevron { line-height: 1; }
.theme-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: min(330px, calc(100vw - 26px));
    max-height: min(620px, calc(100vh - 92px));
    overflow: auto;
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    color: var(--site-text);
    background: var(--site-surface-solid);
    border: 1px solid var(--site-border);
    border-radius: 20px;
    box-shadow: var(--site-shadow);
    backdrop-filter: blur(18px);
}
.theme-menu.open { display: grid; }
.theme-choice {
    width: 100%;
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--site-border);
    border-radius: 15px;
    padding: 9px;
    background: var(--site-surface-soft);
    color: var(--site-text);
    text-align: left;
    cursor: pointer;
}
.theme-choice:hover,.theme-choice.active { border-color: var(--site-primary); background: var(--site-primary-soft); }
.theme-choice__swatch { width: 30px; height: 30px; border-radius: 11px; border: 1px solid rgba(255,255,255,.42); box-shadow: inset 0 0 0 1px rgba(15,23,42,.08); }
.theme-choice__content { display: grid; gap: 1px; }
.theme-choice__content strong { color: var(--site-text) !important; font-size: .92rem; }
.theme-choice__content small { color: var(--site-muted) !important; font-size: .74rem; }
.theme-choice--light .theme-choice__swatch { background: linear-gradient(135deg,#dbeafe,#fff7ed); }
.theme-choice--dark .theme-choice__swatch { background: linear-gradient(135deg,#0b1120,#1e293b); }
.theme-choice--minimal-dark .theme-choice__swatch { background: linear-gradient(135deg,#07111f,#38bdf8,#8b5cf6); }
.theme-choice--modern .theme-choice__swatch { background: linear-gradient(135deg,#f8fafc,#4f46e5); }
.theme-choice--minimal .theme-choice__swatch { background: linear-gradient(135deg,#ffffff,#cbd5e1); }
.theme-choice--neon .theme-choice__swatch { background: linear-gradient(135deg,#070314,#22d3ee,#ec4899); }
.theme-choice--genz .theme-choice__swatch { background: linear-gradient(135deg,#cffafe,#fce7f3,#8b5cf6); }
.theme-choice--vibrant .theme-choice__swatch { background: linear-gradient(135deg,#bfdbfe,#fde68a,#f97316); }
.theme-choice--pink .theme-choice__swatch { background: linear-gradient(135deg,#fff5fa,#f472b6,#be185d); }
.theme-choice--pride .theme-choice__swatch { background: linear-gradient(90deg,#ef4444,#f97316,#eab308,#22c55e,#3b82f6,#a855f7); }
.theme-choice--village .theme-choice__swatch { background: linear-gradient(135deg,#fffdf0,#78a35d,#c79a2f); }
.theme-choice--pattaya .theme-choice__swatch { background: linear-gradient(135deg,#fffdf6,#469dcc,#4dbeb8,#df7767); }

@media (max-width: 620px) {
    .theme-switcher { right: 12px; bottom: 12px; }
    .theme-toggle { padding: 9px 11px !important; }
    .theme-toggle__label { max-width: 112px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .theme-menu { width: min(310px, calc(100vw - 22px)); }
    .site-copyright,.portal-footer,body > footer { padding-bottom: 74px; }
}

@media print {
    .theme-switcher { display: none !important; }
    .site-copyright,.portal-footer,body > footer { color: #000 !important; background: #fff !important; border-color: #aaa !important; }
}

/* Verified-access bar injected into protected static MEP 2 pages. */
.cr-verified-access-bar {
    position: relative;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 16px;
    color: var(--site-text);
    background: var(--site-surface-solid);
    border-bottom: 1px solid var(--site-border);
    font: 650 13px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}
.cr-verified-access-bar strong { color: var(--site-text); }
.cr-verified-access-detail { color: var(--site-muted); }
.cr-verified-access-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cr-verified-access-bar a { color: var(--site-primary); font-weight: 750; text-decoration: none; }
.cr-verified-access-bar a:hover { text-decoration: underline; }
.cr-verified-access-bar a.cr-verified-access-signout { color: var(--site-bad); }

/* V248: prominent MEP 2 account access and first-password guidance. */
.cr-verified-access-identity {
    min-width: 0;
}
.cr-verified-access-bar a.cr-account-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 13px;
    border: 1px solid color-mix(in srgb, var(--site-primary) 55%, var(--site-border));
    border-radius: 999px;
    color: var(--site-text);
    background: linear-gradient(135deg, var(--site-primary-soft), var(--site-surface-soft));
    box-shadow: 0 8px 24px color-mix(in srgb, var(--site-primary) 16%, transparent);
    text-decoration: none;
}
.cr-verified-access-bar a.cr-account-primary:hover {
    border-color: var(--site-primary);
    text-decoration: none;
    transform: translateY(-1px);
}
.cr-account-primary small {
    color: var(--site-muted);
    font-size: 11px;
    font-weight: 750;
}
.cr-first-password-prompt {
    position: relative;
    z-index: 79;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    width: min(1180px, calc(100% - 28px));
    margin: 14px auto;
    padding: 16px 18px;
    border: 1px solid color-mix(in srgb, var(--site-primary) 52%, var(--site-border));
    border-radius: 20px;
    color: var(--site-text);
    background: linear-gradient(135deg, color-mix(in srgb, var(--site-primary) 14%, var(--site-surface-solid)), var(--site-surface-solid));
    box-shadow: 0 16px 40px rgba(2, 6, 23, .22);
    font: 650 14px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
}
.cr-first-password-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 15px;
    background: var(--site-primary-soft);
    font-size: 24px;
}
.cr-first-password-copy {
    min-width: 0;
}
.cr-first-password-copy strong {
    display: block;
    margin-bottom: 3px;
    color: var(--site-text);
    font-size: 16px;
}
.cr-first-password-copy p {
    margin: 3px 0 0;
    color: var(--site-muted);
}
.cr-first-password-copy p[lang="th"] {
    color: color-mix(in srgb, var(--site-text) 82%, var(--site-muted));
}
.cr-first-password-action {
    display: inline-grid;
    justify-items: center;
    gap: 1px;
    min-width: 190px;
    padding: 11px 15px;
    border: 1px solid color-mix(in srgb, var(--site-primary) 72%, white);
    border-radius: 14px;
    color: #fff !important;
    background: linear-gradient(135deg, var(--site-primary), var(--site-accent, var(--site-primary)));
    font-weight: 850 !important;
    text-align: center;
    text-decoration: none !important;
}
.cr-first-password-action:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}
.cr-first-password-action small {
    color: rgba(255,255,255,.86);
    font-size: 11px;
}

@media (max-width: 760px) {
    .cr-verified-access-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        gap: 9px;
        padding: 10px 12px;
    }
    .cr-verified-access-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 8px;
    }
    .cr-verified-access-actions > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 38px;
        padding: 7px 8px;
        border: 1px solid var(--site-border);
        border-radius: 11px;
        background: var(--site-surface-soft);
        text-align: center;
    }
    .cr-verified-access-actions > a.cr-account-primary {
        grid-column: 1 / -1;
        min-height: 46px;
        border-radius: 13px;
        font-size: 15px;
    }
    .cr-first-password-prompt {
        grid-template-columns: auto minmax(0, 1fr);
        width: min(100% - 20px, 680px);
        margin: 10px auto;
        padding: 14px;
    }
    .cr-first-password-action {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
    }
}

@media (max-width: 430px) {
    .cr-verified-access-actions {
        grid-template-columns: 1fr;
    }
    .cr-verified-access-actions > a.cr-account-primary {
        grid-column: auto;
    }
    .cr-first-password-prompt {
        grid-template-columns: 1fr;
    }
    .cr-first-password-icon {
        width: 40px;
        height: 40px;
    }
}

