/* Design tokens: the single place where colours live. Source: the Stitch "ClassPulse" design (light and dark sets).
   Legacy names (--bg, --surface, --fg, ...) stay available for the pages that are not redesigned yet. */
:root {
  /* Stitch shared tokens */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --color-emerald: #10b981;
  --color-emerald-bg: rgba(16, 185, 129, 0.14);
  --color-emerald-border: rgba(16, 185, 129, 0.3);
  --color-emerald-card-border: rgba(16, 185, 129, 0.4);
  --color-emerald-card-tint: rgba(16, 185, 129, 0.03);
  --color-crimson: #ef4444;
  --color-crimson-bg: rgba(239, 68, 68, 0.14);
  --color-crimson-bg-strong: rgba(239, 68, 68, 0.2);
  --color-crimson-border: rgba(239, 68, 68, 0.35);
  --color-amber: #f59e0b;
  --color-amber-bg: rgba(245, 158, 11, 0.14);
  --color-indigo: #6366f1;
  --color-indigo-hover: #4f46e5;
  --color-indigo-solid: #4f46e5;
  --color-indigo-solid-hover: #4338ca;
  --color-emerald-solid: #047857;
  --color-danger-solid: #dc2626;
  --color-sky: #38bdf8;
  --color-indigo-hover-border: rgba(99, 102, 241, 0.4);
  --color-indigo-tint: rgba(99, 102, 241, 0.15);
  --color-indigo-tint-border: rgba(99, 102, 241, 0.3);
  --on-accent: #ffffff;
  --brand-gradient: linear-gradient(135deg, #6366f1, #3b82f6);
  --brand-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
  --shadow-modal: 0 10px 30px rgba(0, 0, 0, 0.5);
  /* Stitch theme tokens: light */
  --bg-app: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8faff;
  --bg-surface-input: #ffffff;
  --bg-surface-card: #ffffff;
  --border-subtle: #e2e8f0;
  --border-focus: #4f46e5;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #566680;
  --text-success: #047857;
  --text-danger: #b91c1c;
  --text-warning: #92400e;
  --text-accent: #4f46e5;
  --badge-zero-bg: #f1f5f9;
  --badge-zero-text: #55657d;
  --badge-low-bg: #e0e7ff;
  --badge-low-text: #4338ca;
  --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.15);
  --hover-tint: rgba(15, 23, 42, 0.05);
  --hover-tint-soft: rgba(15, 23, 42, 0.03);
  --modal-scrim: rgba(15, 23, 42, 0.45);
  color-scheme: light;
  /* Legacy names now follow the Stitch neutrals. */
  --bg: var(--bg-app);
  --surface: var(--bg-surface);
  --surface-2: var(--bg-surface-elevated);
  --border: var(--border-subtle);
  --border-strong: #64748B;
  --fg: var(--text-primary);
  --muted: var(--text-secondary);
  --primary: #4F46E5;
  --primary-fg: #FFFFFF;
  --primary-soft: #E0E7FF;
  --success: #047857;
  --success-bg: #D1FAE5;
  --destructive: #B91C1C;
  --destructive-bg: #FEE2E2;
  --warning: #92400E;
  --heat-0: #F1F5F9;
  --heat-low: #E0E7FF;
  --heat-mid: #CFFAFE;
  --heat-high: #BBF7D0;
  --heat-absent: #FECACA;
  --heat-fg: #0F172A;
  --heat-absent-fg: #7F1D1D;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  --glass: var(--glass-bg);
  --glass-border: rgba(99, 102, 241, 0.18);
  --glow-primary: 0 0 0 1px rgba(79, 70, 229, 0.12), 0 0 20px rgba(79, 70, 229, 0.28);
  --glow-success: 0 0 16px rgba(4, 120, 87, 0.26);
  --glow-destructive: 0 0 16px rgba(185, 28, 28, 0.26);
  --glow-danger: var(--glow-destructive);
  --glow-info: 0 0 16px rgba(2, 132, 199, 0.26);
  --glow-violet-soft: rgba(99, 102, 241, 0.12);
  --glow-blue-soft: rgba(14, 165, 233, 0.09);
  --glow-green-soft: rgba(16, 185, 129, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-bg-strong: rgba(255, 255, 255, 0.94);
  --glass-solid: #ffffff;
  --glass-filter: blur(18px) saturate(1.4);
  --glass-highlight: rgba(255, 255, 255, 0.95);
  --border-violet: rgba(79, 70, 229, 0.42);
  --border-blue: rgba(2, 132, 199, 0.4);
  --border-green: rgba(4, 120, 87, 0.4);
  --border-red: rgba(185, 28, 28, 0.32);
  --edge-violet: rgba(99, 102, 241, 0.55);
  --edge-blue: rgba(14, 165, 233, 0.5);
  --edge-green: rgba(16, 185, 129, 0.5);
  --edge-on-accent: rgba(255, 255, 255, 0.34);
  --divider: rgba(15, 23, 42, 0.09);
  --shadow-glass: 0 10px 30px -10px rgba(79, 70, 229, 0.26), 0 1px 2px rgba(15, 23, 42, 0.06), inset 0 1px 0 var(--glass-highlight), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  --input-bg: rgba(255, 255, 255, 0.92);
  --chip-count-active-bg: rgba(0, 0, 0, 0.22);
  --kbd-bg: rgba(15, 23, 42, 0.05);
  --text-info: #0369a1;
  --info-bg: rgba(14, 165, 233, 0.12);
  --info-border: rgba(2, 132, 199, 0.3);
  --bg-glow: radial-gradient(56rem 36rem at 6% -8%, var(--glow-violet-soft), transparent 62%), radial-gradient(48rem 34rem at 96% 2%, var(--glow-blue-soft), transparent 62%), radial-gradient(52rem 34rem at 55% 112%, var(--glow-green-soft), transparent 62%);
  /* Weekly matrix chips: translucent state colours composited over the matrix surface (--glass-solid), plus a soft glow */
  --chip-0-bg: rgba(100, 116, 139, 0.14);
  --chip-0-border: rgba(71, 85, 105, 0.5);
  --chip-0-text: #334155;
  --chip-0-glow: 0 0 0 rgba(0, 0, 0, 0);
  --chip-low-bg: rgba(99, 102, 241, 0.14);
  --chip-low-border: rgba(79, 70, 229, 0.5);
  --chip-low-text: #3730a3;
  --chip-low-glow: 0 0 10px rgba(79, 70, 229, 0.2);
  --chip-mid-bg: rgba(13, 148, 136, 0.14);
  --chip-mid-border: rgba(13, 148, 136, 0.55);
  --chip-mid-text: #115e59;
  --chip-mid-glow: 0 0 10px rgba(13, 148, 136, 0.24);
  --chip-high-bg: rgba(16, 185, 129, 0.26);
  --chip-high-border: rgba(5, 150, 105, 0.75);
  --chip-high-text: #064e3b;
  --chip-high-glow: 0 0 14px rgba(16, 185, 129, 0.42);
  --chip-absent-bg: rgba(239, 68, 68, 0.14);
  --chip-absent-border: rgba(220, 38, 38, 0.55);
  --chip-absent-text: #991b1b;
  --chip-absent-glow: 0 0 10px rgba(220, 38, 38, 0.26);
  --chip-none-text: var(--text-muted);
  --chip-hover-glow: 0 0 0 2px rgba(79, 70, 229, 0.35), 0 0 16px rgba(79, 70, 229, 0.35);
  --font-display: var(--font-main);
  --font-sans: var(--font-main);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --radius-control: 8px;
  --radius-card: 16px;
  --radius-dialog: 16px;
  --radius-pill: 999px;
  --duration: 120ms;
}

[data-theme="dark"] {
  /* Stitch theme tokens: dark */
  --bg-app: #0b1326;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #162035;
  --bg-surface-input: #131b2e;
  --bg-surface-card: #111a2f;
  --border-subtle: #23314d;
  --border-focus: #6366f1;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #8494ad;
  --text-success: #34d399;
  --text-danger: #f87171;
  --text-warning: #fbbf24;
  --text-accent: #a5b4fc;
  --badge-zero-bg: #1e293b;
  --badge-zero-text: #94a3b8;
  --badge-low-bg: #1e2540;
  --badge-low-text: #818cf8;
  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --hover-tint: rgba(255, 255, 255, 0.05);
  --hover-tint-soft: rgba(255, 255, 255, 0.03);
  --modal-scrim: rgba(0, 0, 0, 0.65);
  color-scheme: dark;
  --border-strong: #7686A6;
  --primary: #818CF8;
  --primary-fg: #0B1020;
  --primary-soft: #232557;
  --success: #34D399;
  --success-bg: #0C3A2E;
  --destructive: #F87171;
  --destructive-bg: #3D1620;
  --warning: #FBBF24;
  --heat-0: #1E293B;
  --heat-low: #2B2F6B;
  --heat-mid: #1F4D5C;
  --heat-high: #0F5B3F;
  --heat-absent: #5A1E2B;
  --heat-fg: #DAE2FD;
  --heat-absent-fg: #FFE4E8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --glass: var(--glass-bg);
  --glass-border: rgba(148, 163, 184, 0.2);
  --glow-primary: 0 0 0 1px rgba(129, 140, 248, 0.22), 0 0 24px rgba(99, 102, 241, 0.44);
  --glow-success: 0 0 20px rgba(16, 185, 129, 0.42);
  --glow-destructive: 0 0 20px rgba(239, 68, 68, 0.42);
  --glow-info: 0 0 20px rgba(56, 189, 248, 0.4);
  --glow-violet-soft: rgba(99, 102, 241, 0.16);
  --glow-blue-soft: rgba(56, 189, 248, 0.09);
  --glow-green-soft: rgba(16, 185, 129, 0.08);
  --glass-bg: rgba(17, 26, 47, 0.6);
  --glass-bg-strong: rgba(15, 23, 42, 0.9);
  --glass-solid: #111a2f;
  --glass-filter: blur(20px) saturate(1.55);
  --glass-highlight: rgba(255, 255, 255, 0.13);
  --border-violet: rgba(129, 140, 248, 0.52);
  --border-blue: rgba(56, 189, 248, 0.46);
  --border-green: rgba(52, 211, 153, 0.48);
  --border-red: rgba(248, 113, 113, 0.42);
  --edge-violet: rgba(165, 180, 252, 0.6);
  --edge-blue: rgba(125, 211, 252, 0.55);
  --edge-green: rgba(110, 231, 183, 0.55);
  --edge-on-accent: rgba(255, 255, 255, 0.3);
  --divider: rgba(148, 163, 184, 0.16);
  --shadow-glass: 0 12px 32px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 var(--glass-highlight), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  --input-bg: rgba(9, 13, 24, 0.5);
  --kbd-bg: rgba(255, 255, 255, 0.04);
  --text-info: #7dd3fc;
  --info-bg: rgba(56, 189, 248, 0.14);
  --info-border: rgba(56, 189, 248, 0.35);
  /* Weekly matrix chips: translucent state colours composited over the matrix surface (--glass-solid), plus a soft glow */
  --chip-0-bg: rgba(148, 163, 184, 0.12);
  --chip-0-border: rgba(148, 163, 184, 0.42);
  --chip-0-text: #cbd5e1;
  --chip-0-glow: 0 0 0 rgba(0, 0, 0, 0);
  --chip-low-bg: rgba(99, 102, 241, 0.22);
  --chip-low-border: rgba(129, 140, 248, 0.62);
  --chip-low-text: #c7d2fe;
  --chip-low-glow: 0 0 12px rgba(99, 102, 241, 0.4);
  --chip-mid-bg: rgba(20, 184, 166, 0.2);
  --chip-mid-border: rgba(45, 212, 191, 0.58);
  --chip-mid-text: #99f6e4;
  --chip-mid-glow: 0 0 12px rgba(20, 184, 166, 0.38);
  --chip-high-bg: rgba(16, 185, 129, 0.36);
  --chip-high-border: rgba(52, 211, 153, 0.85);
  --chip-high-text: #ecfdf5;
  --chip-high-glow: 0 0 18px rgba(16, 185, 129, 0.6);
  --chip-absent-bg: rgba(239, 68, 68, 0.24);
  --chip-absent-border: rgba(248, 113, 113, 0.65);
  --chip-absent-text: #fecaca;
  --chip-absent-glow: 0 0 12px rgba(239, 68, 68, 0.42);
  --chip-none-text: var(--text-muted);
  --chip-hover-glow: 0 0 0 2px rgba(129, 140, 248, 0.5), 0 0 18px rgba(129, 140, 248, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    /* Stitch theme tokens: dark */
    --bg-app: #0b1326;
    --bg-surface: #0f172a;
    --bg-surface-elevated: #162035;
    --bg-surface-input: #131b2e;
    --bg-surface-card: #111a2f;
    --border-subtle: #23314d;
    --border-focus: #6366f1;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #8494ad;
    --text-success: #34d399;
    --text-danger: #f87171;
    --text-warning: #fbbf24;
    --text-accent: #a5b4fc;
    --badge-zero-bg: #1e293b;
    --badge-zero-text: #94a3b8;
    --badge-low-bg: #1e2540;
    --badge-low-text: #818cf8;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
    --hover-tint: rgba(255, 255, 255, 0.05);
    --hover-tint-soft: rgba(255, 255, 255, 0.03);
    --modal-scrim: rgba(0, 0, 0, 0.65);
    --border-strong: #7686A6;
    --primary: #818CF8;
    --primary-fg: #0B1020;
    --primary-soft: #232557;
    --success: #34D399;
    --success-bg: #0C3A2E;
    --destructive: #F87171;
    --destructive-bg: #3D1620;
    --warning: #FBBF24;
    --heat-0: #1E293B;
    --heat-low: #2B2F6B;
    --heat-mid: #1F4D5C;
    --heat-high: #0F5B3F;
    --heat-absent: #5A1E2B;
    --heat-fg: #DAE2FD;
    --heat-absent-fg: #FFE4E8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --glass: var(--glass-bg);
    --glass-border: rgba(148, 163, 184, 0.2);
    --glow-primary: 0 0 0 1px rgba(129, 140, 248, 0.22), 0 0 24px rgba(99, 102, 241, 0.44);
    --glow-success: 0 0 20px rgba(16, 185, 129, 0.42);
    --glow-destructive: 0 0 20px rgba(239, 68, 68, 0.42);
    --glow-info: 0 0 20px rgba(56, 189, 248, 0.4);
    --glow-violet-soft: rgba(99, 102, 241, 0.16);
    --glow-blue-soft: rgba(56, 189, 248, 0.09);
    --glow-green-soft: rgba(16, 185, 129, 0.08);
    --glass-bg: rgba(17, 26, 47, 0.6);
    --glass-bg-strong: rgba(15, 23, 42, 0.9);
    --glass-solid: #111a2f;
    --glass-filter: blur(20px) saturate(1.55);
    --glass-highlight: rgba(255, 255, 255, 0.13);
    --border-violet: rgba(129, 140, 248, 0.52);
    --border-blue: rgba(56, 189, 248, 0.46);
    --border-green: rgba(52, 211, 153, 0.48);
    --border-red: rgba(248, 113, 113, 0.42);
    --edge-violet: rgba(165, 180, 252, 0.6);
    --edge-blue: rgba(125, 211, 252, 0.55);
    --edge-green: rgba(110, 231, 183, 0.55);
    --edge-on-accent: rgba(255, 255, 255, 0.3);
    --divider: rgba(148, 163, 184, 0.16);
    --shadow-glass: 0 12px 32px -10px rgba(0, 0, 0, 0.6), inset 0 1px 0 var(--glass-highlight), inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    --input-bg: rgba(9, 13, 24, 0.5);
    --kbd-bg: rgba(255, 255, 255, 0.04);
    --text-info: #7dd3fc;
    --info-bg: rgba(56, 189, 248, 0.14);
    --info-border: rgba(56, 189, 248, 0.35);
    /* Weekly matrix chips: translucent state colours composited over the matrix surface (--glass-solid), plus a soft glow */
    --chip-0-bg: rgba(148, 163, 184, 0.12);
    --chip-0-border: rgba(148, 163, 184, 0.42);
    --chip-0-text: #cbd5e1;
    --chip-0-glow: 0 0 0 rgba(0, 0, 0, 0);
    --chip-low-bg: rgba(99, 102, 241, 0.22);
    --chip-low-border: rgba(129, 140, 248, 0.62);
    --chip-low-text: #c7d2fe;
    --chip-low-glow: 0 0 12px rgba(99, 102, 241, 0.4);
    --chip-mid-bg: rgba(20, 184, 166, 0.2);
    --chip-mid-border: rgba(45, 212, 191, 0.58);
    --chip-mid-text: #99f6e4;
    --chip-mid-glow: 0 0 12px rgba(20, 184, 166, 0.38);
    --chip-high-bg: rgba(16, 185, 129, 0.36);
    --chip-high-border: rgba(52, 211, 153, 0.85);
    --chip-high-text: #ecfdf5;
    --chip-high-glow: 0 0 18px rgba(16, 185, 129, 0.6);
    --chip-absent-bg: rgba(239, 68, 68, 0.24);
    --chip-absent-border: rgba(248, 113, 113, 0.65);
    --chip-absent-text: #fecaca;
    --chip-absent-glow: 0 0 12px rgba(239, 68, 68, 0.42);
    --chip-none-text: var(--text-muted);
    --chip-hover-glow: 0 0 0 2px rgba(129, 140, 248, 0.5), 0 0 18px rgba(129, 140, 248, 0.55);
  }
}
