/* Particle System Styles - Updated Sept 1, 2025: All modal borders made transparent */
.matrix-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Place above body ::before/::after (which use z-index:-1) but below content */
  z-index: 0;
  pointer-events: none;
  background: transparent;
}

.light-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Place above body ::before/::after (which use z-index:-1) but below content */
  z-index: 0;
  pointer-events: none;
  background: transparent;
}

#particles-js {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Place above body ::before/::after (which use z-index:-1) but below content */
  z-index: 0;
  pointer-events: none;
}

#light-particles-js {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Place above body ::before/::after (which use z-index:-1) but below content */
  z-index: 0;
  pointer-events: none;
}

/* Glassmorphic particles layer - above matrix particles but behind content */
#glassmorphic-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Slightly above matrix/light particles to create depth, still below content */
  z-index: 1;
  pointer-events: none;
  background: transparent;
  opacity: 1;
  transition: opacity 0.5s ease;
}

/* Enhanced theme support for cyber particles */
.light-theme .matrix-particles {
  opacity: 0.4;
}

.dark-theme .matrix-particles {
  opacity: 0.7;
}

/* Auto theme follows system preference */
@media (prefers-color-scheme: dark) {
  .matrix-particles {
    opacity: 0.7;
  }
}

@media (prefers-color-scheme: light) {
  .matrix-particles {
    opacity: 0.4;
  }
}

/* Ensure cyber particles blend well with existing color scheme */
#particles-js canvas {
  mix-blend-mode: screen;
  filter: saturate(1.2) brightness(1.1);
}

.dark-theme #particles-js canvas {
  mix-blend-mode: screen;
  filter: saturate(1.1) brightness(0.9);
}

.light-theme #particles-js canvas {
  mix-blend-mode: multiply;
  filter: saturate(0.8) brightness(1.2);
}

/* CAnalyzerAI - Futuristic Glow/Glass UI */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInFromLeft {
  from { 
    opacity: 0; 
    transform: translateX(-30px); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

@keyframes slideInFromRight {
  from { 
    opacity: 0; 
    transform: translateX(30px); 
  }
  to { 
    opacity: 1; 
    transform: translateX(0); 
  }
}

@keyframes titleGlow {
  0%, 100% { 
    text-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow), 0 0 30px var(--accent-glow);
  }
  50% { 
    text-shadow: 0 0 15px var(--accent-glow), 0 0 25px var(--accent-glow), 0 0 35px var(--accent-glow);
  }
}

@keyframes iconSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes statusPulse {
  0%, 100% { 
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 8px currentColor;
  }
  50% { 
    opacity: 0.8;
    transform: scale(1.1);
    box-shadow: 0 0 15px currentColor;
  }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px var(--accent-cyan), 0 0 16px var(--accent-cyan); }
  50% { box-shadow: 0 0 12px var(--accent-cyan), 0 0 24px var(--accent-cyan); }
}

@keyframes subtleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes backgroundShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes orbitalRotation {
  0% { transform: rotate(0deg) translateX(3px) rotate(0deg); }
  100% { transform: rotate(360deg) translateX(3px) rotate(-360deg); }
}

@keyframes glowPulse {
  0%, 100% { 
    .theme-toggle {
      position: relative;
      display: flex;
      flex-direction: row; /* keep track and label side-by-side to avoid vertical growth */
      align-items: center;
      gap: 8px;
      padding: 0 12px; /* horizontal padding only so height is controlled by the variable */
      background: var(--surface);
      border: 2px solid var(--muted-border);
      border-radius: 12px;
      cursor: pointer;
      transition: all var(--timing-normal) var(--ease-out-quart);
      backdrop-filter: var(--blur-sm) saturate(150%);
      -webkit-backdrop-filter: var(--blur-sm) saturate(150%);
      box-shadow: var(--glass-shadow-sm);
      min-width: 60px;
      user-select: none;
      height: var(--header-control-size);
      min-height: var(--header-control-size);
      box-sizing: border-box;
      justify-content: flex-start;
    }
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes slideInUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInDown {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
  20%, 40%, 60%, 80% { transform: translateX(2px); }
}

@keyframes heartbeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.1); }
  28% { transform: scale(1); }
  42% { transform: scale(1.1); }
  70% { transform: scale(1); }
}

@keyframes morphShape {
  0%, 100% { border-radius: 12px; }
  25% { border-radius: 20px 8px; }
  50% { border-radius: 8px 20px; }
  75% { border-radius: 16px 12px; }
}

@keyframes textGlow {
  0%, 100% { 
    text-shadow: 0 0 5px currentColor;
    opacity: 1;
  }
  50% { 
    text-shadow: 0 0 20px currentColor, 0 0 30px currentColor;
    opacity: 0.9;
  }
}

@keyframes progressFill {
  0% { width: 0%; }
  100% { width: 100%; }
}

@keyframes loadingDots {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

:root {
  /* Enhanced Neutral grayscale palette for improved depth/hierarchy */
  --gray-900: #0f1720;
  --gray-800: #1a2230;
  --gray-700: #2b3344;
  --gray-600: #3f4b63;
  --gray-500: #6b7280;
  --gray-400: #9aa0ac;
  --gray-300: #c7ccd6;
  --gray-200: #e6e9ef;
  
  /* Enhanced Glassmorphism Surface Variables */
  --surface: rgba(255, 255, 255, 0.025);
  --surface-elevated: rgba(255, 255, 255, 0.04);
  --card-bg: rgba(255, 255, 255, 0.035);
  --card-bg-hover: rgba(255, 255, 255, 0.055);
  --muted-border: rgba(255, 255, 255, 0.06);
  --muted-border-hover: rgba(255, 255, 255, 0.12);
  
  /* Enhanced Glass Background System */
  --bg-primary: #02001a;
  --bg-secondary: rgba(10, 8, 38, 0.45);
  --bg-glass: rgba(12, 10, 48, 0.65);
  --bg-glass-light: rgba(20, 16, 60, 0.35);
  --bg-glass-elevated: rgba(12, 10, 48, 0.85);
  
  /* Enhanced Typography Colors - WCAG AA/AAA Compliant */
  --text-primary: #f0f0ff;           /* Improved contrast - AAA compliant */
  --text-secondary: #b8b8d8;         /* Better contrast - AA compliant */
  --text-muted: #8a8aaa;             /* Enhanced visibility - AA large text compliant */
  
  /* Enhanced Border and Accent System - WCAG Compliant */
  --border-color: rgba(108, 99, 255, 0.3);     /* Improved visibility */
  --border-color-hover: rgba(108, 99, 255, 0.45);
  --accent-glow: #7c73ff;           /* Better contrast ratio */
  --accent-cyan: #1ff5d4;           /* Enhanced visibility */
  --accent-magenta: #ff1aff;        /* Improved contrast */
  
  /* Enhanced RGB values for calculations */
  --accent-rgb: 124, 115, 255;
  --cyan-rgb: 31, 245, 212;
  --magenta-rgb: 255, 26, 255;
  --text-primary-rgb: 240, 240, 255;
  --border-rgb: 255, 255, 255;
  
  /* Typography */
  --font-family-main: 'Rajdhani', sans-serif;
  --font-family-heading: 'Orbitron', sans-serif;
  
  /* Enhanced Backdrop Filter System */
  --blur-xs: blur(2px);
  --blur-sm: blur(4px);
  --blur-md: blur(8px);
  --blur-lg: blur(12px);
  --blur-xl: blur(16px);
  --blur-2xl: blur(24px);
  --blur-3xl: blur(32px);
  
  /* Enhanced Glass Shadow System */
  --glow-shadow-light: 0 0 8px rgba(108, 99, 255, 0.15), 0 0 16px rgba(108, 99, 255, 0.08);
  --glow-shadow-medium: 0 0 20px rgba(108, 99, 255, 0.2), 0 0 40px rgba(108, 99, 255, 0.1);
  --glow-shadow-heavy: 0 0 30px rgba(108, 99, 255, 0.25), 0 0 60px rgba(108, 99, 255, 0.15);
  
  /* Glass Element Shadows */
  --glass-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
  --glass-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1);
  --glass-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
  --glass-shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.25), 0 8px 20px rgba(0, 0, 0, 0.2);
  
  /* Enhanced Transition System */
  --transition-fast: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --transition-glass: background-color 0.3s ease, backdrop-filter 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  
  /* Micro-Interaction Timing System */
  --timing-instant: 0.1s;
  --timing-quick: 0.15s;
  --timing-normal: 0.25s;
  --timing-slow: 0.35s;
  --timing-deliberate: 0.5s;
  
  /* Micro-Interaction Easings */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out-circ: cubic-bezier(0.85, 0, 0.15, 1);
  --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  
  /* Button Interaction States */
  --button-press-scale: 0.95;
  --button-hover-scale: 1.02;
  --button-focus-scale: 1.05;
  
  /* Form Interaction States */
  --input-focus-scale: 1.01;
  --input-invalid-shake: shake 0.6s ease-in-out;
  
  /* Card Interaction States */
  --card-hover-lift: -2px;
  --card-active-lift: -1px;
  --card-hover-scale: 1.02;
  /* Header control sizing (promoted) */
  --header-control-size: 44px;
  --header-control-gap: 12px;
}

/* Enhanced Light theme overrides - WCAG AA/AAA Compliant (Improved) */
[data-theme="light"] {
  /* === TYPOGRAPHY COLORS (WCAG AAA COMPLIANT) === */
  --text-primary: #0c1419;           /* 16.6:1 contrast ratio - AAA */
  --text-secondary: #1e2e38;         /* 11.2:1 contrast ratio - AAA */
  --text-muted: #3c4a54;             /* 7.8:1 contrast ratio - AA+ */
  --text-accent: #0d47a1;            /* 8.9:1 contrast ratio - AAA */
  --text-link: #1346a0;              /* 8.63:1 contrast ratio - AAA ENHANCED */
  --text-link-hover: #0f3380;        /* 10.2:1 contrast ratio - AAA ENHANCED */
  
  /* === BACKGROUND COLORS === */
  --bg-primary: #fefefe;             /* Pure white background for maximum contrast */
  --bg-secondary: #f7f9fc;           /* Subtle blue-tinted background */
  --bg-tertiary: #f1f5f9;            /* Card/section backgrounds */
  
  /* === ENHANCED GLASS MORPHISM === */
  --bg-glass: rgba(255, 255, 255, 0.95);      /* Near-opaque for better contrast */
  --bg-glass-light: rgba(255, 255, 255, 0.85); /* Lighter glass effect */
  --bg-glass-elevated: rgba(255, 255, 255, 0.98); /* Elevated elements */
  
  /* === SURFACE COLORS === */
  --surface: rgba(248, 250, 252, 0.9);        /* Enhanced surface visibility */
  --surface-elevated: rgba(241, 245, 249, 0.95); /* Elevated surfaces */
  --surface-hover: rgba(237, 242, 248, 0.9);  /* Hover states */
  
  /* === CARD SYSTEM === */
  --card-bg: rgba(255, 255, 255, 0.98);       /* High-contrast cards */
  --card-bg-hover: rgba(248, 250, 252, 1);    /* Card hover state */
  --card-border: rgba(15, 23, 42, 0.08);      /* Subtle card borders */
  
  /* === BORDER COLORS === */
  --border-color: rgba(15, 23, 42, 0.12);     /* Primary borders */
  --border-color-hover: rgba(15, 23, 42, 0.18); /* Hover borders */
  --muted-border: rgba(71, 85, 105, 0.15);    /* Muted element borders */
  --muted-border-hover: rgba(71, 85, 105, 0.25); /* Muted hover borders */
  
  /* === ENHANCED ACCENT SYSTEM === */
  --accent-primary: #1e40af;         /* Enhanced Primary blue - 8.65:1 contrast ratio AAA */
  --accent-primary-hover: #1d4ed8;   /* Hover state - 7.8:1 contrast ratio */
  --accent-secondary: #0052a3;       /* Enhanced cyan - 7.61:1 contrast ratio AAA */
  --accent-tertiary: #6b21a8;        /* Enhanced Purple accent - 8.72:1 contrast ratio AAA */
  
  /* === LEGACY COMPATIBILITY === */
  --accent-glow: var(--accent-primary);
  --accent-cyan: var(--accent-secondary);
  --accent-magenta: var(--accent-tertiary);
  
  /* Enhanced RGB values for light theme */
  --accent-rgb: 30, 64, 175;         /* Enhanced primary accent */
  --cyan-rgb: 0, 82, 163;            /* Enhanced secondary accent */
  --magenta-rgb: 107, 33, 168;       /* Enhanced tertiary accent */
  --text-primary-rgb: 12, 20, 25;
  --border-rgb: 15, 23, 42;
  
  /* === ENHANCED SHADOWS & GLOWS === */
  --glow-shadow-light: 0 0 12px rgba(37, 99, 235, 0.15), 0 0 24px rgba(37, 99, 235, 0.08);
  --glow-shadow-medium: 0 0 20px rgba(37, 99, 235, 0.2), 0 0 40px rgba(37, 99, 235, 0.1);
  --glow-shadow-heavy: 0 0 32px rgba(37, 99, 235, 0.25), 0 0 64px rgba(37, 99, 235, 0.15);
  
  /* Enhanced light neutral surfaces */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  
  /* === STATUS COLORS (WCAG AAA ENHANCED) === */
  --status-success: #0d6a1f;         /* Enhanced - 6.72:1 contrast ratio AAA */
  --status-warning: #8f4a00;         /* Enhanced - 6.67:1 contrast ratio AAA */
  --status-error: #b91c1c;           /* Enhanced - 6.42:1 contrast ratio AAA */
  --status-info: #1e40af;            /* Enhanced - 8.65:1 contrast ratio AAA */
}

