/**
 * DriveAI Design System — design-system.css
 * ==========================================
 * Single source of truth for all design tokens.
 * Import this file first in every page.
 *
 * Layer order:
 *   1. design-system.css  ← tokens + theme
 *   2. layout.css         ← grid, containers, sections
 *   3. components.css     ← BEM component library
 *   4. utilities.css      ← one-off helpers
 *
 * Theme switching:
 *   - Default:               light mode via :root
 *   - System dark:           @media (prefers-color-scheme: dark)
 *   - Explicit override:     [data-theme="dark"] on <html>
 *   - JS ThemeManager sets data-theme and writes to localStorage("da-theme")
 */

/* ============================================================
   COLOR PALETTE — RAW TOKENS (never use these directly)
   ============================================================ */
:root {
  /* Brand primaries */
  --palette-brand-900: #0f1f33;
  --palette-brand-800: #162b46;
  --palette-brand-700: #1e3a5f;
  --palette-brand-600: #264d7f;
  --palette-brand-500: #2e6099;  /* primary CTA */
  --palette-brand-400: #4a7db5;
  --palette-brand-300: #6e9fcf;
  --palette-brand-200: #a3c3e4;
  --palette-brand-100: #d6e7f5;
  --palette-brand-50:  #eef5fb;

  /* Accent — diagnostic blue-cyan */
  --palette-accent-600: #0077b6;
  --palette-accent-500: #0096c7;
  --palette-accent-400: #00b4d8;
  --palette-accent-300: #48cae4;
  --palette-accent-100: #caf0f8;

  /* Success */
  --palette-success-700: #155724;
  --palette-success-500: #1e8449;
  --palette-success-300: #52be80;
  --palette-success-100: #d4efdf;

  /* Warning */
  --palette-warning-700: #7d6608;
  --palette-warning-500: #d4a017;
  --palette-warning-300: #f4d03f;
  --palette-warning-100: #fef9e7;

  /* Danger */
  --palette-danger-700: #7b241c;
  --palette-danger-500: #c0392b;
  --palette-danger-300: #e57373;
  --palette-danger-100: #fdecea;

  /* Neutral grays */
  --palette-gray-950: #0a0a0a;
  --palette-gray-900: #111827;
  --palette-gray-800: #1f2937;
  --palette-gray-700: #374151;
  --palette-gray-600: #4b5563;
  /* gray-550/350 — muted-text steps (B2C-UI-2-FIX-1 S2). gray-500 fails
     WCAG 1.4.3 AA as muted TEXT on the tertiary surfaces (4.39:1 on
     gray-100; 2.13:1 on gray-700): each theme's --text-muted binds to the
     step that clears 4.5:1 on ALL THREE of that theme's neutral surfaces
     while keeping the primary > secondary > muted hierarchy. gray-500
     remains for non-text uses (borders, neutral chart fills). */
  --palette-gray-550: #5f6875;
  --palette-gray-500: #6b7280;
  --palette-gray-400: #9ca3af;
  --palette-gray-350: #adb3bf;
  --palette-gray-300: #d1d5db;
  --palette-gray-200: #e5e7eb;
  --palette-gray-100: #f3f4f6;
  --palette-gray-50:  #f9fafb;

  /* Gold accent — B&W brand highlight (used sparingly: badges / single highlight) */
  --palette-gold-700: #7a4d10;
  --palette-gold-600: #a8680f;
  --palette-gold-500: #d98b2b;  /* base gold accent (locked) */
  --palette-gold-400: #e3a352;
  --palette-gold-300: #edc089;
  --palette-gold-100: #faecd9;

  /* Opaque status surfaces for DARK theme — pre-composited over gray-900.
     WHY these exist (aui-overhaul visual-system.md §5.4): the dark
     --bg-*-subtle tokens are ALPHA (rgba(..., 0.18)), so their composited
     value depends on whatever sits underneath. The AA annotations in this
     file only ever considered --bg-primary. A chat thread nests three or
     more levels deep (page -> viewport -> bubble -> tool card -> chip), so
     the assistant-ui overhaul ACTIVATES a defect that is mostly dormant on
     today's flat pages: --text-danger on --bg-danger-subtle measures
     5.24:1 at depth 0 but 3.24:1 at depth 2 — the most safety-critical text
     on the individual surface is the text that fails.

     These are OPAQUE: one value, any nesting depth, no drift. Verified here
     against the dark -300 text ramp (WCAG 2.x relative luminance):
       text-success #52be80 on #132b2d = 6.40:1
       text-warning #f4d03f on #343024 = 8.74:1
       text-danger  #e57373 on #301e28 = 5.24:1
       text-gold    #edc089 on #352d28 = 8.03:1
     All clear 4.5:1 for text and 3:1 for their border companions (1.4.11). */
  --palette-surface-success-dark: #132b2d;
  --palette-surface-warning-dark: #343024;
  --palette-surface-danger-dark:  #301e28;
  --palette-surface-gold-dark:    #352d28;
}


