/* START OF FILE style.css */

/* ========== Welcome Screen Styles ========== */
#welcome-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 50%, var(--primary-900) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100000;
  color: var(--white);
  font-family: var(--font-family-sans);
  opacity: 1;
  transition: opacity 0.5s ease-out;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

#welcome-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.welcome-content {
  text-align: center;
  max-width: 600px;
  padding: var(--space-8);
  animation: welcomeSlideUp 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.welcome-logo {
  margin-bottom: var(--space-12);
}

.lantern-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto var(--space-6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: welcomePulse 2s ease-in-out infinite;
}

.lantern-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.welcome-content h1 {
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-bold);
  margin: 0 0 var(--space-2) 0;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.welcome-subtitle {
  font-size: var(--font-size-xl);
  color: var(--gray-300);
  margin: 0;
  font-weight: var(--font-weight-normal);
}

.start-chat-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-8);
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: var(--white);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-normal);
  box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4);
  margin: var(--space-8) 0;
  position: relative;
  overflow: hidden;
}

.start-chat-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 40px rgba(16, 185, 129, 0.5);
  background: var(--primary-gradient-hover);
}

.start-chat-button:active {
  transform: translateY(0);
}

.start-chat-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.start-chat-button:hover::before {
  left: 100%;
}

.welcome-features {
  display: flex;
  justify-content: center;
  gap: var(--space-8);
  margin-top: var(--space-8);
  flex-wrap: wrap;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  opacity: 0.8;
  transition: opacity var(--transition-normal);
}

.feature-item:hover {
  opacity: 1;
}

.feature-item i {
  font-size: var(--font-size-2xl);
  color: var(--primary-400);
  margin-bottom: var(--space-1);
}

.feature-item span {
  font-size: var(--font-size-sm);
  color: var(--gray-400);
  font-weight: var(--font-weight-medium);
}

@keyframes welcomeSlideUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes welcomePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 20px 40px rgba(16, 185, 129, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 25px 50px rgba(16, 185, 129, 0.4);
  }
}

@media (max-width: 768px) {
  .welcome-content {
    padding: var(--space-6);
  }
  
  .welcome-content h1 {
    font-size: var(--font-size-4xl);
  }
  
  .lantern-icon {
    width: 100px;
    height: 100px;
  }
  
  .lantern-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }
  
  .welcome-features {
    gap: var(--space-6);
  }
  
  .start-chat-button {
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-base);
  }
}

@media (max-width: 480px) {
  .welcome-features {
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .start-chat-button {
    width: 100%;
    justify-content: center;
  }
}

/* ========== Loading Screen Styles ========== */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 50%, var(--primary-900) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  color: var(--white);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  opacity: 1;
  transition: opacity 0.5s ease-out;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

/* Class to trigger fade-out, to be added via JS */
#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-circle {
  width: 100px;
  height: 100px;
  border: 3px solid rgba(16, 185, 129, 0.2);
  border-top: 3px solid var(--primary-400);
  border-right: 3px solid var(--primary-500);
  border-radius: 50%;
  animation: modernSpin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  margin-bottom: 40px;
  position: relative;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
}

.loading-circle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: var(--primary-gradient);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

.loading-text {
  text-align: center;
  margin-bottom: 40px;
}

