:root {
  /* ============================================================
     Toolwell Design System — Material-based "Tooling" palette
     Light theme (source: utilityhub/DESIGN.md)
     ============================================================ */

  /* Core surfaces */
  --color-bg: #fafbfc;                /* surface */
  --color-surface: #ffffff;           /* surface-container-lowest (level 0) */
  --color-surface-hover: #f3f4f6;     /* surface-container */
  --color-surface-sunken: #f5f6f8;    /* surface-container-low (tonal cards) */
  --color-surface-dim: #e5e7eb;

  --color-surface-container-lowest: #ffffff;
  --color-surface-container-low: #f5f6f8;
  --color-surface-container: #f3f4f6;
  --color-surface-container-high: #eceef1;
  --color-surface-container-highest: #e4e7eb;

  /* Text / content */
  --color-text-primary: #111827;      /* on-surface */
  --color-text-secondary: #4b5563;    /* on-surface-variant */
  --color-text-muted: #6b7280;        /* outline */
  --color-border: #e5e7eb;            /* surface-variant */
  --color-border-strong: #d1d5db;     /* outline-variant */
  --color-outline: #6b7280;
  --color-outline-variant: #d1d5db;

  /* Brand & accent (blue) */
  --color-accent: #0055cd;            /* primary */
  --color-primary: #0055cd;
  --color-accent-hover: #1f57c4;      /* primary button hover */
  --color-primary-hover: #003a8f;     /* text-link hover */
  --color-primary-container: #2f6feb;
  --color-on-primary: #ffffff;
  --color-accent-2: #2f6feb;
  --color-accent-light: rgba(47, 111, 235, 0.12);  /* primary-container soft fill */
  --color-accent-gradient: #2f6feb;   /* flat primary (no gradients) */
  --color-focus-ring: #2f6feb;

  /* Primary action buttons (contrast-safe per theme) */
  --color-btn-bg: #0055cd;
  --color-btn-fg: #ffffff;
  --color-btn-bg-hover: #1f57c4;
  --color-btn-bg-active: #003a8f;

  /* Hero decoration */
  --hero-grid-opacity: 0.5;

  /* Semantic colors (tool outputs / validation / status) */
  --color-success: #1a7f4e;
  --color-success-bg: #ecfdf5;
  --color-error: #ba1a1a;
  --color-error-bg: #ffdad6;
  --color-secondary: #006d3f;
  --color-tertiary: #b12923;
  --color-tertiary-container: #d34238;

  /* Category accents — uniform primary per Toolwell design */
  --cat-converters: #0055cd;
  --cat-converters-bg: rgba(47, 111, 235, 0.12);
  --cat-text-tools: #0055cd;
  --cat-text-tools-bg: rgba(47, 111, 235, 0.12);
  --cat-generators: #0055cd;
  --cat-generators-bg: rgba(47, 111, 235, 0.12);
  --cat-formatters: #0055cd;
  --cat-formatters-bg: rgba(47, 111, 235, 0.12);
  --cat-calculators: #0055cd;
  --cat-calculators-bg: rgba(47, 111, 235, 0.12);

  /* Typography tokens */
  --font-family-base: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-family-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas,
    "Liberation Mono", Menlo, monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.75rem;
  --font-size-3xl: 2.25rem;
  --line-height-tight: 1.2;
  --line-height-base: 1.6;
  --line-height-relaxed: 1.6;
  --tracking-tight: -0.02em;
  --tracking-label: 0.05em;

  /* Spacing Scale (4px Base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Elevation & Border Radius
     Containers (cards): 8px · Controls (inputs/buttons): 4px
     Shadows only on floating elements: 0 4px 12px rgba(20,22,26,0.08) */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-pill: 9999px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 2px 4px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 4px 8px rgba(16, 24, 40, 0.04), 0 16px 40px rgba(16, 24, 40, 0.12);
  --shadow-accent: 0 4px 12px rgba(0, 85, 205, 0.18);

  /* Animation & Transitions */
  --duration-fast: 150ms;
  --duration-base: 220ms;
  --easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --easing-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Dynamic Design properties */
  --glass-bg: rgba(249, 249, 255, 0.9);
  --glass-border: rgba(226, 226, 232, 0.8);
  --glass-blur: blur(12px);
  --hero-bg: #f3f3f9;
  --body-bg-image: none;
  --card-glow-color: rgba(47, 111, 235, 0.1);
}

