/* Public site (index, login, signup, etc.) — always light */
:root {
  color-scheme: light;
  --page-bg: #ffffff;
  --section-alt: #f6f6f6;
  --surface: #f3f3f3;
  --border: #e8e8e8;
  --heading: #000000;
  --body-text: #242424;
  --muted: #5c5c5c;
  --accent: #000000;
  --accent-hover: #282828;
  --on-accent: #ffffff;
  --error: #c0392b;
  --success: #067a4f;
  --focus-ring: rgba(0, 0, 0, 0.12);
}

/* Never inherit portal themes on marketing/auth pages */
html[data-theme],
html[data-theme] body:not(.portal-page) {
  color-scheme: light;
}

html body:not(.portal-page) {
  color-scheme: light;
  --page-bg: #ffffff;
  --section-alt: #f6f6f6;
  --surface: #f3f3f3;
  --border: #e8e8e8;
  --heading: #000000;
  --body-text: #242424;
  --muted: #5c5c5c;
  --accent: #000000;
  --accent-hover: #282828;
  --on-accent: #ffffff;
  --error: #c0392b;
  --success: #067a4f;
  --focus-ring: rgba(0, 0, 0, 0.12);
}

/* Signed-in portal only */
body.portal-page {
  color-scheme: light;
  --page-bg: #ffffff;
  --section-alt: #f6f6f6;
  --surface: #f3f3f3;
  --border: #e8e8e8;
  --heading: #000000;
  --body-text: #242424;
  --muted: #5c5c5c;
  --accent: #000000;
  --accent-hover: #282828;
  --on-accent: #ffffff;
  --error: #c0392b;
  --success: #067a4f;
  --focus-ring: rgba(0, 0, 0, 0.12);
  --sidebar-bg: #000000;
  --sidebar-text: rgba(255, 255, 255, 0.72);
  --sidebar-text-muted: rgba(255, 255, 255, 0.5);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.25);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
}

body.portal-page[data-theme="light"] {
  color-scheme: light;
}

body.portal-page[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #121212;
  --section-alt: #1a1a1a;
  --surface: #242424;
  --border: #3a3a3a;
  --heading: #f5f5f5;
  --body-text: #e0e0e0;
  --muted: #a8a8a8;
  --accent: #f5f5f5;
  --accent-hover: #ffffff;
  --on-accent: #121212;
  --error: #ff6b6b;
  --success: #4ade80;
  --focus-ring: rgba(255, 255, 255, 0.18);
  --sidebar-bg: #000000;
  --sidebar-text: rgba(255, 255, 255, 0.72);
  --sidebar-text-muted: rgba(255, 255, 255, 0.5);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255, 255, 255, 0.25);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
}

body.portal-page[data-theme="midnight"] {
  color-scheme: dark;
  --page-bg: #0f172a;
  --section-alt: #1e293b;
  --surface: #334155;
  --border: #475569;
  --heading: #f1f5f9;
  --body-text: #cbd5e1;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --on-accent: #0f172a;
  --error: #f87171;
  --success: #4ade80;
  --focus-ring: rgba(56, 189, 248, 0.35);
  --sidebar-bg: #020617;
  --sidebar-text: rgba(226, 232, 240, 0.78);
  --sidebar-text-muted: rgba(148, 163, 184, 0.85);
  --sidebar-text-active: #f8fafc;
  --sidebar-border: rgba(148, 163, 184, 0.35);
  --sidebar-hover: rgba(56, 189, 248, 0.15);
}

body.portal-page[data-theme="high-contrast"] {
  color-scheme: dark;
  --page-bg: #000000;
  --section-alt: #000000;
  --surface: #111111;
  --border: #ffffff;
  --heading: #ffffff;
  --body-text: #ffffff;
  --muted: #e8e8e8;
  --accent: #ffff00;
  --accent-hover: #ffff66;
  --on-accent: #000000;
  --error: #ff4444;
  --success: #00ff88;
  --focus-ring: rgba(255, 255, 0, 0.45);
  --sidebar-bg: #000000;
  --sidebar-text: #ffffff;
  --sidebar-text-muted: #e8e8e8;
  --sidebar-text-active: #ffff00;
  --sidebar-border: #ffffff;
  --sidebar-hover: rgba(255, 255, 0, 0.2);
}

