/* Design tokens. Light is the default; dark applies with [data-theme="dark"]
   or, for [data-theme="system"], when the OS prefers dark. */

:root {
  /* Typography */
  --font-sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --leading: 1.5;

  /* Spacing (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Shape */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  /* Layout */
  --sidebar-width: 244px;
  --sidebar-collapsed: 68px;
  --topbar-height: 56px;
  --content-max: 1360px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 120ms;
  --duration: 180ms;

  /* Brand */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-lighter: #60a5fa;
  --accent: #3a73ff;
  --on-primary: #ffffff;

  /* Light theme surfaces */
  --bg: #f8fafc;
  --surface: #f1f5f9;
  --card: #ffffff;
  --card-alt: #f8faff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-body: #475569;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --hover: #0f172a0a;
  --hover-strong: #0f172a12;
  --primary-bg: #dbeafe;
  --primary-bg-soft: #eff6ff;
  --primary-text: #1d4ed8;
  --focus-ring: 0 0 0 3px #2563eb55;
  --shadow-sm: 0 1px 2px #0f172a0d;
  --shadow-lg: 0 12px 32px -8px #0f172a33, 0 2px 6px #0f172a14;
  --overlay: #0f172a66;
  --sidebar-bg: #ffffff;
  --input-bg: #ffffff;

  /* Status (accessible on both card and tinted backgrounds) */
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --ok-text: #15803d;
  --err: #dc2626;
  --err-bg: #fee2e2;
  --err-text: #b91c1c;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --warn-text: #a16207;
  --run: #2563eb;
  --run-bg: #dbeafe;
  --run-text: #1d4ed8;
  --idle: #64748b;
  --idle-bg: #f1f5f9;
  --idle-text: #475569;

  /* Log viewer (terminal look in both themes) */
  --log-bg: #0b1424;
  --log-gutter: #0f1a2e;
  --log-text: #dbe4f0;
  --log-muted: #5d6f8a;
  --log-err: #fca5a5;
  --log-warn: #fcd34d;
  --log-ok: #86efac;
  --log-mark: #facc1566;
  --log-current: #ffffff12;

  color-scheme: light;
}

/* Dark palette, shared by explicit dark and system-dark. */
:root[data-theme="dark"] {
  --bg: #0a1628;
  --surface: #0d1b31;
  --card: #111d33;
  --card-alt: #13223b;
  --border: #1e293b;
  --border-strong: #2b3a52;
  --text: #f1f5f9;
  --text-body: #cbd5e1;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --hover: #ffffff08;
  --hover-strong: #ffffff14;
  --primary-bg: #1e3a5f;
  --primary-bg-soft: #1e3a5f80;
  --primary-text: #93c5fd;
  --focus-ring: 0 0 0 3px #60a5fa66;
  --shadow-sm: 0 1px 2px #00000040;
  --shadow-lg: 0 16px 40px -8px #000000a0, 0 2px 8px #00000060;
  --overlay: #020617b3;
  --sidebar-bg: #0c1930;
  --input-bg: #0d1a2f;
  --ok: #22c55e;
  --ok-bg: #22c55e1f;
  --ok-text: #4ade80;
  --err: #ef4444;
  --err-bg: #ef44441f;
  --err-text: #f87171;
  --warn: #f59e0b;
  --warn-bg: #f59e0b1f;
  --warn-text: #fbbf24;
  --run: #3b82f6;
  --run-bg: #3b82f626;
  --run-text: #93c5fd;
  --idle: #94a3b8;
  --idle-bg: #ffffff0d;
  --idle-text: #cbd5e1;
  --log-bg: #07101f;
  --log-gutter: #0a1426;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0a1628;
    --surface: #0d1b31;
    --card: #111d33;
    --card-alt: #13223b;
    --border: #1e293b;
    --border-strong: #2b3a52;
    --text: #f1f5f9;
    --text-body: #cbd5e1;
    --muted: #94a3b8;
    --muted-2: #64748b;
    --hover: #ffffff08;
    --hover-strong: #ffffff14;
    --primary-bg: #1e3a5f;
    --primary-bg-soft: #1e3a5f80;
    --primary-text: #93c5fd;
    --focus-ring: 0 0 0 3px #60a5fa66;
    --shadow-sm: 0 1px 2px #00000040;
    --shadow-lg: 0 16px 40px -8px #000000a0, 0 2px 8px #00000060;
    --overlay: #020617b3;
    --sidebar-bg: #0c1930;
    --input-bg: #0d1a2f;
    --ok: #22c55e;
    --ok-bg: #22c55e1f;
    --ok-text: #4ade80;
    --err: #ef4444;
    --err-bg: #ef44441f;
    --err-text: #f87171;
    --warn: #f59e0b;
    --warn-bg: #f59e0b1f;
    --warn-text: #fbbf24;
    --run: #3b82f6;
    --run-bg: #3b82f626;
    --run-text: #93c5fd;
    --idle: #94a3b8;
    --idle-bg: #ffffff0d;
    --idle-text: #cbd5e1;
    --log-bg: #07101f;
    --log-gutter: #0a1426;
    color-scheme: dark;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration: 0ms;
  }
}
