.progress-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary-500);
  transition: width var(--duration-300) var(--ease-out);
}

/**
 * HeuriSight Modern UI/UX Design System
 * Complete redesign based on UI/UX audit recommendations
 * Focus: Progressive disclosure, mobile-first, friendly & inviting
 */

/* ===== DESIGN TOKENS ===== */
:root {
  /* Brand Colors - Warm & Approachable */
  --primary-50: #f0f9ff;
  --primary-100: #e0f2fe;
  --primary-200: #bae6fd;
  --primary-300: #7dd3fc;
  --primary-400: #38bdf8;
  --primary-500: #0ea5e9;
  --primary-600: #0284c7;
  --primary-700: #0369a1;
  --primary-800: #075985;
  --primary-900: #0c4a6e;

  /* Model Accent Colors - Visual Identity for Multi-AI */
  --personal-ai: #8b5cf6;     /* Purple - Personal AI */
  --expert-ai: #10b981;       /* Green - Expert Models */
  --mentor-ai: #f59e0b;       /* Amber - Mentor Models */
  --assistant-ai: #ef4444;    /* Red - Assistant Models */

  /* Semantic Colors */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;

  /* Neutral Grays - Warmer Tone */
  --gray-50: #fafaf9;
  --gray-100: #f5f5f4;
  --gray-200: #e7e5e4;
  --gray-300: #d6d3d1;
  --gray-400: #a8a29e;
  --gray-500: #78716c;
  --gray-600: #57534e;
  --gray-700: #44403c;
  --gray-800: #292524;
  --gray-900: #1c1917;

  /* Additional Colors */
  --white: #ffffff;
  --purple-600: #a855f7;
  --green-600: #059669;
  --amber-600: #d97706;
  --blue-50: #eff6ff;
  --blue-500: #3b82f6;
  --blue-900: #1e3a8a;
  --indigo-100: #e0e7ff;
  --indigo-700: #4338ca;
  --green-50: #f0fdf4;
  --green-100: #dcfce7;

  /* Typography Scale */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  --font-size-xs: 0.75rem;     /* 12px */
  --font-size-sm: 0.875rem;    /* 14px */
  --font-size-base: 1rem;      /* 16px */
  --font-size-lg: 1.125rem;    /* 18px */
  --font-size-xl: 1.25rem;     /* 20px */
  --font-size-2xl: 1.5rem;     /* 24px */
  --font-size-3xl: 1.875rem;   /* 30px */
  --font-size-4xl: 2.25rem;    /* 36px */

  /* Spacing Scale - Golden Ratio Based */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Border Radius */
  --radius-sm: 0.375rem;  /* 6px */
  --radius: 0.5rem;       /* 8px */
  --radius-md: 0.75rem;   /* 12px */
  --radius-lg: 1rem;      /* 16px */
  --radius-xl: 1.5rem;    /* 24px */
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Animation Timing */
  --duration-150: 150ms;
  --duration-200: 200ms;
  --duration-300: 300ms;
  --duration-500: 500ms;
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* Brand Gradient - Unified Token */
  --brand-gradient: linear-gradient(135deg, var(--primary-500), var(--primary-600));

  /* Placeholder */
  --placeholder-color: color-mix(in srgb, var(--text-secondary) 65%, white);

  /* Semantic Surfaces & Text (for consistency across components) */
  --surface-1: var(--gray-900);
  --surface-2: var(--gray-800);
  --surface-3: var(--gray-700);
  --surface-4: var(--gray-600);
  --surface-overlay: rgba(17, 24, 39, 0.6);
  --surface-overlay-strong: rgba(17, 24, 39, 0.9);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --focus-ring-color: var(--primary-400);
  --focus-ring-offset: 2px;

  /* Chart Tokens */
  --chart-mastery: var(--success);
  --chart-pass: var(--primary-500);
  --chart-reassess: var(--error);
  --chart-pattern-strategic: var(--personal-ai);
  --chart-pattern-quick: var(--primary-500);
  --chart-pattern-deep: var(--success);
  --chart-pattern-balanced: var(--mentor-ai);
  --chart-pattern-underdeveloped: var(--error);
  --chart-dimension-level-5: var(--personal-ai);
  --chart-dimension-level-4: var(--success);
  --chart-dimension-level-3: var(--primary-500);
  --chart-dimension-level-2: var(--mentor-ai);
  --chart-dimension-level-1: var(--error);
  --chart-radar-student: var(--personal-ai);
  --chart-radar-cohort: rgba(148, 163, 184, 0.6);

  /* Minimum interactive size (touch target) */
  --target-size-min: 44px;
  --header-h: 56px; /* will be updated dynamically */
}

/* Explicit theme overrides (default is dark). Set data-theme="light" on <html> or <body> to switch. */
:root[data-theme="dark"], [data-theme="dark"] {
  --surface-1: var(--gray-900);
  --surface-2: var(--gray-800);
  --surface-3: var(--gray-700);
  --surface-4: var(--gray-600);
  --surface-overlay: rgba(17, 24, 39, 0.6);
  --surface-overlay-strong: rgba(17, 24, 39, 0.9);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.5);
  --border-subtle: rgba(255, 255, 255, 0.12);
  --placeholder-color: rgba(255, 255, 255, 0.7);
}

:root[data-theme="light"], [data-theme="light"] {
  --surface-1: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #f0f0f0;
  --surface-4: #e8e8e8;
  --surface-overlay: rgba(255, 255, 255, 0.8);
  --surface-overlay-strong: rgba(255, 255, 255, 0.95);
  --text-primary: #111827; /* gray-900 */
  --text-secondary: #374151; /* gray-700 */
  --text-tertiary: #6b7280; /* gray-500 */
  --border-subtle: rgba(17, 24, 39, 0.12);
  --placeholder-color: color-mix(in srgb, var(--text-secondary) 70%, white);
}

/* Respect system preference when no explicit theme is set */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --surface-1: #ffffff;
    --surface-2: #f7f7f7;
    --surface-3: #f0f0f0;
    --surface-4: #e8e8e8;
    --surface-overlay: rgba(255, 255, 255, 0.8);
    --surface-overlay-strong: rgba(255, 255, 255, 0.95);
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-subtle: rgba(17, 24, 39, 0.12);
    --placeholder-color: color-mix(in srgb, var(--text-secondary) 70%, white);
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --surface-1: var(--gray-900);
    --surface-2: var(--gray-800);
    --surface-3: var(--gray-700);
    --surface-4: var(--gray-600);
    --surface-overlay: rgba(17, 24, 39, 0.6);
    --surface-overlay-strong: rgba(17, 24, 39, 0.9);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.12);
    --placeholder-color: rgba(255, 255, 255, 0.7);
  }
}

/* 8pt spacing utilities mapped to tokens (non-Tailwind, prefixed to avoid collision) */
.u-gap-2 { gap: var(--space-2); }
.u-gap-3 { gap: var(--space-3); }
.u-gap-4 { gap: var(--space-4); }
.u-gap-5 { gap: var(--space-5); }
.u-gap-6 { gap: var(--space-6); }
.u-gap-8 { gap: var(--space-8); }
.u-gap-10 { gap: var(--space-10); }
.u-gap-12 { gap: var(--space-12); }
.u-gap-16 { gap: var(--space-16); }

.u-pad-2 { padding: var(--space-2); }
.u-pad-3 { padding: var(--space-3); }
.u-pad-4 { padding: var(--space-4); }
.u-pad-5 { padding: var(--space-5); }
.u-pad-6 { padding: var(--space-6); }
.u-pad-8 { padding: var(--space-8); }

.u-mt-2 { margin-top: var(--space-2); }
.u-mt-3 { margin-top: var(--space-3); }
.u-mt-4 { margin-top: var(--space-4); }
.u-mt-6 { margin-top: var(--space-6); }
.u-mt-8 { margin-top: var(--space-8); }

/* Vertical stack utility: apply margin-top to all but first child */
.u-stack-2 > * + * { margin-top: var(--space-2); }
.u-stack-3 > * + * { margin-top: var(--space-3); }
.u-stack-4 > * + * { margin-top: var(--space-4); }
.u-stack-5 > * + * { margin-top: var(--space-5); }
.u-stack-6 > * + * { margin-top: var(--space-6); }
.u-stack-8 > * + * { margin-top: var(--space-8); }

/* ===== RESET & BASE STYLES ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-variation-settings: normal;
  tab-size: 4;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--surface-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.app-shell {
  min-height: 100vh;
  background-color: var(--surface-1);
  color: var(--text-primary);
}

.theme-backdrop {
  background: color-mix(in srgb, #000 60%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

[data-theme="light"] .theme-backdrop {
  background: color-mix(in srgb, #fff 70%, transparent);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-backdrop {
    background: color-mix(in srgb, #fff 70%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

/* ===== LAYOUT SYSTEM ===== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--surface-1);
  color: var(--text-primary);
  /* Allow page-level scrolling when content overflows */
  overflow-y: auto;
}

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

/* Ensure text-primary works in light theme */
[data-theme="light"] .text-primary {
  color: var(--text-primary) !important;
}

.text-secondary {
  color: var(--text-secondary);
}

[data-theme="light"] .text-secondary {
  color: var(--text-secondary) !important;
}

.text-muted {
  color: color-mix(in srgb, var(--text-secondary) 85%, var(--text-primary));
}

.text-soft {
  color: color-mix(in srgb, var(--text-tertiary) 90%, var(--text-primary));
}

.text-warning {
  color: var(--warning);
}

.text-success {
  color: var(--success);
}

.text-info {
  color: var(--info);
}

.text-danger {
  color: var(--error);
}

.border-subtle {
  border: 1px solid var(--border-subtle);
}

.border-top-subtle {
  border-top: 1px solid var(--border-subtle);
}

.border-bottom-subtle {
  border-bottom: 1px solid var(--border-subtle);
}

.logo-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.logo-mark {
  width: 40px;
  height: 40px;
  display: block;
  object-fit: contain;
}

.signin-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-3);
  display: block;
  object-fit: contain;
}

.link-muted {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  padding: 0;
  transition: color var(--duration-150) var(--ease-out);
}

.link-muted:hover,
.link-muted:focus-visible {
  color: var(--text-primary);
  outline: none;
}

/* Assessment Banner */
.assessment-banner {
  border-left: 4px solid color-mix(in srgb, var(--primary-500) 70%, transparent);
  box-shadow: var(--shadow-lg);
}

.assessment-banner__title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: var(--font-size-base);
}

.assessment-banner__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.assessment-banner__meta {
  display: flex;
  gap: var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.assessment-banner__icon {
  font-size: 1.75rem;
}

[data-theme="light"] .assessment-banner {
  background: color-mix(in srgb, var(--surface-1) 95%, white);
  border-color: color-mix(in srgb, var(--primary-500) 35%, transparent);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .assessment-banner__subtitle,
[data-theme="light"] .assessment-banner__meta {
  color: var(--text-secondary);
}

/* Ensure active/test mode banners keep their gradient backgrounds in light theme */
[data-theme="light"] .assessment-banner--mode-active {
  background: linear-gradient(135deg, var(--personal-ai), color-mix(in srgb, var(--personal-ai) 70%, black));
  border-color: transparent;
}

[data-theme="light"] .assessment-banner--mode-test {
  background: linear-gradient(135deg, var(--info), color-mix(in srgb, var(--primary-600) 60%, black));
  border-color: transparent;
}

.assessment-banner--mode-active,
.assessment-banner--mode-test {
  color: var(--white);
  border: none;
  box-shadow: var(--shadow-xl);
  background: linear-gradient(135deg, var(--personal-ai), color-mix(in srgb, var(--personal-ai) 70%, black));
}

.assessment-banner--mode-test {
  background: linear-gradient(135deg, var(--info), color-mix(in srgb, var(--primary-600) 60%, black));
}

.assessment-banner--mode-active .assessment-banner__title,
.assessment-banner--mode-test .assessment-banner__title {
  color: var(--white);
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
}

.assessment-banner--mode-active .assessment-banner__subtitle,
.assessment-banner--mode-test .assessment-banner__subtitle,
.assessment-banner--mode-active .assessment-banner__meta,
.assessment-banner--mode-test .assessment-banner__meta {
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 2px rgba(15, 23, 42, 0.35);
}

.assessment-banner--mode-active .assessment-banner__meta span,
.assessment-banner--mode-test .assessment-banner__meta span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.assessment-banner--mode-active .btn {
  background: rgba(255, 255, 255, 0.95);
  color: var(--personal-ai);
  border-color: transparent;
}

.assessment-banner--mode-test .btn {
  background: rgba(255, 255, 255, 0.95);
  color: var(--info);
  border-color: transparent;
}

/* ===== SURFACE PRIMITIVES ===== */
.surface-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow);
  color: var(--text-primary);
  transition: border-color var(--duration-150) var(--ease-out), transform var(--duration-150) var(--ease-out);
}

/* Ensure text is visible in light theme for surface cards */
[data-theme="light"] .surface-card {
  color: var(--text-primary);
}

[data-theme="light"] .surface-card h1,
[data-theme="light"] .surface-card h2,
[data-theme="light"] .surface-card h3,
[data-theme="light"] .surface-card h4,
[data-theme="light"] .surface-card h5,
[data-theme="light"] .surface-card h6 {
  color: var(--text-primary);
}

[data-theme="light"] .surface-card .font-medium,
[data-theme="light"] .surface-card .font-semibold {
  color: var(--text-primary);
}

.surface-card--muted {
  background: var(--surface-2);
  border-color: var(--border-subtle);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  backdrop-filter: blur(10px);
  border-color: color-mix(in srgb, var(--border-subtle) 80%, transparent);
}

.surface-card--overlay {
  background: var(--surface-overlay);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-lg);
}

.surface-card--compact {
  padding: var(--space-4);
}

.surface-card--tight {
  padding: var(--space-3);
}

.surface-card__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

.surface-card__subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

.surface-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
  color: var(--text-soft);
}

.surface-card:hover {
  border-color: var(--focus-ring-color);
  border-color: color-mix(in srgb, var(--border-subtle) 40%, var(--focus-ring-color));
}

.surface-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  border: 1px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
}

.surface-chip--muted {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border-color: color-mix(in srgb, var(--border-subtle) 55%, transparent);
}

.list-option {
  border: 1px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  transition: border-color var(--duration-150) var(--ease-out), background var(--duration-200) var(--ease-out), box-shadow var(--duration-150) var(--ease-out);
}

.list-option:hover,
.list-option:focus-visible {
  border-color: color-mix(in srgb, var(--focus-ring-color) 60%, var(--border-subtle));
  background: color-mix(in srgb, var(--surface-2) 95%, transparent);
  box-shadow: var(--shadow);
  outline: none;
}

.media-card {
  padding: 0;
}

.media-card__body {
  padding: var(--space-4);
}

.journal-panel {
  position: fixed;
  top: 5rem;
  right: var(--space-5);
  width: 24rem;
  z-index: 40;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-5);
}

.journal-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.journal-panel__body {
  max-height: calc(80vh - 6rem);
  overflow-y: auto;
  padding-right: var(--space-1);
}

.journal-card {
  margin-bottom: var(--space-3);
}

.journal-card__title {
  color: var(--text-primary);
  font-weight: 600;
}

.journal-card__description {
  color: var(--text-secondary);
}

.journal-card__meta {
  color: var(--text-tertiary);
  font-size: var(--font-size-xs);
}

.journal-card--assessment {
  border-left: 3px solid var(--primary-500);
}

.journal-card--in-progress {
  border-left: 3px solid var(--info);
}

.journal-card--completed {
  border-left: 3px solid var(--success);
  opacity: 0.85;
}

.journal-card--danger {
  border-left: 3px solid var(--error);
}

.journal-card--muted {
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}

.hints-sidebar {
  position: fixed;
  right: var(--space-5);
  top: 6rem;
  width: 20rem;
  z-index: 30;
  transition: transform var(--duration-300) var(--ease-out);
}

.hints-sidebar--hidden {
  transform: translateX(calc(100% + var(--space-4)));
}

.hints-sidebar__hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.35), rgba(59, 130, 246, 0.25));
  margin-bottom: var(--space-3);
  color: #fff;
}

.hints-sidebar__toggle {
  padding: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
}

.hints-sidebar__body {
  max-height: 24rem;
  overflow-y: auto;
}

.hints-sidebar__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-3);
}

.hints-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
}

.hints-switch {
  position: relative;
  width: 2.75rem;
  height: 1.25rem;
  cursor: pointer;
}

.hints-switch__track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--surface-4) 80%, transparent);
  transition: background var(--duration-200) var(--ease-out);
}

.hints-switch__track.is-on {
  background: var(--primary-500);
}

.hints-switch__dot {
  position: absolute;
  top: 0.15rem;
  left: 0.2rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--duration-200) var(--ease-out);
}

.hints-switch__dot.is-on {
  transform: translateX(1.25rem);
}

.toggle-track {
  position: relative;
  width: 2.75rem;
  height: 1.4rem;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--surface-4) 80%, transparent);
  transition: background var(--duration-200) var(--ease-out);
}

.toggle-track--on {
  background: var(--success);
}

.toggle-circle {
  position: absolute;
  top: 0.15rem;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--duration-200) var(--ease-out);
}

.toggle-circle--on {
  transform: translateX(1.2rem);
}

.hints-placeholder {
  text-align: center;
  color: var(--text-soft);
  font-size: var(--font-size-sm);
  padding: var(--space-6) 0;
}

.hint-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
}

.hint-card + .hint-card {
  margin-top: var(--space-2);
}

.hint-card__title {
  font-weight: 600;
  color: var(--text-primary);
}

.hint-card__strength {
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.hint-card__evidence {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
  font-style: italic;
  margin-top: var(--space-2);
}

/* ===== FORM PRIMITIVES ===== */
.form-label {
  display: block;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
}

.form-control {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  line-height: 1.4;
  transition: border-color var(--duration-150) var(--ease-out), box-shadow var(--duration-150) var(--ease-out);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

.form-control:focus {
  outline: none;
  border-color: var(--focus-ring-color);
  box-shadow: 0 0 0 var(--focus-ring-offset) rgba(14, 165, 233, 0.25);
  box-shadow: 0 0 0 var(--focus-ring-offset) color-mix(in srgb, var(--focus-ring-color) 30%, transparent);
}

.form-control--select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% - 3px), calc(100% - 15px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--space-8);
}

.form-control--textarea {
  min-height: 120px;
  resize: vertical;
}

.form-checkbox {
  width: 1rem;
  height: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  accent-color: var(--primary-500);
}

.form-control--small {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
}

.pill-badge {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-3);
  height: 28px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--surface-2) 75%, transparent);
}

.pill-badge--muted {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  border-color: color-mix(in srgb, var(--border-subtle) 65%, transparent);
  color: var(--text-secondary);
}

.section-heading {
  font-size: var(--font-size-xl);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.section-heading--inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.section-heading--small {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-2);
}

.section-heading--subtle {
  color: var(--text-secondary);
}

.media-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.images-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.section-hint {
  font-size: var(--font-size-sm);
  color: var(--text-soft);
}

.info-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  border: 1px solid var(--border-subtle);
}

.info-banner--warning {
  border-color: color-mix(in srgb, var(--warning) 25%, transparent);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface-2));
}

.info-banner__meta {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  font-weight: 600;
}