/* Focus and accessibility improvements for light theme */
[data-theme="light"] *:focus-visible,
[data-color-scheme="light"] *:focus-visible {
  outline: 3px solid var(--accent-glow);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Enhanced button accessibility for light theme */
[data-theme="light"] button,
[data-theme="light"] .btn,
[data-color-scheme="light"] button,
[data-color-scheme="light"] .btn {
  min-height: 44px;
  min-width: 44px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] button:hover,
[data-theme="light"] .btn:hover,
[data-color-scheme="light"] button:hover,
[data-color-scheme="light"] .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
}

/* Enhanced input accessibility for light theme */
[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select,
[data-color-scheme="light"] input,
[data-color-scheme="light"] textarea,
[data-color-scheme="light"] select {
  border: 1px solid var(--border-color);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus,
[data-theme="light"] select:focus,
[data-color-scheme="light"] input:focus,
[data-color-scheme="light"] textarea:focus,
[data-color-scheme="light"] select:focus {
  border-color: var(--focus-outline-color, #64748b);
  box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.1);
}

/* Override focus styles for modal elements to ensure transparent borders */
.status-indicator:focus,
.modal-content:focus,
.status-example:focus,
.service-item:focus,
.legend-item:focus,
.help-item:focus,
.status-example-compact:focus,
.status-help-btn:focus,
.status-legend-btn:focus,
.settings-btn:focus {
  border: 1px solid transparent !important;
  outline: none !important;
}

/* Enhanced link accessibility for light theme */
[data-theme="light"] a,
[data-color-scheme="light"] a {
  color: var(--text-link, var(--accent-glow));
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: all 0.25s ease;
}

[data-theme="light"] a:hover,
[data-color-scheme="light"] a:hover {
  color: var(--text-link-hover, var(--accent-glow));
  text-decoration-color: currentColor;
}

/* Enhanced card accessibility for light theme */
[data-theme="light"] .card,
[data-theme="light"] .glass-card,
[data-color-scheme="light"] .card,
[data-color-scheme="light"] .glass-card {
  border: 1px solid var(--card-border, var(--border-color));
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] .card:hover,
[data-theme="light"] .glass-card:hover,
[data-color-scheme="light"] .card:hover,
[data-color-scheme="light"] .glass-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(15, 23, 42, 0.15), 0 3px 10px rgba(15, 23, 42, 0.08);
}

/* Enhanced notification/status colors for light theme */
[data-theme="light"] .status-indicator,
[data-color-scheme="light"] .status-indicator {
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 500;
  background: transparent;
}

[data-theme="light"] .status-success,
[data-color-scheme="light"] .status-success {
  background-color: rgba(22, 163, 74, 0.1);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.2);
}

[data-theme="light"] .status-error,
[data-color-scheme="light"] .status-error {
  background-color: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

[data-theme="light"] .status-warning,
[data-color-scheme="light"] .status-warning {
  background-color: rgba(217, 119, 6, 0.1);
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.2);
}

[data-theme="light"] .status-info,
[data-color-scheme="light"] .status-info {
  background-color: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* Dark explicit (matches defaults) */
[data-theme="dark"] { --theme-mode: dark; /* explicit dark theme placeholder - use [data-color-scheme] for full overrides */ }

/* FALLBACK: Class-based theme selectors (WCAG Enhanced) */
.theme-light {
  --bg-primary: #fefefe;
  --bg-secondary: rgba(247, 249, 252, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.95);
  --text-primary: #0c1419;           /* AAA compliant */
  --text-secondary: #1e2e38;         /* AAA compliant */
  --text-muted: #3c4a54;             /* AA+ compliant */
  --accent-glow: #2563eb;            /* Enhanced primary blue */
  --accent-cyan: #0067c5;            /* Improved cyan - WCAG compliant */
  --border-color: rgba(15, 23, 42, 0.12);
}

.theme-dark {
  --bg-primary: #02001a;
  --bg-secondary: rgba(10, 8, 38, 0.45);
  --bg-glass: rgba(12, 10, 48, 0.65);
  --text-primary: #f0f0ff;
  --text-secondary: #b8b8d8;
  --text-muted: #8a8aaa;
  --accent-glow: #7c73ff;
  --accent-cyan: #1ff5d4;
  --border-color: rgba(108, 99, 255, 0.3);
}

/* Also support the reference repo's attribute name - WCAG Enhanced */
[data-color-scheme="light"] {
  --bg-primary: #fefefe;             /* Pure white for maximum contrast */
  --bg-secondary: rgba(247, 249, 252, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.95);
  --text-primary: #0c1419;           /* Enhanced contrast - AAA compliant */
  --text-secondary: #1e2e38;         /* Improved visibility - AAA compliant */
  --text-muted: #3c4a54;             /* Better contrast than original */
  --border-color: rgba(15, 23, 42, 0.12);  /* Improved visibility */
  --accent-glow: #2563eb;            /* Enhanced primary blue */
  --accent-cyan: #0067c5;            /* Improved cyan - WCAG compliant */
  --accent-magenta: #7c3aed;         /* Enhanced purple */
  --glow-shadow-light: 0 0 12px rgba(37, 99, 235, 0.15), 0 0 24px rgba(37, 99, 235, 0.08);
  --glow-shadow-medium: 0 0 20px rgba(37, 99, 235, 0.2), 0 0 40px rgba(37, 99, 235, 0.1);
}

[data-color-scheme="dark"] {
  --bg-primary: #02001a;
  --bg-secondary: rgba(10, 8, 38, 0.5);
  --bg-glass: rgba(12, 10, 48, 0.75);
  --text-primary: #e0e0ff;
  --text-secondary: #a0a0cc;
  --text-muted: #6a6a8a;
  --border-color: rgba(108, 99, 255, 0.25);
  --accent-glow: #6c63ff;
  --accent-cyan: #00f5d4;
  --accent-magenta: #ff00ff;
  --glow-shadow-light: 0 0 5px var(--accent-glow), 0 0 10px var(--accent-glow);
  --glow-shadow-medium: 0 0 15px var(--accent-glow), 0 0 25px var(--accent-glow);
  /* dark neutral surfaces */
  --gray-900: #020214;
  --gray-800: #0b0f1a;
  --gray-700: #16202b;
  --gray-600: #24303f;
  --gray-500: #405064;
  --gray-400: #6b7486;
  --gray-300: #9aa0ac;
  --gray-200: #cbd3df;
  --surface: rgba(12,10,48,0.4);
  --card-bg: rgba(18,16,56,0.4);
  --muted-border: rgba(108,99,255,0.12);
}

/* If user prefers a light system theme and no explicit theme is set, apply enhanced light variables */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #fefefe;
    --bg-secondary: rgba(247, 249, 252, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.95);
    --text-primary: #0c1419;           /* AAA compliant */
    --text-secondary: #1e2e38;         /* AAA compliant */
    --text-muted: #3c4a54;             /* AA+ compliant */
    --border-color: rgba(15, 23, 42, 0.12);
    --accent-glow: #2563eb;            /* Enhanced primary blue */
    --accent-cyan: #0067c5;            /* WCAG compliant cyan */
    --accent-magenta: #7c3aed;         /* Enhanced purple */
  }
}

/* Particle canvas positioning and visibility */
#particleCanvas {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 0 !important;
  pointer-events: none !important;
  background: transparent !important;
  display: block !important;
}

/* Ensure canvas is always visible behind content */
.app-container {
  position: relative;
  z-index: 10;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Sticky footer foundation: make the page a flex column that spans the viewport */
body {
  min-height: 100dvh; /* modern mobile-safe viewport */
  min-height: 100vh;  /* fallback */
  display: flex;
  flex-direction: column;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(2,0,26,1) 0%, rgba(12,10,48,1) 50%, rgba(2,0,26,1) 100%),
              url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><g fill-opacity="0.05" fill="%236c63ff"><rect x="0" y="0" width="50" height="50"/><rect x="50" y="50" width="50" height="50"/></g></svg>');
  background-blend-mode: multiply;
  background-size: 400% 400%, 60px 60px;
  animation: backgroundShift 20s ease-in-out infinite;
  z-index: -1;
}

/* Floating geometric shapes in background */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 80%, rgba(108, 99, 255, 0.1) 1px, transparent 1px),
    radial-gradient(circle at 80% 20%, rgba(0, 245, 212, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 300px 300px, 400px 400px, 200px 200px;
  animation: floatingElements 25s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

.hidden { display: none !important; }

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* allow container to fill the page so footer can stick */
  flex: 1 0 auto;
  animation: fadeIn 1s ease-out;
}

/* If your main content is wrapped in .main-content, let it take remaining space */
.main-content {
  flex: 1 0 auto;
  min-height: 0; /* prevents overflow issues in nested flex/grid */
}

.header {
  background: linear-gradient(135deg, rgba(26, 54, 93, 0.9) 0%, rgba(45, 90, 135, 0.8) 100%);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(26, 54, 93, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: var(--transition-glass);
}

.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.05) 0%,
    rgba(31, 245, 212, 0.08) 30%, 
    rgba(255, 255, 255, 0.02) 50%,
    rgba(31, 245, 212, 0.08) 70%,
    rgba(255, 255, 255, 0.05) 100%
  );
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity var(--timing-normal) ease;
}

.header:hover {
  border-bottom-color: rgba(31, 245, 212, 0.4);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.25),
    0 6px 20px rgba(26, 54, 93, 0.4),
    0 0 25px rgba(31, 245, 212, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.header:hover::before {
  opacity: 1;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  animation: slideInFromLeft 1s ease-out;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  animation: slideInFromRight 1s ease-out;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
}

/* Navigation Dropdown Styles */
.main-nav {
  margin-right: 16px;
}

.nav-menu {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 8px;
}

.nav-dropdown {
  position: relative;
}

.dropdown-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 255, 255, 0.2);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  font-size: 14px;
  font-weight: 500;
}

.dropdown-toggle:hover,
.dropdown-toggle:focus {
  background: rgba(0, 255, 255, 0.1);
  border-color: rgba(0, 255, 255, 0.4);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
  transform: translateY(-1px);
}

.dropdown-toggle[aria-expanded="true"] {
  background: rgba(0, 255, 255, 0.15);
  border-color: rgba(0, 255, 255, 0.5);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
}

.dropdown-toggle[aria-expanded="true"] .dropdown-arrow {
  transform: rotate(180deg);
}

.nav-icon {
  font-size: 16px;
  filter: drop-shadow(0 0 3px currentColor);
}

.nav-text {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.dropdown-arrow {
  font-size: 10px;
  transition: transform 0.3s ease;
  opacity: 0.8;
}

.dropdown-menu {
  position: fixed !important;
  top: calc(100% + 8px);
  right: 0;
  min-width: 320px;
  max-width: 400px;
  background: rgba(20, 25, 40, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 255, 255, 0.2);
  border-radius: 12px;
  padding: 16px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999999 !important;
  box-shadow: 
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 0 20px rgba(0, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  /* Ensure dropdown stays within viewport */
  max-width: min(400px, calc(100vw - 32px));
  /* Force new stacking context */
  isolation: isolate;
}

.dropdown-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  /* Force to absolute top layer */
  z-index: 2147483647 !important;
}

/* Dropdown opening upward animation */
.dropdown-menu.dropdown-up {
  transform: translateY(10px) scale(0.95);
}

.dropdown-menu.dropdown-up.show {
  transform: translateY(0) scale(1);
  /* Force to absolute top layer */
  z-index: 2147483647 !important;
}

.dropdown-section {
  margin-bottom: 16px;
}

.dropdown-section:last-child {
  margin-bottom: 0;
}

.dropdown-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.1);
  margin-bottom: 8px;
  background: rgba(0, 255, 255, 0.03);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: all 0.3s ease;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-cyan);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: rgba(0, 255, 255, 0.1);
  color: var(--accent-cyan);
  transform: translateX(8px);
  box-shadow: 0 4px 12px rgba(0, 255, 255, 0.2);
}

.dropdown-item:hover::before,
.dropdown-item:focus::before {
  transform: scaleY(1);
}

/* Mobile Responsive Dropdown */
@media (max-width: 768px) {
  .main-nav {
    margin-right: 8px;
  }
  
  .dropdown-toggle {
    padding: 6px 12px;
    font-size: 12px;
  }
  
  .nav-text {
    display: none;
  }
  
  .dropdown-menu {
    position: fixed;
    top: auto !important;
    bottom: auto !important;
    right: 8px !important;
    left: 8px !important;
    min-width: auto;
    max-width: none !important;
    margin-top: 8px;
    max-height: calc(100vh - 120px) !important;
  }
}

/* WCAG Accessibility Enhancements */
.dropdown-toggle:focus,
.dropdown-item:focus {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.dropdown-toggle:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(0, 255, 255, 0.2);
}

/* Screen reader only class */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .dropdown-menu {
    background: rgba(0, 0, 0, 0.98);
    border: 2px solid #ffffff;
  }
  
  .dropdown-toggle {
    border: 2px solid #ffffff;
    background: rgba(0, 0, 0, 0.9);
  }
  
  .dropdown-item:hover,
  .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.9);
    color: #000000;
  }
  
  .dropdown-header {
    color: #ffffff;
    border-bottom: 2px solid #ffffff;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .dropdown-menu,
  .dropdown-arrow,
  .dropdown-item,
  .dropdown-toggle {
    transition: none;
    animation: none;
  }
  
  .dropdown-item:hover,
  .dropdown-item:focus {
    transform: none;
  }
}

/* Color Contrast Improvements */
@media (prefers-contrast: more) {
  .dropdown-item {
    color: #ffffff;
  }
  
  .dropdown-header {
    color: #00ffff;
  }
}