/* ============================================================
   SEMANTIC TOKENS — LIGHT THEME (default)
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-primary:        #ffffff;
  /* App CANVAS ground (aui-overhaul CEO round 5): a soft cool-neutral grey the
     chat shell sits ON, one step BELOW --bg-primary so surfaces read as
     elevated against it rather than dissolving into a "blaringly white" page.
     It is deliberately its own token, not --bg-secondary: it sits below
     gray-100 (#f3f4f6) in lightness so the gray-50 composer/bubbles AND the
     gray-100 intake card both stay lighter than the ground, while staying
     above gray-200 (#e5e7eb, --border-subtle) so borders keep their edge.
     Only the island consumes it today; the Flask chrome is untouched.
     Contrast: --text-primary (gray-900) clears ~14:1 here (AAA). */
  --bg-canvas:         #edeff2;
  --bg-secondary:      var(--palette-gray-50);
  --bg-tertiary:       var(--palette-gray-100);
  --bg-inverse:        var(--palette-gray-950);
  --bg-brand:          var(--palette-gray-900);   /* B&W lock: brand fill = ink */
  --bg-brand-subtle:   var(--palette-gray-100);   /* B&W lock: neutral, not blue */
  --bg-accent-subtle:  var(--palette-gray-100);   /* B&W lock: cyan accent retired */
  --bg-success-subtle: var(--palette-success-100);
  --bg-warning-subtle: var(--palette-warning-100);
  --bg-danger-subtle:  var(--palette-danger-100);
  --bg-gold-subtle:    var(--palette-gold-100);

  /* Nesting-invariant status surfaces (visual-system.md §5.4). In LIGHT the
     subtle backgrounds are already opaque, so these alias them 1:1 and
     nothing changes. The token exists in BOTH themes so a component can use
     --surface-* unconditionally. */
  --surface-success:   var(--bg-success-subtle);
  --surface-warning:   var(--bg-warning-subtle);
  --surface-danger:    var(--bg-danger-subtle);
  --surface-gold:      var(--bg-gold-subtle);

  /* Text */
  --text-primary:      var(--palette-gray-900);
  --text-secondary:    var(--palette-gray-600);
  /* muted: 5.64:1 / 5.40:1 / 5.12:1 on bg-primary/secondary/tertiary (AA) */
  --text-muted:        var(--palette-gray-550);
  --text-inverse:      #ffffff;
  --text-brand:        var(--palette-gray-900);   /* B&W lock: brand text = ink */
  --text-accent:       var(--palette-gray-600);   /* B&W lock: cyan accent retired */
  --text-gold:         var(--palette-gold-700);
  --text-success:      var(--palette-success-700);
  --text-warning:      var(--palette-warning-700);
  --text-danger:       var(--palette-danger-700);
  --text-on-brand:     #ffffff;

  /* Borders */
  --border-subtle:     var(--palette-gray-200);
  --border-default:    var(--palette-gray-300);
  --border-strong:     var(--palette-gray-400);
  --border-brand:      var(--palette-gray-900);   /* B&W lock: brand outline = ink */
  --border-focus:      var(--palette-brand-400);  /* blue accent — focus only */
  --border-gold:       var(--palette-gold-500);

  /* Shadows */
  --shadow-xs:   0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.10);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl:   0 16px 48px rgba(0, 0, 0, 0.14);
  --shadow-brand: 0 4px 16px rgba(0, 0, 0, 0.18);   /* B&W lock: neutral, not blue glow */

  /* Interactive states — blue accent retained ONLY for links + focus (B&W lock).
     Focus ring is SOLID (B2C-UI-2-FIX-1 M4): the old 0.35-alpha ring
     composited to 1.72:1 over white — below the 3:1 focus-indicator floor
     (WCAG 1.4.11). Solid brand-500 clears 5.87–6.46:1 on all three light
     surfaces. */
  --focus-ring:        0 0 0 3px var(--palette-brand-500);
  --overlay-backdrop:  rgba(0, 0, 0, 0.45);

  /* Health-chart band fills (B2C-UI-2-FIX-1 M2) — the sparkline bars are
     meaningful graphics (WCAG 1.4.11, 3:1). Theme-flexed because
     warning-500 is 2.38:1 on white yet 7.47:1 on gray-900: light uses
     warning-700 (5.56:1); dark overrides back to warning-500. The neutral
     (bandless) fallback bar is gray-500 — 4.83:1 light / 3.67:1 dark on
     bg-primary — so even the unreachable default renders compliant. */
  --health-bar-good:    var(--palette-success-500);
  --health-bar-fair:    var(--palette-warning-700);
  --health-bar-poor:    var(--palette-danger-500);
  --health-bar-neutral: var(--palette-gray-500);
}