.info-banner__hint {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
  margin-left: auto;
}

.kpi-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 90%, transparent), color-mix(in srgb, var(--surface-1) 85%, transparent));
}

.kpi-card__label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: var(--space-2);
}

.kpi-card__value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-card__note {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
  margin-top: var(--space-2);
}

.card-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.dashboard-nav-btn {
  width: 100%;
  justify-content: flex-start !important;
  text-align: left;
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  border-color: var(--border-subtle);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.dashboard-nav-btn:not(.active) {
  color: var(--text-secondary);
}

.dashboard-nav-btn.active {
  background: var(--brand-gradient);
  color: var(--white);
  border-color: transparent;
}

.dashboard-nav-btn + .dashboard-nav-btn {
  margin-top: var(--space-2);
}

.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  height: 28px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--surface-2) 75%, transparent);
}

.badge--warning {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}

.badge--success {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
}

.badge--danger {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

.badge--info {
  color: var(--primary-500);
  border-color: color-mix(in srgb, var(--primary-500) 30%, transparent);
  background: color-mix(in srgb, var(--primary-500) 10%, transparent);
}

.stat-pill {
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  min-width: 96px;
}

.stat-pill__value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-300);
}

.stat-pill__label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.checkbox-field__label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.checkbox-field__hint {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.form-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-500);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}

/* Modal overlay/shell moved to unified section below (line ~8660+) */

.dual-list {
  display: grid;
  gap: var(--space-4);
}

.dual-list__panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  padding: var(--space-4);
}

.dual-list__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: var(--space-2);
}

.dual-list__scroll {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-1);
  height: 200px;
  overflow-y: auto;
  padding: var(--space-2);
}

.callout {
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}

.callout--success {
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}

.callout--warning {
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
}

.callout--danger {
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
  background: color-mix(in srgb, var(--error) 12%, transparent);
  color: var(--error);
}

.callout--info {
  border-color: color-mix(in srgb, var(--primary-500) 30%, transparent);
  background: color-mix(in srgb, var(--primary-500) 12%, transparent);
  color: var(--primary-500);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table__head {
  text-transform: uppercase;
  font-size: var(--font-size-xs);
  letter-spacing: 0.08em;
  color: var(--text-soft);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
}

.data-table__row {
  border-bottom: 1px solid var(--border-subtle);
}

.data-table__row--hover:hover {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
}

.table-row--highlight {
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
}

.assessment-card {
  transition: border-color var(--duration-150) var(--ease-out), transform var(--duration-150) var(--ease-out);
}

.assessment-card:hover {
  border-color: var(--focus-ring-color);
  transform: translateY(-2px);
}

.assessment-card__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.assessment-card__toggle {
  color: var(--text-soft);
  transition: color var(--duration-150) var(--ease-out);
}

.assessment-card__toggle:hover,
.assessment-card__toggle:focus-visible {
  color: var(--text-primary);
}

.assessment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.assessment-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-3);
  color: var(--text-primary);
  transition: background-color var(--duration-150) var(--ease-out),
              color var(--duration-150) var(--ease-out),
              border-color var(--duration-150) var(--ease-out),
              transform var(--duration-150) var(--ease-out);
}

.assessment-action-btn:hover:not(:disabled) {
  background: var(--surface-2);
  transform: translateY(-1px);
}

.assessment-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.assessment-action-btn--assign {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, var(--surface-3));
  border-color: color-mix(in srgb, var(--success) 35%, var(--border-subtle));
}

.assessment-action-btn--assign:hover:not(:disabled) {
  background: color-mix(in srgb, var(--success) 18%, var(--surface-2));
}

.assessment-action-btn--analyze,
.assessment-action-btn--test {
  color: var(--info);
  background: color-mix(in srgb, var(--info) 10%, var(--surface-3));
  border-color: color-mix(in srgb, var(--info) 35%, var(--border-subtle));
}

.assessment-action-btn--analyze:hover:not(:disabled),
.assessment-action-btn--test:hover:not(:disabled) {
  background: color-mix(in srgb, var(--info) 16%, var(--surface-2));
}

.assessment-action-btn--history,
.assessment-action-btn--reports,
.assessment-action-btn--duplicate {
  color: var(--text-secondary);
}

.assessment-action-btn--edit {
  background: var(--primary-500);
  border-color: var(--primary-500);
  color: var(--white);
}

.assessment-action-btn--edit:hover:not(:disabled) {
  background: var(--primary-600);
  border-color: var(--primary-600);
}

.assessment-action-btn--delete {
  background: var(--error);
  border-color: var(--error);
  color: var(--white);
}

.assessment-action-btn--delete:hover:not(:disabled) {
  filter: brightness(0.95);
}

.assignment-option {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  transition: border-color var(--duration-150) var(--ease-out), box-shadow var(--duration-150) var(--ease-out), background-color var(--duration-150) var(--ease-out);
}

.assignment-option:hover,
.assignment-option:focus-within {
  border-color: color-mix(in srgb, var(--personal-ai) 40%, transparent);
  box-shadow: var(--shadow-sm);
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
}

.assignment-option input[type="radio"] {
  accent-color: var(--personal-ai);
}

.assignment-option__title {
  font-weight: 600;
  color: var(--text-primary);
}

.assignment-option__meta {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.assignment-callout {
  border-left: 4px solid color-mix(in srgb, var(--personal-ai) 65%, transparent);
  background: color-mix(in srgb, var(--personal-ai) 12%, var(--surface-2));
  border-radius: var(--radius-xl);
  color: var(--text-primary);
  box-shadow: var(--shadow);
}

[data-theme="light"] .assignment-callout {
  background: color-mix(in srgb, var(--surface-1) 95%, color-mix(in srgb, var(--personal-ai) 12%, transparent));
}

.assignment-callout__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--text-primary);
}

.assignment-callout__meta {
  color: var(--text-soft);
  font-size: var(--font-size-sm);
}

/* ===== HAG UPLOAD COMPONENT ===== */
.link-action {
  background: none;
  border: none;
  color: var(--primary-500);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: inherit;
}

.link-action:hover,
.link-action:focus-visible {
  color: var(--primary-600);
  outline: none;
}

.upload-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.upload-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.upload-header__icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.upload-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.upload-dropzone {
  border: 2px dashed color-mix(in srgb, var(--border-subtle) 70%, transparent);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  text-align: center;
  transition: border-color var(--duration-200) var(--ease-out), background var(--duration-200) var(--ease-out), box-shadow var(--duration-150) var(--ease-out);
  cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: color-mix(in srgb, var(--primary-500) 60%, var(--border-subtle));
  background: color-mix(in srgb, var(--surface-2) 95%, transparent);
  box-shadow: var(--shadow);
}

.upload-dropzone__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary-500) 10%, transparent);
}

.upload-dropzone__title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
}

.upload-dropzone__or {
  color: var(--text-soft);
  font-size: var(--font-size-sm);
}

.upload-dropzone__filetypes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  margin: var(--space-5) 0 var(--space-3);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.upload-dropzone__filetypes .file-type {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.upload-dropzone__hint {
  margin-top: var(--space-2);
  color: var(--text-soft);
}

.batch-upload-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.file-queue {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
}

.queue-item__meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.queue-item__name {
  font-weight: 600;
  color: var(--text-primary);
}

.queue-item__size {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.queue-item__remove {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
}

.queue-item__remove:hover,
.queue-item__remove:focus-visible {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 12%, transparent);
  outline: none;
}

.batch-controls {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.batch-controls .btn {
  flex: 1;
}

.upload-progress .progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

#hag-upload-results {
  margin-top: var(--space-4);
}

.query-inspector {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.query-inspector__meta {
  font-weight: 600;
}

.query-inspector__sql {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', 'Fira Code', monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
}

.query-inspector__issues {
  font-weight: 500;
}

.query-inspector__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.query-inspector__actions .btn {
  flex: 1;
  min-width: 140px;
}

.query-inspector__table table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.query-inspector__table thead {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.query-inspector__table th,
.query-inspector__table td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.query-inspector__table tbody tr:last-child td {
  border-bottom: none;
}

.query-inspector__table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-2) 95%, transparent);
}

.query-inspector__suggestions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.suggestion-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  cursor: pointer;
}

.suggestion-row:hover {
  border-color: color-mix(in srgb, var(--focus-ring-color) 60%, var(--border-subtle));
}

.suggestion-row__text {
  flex: 1;
  color: var(--text-primary);
  line-height: 1.4;
}

.calc-preview table {
  width: 100%;
}

.calc-preview th,
.calc-preview td {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.calc-preview thead {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.calc-assumptions__grid {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .calc-assumptions__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.calc-assumptions__actions {
  margin-top: var(--space-4);
  display: flex;
  justify-content: flex-end;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field + .form-field {
  margin-top: 0;
}

.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
  border-top-color: var(--primary-500);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
}

.conversation-highlight {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--warning) 50%, transparent);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
}

.student-item {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: transparent;
  transition: background-color var(--duration-150) var(--ease-out), border-color var(--duration-150) var(--ease-out);
  cursor: pointer;
}

.student-item:hover {
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
}

.student-item--selected {
  border-left: 2px solid var(--primary-400);
  background: color-mix(in srgb, var(--primary-400) 10%, transparent);
}

.app-header {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow);
}

.app-header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  gap: var(--space-4);
}

/* Center flex container should not force tabs to stretch */
.app-header-content > .flex-1 {
  display: flex;
  justify-content: center;
  flex-shrink: 1;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Icon-only header buttons for cleaner UI */
.header-icon-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: color-mix(in srgb, var(--surface-2) 75%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  position: relative;
}

.header-icon-button:hover {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  border-color: color-mix(in srgb, var(--border-subtle) 40%, var(--focus-ring-color));
  color: var(--text-primary);
  transform: translateY(-1px);
}

.header-icon-button:active {
  transform: translateY(0);
}

.header-icon-button i {
  font-size: var(--font-size-base);
}

/* Legacy user profile (deprecated) */
.user-profile {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.user-name {
  color: var(--text-primary);
  font-weight: 600;
}

/* New User Profile Avatar Dropdown */
.user-profile-dropdown {
  position: relative;
}

.user-avatar-button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-200) var(--ease-out);
}

.user-avatar-button:hover {
  transform: scale(1.05);
}

.user-avatar-button:active {
  transform: scale(0.95);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-500), var(--purple-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 600;
  font-size: var(--font-size-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 2px solid var(--surface-2);
  transition: box-shadow var(--duration-200) var(--ease-out);
}

.user-avatar-button:hover .user-avatar {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.user-menu-dropdown {
  width: 240px;
  margin-top: var(--space-2);
}

.user-menu-header {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.user-menu-name {
  font-weight: 600;
  font-size: var(--font-size-base);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.user-menu-email {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
}

.user-menu-items {
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--duration-200) var(--ease-out);
  text-align: left;
  width: 100%;
}

.user-menu-item:hover {
  background: color-mix(in srgb, var(--primary-500) 10%, transparent);
}

.user-menu-item i {
  width: 16px;
  text-align: center;
  color: var(--text-secondary);
}

.user-menu-item--danger {
  color: var(--error);
}

.user-menu-item--danger:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

.user-menu-item--danger i {
  color: var(--error);
}

/* "Soon" badge in menu items */
.user-menu-item .ml-auto {
  margin-left: auto;
}

.notification-trigger {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--error);
  color: var(--surface-1);
  font-size: var(--font-size-xs);
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.25);
  min-width: 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.header-dropdown {
  position: absolute;
  right: 0;
  margin-top: var(--space-2);
  width: 20rem;
  background: var(--surface-overlay);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 50;
  color: var(--text-primary);
}

.header-dropdown__header {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.header-dropdown__list {
  max-height: 24rem;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.app-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0;
  gap: var(--space-6);
  /* Ensure main content uses remaining height after header */
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* Allow scrolling when content overflows */
  overflow-y: auto;
}

#app-content {
  padding: 0 !important;
}

/* ===== RESPONSIVE GRID SYSTEM ===== */
.grid-container {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1fr;
  min-height: calc(100vh - 200px);
}

/* Unified Container for Glass Panel - Mobile First */
.unified-container {
  display: flex;
  flex-direction: column;
  /* Mobile-first: Use dynamic viewport height for better mobile support */
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height */
  max-height: 100vh;
  max-height: 100dvh;
  gap: var(--space-6);
  /* Allow scrolling when content overflows */
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4);
  box-sizing: border-box;
}

.unified-container .panel.primary-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow: hidden;
  min-height: 0; /* Important: allows flex child to shrink */
  box-shadow: none; /* Remove box-shadow for primary-panel */
}

/* Mobile First - Single Column */
@media (min-width: 768px) {
  .grid-container {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .grid-container {
    grid-template-columns: 1.2fr 1fr;
  }
  
  .unified-container {
    gap: var(--space-4);
  }
}

/* Responsive header improvements */
@media (max-width: 1024px) {
  /* Hide logo subtitle on tablets */
  .logo-subtitle {
    display: none;
  }
  
  /* Make tabs slightly smaller */
  .glass-tab-button {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
  }
}

@media (max-width: 768px) {
  /* Mobile: Stack header elements */
  .app-header-content {
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-4);
    gap: var(--space-2);
  }
  
  /* Logo row */
  .logo-container {
    width: 100%;
    justify-content: space-between;
  }
  
  /* Tabs row - full width */
  .app-header-content > .flex-1 {
    width: 100%;
    order: 2;
  }
  
  .glass-tab-nav.centered {
    width: 100%;
  }
  
  /* Icon-only tabs on mobile */
  .glass-tab-button {
    flex: 1;
    padding: var(--space-2);
    font-size: var(--font-size-sm);
    min-width: 0;
  }
  
  /* Actions row */
  .header-actions {
    order: 1;
    margin-left: auto;
    gap: var(--space-2);
  }
  
  /* Ensure full-width layout */
  .app-header-content,
  .app-main {
    max-width: 100%;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 640px) {
  .app-header-content {
    flex-direction: column;
    align-items: stretch;
  }

  .logo-container {
    justify-content: center;
    width: 100%;
  }

  .glass-tab-nav {
    width: 100%;
    justify-content: flex-start;
    gap: var(--space-2);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .glass-tab-nav::-webkit-scrollbar {
    display: none;
  }

  .glass-tab-button {
    flex: 0 0 auto;
    min-width: 56px;
    white-space: nowrap;
  }

  .header-actions {
    width: 100%;
    justify-content: center;
    order: 3;
  }

  .tab-header-controls {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .app-main {
    padding: 0 var(--space-2) var(--space-4);
  }

  .panel.primary-panel {
    border-radius: var(--radius-lg);
  }
}

@media (max-width: 480px) {
  /* Extra small: Hide tab text, show only emoji */
  .glass-tab-button {
    writing-mode: horizontal-tb;
    font-size: var(--font-size-sm);
    padding: var(--space-1) var(--space-2);
  }
  
  /* Hide brand name on very small screens */
  .logo-container h1 {
    font-size: var(--font-size-lg);
  }
}

/* ===== PROGRESSIVE DISCLOSURE SYSTEM ===== */
.hidden { display: none; }
.panel {
  /* Background removed to allow glassmorphism effects */
  border-radius: var(--radius-lg);
  box-shadow: none;
  overflow: hidden;
  transition: all var(--duration-300) var(--ease-out);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel.collapsed {
  opacity: 0.6;
  transform: scale(0.98);
  pointer-events: none;
}

.panel-header {
  padding: var(--space-5) var(--space-6);
  /* Background removed to allow glassmorphism effects */
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  flex-shrink: 0; /* Prevent header from shrinking */
}

.panel-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0; /* Critical: allows flex child to shrink */
  /* Allow scrolling when content overflows instead of hiding */
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.panel-content {
  flex: 1;
  padding: 0.5rem;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Special override for chat panel to remove padding and enable full height chat */
.panel.primary-panel .panel-content {
  padding: 0;
  /* Allow scrolling when content overflows */
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ===== MODERN TAB SYSTEM ===== */
.tab-navigation {
  display: flex;
  /* Background removed to allow glassmorphism effects */
  border-radius: var(--radius-md);
  padding: var(--space-2);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tab-navigation::-webkit-scrollbar {
  display: none;
}

.tab-button {
  flex: 1;
  min-width: max-content;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.tab-button:hover {
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
  color: var(--text-primary);
}

.tab-button.active {
  background: var(--surface-1);
  color: var(--primary-600);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.tab-content {
  display: none;
  animation: fadeInUp var(--duration-300) var(--ease-out);
}

/* ===== TAB CONTENT SYSTEM ===== */
.tab-content {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; }
#chat-content:not(.active), #heuristics-content:not(.active), #knowledge-content:not(.active) { display: none; }
body.pre-chat #chat-content:not(.active) { display: none !important; }

/* ===== PRE-CHAT LAYOUT (centered hero, Chat tab ONLY) ===== */
/* Size and alignment for pre-chat card */
body.pre-chat #chat-content {
  /* Tight vertical spacing with controlled offset, centered horizontally */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 16vh;
}

body.pre-chat #chat-content .panel.primary-panel {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  width: min(92vw, 1200px);
  max-height: calc(100dvh - var(--header-h) - var(--vk-offset, 0px) - env(safe-area-inset-bottom, 0px) - 16px);
  min-height: 320px;
  display: block; /* keep card tight around content in pre-chat */
  /* 1) Remove border around the primary panel container ONLY in pre-chat */
  border: none !important;
  box-shadow: none !important;
  margin-top: 0 !important;
}

body.pre-chat #chat-content .tab-header-controls {
  justify-content: center;
}

body.pre-chat #chat-content #clear-chat-btn,
body.pre-chat #chat-content #chat-fullscreen-toggle {
  display: none !important;
}

body.pre-chat #chat-content .panel.primary-panel .panel-content { flex: 0 0 auto; min-height: 0; overflow: visible; }
body.pre-chat #chat-content .chat-messages { flex: 0 0 auto; min-height: 0; overflow: visible; }
/* Show the chat messages container in pre-chat so introductions are visible */
body.pre-chat #chat-content #chat-messages-modern { display: block !important; }

/* Center the introduction message only in pre-chat for a simple, reversible tweak */
body.pre-chat #chat-content #chat-messages-modern .message.message-assistant .message-content {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  opacity: 0;
  animation: introFade 260ms ease-out forwards;
  will-change: opacity, transform;
}

/* Keep non-intro assistant messages left-aligned once chat begins */
body:not(.pre-chat) #chat-content #chat-messages-modern .message.message-assistant .message-content {
  text-align: left;
}

/* Subtle intro fade-in animation */
@keyframes introFade {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  body.pre-chat #chat-content #chat-messages-modern .message.message-assistant .message-content {
    animation: none;
    opacity: 1;
  }
}
body.pre-chat #chat-content .chat-container { padding: 0; margin-top: 0; border: none; box-shadow: none; }
body.pre-chat #chat-content .panel.primary-panel .panel-content { padding-top: 0; padding-bottom: 0; padding-left: 0; padding-right: 0; }
/* support panels marked with Tailwind-style class p-0 */
body.pre-chat #chat-content .panel-content.p-0 { padding: 0 !important; }
/* support exact class chain panel primary-panel glass-panel */
/* Ensure glass panel has no frame/shadow in pre-chat, even vs. later rules */
body.pre-chat #chat-content .panel.primary-panel.glass-panel,
body.pre-chat #chat-content .panel.primary-panel.glass-panel::before,
body.pre-chat #chat-content .panel.primary-panel.glass-panel::after {
  border: none;
  box-shadow: none;
  background: transparent;
  outline: none;
  margin: 0;
}

/* 2) Double the minimum width for the chat input container ONLY in pre-chat */
/* Pre-chat input sizing; override on small screens below */
body.pre-chat #chat-content .chat-input-wrapper { min-width: 640px; }

/* 3) Model selector width in pre-chat should match regular chat (full available width) */
body.pre-chat #chat-content .model-selector-container { width: 100%; }
body.pre-chat #chat-content #model-selector-chat { width: 100%; }
/* also target any select inside model-selector container */
body.pre-chat #chat-content .model-selector-container select { width: 100%; }

/* 4) Center the text (selected label) inside the model selector in pre-chat */
body.pre-chat #chat-content #model-selector-chat {
  text-align: center;
  text-align-last: center;
}
body.pre-chat #chat-content #model-selector-chat option { text-align: center; }
/* fallback: center text for selects inside container */
body.pre-chat #chat-content .model-selector-container select { text-align: center; text-align-last: center; }