@media (max-width: 480px) {
  .dropdown-menu {
    right: 4px;
    left: 4px;
    max-height: 60vh;
  }
  
  .dropdown-item {
    padding: 12px 16px;
    font-size: 13px;
  }
}

.app-title {
  font-family: var(--font-family-heading);
  font-weight: 700;
  font-size: 28px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  text-shadow: 0 0 5px var(--accent-cyan), 0 0 10px var(--accent-cyan);
  transition: var(--transition-fast);
  animation: slideInFromLeft 1s ease-out;
}
.app-title:hover {
  transform: scale(1.05);
  text-shadow: 0 0 10px var(--accent-cyan), 0 0 20px var(--accent-cyan);
  animation: titleGlow 2s ease-in-out infinite;
}

.app-title .title-icon {
  animation: iconSpin 3s linear infinite;
  transition: var(--transition-fast);
}

.app-title:hover .title-icon {
  animation: iconSpin 1s linear infinite;
}

/* Stronger visual hierarchy for headings and sections */
h2, h3, h4 {
  color: var(--text-primary);
  font-family: var(--font-family-heading);
  letter-spacing: 0.3px;
}

h2 { font-size: 28px; margin: 0 0 8px; border-bottom: 1px solid var(--muted-border); padding-bottom: 8px; }
h3 { font-size: 20px; margin: 0; }

/* AI highlight for AI-powered results or notices */
.ai-highlight {
  color: var(--accent-cyan);
  background: linear-gradient(90deg, rgba(0,123,255,0.06), rgba(0,245,212,0.03));
  border-radius: 6px;
  padding: 4px 8px;
  font-weight: 700;
  border: 1px solid transparent;
}

/* NA badge styling for readability */
.na-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(0,0,0,0.08);
  color: var(--text-secondary);
  border-radius: 999px;
  font-weight: 700;
}

/* Visual flag for AI unavailability */
.ai-unavailable {
  color: var(--text-secondary);
  background: rgba(255, 80, 80, 0.04);
  border-left: 4px solid rgba(255,80,80,0.18);
  padding: 8px 12px;
  border-radius: 8px;
}

/* Enhanced AI state indicators */
.ai-error {
  color: #ff4757;
  background: rgba(255, 71, 87, 0.08);
  border-left: 4px solid rgba(255, 71, 87, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.ai-warning {
  color: #ffa502;
  background: rgba(255, 165, 2, 0.08);
  border-left: 4px solid rgba(255, 165, 2, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 500;
}

.ai-success {
  color: var(--accent-cyan);
  background: rgba(0, 245, 212, 0.04);
  border-left: 4px solid rgba(0, 245, 212, 0.18);
  padding: 8px 12px;
  border-radius: 8px;
}

.title-icon {
  color: var(--accent-cyan);
  font-size: 32px;
}

.version {
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  animation: fadeIn 1.2s ease-out;
  transition: var(--transition-fast);
}

.version:hover {
  background: var(--border-color-hover);
  transform: translateY(-1px);
}

.api-key-status {
  display: flex;
  align-items: center;
  gap: 12px;
  /* Use a single source of truth for header control sizing so all controls match */
  --header-control-size: 44px;
  --header-control-gap: 12px;
  height: var(--header-control-size); /* Consistent height for alignment */
  min-height: var(--header-control-size);
  box-sizing: border-box;
}

.status-indicator,
.status-indicator.not-set,
.status-indicator.valid,
.status-indicator.invalid,
div.status-indicator,
.api-key-status .status-indicator {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  /* keep internal padding horizontal only so the parent's fixed height isn't exceeded */
  padding: 0 12px !important;
  height: 100% !important;
  box-sizing: border-box !important;
  border-radius: 8px !important;
  border: 1px solid transparent !important;
  background: rgba(20, 20, 35, 0.2) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  transition: all 0.3s ease !important;
  position: relative !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

.api-key-status .status-indicator:hover {
  background: rgba(20, 20, 35, 0.3) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15) !important;
}

.status-help-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
}

.status-help-btn:hover {
  background: var(--accent-glow);
  color: var(--text-primary);
  border-color: var(--accent-glow);
  box-shadow: 0 0 8px rgba(108, 99, 255, 0.3);
}

.status-help-btn:focus,
.status-help-btn:focus-visible {
  outline: none;
}

.status-help-btn .help-icon {
  font-weight: bold;
  font-family: serif;
}

.status-legend-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  flex-shrink: 0;
}

.status-legend-btn:hover {
  background: var(--accent-cyan);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 245, 212, 0.3);
}

.status-legend-btn:focus,
.status-legend-btn:focus-visible {
  outline: none;
}

.api-info-content {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.status-indicator:hover,
.status-indicator.not-set:hover,
.status-indicator.valid:hover,
.status-indicator.invalid:hover,
div.status-indicator:hover,
.api-key-status .status-indicator:hover {
  background: transparent !important;
  box-shadow: 0 0 10px rgba(108, 99, 255, 0.1) !important;
}

.status-indicator .status-dot,
.status-indicator.not-set .status-dot,
div.status-indicator .status-dot,
.api-key-status .status-indicator .status-dot {
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: var(--text-muted) !important;
  transition: all 0.3s ease !important;
  animation: statusPulse 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--text-muted) !important;
  position: relative;
}
.status-indicator .status-dot.valid,
.status-indicator.valid .status-dot,
div.status-indicator.valid .status-dot { 
  background: #39ff14 !important; /* Bright green */
  box-shadow: 0 0 10px #39ff14 !important;
  animation: statusPulse 2s ease-in-out infinite;
}

.status-indicator.valid {
  border-color: rgba(57, 255, 20, 0.3) !important;
}
.status-indicator .status-dot.invalid,
.status-indicator.invalid .status-dot,
div.status-indicator.invalid .status-dot,
.status-indicator.not-set .status-dot { 
  background: #ff4757 !important; /* Red */
  box-shadow: 0 0 10px #ff4757 !important;
  animation: statusPulse 2s ease-in-out infinite;
}

.status-indicator.invalid,
.status-indicator.not-set {
  border-color: rgba(255, 71, 87, 0.3) !important;
}

.settings-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  /* ensure this stays a fixed square matching header controls */
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 20px;
  height: var(--header-control-size);
  width: var(--header-control-size);
  display: flex;
  align-items: center;
  justify-content: center;
}
.settings-btn:hover {
  background: var(--accent-glow);
  color: var(--text-primary);
  box-shadow: var(--glow-shadow-medium);
  transform: rotate(90deg);
}

/* Status Help Modal Styles */
.status-help-modal {
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.status-help-section {
  margin-bottom: 24px;
}

.help-section-title {
  color: var(--accent-glow);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-example {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid transparent;
}

.status-example .status-indicator {
  flex-shrink: 0;
  min-width: 180px;
  padding: 8px 12px;
  height: auto;
}

.status-explanation {
  flex: 1;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
}

.status-explanation strong {
  color: var(--text-primary);
}

.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.help-action-btn {
  background: var(--accent-glow);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition-fast);
}

.help-action-btn:hover {
  background: var(--accent-cyan);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.service-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-item {
  padding: 12px;
  background: var(--bg-glass);
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  color: var(--text-secondary);
}

.service-item strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
}

/* Enhanced tooltip styles for status indicators */
.status-tooltip .tooltip-header {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent-cyan);
  border-bottom: 1px solid transparent;
  padding-bottom: 6px;
}

.status-tooltip .tooltip-content {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.status-tooltip .tooltip-tip {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(108, 99, 255, 0.1);
  padding: 6px 8px;
  border-radius: 4px;
  border-left: 3px solid var(--accent-glow);
  margin-top: 8px;
}

/* Status Legend Modal Styles */
.status-legend-modal {
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
}

.legend-section {
  margin-bottom: 24px;
}

.legend-section-title {
  color: var(--accent-glow);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid transparent;
}

.legend-indicator {
  flex-shrink: 0;
}

.legend-content strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
}

.legend-content p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.status-examples {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-example-compact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-glass);
  border-radius: 6px;
  border: 1px solid transparent;
}

.status-badge {
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  min-width: 120px;
  text-align: center;
}

.status-badge.ready { background: rgba(57, 255, 20, 0.1); color: #39ff14; }
.status-badge.not-set { background: rgba(136, 146, 176, 0.1); color: #8892b0; }
.status-badge.tested { background: rgba(0, 245, 212, 0.1); color: var(--accent-cyan); }
.status-badge.failed { background: rgba(255, 71, 87, 0.1); color: #ff4757; }
.status-badge.pending { background: rgba(255, 165, 2, 0.1); color: #ffa502; }
.status-badge.testing { background: rgba(108, 99, 255, 0.1); color: var(--accent-glow); }
.status-badge.pass { background: rgba(57, 255, 20, 0.1); color: #39ff14; }
.status-badge.fail { background: rgba(255, 71, 87, 0.1); color: #ff4757; }

/* Analysis status badges */
.status-badge.ai-warning { background: rgba(255, 165, 2, 0.1); color: #ffa502; }
.status-badge.ai-error { background: rgba(255, 71, 87, 0.1); color: #ff4757; }
.status-badge.ai-unavailable { background: rgba(136, 146, 176, 0.1); color: #8892b0; }

/* Comparison indicators */
.status-badge.positive { background: rgba(57, 255, 20, 0.1); color: #39ff14; }
.status-badge.negative { background: rgba(255, 71, 87, 0.1); color: #ff4757; }
.status-badge.neutral { background: rgba(0, 245, 212, 0.1); color: var(--accent-cyan); }
.status-badge.na { background: rgba(136, 146, 176, 0.1); color: #8892b0; }

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.help-item {
  padding: 12px;
  background: var(--bg-glass);
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  color: var(--text-secondary);
}

.help-item strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
}

/* Better focus outlines for accessibility */
.settings-btn:focus, .btn:focus, .theme-option:focus, .form-control:focus {
  outline: 3px solid rgba(0,123,255,0.18);
  outline-offset: 2px;
}

/* Light theme focus outlines - subtle gray */
[data-theme="light"] .settings-btn:focus, 
[data-theme="light"] .btn:focus, 
[data-theme="light"] .theme-option:focus, 
[data-theme="light"] .form-control:focus,
[data-color-scheme="light"] .settings-btn:focus, 
[data-color-scheme="light"] .btn:focus, 
[data-color-scheme="light"] .theme-option:focus, 
[data-color-scheme="light"] .form-control:focus {
  outline: none;
  outline-offset: 2px;
}

/* Theme picker menu */
.theme-picker { position: relative; display: inline-block; }
.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-glass);
  border: 1px solid transparent;
  padding: 8px;
  border-radius: 8px;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  z-index: 1200;
}
.theme-menu.hidden { display: none; }
.theme-option {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 8px 12px;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.theme-option:hover { background: rgba(108,99,255,0.06); }
.theme-option.active { background: rgba(108,99,255,0.12); color: var(--accent-cyan); }

/* Enhanced Theme Toggle Component */
.theme-toggle-container {
  position: relative;
  display: inline-block;
  height: var(--header-control-size); /* Match consistent height */
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.theme-toggle {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border: 2px solid var(--muted-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--timing-normal) var(--ease-out-quart);
  backdrop-filter: var(--blur-sm) saturate(150%);
  -webkit-backdrop-filter: var(--blur-sm) saturate(150%);
  box-shadow: var(--glass-shadow-sm);
  min-width: 60px;
  user-select: none;
  height: var(--header-control-size); /* Match consistent height */
  min-height: var(--header-control-size);
  justify-content: center;
}

/* Normalize box-sizing and ensure consistent widths for header controls */
*, *::before, *::after { box-sizing: border-box; }

/* Make the API status area flexible but bounded so text doesn't push buttons */
.api-key-status { min-width: 0; max-width: 520px; }
.api-key-status .status-indicator { flex: 1 1 auto; min-width: 0; }
.api-key-status .status-info { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Keep header actions fixed-size to avoid layout shifts */
.header-actions { flex: 0 0 auto; display: flex; gap: var(--header-control-gap); align-items: center; }
.settings-btn { flex: 0 0 var(--header-control-size); }
.theme-toggle-container { flex: 0 0 auto; }

/* Ensure icons don't grow and remain visually centered */
.theme-icon, .settings-icon, .theme-option-icon { display: inline-block; line-height: 1; font-size: 18px; vertical-align: middle; }

/* Ensure status text and labels don't exceed available space vertically */
.status-info, .theme-toggle-label { display: inline-block; vertical-align: middle; line-height: 1; }

/* Small responsive tweak */
@media (max-width: 640px) {
  .api-key-status { max-width: 300px; gap: 8px; }
  .app-title { font-size: 20px; }
}

/* Responsive header control size: keep uniform heights but allow slight reduction on very narrow screens */
@media (max-width: 480px) {
  .api-key-status {
    --header-control-size: 40px;
    max-width: 260px;
    gap: 8px;
  }
  .settings-btn { width: var(--header-control-size); height: var(--header-control-size); }
  .theme-toggle { height: var(--header-control-size); min-height: var(--header-control-size); padding: 0 8px; }
}

.theme-toggle:hover {
  border-color: var(--border-color-hover);
  background: var(--surface-elevated);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-light);
  transform: translateY(-1px);
}

.theme-toggle:focus {
  outline: none;
  border-color: var(--accent-glow);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.3), var(--glass-shadow-md);
}

/* Light theme theme-toggle focus */
[data-theme="light"] .theme-toggle:focus,
[data-color-scheme="light"] .theme-toggle:focus {
  border-color: var(--focus-outline-color, #64748b);
  box-shadow: var(--glass-shadow-md);
}

.theme-toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--muted-border);
  transition: all var(--timing-normal) var(--ease-out-quart);
  overflow: hidden;
  flex: 0 0 auto;
  margin-right: 8px;
  padding: 1px; /* ensure thumb has room and stays within bounds */
}

.theme-toggle-track::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(255, 193, 7, 0.2) 0%, 
    rgba(255, 193, 7, 0.1) 50%, 
    rgba(108, 99, 255, 0.2) 100%);
  opacity: 0;
  transition: opacity var(--timing-normal) ease;
}

.theme-toggle:hover .theme-toggle-track::before {
  opacity: 1;
}

.theme-toggle-thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  /* Use CSS variable for horizontal translation so vertical centering stays consistent */
  --thumb-translate: 0px;
  /* cap translate to track width minus thumb width to avoid overflow */
  /* Assuming track inner width = calc(44px - 4px padding) = 40px; thumb width 18px; max translate = 40 - 18 = 22px */
  --thumb-translate: clamp(0px, var(--thumb-translate), 22px);
  transform: translateX(var(--thumb-translate)) translateY(-50%);
  width: 18px;
  height: 18px;
  background: var(--accent-glow);
  border-radius: 50%;
  transition: transform var(--timing-normal) var(--ease-spring), background var(--timing-normal) ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.theme-icon {
  position: absolute;
  transition: all var(--timing-normal) var(--ease-out-expo);
  font-size: 8px;
  line-height: 1;
}

.theme-icon-sun {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.theme-icon-moon {
  opacity: 0;
  transform: translateY(10px) scale(0.5);
}

/* Dark mode state */
[data-theme="dark"] .theme-toggle-thumb {
  --thumb-translate: 20px; /* shift thumb horizontally while keeping it vertically centered */
  background: var(--accent-cyan);
}

[data-theme="dark"] .theme-icon-sun {
  opacity: 0;
  transform: translateY(-10px) scale(0.5);
}

[data-theme="dark"] .theme-icon-moon {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Auto mode state */
[data-theme="auto"] .theme-toggle-thumb {
  --thumb-translate: 20px;
  background: linear-gradient(45deg, var(--accent-glow), var(--accent-cyan));
  animation: autoThemeGlow 3s ease-in-out infinite;
}

@keyframes autoThemeGlow {
  0%, 100% { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 10px rgba(108, 99, 255, 0.3); }
  50% { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2), 0 0 15px rgba(0, 245, 212, 0.4); }
}

.theme-toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color var(--timing-normal) ease;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.theme-toggle:hover .theme-toggle-label {
  color: var(--text-primary);
}

/* Theme Options Dropdown */
.theme-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-glass-elevated);
  backdrop-filter: var(--blur-lg) saturate(180%);
  -webkit-backdrop-filter: var(--blur-lg) saturate(180%);
  border: 1px solid var(--muted-border);
  border-radius: 12px;
  padding: 8px;
  min-width: 140px;
  box-shadow: var(--glass-shadow-lg), var(--glow-shadow-medium);
  z-index: 1200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all var(--timing-normal) var(--ease-out-expo);
}

.theme-options.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--timing-quick) var(--ease-out-quart);
  font-family: var(--font-family-main);
  font-size: 14px;
  text-align: left;
}

.theme-option:hover {
  background: var(--surface-elevated);
  transform: translateX(2px);
  box-shadow: var(--glass-shadow-sm);
}

.theme-option:focus {
  outline: none;
  background: var(--surface-elevated);
  box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.3);
}

/* Light theme theme-option focus */
[data-theme="light"] .theme-option:focus,
[data-color-scheme="light"] .theme-option:focus {
  box-shadow: none;
}

.theme-option.active {
  background: var(--accent-glow);
  color: white;
  font-weight: 600;
}

.theme-option.active .theme-option-icon {
  animation: activeThemeIcon var(--timing-slow) var(--ease-spring);
}

@keyframes activeThemeIcon {
  0% { transform: scale(1); }
  50% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1); }
}

.theme-option-icon {
  font-size: 16px;
  transition: transform var(--timing-quick) var(--ease-out-back);
}

.theme-option-label {
  font-weight: 500;
  transition: all var(--timing-quick) ease;
}

/* Theme transition animation */
.theme-transitioning {
  transition: all var(--timing-slow) var(--ease-out-expo) !important;
}

.theme-transitioning * {
  transition: all var(--timing-slow) var(--ease-out-expo) !important;
}

/* System preference indicator */
.system-preference-indicator {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  border: 2px solid var(--bg-primary);
  opacity: 0;
  transform: scale(0);
  transition: all var(--timing-normal) var(--ease-spring);
}

[data-theme="auto"] .system-preference-indicator {
  opacity: 1;
  transform: scale(1);
  animation: systemPulse 2s ease-in-out infinite;
}

/* ===== LIGHT THEME UPLOAD SECTION OVERRIDES ===== */
[data-theme="light"] .upload-section,
[data-color-scheme="light"] .upload-section,
.theme-light .upload-section {
  background: linear-gradient(135deg, rgba(241, 245, 249, 0.6) 0%, rgba(248, 250, 252, 0.8) 100%);
}

[data-theme="light"] .upload-section::before,
[data-color-scheme="light"] .upload-section::before,
.theme-light .upload-section::before {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.02) 0%, rgba(30, 64, 175, 0.04) 100%);
  opacity: 1;
}