.loading-text h2 {
  margin: 0 0 15px 0;
  font-size: 28px;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.loading-text p {
  margin: 0;
  font-size: 16px;
  opacity: 0.9;
  color: var(--gray-300);
  font-weight: 400;
}

.progress-container {
  width: 320px;
  max-width: 85%;
  height: 6px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 25px;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

#progress-bar {
  width: 0%;
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 10px;
  transition: width 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
  position: relative;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

#progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

#progress-text {
  font-size: 14px;
  opacity: 0.8;
  font-weight: 600;
  color: var(--primary-300);
  letter-spacing: 0.5px;
}

@keyframes modernSpin {
  0% { 
    transform: rotate(0deg) scale(1);
    filter: hue-rotate(0deg);
  }
  50% {
    transform: rotate(180deg) scale(1.1);
    filter: hue-rotate(90deg);
  }
  100% { 
    transform: rotate(360deg) scale(1);
    filter: hue-rotate(0deg);
  }
}

@keyframes shimmer {
  0% { 
    transform: translateX(-100%);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% { 
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ========== CSS Variables :root ========== */
:root {
  /* Primary Colors - Good selection */
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --primary-300: #6ee7b7;
  --primary-400: #34d399;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-800: #065f46;
  --primary-900: #064e3b;

  /* Secondary accent colors - Good selection */
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-orange: #f97316;

  /* Neutral Colors - Good selection */
  --white: #ffffff;
  --gray-25: #fcfcfd;
  --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;
  --black: #000000;

  /* Semantic Colors - Good selection */
  --success-50: #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50: #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --error-50: #fef2f2;
  --error-100: #fee2e2;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --error-700: #b91c1c;
  /* Added error-200 for borders on light error backgrounds */
  --error-200: #fecaca;


  --info-50: #eff6ff;
  --info-100: #dbeafe;
  --info-500: #3b82f6;
  --info-600: #2563eb;
  --info-700: #1d4ed8;

  /* Component Colors */
  --primary-color: var(--primary-500);
  --primary-hover: var(--primary-600);
  --primary-active: var(--primary-700); /* Added active state for primary */
  --primary-light: var(--primary-50);
  --primary-gradient: linear-gradient(135deg, var(--primary-500), var(--accent-blue)); /* Changed to use accent-blue for more pop */
  --primary-gradient-hover: linear-gradient(135deg, var(--primary-600), var(--accent-purple)); /* Changed hover to accent-purple */

  /* Renamed --user-bubble to --user-bubble-bg for clarity */
  --user-bubble-bg: var(--primary-500);
  --user-bubble-text: var(--white);
  /* Renamed --bot-bubble to --bot-bubble-bg for clarity */
  --bot-bubble-bg: var(--white);
  --bot-bubble-border: var(--gray-200);
  --bot-bubble-text: var(--gray-700); /* For bot messages */

  --border-color: var(--gray-200);
  --border-light: var(--gray-100); /* Often same as --gray-100 or --gray-200 */
  --text-color: var(--gray-800); /* Main text, slightly darker for better contrast on light bg */
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  --bg-color: var(--gray-50); /* Main page background, changed from gray-25 for a bit more substance */
  --bg-secondary: var(--white); /* For cards, modals, distinct sections */

  /* Glass morphism variables - good to have if used, ensure fallback for non-supporting browsers */
  --glass-bg: rgba(255, 255, 255, 0.6); /* Increased opacity slightly */
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-backdrop: blur(12px); /* Slightly reduced blur, can be intensive */

  /* Spacing - Comprehensive, good. Ensure consistent usage. */
  --space-0: 0;
  --space-px: 1px;
  --space-0_5: 0.125rem; /* 2px */
  --space-1: 0.25rem;   /* 4px */
  --space-1_5: 0.375rem;/* 6px */
  --space-2: 0.5rem;    /* 8px */
  --space-2_5: 0.625rem;/* 10px */
  --space-3: 0.75rem;   /* 12px */
  --space-3_5: 0.875rem;/* 14px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-7: 1.75rem;   /* 28px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;
  --space-24: 6rem;

  /* Legacy spacing for compatibility - Consider removing if not actively used to simplify */
  /* --space-xxs: var(--space-0_5); ... */

  /* Typography - Good selection */
  --font-family-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  --font-family-display: 'Cal Sans', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; /* Cal Sans might need to be imported */
  --font-family-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;

  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;
  --font-size-5xl: 3rem;
  --font-size-6xl: 3.75rem;

  --font-weight-thin: 100;
  --font-weight-light: 300;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extrabold: 800;
  --font-weight-black: 900;

  --line-height-none: 1;
  --line-height-tight: 1.25;
  --line-height-snug: 1.375;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.625;
  --line-height-loose: 2;

  --letter-spacing-tighter: -0.05em;
  --letter-spacing-tight: -0.025em;
  --letter-spacing-normal: 0em;
  --letter-spacing-wide: 0.025em;
  --letter-spacing-wider: 0.05em;
  --letter-spacing-widest: 0.1em;

  /* Shadows - Comprehensive. Ensure they are visually distinct enough. */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03); /* Softer xs shadow */
  --shadow-sm: 0 2px 4px -1px rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.04); /* Adjusted for subtlety */
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.2); /* Reduced alpha for 2xl */
  --shadow-inner: inset 0 1px 2px 0 rgba(0, 0, 0, 0.04); /* Softer inner shadow */

  /* Colored shadows - Use sparingly, can be overpowering. */
  --shadow-primary: 0 6px 12px -3px color-mix(in srgb, var(--primary-500) 30%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--primary-500) 20%, transparent);
  --shadow-error: 0 6px 12px -3px color-mix(in srgb, var(--error-500) 30%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--error-500) 20%, transparent);

  /* Border Radius - Good range */
  --radius-none: 0px;
  --radius-sm: 0.125rem; /* 2px */
  --radius-base: 0.25rem; /* 4px */
  --radius-md: 0.375rem; /* 6px */
  --radius-lg: 0.5rem;   /* 8px */
  --radius-xl: 0.75rem;  /* 12px */
  --radius-2xl: 1rem;    /* 16px */
  --radius-3xl: 1.5rem;  /* 24px */
  --radius-full: 9999px;

  /* Transitions - Good set of options. */
  --transition-none: none;
  --transition-fast: all 150ms cubic-bezier(0.4, 0, 0.2, 1); /* Changed duration */
  --transition-normal: all 250ms cubic-bezier(0.4, 0, 0.2, 1); /* Changed duration */
  --transition-slow: all 400ms cubic-bezier(0.4, 0, 0.2, 1); /* Changed duration */
  --transition-slower: all 500ms cubic-bezier(0.4, 0, 0.2, 1);
  /* Renamed --transition-all to --transition-default for clarity or remove if --transition-normal is the default */
  --transition-default: var(--transition-normal);


  /* Easing curves - Good to have if used consistently. */
  --ease-linear: linear;
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* Z-Index Scale - Comprehensive. */
  --z-index-hide: -1;
  --z-index-auto: auto;
  --z-index-base: 0;
  --z-index-docked: 10;
  --z-index-dropdown: 1000;
  --z-index-sticky: 1020; /* Adjusted for typical header/sticky elements */
  --z-index-banner: 1030;
  --z-index-overlay: 1040;
  --z-index-modal: 1050;
  --z-index-popover: 1060;
  --z-index-skipLink: 1070;
  --z-index-toast: 1080;
  --z-index-tooltip: 1090;
  --z-index-loading: 99999; /* Added for loading screen */
}

/* ========== Base Styles ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-width: 0; /* Reset border width by default */
  border-style: solid; /* Set border style so only color and width need to be set */
  border-color: transparent; /* Default border color */
}

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  -webkit-text-size-adjust: 100%; /* Prevent iOS text size adjustment */
  -ms-text-size-adjust: 100%; /* Prevent Windows Phone text size adjustment */
  tab-size: 4;
  /* Support for safe areas on mobile devices */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
  margin: 0;
  font-family: var(--font-family-sans);
  /* Removed font-feature-settings and font-variation-settings unless 'Cal Sans' or specific features are actively used and tested */
  background: var(--bg-color);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  height: 100vh; /* Changed from min-height to height to prevent overflow */
  overflow: hidden; /* Prevent body overflow */
  line-height: var(--line-height-normal);
  font-weight: var(--font-weight-normal);
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; /* Good for performance */
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-4); /* Consistent bottom margin */
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-color); /* Explicitly set color */
}

h1 { font-size: var(--font-size-4xl); }
h2 { font-size: var(--font-size-3xl); }
h3 { font-size: var(--font-size-2xl); }
h4 { font-size: var(--font-size-xl); }
h5 { font-size: var(--font-size-lg); }
h6 { font-size: var(--font-size-base); font-weight: var(--font-weight-semibold); } /* Bolder h6 */