/* Hide chat composer in non-chat tabs */
.chat-input-container { display: none; }
#chat-content .chat-input-container { display: block; }
#heuristics-content .chat-input-container, #knowledge-content .chat-input-container { display: none; }

/* Make primary panels content-sized (instead of stretching) across tabs */
.tab-content .panel.primary-panel { flex: 0 0 auto; display: block; width: auto; max-width: none; }
.tab-content .panel.primary-panel .panel-content { min-height: 0; }

body.pre-chat #chat-content .chat-input-container {
  position: static;
}

@media (max-width: 768px) {
  body.pre-chat #chat-content .panel.primary-panel {
    max-width: 100%;
    padding-left: var(--space-3);
    padding-right: var(--space-3);
    width: 100%;
  }
  body.pre-chat #chat-content .tab-header-controls {
    padding-left: 0;
    padding-right: 0;
  }
}

/* Mobile responsiveness fixes without changing desktop behavior */
@media (max-width: 640px) {
  /* Reduce top padding so content is visible earlier */
  body.pre-chat #chat-content { padding-top: 8vh; }
  /* Ensure panels and inputs span the viewport width */
  body.pre-chat #chat-content .chat-input-wrapper { min-width: 0; width: 100%; }
  body.pre-chat #chat-content .panel.primary-panel { width: 100%; margin-left: 0; margin-right: 0; }
  /* Intro message should not be constrained on small screens */
  body.pre-chat #chat-content #chat-messages-modern .message.message-assistant .message-content { max-width: 100%; }
}

@media (max-width: 768px) {
  /* In active chat, let the primary panel fill the width on mobile */
  body:not(.pre-chat) .tab-content .panel.primary-panel { width: 100%; max-width: 100%; }
}

/* Extra compact layout for very small devices (e.g., iPhone SE) */
@media (max-width: 390px) {
  /* Bring content higher and tighten side gutters */
  body.pre-chat #chat-content { padding-top: 6vh; }
  body.pre-chat #chat-content .panel.primary-panel { padding-left: var(--space-2); padding-right: var(--space-2); }
  body.pre-chat #chat-content #model-selector-chat { font-size: 0.9rem; }
  /* Tighter, more readable intro bubble */
  body.pre-chat #chat-content #chat-messages-modern .message.message-assistant .message-content {
    font-size: 0.92rem;
    line-height: 1.35;
    padding: var(--space-3) var(--space-4);
    border-radius: 14px;
  }
}

/* Remove frame/shadow on primary chat panel in all modes (desktop + mobile) */
#chat-content .panel.primary-panel.glass-panel,
#chat-content .panel.primary-panel.glass-panel::before,
#chat-content .panel.primary-panel.glass-panel::after {
  border: none;
  box-shadow: none;
  background: transparent;
  outline: none;
}

/* ===== BUTTON SYSTEM (standardized) ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  min-height: var(--target-size-min);
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--duration-200) var(--ease-out),
              border-color var(--duration-200) var(--ease-out),
              color var(--duration-200) var(--ease-out),
              box-shadow var(--duration-200) var(--ease-out),
              transform var(--duration-150) var(--ease-out);
}

.btn-small {
  padding: var(--space-2) var(--space-3);
  min-height: 32px;
  font-size: var(--font-size-xs);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary-500);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-600);
}

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

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error);
  color: var(--white);
}

.btn-danger:hover {
  filter: brightness(0.95);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* Tab Header Controls - Model Selector for each tab */
.tab-header-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3);
  flex-shrink: 0;
  background: transparent;
  backdrop-filter: blur(8px);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Make model selector and chat input span the pre-chat column */
.pre-chat .tab-header-controls,
.pre-chat .chat-input-wrapper,
.pre-chat .model-selector-container,
.pre-chat #model-selector-chat {
  width: 100%;
}

.pre-chat .chat-input-wrapper textarea.chat-input {
  width: 100%;
}

/* ===== Chat Look & Feel - Compact Navy Cards (screenshot match) ===== */
/* Panel surface and elevation */
/* Color scheme: match post-chat card exactly */
body:not(.pre-chat) #chat-content .chat-container,
body:not(.pre-chat) .tab-content#chat-content .chat-container,
body:not(.pre-chat) .panel.primary-panel.glass-panel {
  /* Flatten panel in regular chat too */
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: var(--radius-xl);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  width: min(92vw, 1200px);
}

/* Message bubbles */
.message.message-assistant .message-content,
.message.message-ai .message-content {
  background: linear-gradient(180deg, rgba(20, 30, 48, 0.85), rgba(15, 25, 40, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-xl);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .message.message-assistant .message-content,
[data-theme="light"] .message.message-ai .message-content {
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--border-subtle) 80%, transparent);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.message.message-user .message-content {
  background: linear-gradient(180deg, rgba(38, 18, 71, 0.9), rgba(33, 14, 63, 0.9));
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: var(--radius-xl);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .message.message-user .message-content {
  background: linear-gradient(180deg, rgba(92, 47, 181, 0.12), rgba(67, 0, 123, 0.12));
  border: 1px solid color-mix(in srgb, var(--primary-500) 35%, transparent);
}

/* Timestamps/meta lighter, compact spacing */
.message .message-meta, .message .timestamp, .message .message-timestamp {
  color: rgba(255, 255, 255, 0.6) !important;
  font-size: 12px;
}

[data-theme="light"] .message .message-meta,
[data-theme="light"] .message .timestamp,
[data-theme="light"] .message .message-timestamp {
  color: var(--text-soft) !important;
}


/* Composer as pill with accent send button */
.chat-input-wrapper {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  padding: var(--space-3) var(--space-4);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 8px 20px rgba(0,0,0,0.25);
}

[data-theme="light"] .chat-input-wrapper {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.chat-input {
  padding-left: var(--space-3);
}

[data-theme="light"] .chat-input {
  color: var(--text-primary);
  background: transparent;
}

#chat-attach-button,
.chat-attach-button {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  width: var(--target-size-min);
  height: var(--target-size-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter var(--duration-150) var(--ease-out);
}

#chat-attach-button:hover, .chat-attach-button:hover { filter: brightness(1.1); }

.chat-send-button {
  background: linear-gradient(180deg, #7c3aed, #6d28d9);
  border: 1px solid rgba(168, 85, 247, 0.4);
  width: var(--target-size-min);
  height: var(--target-size-min);
  border-radius: var(--radius-full);
}

[data-theme="light"] #chat-attach-button,
[data-theme="light"] .chat-attach-button {
  background: color-mix(in srgb, var(--surface-3) 85%, transparent);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

[data-theme="light"] .chat-send-button {
  background: var(--primary-500);
  border-color: color-mix(in srgb, var(--primary-500) 70%, transparent);
  color: #fff;
}

.chat-send-button:hover { filter: brightness(1.05); }

/* Hint line right-aligned (if present) */
.composer-hint, .chat-hint {
  text-align: right;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}

/* Header: Notifications bell pill style */
#notifications-button {
  border-radius: var(--radius-full);
  min-height: var(--target-size-min);
  padding: 0 var(--space-3);
  border-color: var(--border-subtle);
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#notifications-button:hover {
  background: color-mix(in srgb, var(--surface-2) 95%, transparent);
}

/* Make model selector shrink so control buttons remain visible */
.tab-header-controls .model-selector-container {
  flex: 1 1 auto;
  min-width: 0;
}
.tab-header-controls .model-selector-container select {
  width: 100%;
}
.tab-header-controls #voice-assistant-toggle,
.tab-header-controls #chat-fullscreen-toggle,
.tab-header-controls #clear-chat-btn {
  flex: 0 0 auto;
}

@media (max-width: 768px) {
  .tab-header-controls {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: var(--space-2);
    align-items: center;
  }
}

/* ===== CHAT LOADING SPINNER ===== */
.chat-loading-container {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  min-height: 200px;
  opacity: 0.8;
  background: rgba(0, 0, 0, 0.05);
  border: 2px solid #3b82f6;
  border-radius: 8px;
  margin: 16px;
}

.chat-loading-spinner {
  position: relative;
  width: 60px;
  height: 60px;
  margin-bottom: 16px;
}

.spinner-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top: 3px solid var(--primary-500);
  border-radius: 50%;
  animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(1) {
  animation-delay: 0s;
  opacity: 1;
}

.spinner-ring:nth-child(2) {
  animation-delay: 0.3s;
  opacity: 0.7;
  transform: scale(0.8);
}

.spinner-ring:nth-child(3) {
  animation-delay: 0.6s;
  opacity: 0.4;
  transform: scale(0.6);
}

.loading-text {
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin: 0;
  animation: pulse 2s ease-in-out infinite;
}

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

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

/* Hide loading spinner by default - will be shown/hidden by JavaScript */
.chat-loading-container.hidden {
  display: none !important;
}

/* Force show when not hidden */
.chat-loading-container:not(.hidden) {
  display: flex !important;
}

/* ===== CHAT INTERFACE - MODERN & FRIENDLY ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  /* Use flex to fill available space, accounting for chat input */
  flex: 1;
  min-height: 0;
  /* Allow scrolling when content overflows */
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  width: 100%;
  max-width: 1200px; /* ensure container can expand to main column width */
  margin-left: auto;
  margin-right: auto;
  /* Enhanced glassmorphism with optimal transparency for background visibility */
  /* Ensure proper height calculation for sticky input */
  height: 100%;
  background: transparent;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255, 255, 255, 0.3);
  /* Ensure proper layering */
  z-index: 1;
  /* Enhanced glassmorphism shadow */
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* ===== Fullscreen Chat Mode ===== */
.chat-fullscreen-active {
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  border-radius: 0;
  border: none;
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
}

.chat-fullscreen-active .chat-messages {
  max-height: calc(100vh - 140px - var(--vk-offset, 0px));
  max-height: calc(100dvh - 140px - var(--vk-offset, 0px));
  /* Allow messages to breathe in fullscreen */
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

/* Fullscreen header status positioning */
#chat-content .chat-fullscreen-active ~ #chat-header-status {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 10001;
  text-align: center;
  padding: var(--space-2) var(--space-6);
}

/* Fullscreen chat input positioning - must override #chat-content selector */
#chat-content .chat-fullscreen-active ~ .chat-input-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  width: 100%;
  max-width: none;
  display: block;
  background: linear-gradient(to top, rgba(17,24,39,0.8), rgba(17,24,39,0));
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

/* Center and size input wrapper in fullscreen mode */
#chat-content .chat-fullscreen-active ~ .chat-input-container .chat-input-wrapper {
  max-width: clamp(80ch, 75vw, 120ch);
  margin-left: auto;
  margin-right: auto;
}

/* Widen and center message column in fullscreen */
.chat-fullscreen-active .message.message-assistant,
.chat-fullscreen-active .message.message-ai,
.chat-fullscreen-active .message.message-system {
  align-items: center;
  margin-right: 0;
}

.chat-fullscreen-active .message.message-user {
  align-items: center;
  margin-left: 0;
  max-width: 100%;
}

.chat-fullscreen-active .message-content {
  /* Expand readable measure while avoiding edge-to-edge lines */
  max-width: clamp(80ch, 75vw, 120ch);
  margin-left: auto;
  margin-right: auto;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4);
  scrollbar-width: thin;
  /* Ensure proper scrolling behavior with sticky input */
  padding-bottom: var(--space-2);
  /* Allow content to scroll above the sticky input */
  margin-bottom: 0;
  scrollbar-color: var(--gray-400) transparent;
  /* Disable smooth scrolling to avoid jitter during streaming updates */
  scroll-behavior: auto;
  /* Prevent browser scroll anchoring from fighting app autoscroll */
  overflow-anchor: none;
  /* Prevent scroll chaining/bounce to parent */
  overscroll-behavior: contain;
  /* Provide a small bottom buffer so last line doesn't snap to edge */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--vk-offset, 0px) + var(--space-3));
  min-height: 0;
  max-height: calc(100vh - 320px - var(--vk-offset, 0px));
  max-height: calc(100dvh - 320px - var(--vk-offset, 0px));
  position: relative;
  width: 100%;
  box-sizing: border-box;
  /* Ensure proper flex behavior within constrained container */
}

/* Hide chat-messages container when empty */
.chat-messages.empty {
  display: none;
}

/* Keep chat container visible even when empty so top controls remain accessible */
.chat-container.empty {
  display: flex;
  /* Keep only the header controls visible when empty */
  height: auto;
}

.chat-messages::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, rgba(250, 250, 249, 0.95), transparent);
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.chat-messages.has-scrolled::before {
  opacity: 1;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: transparent;
}


.message {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  width: 100%;
  position: relative;
  animation: slideInMessage 120ms var(--ease-out) forwards;
  opacity: 0;
  transform: translateY(10px);
}

.message.message-user {
  align-items: flex-end;
  margin-left: 20%;
  max-width: 80%; /* Ensure user messages don't overflow */
  box-sizing: border-box;
}

.message.message-assistant,
.message.message-ai,
.message.message-system {
  align-items: flex-start;
  margin-right: 20%;
}

/* Enhanced Message content styling - modern typography and spacing */
.message-content {
  flex: 1;
  max-width: 100%;
  width: 100%;
  background: transparent;
  border: none;
  padding: var(--space-4) var(--space-5);
  margin: 0;
  border-radius: var(--radius-lg);
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.7;
  font-size: 0.975rem;
  color: var(--text-primary);
  font-feature-settings: "liga" 1, "kern" 1;
  text-rendering: optimizeLegibility;
  box-sizing: border-box;
  /* Readability guardrails */
  max-width: 72ch;
  /* center within message column */
  margin-left: 0;
  margin-right: 0;
}

/* Enhanced Header Hierarchy with Modern Typography */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin: 1.5em 0 0.5em 0;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  scroll-margin-top: 1rem;
}

.message-content h1 {
  font-size: 1.75rem;
  border-bottom: 2px solid var(--primary-500);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  /* Fallback solid color to ensure visibility on browsers without text clipping */
  color: var(--text-primary);
}

/* Use gradient text only when supported to avoid invisible headings */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .message-content h1 {
    background: linear-gradient(135deg, var(--primary-400), var(--blue-400));
    -webkit-background-clip: text;
    background-clip: text;
    /* Do NOT force transparent fill; some browsers render invisible text.
       Keep the solid color fallback so headings are always visible. */
  }
}

.message-content h2 {
  font-size: 1.4rem;
  color: var(--blue-300);
  border-left: 4px solid var(--primary-500);
  padding-left: 1rem;
  margin-left: -1rem;
  position: relative;
}

.message-content h3 {
  font-size: 1.2rem;
  color: var(--blue-200);
  position: relative;
}

.message-content h3::before {
  content: "▸";
  color: var(--primary-400);
  margin-right: 0.5rem;
  font-weight: bold;
}