[data-theme="light"] .upload-zone,
[data-color-scheme="light"] .upload-zone,
.theme-light .upload-zone {
  border: 2px solid rgba(15, 23, 42, 0.1);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.9) 0%, 
    rgba(248, 250, 252, 0.95) 50%,
    rgba(255, 255, 255, 0.9) 100%
  );
  box-shadow: 
    0 8px 32px rgba(15, 23, 42, 0.08),
    0 4px 16px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .upload-zone::before,
[data-color-scheme="light"] .upload-zone::before,
.theme-light .upload-zone::before {
  background: linear-gradient(135deg, 
    rgba(30, 64, 175, 0.02) 0%,
    rgba(30, 64, 175, 0.08) 30%, 
    rgba(255, 255, 255, 0.05) 50%,
    rgba(30, 64, 175, 0.08) 70%,
    rgba(30, 64, 175, 0.02) 100%
  );
}

[data-theme="light"] .upload-zone.drag-over,
[data-theme="light"] .upload-zone:hover,
[data-color-scheme="light"] .upload-zone.drag-over,
[data-color-scheme="light"] .upload-zone:hover,
.theme-light .upload-zone.drag-over,
.theme-light .upload-zone:hover {
  border-color: rgba(30, 64, 175, 0.4);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.95) 0%, 
    rgba(241, 245, 249, 0.9) 30%,
    rgba(30, 64, 175, 0.05) 50%,
    rgba(241, 245, 249, 0.9) 70%,
    rgba(255, 255, 255, 0.95) 100%
  );
  box-shadow: 
    0 16px 48px rgba(15, 23, 42, 0.12),
    0 8px 20px rgba(30, 64, 175, 0.15),
    0 0 25px rgba(30, 64, 175, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(15, 23, 42, 0.08),
    inset 0 0 30px rgba(30, 64, 175, 0.08);
}

[data-theme="light"] .upload-zone.file-dropping,
[data-color-scheme="light"] .upload-zone.file-dropping,
.theme-light .upload-zone.file-dropping {
  border-color: rgba(30, 64, 175, 0.6);
  background: linear-gradient(135deg, 
    rgba(30, 64, 175, 0.1) 0%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(241, 245, 249, 0.95) 100%
  );
  box-shadow: 
    0 20px 60px rgba(15, 23, 42, 0.15),
    0 0 40px rgba(30, 64, 175, 0.25),
    inset 0 0 40px rgba(30, 64, 175, 0.1);
}

[data-theme="light"] .upload-icon,
[data-color-scheme="light"] .upload-icon,
.theme-light .upload-icon {
  color: var(--accent-secondary);
  text-shadow: 0 0 15px rgba(0, 82, 163, 0.4), 0 0 30px rgba(0, 82, 163, 0.2);
  filter: drop-shadow(0 4px 8px rgba(0, 82, 163, 0.2));
}

[data-theme="light"] .upload-zone:hover .upload-icon,
[data-color-scheme="light"] .upload-zone:hover .upload-icon,
.theme-light .upload-zone:hover .upload-icon {
  text-shadow: 0 0 20px rgba(0, 82, 163, 0.6), 0 0 40px rgba(0, 82, 163, 0.3);
  filter: drop-shadow(0 6px 12px rgba(0, 82, 163, 0.3));
}

[data-theme="light"] .upload-zone.drag-over .upload-icon,
[data-color-scheme="light"] .upload-zone.drag-over .upload-icon,
.theme-light .upload-zone.drag-over .upload-icon {
  color: var(--accent-primary);
  text-shadow: 0 0 25px rgba(30, 64, 175, 0.8), 0 0 50px rgba(30, 64, 175, 0.4);
}

[data-theme="light"] .upload-title,
[data-color-scheme="light"] .upload-title,
.theme-light .upload-title {
  color: var(--text-primary);
  text-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .upload-subtitle,
[data-color-scheme="light"] .upload-subtitle,
.theme-light .upload-subtitle {
  color: var(--text-secondary);
  text-shadow: 0 1px 4px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .requirement,
[data-color-scheme="light"] .requirement,
.theme-light .requirement {
  background: linear-gradient(135deg, rgba(241, 245, 249, 0.9), rgba(248, 250, 252, 0.95));
  color: var(--text-secondary);
  border: 1px solid rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Light theme progress bar */
[data-theme="light"] .progress-bar,
[data-color-scheme="light"] .progress-bar,
.theme-light .progress-bar {
  background: rgba(15, 23, 42, 0.1);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.2);
}

[data-theme="light"] .progress-fill,
[data-color-scheme="light"] .progress-fill,
.theme-light .progress-fill {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  box-shadow: 0 0 8px rgba(30, 64, 175, 0.3);
}

[data-theme="light"] .progress-text,
[data-color-scheme="light"] .progress-text,
.theme-light .progress-text {
  color: var(--accent-primary);
}

/* Light theme file info */
[data-theme="light"] .file-info,
[data-color-scheme="light"] .file-info,
.theme-light .file-info {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 
    0 2px 8px rgba(15, 23, 42, 0.08), 
    0 1px 3px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .file-info::before,
[data-color-scheme="light"] .file-info::before,
.theme-light .file-info::before {
  background: linear-gradient(
    45deg,
    rgba(30, 64, 175, 0.02) 0%,
    transparent 50%,
    rgba(0, 82, 163, 0.01) 100%
  );
}

[data-theme="light"] .file-info:hover,
[data-color-scheme="light"] .file-info:hover,
.theme-light .file-info:hover {
  background: rgba(248, 250, 252, 1);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 
    0 4px 16px rgba(15, 23, 42, 0.12), 
    0 2px 6px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(30, 64, 175, 0.1);
}

[data-theme="light"] .file-name,
[data-color-scheme="light"] .file-name,
.theme-light .file-name {
  color: var(--text-primary);
}

[data-theme="light"] .file-meta,
[data-color-scheme="light"] .file-meta,
.theme-light .file-meta {
  color: var(--text-secondary);
}

/* Light theme error message */
[data-theme="light"] .error-message,
[data-color-scheme="light"] .error-message,
.theme-light .error-message {
  color: var(--status-error);
  background: var(--status-error-bg);
  border: 1px solid rgba(185, 28, 28, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
}

/* ===== ACCESSIBILITY UTILITIES ===== */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
  position: static !important;
  width: auto !important;
  height: auto !important;
  padding: 8px 12px !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  background: var(--bg-primary) !important;
  color: var(--text-primary) !important;
  border: 2px solid var(--accent-primary) !important;
  border-radius: 4px !important;
  z-index: 9999 !important;
}

/* Enhanced focus indicators for better accessibility */
*:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Remove focus outlines in light theme */
[data-theme="light"] *:focus-visible,
[data-color-scheme="light"] *:focus-visible {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .upload-zone {
    border-width: 3px;
    border-color: var(--text-primary);
  }
  
  .upload-zone:focus-visible,
  .upload-zone:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.3);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .upload-zone,
  .upload-icon,
  .progress-fill,
  .btn {
    animation: none !important;
    transition: none !important;
  }
  
  .upload-zone:hover {
    transform: none !important;
  }
}

@keyframes systemPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.upload-section {
  padding: 64px 24px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, rgba(26, 54, 93, 0.3) 0%, rgba(45, 90, 135, 0.3) 100%);
  position: relative;
}

.upload-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a365d 0%, #2d5a87 100%);
  opacity: 0.1;
  pointer-events: none;
}

.upload-container {
  max-width: 720px;
  width: 100%;
  position: relative;
  z-index: 2;
}

.upload-zone {
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 56px 32px;
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.4) 0%, 
    rgba(45, 90, 135, 0.3) 50%,
    rgba(26, 54, 93, 0.4) 100%
  );
  position: relative;
  cursor: pointer;
  transition: all var(--timing-normal) var(--ease-out-quart),
              transform var(--timing-quick) var(--ease-spring);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(26, 54, 93, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  animation: subtleFloat 8s ease-in-out infinite;
  overflow: hidden;
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  will-change: transform, background, border-color, box-shadow;
  /* Enhanced accessibility */
  outline: none; /* Custom focus handling */
  min-height: 44px; /* WCAG minimum touch target */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Enhanced focus state for keyboard navigation */
.upload-zone:focus-visible {
  border-color: var(--accent-primary);
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(26, 54, 93, 0.3),
    0 0 0 4px rgba(var(--accent-rgb), 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Light theme upload-zone focus */
[data-theme="light"] .upload-zone:focus-visible,
[data-color-scheme="light"] .upload-zone:focus-visible {
  border-color: var(--focus-outline-color, #64748b);
  outline: none;
  outline-offset: 2px;
  box-shadow: none;
}

/* Improved accessibility states */
.upload-zone[data-upload-state="empty"]:focus-visible,
.upload-zone[data-upload-state="empty"]:hover {
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.6) 0%, 
    rgba(45, 90, 135, 0.5) 30%,
    rgba(31, 245, 212, 0.1) 50%,
    rgba(45, 90, 135, 0.5) 70%,
    rgba(26, 54, 93, 0.6) 100%
  );
}

/* Active state for better feedback */
.upload-zone:active {
  transform: scale(0.98) translateY(0);
  transition: transform var(--timing-instant) var(--ease-out-quart);
}

/* Enhanced keyboard interaction */
.upload-zone[role="button"]:focus-visible .upload-content {
  transform: scale(1.02);
}

/* Ensure content is accessible to screen readers */
.upload-zone[aria-describedby] .upload-content {
  pointer-events: none; /* Let parent handle interactions */
}

.upload-zone::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.05) 0%,
    rgba(31, 245, 212, 0.08) 30%, 
    rgba(255, 255, 255, 0.02) 50%,
    rgba(31, 245, 212, 0.08) 70%,
    rgba(255, 255, 255, 0.05) 100%
  );
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--timing-normal) var(--ease-out-expo);
  z-index: -1;
}

