:root {
  /* --- Color Palette --- */
  /* Categorical chart colors (validated order, dataviz reference palette): use in this order, never cycled. */
  --chart-1: #2a78d6; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100;
  --chart-5: #e87ba4; --chart-6: #008300; --chart-7: #6250d6; --chart-8: #e34948;
  /* Logo tile color. Not an accent for UI elements: buttons and links stay --color-primary. */
  --color-brand: #ea580c;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-subtle: #eff6ff;

  --color-success: #16a34a;
  --color-success-subtle: #f0fdf4;
  --color-warning: #d97706;
  --color-warning-subtle: #fffbeb;
  --color-danger: #dc2626;
  --color-danger-subtle: #fef2f2;
  --color-info: #0891b2;
  --color-info-subtle: #ecfeff;

  /* --- Surface & Background --- */
  --color-bg: #ffffff;
  --color-bg-subtle: #f8fafc;
  --color-bg-raised: #ffffff;
  --color-bg-overlay: rgba(0, 0, 0, 0.5);

  /* --- Text --- */
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #ffffff;
  --color-text-on-primary: #ffffff;

  /* --- Borders --- */
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-border-focus: var(--color-primary);

  /* --- Shadows --- */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  /* --- Spacing Scale (4px base) --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  /* Space between a line you open (a disclosure row) and what it shows: design rule 43. */
  --space-disclosure: var(--space-3);
  /* An open row and what it shows share this background, so they read as one block (rule 43). */
  --color-disclosure-open: var(--color-bg-subtle);
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

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

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --leading-tight: 1.25;
  --leading-normal: 1.5;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* --- Border Radius --- */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* --- Transitions --- */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* --- Z-Index Scale --- */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 300;
  --z-modal: 400;
  --z-toast: 500;

  /* --- Sidebar --- */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;

  /* --- Content widths --- */
  --width-content-form: 640px;

  /* --- Form icons ---
     Chevron stroke is baked into the data URL because `currentColor` does not
     inherit across the data URL boundary in `background-image`. Color matches
     --color-text-secondary for the active theme so it reads as a secondary UI
     element, not a primary one. */
  --chevron-svg-url: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='1 1.5 6 6.5 11 1.5'/></svg>");

  /* --- Console / terminal palette ---
     Theme-agnostic GitHub-dark colors used by all terminal surfaces (game-server
     console, build log, deploy log). Terminals stay dark even in light mode, so
     these values are intentionally NOT redefined under [data-theme="dark"]. */
  --console-bg: #0d1117;
  --console-bg-raised: #161b22;
  --console-bg-interactive: #21262d;
  --console-border: #30363d;
  --console-text: #c9d1d9;
  --console-text-muted: #8b949e;
  --console-text-error: #f87171;

  /* --- Scrollbars ---
     Thin, no track, thumb in the border tone. scrollbar-color inherits into every shadow root.
     scrollbar-width does not, so each scrolling element sets scrollbar-width: thin itself. */
  --scrollbar-thumb: #cbd5e1;
}

:root {
  scrollbar-color: var(--scrollbar-thumb) transparent;
}


/* --- Dark Mode --- */
[data-theme="dark"] {
  --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500;
  --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767;
  --color-primary: #60a5fa;
  --color-primary-hover: #93c5fd;
  --color-primary-subtle: rgba(59, 130, 246, 0.15);

  --color-success-subtle: #052e16;
  --color-warning-subtle: #422006;
  --color-danger-subtle: #450a0a;
  --color-info-subtle: #083344;

  --color-bg: #0f172a;
  --color-bg-subtle: #273449;
  --color-bg-raised: #1e293b;
  --color-bg-overlay: rgba(0, 0, 0, 0.7);

  --color-text: #f1f5f9;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  --color-border: #334155;
  --color-border-strong: #475569;

  --scrollbar-thumb: #475569;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);

  --chevron-svg-url: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='1 1.5 6 6.5 11 1.5'/></svg>");
}