.message-content h4 {
  font-size: 1.05rem;
  color: var(--gray-200);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Enhanced Paragraph Styling with Visual Hierarchy */
.message-content p {
  margin: 0.9em 0;
  color: var(--text-primary);
  line-height: 1.7;
}

.message-content p:first-child {
  margin-top: 0;
}

.message-content p:last-child {
  margin-bottom: 0;
}

/* Improved Section Spacing - add more breathing room */
.message-content h2 + p,
.message-content h3 + p,
.message-content strong[class*="label-"] + * {
  margin-top: 0.5em;
}

/* Add visual separation between major sections */
.message-content > * + h2,
.message-content > * + h3 {
  margin-top: 2em;
}

/* Improve list-to-content spacing */
.message-content ul + p,
.message-content ol + p,
.message-content p + ul,
.message-content p + ol {
  margin-top: 1.2em;
}

/* Better spacing for nested content after labels */
.message-content strong[class*="label-"] {
  margin-top: 1.5em;
}

.message-content strong[class*="label-"]:first-child {
  margin-top: 0;
}

/* Enhanced Text Formatting */
.message-content strong {
  font-weight: 700;
  color: var(--blue-200);
  text-shadow: 0 0 1px rgba(59, 130, 246, 0.3);
}

.message-content em {
  font-style: italic;
  color: var(--purple-300);
  font-weight: 500;
}

/* Semantic Label Styling - Auto-color common label patterns */
/* Classes are added via JavaScript based on text content */
.message-content strong.label-pros,
.message-content strong.label-benefits,
.message-content strong.label-advantages {
  color: var(--success, #10b981) !important;
  font-weight: 700;
}

.message-content strong.label-cons,
.message-content strong.label-drawbacks,
.message-content strong.label-disadvantages,
.message-content strong.label-tradeoffs {
  color: var(--warning, #f59e0b) !important;
  font-weight: 700;
}

.message-content strong.label-summary,
.message-content strong.label-overview,
.message-content strong.label-tldr {
  color: var(--primary-300) !important;
  font-weight: 700;
  font-size: 1.05em;
}

.message-content strong.label-example,
.message-content strong.label-examples,
.message-content strong.label-demo {
  color: var(--purple-300) !important;
  font-weight: 700;
}

.message-content strong.label-next,
.message-content strong.label-action,
.message-content strong.label-actions {
  color: var(--info, #3b82f6) !important;
  font-weight: 700;
}

.message-content strong.label-note,
.message-content strong.label-important,
.message-content strong.label-warning {
  color: var(--warning, #f59e0b) !important;
  font-weight: 700;
}

.message-content strong.label-why,
.message-content strong.label-reason {
  color: var(--blue-300) !important;
  font-weight: 700;
}

/* Add breathing room after labels */
.message-content strong[class*="label-"] {
  display: inline-block;
  margin-bottom: 0.3em;
}

/* Modern List Styling */
.message-content ul,
.message-content ol {
  margin: 1.1em 0;
  padding-left: 0;
  list-style: none;
}

.message-content ul li,
.message-content ol li {
  margin: 0.5em 0; /* tighter list item vertical rhythm */
  padding-left: 1.5rem;
  position: relative;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Custom Bullet Points - Enhanced with better positioning */
.message-content ul li::before {
  content: "●";
  color: var(--primary-400);
  font-size: 0.8rem;
  position: absolute;
  left: 0.5rem;
  top: 0.35em; /* Better vertical alignment */
  line-height: 1;
}

/* Only enable hover effects on completed messages to prevent streaming flashes */
.message:not(.streaming-message) .message-content ul li::before {
  transition: color 0.2s ease;
}

.message:not(.streaming-message) .message-content ul li:hover::before {
  color: var(--primary-300);
}

/* Nested List Styling - Enhanced with proper visual hierarchy */
.message-content ul ul {
  margin: 0.5em 0 0.5em 0;
  padding-left: 1.5rem;
}

.message-content ul ul li::before {
  content: "◦";
  color: var(--blue-400);
  font-size: 0.9rem;
  top: 0.3em;
}

.message-content ul ul ul {
  margin: 0.3em 0;
  padding-left: 1.5rem;
}

.message-content ul ul ul li::before {
  content: "▪";
  color: var(--purple-400);
  font-size: 0.7rem;
  top: 0.4em;
}

/* Add subtle left border for nested lists to show hierarchy */
.message-content ul ul {
  border-left: 1px solid rgba(59, 130, 246, 0.15);
  padding-left: 1.8rem;
}

.message-content ul ul ul {
  border-left: 1px solid rgba(139, 92, 246, 0.15);
}

/* Numbered Lists */
.message-content ol {
  counter-reset: list-counter;
}

.message-content ol li {
  counter-increment: list-counter;
}

.message-content ol li::before {
  content: counter(list-counter) ".";
  color: var(--primary-400);
  font-weight: 600;
  position: absolute;
  left: 0;
  top: 0;
  min-width: 1.2rem;
}

.message-content code:not(.code-block code) {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
  font-size: 0.85em;
  color: var(--blue-200);
  font-weight: 500;
}

/* Enhanced Blockquotes */
.message-content blockquote {
  margin: 1.5em 0;
  padding: 1rem 1.5rem;
  border-left: 4px solid var(--primary-500);
  background: rgba(59, 130, 246, 0.05);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--gray-200);
  position: relative;
  overflow: hidden;
}

.message-content blockquote::before {
  content: '"';
  position: absolute;
  top: -0.5rem;
  left: 1rem;
  font-size: 3rem;
  color: var(--primary-400);
  opacity: 0.3;
  font-family: Georgia, serif;
}

.message.message-user .message-content {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  border-bottom-left-radius: var(--radius);
}

/* User message alignment - keep bubble on right but left-align text like typical chat apps */
.message.message-user .message-content > p:only-child {
  text-align: left;
}

.message.message-assistant .message-content,
.message.message-ai .message-content {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  border-bottom-left-radius: var(--radius);
}

.message.message-system .message-content {
  background: transparent;
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  font-style: italic;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* ===== STICKY CHAT HEADER ===== */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chat-clear-button {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
}

.chat-clear-button:hover {
  background: var(--gray-200);
  border-color: var(--gray-300);
}

/* User message meta alignment */
.message.message-user .message-meta {
  flex-direction: row-reverse; /* Align timestamp to right for user messages */
  justify-content: flex-end;
}

/* Day Divider Styles */
.day-divider {
  position: sticky;
  top: 60px; /* Below chat header */
  z-index: 25;
  text-align: center;
  margin: var(--space-4) 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--gray-600);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: var(--shadow-sm);
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}

.model-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* Improve timestamp readability for user messages */
.message.user .message-meta,
.message.user .timestamp {
  color: rgba(255, 255, 255, 0.863) !important; /* Match message text color */
  text-shadow: none;
  font-weight: 500;
}

/* For inline Tailwind classes in user messages */
.message.user .text-blue-100 {
  color: #2d3748 !important; /* Override light blue text with dark gray */
}

/* REMOVED: Duplicate processing container styles - consolidated below */

/* REMOVED: Duplicate processing styles - consolidated in main processing container section */

/* REMOVED: Duplicate processing container collapsed state - consolidated in main section */

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  margin-bottom: 16px;
  animation: fadeInUp 0.3s ease-out;
  opacity: 0.7;
}

/* Thinking message styling */
.message-thinking {
  opacity: 0.8;
}

.typing-cursor {
  color: #3b82f6;
  font-weight: bold;
  animation: typingCursorBlink 1s infinite;
}

.typing-text {
  color: #6b7280;
  font-style: italic;
}

/* Blinking cursor animation for typing indicator */
@keyframes typingCursorBlink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

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

.typing-dot, .typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--gray-400);
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1), .typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2), .typing-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ===== PROCESSING INDICATOR - ENHANCED UI FEEDBACK ===== */
/* Global Processing Container Toggle */

.processing-toggle {
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  transition: all var(--duration-200) var(--ease-out);
  margin-left: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
}

.processing-toggle:hover {
  background-color: var(--gray-100);
  border-color: var(--gray-400);
}

.processing-sections {
  transition: all var(--duration-300) var(--ease-out);
}

.processing-sections.collapsed {
  display: none;
}

/* ✅ LEGACY: processing-container.collapsed styles removed */





/* ✅ LEGACY: Dark theme processing-container styles removed */

/* JSON Formatting Styles */
.json-block {
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  margin: 8px 0;
  overflow: hidden;
}

.json-block pre {
  margin: 0;
  padding: 12px 16px;
  background: transparent;
  border: none;
  font-family: 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.json-block code {
  background: transparent;
  padding: 0;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

[data-theme="dark"] .json-block {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Processing Content Styling */
.processing-content {
  padding: 16px 20px;
  position: relative;
  z-index: 1;
}

.streaming-text {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.streaming-text::-webkit-scrollbar {
  width: 6px;
}

.streaming-text::-webkit-scrollbar-track {
  background: transparent;
}

.streaming-text::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.streaming-text::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* REMOVED: Duplicate processing container collapsed and header styles - consolidated in main section */

/* REMOVED: Duplicate processing container styles - consolidated in main processing container section */

/* Model Selector Styling */
#model-selector {
  background: rgba(255, 255, 255, 0.1) !important;
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle) !important;
  color: var(--gray-800) !important;
}

#model-selector:focus {
  background: rgba(255, 255, 255, 0.15) !important;
  border-color: var(--primary-500) !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1) !important;
}

/* Placeholder Styling */
input::placeholder,
textarea::placeholder,
#chat-input::placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder,
#chat-input::-webkit-input-placeholder {
  color: var(--placeholder-color);
}

input::-moz-placeholder,
textarea::-moz-placeholder,
#chat-input::-moz-placeholder {
  color: var(--placeholder-color);
  opacity: 1;
}

/* Tab Navigation Styling */
.panel-header .glass-tab-nav,
.glass-tab-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  /* Remove width: 100% to let it fit content */
  width: auto;
}

.panel-header .glass-tab-nav.centered,
.glass-tab-nav.centered {
  justify-content: center;
  /* Compact width - only as wide as needed */
  width: auto;
}

.glass-tab-button {
  background: color-mix(in srgb, var(--surface-2) 75%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  transition: background-color var(--duration-150) var(--ease-out),
              border-color var(--duration-150) var(--ease-out),
              color var(--duration-150) var(--ease-out),
              transform var(--duration-150) var(--ease-out);
  font-size: var(--font-size-sm);
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}

.glass-tab-button:hover {
  background: color-mix(in srgb, var(--surface-2) 90%, transparent);
  border-color: color-mix(in srgb, var(--border-subtle) 40%, var(--focus-ring-color));
  color: var(--text-primary);
  transform: translateY(-1px);
}

.glass-tab-button.active {
  background: var(--brand-gradient);
  border-color: color-mix(in srgb, var(--primary-500) 35%, transparent);
  color: var(--white);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary-500) 30%, transparent);
}

/* Send Button Font Size Fix */
.send-button,
button[type="submit"],
#send-button {
  font-size: 0.85rem !important;
}

/* New Button Visibility Control */
.new-message-button,
.go-to-latest-button,
#new-button {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.new-message-button.hidden,
.go-to-latest-button.hidden,
#new-button.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Message Meta Styling Fix */
.message-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.6);
  margin-top: var(--space-1);
}

.message.message-user .message-meta {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

/* Model Sub-Tab Styling */
.model-sub-tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
}

.model-sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.model-sub-tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color var(--duration-150) var(--ease-out),
              border-color var(--duration-150) var(--ease-out);
}

.model-sub-tab-btn:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-subtle);
}

.model-sub-tab-btn.active {
  color: var(--primary-500);
  border-bottom-color: var(--primary-500);
}

.model-sub-tab-content {
  display: none;
}

.model-sub-tab-content.active {
  display: block;
}

/* Mobile: stack Reasoning subtabs and allow wrap */
@media (max-width: 768px) {
  .model-sub-tab-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .model-sub-tabs {
    width: 100%;
  }
  .model-sub-tab-btn {
    flex: 1 1 45%;
    text-align: center;
  }
}

.permission-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  flex-wrap: wrap;
}

.permission-banner__status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.permission-banner__status--owner {
  color: var(--success);
}

.permission-banner__status--readonly {
  color: var(--warning);
}

.permission-banner__status--default {
  color: var(--text-secondary);
}

.permission-banner__hint {
  color: var(--text-soft);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--gray-700);
  font-size: var(--font-size-sm);
}

.section-header:hover {
  background: var(--gray-100);
}

.section-header.expanded {
  background: var(--blue-50);
}

.section-icon {
  margin-right: 8px;
}

.section-title {
  flex: 1;
}

.toggle-arrow {
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  transition: transform var(--duration-200) var(--ease-out);
}

.section-header.expanded .toggle-arrow {
  transform: rotate(180deg);
}

.section-content {
  padding: var(--space-4);
  max-height: 300px;
  overflow-y: auto;
  transition: all var(--duration-300) var(--ease-out);
}

.section-content.hidden {
  display: none;
}

/* ✅ LEGACY: Processing container audit mode styles removed */

.processing-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--primary-200);
  border-top: 2px solid var(--primary-500);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}

/* REMOVED: Duplicate processing-text and processing-timer styles - consolidated in main section */

/* KB Summary Styles */
.kb-summaries-section {
    margin-bottom: 2rem;
}

.kb-summary-card {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    border: 1px solid #4b5563;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.kb-summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0.8;
}

.kb-summary-card.private-summary::before {
    background: linear-gradient(90deg, #10b981, #3b82f6);
}

.kb-summary-card.model-summary::before {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.kb-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border-color: #6b7280;
}

.kb-summary-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.kb-summary-icon {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.private-summary .kb-summary-icon {
    background: linear-gradient(135deg, #10b981, #3b82f6);
}

.model-summary .kb-summary-icon {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.kb-summary-title h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f9fafb;
    margin: 0 0 0.25rem 0;
    line-height: 1.3;
}

.kb-summary-meta {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 400;
}

.kb-summary-content {
    color: #d1d5db;
    line-height: 1.6;
    font-size: 0.9rem;
}

.kb-summary-content p {
    margin: 0;
    text-align: justify;
}

.kb-summary-empty {
    text-align: center;
    padding: 2rem;
    background: #1f2937;
    border: 2px dashed #4b5563;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.kb-summary-empty p {
    margin: 0.5rem 0;
}

/* Responsive adjustments for KB summaries */
@media (max-width: 768px) {
    .kb-summary-card {
        padding: 1rem;
    }
    
    .kb-summary-header {
        gap: 0.5rem;
    }
    
    .kb-summary-icon {
        width: 2rem;
        height: 2rem;
    }
    
    .kb-summary-title h4 {
        font-size: 1rem;
    }
    
    .kb-summary-content {
        font-size: 0.85rem;
    }
}

/* ===== CHAT INPUT - MODERN & ACCESSIBLE ===== */
.chat-input-container {
  flex-shrink: 0;
  padding: var(--space-4);
  /* Completely transparent - no visual effects */
  background: transparent;
  /* Ensure input stays at bottom and is always visible */
  position: sticky;
  bottom: 0;
  z-index: 10;
  /* Ensure the chat-input wrapper bottom border is fully visible */
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + var(--vk-offset, 0px) + var(--space-4));
  /* Add margin to prevent cutoff when content is long */
  margin-top: auto;
  /* Ensure minimum spacing from bottom */
  margin-bottom: var(--space-2);
}

.chat-input-wrapper {
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
  /* Glassmorphism with high transparency */
  background: transparent;
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  transition: all var(--duration-200) var(--ease-out);
  position: relative;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-input-wrapper:focus-within {
  /* Enhanced glassmorphism on focus */
  background: transparent;
  border-color: rgba(14, 165, 233, 0.4);
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 0 3px rgba(14, 165, 233, 0.15),
    0 4px 16px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 400; /* Improved from 300 for better readability */
  min-height: 20px;
  max-height: 144px; /* Expandable to 6 lines (24px * 6) */
  outline: none;
  padding: var(--space-2) 0;
  transition: max-height var(--duration-200) var(--ease-out);
}

.chat-input::placeholder {
  color: var(--gray-500);
}

.chat-send-button {
  background: var(--primary-500);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  width: var(--target-size-min);
  height: var(--target-size-min);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  flex-shrink: 0;
}

.chat-send-button:hover {
  background: var(--primary-600);
  transform: scale(1.05);
}

.chat-send-button:active {
  transform: scale(0.95);
}

.chat-send-button:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
  transform: none;
}

/* ===== CHAT STOP BUTTON ===== */
.chat-stop-button {
  background: var(--error, #ef4444);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  width: var(--target-size-min);
  height: var(--target-size-min);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  flex-shrink: 0;
  margin-left: var(--space-2);
  font-size: 14px;
  font-weight: 500;
}

.chat-stop-button:hover {
  background: #dc2626;
  transform: scale(1.05);
}

.chat-stop-button:active {
  transform: scale(0.95);
}

.chat-stop-button.hidden {
  display: none;
}

.chat-send-button.hidden {
  display: none;
}

/* ===== DOCUMENT DRAG & DROP - CHAT ATTACHMENTS ===== */

/* Drag over visual feedback */
.chat-input-wrapper.drag-over-documents {
  border-color: rgba(14, 165, 233, 0.6) !important;
  background: rgba(14, 165, 233, 0.05) !important;
  box-shadow: 
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 0 3px rgba(14, 165, 233, 0.25),
    0 4px 20px rgba(14, 165, 233, 0.15) !important;
  backdrop-filter: blur(20px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
  transform: scale(1.02);
  transition: all 0.2s ease;
}

/* Drag overlay */
.chat-drag-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(14, 165, 233, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
  border-radius: var(--radius-xl);
  border: 2px dashed rgba(14, 165, 233, 0.4);
  pointer-events: none; /* Prevent overlay from blocking drag events */
}

.drag-overlay-content {
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.drag-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  animation: bounce 1s infinite;
}

.drag-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.drag-subtext {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(-4px);
  }
}

/* Attached documents container */
.attached-documents-container {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

/* Document pills */
.document-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  transition: all 0.2s ease;
  max-width: 250px;
  position: relative;
}

.document-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.document-pill.processing {
  border-color: rgba(255, 193, 7, 0.4);
  background: rgba(255, 193, 7, 0.05);
}

.document-pill.ready {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.05);
}

.document-pill.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.05);
}

.document-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.document-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.document-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.95);
}

.document-size {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.1rem;
}

.document-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
}

.document-remove {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: none;
  background: rgba(239, 68, 68, 0.8);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10;
}

.document-pill:hover .document-remove {
  opacity: 1;
}

.document-remove:hover {
  background: rgba(220, 38, 38, 0.9);
  transform: scale(1.1);
}

/* Spinner for processing documents */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 193, 7, 0.3);
  border-top: 2px solid rgba(255, 193, 7, 0.8);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Responsive adjustments for document attachments */
@media (max-width: 768px) {
  .attached-documents-container {
    padding: 0.5rem;
    gap: 0.375rem;
  }
  
  .document-pill {
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
    max-width: 200px;
  }
  
  .document-icon {
    font-size: 1rem;
  }
  
  .drag-overlay-content {
    padding: 1rem;
  }
  
  .drag-icon {
    font-size: 2rem;
  }
  
  .drag-text {
    font-size: 1rem;
  }
  
  .drag-subtext {
    font-size: 0.8rem;
  }
}

/* ===== OUTPUT FORMATTING - REASONING TRACE ===== */
.output-section {
  margin-top: var(--space-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.output-header {
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
}

.output-header::before {
  content: "📋";
  margin-right: var(--space-1);
}

.direct-response-output .output-header::before {
  content: "💬";
}

.hag-planning-output .output-header::before {
  content: "🧠";
}

.output-content {
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.output-content pre {
  margin: 0;
  padding: var(--space-3);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: rgba(248, 250, 252, 0.7);
  border: 1px solid rgba(203, 213, 225, 0.3);
}

/* Direct Response Output Styling */
.direct-response-output {
  background: rgba(219, 234, 254, 0.3);
  border: 1px solid rgba(147, 197, 253, 0.4);
}

.direct-response-output .output-header {
  color: #1e40af;
}

.direct-response-output .output-content {
  border: 1px solid rgba(147, 197, 253, 0.2);
}

/* HAG Planning Output Styling */
.hag-planning-output {
  background: rgba(243, 232, 255, 0.3);
  border: 1px solid rgba(196, 181, 253, 0.4);
}

.hag-planning-output .output-header {
  color: #7c3aed;
}

.hag-planning-output .output-content {
  border: 1px solid rgba(196, 181, 253, 0.2);
}

/* Enhanced trace items for better readability */
.trace-item .output-section {
  margin-left: calc(-1 * var(--space-3));
  margin-right: calc(-1 * var(--space-3));
  margin-bottom: var(--space-2);
}

/* Legacy glassmorphism message system removed - using modern message-wrapper system instead */

/* Enhanced message meta styling */
.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-1);
  font-size: 11px;
  color: rgba(223, 210, 210, 0.753);
  background: transparent !important;
  border: none !important;
  padding: 0 var(--space-2);
}

/* ===== RESPONSIVE MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
  /* Mobile-first responsive adjustments */
  .unified-container {
    /* Use safe area insets for mobile devices with notches */
    height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    height: 100dvh;
    padding: var(--space-2);
    gap: var(--space-3);
  }
  
  .chat-container {
    border-radius: var(--radius-lg);
    /* Allow chat container to grow naturally on mobile */
    max-height: none;
  }
  
  .chat-messages {
    padding: var(--space-3);
    max-height: none !important;
    min-height: 200px;
    flex: 1;
  }
  
  .chat-input-wrapper {
    padding: var(--space-2);
    margin: var(--space-2) 0 0 0;
    border-radius: var(--radius-lg);
    /* Ensure input is always above mobile keyboards */
    margin-bottom: env(safe-area-inset-bottom, 0);
  }
  
  .chat-input {
    font-size: var(--font-size-sm);
    padding: var(--space-2) 0;
  }
  
  .chat-send-button, .chat-stop-button {
    width: var(--target-size-min);
    height: var(--target-size-min);
    font-size: 12px;
  }

  /* Header: compact layout for touch targets */
  .app-header-content {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .header-actions {
    gap: var(--space-2);
  }
  
  /* Ensure icon buttons are touch-friendly */
  .header-icon-button {
    min-width: 44px;
    min-height: 44px;
    width: 44px;
    height: 44px;
  }
  
  /* User avatar should also be touch-friendly */
  .user-avatar {
    width: 44px;
    height: 44px;
  }
  #user-profile {
    max-width: 60vw;
    overflow: hidden;
  }
  #user-profile #user-name {
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #user-profile .text-blue-400 {
    display: none;
  }
  
  .chat-stop-button {
    margin-left: var(--space-1);
  }
  
  /* Message styling adjustments integrated into main responsive system */
  

  
  .tab-button {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
  }
  
  .output-content pre {
    font-size: 0.75rem;
    padding: var(--space-2);
  }
  
  .output-header {
    font-size: 0.8rem;
  }
  
  /* Markdown content mobile adjustments */
  .table-container {
    font-size: var(--font-size-xs);
    /* Maintain glassmorphism on mobile with slightly reduced blur for performance */
    backdrop-filter: blur(15px) saturate(160%);
    -webkit-backdrop-filter: blur(15px) saturate(160%);
  }
  
  .markdown-table th,
  .markdown-table td,
  .rich-table th,
  .rich-table td {
    padding: 0.5rem;
  }
  
  .code-block {
    padding: 0.75rem;
    font-size: var(--font-size-xs);
  }
  
  .message-text h1 {
    font-size: 1.25rem;
  }
  
  .message-text h2 {
    font-size: 1.125rem;
  }
}

