/* --- PLUSO CORE THEME TOKENS --- */
:root {
  --text-main:    rgba(255,255,255,.95);
  --text-muted:   rgba(255,255,255,.55);
  --text-ghost:   rgba(255,255,255,.22);
  --surface-text:  rgba(255,255,255,.96);
  --surface-muted: rgba(255,255,255,.72);
  --surface-ghost: rgba(255,255,255,.46);
  --surface-inverse-text: #0a0f17;
  --glass:        rgba(255,255,255,.07);
  --glass-strong: rgba(255,255,255,.12);
  --border:       rgba(255,255,255,.10);
  --border-strong:rgba(255,255,255,.18);
  --bg-base:      #0a0f17;
  --bg-spot-1:    rgba(59,130,246,.20);
  --bg-spot-2:    rgba(139,92,246,.18);
  --bg-spot-3:    rgba(20,184,166,.14);
  --bg-panel:     #111826;
  --bg-warm:      #111826;
  --shadow:       0 20px 48px rgba(0,0,0,.45);
  --serif:        "Playfair Display", Georgia, serif;
  --garamond:     "EB Garamond", Georgia, serif;
  --sans:         "Outfit", system-ui, sans-serif;
  --accent:       #c8a96e;
  --accent-dim:   rgba(200,169,110,.35);
  --accent-soft:  rgba(200,169,110,.055);
  --urgent:       rgba(239,68,68,.85);
  --urgent-dim:   rgba(239,68,68,.2);
  --complete:     #57d38c;
  --complete-dim: rgba(87,211,140,.16);
  --danger:       #ef4444;
  --priority-high: #ff7a59;
  --priority-medium: #ffbf3c;
  --priority-low:  #2dd4bf;
  --email-accent: #6fa8ff;
  --panel-enter:  500ms cubic-bezier(.22,1,.36,1);
  --ease-emph:    cubic-bezier(.22,1,.36,1);
  --rule:         rgba(255,255,255,.08);
  --sidebar-shadow: 10px 0 30px rgba(0,0,0,.3);
  
  /* Category Accents */
  --c-integration: #6fa8ff;
  --c-companion:   #e8b87a;
  --c-proactive:   #b08cd4;
  --c-account:     #8ca8d4;
  --c-privacy:     #d4b87e;
}

[data-theme="light"] {
  --text-main:    rgba(28,18,8,.90);
  --text-muted:   rgba(60,40,15,.54);
  --text-ghost:   rgba(60,40,15,.35);
  --surface-text:  rgba(12,14,18,.96);
  --surface-muted: rgba(48,52,60,.78);
  --surface-ghost: rgba(68,72,80,.52);
  --surface-inverse-text: #ffffff;
  --glass:        rgba(255,255,255,.48);
  --glass-strong: rgba(255,255,255,.82);
  --border:       rgba(12,16,28,.09);
  --border-strong:rgba(12,16,28,.16);
  --bg-base:      #f7f5f0;
  --bg-spot-1:    rgba(59,130,246,.06);
  --bg-spot-2:    rgba(139,92,246,.04);
  --bg-warm:      #f2efe9;
  --bg-panel:     #ffffff;
  --bg-spot-3:    rgba(20,184,166,.18);
  --accent:       #8b6520;
  --accent-dim:   rgba(139,101,32,.22);
  --accent-soft:  rgba(139,101,32,.045);
  --email-accent: rgba(90,120,160,.85);
  --rule:         rgba(12,16,28,.07);
  --sidebar-shadow: 10px 0 30px rgba(86,63,33,.05);
  --complete:     #2f9f62;
  --complete-dim: rgba(47,159,98,.12);
  --danger:       #d94f2b;
}

