/* AIConnect design tokens (docs/DESIGN.md section 2).
   Components use ONLY the semantic tokens (--text-1, --surface, --success-fg...), never the
   raw scale steps, so dark mode is a token swap. Fonts are vendored (CSP: no CDNs). */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/InterVariable-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/static/fonts/JetBrainsMono-Variable.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* ---- scales (2.1) */
  --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db;
  --gray-400: #9ca3af; --gray-450: #868c98; --gray-500: #6b7280; --gray-600: #4b5563;
  --gray-700: #374151; --gray-800: #1f2937; --gray-900: #111827; --gray-950: #030712;

  --brand-50: #eef1fe; --brand-100: #e0e5fd; --brand-200: #c6cefb; --brand-300: #a5b1fb;
  --brand-400: #7d8cf6; --brand-500: #5466f0; --brand-600: #3a4bd4; --brand-700: #2f3cb0;
  --brand-800: #29348c; --brand-900: #262f6f; --brand-950: #181d42;

  /* ---- semantic status colours */
  --success-bg: #f0fdf4; --success-fg: #166534; --success-border: #bbf7d0; --success-solid: #16a34a;
  --warning-bg: #fffbeb; --warning-fg: #92400e; --warning-border: #fde68a; --warning-solid: #d97706;
  --danger-bg: #fef2f2;  --danger-fg: #b91c1c;  --danger-border: #fecaca;  --danger-solid: #dc2626;
  --info-bg: #eff6ff;    --info-fg: #1e40af;    --info-border: #bfdbfe;    --info-solid: #2563eb;
  --neutral-bg: #f3f4f6; --neutral-fg: #374151; --neutral-border: #e5e7eb; --neutral-solid: #9ca3af;
  --danger-button: #b91c1c;     /* 6.47:1 with white */
  --danger-button-hover: #991b1b;

  /* ---- surfaces (2.2) */
  --bg: var(--gray-50);
  --surface: #ffffff;
  --surface-sunken: var(--gray-50);
  --surface-hover: var(--gray-100);
  --surface-selected: var(--brand-50);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --border-control: var(--gray-450);
  --border-control-hover: var(--gray-500);
  --text-1: var(--gray-900);
  --text-2: var(--gray-600);
  --text-3: var(--gray-500);
  --text-on-accent: #ffffff;
  --link: var(--brand-600);
  --link-hover: var(--brand-700);
  --accent: var(--brand-600);
  --accent-hover: var(--brand-700);
  --accent-subtle: var(--brand-50);
  --accent-subtle-fg: var(--brand-700);
  --focus: var(--brand-600);
  --overlay: rgb(3 7 18 / .4);
  --tooltip-bg: var(--gray-900);
  --tooltip-fg: #ffffff;
  --avatar-bg: var(--brand-100);
  --avatar-fg: var(--brand-700);

  /* ---- typography (2.4) */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 12px;   --lh-xs: 16px;
  --text-sm: 13px;   --lh-sm: 20px;
  --text-base: 14px; --lh-base: 20px;
  --text-md: 16px;   --lh-md: 24px;
  --text-lg: 18px;   --lh-lg: 28px;
  --text-xl: 20px;   --lh-xl: 28px;
  --text-2xl: 24px;  --lh-2xl: 32px;
  --text-3xl: 30px;  --lh-3xl: 36px;
  --tracking-tight: -0.011em;

  /* ---- spacing: 4px grid (2.5) */
  --space-0: 0; --space-1: 2px; --space-2: 4px; --space-3: 8px; --space-4: 12px; --space-5: 16px;
  --space-6: 20px; --space-7: 24px; --space-8: 32px; --space-9: 40px; --space-10: 48px; --space-11: 64px;

  /* ---- radii */
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 12px; --radius-full: 9999px;

  /* ---- elevation: borders do the work; shadows only for things that float */
  --shadow-xs: 0 1px 2px rgb(16 24 40 / .05);
  --shadow-sm: 0 1px 3px rgb(16 24 40 / .08), 0 1px 2px rgb(16 24 40 / .04);
  --shadow-md: 0 8px 16px -4px rgb(16 24 40 / .10), 0 2px 4px rgb(16 24 40 / .06);
  --shadow-lg: 0 20px 24px -4px rgb(16 24 40 / .10), 0 8px 8px -4px rgb(16 24 40 / .04);

  --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus);
  --focus-ring-danger: 0 0 0 2px var(--surface), 0 0 0 4px var(--danger-solid);

  --z-sticky: 10; --z-topbar: 20; --z-sidebar: 30; --z-overlay: 40; --z-drawer: 50;
  --z-popover: 60; --z-toast: 70; --z-tooltip: 80;

  --dur-fast: 120ms; --dur-base: 200ms; --ease: cubic-bezier(.2, 0, 0, 1);

  /* ---- layout */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --content-max: 1280px;
  --form-max: 720px;
  --chat-col: 720px;
  --chat-sidebar-w: 272px;

  /* ---- legacy aliases (pre-design-system page CSS in admin.css still uses these;
     remove once every page uses _ui.html) */
  --text: var(--text-1);
  --muted: var(--text-2);
  --zebra: var(--surface-sunken);
  --warn-bg: var(--warning-bg);
  --warn-text: var(--warning-fg);
  --radius: var(--radius-lg);
  --font: var(--font-sans);
  --mono: var(--font-mono);
}

/* ---- dark mode (2.3): OFF by default (Jason, 2026-10-16: light is the default view, even when
   the OS is in dark mode). Dark applies only when <html data-theme="dark"> is set: the
   user's toggle (ui.theme_toggle), rendered server-side from the aic_theme cookie. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f19; --surface: #111827; --surface-sunken: #0b0f19; --surface-hover: #1f2937;
  --surface-selected: #1c2150; --border: #1f2937; --border-strong: #374151;
  --border-control: #6b7280; --border-control-hover: #9ca3af;
  --text-1: #f9fafb; --text-2: #9ca3af; --text-3: #8b93a1; --text-on-accent: #030712;
  --link: var(--brand-300); --link-hover: var(--brand-200);
  --accent: var(--brand-400); --accent-hover: var(--brand-300);
  --accent-subtle: #1c2150; --accent-subtle-fg: var(--brand-200); --focus: var(--brand-400);
  --success-bg: #0f2a1a; --success-fg: #86efac; --success-border: #14532d; --success-solid: #22c55e;
  --warning-bg: #2b1d08; --warning-fg: #fcd34d; --warning-border: #78350f; --warning-solid: #f59e0b;
  --danger-bg: #2d1414;  --danger-fg: #fca5a5;  --danger-border: #7f1d1d;  --danger-solid: #ef4444;
  --info-bg: #111c38;    --info-fg: #93c5fd;    --info-border: #1e3a8a;    --info-solid: #3b82f6;
  --neutral-bg: #1f2937; --neutral-fg: #d1d5db; --neutral-border: #374151; --neutral-solid: #6b7280;
  --danger-button: #dc2626; --danger-button-hover: #ef4444;
  --overlay: rgb(0 0 0 / .6);
  --tooltip-bg: #f9fafb; --tooltip-fg: #111827;
  --avatar-bg: #1c2150; --avatar-fg: var(--brand-200);
  --shadow-xs: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / .4), 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 8px 16px -4px rgb(0 0 0 / .4), 0 2px 4px rgb(0 0 0 / .4);
  --shadow-lg: 0 20px 24px -4px rgb(0 0 0 / .4), 0 8px 8px -4px rgb(0 0 0 / .4);
}