/* ===== LOADING, THINKING, AND ERROR INDICATORS ===== */

/* Loading Indicator */
.loading-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  margin: var(--space-3) 0;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: rgba(255, 255, 255, 0.8);
}



.loading-text {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

/* Thinking Indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  margin: var(--space-3) 0;
  background: rgba(59, 130, 246, 0.1);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.thinking-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: rgba(255, 255, 255, 0.9);
}

.thinking-avatar {
  font-size: 20px;
  opacity: 0.8;
}

.thinking-text {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

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

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: thinking-pulse 1.4s ease-in-out infinite both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0s; }

/* Error Container */
.error-container {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  margin: var(--space-3) 0;
  border-radius: var(--radius-lg);
  border: 1px solid;
  backdrop-filter: blur(8px);
}

.error-container.error-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  color: #ffffff;
}

.error-container.error-warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #ffffff;
}

.error-container.error-critical {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.6);
  color: #ffffff;
  box-shadow: 0 0 20px rgba(220, 38, 38, 0.3);
}

.error-content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
}

.error-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.error-message {
  flex: 1;
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.error-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  opacity: 0.7;
  transition: opacity var(--duration-200) var(--ease-out);
  flex-shrink: 0;
}

.error-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Animations */
@keyframes thinking-pulse {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

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

/* Focus states: use focus-visible to avoid distracting mouse users */
.tab-button:focus-visible,
.chat-send-button:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.knowledge-sub-tab-btn:focus-visible,
.glass-tab-button:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --gray-200: #000000;
    --gray-300: #000000;
    --shadow: 0 0 0 1px #000000;
  }
}

/* ===== MODEL SELECTION CARDS ===== */
.model-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .model-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .model-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.model-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--duration-200) var(--ease-out);
  position: relative;
  overflow: hidden;
}

/* Modal Dialog Styles */
.modal-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-dialog.show {
    display: flex;
}

.modal-content {
    background: var(--surface-overlay-strong);
    color: var(--text-primary);
    border-radius: var(--radius-xl);
    border: 1px solid color-mix(in srgb, var(--border-subtle) 80%, transparent);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.2s ease-out;
}

[data-theme="light"] .modal-content {
    background: color-mix(in srgb, var(--surface-1) 97%, rgba(255, 255, 255, 0.96));
}

.modal-dialog.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-primary);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.close-button {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--duration-200) var(--ease-out);
}

.close-button:hover {
    background-color: color-mix(in srgb, var(--surface-3) 80%, transparent);
    color: var(--text-primary);
}

/* Form styles for modal */
.modal-dialog .form-group {
    margin-bottom: 1rem;
}

.modal-dialog .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
}

.modal-dialog .form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color var(--duration-200) var(--ease-out);
}

.modal-dialog .form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-dialog textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

/* Button styles for modal */
.modal-dialog .btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-200) var(--ease-out);
    border: none;
}

.modal-dialog .btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.modal-dialog .btn-primary:hover {
    background-color: var(--accent-hover);
}

.modal-dialog .btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.modal-dialog .btn-secondary:hover {
    background-color: var(--bg-tertiary);
}

/* Wizard modal styles */
.wizard-modal {
    max-width: 600px;
}

.wizard-modal .modal-content {
    max-width: none;
}

/* Button styling removed - handled by component-specific CSS */

/* Form styling, loading states, and utility classes removed - handled by component-specific CSS */

/* Model Selector Styling */
.model-selector-container select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239aa1aa' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.25em 1.25em;
    padding-right: 2.25rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    color: var(--text-primary);
    background-color: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
}

/* Center text for model selectors globally (chat + heuristics + others) */
#model-selector-chat,
#model-selector-heuristics,
.model-selector-container select {
  text-align: center;
  text-align-last: center;
}
#model-selector-chat option,
#model-selector-heuristics option,
.model-selector-container select option {
  text-align: center;
}

.model-selector-container select:focus {
    outline: none;
    border-color: var(--info);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 30%, transparent);
}

/* Desktop: constrain model selector for balanced header */
@media (min-width: 1024px) {
  .tab-header-controls .model-selector-container { max-width: 420px; }
}

/* Pre-chat overrides must come AFTER desktop constraint to win */
.pre-chat .tab-header-controls .model-selector-container {
  max-width: 100% !important;
}
.pre-chat .tab-header-controls {
  display: grid;
  grid-template-columns: 1fr auto; /* selector grows, trailing buttons shrink */
}
.pre-chat .tab-header-controls .model-selector-container select {
  width: 100%;
}

/* Chat Content Header - Fully transparent background */
.chat-content-header {
    background: transparent;
    backdrop-filter: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
    transition: all 0.3s ease;
    box-shadow: none;
}

.chat-content-header:hover {
    background: transparent;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

/* Reasoning Trace Styling */
.reasoning-trace-container {
    margin-top: var(--space-3);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration-300) var(--ease-out);
}

.reasoning-trace-toggle {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--gray-100);
    border: none;
    text-align: left;
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--gray-700);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all var(--duration-200) var(--ease-out);
    font-weight: 600;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.reasoning-trace-toggle:hover {
    background: var(--gray-200);
}

.reasoning-trace-toggle .toggle-icon {
    transform: rotate(-90deg);
    transition: transform 0.2s ease;
    font-size: 12px;
    width: 16px;
    height: 16px;
    display: inline-block;
    text-align: center;
    line-height: 16px;
}

.reasoning-trace-content.expanded + .reasoning-trace-toggle .toggle-icon {
    transform: rotate(0deg);
}

.reasoning-trace-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.reasoning-trace-content.expanded {
    max-height: 800px;
    overflow: visible;
}

.reasoning-header {
    padding: var(--space-3);
    border-bottom: 1px solid var(--gray-200);
    background: var(--white);
}

.reasoning-header h4 {
    margin: 0 0 var(--space-1) 0;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-900);
}

.reasoning-header p {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--gray-600);
}

.reasoning-steps {
    padding: 0;
}

.reasoning-step {
    padding: var(--space-3);
    border-bottom: 1px solid var(--gray-100);
    background: var(--white);
}

.reasoning-step:last-child {
    border-bottom: none;
}

.reasoning-step-title {
    font-weight: 600;
    font-size: var(--font-size-xs);
    color: var(--gray-700);
    margin-bottom: var(--space-2);
}

.reasoning-step-content {
    font-size: var(--font-size-xs);
    color: var(--gray-600);
    line-height: 1.4;
}

/* System Messages - modernized */
.message-system {
    align-self: center;
    max-width: 80%;
}

.message-system .message-content {
    background: transparent;
    backdrop-filter: blur(12px) saturate(150%);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    font-size: var(--font-size-sm);
    text-align: center;
}



/* Legacy authentication, graph, and tab styling removed - handled by modern component system */

/* ===== KNOWLEDGE BASE SUB-TABS ===== */
.knowledge-sub-tabs {
  width: 100%;
}

.knowledge-sub-tab-btn {
  transition: all 0.2s ease;
  cursor: pointer;
  background: none;
  border: none;
  outline: none;
}

.knowledge-sub-tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

.knowledge-sub-tab-btn:not(.active):hover {
  color: var(--gray-700);
  border-bottom-color: var(--gray-300);
}

.knowledge-sub-tab-content {
  animation: fadeIn 0.2s ease-in-out;
}

.knowledge-sub-tab-content.hidden {
  display: none;
}

/* Legacy tool results, plan content, and step styling removed - handled by modern processing system */

.plan-steps li {
    margin-bottom: 6px;
    color: #444;
}

/* Reasoning Summary Styling */
.reasoning-summary {
  font-size: 0.85em;
  color: #555;
  line-height: 1.5;
  white-space: pre-line;
  background: #f8f9fa;
  padding: 10px 12px;
  border-radius: 4px;
  border-left: 3px solid #007bff;
}

/* ===== MARKDOWN CONTENT STYLING ===== */

/* Markdown Tables - Glassmorphism Design */
.table-container {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: var(--radius-lg);
  /* Glassmorphism container effect */
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all var(--duration-300) var(--ease-out);
}

.table-container:hover {
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Enhanced Tables */
.markdown-table,
.rich-table {
  border-collapse: collapse;
  margin: 1.5rem 0;
  width: 100%;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(10px);
}

.markdown-table th,
.rich-table th {
  background: linear-gradient(135deg, var(--primary-600), var(--blue-600));
  color: white;
  font-weight: 600;
  padding: 1rem;
  text-align: left;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.markdown-table th::after,
.rich-table th::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 255, 255, 0.3);
}

.markdown-table td,
.rich-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(59, 130, 246, 0.1);
  color: var(--gray-100);
}

/* Only enable table hover effects on completed messages to prevent streaming flashes */
.message:not(.streaming-message) .markdown-table td,
.message:not(.streaming-message) .rich-table td {
  transition: background-color 0.2s ease;
}

.message:not(.streaming-message) .markdown-table tr:hover,
.message:not(.streaming-message) .rich-table tr:hover {
  background: rgba(59, 130, 246, 0.08);
}

.message:not(.streaming-message) .markdown-table tr:hover td,
.message:not(.streaming-message) .rich-table tr:hover td {
  background: rgba(59, 130, 246, 0.08);
}

.markdown-table tr:last-child td,
.rich-table tr:last-child td {
  border-bottom: none;
}

/* Markdown Code Blocks */
.code-block {
  background-color: var(--gray-900);
  color: var(--gray-100);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin: 1rem 0;
  overflow-x: auto;
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

.code-block code {
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}

/* Inline Code */
.message-text code:not(.code-block code) {
  background-color: var(--gray-100);
  color: var(--gray-800);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
  font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 0.875em;
}

/* Lightweight wrapper/header for markdown-only code blocks */
.code-block-wrapper { margin: 1rem 0; }
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.75rem; border: 1px solid rgba(255,255,255,0.08);
  border-bottom: none; border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: rgba(255,255,255,0.04); backdrop-filter: blur(8px);
}
.code-language { font-size: 0.75rem; opacity: 0.85; text-transform: uppercase; }
.code-actions { display: flex; gap: 0.5rem; }
.code-actions button {
  font-size: 0.75rem; padding: 0.25rem 0.5rem; cursor: pointer;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; color: #fff;
}
.code-actions button:hover { background: rgba(255,255,255,0.14); }

.code-block-wrapper pre {
  margin: 0; border: 1px solid rgba(255,255,255,0.08);
  border-top: none; border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* Live HTML preview */
.code-preview-frame {
  width: 100%; min-height: 420px; border: 1px solid rgba(255,255,255,0.08);
  border-top: none; border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: #ffffff;
}

/* Markdown Images */
.message-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 0.5rem 0;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.message-image:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

/* Enhanced Links */
.markdown-link {
  color: var(--primary-300);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  font-weight: 500;
}

/* Only enable link hover effects on completed messages to prevent streaming flashes */
.message:not(.streaming-message) .markdown-link {
  transition: all 0.2s ease;
}

.message:not(.streaming-message) .markdown-link:hover {
  color: var(--primary-200);
  border-bottom-color: var(--primary-300);
  text-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.markdown-link:visited {
  color: var(--purple-300);
}
/* Responsive Typography and Animations for Enhanced Markdown */
@media (max-width: 768px) {
  .message-content {
    font-size: 0.95rem;
    max-width: 90ch; /* allow slightly wider on mobile to reduce wrapping */
  }
  
  .message-content h1 {
    font-size: 1.5rem;
  }
  
  .message-content h2 {
    font-size: 1.25rem;
  }
  
  .message-content h3 {
    font-size: 1.1rem;
  }
}

/* Section Separators */
.message-content hr {
  margin: 2rem 0;
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-500), transparent);
}

/* Code Blocks Enhancement */
.message-content pre {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  position: relative;
  backdrop-filter: blur(10px);
}

.message-content pre::before {
  content: "Code";
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 0.7rem;
  color: var(--primary-400);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
}

/* Animation removed to prevent flashing during streaming */

/* Jump to newest button and micro-interactions removed - handled by modern component system */



/* Brand consistency - unified gradient token */
.message-bubble.ai,
.tab-button.active,
.chat-send-button {
  background: var(--brand-gradient);
}

/* ===== KEYFRAMES ===== */
/* Essential keyframes only - removed redundant animations */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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



/* Optimization Progress Modal */
.optimization-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.optimization-modal.show {
    opacity: 1;
    visibility: visible;
}

.optimization-modal-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.optimization-modal.show .optimization-modal-content {
    transform: scale(1);
}

.optimization-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.optimization-modal-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.optimization-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.optimization-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--gray-700);
}

.optimization-progress-container {
    margin-bottom: 1.5rem;
}

.optimization-overall-progress {
    margin-bottom: 1rem;
}

.optimization-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.optimization-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.optimization-progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.optimization-current-step {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.optimization-step-title {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.optimization-step-description {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.optimization-step-details {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-family: 'Monaco', 'Menlo', monospace;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.optimization-time-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.optimization-time-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.75rem;
    text-align: center;
}

.optimization-time-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.optimization-time-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--green-600);
    margin-bottom: 0.25rem;
}

.optimization-results {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.optimization-results-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--green-700);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.optimization-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.optimization-result-card {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

.optimization-result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--green-600);
    margin-bottom: 0.25rem;
}