.upload-zone::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(31, 245, 212, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all var(--timing-slow) var(--ease-out-expo);
  pointer-events: none;
  z-index: 0;
}

.upload-zone.drag-over::before,
.upload-zone:hover::before {
  opacity: 1;
  animation: shimmer 2s ease-in-out infinite;
}

.upload-zone.drag-over, .upload-zone:hover {
  border-color: rgba(31, 245, 212, 0.6);
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.6) 0%, 
    rgba(45, 90, 135, 0.5) 30%,
    rgba(31, 245, 212, 0.1) 50%,
    rgba(45, 90, 135, 0.5) 70%,
    rgba(26, 54, 93, 0.6) 100%
  );
  transform: scale(1.02) translateY(var(--card-hover-lift));
  box-shadow: 
    0 16px 48px rgba(0, 0, 0, 0.25),
    0 8px 20px rgba(26, 54, 93, 0.4),
    0 0 25px rgba(31, 245, 212, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    inset 0 0 30px rgba(31, 245, 212, 0.1);
  backdrop-filter: blur(16px) saturate(200%) brightness(110%);
  -webkit-backdrop-filter: blur(16px) saturate(200%) brightness(110%);
  animation: morphShape var(--timing-deliberate) ease-in-out,
             subtleFloat 8s ease-in-out infinite;
}

.upload-zone:hover::after {
  width: 300px;
  height: 300px;
}

.upload-zone:active {
  transform: scale(0.98) translateY(0);
  transition: transform var(--timing-instant) var(--ease-out-quart);
}

.upload-zone.file-dropping {
  border-color: rgba(31, 245, 212, 0.8);
  background: linear-gradient(135deg, 
    rgba(31, 245, 212, 0.2) 0%,
    rgba(26, 54, 93, 0.7) 50%,
    rgba(45, 90, 135, 0.6) 100%
  );
  animation: heartbeat var(--timing-normal) ease-in-out infinite;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.3),
    0 0 40px rgba(31, 245, 212, 0.4),
    inset 0 0 40px rgba(31, 245, 212, 0.15);
}

.upload-icon {
  font-size: 56px;
  margin-bottom: 16px;
  color: var(--accent-cyan);
  text-shadow: 0 0 15px rgba(31, 245, 212, 0.8), 0 0 30px rgba(31, 245, 212, 0.4);
  transition: all var(--timing-normal) var(--ease-spring);
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 4px 8px rgba(31, 245, 212, 0.3));
}

.upload-zone:hover .upload-icon {
  transform: scale(1.1) rotate(-10deg);
  animation: heartbeat var(--timing-slow) ease-in-out;
  text-shadow: 0 0 20px rgba(31, 245, 212, 1), 0 0 40px rgba(31, 245, 212, 0.6);
  filter: drop-shadow(0 6px 12px rgba(31, 245, 212, 0.5));
}

.upload-zone.drag-over .upload-icon {
  transform: scale(1.15) rotate(10deg);
  color: #ffffff;
  text-shadow: 0 0 25px rgba(31, 245, 212, 1), 0 0 50px rgba(31, 245, 212, 0.8);
  animation: pulse 1s ease-in-out infinite;
}

.upload-title {
  font-family: var(--font-family-heading);
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
  margin: 0 0 8px 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
}

.upload-subtitle {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 24px 0;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.file-requirements {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
  position: relative;
  z-index: 1;
}

.requirement {
  background: linear-gradient(135deg, rgba(26, 54, 93, 0.8), rgba(45, 90, 135, 0.8));
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.file-requirements {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.requirement {
  background: var(--border-color);
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  /* Enhanced accessibility for screen readers */
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Ensure file input is accessible when upload zone is focused */
.upload-zone:focus-within .file-input {
  opacity: 0.01; /* Slightly visible for screen readers but invisible to users */
}

.error-message {
  color: var(--accent-magenta);
  margin-top: 10px;
  font-size: 14px;
  text-align: center;
}

.upload-progress {
  margin-top: 24px;
  opacity: 0;
  transform: translateY(10px);
  transition: all .3s;
}
.upload-progress.visible { opacity: 1; transform: translateY(0); }

.progress-bar {
  height: 8px;
  background: var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-glow), var(--accent-cyan));
  width: 0%;
  transition: width .4s;
  box-shadow: 0 0 8px var(--accent-cyan);
}

.progress-text {
  text-align: center;
  margin-top: 12px;
  color: var(--accent-cyan);
  font-weight: 600;
}

.file-info {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--muted-border);
  border-radius: 12px;
  text-align: left;
  backdrop-filter: var(--blur-md) saturate(180%);
  -webkit-backdrop-filter: var(--blur-md) saturate(180%);
  box-shadow: var(--glass-shadow-sm);
  transition: var(--transition-glass);
  position: relative;
  overflow: hidden;
}

.file-info::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    45deg,
    rgba(108, 99, 255, 0.03) 0%,
    transparent 50%,
    rgba(0, 245, 212, 0.02) 100%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.file-info:hover {
  background: var(--card-bg-hover);
  border-color: var(--muted-border-hover);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-light);
  transform: translateY(-1px);
}

.file-info:hover::before {
  opacity: 1;
}

.file-name {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.file-meta {
  display: flex;
  gap: 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.file-actions { display: flex; gap: 12px; }

.results-section {
  padding: 32px 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  background: linear-gradient(135deg, rgba(26, 54, 93, 0.2) 0%, rgba(45, 90, 135, 0.15) 100%);
  border-radius: 16px;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(26, 54, 93, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  margin-top: 24px;
  position: relative;
}

.results-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(31, 245, 212, 0.5), transparent);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 16px;
}
.results-header h2 {
  font-family: var(--font-family-heading);
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(31, 245, 212, 0.3);
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Enhanced panel animations with advanced glassmorphism */
.analysis-panel, .comparison-panel {
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.4) 0%, 
    rgba(45, 90, 135, 0.3) 50%,
    rgba(26, 54, 93, 0.4) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  backdrop-filter: blur(12px) saturate(180%) brightness(110%);
  -webkit-backdrop-filter: blur(12px) saturate(180%) brightness(110%);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(26, 54, 93, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  transition: all var(--timing-normal) var(--ease-out-quart),
              transform var(--timing-quick) var(--ease-spring);
  position: relative;
  overflow: hidden;
  will-change: transform, box-shadow, background-color;
  animation: slideInUp var(--timing-slow) var(--ease-out-expo);
}

.analysis-panel:nth-child(1) {
  animation-delay: 0.1s;
  animation-fill-mode: both;
}

.analysis-panel:nth-child(2) {
  animation-delay: 0.2s;
  animation-fill-mode: both;
}

.comparison-panel {
  animation-delay: 0.3s;
  animation-fill-mode: both;
  grid-column: 1 / -1;
}

.analysis-panel::before, .comparison-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(31, 245, 212, 0.6), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.analysis-panel::after, .comparison-panel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(108, 99, 255, 0.02) 0%,
    rgba(0, 245, 212, 0.01) 25%,
    transparent 50%,
    rgba(255, 0, 255, 0.01) 75%,
    rgba(108, 99, 255, 0.02) 100%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
}

.analysis-panel:hover, .comparison-panel:hover {
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.6) 0%, 
    rgba(45, 90, 135, 0.5) 30%,
    rgba(31, 245, 212, 0.1) 50%,
    rgba(45, 90, 135, 0.5) 70%,
    rgba(26, 54, 93, 0.6) 100%
  );
  border-color: rgba(31, 245, 212, 0.4);
  box-shadow: 
    0 16px 48px rgba(0, 0, 0, 0.25),
    0 8px 20px rgba(26, 54, 93, 0.4),
    0 0 25px rgba(31, 245, 212, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  transform: translateY(-4px) scale(1.02);
}

.analysis-panel:hover::before, .comparison-panel:hover::before {
  opacity: 1;
  animation: shimmer 2s ease-in-out infinite;
}

.analysis-panel:hover::after, .comparison-panel:hover::after {
  opacity: 1;
}

.panel-header {
  background: linear-gradient(135deg, rgba(26, 54, 93, 0.3), rgba(45, 90, 135, 0.2));
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-family: var(--font-family-heading);
  font-weight: 600;
  font-size: 20px;
  color: var(--text-primary);
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0;
}

.panel-content { padding: 24px; }

.metric-card {
  background: var(--surface);
  backdrop-filter: var(--blur-md) saturate(180%) brightness(110%);
  -webkit-backdrop-filter: var(--blur-md) saturate(180%) brightness(110%);
  border: 1px solid var(--muted-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
  transition: all var(--timing-normal) var(--ease-out-quart),
              transform var(--timing-quick) var(--ease-out-expo);
  box-shadow: var(--glass-shadow-sm);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  will-change: transform, box-shadow, background-color;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(0, 245, 212, 0.08) 0%,
    transparent 30%,
    transparent 70%,
    rgba(108, 99, 255, 0.08) 100%
  );
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--timing-normal) var(--ease-out-expo);
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(0, 245, 212, 0.3) 0%, transparent 70%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all var(--timing-slow) var(--ease-out-expo);
  pointer-events: none;
}

.metric-card:hover {
  transform: scale(var(--card-hover-scale)) translateY(var(--card-hover-lift));
  border-color: var(--accent-cyan);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-light);
  backdrop-filter: var(--blur-lg) saturate(200%) brightness(120%);
  -webkit-backdrop-filter: var(--blur-lg) saturate(200%) brightness(120%);
  background: var(--card-bg-hover);
  animation: morphShape var(--timing-deliberate) ease-in-out;
}

.metric-card:hover::after {
  width: 200px;
  height: 200px;
}

.metric-card:active {
  transform: scale(0.98) translateY(var(--card-active-lift));
  transition: transform var(--timing-instant) var(--ease-out-quart);
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-label {
  font-size: 14px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

.metric-value {
  font-family: var(--font-family-heading);
  font-size: 36px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0,123,255,0.12);
}

.complexity-title {
  color: var(--text-primary);
  margin: 0 0 16px;
  text-align: center;
  font-weight: 600;
  font-family: var(--font-family-heading);
}

.complexity-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.complexity-card {
  background: var(--card-bg);
  backdrop-filter: var(--blur-md) saturate(170%) brightness(105%);
  -webkit-backdrop-filter: var(--blur-md) saturate(170%) brightness(105%);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: all var(--timing-normal) var(--ease-out-quart),
              transform var(--timing-quick) var(--ease-spring);
  box-shadow: var(--glass-shadow-sm);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  will-change: transform, box-shadow, background-color;
}

.complexity-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(108, 99, 255, 0.12) 0%,
    transparent 50%,
    rgba(255, 0, 255, 0.08) 100%
  );
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--timing-normal) var(--ease-out-expo);
}

.complexity-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-glow), var(--accent-magenta));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--timing-normal) var(--ease-out-expo);
}

.complexity-card:hover {
  background: var(--card-bg-hover);
  backdrop-filter: var(--blur-lg) saturate(190%) brightness(115%);
  -webkit-backdrop-filter: var(--blur-lg) saturate(190%) brightness(115%);
  border-color: var(--accent-glow);
  transform: translateY(var(--card-hover-lift)) rotateX(5deg);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-medium);
  animation: bounceIn var(--timing-slow) var(--ease-spring);
}

.complexity-card:hover::before {
  opacity: 1;
}

.complexity-card:hover::after {
  transform: scaleX(1);
}

.complexity-card:active {
  transform: translateY(0) rotateX(0deg) scale(0.97);
  transition: transform var(--timing-instant) var(--ease-out-quart);
}

.complexity-formula {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: var(--accent-glow);
  margin-bottom: 8px;
}

.complexity-value {
  font-family: var(--font-family-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.complexity-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.comparison-panel { grid-column: 1/-1; }

.comparison-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.summary-item {
  background: var(--surface);
  backdrop-filter: var(--blur-sm) saturate(160%) brightness(108%);
  -webkit-backdrop-filter: var(--blur-sm) saturate(160%) brightness(108%);
  border: 1px solid var(--muted-border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  transition: var(--transition-glass);
  box-shadow: var(--glass-shadow-sm);
  position: relative;
  overflow: hidden;
}

.summary-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 0, 255, 0.08) 0%,
    transparent 50%,
    rgba(108, 99, 255, 0.08) 100%
  );
  border-radius: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.summary-item:hover {
  background: var(--card-bg-hover);
  backdrop-filter: var(--blur-md) saturate(180%) brightness(115%);
  -webkit-backdrop-filter: var(--blur-md) saturate(180%) brightness(115%);
  border-color: var(--muted-border-hover);
  transform: translateY(-3px);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-light);
}

