:root {
  /* Primary Palette */
  --primary-50: #eef4ff;
  --primary-100: #d1e0ff;
  --primary-300: #84adff;
  --primary-500: #155eef;
  --primary-600: #1047c8;
  --primary-900: #0a1a33;

  /* Neutral Palette */
  --gray-100: #f2f4f7;
  --gray-200: #eaecf0;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-900: #101828;

  /* Semantic Colors */
  --success-50: #ecfdf3;
  --success-100: #d1fadf;
  --success-600: #067647;
  --success-700: #027a48;

  --warning-50: #fffaeb;
  --warning-100: #fef0c7;
  --warning-600: #dc6803;

  --error-50: #fef3f2;
  --error-100: #fee4e2;
  --error-500: #f04438;
  --error-600: #b42318;

  /* Theme Borders */
  --border-subtle: var(--gray-200);
  --border-default: var(--gray-300);
  --border-strong: var(--gray-400);

  /* Shadows */
  --shadow-color: 16, 24, 40;
  --shadow-xs: 0 1px 2px rgba(var(--shadow-color), 0.04);
  --shadow-sm:
    0 1px 3px rgba(var(--shadow-color), 0.08),
    0 1px 2px rgba(var(--shadow-color), 0.04);
  --shadow-lg:
    0 12px 16px -4px rgba(var(--shadow-color), 0.06),
    0 4px 6px -2px rgba(var(--shadow-color), 0.03);
  --shadow-inset: inset 0 2px 4px rgba(var(--shadow-color), 0.04);
  --shadow-glow-primary: 0 0 0 4px var(--primary-50);

  /* Typography — Slightly Increased */
  --font-sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  --text-x: 0.75rem;   /*12px*/
  --text-xs: 0.8125rem; /* 13px */
  --text-sm: 0.875rem; /* 14px */
  --text-m: 0.9375rem; /* 15px */
  --text-base: 1rem; /* 16px */
  --text-lg: 1.125rem; /* 18px */
  --text-xl: 1.375rem; /* 22px */
  --text-2xl: 1.625rem; /* 26px */
  --text-3xl: 2rem; /* 32px */

  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-base:1.4;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Spacing */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-7: 1.75rem;    /* 28px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --radius-2xl: 18px;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  --primary: #007bff;
  --accent-dark: #0056b3;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --surface: rgba(0, 0, 0, 0.03);
  --surface-hover: rgba(0, 123, 255, 0.08);
  --border: #e9ecef;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --chat-bg: #f5f1eb;
  --msg-bg: #ffffff; /* #f8f9fa;*/
  --incoming: rgba(0, 0, 0, 0.04);
  --outgoing: rgb(210, 242, 252);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --bg: #f8f9fa;
  --card: #ffffff;
  --light: #f8f9fa;
  --dark: #343a40;
  --info: #17a2b8;
  --text: #495057;
  --link-color: #22b861;
  --link-hover-color: #0f8540;
  --table-header-bg: #f8fafc;
  --table-hover-bg: #fafcff;

  --danger-shadow-1: rgba(249, 28, 13, 0.35);
  --danger-shadow-2: rgba(255, 25, 9, 0.25);

  --model-bg: #ffffff;
  --model-surface: #ffffff;
  --model-border: #dbe3ec;
  --model-hover: #f3f6fb;
  --model-active: #e8f1ff;
  --model-text: #111827;
  --model-muted: #6b7280;
  --model-divider: #e5e7eb;
  --model-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

/* --------------------------------------------------------------------------
   2. Dark Theme Tokens
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  /* Primary Palette — slightly desaturated for dark */
  --primary-50: #111c38;
  --primary-100: #1a2e5e;
  --primary-300: #3b62c4;
  --primary-500: #6b9fff;
  --primary-600: #8ab4ff;
  --primary-900: #eef4ff;

  /* Neutral Palette — inverted */
  --gray-100: #182230;
  --gray-200: #344054;
  --gray-300: #475467;
  --gray-400: #667085;
  --gray-500: #98a2b3;
  --gray-900: #f2f4f7;

  /* Semantic Colors — dark adjusted */
  --success-50: #062c1d;
  --success-100: #084c2e;
  --success-600: #6ce9a6;
  --success-700: #a6f4c5;

  --warning-50: #271c05;
  --warning-100: #4a2c0b;
  --warning-600: #fec84b;

  --error-50: #381515;
  --error-100: #551c1c;
  --error-500: #f97066;
  --error-600: #fda29b;

  /* Theme Borders — Dark */
  --border-subtle: var(--gray-100);
  --border-default: var(--gray-200);
  --border-strong: var(--gray-300);

  /* Shadows — softer in dark */
  --shadow-color: 0, 0, 0;
  --shadow-xs: 0 1px 2px rgba(var(--shadow-color), 0.2);
  --shadow-sm:
    0 1px 3px rgba(var(--shadow-color), 0.25),
    0 1px 2px rgba(var(--shadow-color), 0.15);
  --shadow-lg:
    0 12px 16px -4px rgba(var(--shadow-color), 0.35),
    0 4px 6px -2px rgba(var(--shadow-color), 0.2);
  --shadow-glow-primary: 0 0 0 4px rgba(21, 94, 239, 0.2);

  --primary: #4dabf7;
  --accent-dark: #339af0;
  --text-primary: #e9ecef;
  --text-secondary: #adb5bd;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(77, 171, 247, 0.1);
  --border: #343a40;
  --success: #51cf66;
  --warning: #ffd43b;
  --danger: #ff6b6b;
  --chat-bg: #161717; /* rgba(255, 255, 255, .1);/* #202121; /*#121212;*/
  --msg-bg: #242626;
  --incoming: rgba(255, 255, 255, 0.06);
  /* --outgoing: rgba(77, 171, 247, 0.2); */
  --outgoing: rgb(20, 42, 77);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --bg: #222831; /*#121212;*/
  --card: #1e1e1e;
  --light: #212529;
  --dark: #f8f9fa;
  --link-color: #3bec82;
  --link-hover-color: #4df091;
  --table-header-bg: #1f2937;
  --table-hover-bg: #273244;
  --info: #22b8cf;
  --text: #e9ecef;

  --danger-shadow-1: rgba(239, 68, 68, 0.45);
  --danger-shadow-2: rgba(239, 68, 68, 0.3);

  --model-bg: #111827;
  --model-surface: #1b2434;
  --model-border: #2d3748;
  --model-hover: #2b3547;
  --model-active: #334155;
  --model-text: #f8fafc;
  --model-muted: #94a3b8;
  --model-divider: #2f394d;
  --model-shadow: 0 25px 50px rgba(0, 0, 0, 0.55);
}