/* ============================================================
   SEMANTIC TOKENS — DARK THEME
   Applied when [data-theme="dark"] is on <html>
   ============================================================ */
[data-theme="dark"] {
  --bg-primary:        var(--palette-gray-900);
  /* Dark was already right: the ground is the DARKEST plane and gray-800
     surfaces sit ABOVE it. Canvas therefore stays gray-900 in dark — the CEO
     round-5 complaint was light-only, and this keeps dark elevation intact. */
  --bg-canvas:         var(--palette-gray-900);
  --bg-secondary:      var(--palette-gray-800);
  --bg-tertiary:       var(--palette-gray-700);
  --bg-inverse:        var(--palette-gray-50);
  --bg-brand:          var(--palette-gray-700);   /* B&W lock: charcoal ink fill, white text AA */
  --bg-brand-subtle:   var(--palette-gray-800);   /* B&W lock: neutral, not blue */
  --bg-accent-subtle:  var(--palette-gray-800);   /* B&W lock: cyan accent retired */
  --bg-success-subtle: rgba(30, 132, 73, 0.18);
  --bg-warning-subtle: rgba(212, 160, 23, 0.18);
  --bg-danger-subtle:  rgba(192, 57, 43, 0.18);
  --bg-gold-subtle:    rgba(217, 139, 43, 0.18);

  /* Nesting-invariant OPAQUE status surfaces (visual-system.md §5.4).
     The --bg-*-subtle tokens above are alpha and lose contrast as they
     nest; these do not. Use --surface-* for any status fill that can
     sit inside a card, bubble or thread. */
  --surface-success:   var(--palette-surface-success-dark);
  --surface-warning:   var(--palette-surface-warning-dark);
  --surface-danger:    var(--palette-surface-danger-dark);
  --surface-gold:      var(--palette-surface-gold-dark);

  --text-primary:      var(--palette-gray-50);
  --text-secondary:    var(--palette-gray-300);
  /* muted: 8.43:1 / 6.97:1 / 4.90:1 on bg-primary/secondary/tertiary (AA);
     dimmer than --text-secondary (gray-300) so the hierarchy survives. */
  --text-muted:        var(--palette-gray-350);
  --text-inverse:      var(--palette-gray-900);
  --text-brand:        var(--palette-gray-100);   /* B&W lock: brand text = ink (light on dark) */
  --text-accent:       var(--palette-gray-400);   /* B&W lock: cyan accent retired */
  --text-gold:         var(--palette-gold-300);
  --text-success:      var(--palette-success-300);
  --text-warning:      var(--palette-warning-300);
  --text-danger:       var(--palette-danger-300);
  --text-on-brand:     #ffffff;

  --border-subtle:     var(--palette-gray-700);
  --border-default:    var(--palette-gray-600);
  --border-strong:     var(--palette-gray-500);
  --border-brand:      var(--palette-gray-400);   /* B&W lock: brand outline = ink (light on dark) */
  --border-focus:      var(--palette-brand-300);  /* blue accent — focus only */
  --border-gold:       var(--palette-gold-400);

  --shadow-xs:   0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.40);
  --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-xl:   0 16px 48px rgba(0, 0, 0, 0.50);
  --shadow-brand: 0 4px 16px rgba(0, 0, 0, 0.50);   /* B&W lock: neutral, not blue glow */

  /* Solid ring (B2C-UI-2-FIX-1 M4): the 0.45-alpha ring composited to
     2.30:1 over gray-900; solid brand-300 clears 3.69–6.36:1 on all three
     dark surfaces. */
  --focus-ring:        0 0 0 3px var(--palette-brand-300);
  --overlay-backdrop:  rgba(0, 0, 0, 0.65);

  /* Health-chart fair band back to warning-500 on dark (7.47:1 on
     gray-900); warning-700 would be marginal there (B2C-UI-2-FIX-1 M2). */
  --health-bar-fair:   var(--palette-warning-500);
}