p {
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

a { /* Basic link styling */
  color: var(--primary-600); /* Darker primary for links */
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

/* Typography utilities - Good, ensure they are used. */
.text-xs { font-size: var(--font-size-xs); }
/* ... other text utilities are fine */
.text-primary { color: var(--primary-color); }
/* ... other color utilities are fine */

/* ========== Layout Utilities ========== */
.container {
  width: 100%;
  max-width: 1280px; /* Slightly wider max-width */
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

/* Flex and Grid utilities are fine and comprehensive. */
.flex { display: flex; }
/* ... other flex/grid utilities are fine */
.gap-1 { gap: var(--space-1); }
/* ... other gap utilities are fine */
.w-full { width: 100%; }
/* ... other sizing utilities are fine */

/* ========== Header Styles ========== */
header {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-lg);
  padding: var(--space-5) var(--space-6);
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%);
  border-bottom: 2px solid #10b981;
  color: white;
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition-default);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  isolation: isolate;
  flex-shrink: 0; /* Prevent header from shrinking */
}

header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(45deg, transparent 30%, rgba(16, 185, 129, 0.1) 50%, transparent 70%);
  animation: shimmer 3s infinite;
  will-change: transform, opacity;
  pointer-events: none;
}

@keyframes shimmer {
  0% { 
    transform: translateX(-100%);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% { 
    transform: translateX(100%);
    opacity: 0;
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: relative;
  z-index: 2;
}

.header-title {
  background: linear-gradient(135deg, #10b981, #06d6a0, #118ab2);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #10b981; /* Fallback for browsers that don't support background-clip */
  font-weight: var(--font-weight-extrabold);
  letter-spacing: var(--letter-spacing-tight);
  font-size: var(--font-size-3xl);
  margin: 0;
  position: relative;
}

.header-title::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #10b981, #06d6a0, #118ab2);
  border-radius: var(--radius-full);
  animation: pulse 2s infinite;
  will-change: transform, opacity;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; transform: scaleX(1); }
  50% { opacity: 1; transform: scaleX(1.05); }
}

.header-subtitle {
  color: #94a3b8;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  background: rgba(148, 163, 184, 0.1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid rgba(148, 163, 184, 0.2);
  backdrop-filter: blur(10px);
}

.header-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  position: relative;
  z-index: 2;
}

/* Dropdown Styles */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-btn {
  background: var(--primary-color);
  border: none;
  color: white;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.dropdown-btn:hover {
  background: var(--primary-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.dropdown-arrow {
  font-size: 0.75rem;
  transition: transform var(--transition-fast);
}

.dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-content {
  position: absolute;
  top: 100%;
  right: 0;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  min-width: 200px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(16, 185, 129, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all var(--transition-default);
  z-index: 1001;
  margin-top: var(--space-1);
  padding: var(--space-2);
  backdrop-filter: blur(20px);
}

.dropdown.active .dropdown-content {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: white;
  text-decoration: none;
  transition: all var(--transition-default);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  position: relative;
  overflow: hidden;
}

.dropdown-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.2), transparent);
  transition: left 0.3s ease;
}

.dropdown-item:hover {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  transform: translateX(4px);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

.dropdown-item:hover::before {
  left: 100%;
}

.dropdown-item i {
  width: 16px;
  text-align: center;
  color: #94a3b8;
}

.dropdown-item:hover i {
  color: #10b981;
}

.header-btn {
  background: rgba(16, 185, 129, 0.1);
  color: white;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: all var(--transition-default);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  position: relative;
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.header-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.2), transparent);
  transition: left 0.5s ease;
}

.header-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #10b981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
  transform: translateY(-2px);
}

.header-btn:hover::before {
  left: 100%;
}

.header-btn:active {
  transform: translateY(0);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

/* Focus visible already handled globally, but can be specific if needed */
/* .header-btn:focus-visible { ... } */

/* ========== Chat Interface ========== */
#chat-interface {
  display: flex;
  flex-direction: column;
  flex: 1; /* Crucial for taking available space */
  min-height: 0; /* Allow flex item to shrink below content size */
  overflow: hidden; /* Prevent content overflow */
  background: var(--bg-color);
  position: relative; /* For potential absolute positioned children */
}

#chat-interface #input-area {
  position: sticky;
  bottom: 0;
}

#chat-container {
  flex: 1; /* Allows chat container to grow and scroll */
  overflow-y: auto; /* Enable vertical scrolling */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  padding: var(--space-4) var(--space-4) var(--space-12) var(--space-4); /* Add more bottom padding to avoid overlap with input area */
  display: flex;
  flex-direction: column;
  gap: var(--space-4); /* Adjusted gap between messages */
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-4); /* Ensure content isn't hidden by sticky header if applicable */
}

/* ========== Message Styles ========== */
.message {
  max-width: 70%; /* Restored original responsive width */
  padding: var(--space-3) var(--space-4); /* Adjusted padding */
  border-radius: var(--radius-xl); /* Slightly less rounded */
  line-height: var(--line-height-relaxed);
  white-space: normal; /* Fixed white space issue */
  word-wrap: break-word; /* Prevent long words from breaking layout */
  position: relative;
  animation: messageSlideIn 0.3s var(--ease-out) forwards; /* Smoother ease and forwards */
  font-size: var(--font-size-base);
  /* backdrop-filter and -webkit-backdrop-filter can be performance intensive. Use cautiously. */
  /* Consider removing if not essential for the design or if performance issues arise. */
   backdrop-filter: var(--glass-backdrop);
   -webkit-backdrop-filter: var(--glass-backdrop);
   box-shadow: var(--shadow-md); /* Consistent shadow */
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.97); /* Adjusted for subtlety */
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message.user { /* Ensure .user is used with .message */
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  align-self: flex-end;
  margin-left: auto; /* Good for alignment */
  border-bottom-right-radius: var(--radius-md);
}

/* Removed .user::before and .bot::before as they add visual noise and might not be intended for simple chat bubbles. */
/* If a subtle sheen is desired, ensure it's very minimal. */

.message.bot { /* Ensure .bot is used with .message */
  background: var(--bot-bubble-bg);
  color: var(--bot-bubble-text);
  border: 1px solid var(--bot-bubble-border);
  align-self: flex-start;
  margin-right: auto; /* Good for alignment */
  border-bottom-left-radius: var(--radius-md);
  /* box-shadow: var(--shadow-md); // Already has shadow */
}


.message.error { /* Ensure .error is used with .message */
  background: var(--error-50); /* Solid error background for clarity */
  border: 1px solid var(--error-200);
  color: var(--error-700);
  box-shadow: var(--shadow-error); /* Specific error shadow */
}