/* --------------------------------------------------------------------------
   3. Base Reset & Global Styles
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  background-color: var(--bg);
  min-height: 100vh;
  transition:
    background-color var(--duration-slow) var(--ease-out),
    color var(--duration-slow) var(--ease-out);
}

::selection {
  background-color: var(--primary-100);
  color: var(--primary-900);
}

:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbar — theme-aware */
::-webkit-scrollbar {
  width: var(--space-2);
  height: var(--space-2);
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* --------------------------------------------------------------------------
   4. Typography
   -------------------------------------------------------------------------- */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  color: var(--gray-900);
  transition: color var(--duration-slow) var(--ease-out);
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--font-extrabold);
}

h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
}

h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

p {
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  transition: color var(--duration-slow) var(--ease-out);
}

a {
  color: var(--primary-500);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
  color: var(--primary-600);
}

/* ==========================
   COMMON BUTTONS
========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  padding: var(--space-3) 18px;

  border: none;
  border-radius: 12px;

  cursor: pointer;

  background: var(--primary);
  color: white;

  font-weight: var(--font-semibold);

  transition: 0.25s;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: white;
  color: var(--text);

  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #f8fafc;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  filter: brightness(0.95);
}

/* ==========================
   BADGES
========================== */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 6px var(--space-3);

  border-radius: 999px;

  font-size: var(--text-x);
  font-weight: var(--font-semibold);
}

.badge.success {
  background: #dcfce7;
  color: #15803d;
}

.badge.warning {
  background: #fef3c7;
  color: #b45309;
}

.badge.danger {
  background: #fee2e2;
  color: #dc2626;
}

.page-layout {
  /* display: grid;
  grid-template-columns: auto 1fr;
  height: 100vh; */
  display: flex;
}