/* ============================================================
   SYSTEM PREFERENCE — auto dark when no explicit override
   THIS is the dark path that ships (B2C-UI-2-FIX-2): nothing sets
   data-theme today (base.html carries data-role only; no ThemeManager
   exists yet), so [data-theme="dark"] never matches and every OS-dark
   user resolves tokens HERE — and this block also wins on specificity
   (0,2,0) and source order if an explicit toggle is ever added. Keep it
   in exact parity with the [data-theme="dark"] mirror above
   (TestDarkMirrorParity enforces this mechanically).
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary:        var(--palette-gray-900);
    /* Dark was already right: the ground is the DARKEST plane and gray-800
       surfaces sit ABOVE it. Canvas therefore stays gray-900 in dark — the CEO
       round-5 complaint was light-only, and this keeps dark elevation intact. */
    --bg-canvas:         var(--palette-gray-900);
    --bg-secondary:      var(--palette-gray-800);
    --bg-tertiary:       var(--palette-gray-700);
    --bg-inverse:        var(--palette-gray-50);
    --bg-brand:          var(--palette-gray-700);   /* B&W lock: charcoal ink fill, white text AA */
    --bg-brand-subtle:   var(--palette-gray-800);   /* B&W lock: neutral, not blue */
    --bg-accent-subtle:  var(--palette-gray-800);   /* B&W lock: cyan accent retired */
    --bg-success-subtle: rgba(30, 132, 73, 0.18);
    --bg-warning-subtle: rgba(212, 160, 23, 0.18);
    --bg-danger-subtle:  rgba(192, 57, 43, 0.18);
    --bg-gold-subtle:    rgba(217, 139, 43, 0.18);

    /* Nesting-invariant OPAQUE status surfaces (visual-system.md §5.4).
       The --bg-*-subtle tokens above are alpha and lose contrast as they
       nest; these do not. Use --surface-* for any status fill that can
       sit inside a card, bubble or thread. */
    --surface-success:   var(--palette-surface-success-dark);
    --surface-warning:   var(--palette-surface-warning-dark);
    --surface-danger:    var(--palette-surface-danger-dark);
    --surface-gold:      var(--palette-surface-gold-dark);

    --text-primary:      var(--palette-gray-50);
    --text-secondary:    var(--palette-gray-300);
    /* muted: 8.43:1 / 6.97:1 / 4.90:1 on bg-primary/secondary/tertiary (AA);
       dimmer than --text-secondary (gray-300) so the hierarchy survives.
       Mirrors the [data-theme="dark"] fix — gray-500 here was the live-path
       residue of B2C-UI-2-FIX-1 S1/S2 (2.13:1 badges). */
    --text-muted:        var(--palette-gray-350);
    --text-inverse:      var(--palette-gray-900);
    --text-brand:        var(--palette-gray-100);   /* B&W lock: brand text = ink (light on dark) */
    --text-accent:       var(--palette-gray-400);   /* B&W lock: cyan accent retired */
    --text-gold:         var(--palette-gold-300);
    --text-success:      var(--palette-success-300);
    --text-warning:      var(--palette-warning-300);
    --text-danger:       var(--palette-danger-300);
    --text-on-brand:     #ffffff;

    --border-subtle:     var(--palette-gray-700);
    --border-default:    var(--palette-gray-600);
    --border-strong:     var(--palette-gray-500);
    --border-brand:      var(--palette-gray-400);   /* B&W lock: brand outline = ink (light on dark) */
    --border-focus:      var(--palette-brand-300);  /* blue accent — focus only */
    --border-gold:       var(--palette-gold-400);

    --shadow-xs:   0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-sm:   0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.40);
    --shadow-lg:   0 8px 32px rgba(0, 0, 0, 0.45);
    --shadow-xl:   0 16px 48px rgba(0, 0, 0, 0.50);
    --shadow-brand: 0 4px 16px rgba(0, 0, 0, 0.50);   /* B&W lock: neutral, not blue glow */

    /* Solid ring (B2C-UI-2-FIX-1 M4, mirrored to the live path in FIX-2):
       the 0.45-alpha ring composited to 2.30/2.18/1.86:1 over
       gray-900/800/700; solid brand-300 clears 3.69–6.36:1 on all three
       dark surfaces. */
    --focus-ring:        0 0 0 3px var(--palette-brand-300);
    --overlay-backdrop:  rgba(0, 0, 0, 0.65);

    /* Health-chart fair band back to warning-500 on dark (7.47:1 on
       gray-900); warning-700 would be marginal there (B2C-UI-2-FIX-1 M2,
       mirrored to the live path in FIX-2 — it was inheriting light's
       warning-700 at 3.19:1). */
    --health-bar-fair:   var(--palette-warning-500);
  }
}