/* Optional: If you want to display message timestamps */
.message-time {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-1_5); /* Adjusted margin */
  text-align: right; /* Or left, depending on sender */
  opacity: 0.7; /* Reduced opacity */
  font-weight: var(--font-weight-normal); /* Normal weight */
}

/* Typing indicator - JS creates this, CSS styles it */
/* This assumes JS adds a div with class "typing-indicator" and three child divs with "typing-dot" */
.typing-indicator {
  display: flex; /* Use flex for dot alignment */
  align-items: center; /* Vertically center dots if they have different heights */
  gap: var(--space-1_5); /* Space between dots */
  padding: var(--space-3) var(--space-4); /* Match bot message padding */
  align-self: flex-start; /* Align like a bot message */
  background: var(--bot-bubble-bg);
  border: 1px solid var(--bot-bubble-border);
  border-radius: var(--radius-xl);
  border-bottom-left-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  animation: messageSlideIn 0.3s var(--ease-out) forwards; /* Reuse message animation */
  margin: var(--space-2) 0; /* Add some margin if needed */
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--gray-400); /* Muted color for dots */
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; } /* Adjusted delays for smoother loop */
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce { /* Simplified bounce */
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========== Suggestions Container ========== */
#suggestions-container {
  position: relative;
  z-index: var(--z-index-dropdown);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-color);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 
    0 -4px 12px rgba(0, 0, 0, 0.03),
    0 -2px 6px rgba(0, 0, 0, 0.02);
  transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0);
  opacity: 1;
  overflow: hidden;
}

#suggestions-container::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(99, 102, 241, 0.4) 25%, 
    rgba(139, 92, 246, 0.4) 50%, 
    rgba(168, 85, 247, 0.4) 75%, 
    transparent 100%);
  opacity: 0.7;
}

#suggestions-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(203, 213, 225, 0.6) 25%, 
    rgba(148, 163, 184, 0.6) 50%, 
    rgba(203, 213, 225, 0.6) 75%, 
    transparent 100%);
  opacity: 0.5;
}



#suggestions-container.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.suggestion-item {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2_5) var(--space-5);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.95) 0%, 
    rgba(248, 250, 252, 0.9) 25%,
    rgba(241, 245, 249, 0.85) 50%,
    rgba(236, 242, 249, 0.8) 75%,
    rgba(230, 238, 248, 0.75) 100%);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  margin: var(--space-1);
}

.suggestion-item:hover {
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.08) 0%, 
    rgba(147, 51, 234, 0.06) 25%,
    rgba(236, 72, 153, 0.04) 50%,
    rgba(251, 146, 60, 0.06) 75%,
    rgba(59, 130, 246, 0.08) 100%);
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 
    0 8px 25px rgba(59, 130, 246, 0.15),
    0 4px 12px rgba(0, 0, 0, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.suggestion-item:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 
    0 2px 8px rgba(59, 130, 246, 0.2),
    0 1px 4px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.suggestion-item i {
  margin-right: var(--space-2);
  font-size: var(--font-size-sm);
  opacity: 0.75;
  transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
  flex-shrink: 0;
}

.suggestion-item:hover i {
  opacity: 1;
  transform: scale(1.15) rotate(5deg);
  color: var(--primary-600);
  filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.3));
}

.suggestion-item:active i {
  transform: scale(1.1) rotate(2deg);
  transition: all var(--transition-fast);
}

.suggestion-item .suggestion-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestions-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.suggestions-label {
  font-size: var(--font-size-sm);
  background: linear-gradient(135deg, 
    var(--primary-600) 0%, 
    var(--primary-700) 50%, 
    var(--primary-600) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: var(--font-weight-bold);
  margin-right: var(--space-4);
  white-space: nowrap;
  display: flex;
  align-items: center;
  text-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
  position: relative;
  letter-spacing: 0.025em;
}

.suggestions-label::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--primary-400) 50%, 
    transparent 100%);
  border-radius: var(--radius-full);
  opacity: 0.6;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2_5) var(--space-5);
  background: linear-gradient(135deg, 
    rgba(255, 255, 255, 0.95) 0%, 
    rgba(248, 250, 252, 0.9) 25%,
    rgba(241, 245, 249, 0.85) 50%,
    rgba(236, 242, 249, 0.8) 75%,
    rgba(230, 238, 248, 0.75) 100%);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.suggestion-chip::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.6) 25%, 
    rgba(59, 130, 246, 0.2) 50%, 
    rgba(255, 255, 255, 0.6) 75%, 
    transparent 100%);
  transition: left var(--transition-slow) cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-full);
}

.suggestion-chip:hover {
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.08) 0%, 
    rgba(147, 51, 234, 0.06) 25%,
    rgba(236, 72, 153, 0.04) 50%,
    rgba(251, 146, 60, 0.06) 75%,
    rgba(59, 130, 246, 0.08) 100%);
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--primary-700);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    0 12px 32px rgba(59, 130, 246, 0.15),
    0 6px 16px rgba(0, 0, 0, 0.1),
    0 3px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(59, 130, 246, 0.2);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
}

.suggestion-chip:hover::before {
  left: 100%;
}

.suggestion-chip:active {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 
    0 6px 20px rgba(59, 130, 246, 0.2),
    0 3px 10px rgba(0, 0, 0, 0.15),
    inset 0 2px 4px rgba(59, 130, 246, 0.1);
  transition: all var(--transition-fast) cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, 
    rgba(59, 130, 246, 0.12) 0%, 
    rgba(147, 51, 234, 0.1) 50%,
    rgba(59, 130, 246, 0.12) 100%);
}

.suggestion-chip i {
  margin-right: var(--space-2);
  font-size: var(--font-size-sm);
  opacity: 0.75;
  transition: all var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.suggestion-chip:hover i {
  opacity: 1;
  transform: scale(1.15) rotate(5deg);
  color: var(--primary-600);
  filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.3));
}

.suggestion-chip:active i {
  transform: scale(1.1) rotate(2deg);
  transition: all var(--transition-fast);
}