[data-theme="atelier"] {
  --text-main: rgba(26, 28, 32, 0.94);
  --text-muted: rgba(82, 86, 94, 0.74);
  --text-dim: rgba(100, 104, 112, 0.56);
  --text-ghost: rgba(118, 120, 124, 0.3);
  --surface-text: rgba(18, 20, 24, 0.96);
  --surface-muted: rgba(58, 62, 70, 0.78);
  --surface-ghost: rgba(74, 78, 84, 0.52);
  --surface-inverse-text: #ffffff;
  --glass: rgba(255, 251, 244, 0.78);
  --glass-strong: rgba(255, 253, 249, 0.9);
  --border: rgba(93, 84, 63, 0.14);
  --border-strong: rgba(93, 84, 63, 0.24);
  --bg-base: #f4f2ee;
  --bg-spot-1: rgba(200, 180, 140, 0.12);
  --bg-spot-2: rgba(160, 140, 200, 0.08);
  --bg-spot-3: rgba(98, 148, 129, 0.08);
  --accent: #8b6f2e;
  --accent-dim: rgba(139, 111, 46, 0.22);
  --shadow: 0 18px 40px rgba(59, 46, 24, 0.12);
  --shadow-glow: 0 18px 40px rgba(59, 46, 24, 0.12);
  --chip: rgba(255, 253, 248, 0.92);
  --chip-active: rgba(139, 111, 46, 0.14);
  --chip-border: rgba(93, 84, 63, 0.18);
  --ok: #1a7a55;
  --warn: #8b6014;
  --danger: #a14050;
  --bg: linear-gradient(120deg, #f4f2ee 0%, #faf7f2 45%, #efe7db 100%);
  --accent-soft: rgba(139, 111, 46, 0.18);
  --danger-soft: rgba(161, 64, 80, 0.12);
  --bg-warm: #f2efe9;
  --bg-panel: #ffffff;
}

/* Surface legibility guardrail: contrast is scoped to surfaces, not every text token. */
.surface-on-light,
[data-theme="light"] .pane,
[data-theme="light"] .mag-card,
[data-theme="light"] .pc,
[data-theme="light"] .pluso-card,
[data-theme="light"] .home-v2-mail-ledger-surface,
[data-theme="light"] .home-v2-mail-thread-surface,
[data-theme="light"] .home-v2-mail-inbox-surface,
[data-theme="atelier"] .pane,
[data-theme="atelier"] .mag-card,
[data-theme="atelier"] .pc,
[data-theme="atelier"] .pluso-card,
[data-theme="atelier"] .home-v2-mail-ledger-surface,
[data-theme="atelier"] .home-v2-mail-thread-surface,
[data-theme="atelier"] .home-v2-mail-inbox-surface,
[data-theme="pollock"] .pane,
[data-theme="pollock"] .mag-card,
[data-theme="pollock"] .pc,
[data-theme="pollock"] .pluso-card,
[data-theme="pollock"] .home-v2-mail-ledger-surface,
[data-theme="pollock"] .home-v2-mail-thread-surface,
[data-theme="pollock"] .home-v2-mail-inbox-surface,
[data-theme="pollock-raw"] .pane,
[data-theme="pollock-raw"] .mag-card,
[data-theme="pollock-raw"] .pc,
[data-theme="pollock-raw"] .pluso-card,
[data-theme="pollock-raw"] .home-v2-mail-ledger-surface,
[data-theme="pollock-raw"] .home-v2-mail-thread-surface,
[data-theme="pollock-raw"] .home-v2-mail-inbox-surface,
[data-theme="pollock-light"] .pane,
[data-theme="pollock-light"] .mag-card,
[data-theme="pollock-light"] .pc,
[data-theme="pollock-light"] .pluso-card,
[data-theme="pollock-light"] .home-v2-mail-ledger-surface,
[data-theme="pollock-light"] .home-v2-mail-thread-surface,
[data-theme="pollock-light"] .home-v2-mail-inbox-surface {
  --surface-text: var(--surface-light-text, rgba(12, 14, 18, 0.96));
  --surface-muted: var(--surface-light-muted, rgba(48, 52, 60, 0.78));
  --surface-ghost: var(--surface-light-ghost, rgba(68, 72, 80, 0.52));
}

[data-theme="dark"] .surface-on-dark,
[data-theme="tron-grid"] .surface-on-dark,
[data-theme="pollock-void"] .surface-on-dark,
.surface-on-dark {
  --surface-text: var(--surface-dark-text, rgba(255, 255, 255, 0.96));
  --surface-muted: var(--surface-dark-muted, rgba(255, 255, 255, 0.72));
  --surface-ghost: var(--surface-dark-ghost, rgba(255, 255, 255, 0.46));
}

[data-theme="dark"] .pane,
[data-theme="dark"] .mag-card,
[data-theme="dark"] .pc,
[data-theme="dark"] .pluso-card,
[data-theme="dark"] .home-v2-mail-ledger-surface,
[data-theme="dark"] .home-v2-mail-thread-surface,
[data-theme="dark"] .home-v2-mail-inbox-surface,
[data-theme="tron-grid"] .pane,
[data-theme="tron-grid"] .mag-card,
[data-theme="tron-grid"] .pc,
[data-theme="tron-grid"] .pluso-card,
[data-theme="tron-grid"] .home-v2-mail-ledger-surface,
[data-theme="tron-grid"] .home-v2-mail-thread-surface,
[data-theme="tron-grid"] .home-v2-mail-inbox-surface,
[data-theme="pollock-void"] .pane,
[data-theme="pollock-void"] .mag-card,
[data-theme="pollock-void"] .pc,
[data-theme="pollock-void"] .pluso-card,
[data-theme="pollock-void"] .home-v2-mail-ledger-surface,
[data-theme="pollock-void"] .home-v2-mail-thread-surface,
[data-theme="pollock-void"] .home-v2-mail-inbox-surface {
  --surface-text: var(--surface-dark-text, rgba(255, 255, 255, 0.96));
  --surface-muted: var(--surface-dark-muted, rgba(255, 255, 255, 0.72));
  --surface-ghost: var(--surface-dark-ghost, rgba(255, 255, 255, 0.46));
}

/* Base Body Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text-main);
  background:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--bg-spot-1) 32%, transparent), transparent 74%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--bg-spot-2) 28%, transparent), transparent 74%),
    radial-gradient(circle at 50% 80%, color-mix(in srgb, var(--bg-spot-3) 30%, transparent), transparent 78%),
    var(--bg-base);
  background-size: 240% 240%;
  animation: drift 32s ease infinite;
  transition: color .4s, background-color var(--panel-enter);
  position: relative;
}

/* Custom Background Layer */
html.has-custom-bg body {
  background-image: var(--pluso-custom-bg) !important;
  background-size: cover !important;
  background-position: center !important;
  background-attachment: fixed !important;
  animation: none !important;
}

/* Dimming Overlay for custom backgrounds */
html.has-custom-bg body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: black;
  opacity: var(--pluso-bg-dim, 0.3);
  z-index: -1;
  pointer-events: none;
}

/* Specific background for Atelier if needed */
[data-theme="atelier"] body {
  background:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--bg-spot-1) 32%, transparent), transparent 74%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--bg-spot-2) 28%, transparent), transparent 74%),
    radial-gradient(circle at 50% 80%, color-mix(in srgb, var(--bg-spot-3) 30%, transparent), transparent 78%),
    var(--bg-base);
}

@keyframes drift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