/* ============================================================
   TYPOGRAPHY SCALE
   ============================================================ */
:root {
  --font-sans:  'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  /* Brand wordmark display font (self-hosted Nunito Sans — see
     vendor/nunito-sans/nunito-sans.css). Scoped to the DriveTrace wordmark via
     .da-wordmark; --font-sans (Inter) stays the body/UI font. */
  --font-display: 'Nunito Sans', 'Inter', 'Segoe UI', system-ui, sans-serif;

  --text-xs:    0.75rem;    /* 12px */
  --text-sm:    0.875rem;   /* 14px */
  --text-base:  1rem;       /* 16px */
  --text-lg:    1.125rem;   /* 18px */
  --text-xl:    1.25rem;    /* 20px */
  --text-2xl:   1.5rem;     /* 24px */
  --text-3xl:   1.875rem;   /* 30px */
  --text-4xl:   2.25rem;    /* 36px */
  --text-5xl:   3rem;       /* 48px */
  --text-6xl:   3.75rem;    /* 60px */

  --leading-tight:   1.2;
  --leading-snug:    1.35;
  --leading-normal:  1.5;
  --leading-relaxed: 1.65;

  --tracking-tight:  -0.025em;
  --tracking-normal: 0;
  --tracking-wide:   0.05em;
  --tracking-widest: 0.1em;

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

/* Brand wordmark — renders the "DriveTrace" lettermark in the display font
   (Nunito Sans) while the surrounding UI/body stays on Inter. Applied to the
   wordmark <span> in the navbar and footer (templates/base.html). Size, weight,
   and letter-spacing come from the containing .navbar-brand / .da-footer__brand
   rules — this class only swaps the family. */
.da-wordmark {
  font-family: var(--font-display);
}


/* ============================================================
   SPACING SCALE — 4px base grid
   ============================================================ */
:root {
  --space-0:   0;
  --space-px:  1px;
  --space-0_5: 0.125rem;   /*  2px */
  --space-1:   0.25rem;    /*  4px */
  --space-1_5: 0.375rem;   /*  6px */
  --space-2:   0.5rem;     /*  8px */
  --space-2_5: 0.625rem;   /* 10px */
  --space-3:   0.75rem;    /* 12px */
  --space-3_5: 0.875rem;   /* 14px */
  --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 */
  --space-14:  3.5rem;     /* 56px */
  --space-16:  4rem;       /* 64px */
  --space-20:  5rem;       /* 80px */
  --space-24:  6rem;       /* 96px */
  --space-32:  8rem;       /* 128px */
}


/* ============================================================
   BORDER RADIUS
   ============================================================ */
:root {
  --radius-none: 0;
  --radius-sm:   0.25rem;   /* 4px */
  --radius-md:   0.5rem;    /* 8px */
  --radius-lg:   0.75rem;   /* 12px */
  --radius-xl:   1rem;      /* 16px */
  --radius-2xl:  1.25rem;   /* 20px */
  --radius-3xl:  1.5rem;    /* 24px */
  --radius-full: 9999px;
}


/* ============================================================
   TRANSITIONS
   ============================================================ */
