:root {
  --bg: #050409;
  --bg-sidebar: rgba(8, 7, 14, 0.95);
  --bg-solid: #0b0a12;
  --card: rgba(15, 13, 22, 0.75);
  --border: rgba(226, 184, 83, 0.15);
  --border-glow: rgba(226, 184, 83, 0.35);
  --purple: #8b5cf6;
  --pink: #ec4899;
  --gold: #e2b853;
  --green: #10b981;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --glow: 0 0 25px rgba(226, 184, 83, 0.15);
  --glow-pink: 0 0 25px rgba(236, 72, 153, 0.15);
  --blur: blur(25px);
  --radius: 20px;
  --font: 'Inter Tight', sans-serif;
  --header-height: 70px;

  /* Asset and backdrop defaults shared by portal themes. */
  --theme-bg-image: none;
  --top-bg-image: none;
  --hero-overlay-start: rgba(5, 4, 9, 0.4);
  --hero-overlay-end: rgba(5, 4, 9, 0.88);
  --body-orb-warm: rgba(226, 184, 83, 0.06);
  --body-orb-primary: rgba(139, 92, 246, 0.07);
  --body-orb-secondary: rgba(236, 72, 153, 0.02);
}

/* Forest */
body.theme-forest {
  --bg: #040d06;
  --bg-sidebar: rgba(4, 15, 8, 0.95);
  --bg-solid: #051408;
  --card: rgba(8, 25, 13, 0.82);
  --border: rgba(52, 211, 153, 0.22);
  --border-glow: rgba(52, 211, 153, 0.52);
  --purple: #059669;
  --pink: #34d399;
  --gold: #6ee7b7;
  --green: #6ee7b7;
  --text: #ecfdf5;
  --muted: #a7c4b2;
  --glow: 0 0 25px rgba(52, 211, 153, 0.2);
  --glow-pink: 0 0 25px rgba(16, 185, 129, 0.18);
  --body-orb-warm: rgba(110, 231, 183, 0.07);
  --body-orb-primary: rgba(5, 150, 105, 0.1);
  --body-orb-secondary: rgba(52, 211, 153, 0.04);
}

/* Sunset */
body.theme-sunset {
  --bg: #120603;
  --bg-sidebar: rgba(20, 6, 3, 0.95);
  --bg-solid: #150804;
  --card: rgba(30, 12, 5, 0.82);
  --border: rgba(249, 115, 22, 0.22);
  --border-glow: rgba(249, 115, 22, 0.52);
  --purple: #ea580c;
  --pink: #fb7185;
  --gold: #f59e0b;
  --green: #bef264;
  --text: #fff7ed;
  --muted: #d4a990;
  --glow: 0 0 25px rgba(249, 115, 22, 0.22);
  --glow-pink: 0 0 25px rgba(251, 113, 133, 0.18);
  --body-orb-warm: rgba(245, 158, 11, 0.08);
  --body-orb-primary: rgba(234, 88, 12, 0.11);
  --body-orb-secondary: rgba(251, 113, 133, 0.04);
}

/* Editorial */
body.theme-editorial {
  --bg: #0c050a;
  --bg-sidebar: rgba(16, 6, 13, 0.96);
  --bg-solid: #11050d;
  --card: rgba(26, 11, 21, 0.82);
  --border: rgba(225, 29, 72, 0.24);
  --border-glow: rgba(225, 29, 72, 0.56);
  --purple: #e11d48;
  --pink: #fda4af;
  --gold: #fbbf24;
  --green: #86efac;
  --text: #fff1f2;
  --muted: #d7a8b5;
  --glow: 0 0 25px rgba(225, 29, 72, 0.25);
  --glow-pink: 0 0 25px rgba(253, 164, 175, 0.18);
  --body-orb-warm: rgba(251, 191, 36, 0.06);
  --body-orb-primary: rgba(225, 29, 72, 0.11);
  --body-orb-secondary: rgba(253, 164, 175, 0.04);
}

/* Academic light */
body.theme-light {
  --bg: #f8f7fc;
  --bg-sidebar: rgba(248, 247, 252, 0.97);
  --bg-solid: #f0eefa;
  --card: rgba(255, 255, 255, 0.96);
  --border: rgba(99, 91, 171, 0.2);
  --border-glow: rgba(99, 91, 171, 0.42);
  --purple: #5b4fcf;
  --pink: #9333ea;
  --gold: #b45309;
  --green: #15803d;
  --text: #1e1b3a;
  --muted: #596273;
  --glow: 0 0 20px rgba(91, 79, 207, 0.1);
  --glow-pink: 0 0 20px rgba(147, 51, 234, 0.1);
  --body-orb-warm: rgba(180, 83, 9, 0.05);
  --body-orb-primary: rgba(91, 79, 207, 0.08);
  --body-orb-secondary: rgba(147, 51, 234, 0.035);
  color-scheme: light;
}