.optimization-result-label {
    font-size: 0.75rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.optimization-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.optimization-stop-btn {
    background: var(--red-500);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.optimization-stop-btn:hover {
    background: var(--red-600);
    transform: translateY(-1px);
}

.optimization-stop-btn:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
    transform: none;
}

.optimization-close-btn {
    background: var(--primary-500);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.optimization-close-btn:hover {
    background: var(--primary-600);
    transform: translateY(-1px);
}

.optimization-results {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.optimization-results-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--green-700);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.optimization-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.optimization-result-card {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

/* ===== GLASSMORPHIC CITATIONS STYLES ===== */
.message-citations {
    margin-top: var(--space-4);
    padding: var(--space-4);
    width: 100%;
    max-width: 100%;
    /* Enhanced glassmorphism with better readability */
    background: transparent;
    backdrop-filter: blur(12px) saturate(120%);
    -webkit-backdrop-filter: blur(12px) saturate(120%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.4);
    /* Enhanced glassmorphism shadow */
    box-shadow: 
        0 4px 16px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

.citations-header {
    margin-bottom: var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: var(--space-2);
    position: relative;
}

.citations-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: var(--space-1);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    transition: color 0.2s ease;
}

.citations-title::before {
    content: "📚";
    font-size: 1rem;
}

.citations-header:hover .citations-title {
    color: rgba(59, 130, 246, 0.9);
}

.citations-title .toggle-icon {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.2s ease, color 0.2s ease;
    transform: rotate(-90deg); /* Start collapsed (pointing right) */
}

/* ===== PLANNER PANEL (Planner V2) ===== */
.planner-panel {
  position: fixed;
  top: 64px;
  right: 16px;
  width: 320px;
  max-height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  z-index: 60;
}
.planner-panel.hidden { display: none; }
.planner-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.planner-title { font-weight: 600; color: rgba(255,255,255,0.95); }
.planner-btn { background: transparent; border: 1px solid rgba(255,255,255,0.16); color: rgba(255,255,255,0.9); border-radius: 8px; padding: 4px 8px; cursor: pointer; }
.planner-btn:hover { border-color: rgba(59,130,246,0.6); color: rgba(59,130,246,0.9); }
.planner-body { padding: 8px 12px 12px; overflow: auto; }
.planner-section { margin-bottom: 12px; }
.planner-subtitle { font-size: 12px; color: rgba(255,255,255,0.7); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.planner-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.planner-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255,255,255,0.04); }
.planner-item .state { width: 8px; height: 8px; border-radius: 9999px; display: inline-block; }
.state-pending { background: rgba(148,163,184,0.9); }
.state-in_progress { background: rgba(59,130,246,0.95); box-shadow: 0 0 0 2px rgba(59,130,246,0.35); }
.state-completed { background: rgba(34,197,94,0.95); }
.state-cancelled { background: rgba(244,63,94,0.95); }
.planner-item .label { color: rgba(255,255,255,0.92); font-size: 13px; line-height: 1.4; }
.planner-activity { max-height: 200px; overflow: auto; border: 1px dashed rgba(255,255,255,0.12); border-radius: 8px; padding: 6px; background: rgba(255,255,255,0.03); }
.planner-activity .act { display: flex; gap: 8px; font-size: 12px; color: rgba(255,255,255,0.85); padding: 2px 0; }
.planner-activity .ts { color: rgba(148,163,184,0.9); min-width: 48px; }
.planner-stream { max-height: 140px; overflow: auto; border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 6px; background: rgba(255,255,255,0.04); font-size: 12px; color: rgba(255,255,255,0.9); }
.planner-stream .placeholder { color: rgba(148,163,184,0.9); font-style: italic; }
.planner-stream-frag { animation: fadeIn 120ms ease-out; }
.planner-stream-row { display: flex; align-items: flex-start; gap: 6px; }
.planner-stream-row .badge { display: inline-block; font-size: 10px; padding: 2px 6px; border-radius: 999px; background: rgba(59,130,246,0.18); color: rgba(173,216,255,0.95); text-transform: uppercase; letter-spacing: 0.04em; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.citations-header:hover .toggle-icon {
    color: rgba(59, 130, 246, 0.9);
}

/* Citations collapsible content */
.citations-content {
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.citations-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    padding-top: 0;
}

.citations-content.expanded {
    max-height: none;
    opacity: 1;
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.citations-count-warning {
    font-size: var(--font-size-xs);
    color: rgba(255, 193, 7, 0.9);
    font-style: italic;
}

.citations-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-3);
    width: 100%;
}

.citation-item {
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.citation-item:hover {
    background: rgba(0, 0, 0, 0.25);
    border-color: rgba(59, 130, 246, 0.5);
    box-shadow: 
        0 8px 24px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.citation-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    text-decoration: none;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.citation-link:hover {
    color: rgba(255, 255, 255, 0.95);
}

.citation-number {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: rgba(59, 130, 246, 0.9);
    background: rgba(59, 130, 246, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(59, 130, 246, 0.25);
    min-width: 2rem;
    text-align: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.citation-icon {
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.citation-title {
    flex: 1;
    font-size: var(--font-size-sm);
    font-weight: 500;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.85);
}

.citation-action {
    font-size: var(--font-size-xs);
    color: rgba(59, 130, 246, 0.8);
    font-weight: 500;
    opacity: 0.7;
    transition: all 0.3s ease;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.citation-link:hover .citation-action {
    opacity: 1;
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

.citation-link:hover .citation-icon {
    opacity: 1;
}

.citations-load-more-container {
    margin-top: var(--space-4);
    text-align: center;
    padding-top: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.citations-load-more-btn {
    background: rgba(59, 130, 246, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.citations-load-more-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.citations-load-more-btn:active {
    transform: translateY(-1px);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Citation type specific styles */
.citation-document .citation-icon {
    color: rgba(59, 130, 246, 0.8);
}

.citation-web .citation-icon {
    color: rgba(34, 197, 94, 0.8);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .citation-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .citation-title {
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
    }
    
    .citation-action {
        align-self: flex-end;
    }
}

.optimization-result-card {
    padding: 1rem;
    text-align: center;
}

.optimization-result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--green-600);
    margin-bottom: 0.25rem;
}

.optimization-result-label {
    font-size: 0.75rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.optimization-spinning {
    animation: spin 2s linear infinite;
}

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

.optimization-pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .optimization-modal-content {
        margin: 1rem;
        padding: 1.5rem;
        max-width: none;
        width: calc(100% - 2rem);
    }
    
    .optimization-time-info {
        grid-template-columns: 1fr;
    }
    
    .optimization-results-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .optimization-actions {
        flex-direction: column;
    }
}

/* ===== CITATION DISPLAY SYSTEM (REMOVED DUPLICATE) ===== */
/* Duplicate citation styles removed to prevent conflicts with glassmorphic styles above */

/* All duplicate citation styles removed - using glassmorphic styles above */

/* ===== HEURISTIC TABLE STYLES (KB DOCUMENTS TABLE DESIGN) ===== */
/* Unified styling to match KB Your Documents Table design */

.heuristics-table-container {
    overflow-x: auto;
}

.heuristics-table {
    width: 100%;
    font-size: 0.875rem; /* text-sm */
    border-collapse: collapse;
}

/* Table header - KB Documents Table style */
.heuristics-table thead {
    background: color-mix(in srgb, var(--surface-2) 90%, transparent);
}

.heuristics-table th {
    padding: 0.5rem 1rem;
    text-align: left;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-subtle);
}

/* Table body - KB Documents Table style */
.heuristics-table tbody tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s ease;
}

.heuristics-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.heuristics-table td {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    vertical-align: top;
}

/* Sort buttons in headers */
.heuristics-table th button {
    color: inherit;
    background: transparent;
    border: none;
    font-weight: inherit;
    font-size: inherit;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
}

.heuristics-table th button:hover {
    color: rgb(255, 255, 255);
}

.heuristics-table td:last-child {
    border-right: none;
}

/* Removed duplicate glassmorphism category badge - using simplified KB Documents style below */

/* Category badges - simplified for KB Documents Table style */
.heuristics-table .category-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: rgba(59, 130, 246, 0.2);
    color: rgb(147, 197, 253); /* text-blue-300 */
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.heuristics-table .category-badge:hover {
    background-color: rgba(59, 130, 246, 0.3);
    color: rgb(191, 219, 254); /* text-blue-200 */
}

/* Action buttons - simplified for KB Documents Table style */
.heuristics-table .action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background-color: rgba(239, 68, 68, 0.1);
    color: rgb(248, 113, 113); /* text-red-400 */
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.heuristics-table .action-button:hover {
    background-color: rgba(239, 68, 68, 0.2);
    color: rgb(239, 68, 68); /* text-red-500 */
}

/* Text content - simplified for KB Documents Table style */
.heuristics-table .text-content {
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Toggle buttons for show more/less */
.heuristics-table .toggle-button {
    background: transparent;
    border: none;
    color: rgb(59, 130, 246); /* text-blue-500 */
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: 0.5rem;
    text-decoration: underline;
}

.heuristics-table .toggle-button:hover {
    color: rgb(37, 99, 235); /* text-blue-600 */
}

/* Preview and quote text */
.heuristics-table .preview-text {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.heuristics-table .quote-text {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-style: italic;
}

.heuristics-table .empty-content {
    color: var(--text-soft);
    font-style: italic;
}

/* Pagination styling to match KB Documents Table */
.heuristics-pagination {
    margin-top: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.heuristics-pagination .pagination-info {
    color: var(--text-muted);
}

.heuristics-pagination .page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.heuristics-pagination .page-navigation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.heuristics-pagination .pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.heuristics-pagination .pagination-button {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-200) var(--ease-out);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-width: 2.5rem;
    justify-content: center;
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.heuristics-pagination .pagination-button:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.heuristics-pagination .pagination-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
}

.heuristics-pagination .pagination-button.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
    color: rgba(59, 130, 246, 1);
    box-shadow: 
        0 2px 8px rgba(59, 130, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.heuristics-subtab {
    border-bottom: 2px solid transparent;
    padding: var(--space-2) var(--space-3);
    color: var(--text-soft);
    font-weight: 600;
    transition: color var(--duration-150) var(--ease-out), border-color var(--duration-200) var(--ease-out);
}

.heuristics-subtab--inactive:hover {
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--focus-ring-color) 50%, transparent);
}

.heuristics-subtab--active {
    color: var(--text-primary);
    border-color: var(--focus-ring-color);
}

/* Responsive design */
@media (max-width: 768px) {
    .heuristics-table-container {
        border-radius: var(--radius-md);
        margin: var(--space-2);
    }
    
    .heuristics-table th,
    .heuristics-table td {
        padding: var(--space-3) var(--space-2);
        font-size: var(--font-size-xs);
    }
    
    .heuristics-table .text-content {
        max-width: 120px;
    }
    
    .heuristics-pagination {
        flex-direction: column;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
    }
}

/* Additional glassmorphism elements */
.heuristics-table .sort-button {
    color: inherit;
    background: transparent;
    border: none;
    font-weight: 600;
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all var(--duration-200) var(--ease-out);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    text-align: left;
}

.heuristics-table .sort-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

/* Removed duplicate toggle-button, preview-text, and quote-text styles - using simpler KB Documents style definitions above */

.heuristics-table .empty-content {
    color: rgba(255, 255, 255, 0.5);
    font-style: italic;
}

/* Pagination layout elements */
.heuristics-pagination .page-size-selector {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.heuristics-pagination .page-navigation {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ===== YOUR DOCUMENTS TABLE STYLES (KB DOCUMENTS TABLE) ===== */
/* Styling for the Your Documents table to ensure proper readability */

#kb-documents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

#kb-documents-table thead {
    background: var(--surface-2);
}

#kb-documents-table th {
    padding: var(--space-2) var(--space-4);
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-subtle);
}

#kb-documents-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
}

#kb-documents-table td {
    padding: var(--space-2) var(--space-4);
    color: var(--text-secondary);
    vertical-align: top;
}

#kb-documents-table td a {
    color: var(--primary-400);
    text-decoration: none;
    transition: color var(--duration-200) var(--ease-out);
}

#kb-documents-table td a:hover {
    color: var(--primary-300);
    text-decoration: underline;
}

#kb-documents-table td button {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: var(--font-size-sm);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    transition: all var(--duration-200) var(--ease-out);
}

#kb-documents-table td button:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

/* Mobile: make documents table horizontally scrollable within container */
@media (max-width: 768px) {
  .documents-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #kb-documents-table {
    min-width: 640px;
  }
}

/* Removed conflicting Tailwind override rules - using unified hover style from main table definition */

/* ===== UNIFIED MODAL STYLING ===== */
/* Apply the same dark glassmorphism background as optimization modal to all modals */

/* Welcome Modal - Dark Glassmorphism Style */
#welcome-modal,
#model-assignment-modal,
.modal-dialog {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#welcome-modal > div,
#model-assignment-modal > div,
.modal-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.95);
}

#welcome-modal h2,
#model-assignment-modal h2,
.modal-content h2 {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#welcome-modal p,
#model-assignment-modal p,
.modal-content p {
    color: rgba(255, 255, 255, 0.8);
}

/* ===== PROCESSING CONTAINER STYLES - CONSOLIDATED ===== */
/* Single unified section for all processing container styles */

/* Processing trace container - the existing HTML container */
.processing-trace-container {
    margin-bottom: var(--space-4);
    animation: slideInMessage 0.3s ease-out;
    /* Distinct styling for processing area - not a message */
    /* Removed left border */
    background: rgba(59, 130, 246, 0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    display: none; /* Hidden by default, shown when active */
}

/* Legacy processing-area class for backward compatibility */
.processing-area {
    margin-bottom: var(--space-4);
    animation: slideInMessage 0.3s ease-out;
    /* Distinct styling for processing area - not a message */
    /* Removed left border */
    background: rgba(59, 130, 246, 0.05);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
}

/* ✅ LEGACY: All .processing-container styles removed - using only embedded processing containers */

/* ===== EMBEDDED PROCESSING CONTAINER STYLES ===== */
/* Styles for processing containers embedded within assistant messages */

.embedded-processing-container {
    margin: 0 0 var(--space-4) 0;
    border-radius: var(--radius-md);
    border: 1px solid rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.05);
    overflow: hidden;
}

.embedded-processing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: rgba(6, 182, 212, 0.1);
    border-bottom: 1px solid rgba(6, 182, 212, 0.2);
}

.embedded-processing-header .processing-info {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.embedded-processing-header .processing-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: rgba(255, 255, 255, 0.95);
}

/* Ensure high-contrast text for processing message in header */
.embedded-processing-header .processing-text {
    color: rgba(255, 255, 255, 0.95);
}

.embedded-processing-header .processing-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(6, 182, 212, 0.3);
    border-top: 2px solid rgb(6, 182, 212);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.embedded-processing-header .processing-timer {
    font-size: var(--font-size-xs);
    color: rgba(255, 255, 255, 0.6);
    font-family: monospace;
}

.embedded-processing-header .processing-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.embedded-processing-header .processing-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

.embedded-processing-content {
    padding: var(--space-4);
    max-height: 400px;
    overflow-y: auto;
    font-size: var(--font-size-sm);
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}

.embedded-processing-container.collapsed .embedded-processing-content {
    display: none;
}

.embedded-processing-container.completed {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.embedded-processing-container.completed .embedded-processing-header {
    background: rgba(16, 185, 129, 0.1);
    border-bottom-color: rgba(16, 185, 129, 0.2);
}

.embedded-processing-container.completed .processing-spinner {
    display: none;
}

/* Final response content within embedded messages */
.final-response-content {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.final-response-content .typing-indicator {
    color: rgba(6, 182, 212, 0.8);
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Inherit table styles for embedded processing */
.embedded-processing-container .table-container,
.embedded-processing-container .processing-table {
    /* Inherit glassmorphism effects from main table styles */
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px) saturate(170%);
    -webkit-backdrop-filter: blur(15px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
}

.embedded-processing-container .processing-table th {
    background: rgba(6, 182, 212, 0.1);
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid rgba(6, 182, 212, 0.2);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.embedded-processing-container .processing-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.85);
    vertical-align: top;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: rgba(255, 255, 255, 0.95) !important;
}

.modal-title {
    color: rgba(255, 255, 255, 0.95) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

.modal-body {
    color: rgba(255, 255, 255, 0.9) !important;
}

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* Universal Modal Overlay Styling */
[class*="modal"][class*="fixed"],
[id*="modal"][class*="fixed"] {
    background: rgba(0, 0, 0, 0.4) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

/* Universal Modal Content Styling */
[class*="modal"] .bg-white,
[id*="modal"] .bg-white {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 20px !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 16px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.95) !important;
}

/* Shared modal theme */
.hs-modal-content {
    background: rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 16px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.1) !important;
    color: rgba(255, 255, 255, 0.95) !important;
}

.hs-modal-content header,
.hs-modal-content .modal-header { border-bottom: 1px solid rgba(255,255,255,0.15) !important; }
.hs-modal-content footer,
.hs-modal-content .modal-footer { border-top: 1px solid rgba(255,255,255,0.15) !important; }
.hs-modal-content h1,
.hs-modal-content h2,
.hs-modal-content h3 { color: rgba(255,255,255,0.95) !important; text-shadow: 0 1px 2px rgba(0,0,0,0.1) !important; }
.hs-modal-content p,
.hs-modal-content .text-sm,
.hs-modal-content .text-base { color: rgba(255,255,255,0.9) !important; }

.hs-modal-content .btn-primary,
.hs-modal-content button[type="submit"] {
    background: linear-gradient(180deg, #7c3aed, #6d28d9) !important;
    border: 1px solid rgba(168,85,247,0.45) !important;
    color: #fff !important;
    border-radius: 10px !important;
}
.hs-modal-content .btn-secondary,
.hs-modal-content .btn:not(.btn-primary) {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 10px !important;
}

/* Overlays */
#model-assignment-modal, #heuristic-modal {
    background: rgba(0,0,0,0.45) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}
/* Heuristics (Assign Models) Tailwind modal override */
#heuristics-modal {
    background: rgba(0, 0, 0, 0.45) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

#heuristics-modal .bg-white,
#heuristics-modal [class*="bg-white"] {
    background: rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 20px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 16px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
}

#heuristics-modal h1, #heuristics-modal h2, #heuristics-modal h3 {
    color: rgba(255, 255, 255, 0.95) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
}

#heuristics-modal header, #heuristics-modal .modal-header { border-bottom: 1px solid rgba(255,255,255,0.15) !important; }
#heuristics-modal footer, #heuristics-modal .modal-footer { border-top: 1px solid rgba(255,255,255,0.15) !important; }

#heuristics-modal .btn-primary,
#heuristics-modal button[type="submit"],
#heuristics-modal button[class*="bg-blue"],
#heuristics-modal button[class*="bg-indigo"],
#heuristics-modal [class*="btn-primary"] {
    background: linear-gradient(180deg, #7c3aed, #6d28d9) !important;
    border: 1px solid rgba(168, 85, 247, 0.45) !important;
    color: #fff !important;
    border-radius: 10px !important;
}

#heuristics-modal .btn-secondary,
#heuristics-modal [class*="btn-secondary"] {
    background: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 10px !important;
}

#heuristics-modal label, #heuristics-modal .text-sm, #heuristics-modal .text-base { color: rgba(255,255,255,0.92) !important; }
#heuristics-modal input[type="checkbox"] { width: 16px; height: 16px; border-radius: 4px; }

#heuristics-modal ::-webkit-scrollbar { width: 8px; }
#heuristics-modal ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 8px; }

/* Removed conflicting dark mode rules - dark mode handled by main CSS variables */

/* Chart Styling */
.chart-container {
    margin: 20px 0;
    padding: 20px;
    border-radius: var(--radius-xl);
    /* Apply glassmorphism styling to match the rest of the app */
    background: transparent;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
}

.chart-container:hover {
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.chart-header {
    margin-bottom: 15px;
    text-align: center;
}

.chart-header h4 {
    margin: 0 0 5px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.chart-header span {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--surface-3);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.chart-content {
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 20px;
    text-align: center;
}

/* Chart tooltips */
.chart-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Visualization Container */
.visualization-container {
    width: 100%;
    height: calc(75vh - 150px);
    position: relative;
    background: var(--surface-overlay);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Fullscreen Visualization Container */
.visualization-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    z-index: 9999;
    background: var(--surface-overlay-strong);
    border-radius: 0;
}

/* Fullscreen Toggle Button */
.fullscreen-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--surface-overlay-strong);
    border: 1px solid var(--border-subtle);
    color: var(--info);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    z-index: 10;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    white-space: nowrap;
    user-select: none;
}

.fullscreen-toggle:hover {
    background: color-mix(in srgb, var(--surface-overlay-strong) 70%, var(--info) 30%);
    border-color: var(--info);
    transform: scale(1.05);
}

/* Ensure fullscreen button is visible in fullscreen mode */
.visualization-container.fullscreen .fullscreen-toggle {
    z-index: 10001;
    position: fixed;
    top: 20px;
    right: 20px;
}

/* Threshold Controls - DISABLED
 * Note: Threshold filtering controls have been removed from the UI
 * Keeping these styles commented out for potential future use
 */
/*
.threshold-controls {
    background: rgba(31, 41, 55, 0.9);
    padding: 8px 12px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

.threshold-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.threshold-slider {
    width: 100px;
    height: 4px;
    background: rgba(75, 85, 99, 0.5);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #3b82f6;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.threshold-slider::-webkit-slider-thumb:hover {
    background: #60a5fa;
    transform: scale(1.2);
}

.threshold-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #3b82f6;
    cursor: pointer;
    border-radius: 50%;
    border: none;
    transition: all 0.2s ease;
}

.threshold-slider::-moz-range-thumb:hover {
    background: #60a5fa;
    transform: scale(1.2);
}

.threshold-value {
    color: #60a5fa;
    font-weight: 500;
    min-width: 25px;
    text-align: center;
}
*/

/* 3D Graph Container */
#graph-3d-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Graph Info Panel */
.graph-info-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--surface-overlay-strong);
    padding: 10px 15px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 10;
}

.graph-info-panel .info-item {
    margin-bottom: 4px;
}

.graph-info-panel .info-label {
    color: var(--text-secondary);
    margin-right: 8px;
}

.graph-info-panel .info-value {
    color: var(--info);
    font-weight: 500;
}

/* Node Tooltip */
.node-tooltip {
    position: absolute;
    background: var(--surface-overlay-strong);
    border: 1px solid var(--border-subtle);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    pointer-events: none;
    z-index: 1000;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    max-width: 300px;
}

.node-tooltip .tooltip-title {
    font-weight: 600;
    color: var(--info);
    margin-bottom: 4px;
}

.node-tooltip .tooltip-metric {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
}

.node-tooltip .metric-label {
    color: var(--text-secondary);
}

.node-tooltip .metric-value {
    color: var(--warning);
    font-weight: 500;
}

.node-tooltip .tooltip-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    gap: 8px;
}

.node-tooltip--simple .tooltip-title {
    margin-bottom: 0;
}

/* Persistent Graph Labels */
.graph-node-label {
    --label-accent: var(--primary-400);
    position: absolute;
    pointer-events: none;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    background: color-mix(in srgb, var(--surface-1) 92%, transparent);
    color: var(--text-primary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
    backdrop-filter: blur(8px);
    white-space: nowrap;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.graph-node-label::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--label-accent);
    box-shadow: 0 0 10px color-mix(in srgb, var(--label-accent) 40%, transparent);
    flex-shrink: 0;
}

.graph-node-label .label-title {
    color: inherit;
}

.graph-node-label--category {
    --label-accent: var(--success);
    border-color: color-mix(in srgb, var(--success) 30%, var(--border-subtle));
}

.graph-node-label--heuristic {
    --label-accent: var(--primary-400);
    border-color: color-mix(in srgb, var(--primary-500) 30%, var(--border-subtle));
}

.graph-node-label--expanded {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--surface-overlay-strong);
    border-color: var(--border-subtle);
    box-shadow: var(--shadow-lg);
    white-space: normal;
    max-width: min(340px, 80vw);
    line-height: 1.45;
    z-index: 1000;
}

.graph-node-label--expanded::before {
    display: none;
}

.graph-node-label--collapsed {
    white-space: nowrap;
}

.graph-node-label--expanded .label-title {
    color: var(--text-primary);
}

.graph-label-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--info);
}

.graph-label-metric {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
}

.graph-label-metric .metric-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.graph-label-metric .metric-value {
    color: var(--text-primary);
}