:root {
  --duration-fast:    100ms;
  --duration-normal:  200ms;
  --duration-slow:    300ms;
  --duration-slower:  500ms;
  --ease-default:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in:          cubic-bezier(0.4, 0, 1, 1);
  --ease-out:         cubic-bezier(0, 0, 0.2, 1);
  --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);

  --transition-colors: color var(--duration-normal) var(--ease-default),
                       background-color var(--duration-normal) var(--ease-default),
                       border-color var(--duration-normal) var(--ease-default);
  --transition-transform: transform var(--duration-normal) var(--ease-default);
  --transition-shadow:    box-shadow var(--duration-normal) var(--ease-default);
  --transition-all:       all var(--duration-normal) var(--ease-default);
}


/* ============================================================
   Z-INDEX SCALE
   ============================================================ */
:root {
  --z-base:     0;
  --z-raised:   10;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-toast:    500;
}


/* ============================================================
   VERDICT STATUS TOKENS — first-class confirmed / refuted / unknown
   (WAVE0-VERDICT-HERO §7)
   ------------------------------------------------------------
   The verdict vocabulary (common/schemas/diag_pair.py) maps:
     fixed        -> confirmed
     not_fixed    -> refuted
     not_attempted-> unknown
   These are SEMANTIC ALIASES over the existing success/danger/warning
   ramps, promoted to first-class names so the verdict surfaces read by
   intent ("confirmed") rather than by generic feedback color ("success").
   Theme-flexed automatically because they alias the semantic tokens,
   which already have light + dark definitions above.
   ============================================================ */
:root {
  --color-confirmed:    var(--text-success);
  --bg-confirmed-subtle: var(--bg-success-subtle);
  --border-confirmed:   var(--palette-success-500);

  --color-refuted:      var(--text-danger);
  --bg-refuted-subtle:  var(--bg-danger-subtle);
  --border-refuted:     var(--palette-danger-500);

  --color-unknown:      var(--text-warning);
  --bg-unknown-subtle:  var(--bg-warning-subtle);
  --border-unknown:     var(--palette-warning-500);
}


/* ============================================================
   DENSITY TOKENS (WAVE0-VERDICT-HERO §7)
   ------------------------------------------------------------
   Components read --density-gap / --density-pad for consistent spacing.
   The active scale is pinned to the comfortable values site-wide — the
   Simple/Expert view-density switch was removed in FE-07. The compact
   scale tokens are retained so any consumer still referencing them
   resolves cleanly. One density, no per-component forks.
   ============================================================ */
:root {
  --density-comfortable-gap: var(--space-4);   /* 16px */
  --density-comfortable-pad: var(--space-6);   /* 24px */
  --density-compact-gap:     var(--space-2);   /*  8px (retained) */
  --density-compact-pad:     var(--space-4);   /* 16px (retained) */

  /* Active density — pinned to the comfortable scale. */
  --density-gap: var(--density-comfortable-gap);
  --density-pad: var(--density-comfortable-pad);
}


/* ============================================================
   FORM-CONTROL TOKENS — data-entry kit (FE-06)
   ------------------------------------------------------------
   Shared SIZING primitives for the data-entry component kit
   (da-switch / da-checkbox / da-radio / da-segmented /
   da-input-group / da-stepper / da-tabs). Dimension-only: the
   COLOR of every control is driven by the semantic tokens above,
   so the Black & White brand lock and the dark theme are
   inherited automatically with no per-control color forks.
   ============================================================ */
:root {
  /* Control heights — keep inputs / buttons / steppers on one rhythm. */
  --control-h-sm: 2rem;       /* 32px — compact rows */
  --control-h-md: 2.75rem;    /* 44px — WCAG 2.5.5 touch-target floor */
  --control-h-lg: 3.25rem;    /* 52px — prominent / mobile-first */

  /* Shared control corner radius. */
  --control-radius: var(--radius-lg);

  /* Checkbox / radio control box. */
  --control-box-size: 1.25rem;  /* 20px */

  /* Switch dimensions (thumb travel = w - thumb - 2*gap = 20px). */
  --switch-w: 2.75rem;        /* 44px track width */
  --switch-h: 1.5rem;         /* 24px track height */
  --switch-thumb: 1.125rem;   /* 18px thumb diameter */
  --switch-gap: 0.1875rem;    /*  3px thumb inset from track edge */
}


/* ============================================================
   GRADIENTS — DriveAI brand gradients
   ============================================================ */