/* Responsive suggestions */
@media (max-width: 768px) {
  #suggestions-container {
    padding: var(--space-1_5) var(--space-3);
    background: var(--bg-color);
    backdrop-filter: blur(6px) saturate(110%);
    -webkit-backdrop-filter: blur(6px) saturate(110%);
    box-shadow: 
      0 -3px 8px rgba(0, 0, 0, 0.02),
      0 -1px 4px rgba(0, 0, 0, 0.01);
  }
  
  .suggestions-wrapper {
    gap: var(--space-1_5);
    justify-content: center;
  }
  
  .suggestion-chip {
    padding: var(--space-1_5) var(--space-3);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-lg);
  }
  
  .suggestion-chip:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
  }
  
  .suggestions-label {
    font-size: var(--font-size-xs);
    margin-right: var(--space-2);
  }
}

@media (max-width: 480px) {
  .suggestions-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }
  
  .suggestions-label {
    text-align: center;
    margin-right: 0;
    margin-bottom: var(--space-1);
  }
  
  .suggestion-chip {
    justify-content: center;
    text-align: center;
  }
}

/* ========== Input Area ========== */
#input-area {
  display: flex;
  align-items: flex-end; /* Align items to bottom for multi-line text area */
  padding: var(--space-3) var(--space-4); /* Adjusted padding */
  background: var(--glass-bg); /* Using glass variables */
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border-top: 1px solid var(--glass-border); /* Using glass variables */
  gap: var(--space-3); /* Adjusted gap */
  position: relative;
  z-index: var(--z-index-sticky);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); /* Softer shadow */
  transition: background-color var(--transition-default), border-color var(--transition-default);
  flex-shrink: 0; /* Prevent input area from shrinking */
}

#userInput {
  flex: 1; /* Allow it to grow */
  padding: var(--space-3) var(--space-4); /* Adjusted padding */
  font-size: max(16px, var(--font-size-base)); /* Prevent zoom on iOS */
  border-radius: var(--radius-lg); /* Consistent radius */
  border: 1px solid var(--gray-300); /* Clearer border */
  outline: none; /* Handled by focus-visible */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  resize: none; /* Keep if JS handles height, otherwise consider 'vertical' */
  min-height: calc(var(--line-height-normal) * 1em + var(--space-3) * 2 + 2px); /* Calculate based on line height and padding */
  line-height: var(--line-height-normal);
  font-family: var(--font-family-sans);
  background: var(--white);
  color: var(--text-color);
  box-shadow: var(--shadow-inner); /* Subtle inner shadow */
  -webkit-appearance: none; /* Remove iOS styling */
  appearance: none;
}

#userInput:focus { /* Use :focus for consistent styling if :focus-visible is not always triggered by JS focus */
  border-color: var(--primary-color);
  background-color: var(--white); /* Ensure background stays white on focus */
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 20%, transparent), var(--shadow-sm); /* Focus ring + subtle shadow */
  transform: none; /* Remove transform on focus as it can cause jitter with text */
}

#userInput::placeholder {
  color: var(--text-muted);
  font-weight: var(--font-weight-normal);
  opacity: 1; /* Ensure placeholder is fully visible */
}

#sendBtn {
  background: var(--primary-500);
  border: none; /* Consistent with border reset */
  padding: 0 var(--space-5); /* Adjusted padding */
  border-radius: var(--radius-lg); /* Consistent radius */
  color: var(--white);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-size: var(--font-size-base);
  transition: background var(--transition-fast);
  white-space: nowrap; /* Prevent text wrapping */
  min-height: calc(var(--line-height-normal) * 1em + var(--space-3) * 2 + 2px); /* Match input height */
  height: auto; /* Allow button to size to content if needed, or set fixed height */
  width: 80px; /* Fixed width for consistent sizing */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}



#sendBtn:hover:not(:disabled) { /* Apply hover only if not disabled */
  background: var(--primary-600);
}

#sendBtn:active:not(:disabled) {
  background: var(--primary-700);
}

#sendBtn:disabled {
  background: var(--gray-200); /* Lighter disabled background */
  color: var(--gray-400); /* Muted text for disabled */
  cursor: not-allowed;
  opacity: 0.7; /* Slightly more opaque */
}
/* sendBtn:focus-visible already handled by global */

/* ========== Footer Styles ========== */
footer {
  text-align: center;
  font-size: var(--font-size-sm);
  color: #94a3b8;
  padding: var(--space-4) var(--space-4); /* Reduced padding to prevent overflow */
  border-top: 2px solid #10b981;
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%);
  position: relative;
  overflow: hidden;
  flex-shrink: 0; /* Prevent footer from shrinking */
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(45deg, transparent 30%, rgba(16, 185, 129, 0.05) 50%, transparent 70%);
  animation: shimmer 4s infinite reverse;
  will-change: transform, opacity;
  pointer-events: none;
}