body.portal-page[data-theme="sepia"] {
  color-scheme: light;
  --page-bg: #f4ecd8;
  --section-alt: #ebe0c8;
  --surface: #e2d4b8;
  --border: #c9b896;
  --heading: #3d2f1f;
  --body-text: #4a3c2a;
  --muted: #6b5a42;
  --accent: #6b4423;
  --accent-hover: #543619;
  --on-accent: #fff8ef;
  --error: #a93226;
  --success: #1e6f43;
  --focus-ring: rgba(107, 68, 35, 0.25);
  --sidebar-bg: #3d2f1f;
  --sidebar-text: rgba(255, 248, 239, 0.78);
  --sidebar-text-muted: rgba(255, 248, 239, 0.55);
  --sidebar-text-active: #fff8ef;
  --sidebar-border: rgba(255, 248, 239, 0.28);
  --sidebar-hover: rgba(255, 248, 239, 0.12);
}

body.portal-page[data-theme="ocean"] {
  color-scheme: light;
  --page-bg: #f0f7fa;
  --section-alt: #e3f2f8;
  --surface: #d6ebf5;
  --border: #b8d9ea;
  --heading: #023047;
  --body-text: #1a4a63;
  --muted: #4a7188;
  --accent: #0077b6;
  --accent-hover: #005f91;
  --on-accent: #ffffff;
  --error: #c0392b;
  --success: #067a4f;
  --focus-ring: rgba(0, 119, 182, 0.22);
  --sidebar-bg: #023047;
  --sidebar-text: rgba(230, 245, 252, 0.78);
  --sidebar-text-muted: rgba(184, 217, 234, 0.75);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(184, 217, 234, 0.35);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
}

body.portal-page[data-theme="forest"] {
  color-scheme: light;
  --page-bg: #f1f8f4;
  --section-alt: #e3f0e8;
  --surface: #d4e8dc;
  --border: #b7d4c4;
  --heading: #1b4332;
  --body-text: #2d4a3e;
  --muted: #4f6f5e;
  --accent: #2d6a4f;
  --accent-hover: #24543f;
  --on-accent: #ffffff;
  --error: #c0392b;
  --success: #067a4f;
  --focus-ring: rgba(45, 106, 79, 0.22);
  --sidebar-bg: #1b4332;
  --sidebar-text: rgba(232, 245, 237, 0.78);
  --sidebar-text-muted: rgba(183, 212, 196, 0.75);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(183, 212, 196, 0.35);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
}

body.portal-page[data-theme="rose"] {
  color-scheme: light;
  --page-bg: #fdf2f4;
  --section-alt: #fce7ec;
  --surface: #f9d5de;
  --border: #f0b8c8;
  --heading: #500724;
  --body-text: #6b2140;
  --muted: #9d4566;
  --accent: #9d174d;
  --accent-hover: #831843;
  --on-accent: #ffffff;
  --error: #be123c;
  --success: #067a4f;
  --focus-ring: rgba(157, 23, 77, 0.22);
  --sidebar-bg: #500724;
  --sidebar-text: rgba(253, 242, 244, 0.78);
  --sidebar-text-muted: rgba(240, 184, 200, 0.75);
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(240, 184, 200, 0.35);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
}

body.portal-page[data-theme="slate"] {
  color-scheme: dark;
  --page-bg: #18181b;
  --section-alt: #27272a;
  --surface: #3f3f46;
  --border: #52525b;
  --heading: #fafafa;
  --body-text: #d4d4d8;
  --muted: #a1a1aa;
  --accent: #a1a1aa;
  --accent-hover: #d4d4d8;
  --on-accent: #18181b;
  --error: #f87171;
  --success: #4ade80;
  --focus-ring: rgba(212, 212, 216, 0.25);
  --sidebar-bg: #09090b;
  --sidebar-text: rgba(250, 250, 250, 0.75);
  --sidebar-text-muted: rgba(161, 161, 170, 0.85);
  --sidebar-text-active: #fafafa;
  --sidebar-border: rgba(161, 161, 170, 0.35);
  --sidebar-hover: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
  body.portal-page:not([data-theme]) {
    color-scheme: dark;
    --page-bg: #121212;
    --section-alt: #1a1a1a;
    --surface: #242424;
    --border: #3a3a3a;
    --heading: #f5f5f5;
    --body-text: #e0e0e0;
    --muted: #a8a8a8;
    --accent: #f5f5f5;
    --accent-hover: #ffffff;
    --on-accent: #121212;
    --error: #ff6b6b;
    --success: #4ade80;
    --focus-ring: rgba(255, 255, 255, 0.18);
    --sidebar-bg: #000000;
    --sidebar-text: rgba(255, 255, 255, 0.72);
    --sidebar-text-muted: rgba(255, 255, 255, 0.5);
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.25);
    --sidebar-hover: rgba(255, 255, 255, 0.12);
  }
}