:root {
  /* B&W lock: brand/hero/diagnostic/accent gradients neutralized to ink (no navy->cyan). */
  --gradient-brand:       linear-gradient(135deg, var(--palette-gray-800) 0%, var(--palette-gray-950) 100%);
  --gradient-accent:      linear-gradient(135deg, var(--palette-gray-700) 0%, var(--palette-gray-900) 100%);
  --gradient-diagnostic:  linear-gradient(135deg, var(--palette-gray-800) 0%, var(--palette-gray-950) 100%);
  --gradient-hero:        linear-gradient(160deg, var(--palette-gray-900) 0%, var(--palette-gray-800) 50%, var(--palette-gray-950) 100%);
  --gradient-warning:     linear-gradient(135deg, #d4a017 0%, #f4d03f 100%);
  --gradient-success:     linear-gradient(135deg, #155724 0%, #1e8449 100%);
  --gradient-card-dark:   linear-gradient(160deg, var(--palette-gray-800) 0%, var(--palette-gray-700) 100%);
}


/* ============================================================
   BASE RESET & THEME APPLICATION
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: var(--transition-colors);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Smooth theme transitions — only on interactive toggle,
   not on initial page load. JS adds .theme-transitioning to <html>. */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition: color var(--duration-slow) var(--ease-default),
              background-color var(--duration-slow) var(--ease-default),
              border-color var(--duration-slow) var(--ease-default),
              box-shadow var(--duration-slow) var(--ease-default) !important;
}


/* ============================================================
   TYPOGRAPHY UTILITY CLASSES
   ============================================================ */
.da-heading-1 {
  font-size: var(--text-5xl);
  font-weight: var(--font-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.da-heading-2 {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

.da-heading-3 {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.da-heading-4 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.da-heading-5 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
  color: var(--text-primary);
}

.da-lead {
  font-size: var(--text-xl);
  font-weight: var(--font-normal);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.da-body {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
}

.da-caption {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

.da-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-secondary);
}

.da-mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}


/* ============================================================
   RESPONSIVE TYPOGRAPHY — scale down on mobile
   ============================================================ */
@media (max-width: 639px) {
  .da-heading-1 { font-size: var(--text-4xl); }
  .da-heading-2 { font-size: var(--text-3xl); }
  .da-heading-3 { font-size: var(--text-2xl); }
  .da-heading-4 { font-size: var(--text-xl); }
}


/* ============================================================
   BOOTSTRAP 5 VARIABLE OVERRIDES
   Map BS5 CSS vars to our design tokens so BS components
   inherit our theme automatically.
   ============================================================ */
:root {
  /* Bootstrap color overrides — B&W lock: primary = ink, links = blue accent */
  --bs-primary:          var(--palette-gray-900);
  --bs-primary-rgb:      17, 24, 39;
  --bs-secondary:        var(--palette-gray-600);
  --bs-secondary-rgb:    75, 85, 99;
  --bs-success:          var(--palette-success-500);
  --bs-warning:          var(--palette-warning-500);
  --bs-danger:           var(--palette-danger-500);
  --bs-info:             var(--palette-brand-500);

  /* Links — blue accent retained for links only (B&W lock) */
  --bs-link-color:       var(--palette-brand-600);
  --bs-link-hover-color: var(--palette-brand-700);

  /* Bootstrap body */
  --bs-body-font-family: var(--font-sans);
  --bs-body-color:       var(--text-primary);
  --bs-body-bg:          var(--bg-primary);

  /* Bootstrap border */
  --bs-border-color:     var(--border-default);
  --bs-border-radius:    var(--radius-md);
  --bs-border-radius-sm: var(--radius-sm);
  --bs-border-radius-lg: var(--radius-lg);

  /* Bootstrap card */
  --bs-card-bg:          var(--bg-primary);
  --bs-card-border-color:var(--border-subtle);
  --bs-card-cap-bg:      var(--bg-secondary);
  --bs-card-cap-color:   var(--text-primary);

  /* Bootstrap navbar */
  --bs-navbar-color:     var(--text-primary);
  --bs-navbar-bg:        var(--bg-primary);
  /* Navbar toggler (hamburger): deliberately NOT declared here. Bootstrap
     declares --bs-navbar-toggler-* inside `.navbar{}`, a nearer ancestor of
     the icon than :root, so a :root declaration can never reach it. The real
     declarations are .navbar-scoped, in layout.css § 6 NAVBAR LAYOUT
     OVERRIDES. */

  /* Bootstrap modal */
  --bs-modal-bg:         var(--bg-primary);

  /* Bootstrap dropdown */
  --bs-dropdown-bg:          var(--bg-primary);
  --bs-dropdown-border-color:var(--border-subtle);
  --bs-dropdown-link-color:  var(--text-primary);
  --bs-dropdown-link-hover-bg: var(--bg-secondary);

  /* Bootstrap form */
  --bs-form-control-bg:     var(--bg-primary);
  --bs-form-control-color:  var(--text-primary);
  --bs-form-control-border: var(--border-default);

  /* Bootstrap table */
  --bs-table-bg:           var(--bg-primary);
  --bs-table-color:        var(--text-primary);
  --bs-table-striped-bg:   var(--bg-secondary);
  --bs-table-hover-bg:     var(--bg-tertiary);
}

[data-theme="dark"] {
  --bs-body-color:          var(--text-primary);
  --bs-body-bg:             var(--bg-primary);
  /* Links — lighter blue accent for legibility on dark (B&W lock) */
  --bs-link-color:          var(--palette-brand-300);
  --bs-link-hover-color:    var(--palette-brand-200);
  --bs-border-color:        var(--border-default);
  --bs-card-bg:             var(--bg-secondary);
  --bs-card-border-color:   var(--border-subtle);
  --bs-card-cap-bg:         var(--bg-tertiary);
  --bs-navbar-bg:           var(--bg-secondary);
  /* Navbar toggler (hamburger): deliberately NOT declared here. Bootstrap
     declares --bs-navbar-toggler-* inside `.navbar{}`, a nearer ancestor of
     the icon than :root, so a :root declaration can never reach it. The real
     declarations are .navbar-scoped, in layout.css § 6 NAVBAR LAYOUT
     OVERRIDES. */
  --bs-modal-bg:            var(--bg-secondary);
  --bs-dropdown-bg:         var(--bg-secondary);
  --bs-dropdown-border-color:var(--border-subtle);
  --bs-dropdown-link-color: var(--text-primary);
  --bs-dropdown-link-hover-bg: var(--bg-tertiary);
  --bs-form-control-bg:     var(--bg-tertiary);
  --bs-form-control-color:  var(--text-primary);
  --bs-form-control-border: var(--border-default);
  --bs-table-bg:            var(--bg-secondary);
  --bs-table-striped-bg:    var(--bg-tertiary);
  --bs-table-hover-bg:      rgba(255,255,255,0.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bs-body-color:          var(--text-primary);
    --bs-body-bg:             var(--bg-primary);
    /* Links — lighter blue accent for legibility on dark (B&W lock) */
    --bs-link-color:          var(--palette-brand-300);
    --bs-link-hover-color:    var(--palette-brand-200);
    --bs-border-color:        var(--border-default);
    --bs-card-bg:             var(--bg-secondary);
    --bs-card-border-color:   var(--border-subtle);
    --bs-card-cap-bg:         var(--bg-tertiary);
    --bs-navbar-bg:           var(--bg-secondary);
    /* Navbar toggler (hamburger): deliberately NOT declared here. Bootstrap
       declares --bs-navbar-toggler-* inside `.navbar{}`, a nearer ancestor of
       the icon than :root, so a :root declaration can never reach it. The real
       declarations are .navbar-scoped, in layout.css § 6 NAVBAR LAYOUT
       OVERRIDES. */
    --bs-modal-bg:            var(--bg-secondary);
    --bs-dropdown-bg:         var(--bg-secondary);
    /* Mirror parity with the [data-theme="dark"] bridge block above
       (B2C-UI-2-FIX-2): dropdown-border + form-control-border are
       value-identical to light (they route through flipped semantic
       tokens); table-hover-bg is the designed dark overlay that the live
       path never received. */
    --bs-dropdown-border-color:var(--border-subtle);
    --bs-dropdown-link-color: var(--text-primary);
    --bs-dropdown-link-hover-bg: var(--bg-tertiary);
    --bs-form-control-bg:     var(--bg-tertiary);
    --bs-form-control-color:  var(--text-primary);
    --bs-form-control-border: var(--border-default);
    --bs-table-bg:            var(--bg-secondary);
    --bs-table-striped-bg:    var(--bg-tertiary);
    --bs-table-hover-bg:      rgba(255,255,255,0.05);
  }
}