.graph-label-section {
    border-top: 1px solid var(--border-subtle);
    padding-top: 8px;
    margin-top: 8px;
    width: 100%;
}

.graph-label-section__title {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.graph-label-section__body {
    font-size: 12px;
    color: var(--text-primary);
    line-height: 1.5;
}

.graph-label-section__body--quote {
    font-style: italic;
    color: var(--text-secondary);
}

[data-theme="light"] .graph-node-label {
    background: color-mix(in srgb, var(--surface-1) 98%, white);
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .graph-node-label--expanded {
    background: color-mix(in srgb, var(--surface-1) 94%, white);
    border-color: rgba(15, 23, 42, 0.2);
}

[data-theme="light"] .graph-node-label--heuristic {
    --label-accent: var(--primary-600);
}

[data-theme="light"] .graph-node-label--category {
    --label-accent: var(--success);
}

/* Graph Legend */
.graph-legend {
    position: absolute;
    top: 55px; /* Position below fullscreen button */
    right: 10px;
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    backdrop-filter: blur(10px);
    font-size: 12px;
    color: var(--text-secondary);
    z-index: 10;
    min-width: 150px;
    transition: all 0.2s ease;
    user-select: none;
}

.graph-legend .legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    cursor: pointer;
}

.graph-legend .legend-header:hover {
    background: color-mix(in srgb, var(--primary-500) 15%, transparent);
}

.graph-legend .legend-content {
    padding: 12px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.graph-legend.collapsed .legend-content {
    max-height: 0;
    padding: 0 12px;
    opacity: 0;
}

.graph-legend .legend-toggle {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.graph-legend.collapsed .legend-toggle {
    transform: rotate(-90deg);
}

.graph-legend .legend-title {
    font-weight: 600;
    color: var(--primary-400);
    font-size: 13px;
    margin: 0;
}

.graph-legend .legend-section {
    margin-bottom: 8px;
}

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

.graph-legend .legend-section-title {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.graph-legend .legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
    gap: 6px;
}

.graph-legend .legend-item:last-child {
    margin-bottom: 0;
}

.graph-legend .legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
}

.graph-legend .legend-color-line {
    width: 16px;
    height: 2px;
    flex-shrink: 0;
    border-radius: 1px;
}

.graph-legend .legend-item span {
    font-size: 11px;
    color: var(--text-primary);
}

/* Graph Controls */
.graph-controls {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: var(--surface-overlay-strong);
    border: 1px solid var(--border-subtle);
    padding: 8px 12px;
    border-radius: 6px;
    backdrop-filter: blur(10px);
    z-index: 10;
    transition: all 0.2s ease;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.graph-controls .control-group {
    margin-bottom: 0;
}

.graph-controls .control-group--inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.graph-controls .control-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.graph-controls .control-toggle-input {
    display: none;
}

.graph-controls .control-toggle-slider {
    position: relative;
    width: 32px;
    height: 18px;
    background: color-mix(in srgb, var(--text-secondary) 25%, transparent);
    border-radius: 9px;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.graph-controls .control-toggle-slider::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--surface-1);
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.graph-controls .control-toggle-input:checked + .control-toggle-slider {
    background: var(--primary-500);
}

.graph-controls .control-toggle-input:checked + .control-toggle-slider::before {
    transform: translateX(14px);
}

.graph-controls .control-toggle-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.graph-controls .control-text {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.graph-control-input {
    background: var(--surface-3);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: var(--font-size-sm);
    min-height: 32px;
    transition: border-color var(--duration-150) var(--ease-out), box-shadow var(--duration-150) var(--ease-out);
}

.graph-control-input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary-400) 40%, transparent);
    background: var(--surface-2);
}

.graph-control-input--narrow {
    width: 90px;
}

.graph-control-input--wide {
    width: 200px;
}

.graph-controls .control-refresh-button svg {
    flex-shrink: 0;
}

/* Fullscreen mode adjustments for legend and controls */
.visualization-container.fullscreen .graph-legend,
.visualization-container.fullscreen .graph-controls {
    z-index: 10001;
    position: fixed;
}

.visualization-container.fullscreen .graph-legend {
    top: 70px; /* Position below fullscreen button in fullscreen mode */
    right: 20px;
}

.visualization-container.fullscreen .graph-controls {
    bottom: 20px;
    right: 20px;
}

/* Node Labels - managed by JavaScript hover events */

/* Model Visibility Toggle Styles */
#model-visibility-toggle:checked + div {
    background-color: #10b981; /* green-500 */
}

#model-visibility-toggle:checked + div > div {
    transform: translateX(1rem); /* translate-x-4 */
}

#model-visibility-section {
    transition: all 0.3s ease;
}

#model-visibility-section .toggle-bg {
    transition: background-color 0.3s ease;
}

#model-visibility-section .toggle-circle {
    transition: transform 0.3s ease;
}

/* ========================================
   UNIFIED CHART MANAGER STYLES
   ======================================== */

/* Base chart container styles */
.unified-chart-container {
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin: 16px 0;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.unified-chart-container:hover {
    background: var(--surface-overlay-strong);
    border-color: color-mix(in srgb, var(--border-subtle) 40%, var(--text-secondary));
    box-shadow: var(--shadow-lg);
}

.unified-chart-container.error {
    border-color: color-mix(in srgb, var(--error) 60%, transparent);
    background: color-mix(in srgb, var(--error) 15%, transparent);
}

/* Chart header styles */
.unified-chart-container .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--surface-3);
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
}

.unified-chart-container .chart-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-type-badge {
    background: color-mix(in srgb, var(--info) 15%, transparent);
    color: var(--info);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid color-mix(in srgb, var(--info) 40%, transparent);
}

.chart-type-badge.error {
    background: color-mix(in srgb, var(--error) 20%, transparent);
    color: var(--error);
    border-color: color-mix(in srgb, var(--error) 40%, transparent);
}

.chart-type-badge.legacy {
    background: color-mix(in srgb, var(--warning) 20%, transparent);
    color: var(--warning);
    border-color: color-mix(in srgb, var(--warning) 40%, transparent);
}

/* Chart actions styles */
.chart-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chart-download-btn {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.chart-download-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    color: #dbeafe;
    transform: translateY(-1px);
}

.chart-download-btn:active {
    transform: translateY(0);
    background: rgba(59, 130, 246, 0.4);
}

.chart-download-btn svg {
    width: 16px;
    height: 16px;
}

/* Chart content area */
.unified-chart-container .chart-content {
    padding: 16px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto; /* Fallback scrolling if needed */
    max-width: 100%;
}

/* Ensure all chart SVGs are responsive and centered */
.unified-chart-container .chart-content svg,
.chart-container .chart-content svg,
.unified-chart-svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Chart loading states */
.chart-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: chartSpin 1s linear infinite;
}

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

/* Chart error states */
.chart-error,
.chart-render-error {
    color: #fca5a5;
    text-align: center;
    padding: 20px;
    border: 1px dashed rgba(239, 68, 68, 0.4);
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.05);
}

.no-data-message {
    color: #9ca3af;
    text-align: center;
    padding: 20px;
    font-style: italic;
}

.unsupported-chart {
    color: #fbbf24;
    text-align: center;
    padding: 20px;
    border: 1px dashed rgba(245, 158, 11, 0.4);
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.05);
}

/* SVG chart styles */
.unified-chart-svg {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chart element styles */
.unified-bar {
    transition: fill 0.2s ease;
    cursor: pointer;
}

.unified-line {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.unified-dot {
    transition: all 0.2s ease;
    cursor: pointer;
}

.unified-dot:hover {
    filter: drop-shadow(0 2px 4px rgba(59, 130, 246, 0.4));
}

/* Chart axis styles */
.unified-chart-svg .x-axis text,
.unified-chart-svg .y-axis text {
    fill: #9ca3af;
    font-size: 11px;
}

.unified-chart-svg .x-axis line,
.unified-chart-svg .y-axis line,
.unified-chart-svg .x-axis path,
.unified-chart-svg .y-axis path {
    stroke: #4b5563;
    stroke-width: 1;
}

.unified-chart-svg .x-label,
.unified-chart-svg .y-label {
    fill: #6b7280;
    font-size: 12px;
    font-weight: 500;
}

/* Chart tooltip styles */
.unified-chart-tooltip {
    background: rgba(0, 0, 0, 0.9) !important;
    color: white !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    pointer-events: none !important;
    z-index: 10000 !important;
    max-width: 250px !important;
    line-height: 1.4 !important;
}

/* Legacy chart compatibility */
.chart-container.legacy {
    opacity: 0.8;
    filter: grayscale(0.2);
}

.chart-container.legacy .chart-header {
    background: rgba(245, 158, 11, 0.1);
    border-bottom-color: rgba(245, 158, 11, 0.3);
}

/* Responsive design */
@media (max-width: 768px) {
    .unified-chart-container {
        margin: 12px 0;
    }
    
    .unified-chart-container .chart-header {
        padding: 10px 12px;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .unified-chart-container .chart-content {
        padding: 12px;
        text-align: center;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .chart-type-badge {
        align-self: flex-end;
    }
}

/* Animation for chart appearance */
.unified-chart-container {
    animation: chartFadeIn 0.5s ease-out;
}

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

/* Chart interaction states */
.unified-chart-container:focus-within {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .unified-chart-container {
        border-width: 2px;
        border-color: #ffffff;
    }
    
    .chart-type-badge {
        border-width: 2px;
    }
    
    .unified-chart-svg .x-axis text,
    .unified-chart-svg .y-axis text,
    .unified-chart-svg .x-label,
    .unified-chart-svg .y-label {
        fill: #ffffff;
        font-weight: 600;
    }
}

/* ========================================
   SOTA ENHANCED CHART STYLES
   ======================================== */

/* Enhanced Chart Container Styling with Glassmorphism */
.unified-chart-container {
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin: 16px 0;
    overflow: hidden;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    transition: all 0.3s ease;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.unified-chart-container:hover {
    background: var(--surface-overlay-strong);
    border-color: color-mix(in srgb, var(--border-subtle) 40%, var(--text-secondary));
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    box-shadow: 
        0 12px 40px rgba(59, 130, 246, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Scatter Chart Specific Styles */
.scatter-chart .scatter-dot {
    transition: all 0.2s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.scatter-chart .scatter-dot:hover {
    filter: drop-shadow(0 4px 8px rgba(79, 70, 229, 0.4));
}

.scatter-chart .voronoi-cell:focus {
    outline: 2px solid rgba(79, 70, 229, 0.6);
    outline-offset: 2px;
}

/* Area Chart Specific Styles */
.area-chart .area-path {
    filter: drop-shadow(0 4px 8px rgba(79, 70, 229, 0.3));
}

.area-chart .area-line {
    filter: drop-shadow(0 2px 4px rgba(79, 70, 229, 0.4));
}

.area-chart .area-dot {
    transition: all 0.2s ease;
    cursor: pointer;
}

.area-chart .area-dot:hover {
    filter: drop-shadow(0 3px 6px rgba(79, 70, 229, 0.5));
}

.area-chart .guide-line {
    opacity: 0.7;
    animation: pulse-guide 2s infinite;
}

@keyframes pulse-guide {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 0.4; }
}

/* Pie Chart Specific Styles */
.pie-chart .pie-slice {
    cursor: pointer;
    transition: all 0.3s ease;
}

.pie-chart .pie-slice:hover path {
    filter: brightness(1.1) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.pie-chart .pie-slice:focus {
    outline: 3px solid rgba(79, 70, 229, 0.6);
    outline-offset: 3px;
    border-radius: 8px;
}

.pie-chart .label-line {
    transition: opacity 0.3s ease;
}

.pie-chart .pie-label {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

/* Donut Chart Specific Styles */
.donut-chart .donut-slice {
    cursor: pointer;
    transition: all 0.3s ease;
}

.donut-chart .donut-slice:hover path {
    filter: brightness(1.1) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.donut-chart .donut-center {
    transition: all 0.3s ease;
}

.donut-chart .donut-total-label {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.donut-chart .donut-total-value {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.1));
}

/* Enhanced Glassmorphic Tooltip */
.glassmorphic-tooltip {
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 12px !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.95) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
    max-width: 300px;
    min-width: 120px;
    animation: tooltip-appear 0.2s ease-out;
}

@keyframes tooltip-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.glassmorphic-tooltip strong {
    color: rgba(255, 255, 255, 1);
    font-weight: 600;
}

/* No Data State Styling */
.no-data-state {
    background: rgba(255, 255, 255, 0.03) !important;
    backdrop-filter: blur(10px) saturate(120%) !important;
    -webkit-backdrop-filter: blur(10px) saturate(120%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    transition: all 0.3s ease;
    animation: fade-in 0.5s ease-out;
}

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

.no-data-state:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* Enhanced Axis Styling */
.unified-chart-svg .axis-label {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.025em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.unified-chart-svg .x-axis, 
.unified-chart-svg .y-axis {
    transition: all 0.3s ease;
}

.unified-chart-svg .domain,
.unified-chart-svg .tick line {
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 1px;
    transition: all 0.3s ease;
}

.unified-chart-svg .tick text {
    fill: rgba(255, 255, 255, 0.8);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 11px;
    transition: all 0.3s ease;
}

/* Responsive Design for Charts */
@media (max-width: 768px) {
    .unified-chart-container {
        margin: 12px 0;
        border-radius: 10px;
    }
    
    .glassmorphic-tooltip {
        font-size: 12px !important;
        padding: 10px 12px !important;
        max-width: 250px;
    }
    
    .unified-chart-svg .tick text {
        font-size: 10px;
    }
    
    .unified-chart-svg .axis-label {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .unified-chart-container {
        margin: 8px 0;
        border-radius: 8px;
    }
    
    .glassmorphic-tooltip {
        font-size: 11px !important;
        padding: 8px 10px !important;
        max-width: 200px;
    }
    
    .no-data-state {
        height: 200px !important;
    }
    
    .unified-chart-svg .axis-label {
        font-size: 11px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .unified-chart-container {
        border: 2px solid rgba(255, 255, 255, 0.8);
        background: rgba(0, 0, 0, 0.9);
    }
    
    .glassmorphic-tooltip {
        background: rgba(0, 0, 0, 0.95) !important;
        border: 2px solid rgba(255, 255, 255, 0.8) !important;
    }
    
    .unified-chart-svg .domain,
    .unified-chart-svg .tick line {
        stroke: rgba(255, 255, 255, 0.8);
        stroke-width: 2px;
    }
    
    .unified-chart-svg .tick text,
    .unified-chart-svg .axis-label {
        fill: rgba(255, 255, 255, 1);
        font-weight: 600;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .unified-chart-container,
    .glassmorphic-tooltip,
    .scatter-chart .scatter-dot,
    .area-chart .area-dot,
    .pie-chart .pie-slice,
    .donut-chart .donut-slice {
        transition: none !important;
        animation: none !important;
    }
    
    .area-chart .guide-line {
        animation: none;
        opacity: 0.7;
    }
}

/* Print Styles for Charts */
@media print {
    .unified-chart-container {
        background: white !important;
        border: 1px solid #000 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        box-shadow: none !important;
    }
    
    .glassmorphic-tooltip {
        display: none !important;
    }
    
    .unified-chart-svg .tick text,
    .unified-chart-svg .axis-label {
        fill: #000 !important;
    }
    
    .unified-chart-svg .domain,
    .unified-chart-svg .tick line {
        stroke: #000 !important;
    }
}

/* ========================================
   EXISTING CHART STYLING (PRESERVED)
   ======================================== */

/* Notifications & Reminders */
.journal-reminders {
    position: relative;
    margin: var(--space-3) var(--space-4);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    background: var(--surface-overlay);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    display: none;
}

.journal-reminders--visible {
    display: block;
}

.journal-reminders__content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.journal-reminders__body {
    flex: 1;
    min-width: 220px;
}

.journal-reminders__list {
    list-style: none;
    padding: 0;
    margin: var(--space-2) 0 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.journal-reminders__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.journal-reminders__text {
    color: var(--text-secondary);
}

.journal-reminders__actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .journal-reminders__item {
        flex-direction: column;
        align-items: flex-start;
    }

    .journal-reminders__actions {
        width: 100%;
    }
}

.paste-success-message {
    position: absolute;
    top: -32px;
    left: var(--space-3);
    background: color-mix(in srgb, var(--success) 85%, transparent);
    color: #ffffff;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    font-size: var(--font-size-xs);
    z-index: 40;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

[data-theme="light"] .paste-success-message {
    color: #06361f;
}

.notification-container {
    position: fixed;
    bottom: var(--space-5);
    left: var(--space-5);
    z-index: 10000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.notification-toast {
    --notification-accent: var(--info);
    background: var(--surface-overlay-strong);
    color: var(--text-primary);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    word-wrap: break-word;
    transform: translateX(-120%);
    opacity: 0;
    transition: transform 0.3s var(--ease-out), opacity 0.3s var(--ease-out);
    pointer-events: auto;
    font-size: var(--font-size-sm);
    line-height: 1.4;
    position: relative;
    border: 1px solid color-mix(in srgb, var(--notification-accent) 30%, var(--border-subtle));
    overflow: hidden;
}

.notification-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--notification-accent);
    opacity: 0.9;
}

.notification-toast--visible {
    transform: translateX(0);
    opacity: 1;
}

.notification-toast--closing {
    transform: translateX(-120%);
    opacity: 0;
}

/* Notification toast variants - Dark theme (default) */
.notification-toast--success { 
    --notification-accent: var(--success); 
    color: #f6fffb; 
}
.notification-toast--error { 
    --notification-accent: var(--error); 
    color: #fff5f5; 
}
.notification-toast--warning { 
    --notification-accent: var(--warning); 
    color: #fff8e1; 
}
.notification-toast--info { 
    --notification-accent: var(--info); 
    color: #e9f2ff; 
}

/* Notification toast variants - Light theme overrides */
[data-theme="light"] .notification-toast--success {
    color: #065f46;
}

[data-theme="light"] .notification-toast--error {
    color: #7f1d1d;
}

[data-theme="light"] .notification-toast--warning {
    color: #78350f;
}

[data-theme="light"] .notification-toast--info {
    color: #1e3a8a;
}

.notification-toast__content {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.notification-toast__icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--notification-accent);
}

.notification-toast__message {
    flex: 1;
}

.notification-toast__close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0;
    margin-left: var(--space-2);
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.notification-toast__close:hover {
    color: var(--notification-accent);
}

.notification-toast__action {
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--notification-accent) 35%, var(--border-subtle));
    color: var(--notification-accent);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius);
    cursor: pointer;
    margin-top: var(--space-3);
    font-size: var(--font-size-xs);
    transition: background 0.2s ease, color 0.2s ease;
}

.notification-toast__action:hover {
    background: color-mix(in srgb, var(--notification-accent) 15%, transparent);
    color: var(--text-primary);
}

@media (max-width: 640px) {
    .notification-container {
        left: var(--space-3);
        right: var(--space-3);
        bottom: var(--space-3);
    }

    .notification-toast {
        width: 100%;
        max-width: none;
    }
}

/* ===== RESTRUCTURED HEURISTICS UI STYLES ===== */

.app-content-forced {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    min-height: 100vh !important;
    height: auto !important;
    background: var(--surface-1) !important;
    color: var(--text-primary) !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    z-index: 1 !important;
}

.app-container-forced {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
    width: 100% !important;
}

.role-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    margin-left: var(--space-2);
    color: #ffffff;
}

.role-badge--guest {
    background: color-mix(in srgb, var(--text-secondary) 70%, transparent);
}

.role-badge--student {
    background: var(--info);
}

.role-badge--instructor {
    background: var(--success);
}

.role-badge--lf {
    background: var(--personal-ai);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--surface-overlay-strong) 85%, rgba(0,0,0,0.4));
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    z-index: 9999;
}

.modal-overlay.hidden {
  display: none;
}

.modal-shell {
    background: var(--surface-2);
    color: var(--text-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-subtle);
    width: min(600px, 95%);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-shell--sm {
    width: min(420px, 92%);
}

.modal-shell--lg {
    width: min(860px, 95%);
}

.modal-shell--xl {
    width: min(1040px, 96%);
}

.modal-shell--full {
    width: min(1280px, 98%);
}

.modal-shell__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-3);
}

.modal-shell__header h3 {
    margin: 0;
    font-size: var(--font-size-xl);
}

.modal-shell__close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-shell__body {
    color: var(--text-secondary);
}

.modal-shell__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-5);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.bulk-upload-modal .upload-instructions {
    background: var(--surface-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-4);
}

.bulk-upload-modal pre {
    background: var(--surface-2);
    padding: var(--space-3);
    border-radius: var(--radius);
    overflow-x: auto;
    color: var(--text-secondary);
}

.bulk-upload-modal .form-group {
    margin-bottom: var(--space-4);
}

.bulk-upload-modal label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 500;
    color: var(--text-primary);
}

.bulk-upload-modal .form-control {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
}

.checkbox-inline {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
}

.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.checkbox-inline span {
    color: var(--text-secondary);
}

.upload-progress.hidden,
.upload-results.hidden {
    display: none;
}

.upload-progress .progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-3);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.upload-progress .progress-fill {
    height: 100%;
    background: var(--info);
    transition: width 0.3s ease;
}

.upload-progress .progress-text {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.upload-results {
    margin-top: var(--space-4);
}

.framework-chart {
    width: 100%;
    padding: var(--space-5);
    background: radial-gradient(circle at top, color-mix(in srgb, var(--surface-overlay-strong) 70%, transparent), var(--surface-overlay));
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
}

.framework-chart__title {
    margin: 0 0 var(--space-4);
    text-align: center;
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--text-primary);
}

.framework-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    grid-auto-rows: minmax(160px, auto);
    gap: var(--space-4);
}

.framework-grid__section {
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    overflow-y: auto;
    border: 2px solid transparent;
    background: color-mix(in srgb, var(--surface-overlay) 85%, transparent);
}

.framework-grid__section--strengths {
    border-color: color-mix(in srgb, var(--success) 60%, transparent);
    background: color-mix(in srgb, var(--success) 12%, var(--surface-overlay));
}

.framework-grid__section--weaknesses {
    border-color: color-mix(in srgb, var(--error) 60%, transparent);
    background: color-mix(in srgb, var(--error) 12%, var(--surface-overlay));
}

.framework-grid__section--opportunities {
    border-color: color-mix(in srgb, var(--info) 60%, transparent);
    background: color-mix(in srgb, var(--info) 12%, var(--surface-overlay));
}

.framework-grid__section--threats {
    border-color: color-mix(in srgb, var(--warning) 60%, transparent);
    background: color-mix(in srgb, var(--warning) 12%, var(--surface-overlay));
}

.framework-grid__title {
    margin: 0 0 var(--space-2);
    color: var(--text-primary);
    font-size: var(--font-size-lg);
    font-weight: 600;
    text-align: center;
}

.framework-grid__item {
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
    font-size: var(--font-size-sm);
    line-height: 1.4;
}
.seed-wizard-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--surface-overlay-strong) 80%, rgba(0,0,0,0.4));
    backdrop-filter: blur(6px);
    padding: var(--space-4);
}