/* Academic dark */
body.theme-dark {
  --bg: #0d0d12;
  --bg-sidebar: rgba(13, 13, 18, 0.97);
  --bg-solid: #111118;
  --card: rgba(20, 20, 28, 0.88);
  --border: rgba(148, 163, 184, 0.14);
  --border-glow: rgba(148, 163, 184, 0.32);
  --purple: #818cf8;
  --pink: #a78bfa;
  --gold: #cbd5e1;
  --green: #4ade80;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --glow: 0 0 20px rgba(129, 140, 248, 0.08);
  --glow-pink: 0 0 20px rgba(167, 139, 250, 0.08);
  --body-orb-warm: rgba(203, 213, 225, 0.035);
  --body-orb-primary: rgba(129, 140, 248, 0.08);
  --body-orb-secondary: rgba(167, 139, 250, 0.035);
}

/* Sand and gold */
body.theme-sand-gold {
  --bg: #f4efea;
  --bg-sidebar: rgba(244, 239, 234, 0.96);
  --bg-solid: #eae3dc;
  --card: rgba(255, 255, 255, 0.9);
  --border: rgba(180, 137, 28, 0.26);
  --border-glow: rgba(180, 137, 28, 0.48);
  --purple: #92731f;
  --pink: #b78c2f;
  --gold: #9a7418;
  --green: #557a46;
  --text: #3d312a;
  --muted: #66584f;
  --glow: 0 0 20px rgba(180, 137, 28, 0.15);
  --glow-pink: 0 0 20px rgba(183, 140, 47, 0.13);
  --body-orb-warm: rgba(154, 116, 24, 0.08);
  --body-orb-primary: rgba(146, 115, 31, 0.06);
  --body-orb-secondary: rgba(183, 140, 47, 0.035);
  color-scheme: light;
}

/* Astral mint */
body.theme-astral-mint {
  --bg: #0b1915;
  --bg-sidebar: rgba(11, 25, 21, 0.95);
  --bg-solid: #0f241e;
  --card: rgba(15, 35, 30, 0.82);
  --border: rgba(0, 255, 204, 0.22);
  --border-glow: rgba(0, 255, 204, 0.52);
  --purple: #00cc99;
  --pink: #5eead4;
  --gold: #2dd4bf;
  --green: #34d399;
  --text: #f0fdfa;
  --muted: #9ab8b3;
  --glow: 0 0 25px rgba(0, 255, 204, 0.25);
  --glow-pink: 0 0 25px rgba(45, 212, 191, 0.18);
  --body-orb-warm: rgba(45, 212, 191, 0.06);
  --body-orb-primary: rgba(0, 204, 153, 0.1);
  --body-orb-secondary: rgba(94, 234, 212, 0.035);
}