.summary-item:hover::before {
  opacity: 1;
}

.summary-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.summary-value {
  font-family: var(--font-family-heading);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-magenta);
  text-shadow: 0 0 8px var(--accent-magenta);
}

.difference-details h4, .recommendation-section h4 {
  font-family: var(--font-family-heading);
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 12px;
  border-bottom: 1px solid transparent;
  padding-bottom: 8px;
}

.differences-list, .recommendations {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.difference-item, .recommendation-item {
  padding: 12px 16px;
  background: var(--surface);
  border-radius: 8px;
  border-left: 4px solid var(--accent-magenta);
  color: var(--text-primary);
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.recommendation-item {
  border-left-color: var(--accent-cyan);
}

/* Enhanced button animations with advanced glassmorphism */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text-primary);
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  font-family: var(--font-family-main);
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: all var(--timing-normal) var(--ease-out-quart),
              transform var(--timing-quick) var(--ease-out-expo);
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--blur-sm) saturate(180%);
  -webkit-backdrop-filter: var(--blur-sm) saturate(180%);
  box-shadow: var(--glass-shadow-sm);
  --mouse-x: 50%;
  --mouse-y: 50%;
  transform-origin: center;
  will-change: transform, box-shadow, background-color;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  transition: left var(--timing-deliberate) var(--ease-out-expo);
  z-index: 1;
}

.btn::after {
  content: '';
  position: absolute;
  top: var(--mouse-y);
  left: var(--mouse-x);
  width: 3px;
  height: 3px;
  background: var(--accent-cyan);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: orbitalRotation 3s linear infinite;
  transition: opacity var(--timing-normal) ease, 
              top var(--timing-instant) ease, 
              left var(--timing-instant) ease;
  z-index: 2;
}

/* Ripple effect for button presses */
.btn-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  animation: rippleEffect var(--timing-deliberate) var(--ease-out-expo);
  z-index: 0;
}

.btn:hover {
  transform: translateY(var(--card-hover-lift)) scale(var(--button-hover-scale));
  background: var(--surface-elevated);
  border-color: var(--border-color-hover);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-light);
  backdrop-filter: var(--blur-md) saturate(200%) brightness(120%);
  -webkit-backdrop-filter: var(--blur-md) saturate(200%) brightness(120%);
}

.btn:active {
  transform: translateY(var(--card-active-lift)) scale(var(--button-press-scale));
  transition: transform var(--timing-instant) var(--ease-out-quart);
}

.btn:focus {
  outline: none;
  transform: scale(var(--button-focus-scale));
  box-shadow: var(--glass-shadow-lg), 
              var(--glow-shadow-medium),
              0 0 0 3px rgba(108, 99, 255, 0.3);
}

/* Light theme button focus */
[data-theme="light"] .btn:focus,
[data-color-scheme="light"] .btn:focus {
  box-shadow: var(--glass-shadow-lg);
}

/* Enhanced focus-visible for better keyboard accessibility */
.btn:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  transform: scale(var(--button-focus-scale));
  box-shadow: var(--glass-shadow-lg), 
              var(--glow-shadow-medium),
              0 0 0 3px rgba(var(--accent-rgb), 0.4);
}

/* Light theme focus-visible */
[data-theme="light"] .btn:focus-visible,
[data-color-scheme="light"] .btn:focus-visible {
  outline: none;
  outline-offset: 2px;
  box-shadow: var(--glass-shadow-lg);
}

/* Ensure buttons meet minimum touch target size */
.btn {
  min-height: 44px;
  min-width: 44px;
}

/* Enhanced disabled state accessibility */
.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  box-shadow: none;
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--muted-border);
}

.btn:disabled::before,
.btn[disabled]::before,
.btn:disabled::after,
.btn[disabled]::after {
  display: none;
}

.btn:hover::before {
  left: 100%;
}

.btn:hover::after {
  opacity: 1;
}

.btn--primary {
  background: var(--accent-glow);
  color: #fff;
  border-color: var(--accent-glow);
  box-shadow: var(--glass-shadow-sm), 0 0 15px rgba(108, 99, 255, 0.4);
  backdrop-filter: var(--blur-sm) saturate(150%);
  -webkit-backdrop-filter: var(--blur-sm) saturate(150%);
  position: relative;
}

.btn--primary::before {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.btn--primary:hover {
  box-shadow: var(--glow-shadow-medium), 0 0 20px rgba(108, 99, 255, 0.5);
  background: linear-gradient(135deg, var(--accent-glow), #8a7fff);
  animation: heartbeat var(--timing-deliberate) ease-in-out;
}

.btn--primary:active {
  background: #5a52e6;
  box-shadow: var(--glass-shadow-sm), 0 0 10px rgba(108, 99, 255, 0.6);
}

.btn#analyzeBtn {
  animation: pulseGlow 3s infinite;
}

.btn#analyzeBtn:hover {
  animation: pulseGlow 1.5s infinite, heartbeat var(--timing-deliberate) ease-in-out;
}

.btn--outline {
  background: transparent;
  color: var(--accent-cyan);
  border-color: var(--muted-border);
  position: relative;
}

.btn--outline::before {
  background: linear-gradient(90deg, transparent, rgba(0, 245, 212, 0.2), transparent);
}

.btn--outline:hover {
  background: rgba(0, 245, 212, 0.06);
  box-shadow: 0 0 12px rgba(0, 245, 212, 0.18), 0 0 8px rgba(0, 245, 212, 0.3);
  border-color: var(--accent-cyan);
  color: #fff;
  text-shadow: 0 0 10px var(--accent-cyan);
}

.btn--outline:active {
  background: rgba(0, 245, 212, 0.12);
  transform: translateY(0) scale(0.98);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--muted-border);
}

.btn--secondary:hover {
  background: var(--surface-elevated);
  border-color: var(--accent-magenta);
  box-shadow: var(--glass-shadow-md), 0 0 15px rgba(255, 0, 255, 0.15);
}

.btn--secondary:active {
  background: var(--surface);
  border-color: var(--accent-magenta);
}

.btn--sm {
  padding: 8px 16px;
  font-size: 14px;
  transform-origin: center;
}

.btn--sm:hover {
  transform: translateY(-1px) scale(1.05);
}

.btn--sm:active {
  transform: scale(0.95);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-glass-elevated);
  backdrop-filter: var(--blur-xl) saturate(180%) brightness(95%);
  -webkit-backdrop-filter: var(--blur-xl) saturate(180%) brightness(95%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: opacity .3s;
}

.loading-content {
  background: var(--card-bg);
  backdrop-filter: var(--blur-lg) saturate(160%) brightness(110%);
  -webkit-backdrop-filter: var(--blur-lg) saturate(160%) brightness(110%);
  border: 1px solid var(--muted-border);
  border-radius: 20px;
  padding: 40px;
  text-align: center;
  box-shadow: var(--glass-shadow-lg), var(--glow-shadow-medium);
  min-width: 300px;
}

/* Enhanced loading spinner with orbital elements */
.loading-spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 6px solid transparent;
  border-top-color: var(--accent-cyan);
  border-left-color: var(--accent-glow);
  animation: rotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  margin: 0 auto 20px;
  position: relative;
}

.loading-spinner::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent-magenta);
  animation: rotate 2s cubic-bezier(0.5, 0, 0.5, 1) infinite reverse;
}

.loading-spinner::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: glowPulse 1.5s ease-in-out infinite;
}

.loading-text {
  color: var(--accent-cyan);
  font-weight: 700;
  font-size: 18px;
  text-shadow: 0 0 5px var(--accent-cyan);
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .results-grid { grid-template-columns: 1fr; }
  .upload-container { max-width: 100%; }
  .header-content { flex-direction: column; gap: 16px; }
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: var(--blur-md) saturate(150%);
  -webkit-backdrop-filter: var(--blur-md) saturate(150%);
  transition: var(--transition-smooth);
}

.modal-content {
  position: relative;
  background: var(--bg-glass-elevated);
  border: 1px solid transparent;
  border-radius: 16px;
  backdrop-filter: var(--blur-xl) saturate(180%) brightness(110%);
  -webkit-backdrop-filter: var(--blur-xl) saturate(180%) brightness(110%);
  max-width: 600px;
  width: 90%;
  padding: 24px;
  box-shadow: var(--glass-shadow-xl), var(--glow-shadow-medium);
  animation: fadeIn 0.5s ease-out;
  transition: var(--transition-glass);
}

.modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(108, 99, 255, 0.05) 0%,
    rgba(0, 245, 212, 0.02) 25%,
    transparent 50%,
    rgba(255, 0, 255, 0.02) 75%,
    rgba(108, 99, 255, 0.05) 100%
  );
  border-radius: 16px;
  pointer-events: none;
  z-index: -1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.modal-title {
  font-family: var(--font-family-heading);
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 32px;
  cursor: pointer;
  transition: var(--transition-fast);
}
.modal-close:hover {
  color: var(--accent-magenta);
  transform: rotate(90deg);
}

.modal-body .form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--timing-normal) var(--ease-out-quart),
              transform var(--timing-quick) var(--ease-out-expo);
  font-family: var(--font-family-main);
  position: relative;
  will-change: transform, border-color, box-shadow;
}

.form-control:hover {
  border-color: var(--border-color-hover);
  transform: scale(var(--input-focus-scale));
  box-shadow: 0 2px 8px rgba(108, 99, 255, 0.1);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-glow);
  transform: scale(var(--input-focus-scale));
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.3), 
              inset 0 0 5px rgba(108, 99, 255, 0.2),
              0 4px 12px rgba(108, 99, 255, 0.15);
  animation: textGlow var(--timing-slow) ease-in-out;
}

/* Light theme form-control focus */
[data-theme="light"] .form-control:focus,
[data-color-scheme="light"] .form-control:focus {
  border-color: var(--focus-outline-color, #64748b);
  box-shadow: none;
}

.form-control:invalid {
  border-color: #ff4757;
  animation: var(--input-invalid-shake);
  box-shadow: 0 0 0 2px rgba(255, 71, 87, 0.2);
}

.form-control:valid {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(0, 245, 212, 0.1);
}

.form-control::placeholder {
  color: var(--text-muted);
  transition: color var(--timing-normal) ease;
}

.form-control:focus::placeholder {
  color: transparent;
  transform: translateY(-20px);
}

.api-key-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.key-toggle-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: var(--transition-fast);
}
.key-toggle-btn:hover {
  color: var(--accent-glow);
  border-color: var(--accent-glow);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  margin-top: 24px;
}

.security-notice {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(0, 245, 212, .05);
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-size: 14px;
}
.notice-icon { font-size: 20px; color: var(--accent-cyan); }

.status-indicator .status-text { 
  font-weight: 700; 
  color: var(--text-primary); 
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.1);
}
.status-indicator .status-info { 
  display: flex; 
  flex-direction: column; 
  text-align: left; 
}
/* Status text styling */
.status-text {
  font-weight: 500;
  transition: color 0.3s ease;
}

.status-indicator.valid .status-text {
  color: #39ff14; /* Bright green */
}

.status-indicator.invalid .status-text,
.status-indicator.not-set .status-text {
  color: #ff4757; /* Red */
}

/* Status detail styling */
.status-detail { 
  font-size: 12px; 
  color: var(--text-muted);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
  transition: color 0.3s ease;
}

.status-indicator.valid .status-detail {
  color: rgba(57, 255, 20, 0.7);
}

.status-indicator.invalid .status-detail,
.status-indicator.not-set .status-detail {
  color: rgba(255, 71, 87, 0.7);
}

/* Ensure header API status text blends seamlessly */
.api-key-status .status-info {
  border: 1px solid transparent !important;
  background: transparent !important;
}

/* Enhanced Glassmorphic Footer - Mirrors Header Aesthetic */
.footer {
  position: relative;
  /* Let the footer push to the bottom in flex layouts */
  margin-top: auto;
  padding: 48px 0 24px;
  font-size: 14px;
  z-index: 100;
  /* Ensure footer doesn't interfere with dropdown */
  isolation: isolate;
  
  /* Glassmorphic Background - Theme Adaptive */
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.9) 0%, 
    rgba(45, 90, 135, 0.8) 100%
  );
  
  /* Enhanced Backdrop Blur for Glass Effect */
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  
  /* Refined Border and Shadow System */
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 
    0 -8px 32px rgba(0, 0, 0, 0.15),
    0 -4px 16px rgba(26, 54, 93, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
    
  /* Smooth Transitions */
  transition: all 350ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Default Dark Theme Colors */
  color: #e2e8f0;
}

/* Ensure sticky behavior when footer is a direct child of the app container */
.app-container > .footer { margin-top: auto; }

/* Glassmorphic Overlay Effect */
.footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.03) 0%,
    rgba(31, 245, 212, 0.06) 25%, 
    rgba(255, 255, 255, 0.02) 50%,
    rgba(31, 245, 212, 0.06) 75%,
    rgba(255, 255, 255, 0.03) 100%
  );
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity 300ms ease;
}