.seed-wizard-card {
    width: min(95%, 560px);
    background: var(--surface-overlay);
    color: var(--text-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-subtle);
    animation: cardFadeIn 0.3s ease;
}

.seed-wizard-header {
    text-align: center;
    margin-bottom: var(--space-4);
}

.seed-wizard-title {
    font-weight: 600;
    font-size: var(--font-size-lg);
}

.seed-wizard-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.seed-wizard-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.seed-wizard-question h3 {
    margin: 0;
    font-size: 1.1rem;
}

.seed-wizard-question span {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.seed-wizard-prompt {
    margin: 0 0 var(--space-3);
    color: var(--text-secondary);
    line-height: 1.6;
}

.seed-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-2);
}

.seed-option {
    text-align: left;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-primary);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: var(--font-size-base);
    transition: border-color 0.2s ease, background 0.2s ease;
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
}

.seed-option strong {
    color: var(--info);
}

.seed-option:hover {
    border-color: var(--info);
}

.seed-option--selected {
    border-color: var(--info);
    background: color-mix(in srgb, var(--info) 12%, transparent);
}

.seed-wizard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-4);
    gap: var(--space-4);
}

.seed-wizard-cancel {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.seed-wizard-cancel:hover {
    color: var(--text-primary);
}

.seed-wizard-actions {
    display: flex;
    gap: var(--space-2);
}

/* Permission Banner Styles */
.permission-banner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    border: 1px solid rgba(107, 114, 128, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 24px 16px 24px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.permission-banner.owner {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(34, 197, 94, 0.1) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

.permission-banner.readonly {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.15) 0%, rgba(245, 158, 11, 0.1) 100%);
    border-color: rgba(251, 146, 60, 0.3);
}

.permission-banner.no-model {
    background: linear-gradient(135deg, rgba(107, 114, 128, 0.1) 0%, rgba(75, 85, 99, 0.1) 100%);
    border-color: rgba(107, 114, 128, 0.3);
}

/* Workflow Group Styles */
.workflow-groups {
    padding: 0 24px;
}

.workflow-group {
    margin-bottom: 32px;
}

.workflow-group-header {
    margin-bottom: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(147, 51, 234, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.workflow-group-header h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.workflow-group-header p {
    font-size: 0.875rem;
    color: rgba(156, 163, 175, 0.9);
    margin: 0;
}

/* Group Sub-Tab Navigation */
.group-sub-tabs .flex {
    border-bottom: 1px solid rgba(107, 114, 128, 0.3);
    margin-bottom: 16px;
}

.model-sub-tab-btn {
    position: relative;
    padding: 12px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    background: transparent;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.model-sub-tab-btn:hover {
    background: rgba(59, 130, 246, 0.05);
}

.model-sub-tab-btn.active {
    color: #60a5fa !important;
    border-bottom-color: #60a5fa !important;
    background: rgba(59, 130, 246, 0.1);
}

.model-sub-tab-btn[data-group="model-specific"] {
    border-left: 3px solid rgba(34, 197, 94, 0.5);
}

.model-sub-tab-btn[data-group="model-management"] {
    border-left: 3px solid rgba(168, 85, 247, 0.5);
}

/* Permission Indicator Styles */
.permission-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: rgba(156, 163, 175, 0.8);
}

.permission-indicator.owner::before {
    content: "🔓";
    font-size: 0.875rem;
}

.permission-indicator.readonly::before {
    content: "👁️";
    font-size: 0.875rem;
}

/* Read-only View Styles */
.readonly-view {
    margin-bottom: 16px;
}

.readonly-view .bg-orange-900 {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1px solid rgba(251, 146, 60, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Owner-only Action Styles */
.owner-only-actions {
    border-top: 1px solid rgba(107, 114, 128, 0.2);
    padding-top: 16px;
    margin-top: 16px;
}

.owner-only:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.owner-only:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Model Card Styles */
.model-card {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    transition: transform var(--duration-200) var(--ease-out), box-shadow var(--duration-200) var(--ease-out), border-color var(--duration-200) var(--ease-out);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    color: var(--text-primary);
}

.model-card:hover {
    border-color: color-mix(in srgb, var(--primary-400) 35%, var(--border-subtle));
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.model-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
    opacity: 0;
    transition: opacity var(--duration-200) var(--ease-out);
}

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

.model-card__status {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: color-mix(in srgb, var(--surface-2) 90%, transparent);
    color: var(--text-secondary);
}

.model-card__status--owned {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 15%, transparent);
}

.model-card__status--shared {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 18%, transparent);
}

/* Model Actions on Cards */
.model-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(107, 114, 128, 0.2);
}

.model-actions button {
    border: none;
    background: transparent;
    cursor: pointer;
}

.model-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    transition: transform var(--duration-150) var(--ease-out), box-shadow var(--duration-150) var(--ease-out), background-color var(--duration-150) var(--ease-out);
    color: var(--text-secondary);
}

.model-action-btn:hover {
    transform: translateY(-1px);
    background: color-mix(in srgb, var(--surface-3) 85%, transparent);
    box-shadow: var(--shadow-sm);
}

.model-action-btn--success {
    color: var(--success);
}

.model-action-btn--warning {
    color: var(--warning);
}

.model-action-btn--danger {
    color: var(--error);
}

.model-action-btn--info {
    color: var(--info);
}

/* Persona Display Styles */
#persona-display {
    max-height: none;
    overflow: visible;
}

#persona-content-display {
    max-height: none;
    overflow: visible;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.persona-text {
    line-height: 1.6;
    color: rgba(209, 213, 219, 0.9);
}

.persona-heading {
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    color: #e5e7eb;
}

.persona-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    align-items: start;
    margin: 6px 0;
}

.persona-label {
    color: #9ca3af;
    font-weight: 600;
}

.persona-value {
    color: #e5e7eb;
}

.persona-paragraph {
    margin: 6px 0;
}

.persona-list {
    padding-left: 18px;
    margin: 4px 0 10px;
}

.persona-list li {
    list-style-type: disc;
    margin: 2px 0;
}

.persona-text strong {
    color: rgba(239, 246, 255, 1);
    font-weight: 600;
}

.persona-text em {
    color: rgba(96, 165, 250, 1);
    font-style: italic;
}

/* Mobile responsiveness for persona readability */
@media (max-width: 640px) {
    #persona-display {
        padding: 12px;
    }
    #persona-content-display {
        font-size: 0.95rem;
        line-height: 1.55;
    }
    .persona-row { grid-template-columns: 90px 1fr; }
}

/* Model Actions Grid */
.model-actions-grid {
    gap: 24px;
}

.action-section {
    background: var(--surface-overlay);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.action-section:hover {
    border-color: color-mix(in srgb, var(--border-subtle) 50%, var(--text-secondary));
    background: var(--surface-overlay-strong);
}

.action-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-section p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* Enhanced Button Styles for Actions */
.action-section button {
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    position: relative;
    overflow: hidden;
}

.action-section button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.action-section button:hover::before {
    left: 100%;
}

.action-section button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-section button:disabled:hover {
    transform: none;
}

.action-section button:disabled::before {
    display: none;
}

/* Responsive Design for Workflow Groups */
@media (max-width: 768px) {
    .workflow-groups {
        padding: 0 16px;
    }
    
    .workflow-group-header {
        padding: 12px 16px;
    }
    
    .workflow-group-header h4 {
        font-size: 1rem;
    }
    
    .permission-banner {
        margin: 0 16px 16px 16px;
        padding: 10px 14px;
    }
    
    .model-sub-tab-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    
    .model-actions-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Animation for Permission State Changes */
@keyframes permissionChange {
    0% { opacity: 0.7; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 1; transform: scale(1); }
}

.permission-banner.changing {
    animation: permissionChange 0.5s ease-out;
}

/* Focus States for Accessibility */
.model-sub-tab-btn:focus {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}

.model-card:focus {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}

.action-section button:focus {
    outline: 2px solid var(--primary-400);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .permission-banner {
        border-width: 2px;
    }
    
    .workflow-group-header {
        border-width: 2px;
    }
    
    .model-card {
        border-width: 2px;
    }
    
    .readonly-view .bg-orange-900 {
        border-width: 2px;
    }
}

/* Print Styles for New Elements */
@media print {
    .permission-banner,
    .workflow-group-header {
        background: none !important;
        border: 1px solid #000 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .model-card {
        background: white !important;
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
}


/* ===== CONVERSATION HISTORY PANEL ===== */

.conversation-history-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    color: #3b82f6;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 40px;
    height: 40px;
}

.conversation-history-toggle:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.conversation-history-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    height: 100vh;
    background: var(--surface-overlay);
    border-right: 1px solid var(--border-subtle);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    transform: translateX(0);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.conversation-history-panel.hidden {
    transform: translateX(-100%);
}

.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-overlay-strong);
    backdrop-filter: blur(10px);
}

.history-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-panel-title i {
    color: var(--info);
}

.history-panel-actions {
    display: flex;
    gap: 8px;
}

.history-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--surface-3);
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: var(--surface-4);
    color: var(--text-primary);
    transform: scale(1.05);
}

.history-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.history-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #9ca3af;
    gap: 12px;
}

.history-loading .spinner-ring {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.history-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
}

/* CRITICAL FIX: Hidden states for conversation history elements */
.history-loading.hidden {
    display: none !important;
}

.history-empty-state.hidden {
    display: none !important;
}

.conversations-list {
    padding: 0 16px;
}

.conversation-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: rgba(55, 65, 81, 0.6);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

[data-theme="light"] .conversation-history-item {
    background: var(--surface-2);
    border-color: var(--border-subtle);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}

.conversation-history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: #3b82f6;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.conversation-history-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateX(4px);
}

[data-theme="light"] .conversation-history-item:hover {
    background: color-mix(in srgb, var(--primary-500) 8%, var(--surface-2));
    border-color: color-mix(in srgb, var(--primary-500) 40%, var(--border-subtle));
}

.conversation-history-item:hover::before {
    opacity: 1;
}

.conversation-item-content {
    flex: 1;
    min-width: 0;
}

.conversation-title {
    font-size: 14px;
    font-weight: 500;
    color: #f9fafb;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

[data-theme="light"] .conversation-title {
    color: var(--text-primary);
}

.conversation-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #9ca3af;
}

[data-theme="light"] .conversation-meta {
    color: var(--text-muted);
}

.conversation-time,
.conversation-messages {
    white-space: nowrap;
}

.conversation-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: 12px;
}

.conversation-history-item:hover .conversation-actions {
    opacity: 1;
}

.conversation-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(75, 85, 99, 0.4);
    color: #9ca3af;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

[data-theme="light"] .conversation-action-btn {
    background: color-mix(in srgb, var(--surface-3) 90%, transparent);
    color: var(--text-secondary);
    border: 1px solid color-mix(in srgb, var(--border-subtle) 70%, transparent);
}

.conversation-action-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    transform: scale(1.1);
}

.conversation-action-btn.delete-conversation:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .conversation-history-panel {
        width: 100%;
        max-width: 320px;
    }
}

/* Overlay for mobile */
@media (max-width: 640px) {
    .conversation-history-panel:not(.hidden)::after {
        content: '';
        position: fixed;
        top: 0;
        left: 100%;
        width: calc(100% - 100%);
        height: 100vh;
        height: 100dvh;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: -1;
    }
}

/* Auto-saved conversation styling */
.conversation-history-item.auto-saved {
    border-left: 3px solid #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.conversation-history-item.auto-saved:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.auto-save-indicator {
    display: inline-block;
    margin-right: 6px;
    opacity: 0.7;
    font-size: 12px;
    animation: pulse 2s infinite;
}

.auto-save-label {
    font-size: 10px;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.2);
    margin-left: 8px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* ===== MY MODELS SUBTAB IMPROVEMENTS ===== */

/* Editable model name input */
.model-card .model-name-input {
    transition: all var(--duration-150) var(--ease-out);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
}

.model-card .model-name-input:hover {
    background-color: color-mix(in srgb, var(--surface-2) 85%, transparent);
    border-color: color-mix(in srgb, var(--border-subtle) 60%, transparent);
}

.model-card .model-name-input:focus {
    background-color: color-mix(in srgb, var(--surface-3) 92%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-400) 35%, transparent);
    border-color: color-mix(in srgb, var(--primary-400) 45%, transparent);
    color: var(--text-primary);
}

/* Editable model description textarea */
.model-card .model-description-input {
    transition: all var(--duration-150) var(--ease-out);
    font-family: inherit;
    min-height: 60px;
    max-height: 120px;
    background: transparent;
    border: 1px solid transparent;
    line-height: 1.4;
    color: var(--text-secondary);
}

.model-card .model-description-input:hover {
    background-color: color-mix(in srgb, var(--surface-2) 85%, transparent);
    border-color: color-mix(in srgb, var(--border-subtle) 60%, transparent);
}

.model-card .model-description-input:focus {
    background-color: color-mix(in srgb, var(--surface-3) 92%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-400) 35%, transparent);
    border-color: color-mix(in srgb, var(--primary-400) 45%, transparent);
    color: var(--text-primary);
}

/* Placeholder styling */
.model-card .model-name-input::placeholder,
.model-card .model-description-input::placeholder {
    color: var(--placeholder-color);
    font-style: italic;
}

/* Model action buttons */
.model-actions button {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.model-actions button:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.model-actions button:active {
    transform: scale(1.05);
}

/* Visibility toggle button states */
.model-actions button[title*="Public"] {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.model-actions button[title*="Private"] {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.3);
}

/* Loading states for buttons */
.model-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    pointer-events: none;
}

/* Improved model card hover effects */
.model-card {
    min-height: 180px;
    display: flex;
    flex-direction: column;
}

.model-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.model-card:hover .model-actions button {
    opacity: 1;
}

.model-actions {
    opacity: 0.8;
    transition: opacity 0.2s ease;
    margin-top: auto;
}

.planner-embedded-host { margin: 2px 0; }
.planner-embedded-container { background: rgba(15,23,42,0.6); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 10px; }
.planner-embedded-header { display:flex; align-items:center; justify-content: space-between; font-size: 12px; color: rgba(148,163,184,0.95); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.planner-embedded-header .title { font-weight: 600; }
.planner-embed-toggle { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; padding: 0 8px; line-height: 20px; cursor: pointer; }
.planner-embed-toggle:hover { background: rgba(59,130,246,0.2); border-color: rgba(59,130,246,0.4); }
.planner-embedded-body .planner-list { list-style: none; margin: 0 0 6px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.planner-embedded-body .planner-activity { max-height: 120px; overflow: auto; border: 1px dashed rgba(255,255,255,0.12); border-radius: 8px; padding: 6px; background: rgba(255,255,255,0.03); margin-bottom: 6px; }
.planner-embedded-body .planner-stream { max-height: 120px; }
.planner-section-title { font-size: 11px; color: rgba(148,163,184,0.95); text-transform: uppercase; letter-spacing: 0.04em; margin: 6px 0 4px; }

/* Scroll to bottom button styles */
.scroll-to-bottom-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: rgba(59, 130, 246, 0.9);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    z-index: 1000;
}

.scroll-to-bottom-button.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-bottom-button:hover {
    background: rgba(59, 130, 246, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-bottom-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.scroll-to-bottom-button svg {
    width: 20px;
    height: 20px;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .scroll-to-bottom-button {
        bottom: 15px;
        right: 15px;
        width: 44px;
        height: 44px;
    }
    
    .scroll-to-bottom-button svg {
        width: 18px;
        height: 18px;
    }
}