footer a {
  color: #10b981; /* Fallback color */
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  transition: all var(--transition-default);
  position: relative;
  z-index: 2;
  background: linear-gradient(135deg, #10b981, #06d6a0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: var(--font-size-base);
}

footer a::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #10b981, #06d6a0, #118ab2);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

footer a:hover {
  text-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
  transform: translateY(-2px);
}

footer a:hover::after {
  width: 120%;
}

/* ========== Code Blocks (Prism.js overrides) ========== */
/* Ensure this comes AFTER Prism's default stylesheet if you're using one */
pre[class*="language-"] { /* Target Prism's generated <pre> tags */
  background: var(--gray-800) !important; /* Dark background for code */
  color: var(--gray-100) !important; /* Light text for code */
  padding: var(--space-4) !important; /* Consistent padding */
  border-radius: var(--radius-lg) !important; /* Consistent radius */
  overflow-x: auto !important;
  margin: var(--space-4) 0 !important; /* Consistent margin */
  box-shadow: var(--shadow-lg) !important;
  font-family: var(--font-family-mono) !important;
  font-size: var(--font-size-sm) !important;
  line-height: var(--line-height-relaxed) !important;
  border: 1px solid var(--gray-700) !important; /* Subtle border */
  position: relative; /* For ::before if needed */
  white-space: pre-wrap !important; /* Allow wrapping but preserve spaces */
  word-break: break-all; /* Break long unbreakable strings if necessary */
}

/* Removing pre::before as it might conflict with Prism's line numbering or other plugins. */

code[class*="language-"] { /* Target Prism's generated <code> tags */
  font-family: var(--font-family-mono) !important;
  font-size: 1em !important; /* Inherit from pre */
  font-weight: var(--font-weight-normal) !important; /* Normal weight for code */
  background: none !important; /* Ensure no background on inline code if Prism adds it */
  color: inherit !important; /* Inherit color from pre */
  padding: 0 !important; /* Remove padding if Prism adds it */
  text-shadow: none !important; /* Remove Prism's text shadow if any */
}

/* ========== Code Container (Your custom wrapper) ========== */
.code-container {
  background: var(--gray-800); /* Match pre background */
  border-radius: var(--radius-lg); /* Match pre radius */
  overflow: hidden; /* Important for child elements */
  margin: var(--space-4) 0; /* Consistent margin */
  box-shadow: var(--shadow-lg); /* Consistent shadow */
  border: 1px solid var(--gray-700); /* Consistent border */
}

.code-header {
  background: var(--gray-700); /* Slightly lighter header */
  padding: var(--space-2_5) var(--space-4); /* Adjusted padding */
  color: var(--gray-300); /* Lighter text for header */
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-600); /* Darker border */
  font-weight: var(--font-weight-medium);
}
.code-header span { /* Style the language text */
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.code-header i.fas.fa-code { /* Style FontAwesome icon if present */
 color: var(--primary-400); /* Primary color for icon */
}

.code-content { /* This div wraps the <pre> tag in your JS */
  /* Padding is handled by the pre tag itself now */
  overflow-x: auto; /* Ensure horizontal scroll if content is too wide */
  /* Background is handled by the pre tag */
}

/* Copy/Preview buttons in code header - Assuming these are styled by JS mostly. */
/* It's better to add classes via JS and style them here. */
.code-actions {
  display: flex;
  gap: var(--space-2);
}
.code-actions button { /* Generic styling for buttons in code-actions */
  background: var(--gray-600);
  border: 1px solid var(--gray-500);
  color: var(--gray-100);
  padding: var(--space-1_5) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--font-size-xs);
  display: flex;
  align-items: center;
  gap: var(--space-1_5);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
  font-weight: var(--font-weight-medium);
}
.code-actions button:hover {
  background: var(--gray-500);
  border-color: var(--gray-400);
  color: var(--white);
  transform: translateY(-1px);
}
.code-actions button:active {
  transform: translateY(0px) scale(0.98);
  background: var(--gray-600);
}
/* Preview container and tabs are fine as they are, assuming they are implemented correctly in HTML/JS. */

/* ========== Scrollbar (Global) ========== */
::-webkit-scrollbar {
  width: 10px; /* Slightly wider */
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--gray-100); /* Lighter track */
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb {
  background: var(--gray-300); /* More distinct thumb */
  border-radius: var(--radius-full);
  border: 2px solid var(--gray-100); /* Creates a "channel" effect */
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}
::-webkit-scrollbar-corner { /* Style the corner where vertical and horizontal scrollbars meet */
  background: var(--gray-100);
}
* { /* Firefox scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) var(--gray-100);
}

/* Animations - Keyframes are fine. */
/* Utility classes (shadows, borders, bg, display etc.) are fine and very comprehensive. */

/* ========== Responsive Design ========== */
@media (max-width: 1024px) { /* Tablet and smaller */
  .container {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }
  #chat-container {
    padding: var(--space-3) var(--space-3) var(--space-10) var(--space-3); /* Adjust bottom padding */
    gap: var(--space-3);
  }
}

@media (max-width: 768px) { /* Mobile */
  :root { /* Adjust base sizes for mobile */
    --font-size-base: 0.9375rem; /* 15px */
    --font-size-lg: 1.0625rem; /* 17px */
    --font-size-xl: 1.1875rem; /* 19px */
    --space-4: 0.875rem;   /* 14px */
    --space-6: 1.25rem;    /* 20px */
  }
  
  /* Fix mobile viewport issues */
  body {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    overflow: hidden;
  }
  
  header {
    padding: var(--space-2_5) var(--space-3); /* Tighter header padding */
    font-size: var(--font-size-base); /* Smaller header font */
    /* Keep desktop layout - horizontal flex */
  }
  
  .header-title {
    font-size: var(--font-size-xl); /* Smaller title for mobile */
  }
  
  .header-subtitle {
    font-size: var(--font-size-xs);
    padding: var(--space-0_5) var(--space-2);
  }
  
  .header-actions {
    gap: var(--space-2); /* Tighter gap */
  }
  
  .dropdown-content {
    right: 0;
    min-width: 180px; /* Smaller dropdown */
    max-width: 90vw; /* Prevent overflow */
  }
  
  .message {
    max-width: 90%; /* Allow messages to take more width */
    padding: var(--space-2_5) var(--space-3_5);
    border-radius: var(--radius-lg); /* Slightly smaller radius */
  }
  
  #input-area {
    padding: var(--space-2_5) var(--space-3);
    gap: var(--space-2_5);
    /* Ensure input area doesn't get cut off */
    padding-bottom: max(var(--space-2_5), env(safe-area-inset-bottom));
  }
  
  #userInput, #sendBtn { /* Ensure consistent height for input and button */
    min-height: 44px; /* iOS minimum touch target */
    padding-top: var(--space-2_5);
    padding-bottom: var(--space-2_5);
  }
  
  #sendBtn {
    padding-left: var(--space-4); /* Adjust button padding */
    padding-right: var(--space-4);
    font-size: var(--font-size-sm);
    min-width: 60px;
  }
  
  /* Improve touch targets */
  .header-btn, .dropdown-btn {
    min-height: 44px;
    min-width: 44px;
    padding: var(--space-2_5);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .header-btn i {
    font-size: var(--font-size-base);
  }
  
  .dropdown-item {
    min-height: 44px;
    padding: var(--space-3) var(--space-4);
  }
}