/* Stellar midnight */
body.theme-stellar-midnight {
  --bg: #050b14;
  --bg-sidebar: rgba(8, 17, 30, 0.95);
  --bg-solid: #091220;
  --card: rgba(10, 22, 40, 0.82);
  --border: rgba(197, 168, 128, 0.22);
  --border-glow: rgba(197, 168, 128, 0.52);
  --purple: #9a7b56;
  --pink: #d4af37;
  --gold: #c5a880;
  --green: #4ade80;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --glow: 0 0 25px rgba(197, 168, 128, 0.2);
  --glow-pink: 0 0 25px rgba(212, 175, 55, 0.14);
  --body-orb-warm: rgba(197, 168, 128, 0.06);
  --body-orb-primary: rgba(86, 118, 154, 0.08);
  --body-orb-secondary: rgba(212, 175, 55, 0.025);
}
body.theme-stellar-midnight {
  background-image:
    radial-gradient(circle at 10% 90%, var(--body-orb-warm) 0%, transparent 45%),
    radial-gradient(circle at 90% 10%, var(--body-orb-primary) 0%, transparent 50%),
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 40px 70px, #fff, transparent),
    radial-gradient(2px 2px at 150px 80px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 80px 120px, #fff, transparent),
    radial-gradient(1px 1px at 110px 220px, #fff, transparent);
  background-repeat: repeat;
  background-size: 300px 300px;
}

/* Mystic sakura */
body.theme-mystic-sakura {
  --bg: #fff0f5;
  --bg-sidebar: rgba(255, 240, 245, 0.96);
  --bg-solid: #fad0dd;
  --card: rgba(255, 255, 255, 0.94);
  --border: rgba(208, 59, 124, 0.24);
  --border-glow: rgba(208, 59, 124, 0.48);
  --purple: #a92f68;
  --pink: #d03b7c;
  --gold: #b52f6c;
  --green: #507a5e;
  --text: #3a1f42;
  --muted: #755b7b;
  --glow: 0 0 20px rgba(208, 59, 124, 0.18);
  --glow-pink: 0 0 20px rgba(208, 59, 124, 0.14);
  --body-orb-warm: rgba(181, 47, 108, 0.06);
  --body-orb-primary: rgba(169, 47, 104, 0.075);
  --body-orb-secondary: rgba(208, 59, 124, 0.035);
  color-scheme: light;
}

/* Shadow ritual */
body.theme-shadow-ritual {
  --bg: #0a0a0a;
  --bg-sidebar: rgba(10, 10, 10, 0.97);
  --bg-solid: #151515;
  --card: rgba(18, 18, 18, 0.88);
  --border: rgba(255, 0, 51, 0.18);
  --border-glow: rgba(255, 0, 51, 0.48);
  --purple: #b30022;
  --pink: #ff335c;
  --gold: #fb7185;
  --green: #4ade80;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --glow: 0 0 25px rgba(255, 0, 51, 0.24);
  --glow-pink: 0 0 25px rgba(255, 51, 92, 0.17);
  --body-orb-warm: rgba(251, 113, 133, 0.045);
  --body-orb-primary: rgba(179, 0, 34, 0.1);
  --body-orb-secondary: rgba(255, 51, 92, 0.035);
}

/* Showtime natal */
body.theme-showtime-natal {
  --bg: #120e2e;
  --bg-sidebar: rgba(18, 14, 46, 0.95);
  --bg-solid: #1b1545;
  --card: rgba(25, 20, 65, 0.84);
  --border: rgba(255, 242, 0, 0.26);
  --border-glow: rgba(255, 242, 0, 0.52);
  --purple: #8a2be2;
  --pink: #ff4dff;
  --gold: #fff200;
  --green: #5ee85e;
  --text: #ffffff;
  --muted: #b8afe0;
  --glow: 0 0 25px rgba(255, 242, 0, 0.3);
  --glow-pink: 0 0 25px rgba(255, 77, 255, 0.18);
  --body-orb-warm: rgba(255, 242, 0, 0.055);
  --body-orb-primary: rgba(138, 43, 226, 0.1);
  --body-orb-secondary: rgba(255, 77, 255, 0.035);
}

/* Shamanic earth */
body.theme-shamanic-earth {
  --bg: #1a1412;
  --bg-sidebar: rgba(26, 20, 18, 0.96);
  --bg-solid: #261d1a;
  --card: rgba(32, 25, 22, 0.88);
  --border: rgba(255, 111, 36, 0.24);
  --border-glow: rgba(255, 111, 36, 0.52);
  --purple: #d35400;
  --pink: #ff6f24;
  --gold: #e5ddcb;
  --green: #86b86b;
  --text: #f2ead9;
  --muted: #b2a69a;
  --glow: 0 0 25px rgba(255, 111, 36, 0.22);
  --glow-pink: 0 0 25px rgba(255, 111, 36, 0.16);
  --body-orb-warm: rgba(229, 221, 203, 0.045);
  --body-orb-primary: rgba(211, 84, 0, 0.1);
  --body-orb-secondary: rgba(255, 111, 36, 0.035);
}

/* Strict astrological dark */
body.theme-strict-astro-dark {
  --bg: #09090b;
  --bg-sidebar: rgba(9, 9, 11, 0.98);
  --bg-solid: #121215;
  --card: rgba(20, 20, 23, 0.92);
  --border: rgba(197, 168, 128, 0.16);
  --border-glow: rgba(197, 168, 128, 0.34);
  --purple: #8e8e93;
  --pink: #c5a880;
  --gold: #c5a880;
  --green: #4ade80;
  --text: #e4e4e7;
  --muted: #a1a1aa;
  --glow: 0 0 20px rgba(197, 168, 128, 0.08);
  --glow-pink: 0 0 20px rgba(197, 168, 128, 0.08);
  --body-orb-warm: rgba(197, 168, 128, 0.04);
  --body-orb-primary: rgba(142, 142, 147, 0.045);
  --body-orb-secondary: rgba(197, 168, 128, 0.02);
}

/* Strict astrological light */
body.theme-strict-astro-light {
  --bg: #f4f4f5;
  --bg-sidebar: rgba(244, 244, 245, 0.98);
  --bg-solid: #e4e4e7;
  --card: rgba(255, 255, 255, 0.96);
  --border: rgba(142, 142, 147, 0.22);
  --border-glow: rgba(181, 148, 104, 0.42);
  --purple: #71717a;
  --pink: #a88456;
  --gold: #8b6841;
  --green: #2e7d32;
  --text: #18181b;
  --muted: #52525b;
  --glow: 0 0 20px rgba(181, 148, 104, 0.08);
  --glow-pink: 0 0 20px rgba(181, 148, 104, 0.08);
  --body-orb-warm: rgba(139, 104, 65, 0.045);
  --body-orb-primary: rgba(113, 113, 122, 0.045);
  --body-orb-secondary: rgba(168, 132, 86, 0.02);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  /* Resolve aliases here, after body.theme-* has supplied its primitives. */
  --surface-page: var(--bg);
  --surface-sidebar: var(--bg-sidebar);
  --surface-card: var(--card);
  --surface-control: var(--bg-solid);
  --text-primary: var(--text);
  --text-secondary: var(--muted);
  --accent-primary: var(--purple);
  --accent-secondary: var(--pink);
  --accent-warm: var(--gold);
  --status-positive: var(--green);
  --focus-ring: var(--border-glow);
  --header-bg: var(--bg-sidebar);
  --card-border: var(--border);
  --theme-btn-shadow: var(--glow);

  font-family: var(--font);
  background: var(--surface-page);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    var(--theme-bg-image),
    radial-gradient(circle at 10% 90%, var(--body-orb-warm) 0%, transparent 45%),
    radial-gradient(circle at 90% 10%, var(--body-orb-primary) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--body-orb-secondary) 0%, transparent 60%);
  background-attachment: fixed;
  transition: background 0.5s ease, color 0.5s ease;
}

/* Non-base themes share structure but retain their own semantic values. */
body:is(
  .theme-forest,
  .theme-sunset,
  .theme-editorial,
  .theme-light,
  .theme-dark,
  .theme-sand-gold,
  .theme-astral-mint,
  .theme-stellar-midnight,
  .theme-mystic-sakura,
  .theme-shadow-ritual,
  .theme-showtime-natal,
  .theme-shamanic-earth,
  .theme-strict-astro-dark,
  .theme-strict-astro-light,
  .theme-server-skin
) {
  background-color: var(--surface-page);
  color: var(--text-primary);
}

body:is(
  .theme-forest,
  .theme-sunset,
  .theme-editorial,
  .theme-light,
  .theme-dark,
  .theme-sand-gold,
  .theme-astral-mint,
  .theme-stellar-midnight,
  .theme-mystic-sakura,
  .theme-shadow-ritual,
  .theme-showtime-natal,
  .theme-shamanic-earth,
  .theme-strict-astro-dark,
  .theme-strict-astro-light,
  .theme-server-skin
) .portal-global-header {
  background: var(--header-bg);
  border-bottom-color: var(--card-border);
}

body:is(
  .theme-forest,
  .theme-sunset,
  .theme-editorial,
  .theme-light,
  .theme-dark,
  .theme-sand-gold,
  .theme-astral-mint,
  .theme-stellar-midnight,
  .theme-mystic-sakura,
  .theme-shadow-ritual,
  .theme-showtime-natal,
  .theme-shamanic-earth,
  .theme-strict-astro-dark,
  .theme-strict-astro-light,
  .theme-server-skin
) :is(
  .feature-card,
  .drive-widget,
  .diary-post-card,
  .master-highlight-card,
  .glass-panel,
  .panel,
  .calc-container,
  .demo-card,
  .portal-card,
  .news-card,
  .article-card,
  .forum-card,
  .tool-card,
  .test-card,
  .game-card,
  .lunar-card,
  .lunar-day-card,
  .client-skin-card
) {
  background-color: var(--surface-card);
  border-color: var(--card-border);
  color: var(--text-primary);
}

body:is(
  .theme-forest,
  .theme-sunset,
  .theme-editorial,
  .theme-light,
  .theme-dark,
  .theme-sand-gold,
  .theme-astral-mint,
  .theme-stellar-midnight,
  .theme-mystic-sakura,
  .theme-shadow-ritual,
  .theme-showtime-natal,
  .theme-shamanic-earth,
  .theme-strict-astro-dark,
  .theme-strict-astro-light,
  .theme-server-skin
) :is(input, select, textarea) {
  background-color: var(--surface-control);
  border-color: var(--card-border);
  color: var(--text-primary);
}

body.theme-server-skin {
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

body.theme-server-skin .hero-sec {
  background-color: var(--surface-control) !important;
  background-image:
    linear-gradient(to bottom, var(--hero-overlay-start), var(--hero-overlay-end)),
    var(--top-bg-image) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: cover !important;
}