[data-theme="dark"] {
  /* Dark theme derived from the Toolwell inverse palette */
  --color-bg: #14161b;
  --color-surface: #1d1f26;
  --color-surface-hover: #2a2d35;
  --color-surface-sunken: #23262e;
  --color-surface-dim: #2f3035;

  --color-surface-container-lowest: #1d1f26;
  --color-surface-container-low: #23262e;
  --color-surface-container: #2a2d35;
  --color-surface-container-high: #32353d;
  --color-surface-container-highest: #3a3e47;

  --color-text-primary: #f0f0f6;      /* inverse-on-surface */
  --color-text-secondary: #c2c6d6;    /* outline-variant */
  --color-text-muted: #9ba0ad;        /* outline */
  --color-border: #2a2d35;
  --color-border-strong: #424654;
  --color-outline: #9ba0ad;
  --color-outline-variant: #424654;

  --color-accent: #b1c5ff;            /* inverse-primary */
  --color-primary: #b1c5ff;
  --color-accent-hover: #2f6feb;
  --color-primary-hover: #7c9cff;
  --color-primary-container: #2f6feb;
  --color-on-primary: #001947;
  --color-accent-2: #2f6feb;
  --color-accent-light: rgba(47, 111, 235, 0.25);
  --color-accent-gradient: #2f6feb;
  --color-focus-ring: #2f6feb;

  --color-btn-bg: #b1c5ff;
  --color-btn-fg: #001947;
  --color-btn-bg-hover: #7c9cff;
  --color-btn-bg-active: #9fb8ff;

  --hero-grid-opacity: 0.14;

  --color-success: #7cd9a0;
  --color-success-bg: rgba(124, 217, 160, 0.12);
  --color-error: #ffb4aa;
  --color-error-bg: rgba(255, 180, 170, 0.12);
  --color-secondary: #98f6ba;
  --color-tertiary: #ffb4aa;
  --color-tertiary-container: #d34238;

  --cat-converters: #b1c5ff;
  --cat-converters-bg: rgba(47, 111, 235, 0.22);
  --cat-text-tools: #b1c5ff;
  --cat-text-tools-bg: rgba(47, 111, 235, 0.22);
  --cat-generators: #b1c5ff;
  --cat-generators-bg: rgba(47, 111, 235, 0.22);
  --cat-formatters: #b1c5ff;
  --cat-formatters-bg: rgba(47, 111, 235, 0.22);
  --cat-calculators: #b1c5ff;
  --cat-calculators-bg: rgba(47, 111, 235, 0.22);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.35), 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-accent: 0 4px 12px rgba(0, 0, 0, 0.5);

  --glass-bg: rgba(20, 22, 27, 0.85);
  --glass-border: rgba(42, 45, 53, 0.8);
  --glass-blur: blur(12px);
  --hero-bg: #23262e;
  --body-bg-image: none;
  --card-glow-color: rgba(47, 111, 235, 0.25);
}

/* Fallback support for auto-dark theme if data-theme is not set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #14161b;
    --color-surface: #1d1f26;
    --color-surface-hover: #2a2d35;
    --color-surface-sunken: #23262e;
    --color-surface-dim: #2f3035;

    --color-surface-container-lowest: #1d1f26;
    --color-surface-container-low: #23262e;
    --color-surface-container: #2a2d35;
    --color-surface-container-high: #32353d;
    --color-surface-container-highest: #3a3e47;

    --color-text-primary: #f0f0f6;
    --color-text-secondary: #c2c6d6;
    --color-text-muted: #9ba0ad;
    --color-border: #2a2d35;
    --color-border-strong: #424654;
    --color-outline: #9ba0ad;
    --color-outline-variant: #424654;

    --color-accent: #b1c5ff;
    --color-primary: #b1c5ff;
    --color-accent-hover: #2f6feb;
    --color-primary-container: #2f6feb;
    --color-on-primary: #001947;
    --color-accent-2: #2f6feb;
    --color-accent-light: rgba(47, 111, 235, 0.25);
    --color-accent-gradient: #2f6feb;
    --color-focus-ring: #2f6feb;

    --color-btn-bg: #b1c5ff;
    --color-btn-fg: #001947;
    --color-btn-bg-hover: #7c9cff;
    --color-btn-bg-active: #9fb8ff;

    --hero-grid-opacity: 0.14;

    --color-success: #7cd9a0;
    --color-success-bg: rgba(124, 217, 160, 0.12);
    --color-error: #ffb4aa;
    --color-error-bg: rgba(255, 180, 170, 0.12);
    --color-secondary: #98f6ba;
    --color-tertiary: #ffb4aa;
    --color-tertiary-container: #d34238;

    --cat-converters: #b1c5ff;
    --cat-converters-bg: rgba(47, 111, 235, 0.22);
    --cat-text-tools: #b1c5ff;
    --cat-text-tools-bg: rgba(47, 111, 235, 0.22);
    --cat-generators: #b1c5ff;
    --cat-generators-bg: rgba(47, 111, 235, 0.22);
    --cat-formatters: #b1c5ff;
    --cat-formatters-bg: rgba(47, 111, 235, 0.22);
    --cat-calculators: #b1c5ff;
    --cat-calculators-bg: rgba(47, 111, 235, 0.22);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 4px 12px rgba(0, 0, 0, 0.45);

    --glass-bg: rgba(20, 22, 27, 0.85);
    --glass-border: rgba(42, 45, 53, 0.8);
    --glass-blur: blur(12px);
    --hero-bg: #23262e;
    --body-bg-image: none;
    --card-glow-color: rgba(47, 111, 235, 0.25);
  }
}