@media (max-width: 480px) { /* Very small screens */
  .message {
    max-width: 95%;
    font-size: var(--font-size-sm); /* Smaller message text */
    padding: var(--space-2) var(--space-3);
  }
  
  header { 
    padding: var(--space-2) var(--space-2_5);
    padding-top: max(var(--space-2), env(safe-area-inset-top));
    /* Maintain horizontal layout */
  }
  
  .header-title {
    font-size: var(--font-size-lg); /* Even smaller for very small screens */
  }
  
  .header-subtitle {
    display: none; /* Hide subtitle on very small screens */
  }
  
  .header-btn { 
    min-width: 44px; /* Keep accessible size */
    min-height: 44px;
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .header-btn i {
    font-size: var(--font-size-sm); /* Slightly smaller icon for very small screens */
  }
  
  .dropdown-btn {
    font-size: var(--font-size-xs);
    padding: var(--space-1_5) var(--space-2);
  }
  
  .dropdown-btn span {
    display: none; /* Hide "Menu" text, keep only icon */
  }
  
  .dropdown-content {
    min-width: 160px;
    max-width: 85vw;
    right: 0;
  }
  
  #chat-container { 
    padding: var(--space-2) var(--space-2) var(--space-8) var(--space-2);
  }
  
  #input-area { 
    padding: var(--space-2);
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    gap: var(--space-2);
  }
  
  #userInput, #sendBtn { 
    font-size: var(--font-size-sm);
    min-height: 44px;
  }
  
  #sendBtn {
    min-width: 50px;
    padding: var(--space-2) var(--space-2_5);
  }
  
  footer {
    padding: var(--space-2) var(--space-2);
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    font-size: var(--font-size-xs);
  }
}

/* ========== Dark Mode ========== */
@media (prefers-color-scheme: dark) {
  :root {
    --primary-color: var(--primary-400);
    --primary-hover: var(--primary-300);
    --primary-active: var(--primary-500); /* Darker active for dark mode */
    --primary-light: color-mix(in srgb, var(--primary-400) 10%, transparent); /* Mix for light bg */
    --primary-gradient: linear-gradient(135deg, var(--primary-400), var(--accent-purple)); /* Dark mode gradient */
    --primary-gradient-hover: linear-gradient(135deg, var(--primary-300), var(--accent-pink));

    --user-bubble-bg: var(--primary-500);
    --user-bubble-text: var(--gray-900); /* Darker text for better contrast on brighter gradient */
    --bot-bubble-bg: var(--gray-800);
    --bot-bubble-border: var(--gray-700);
    --bot-bubble-text: var(--gray-100); /* Light text for bot */

    --border-color: var(--gray-700);
    --border-light: var(--gray-800);
    --text-color: var(--gray-100);
    --text-secondary: var(--gray-400);
    --text-muted: var(--gray-500);
    --bg-color: var(--gray-900);
    --bg-secondary: var(--gray-800);

    --glass-bg: rgba(30, 41, 59, 0.6); /* Dark glass, e.g., --gray-800 with alpha */
    --glass-border: rgba(255, 255, 255, 0.1);

    --shadow-primary: 0 6px 12px -3px color-mix(in srgb, var(--primary-400) 25%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--primary-400) 15%, transparent);
    --shadow-error: 0 6px 12px -3px color-mix(in srgb, var(--error-500) 25%, transparent), 0 4px 8px -4px color-mix(in srgb, var(--error-500) 15%, transparent);
    /* Error colors for dark mode text/bg were missing, using semantic variables now */
    --error-bg-dark: var(--error-500); /* Example, or use a specific dark error bg */
    --error-text-dark: var(--white);

  }

  body {
    /* Using solid color for dark mode, radial gradient can be distracting */
    background: var(--bg-color);
    color: var(--text-color);
  }

  header, #input-area {
    background: var(--glass-bg);
    border-color: var(--glass-border);
    color: var(--text-color); /* Ensure header text is light */
  }
  .header-btn:hover { background: var(--gray-700); color: var(--primary-color); }

  #userInput {
    background: var(--gray-800); /* Darker input */
    border-color: var(--gray-600); /* Darker border */
    color: var(--text-color);
  }
  #userInput:focus {
    border-color: var(--primary-color);
    background-color: var(--gray-700); /* Slightly lighter on focus */
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 25%, transparent), var(--shadow-sm);
  }

  #sendBtn:disabled { background: var(--gray-700); color: var(--gray-500); }

  footer {
    background: var(--bg-secondary); /* Match other secondary backgrounds */
    border-color: var(--border-color);
    color: var(--text-muted); /* Use variable for muted text */
  }
  footer a { /* Footer links in dark mode */
    color: var(--primary-400); /* Use dark mode primary */
  }
  footer a:hover {
    color: var(--primary-300);
    background-color: var(--primary-light); /* Use dark mode light primary */
  }

  /* Dark mode for tabs and preview would follow similar logic, using dark theme variables. */
  /* Example for tabs: */
  .tab-container { background: var(--gray-800); border-bottom-color: var(--gray-700); }
  .tab { color: var(--gray-400); }
  .tab:hover { background: var(--gray-700); color: var(--gray-100); }
  .tab.active { background: var(--bg-secondary); color: var(--primary-color); }
  .tab.active::after { background: var(--primary-gradient); }
  .tab-content { background: var(--bg-secondary); border-color: var(--border-color); }

  /* Dark mode for Prism (pre/code) - Ensure this doesn't conflict with Prism's own dark theme if used */
  pre[class*="language-"] {
    background: var(--gray-900) !important; /* Even darker for code in dark mode */
    color: var(--gray-200) !important;
    border-color: var(--gray-700) !important;
  }
  .code-container { background: var(--gray-900); border-color: var(--gray-700); }
  .code-header { background: var(--gray-800); color: var(--gray-300); border-bottom-color: var(--gray-700); }
  .code-actions button { background: var(--gray-700); border-color: var(--gray-600); color: var(--gray-100); }
  .code-actions button:hover { background: var(--gray-600); border-color: var(--gray-500); }


  ::-webkit-scrollbar-track { background: var(--gray-800); }
  ::-webkit-scrollbar-thumb { background: var(--gray-600); border-color: var(--gray-800); }
  ::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
  * { scrollbar-color: var(--gray-600) var(--gray-800); }
}