/* Enhanced Hover Effects */
.footer:hover {
  border-top-color: rgba(31, 245, 212, 0.3);
  box-shadow: 
    0 -12px 40px rgba(0, 0, 0, 0.2),
    0 -6px 20px rgba(26, 54, 93, 0.35),
    0 0 25px rgba(31, 245, 212, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.footer:hover::before {
  opacity: 1;
}

/* ===== LIGHT THEME ADAPTATIONS (WCAG AAA COMPLIANT) ===== */
[data-theme="light"] .footer,
[data-color-scheme="light"] .footer,
.theme-light .footer {
  /* Enhanced Glassmorphic Background for Light Theme */
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.95) 0%, 
    rgba(248, 250, 252, 0.9) 100%
  );
  
  /* Enhanced Backdrop Blur */
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  
  /* Light Theme Border and Shadows */
  border-top: 1px solid rgba(15, 23, 42, 0.15);
  box-shadow: 
    0 -8px 32px rgba(15, 23, 42, 0.08),
    0 -4px 16px rgba(15, 23, 42, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
    
  /* WCAG AAA Compliant Text Color */
  color: var(--text-primary); /* #0c1419 - 18.43:1 contrast */
}

/* Light Theme Glassmorphic Overlay */
[data-theme="light"] .footer::before,
[data-color-scheme="light"] .footer::before,
.theme-light .footer::before {
  background: linear-gradient(135deg, 
    rgba(30, 64, 175, 0.02) 0%,    /* Enhanced accent primary */
    rgba(107, 33, 168, 0.03) 25%,  /* Enhanced accent tertiary */
    rgba(255, 255, 255, 0.05) 50%,
    rgba(0, 82, 163, 0.03) 75%,    /* Enhanced accent secondary */
    rgba(30, 64, 175, 0.02) 100%
  );
}

/* Light Theme Hover Effects */
[data-theme="light"] .footer:hover,
[data-color-scheme="light"] .footer:hover,
.theme-light .footer:hover {
  border-top-color: rgba(30, 64, 175, 0.25); /* Enhanced accent primary */
  box-shadow: 
    0 -12px 40px rgba(15, 23, 42, 0.12),
    0 -6px 20px rgba(15, 23, 42, 0.08),
    0 0 25px rgba(30, 64, 175, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

.footer-main {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 32px;
}

.footer-section {
  display: flex;
  flex-direction: column;
}

.footer-brand-title {
  font-family: var(--font-family-heading, 'Orbitron'), monospace;
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px 0;
  line-height: 1.2;
  
  /* Dark Theme Gradient */
  background: linear-gradient(135deg, var(--accent-cyan), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: #ffffff; /* Fallback for unsupported browsers */
  
  /* Enhanced Text Shadow for Dark Theme */
  text-shadow: 0 0 8px rgba(31, 245, 212, 0.3);
  transition: all var(--transition-fast, 0.2s ease);
}

/* Light Theme Brand Title */
[data-theme="light"] .footer-brand-title,
[data-color-scheme="light"] .footer-brand-title,
.theme-light .footer-brand-title {
  /* WCAG AAA Compliant Gradient */
  background: linear-gradient(135deg, var(--accent-primary, #1e40af), var(--accent-tertiary, #6b21a8));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: var(--text-primary, #0c1419); /* WCAG AAA fallback */
  
  /* Light Theme Text Shadow */
  text-shadow: 0 0 4px rgba(30, 64, 175, 0.15);
}

.footer-brand-subtitle {
  font-size: 14px;
  margin: 0 0 16px 0;
  line-height: 1.5;
  color: #94a3b8; /* Dark theme default */
}

/* Light Theme Subtitle */
[data-theme="light"] .footer-brand-subtitle,
[data-color-scheme="light"] .footer-brand-subtitle,
.theme-light .footer-brand-subtitle {
  color: var(--text-secondary, #1e2e38); /* WCAG AAA: 13.85:1 contrast */
}

.footer-copyright {
  font-size: 12px;
  margin: 0;
  color: #64748b; /* Dark theme default */
}

/* Light Theme Copyright */
[data-theme="light"] .footer-copyright,
[data-color-scheme="light"] .footer-copyright,
.theme-light .footer-copyright {
  color: var(--text-muted, #3c4a54); /* WCAG AAA: 9.05:1 contrast */
}

.footer-section-title {
  font-family: var(--font-family-main, 'Rajdhani'), sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #ffffff; /* Dark theme default */
  position: relative;
}

/* Light Theme Section Title */
[data-theme="light"] .footer-section-title,
[data-color-scheme="light"] .footer-section-title,
.theme-light .footer-section-title {
  color: var(--text-primary, #0c1419); /* WCAG AAA: 18.43:1 contrast */
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-link {
  position: relative;
  display: inline-block;
  padding: 8px 0; /* Enhanced touch target */
  min-height: 44px; /* WCAG touch target requirement */
  line-height: 1.6;
  text-decoration: none;
  transition: all var(--transition-fast, 0.2s ease);
  border-radius: 4px; /* For focus outline */
  
  /* Dark Theme Colors */
  color: #cbd5e1;
}

/* Light Theme Link Colors - WCAG AAA Enhanced */
[data-theme="light"] .footer-link,
[data-color-scheme="light"] .footer-link,
.theme-light .footer-link {
  color: var(--text-link, #1346a0); /* WCAG AAA: 8.63:1 contrast */
}

/* Enhanced Hover States */
.footer-link:hover {
  transform: translateX(4px);
  color: var(--accent-cyan, #1ff5d4); /* Dark theme */
  text-shadow: 0 0 8px rgba(31, 245, 212, 0.4);
}

/* Light Theme Hover */
[data-theme="light"] .footer-link:hover,
[data-color-scheme="light"] .footer-link:hover,
.theme-light .footer-link:hover {
  color: var(--text-link-hover, #0f3380); /* WCAG AAA: 10.2:1 contrast */
  text-shadow: 0 0 4px rgba(15, 51, 128, 0.3);
}

/* Enhanced Focus States for Accessibility */
.footer-link:focus-visible {
  outline: 3px solid var(--accent-cyan, #1ff5d4);
  outline-offset: 2px;
  transform: translateX(2px);
}

/* Light Theme Focus */
[data-theme="light"] .footer-link:focus-visible,
[data-color-scheme="light"] .footer-link:focus-visible,
.theme-light .footer-link:focus-visible {
  outline: none;
  outline-offset: 2px;
  background: none;
}

/* Animated Underline Effect */
.footer-link::before {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent-cyan, #1ff5d4);
  transition: width var(--transition-fast, 0.2s ease);
  border-radius: 1px;
}

/* Light Theme Underline */
[data-theme="light"] .footer-link::before,
[data-color-scheme="light"] .footer-link::before,
.theme-light .footer-link::before {
  background: var(--accent-primary, #1e40af);
}

.footer-link:hover::before,
.footer-link:focus-visible::before {
  width: 100%;
}

.footer-social-links {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.social-link-modern {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 44px; /* WCAG touch target */
  border-radius: 8px;
  text-decoration: none;
  transition: all var(--transition-fast, 0.2s ease);
  position: relative;
  
  /* Dark Theme Glassmorphic Background */
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: #e2e8f0;
}

/* Light Theme Social Links */
[data-theme="light"] .social-link-modern,
[data-color-scheme="light"] .social-link-modern,
.theme-light .social-link-modern {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 23, 42, 0.1);
  backdrop-filter: blur(12px);
  color: var(--text-primary, #0c1419); /* WCAG AAA */
}

/* Enhanced Hover Effects */
.social-link-modern:hover {
  background: rgba(31, 245, 212, 0.1);
  border-color: var(--accent-cyan, #1ff5d4);
  color: var(--accent-cyan, #1ff5d4);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(31, 245, 212, 0.15);
}

/* Light Theme Social Hover */
[data-theme="light"] .social-link-modern:hover,
[data-color-scheme="light"] .social-link-modern:hover,
.theme-light .social-link-modern:hover {
  background: rgba(30, 64, 175, 0.1);
  border-color: var(--accent-primary, #1e40af);
  color: var(--accent-primary, #1e40af);
  box-shadow: 0 8px 25px rgba(30, 64, 175, 0.15);
}

/* Focus States for Social Links */
.social-link-modern:focus-visible {
  outline: 3px solid var(--accent-cyan, #1ff5d4);
  outline-offset: 2px;
}

[data-theme="light"] .social-link-modern:focus-visible,
[data-color-scheme="light"] .social-link-modern:focus-visible,
.theme-light .social-link-modern:focus-visible {
  outline: none;
  outline-offset: 2px;
}

.social-icon-svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-fast);
}

.social-link-modern:hover .social-icon-svg {
  transform: scale(1.1);
}

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 32px;
}

/* Light Theme Footer Bottom */
[data-theme="light"] .footer-bottom,
[data-color-scheme="light"] .footer-bottom,
.theme-light .footer-bottom {
  border-top: 1px solid rgba(15, 23, 42, 0.15);
}

.footer-brand-credit {
  display: flex;
  align-items: center;
}

.brand-credit-text {
  font-family: var(--font-family-main, 'Rajdhani'), sans-serif;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  
  /* Dark Theme Gradient */
  background: linear-gradient(135deg, var(--accent-cyan, #1ff5d4), #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: #ffffff; /* Fallback */
}

/* Light Theme Brand Credit */
[data-theme="light"] .brand-credit-text,
[data-color-scheme="light"] .brand-credit-text,
.theme-light .brand-credit-text {
  background: linear-gradient(135deg, var(--accent-primary, #1e40af), var(--accent-tertiary, #6b21a8));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: var(--text-primary, #0c1419); /* WCAG AAA fallback */
}

.footer-version {
  font-size: 14px;
  font-family: var(--font-family-heading, 'Orbitron'), monospace;
  color: #94a3b8; /* Dark theme */
}

/* Light Theme Version */
[data-theme="light"] .footer-version,
[data-color-scheme="light"] .footer-version,
.theme-light .footer-version {
  color: var(--text-secondary, #1e2e38); /* WCAG AAA */
}

/* Responsive Design */
@media (max-width: 768px) {
  .footer-main {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  
  .social-link-modern {
    flex-direction: row;
    justify-content: center;
  }
}

@media (max-width: 1024px) {
  .footer-main {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

/* Remove old footer styles */
.footer-social {
  display: none;
}

.social-link {
  display: none;
}

.social-icon {
  display: none;
}

[title] {
  position: relative;
  cursor: help;
}

/* Enhanced Glassmorphism Utility Classes */
.glass-effect {
  backdrop-filter: var(--blur-md) saturate(180%);
  -webkit-backdrop-filter: var(--blur-md) saturate(180%);
  -moz-backdrop-filter: var(--blur-md) saturate(180%);
  -o-backdrop-filter: var(--blur-md) saturate(180%);
  -ms-backdrop-filter: var(--blur-md) saturate(180%);
  background: var(--card-bg);
  border: 1px solid var(--muted-border);
  box-shadow: var(--glass-shadow-sm);
  transition: var(--transition-glass);
}

.glass-effect-light {
  backdrop-filter: var(--blur-sm) saturate(150%);
  -webkit-backdrop-filter: var(--blur-sm) saturate(150%);
  background: var(--surface);
  border: 1px solid var(--muted-border);
  box-shadow: var(--glass-shadow-sm);
}

.glass-effect-heavy {
  backdrop-filter: var(--blur-xl) saturate(200%) brightness(110%);
  -webkit-backdrop-filter: var(--blur-xl) saturate(200%) brightness(110%);
  background: var(--bg-glass-elevated);
  border: 1px solid var(--muted-border);
  box-shadow: var(--glass-shadow-lg);
}

.glass-hover:hover {
  background: var(--card-bg-hover);
  border-color: var(--muted-border-hover);
  box-shadow: var(--glass-shadow-md), var(--glow-shadow-light);
  backdrop-filter: var(--blur-lg) saturate(200%) brightness(120%);
  -webkit-backdrop-filter: var(--blur-lg) saturate(200%) brightness(120%);
  transform: translateY(-1px);
}

/* Cross-browser backdrop-filter fallbacks */
@supports not (backdrop-filter: blur(1px)) {
  .glass-effect,
  .glass-effect-light,
  .glass-effect-heavy,
  .header,
  .modal-content,
  .analysis-panel,
  .comparison-panel,
  .file-info,
  .upload-zone,
  .btn {
    background: rgba(12, 10, 48, 0.85);
  }
  
  [data-theme="light"] .glass-effect,
  [data-theme="light"] .glass-effect-light,
  [data-theme="light"] .glass-effect-heavy,
  [data-theme="light"] .header,
  [data-theme="light"] .modal-content,
  [data-theme="light"] .analysis-panel,
  [data-theme="light"] .comparison-panel,
  [data-theme="light"] .file-info,
  [data-theme="light"] .upload-zone,
  [data-theme="light"] .btn {
    background: rgba(255, 255, 255, 0.9);
  }
}

/* Firefox-specific optimizations */
@-moz-document url-prefix() {
  .glass-effect,
  .glass-effect-light,
  .glass-effect-heavy,
  .header,
  .modal-content,
  .analysis-panel,
  .comparison-panel,
  .file-info,
  .upload-zone,
  .btn,
  .metric-card,
  .complexity-card,
  .summary-item {
    background: rgba(12, 10, 48, 0.8);
  }
}

/* Safari-specific enhancements */
@supports (-webkit-backdrop-filter: blur(1px)) and (not (backdrop-filter: blur(1px))) {
  .glass-effect,
  .glass-effect-light,
  .glass-effect-heavy,
  .header,
  .modal-content,
  .analysis-panel,
  .comparison-panel,
  .file-info,
  .upload-zone,
  .btn,
  .metric-card,
  .complexity-card,
  .summary-item,
  .loading-overlay {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
  }
}

/* Enhanced responsive glassmorphism */
@media (max-width: 768px) {
  .glass-effect,
  .glass-effect-light,
  .glass-effect-heavy {
    backdrop-filter: var(--blur-sm) saturate(150%);
    -webkit-backdrop-filter: var(--blur-sm) saturate(150%);
  }
  
  .analysis-panel,
  .comparison-panel {
    backdrop-filter: var(--blur-md) saturate(170%);
    -webkit-backdrop-filter: var(--blur-md) saturate(170%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .glass-effect,
  .glass-effect-light,
  .glass-effect-heavy,
  .glass-hover {
    transition: none;
  }
  
  .analysis-panel,
  .comparison-panel,
  .file-info,
  .upload-zone,
  .btn {
    animation: none;
    transition: none;
  }
}

/* Enhanced mobile glassmorphism optimizations */
@media (max-width: 480px) {
  .metric-card,
  .complexity-card,
  .summary-item {
    backdrop-filter: var(--blur-xs) saturate(140%);
    -webkit-backdrop-filter: var(--blur-xs) saturate(140%);
  }
  
  .header,
  .modal-content {
    backdrop-filter: var(--blur-sm) saturate(150%);
    -webkit-backdrop-filter: var(--blur-sm) saturate(150%);
  }
  
  .loading-overlay {
    backdrop-filter: var(--blur-md) saturate(160%);
    -webkit-backdrop-filter: var(--blur-md) saturate(160%);
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .glass-effect,
  .glass-effect-light,
  .glass-effect-heavy,
  .header,
  .modal-content,
  .analysis-panel,
  .comparison-panel,
  .file-info,
  .upload-zone,
  .btn,
  .metric-card,
  .complexity-card,
  .summary-item {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-width: 2px;
  }
}

/* ===== Theme-toggle containment override (final, high-specificity) =====
   Ensures the toggle track/thumb layout cannot be accidentally overridden
   by earlier or user edits. Keeps the thumb vertically centered and
   capped horizontally so it never visually escapes the track. */
.theme-toggle-container, .theme-toggle {
  box-sizing: border-box !important;
}

.theme-toggle {
  /* force horizontal layout and consistent height */
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 0 8px !important;
  height: var(--header-control-size) !important;
  min-height: var(--header-control-size) !important;
  justify-content: flex-start !important;
}

.theme-toggle-track {
  position: relative !important;
  overflow: hidden !important; /* keep thumb visually inside */
  width: 44px !important;
  height: 24px !important;
  padding: 2px !important; /* give thumb breathing room */
  border-radius: 12px !important;
  flex: 0 0 auto !important;
  margin-right: 8px !important;
}

.theme-toggle-thumb {
  position: absolute !important;
  top: 50% !important; /* vertical centering */
  left: 2px !important; /* left inset inside track */
  width: 18px !important;
  height: 18px !important;
  border-radius: 50% !important;
  background: var(--accent-glow) !important;
  transform: translateX(var(--thumb-translate, 0px)) translateY(-50%) !important;
  transition: transform var(--timing-normal) var(--ease-spring), background var(--timing-normal) ease !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
}

/* Ensure dark/auto still drive the thumb variable but as a capped value */
[data-theme="dark"] .theme-toggle-thumb,
[data-theme="auto"] .theme-toggle-thumb {
  --thumb-translate: 20px !important;
}

/* Small safeguard: if any competing rule sets a larger translate, clamp it here */
.theme-toggle-thumb {
  --thumb-translate: clamp(0px, var(--thumb-translate), 22px) !important;
}

/* Header action button for chat */
.header-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--muted-border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  min-height: var(--header-control-size);
  box-sizing: border-box;
}

.header-action-btn:hover {
  background: var(--card-bg-hover);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
  box-shadow: var(--glass-shadow-sm);
}

.header-action-btn:active {
  transform: translateY(0);
}

.header-action-btn .action-icon {
  font-size: 16px;
  color: var(--accent-cyan);
}

.header-action-btn .action-text {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@media (max-width: 768px) {
  .header-action-btn .action-text {
    display: none;
  }
  
  .header-action-btn {
    padding: 8px;
    min-width: var(--header-control-size);
    justify-content: center;
  }
}

/* ===================================
   CHAT WINDOW COMPONENT STYLES
   =================================== */

.chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 400px;
  height: 600px;
  /* Fallback solid background for browsers that don't support backdrop-filter */
  background: #1a365d;
  background: linear-gradient(135deg, 
    rgba(26, 54, 93, 0.95) 0%, 
    rgba(45, 90, 135, 0.9) 50%,
    rgba(26, 54, 93, 0.95) 100%
  );
  backdrop-filter: blur(16px) saturate(150%) brightness(110%);
  -webkit-backdrop-filter: blur(16px) saturate(150%) brightness(110%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  box-shadow: 
    0 16px 48px rgba(0, 0, 0, 0.25),
    0 8px 20px rgba(26, 54, 93, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.1);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: var(--transition-glass);
  transform-origin: bottom right;
}

.chat-container.dragging {
  transition: none;
  box-shadow: var(--glass-shadow-xl), var(--glow-shadow-heavy), 0 0 40px rgba(108, 99, 255, 0.3);
  transform: scale(1.02);
  z-index: 10001;
}

.chat-container.hidden {
  display: none;
}

.chat-container.minimized {
  /* Override inline height set by JS resize so minimized state truly collapses to header */
  height: auto !important;
}

/* Chat Header */
.chat-header {
  background: #1a365d;
  background: linear-gradient(135deg, rgba(26, 54, 93, 0.8), rgba(45, 90, 135, 0.7));
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
  min-height: 60px;
  position: relative;
  transition: background-color 0.2s ease;
}

.chat-header:hover {
  background: var(--card-bg-hover);
}

.chat-header:active,
.chat-container.dragging .chat-header {
  cursor: grabbing;
  background: var(--card-bg-hover);
}

.chat-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
  position: relative;
}

.chat-header-content::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.3;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 1;
}

.chat-header:hover .chat-header-content::before {
  opacity: 0.6;
}

.chat-container.dragging .chat-header-content::before {
  opacity: 0.8;
  background: var(--accent-cyan);
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.chat-icon {
  font-size: 20px;
  color: var(--accent-cyan);
  text-shadow: 0 0 8px var(--accent-cyan);
}

.chat-title-text {
  font-family: var(--font-family-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--muted-border);
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 4px currentColor;
  animation: pulseGlow 2s ease-in-out infinite;
}

.chat-status-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.chat-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 10;
}

.chat-control-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.chat-control-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.05);
}

.chat-control-btn:active {
  transform: scale(0.95);
}

.chat-control-icon {
  font-size: 14px;
}

/* Chat Body */
.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--surface);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--muted-border-hover);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* Chat Messages */
.chat-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  opacity: 1;
  transform: translateY(0);
}

.chat-message.user-message {
  flex-direction: row-reverse;
}

.chat-message.user-message .message-content {
  background: var(--accent-glow);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
}

.chat-message.assistant-message .message-content {
  background: var(--card-bg);
  border: 1px solid var(--muted-border);
  border-radius: 16px 16px 16px 4px;
}

.chat-message.error-message .message-content {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid rgba(255, 71, 87, 0.3);
  border-radius: 12px;
}

.chat-message.system-message {
  justify-content: center;
}

.chat-message.system-message .message-content {
  background: var(--surface);
  border: 1px solid var(--muted-border);
  border-radius: 12px;
  max-width: 90%;
  text-align: center;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--muted-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--glass-shadow-sm);
}

.avatar-icon {
  font-size: 18px;
}

.user-message .avatar-icon {
  color: var(--accent-magenta);
}

.assistant-message .avatar-icon {
  color: var(--accent-cyan);
}

.error-message .avatar-icon {
  color: #ff4757;
}

.message-content {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  transition: var(--transition-fast);
  position: relative;
}

.system-content {
  padding: 16px 20px;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.message-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
}

.message-model {
  font-size: 10px;
  color: var(--accent-cyan);
  background: rgba(31, 245, 212, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(31, 245, 212, 0.2);
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.user-message .message-text {
  color: #ffffff;
}

.error-text {
  color: #ff4757;
}

.message-text code {
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
}

.message-text pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--muted-border);
}

.message-text pre code {
  background: none;
  padding: 0;
}

.message-context {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--muted-border);
}

.message-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition-fast);
}

.chat-message:hover .message-actions {
  opacity: 1;
}

.message-action-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  border: 1px solid var(--muted-border);
  font-size: 12px;
}

.message-action-btn:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
  transform: scale(1.1);
}

/* Typing Indicator */
.typing-message .message-content {
  background: var(--card-bg);
  border: 1px solid var(--muted-border);
  border-radius: 16px 16px 16px 4px;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: typingDots 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0ms; }
.typing-dots span:nth-child(2) { animation-delay: 160ms; }
.typing-dots span:nth-child(3) { animation-delay: 320ms; }

@keyframes typingDots {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.5;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.typing-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

/* Chat Input */
.chat-input-container {
  background: #1a365d;
  background: rgba(26, 54, 93, 0.8);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  padding: 16px 20px;
}

.chat-context-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--muted-border);
  border-radius: 8px;
  font-size: 12px;
}

.context-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.context-icon {
  color: var(--accent-cyan);
}

.context-text {
  font-weight: 500;
}

.chat-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: var(--transition-fast);
  line-height: 1.4;
}

.chat-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(31, 245, 212, 0.2);
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-input-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-action-btn,
.chat-send-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  font-size: 16px;
}

.chat-action-btn {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--muted-border);
}

.chat-action-btn:hover {
  background: var(--card-bg-hover);
  color: var(--text-primary);
  border-color: var(--muted-border-hover);
}

.chat-send-btn {
  background: var(--accent-cyan);
  color: #000000;
  box-shadow: 0 0 8px rgba(31, 245, 212, 0.3);
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(31, 245, 212, 0.5);
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.chat-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.char-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.char-count.warning {
  color: #ffa502;
}

.chat-shortcuts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.shortcut-btn {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--muted-border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.shortcut-btn:hover {
  background: var(--card-bg-hover);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

/* Chat Toggle Button (when chat is closed) */
.chat-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border: none;
  background: var(--accent-cyan);
  color: #000000;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: var(--glass-shadow-lg), 0 0 20px rgba(31, 245, 212, 0.4);
  transition: var(--transition-fast);
  z-index: 9999;
  animation: subtleFloat 3s ease-in-out infinite;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--glass-shadow-xl), 0 0 30px rgba(31, 245, 212, 0.6);
}

.chat-toggle-btn:active {
  transform: scale(0.95);
}

.chat-toggle-icon {
  font-size: 24px;
}

.chat-toggle-text {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Chat Resize Handle */
.chat-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  cursor: nw-resize;
  background: transparent;
  z-index: 10;
}

.chat-resize-handle::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 8px;
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 50%;
  box-shadow: 
    0 -4px 0 var(--text-muted),
    -4px 0 0 var(--text-muted),
    -4px -4px 0 var(--text-muted);
  opacity: 0.5;
  transition: var(--transition-fast);
}

.chat-resize-handle:hover::before {
  opacity: 1;
  background: var(--accent-cyan);
  box-shadow: 
    0 -4px 0 var(--accent-cyan),
    -4px 0 0 var(--accent-cyan),
    -4px -4px 0 var(--accent-cyan);
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-container {
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    bottom: 20px;
    right: 20px;
    left: 20px;
    border-radius: 12px;
  }

  .chat-container.dragging {
    transform: none; /* Disable scale on mobile for better performance */
  }

  .chat-toggle-btn {
    width: 56px;
    height: 56px;
    bottom: 16px;
    right: 16px;
  }

  .chat-input-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chat-shortcuts {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .chat-container {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    border-radius: 0;
    border: none;
  }

  .chat-header {
    padding: 12px 16px;
  }

  .chat-messages {
    padding: 12px 16px;
  }

  .chat-input-container {
    padding: 12px 16px;
  }

  .message-content {
    padding: 10px 14px;
  }
}

/* Streaming Messages */
.streaming-message .message-content {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(31, 245, 212, 0.2);
}

.streaming-indicator {
  font-size: 11px;
  color: var(--accent-cyan);
  font-style: italic;
  animation: pulseGlow 1.5s ease-in-out infinite;
}

.streaming-text {
  min-height: 20px;
  position: relative;
}

.streaming-text::after {
  content: '▋';
  color: var(--accent-cyan);
  animation: typingCursor 1s ease-in-out infinite;
}

@keyframes typingCursor {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Accessibility Enhancements */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .chat-container {
    border: 2px solid;
    background: Canvas;
    color: CanvasText;
  }
  
  .chat-input {
    border: 2px solid;
    background: Field;
    color: FieldText;
  }
  
  .chat-send-btn:not(:disabled) {
    background: Highlight;
    color: HighlightText;
    border: 2px solid;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .chat-container,
  .chat-message,
  .typing-dots span,
  .streaming-indicator,
  .streaming-text::after {
    animation: none !important;
    transition: none !important;
  }
  
  .chat-toggle-btn {
    animation: none !important;
  }
}

/* Light Theme Adjustments */
[data-theme="light"] .chat-container {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(16, 24, 40, 0.2);
}

[data-theme="light"] .chat-input {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(16, 24, 40, 0.15);
}

[data-theme="light"] .chat-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);
}

[data-theme="light"] .message-text code {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

[data-theme="light"] .message-text pre {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(16, 24, 40, 0.15);
}

[data-theme="light"] .chat-send-btn {
  color: #ffffff;
}

/* Animation Classes */
.chat-message-enter {
  opacity: 0;
  transform: translateY(20px);
}

.chat-message-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: all 300ms ease-out;
}

.chat-message-exit {
  opacity: 1;
  transform: translateX(0);
}

.chat-message-exit-active {
  opacity: 0;
  transform: translateX(-20px);
  transition: all 200ms ease-in;
}

/* Accessibility */
.chat-input:focus,
.chat-control-btn:focus,
.chat-action-btn:focus,
.chat-send-btn:focus,
.shortcut-btn:focus {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .chat-container {
    border-width: 2px;
  }
  
  .message-content {
    border-width: 2px;
  }
  
  .chat-input {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .chat-container,
  .chat-message,
  .chat-toggle-btn,
  .typing-dots span {
    animation: none;
    transition: none;
  }
  
  .chat-messages {
    scroll-behavior: auto;
  }
}

