:root {
  /* -------------------------------------------------------------------------
     DEFAULT THEME: Warm Obsidian Slate
     ------------------------------------------------------------------------- */

  /* Body & Layout Surfaces */
  --bg-primary: #0a0e17;
  --bg-secondary: #0f1523;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(26, 36, 56, 0.88);
  --bg-translucent: rgba(255, 255, 255, 0.04);
  --bg-translucent-hover: rgba(255, 255, 255, 0.08);
  --bg-body-gradient: radial-gradient(circle at 10% 10%, #0d121f 0%, #06090e 55%, #030508 100%);
  --bg-topbar: rgba(10, 15, 26, 0.88);
  --bg-pill: rgba(0, 0, 0, 0.35);
  --bg-pill-hover: rgba(255, 255, 255, 0.06);
  --bg-pill-active: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.15));
  --bg-elevated-dark: rgba(0, 0, 0, 0.45);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-glow: rgba(99, 102, 241, 0.3);
  --border-divider: rgba(255, 255, 255, 0.12);

  /* High-Contrast Typography (Exceeds WCAG AA 4.5:1) */
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --text-inverse: #ffffff;
  --text-brand-gradient: linear-gradient(to right, #ffffff, #93c5fd);

  /* Brand Accents */
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-indigo: #6366f1;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-gradient: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));

  /* Buttons */
  --btn-primary-bg: linear-gradient(135deg, #6366f1, #4f46e5);
  --btn-primary-hover-bg: linear-gradient(135deg, #818cf8, #4338ca);
  --btn-primary-text: #ffffff;
  --btn-primary-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
  --btn-primary-hover-shadow: 0 4px 14px rgba(79, 70, 229, 0.5);

  --btn-emerald-bg: linear-gradient(135deg, #10b981, #059669);
  --btn-emerald-hover-bg: linear-gradient(135deg, #34d399, #047857);
  --btn-emerald-text: #ffffff;
  --btn-emerald-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
  --btn-emerald-hover-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);

  --btn-danger-bg: rgba(239, 68, 68, 0.12);
  --btn-danger-hover-bg: rgba(239, 68, 68, 0.22);
  --btn-danger-text: #f87171;
  --btn-danger-hover-text: #ffffff;
  --btn-danger-border: rgba(239, 68, 68, 0.25);
  --btn-danger-hover-border: rgba(239, 68, 68, 0.45);
  --btn-danger-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);

  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --btn-secondary-hover-bg: rgba(255, 255, 255, 0.1);
  --btn-secondary-text: var(--text-main);
  --btn-secondary-border: var(--border-subtle);
  --btn-secondary-hover-border: rgba(255, 255, 255, 0.2);

  --btn-ghost-hover-bg: rgba(255, 255, 255, 0.08);
  --btn-ghost-text: var(--text-muted);

  /* Status Colors & Glows */
  --status-stopped: #64748b;
  --status-starting: #f59e0b;
  --status-healthy: #10b981;
  --status-degraded: #ef4444;

  --status-glow-healthy: 0 0 10px rgba(16, 185, 129, 0.6);
  --status-glow-starting: 0 0 10px rgba(245, 158, 11, 0.6);
  --status-glow-degraded: 0 0 10px rgba(239, 68, 68, 0.6);
  --status-glow-stopped: none;

  --card-accent-healthy: linear-gradient(90deg, transparent, #10b981, transparent);
  --card-accent-starting: linear-gradient(90deg, transparent, #f59e0b, transparent);
  --card-accent-degraded: linear-gradient(90deg, transparent, #ef4444, transparent);
  --card-accent-stopped: linear-gradient(90deg, transparent, var(--border-glow), transparent);

  /* Badges & Pills */
  --badge-live-bg: rgba(16, 185, 129, 0.12);
  --badge-live-border: rgba(16, 185, 129, 0.3);
  --badge-live-text: #34d399;

  --badge-idle-bg: rgba(100, 116, 139, 0.12);
  --badge-idle-border: rgba(100, 116, 139, 0.25);
  --badge-idle-text: #94a3b8;

  --badge-warn-bg: rgba(245, 158, 11, 0.12);
  --badge-warn-border: rgba(245, 158, 11, 0.3);
  --badge-warn-text: #fbbf24;

  --badge-err-bg: rgba(239, 68, 68, 0.12);
  --badge-err-border: rgba(239, 68, 68, 0.3);
  --badge-err-text: #f87171;

  --badge-neutral-bg: rgba(255, 255, 255, 0.05);
  --badge-neutral-border: rgba(255, 255, 255, 0.1);
  --badge-neutral-text: var(--text-muted);

  /* Terminal & PTY Console */
  --term-bg: #0a0d14;
  --term-header-bg: #0e131d;
  --term-border: rgba(255, 255, 255, 0.1);
  --term-text: #e2e8f0;
  --term-dim: #64748b;
  --term-input-bg: rgba(0, 0, 0, 0.45);
  --term-input-border: rgba(255, 255, 255, 0.12);
  --term-input-text: #f8fafc;
  --term-stdin-prompt: #38bdf8;
  --term-line-stdout: #f1f5f9;
  --term-line-stderr: #f87171;
  --term-line-stdin: #38bdf8;

  /* Modals, Popovers, & Toasts */
  --modal-backdrop: rgba(3, 7, 18, 0.75);
  --modal-bg: #0f172a;
  --modal-border: rgba(255, 255, 255, 0.12);
  --modal-header-border: rgba(255, 255, 255, 0.08);
  --modal-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);

  --toast-bg: #1e293b;
  --toast-border: rgba(255, 255, 255, 0.15);
  --toast-text: #f8fafc;
  --toast-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);

  /* Studio & DAG Engine */
  --studio-hero-bg: rgba(15, 23, 42, 0.65);
  --dag-connector-line: rgba(255, 255, 255, 0.15);
  --dag-node-bg: rgba(15, 23, 42, 0.8);
  --dag-node-border: rgba(255, 255, 255, 0.12);
  --dag-node-text: var(--text-main);
  --dag-node-passed-bg: rgba(16, 185, 129, 0.15);
  --dag-node-passed-border: rgba(16, 185, 129, 0.45);
  --dag-node-passed-text: #34d399;
  --dag-node-running-bg: rgba(245, 158, 11, 0.15);
  --dag-node-running-border: rgba(245, 158, 11, 0.45);
  --dag-node-running-text: #fbbf24;
  --dag-node-failed-bg: rgba(239, 68, 68, 0.15);
  --dag-node-failed-border: rgba(239, 68, 68, 0.45);
  --dag-node-failed-text: #f87171;

  /* Typography Scales */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Shadows & Glassmorphism */
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.06);
  --shadow-glow: 0 0 25px -5px rgba(99, 102, 241, 0.4);
  --shadow-drawer-top: 0 -4px 16px rgba(0, 0, 0, 0.25);
  --backdrop-blur: blur(16px);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Spacing Scale */
  --space-2xs: 0.125rem;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;

  /* Motion Tokens */
  --anim-fast: 150ms;
  --anim-normal: 250ms;
  --anim-slow: 400ms;
  --anim-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --anim-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Semantic Role Tokens */
  --brand-primary: #6366f1;
  --brand-primary-hover: #4f46e5;

  /* Transitions */
  --transition-fast: var(--anim-fast) cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: var(--anim-normal) cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------------------------------------------------------------------------
   THEME 2: 🌌 Cyber Midnight Cyan Theme
   --------------------------------------------------------------------------- */
[data-theme="midnight"] {
  --bg-primary: #030712;
  --bg-secondary: #0b1120;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-card: rgba(15, 23, 42, 0.88);
  --bg-card-hover: rgba(22, 36, 64, 0.92);
  --bg-body-gradient: radial-gradient(circle at 10% 10%, #081226 0%, #040914 60%, #02050a 100%);
  --bg-topbar: rgba(11, 17, 32, 0.9);
  --border-subtle: rgba(56, 189, 248, 0.16);
  --border-medium: rgba(56, 189, 248, 0.25);
  --border-glow: rgba(56, 189, 248, 0.45);
  --accent-indigo: #38bdf8;
  --accent-cyan: #00f2fe;
  --accent-blue: #0284c7;
  --accent-gradient: linear-gradient(135deg, #0284c7, #00f2fe);
  --shadow-glow: 0 0 25px -5px rgba(56, 189, 248, 0.45);
  --text-brand-gradient: linear-gradient(to right, #ffffff, #38bdf8);
  --btn-primary-bg: linear-gradient(135deg, #0284c7, #0369a1);
  --btn-primary-hover-bg: linear-gradient(135deg, #38bdf8, #0284c7);
  --btn-primary-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
  --modal-bg: #0b1329;
  --term-bg: #040814;
  --term-header-bg: #070e20;
}

/* ---------------------------------------------------------------------------
   THEME 3: 📟 Hacker Terminal Emerald Theme
   --------------------------------------------------------------------------- */
[data-theme="emerald"] {
  --bg-primary: #020b05;
  --bg-secondary: #05160b;
  --bg-surface: #0a2414;
  --bg-surface-elevated: #0f361f;
  --bg-card: rgba(10, 36, 20, 0.85);
  --bg-card-hover: rgba(16, 48, 28, 0.92);
  --bg-body-gradient: radial-gradient(circle at 10% 10%, #052312 0%, #021208 60%, #010a04 100%);
  --bg-topbar: rgba(5, 22, 11, 0.9);
  --border-subtle: rgba(16, 185, 129, 0.22);
  --border-medium: rgba(16, 185, 129, 0.32);
  --border-glow: rgba(16, 185, 129, 0.5);
  --brand-primary: #059669;
  --brand-primary-hover: #047857;
  --accent-indigo: #10b981;
  --accent-cyan: #34d399;
  --accent-blue: #059669;
  --accent-gradient: linear-gradient(135deg, #059669, #34d399);
  --shadow-glow: 0 0 25px -5px rgba(16, 185, 129, 0.45);
  --text-brand-gradient: linear-gradient(to right, #ffffff, #6ee7b7);
  --btn-primary-bg: linear-gradient(135deg, #059669, #047857);
  --btn-primary-hover-bg: linear-gradient(135deg, #10b981, #059669);
  --btn-primary-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
  --modal-bg: #071f11;
  --term-bg: #030e07;
  --term-header-bg: #06180c;
  /* Separate Healthy status from brand green (Mo3) */
  --status-healthy: #22c55e;
  --status-glow-healthy: 0 0 10px rgba(34, 197, 94, 0.6);
  --badge-live-bg: rgba(34, 197, 94, 0.16);
  --badge-live-border: rgba(34, 197, 94, 0.4);
  --badge-live-text: #4ade80;
}

/* ---------------------------------------------------------------------------
   THEME 4: ☀️ Clean Daylight Slate Theme (High Contrast Light Mode)
   --------------------------------------------------------------------------- */
[data-theme="daylight"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(248, 250, 252, 1);
  --bg-translucent: rgba(0, 0, 0, 0.04);
  --bg-translucent-hover: rgba(0, 0, 0, 0.08);
  --bg-body-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --bg-topbar: rgba(255, 255, 255, 0.92);
  --bg-pill: rgba(0, 0, 0, 0.06);
  --bg-pill-hover: rgba(0, 0, 0, 0.1);
  --bg-pill-active: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.12));
  --bg-elevated-dark: rgba(0, 0, 0, 0.08);

  --border-subtle: rgba(15, 23, 42, 0.14);
  --border-medium: rgba(15, 23, 42, 0.22);
  --border-glow: rgba(99, 102, 241, 0.35);
  --border-divider: rgba(15, 23, 42, 0.12);

  --text-main: #0f172a;
  --text-muted: #1e293b;
  --text-dim: #334155;
  --text-inverse: #ffffff;
  --text-brand-gradient: linear-gradient(to right, #0f172a, #1d4ed8);
  --accent-blue: #1d4ed8;
  --accent-indigo: #4338ca;
  --brand-primary: #2563eb;
  --brand-primary-hover: #1d4ed8;

  --shadow-card: 0 4px 16px -2px rgba(0, 0, 0, 0.08), 0 0 1px 1px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 20px -4px rgba(29, 78, 216, 0.25);
  --shadow-drawer-top: 0 -4px 16px rgba(0, 0, 0, 0.14);

  --btn-secondary-bg: rgba(0, 0, 0, 0.05);
  --btn-secondary-hover-bg: rgba(0, 0, 0, 0.1);
  --btn-secondary-text: #0f172a;
  --btn-secondary-border: rgba(15, 23, 42, 0.18);
  --btn-secondary-hover-border: rgba(15, 23, 42, 0.3);

  --btn-ghost-hover-bg: rgba(0, 0, 0, 0.06);
  --btn-ghost-text: #1e293b;

  --badge-live-bg: rgba(16, 185, 129, 0.15);
  --badge-live-border: rgba(16, 185, 129, 0.4);
  --badge-live-text: #047857;

  --badge-idle-bg: rgba(100, 116, 139, 0.15);
  --badge-idle-border: rgba(100, 116, 139, 0.35);
  --badge-idle-text: #1e293b;

  --badge-warn-bg: rgba(245, 158, 11, 0.15);
  --badge-warn-border: rgba(245, 158, 11, 0.4);
  --badge-warn-text: #92400e;

  --badge-err-bg: rgba(239, 68, 68, 0.15);
  --badge-err-border: rgba(239, 68, 68, 0.4);
  --badge-err-text: #991b1b;

  --badge-neutral-bg: rgba(0, 0, 0, 0.06);
  --badge-neutral-border: rgba(0, 0, 0, 0.14);
  --badge-neutral-text: #1e293b;

  --modal-backdrop: rgba(15, 23, 42, 0.5);
  --modal-bg: #ffffff;
  --modal-border: rgba(15, 23, 42, 0.16);
  --modal-header-border: rgba(15, 23, 42, 0.1);
  --modal-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.2);

  --toast-bg: #ffffff;
  --toast-border: rgba(15, 23, 42, 0.18);
  --toast-text: #0f172a;
  --toast-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);

  --studio-hero-bg: rgba(255, 255, 255, 0.85);
  --dag-connector-line: rgba(15, 23, 42, 0.18);
  --dag-node-bg: #ffffff;
  --dag-node-border: rgba(15, 23, 42, 0.16);
  --dag-node-passed-bg: rgba(16, 185, 129, 0.12);
  --dag-node-passed-border: rgba(16, 185, 129, 0.4);
  --dag-node-passed-text: #047857;

  /* Terminal in Daylight remains dark slate for contrast */
  --term-bg: #0f172a;
  --term-header-bg: #1e293b;
  --term-border: rgba(15, 23, 42, 0.2);
  --term-text: #f1f5f9;
  --term-dim: #94a3b8;
  --term-input-bg: rgba(0, 0, 0, 0.35);
  --term-input-border: rgba(255, 255, 255, 0.15);
  --term-input-text: #f8fafc;
}

/* ---------------------------------------------------------------------------
   ACCESSIBILITY: Respect Reduced Motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