/* ========== Accessibility & Focus ========== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: high) { /* Basic high contrast adjustments */
  :root {
    --border-color: var(--gray-900); /* Darker borders */
    --text-color: var(--black); /* Ensure text is black */
    --primary-color: #005a9e; /* Darker primary for contrast */
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --border-color: var(--gray-100); /* Lighter borders in dark high contrast */
      --text-color: var(--white);
      --primary-color: #60a5fa; /* Brighter primary */
    }
  }
}

*:focus-visible { /* Global focus style, very important for accessibility */
  outline: 3px solid var(--primary-600); /* More prominent outline */
  outline-offset: 1px; /* Slight offset */
  border-radius: var(--radius-base); /* Consistent radius for focus */
  box-shadow: 0 0 0 3px var(--bg-color), 0 0 0 5px var(--primary-600); /* Inner and outer ring effect */
}
/* Remove default outline for elements that have custom box-shadow focus rings */
#userInput:focus-visible, #sendBtn:focus-visible, .header-btn:focus-visible, footer a:focus-visible, .code-actions button:focus-visible, .tab:focus-visible {
  outline: none;
}


/* Chat Container Specific Scrollbar - This is good */
#chat-container::-webkit-scrollbar { width: 8px; } /* Slightly thicker for easier grabbing */
#chat-container::-webkit-scrollbar-track { background: transparent; }
#chat-container::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
#chat-container::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
@media (prefers-color-scheme: dark) {
  #chat-container::-webkit-scrollbar-thumb { background: var(--gray-600); }
  #chat-container::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
}


/* ========== Print Styles ========== */
@media print {
  header, footer, #input-area, .header-actions, #clearChat, .code-actions, .tab-container { /* Hide more non-essential elements */
    display: none !important;
  }
  .message {
    break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ccc !important; /* Simple border for print */
    padding: var(--space-2) !important;
    background: var(--white) !important; /* Ensure white background for messages */
    color: var(--black) !important; /* Ensure black text */
    backdrop-filter: none !important; /* Remove filters */
    -webkit-backdrop-filter: none !important;
  }
  body {
    background: white !important;
    color: black !important;
    font-size: 10pt; /* Readable print size */
    line-height: 1.3; /* Tighter line height for print */
  }
  #chat-container {
    padding: 0 !important;
    gap: var(--space-2) !important;
    overflow: visible !important; /* Show all content */
  }
  .code-container, pre[class*="language-"] {
    page-break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    background: #f8f8f8 !important; /* Light background for code */
    color: #333 !important; /* Dark text for code */
  }
  a { text-decoration: none; color: inherit !important; }
  code[class*="language-"] { /* Ensure code text is visible */
    color: #333 !important;
    text-shadow: none !important;
  }
}

#stopBtn {
  background: var(--error-500);
  border: none; /* Consistent with border reset */
  padding: 0 var(--space-5); /* Adjusted padding */
  border-radius: var(--radius-lg); /* Consistent radius */
  color: var(--white);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  font-size: var(--font-size-base);
  transition: background var(--transition-fast);
  white-space: nowrap; /* Prevent text wrapping */
  min-height: calc(var(--line-height-normal) * 1em + var(--space-3) * 2 + 2px); /* Match input height */
  height: auto; /* Allow button to size to content if needed, or set fixed height */
  width: 80px; /* Fixed width for consistent sizing */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

#stopBtn:hover {
  background: var(--error-600);
}

#stopBtn:active {
  background: var(--error-700);
}

/* ========== Markdown Styles ========== */
.message h1, .message h2, .message h3, .message h4, .message h5, .message h6 {
  margin: 1em 0 0.5em 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-color);
}

.message h1 { font-size: 1.8em; border-bottom: 2px solid var(--border-color); padding-bottom: 0.3em; }
.message h2 { font-size: 1.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.message h3 { font-size: 1.3em; }
.message h4 { font-size: 1.1em; }
.message h5 { font-size: 1em; }
.message h6 { font-size: 0.9em; color: var(--text-muted); }

.message p {
  margin: 0.8em 0;
  line-height: 1.6;
}

.message ul, .message ol {
  margin: 0.8em 0;
  padding-left: 2em;
}

.message li {
  margin: 0.3em 0;
  line-height: 1.5;
}

.message blockquote {
  margin: 1em 0;
  padding: 0.8em 1.2em;
  border-left: 4px solid var(--primary-500);
  background: var(--gray-50);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--text-muted);
}

.message table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.message th, .message td {
  padding: 0.8em 1em;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.message th {
  background: var(--gray-100);
  font-weight: 600;
  color: var(--text-color);
}

.message tr:hover {
  background: var(--gray-50);
}

.message .inline-code {
  background: var(--gray-100);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.9em;
  color: var(--primary-700);
  border: 1px solid var(--border-color);
}

.message strong {
  font-weight: 600;
  color: var(--text-color);
}

.message em {
  font-style: italic;
  color: var(--text-muted);
}

.message a {
  color: var(--primary-600);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.message a:hover {
  color: var(--primary-700);
  border-bottom-color: var(--primary-600);
}

.message hr {
  margin: 2em 0;
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

/* Ensure markdown elements don't interfere with code blocks */
.message .code-container h1,
.message .code-container h2,
.message .code-container h3,
.message .code-container h4,
.message .code-container h5,
.message .code-container h6,
.message .code-container p,
.message .code-container ul,
.message .code-container ol,
.message .code-container blockquote {
  all: unset;
  display: inline;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
}

/* Copy and Preview button styles */
.copy-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  margin-left: 8px;
  transition: background-color 0.2s;
}

.copy-btn:hover {
  background: #0056b3;
}

.copy-btn.copied {
  background: #28a745;
}

.preview-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  margin-left: 4px;
  transition: background-color 0.2s;
}

.preview-btn:hover {
  background: #1e7e34;
}

/* Preview modal styles */
#preview-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
}

.preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
}

.preview-container {
  background: white;
  border-radius: 8px;
  width: 90%;
  height: 90%;
  max-width: 1200px;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  background: #f8f9fa;
  border-radius: 8px 8px 0 0;
}

.preview-header h3 {
  margin: 0;
  color: #333;
  font-size: 18px;
}

.preview-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.preview-close:hover {
  background: #e0e0e0;
  color: #333;
}

.preview-content {
  flex: 1;
  padding: 0;
  overflow: hidden;
}

#preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
}
