/**
 * Yusagi AI Assistant - Shared Styles
 *
 * Synced with muratov.io design system
 * Emerald + Cyan accent for consistent branding
 * Subtle glassmorphism, modern micro-interactions
 */

/* ============================================
   CSS VARIABLES - EMERALD COLOR PALETTE
   (Synced from muratov.io)
   ============================================ */

:root {
  /* Light mode - clean, professional */
  --bg: #FAFBFC;
  --fg: #0F172A;
  --muted: #5B6876; /* WCAG AA compliant: 4.9:1 contrast on light bg */
  --border: #E2E8F0;
  --surface: #FFFFFF;
  --surface-elevated: #FFFFFF;

  /* Refined Emerald + Cyan system (from muratov.io) */
  --accent: #059669;
  --accent-soft: #10B981;
  --accent-muted: #D1FAE5;
  --accent-text: #047857;
  --secondary: #06B6D4;
  --secondary-soft: #22D3EE;
  --secondary-muted: #CFFAFE;

  /* Semantic - softer tones */
  --success: #059669;
  --warning: #D97706;
  --error: #DC2626;

  /* Shadows - 2026 softer, more natural */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  --shadow-glow: 0 0 20px rgb(5 150 105 / 0.15);

  /* Typography */
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Border radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Transitions */
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;

  color-scheme: light;
}

.dark {
  /* Dark mode - richer, deeper tones */
  --bg: #0B0F14;
  --fg: #F1F5F9;
  --muted: #B8C5D6; /* WCAG AA compliant: 5.3:1 contrast on dark bg */
  --border: #1E293B;
  --surface: #111827;
  --surface-elevated: #1F2937;

  /* Brighter accents for dark mode (from muratov.io) */
  --accent: #10B981;
  --accent-soft: #34D399;
  --accent-muted: #064E3B;
  --accent-text: #6EE7B7;
  --secondary: #22D3EE;
  --secondary-soft: #67E8F9;
  --secondary-muted: #164E63;

  /* Semantic - adjusted for dark */
  --success: #34D399;
  --warning: #FBBF24;
  --error: #F87171;

  /* Shadows - glow-focused for dark mode */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.5);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.6);
  --shadow-glow: 0 0 30px rgb(16 185 129 / 0.2);

  color-scheme: dark;
}

/* ============================================
   BASE LAYOUT
   ============================================ */

html,
body {
  height: 100%;
}

html {
  scroll-behavior: smooth;
  font-size: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Force scrollbar on all pages for consistent viewport width */
  overflow-y: scroll;
}

/* Background Noise */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.02"/></svg>');
  opacity: 0.3;
}

.dark .noise {
  opacity: 0.4;
}

/* ============================================
   SECTION BACKGROUNDS & TRANSITIONS
   ============================================ */

/* Smooth section background transitions on scroll */
section {
  position: relative;
  transition: background-color 0.3s ease;
}

/* Section divider line for visual separation */
section::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 1100px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  opacity: 0;
  pointer-events: none;
}

/* Icon container styles - consistent across all cards */
.icon-container {
  width: 56px;
  height: 56px;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
  transition: transform 0.3s var(--ease-spring);
}

.icon-container.accent {
  background: linear-gradient(to bottom right, var(--accent), rgba(5, 150, 105, 0.7));
}

.icon-container.secondary {
  background: linear-gradient(to bottom right, var(--secondary), rgba(6, 182, 212, 0.7));
}

.icon-container.mixed {
  background: linear-gradient(to bottom right, var(--accent), var(--secondary));
}

.icon-container svg {
  width: 28px;
  height: 28px;
  color: white;
}

.group:hover .icon-container {
  transform: scale(1.1);
}

/* ============================================
   GLASSMORPHISM
   ============================================ */

.glass {
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  background: rgba(250, 251, 252, 0.85);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

.dark .glass {
  background: rgba(11, 15, 20, 0.8);
  border-bottom: 1px solid rgba(30, 41, 59, 0.6);
}

/* ============================================
   GRADIENT BACKGROUNDS (Emerald)
   ============================================ */

.grad {
  background-image:
    radial-gradient(ellipse 1200px 700px at 15% 5%, rgba(5, 150, 105, 0.08), transparent 60%),
    radial-gradient(ellipse 900px 600px at 85% 15%, rgba(6, 182, 212, 0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 50% 95%, rgba(5, 150, 105, 0.04), transparent 60%);
}

.dark .grad {
  background-image:
    radial-gradient(ellipse 1200px 700px at 15% 5%, rgba(16, 185, 129, 0.15), transparent 60%),
    radial-gradient(ellipse 900px 600px at 85% 15%, rgba(34, 211, 238, 0.10), transparent 60%),
    radial-gradient(ellipse 700px 500px at 50% 95%, rgba(16, 185, 129, 0.06), transparent 60%);
}

@media (max-width: 768px) {
  .grad {
    background-image:
      radial-gradient(ellipse 500px 400px at 20% 10%, rgba(5, 150, 105, 0.08), transparent 60%),
      radial-gradient(ellipse 400px 300px at 80% 20%, rgba(6, 182, 212, 0.06), transparent 60%);
  }

  .dark .grad {
    background-image:
      radial-gradient(ellipse 500px 400px at 20% 10%, rgba(16, 185, 129, 0.15), transparent 60%),
      radial-gradient(ellipse 400px 300px at 80% 20%, rgba(34, 211, 238, 0.10), transparent 60%);
  }
}

/* ============================================
   ACCENT UNDERLINE
   ============================================ */

.accent-underline {
  background: linear-gradient(90deg, var(--accent), var(--secondary), transparent);
  height: 3px;
  width: 56px;
  border-radius: var(--radius-full);
  animation: slideInLeft var(--duration-slow) var(--ease-out);
}

@keyframes slideInLeft {
  from {
    width: 0;
    opacity: 0;
  }
  to {
    width: 56px;
    opacity: 1;
  }
}

/* ============================================
   CARD COMPONENT
   ============================================ */

.card {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: var(--space-lg);
  border-radius: var(--radius-xl);
  transition:
    border-color var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-spring);
  position: relative;
  box-shadow: var(--shadow-sm);
}

.card:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dark .card {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(30, 41, 59, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.dark .card:hover {
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow:
    var(--shadow-lg),
    0 0 20px rgba(16, 185, 129, 0.08);
}

/* ============================================
   FOCUS STATES - WCAG 2.2 COMPLIANT
   ============================================ */

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.12);
}

.dark input:focus,
.dark textarea:focus,
.dark select:focus {
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   SCROLL PROGRESS BAR
   ============================================ */

#scrollProgress {
  height: 2px;
  box-shadow: var(--shadow-glow);
  transition: width 80ms linear;
}

/* ============================================
   ANIMATIONS
   ============================================ */

#stickyCTA {
  animation: slideInUp var(--duration-slow) var(--ease-spring);
}

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

.fade-in {
  animation: fadeIn 0.7s var(--ease-out);
}

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.95);
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(-20%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

.animate-bounce {
  animation: bounce 1.2s infinite;
}

/* Glow pulse animation (Emerald) */
@keyframes glow-pulse {
  0%, 100% {
    box-shadow:
      0 0 15px rgba(5, 150, 105, 0.2),
      0 0 30px rgba(5, 150, 105, 0.1);
  }
  50% {
    box-shadow:
      0 0 25px rgba(5, 150, 105, 0.35),
      0 0 50px rgba(5, 150, 105, 0.15);
  }
}

.animate-glow {
  animation: glow-pulse 2.5s ease-in-out infinite;
}

/* ============================================
   SCREEN READER ONLY
   ============================================ */

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

/* ============================================
   RESPONSIVE TYPOGRAPHY
   ============================================ */

@media (max-width: 768px) {
  main h1,
  section h1 {
    font-size: 2rem;
    line-height: 1.15;
  }

  main h2,
  section h2 {
    font-size: 1.625rem;
  }

  main h3,
  section h3 {
    font-size: 1.25rem;
  }
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: inner-spin-button;
  width: 22px;
  height: 100%;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity var(--duration-fast) var(--ease-out);
}

input[type="number"]:hover::-webkit-outer-spin-button,
input[type="number"]:hover::-webkit-inner-spin-button {
  opacity: 0.7;
}

/* Select Dropdown - Fully Branded (2026 UX) */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--bg);
  background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23059669" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 1.125em 1.125em;
  padding: var(--space-sm) var(--space-md);
  padding-right: 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg);
  font-size: var(--text-base);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

select:hover {
  border-color: var(--accent);
  background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23059669" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

select option {
  background: var(--surface);
  color: var(--fg);
  padding: 0.875rem;
  font-size: var(--text-base);
}

select option:checked {
  background: var(--accent-muted);
  color: var(--accent-text);
}

select option:hover {
  background: var(--accent-muted);
}

select optgroup {
  font-weight: 600;
  color: var(--accent);
  background: var(--bg);
  padding: 0.5rem 0;
}

select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--surface);
}

/* Dark mode select */
.dark select {
  background-color: var(--bg);
  background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2310B981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
}

.dark select:hover {
  background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2310B981" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
}

.dark select:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.dark select option {
  background: var(--surface);
  color: var(--fg);
}

.dark select option:checked {
  background: var(--accent-muted);
  color: var(--accent-text);
}

.dark select optgroup {
  background: var(--surface);
  color: var(--accent);
}

/* ============================================
   MOBILE SAFE AREAS (iOS/Android)
   ============================================ */

@supports (padding: env(safe-area-inset-bottom)) {
  .pb-safe {
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  }

  .pt-safe {
    padding-top: calc(var(--space-lg) + env(safe-area-inset-top));
  }
}

/* ============================================
   MOBILE MENU ANIMATION
   ============================================ */

#mobileMenu {
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-spring);
}

#mobileMenu.hidden {
  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
}

#mobileMenu:not(.hidden) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ============================================
   REDUCED MOTION (Accessibility)
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .accent-underline,
  #stickyCTA,
  #mobileMenu,
  .animate-glow,
  .animate-pulse,
  .animate-bounce {
    animation: none !important;
  }

  * {
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  header,
  #mobileMenu,
  #stickyCTA,
  #scrollProgress,
  .noise,
  footer nav,
  .accent-underline,
  button {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
  }

  .card {
    border: 1px solid #ddd !important;
    background: white !important;
    break-inside: avoid;
    box-shadow: none !important;
  }

  a {
    color: #000 !important;
    text-decoration: underline !important;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
    color: #666;
  }

  main {
    padding-top: 0 !important;
  }

  h1, h2, h3 {
    color: black !important;
    break-after: avoid;
  }

  @page {
    margin: 2cm;
  }
}

/* ============================================
   BACKDROP FILTER FALLBACK
   ============================================ */

@supports not (backdrop-filter: blur(8px)) {
  .glass {
    background: var(--bg) !important;
  }
}

/* ============================================
   UTILITY CLASSES (Emerald)
   ============================================ */

/* Glow effects */
.glow-emerald {
  box-shadow: 0 0 20px rgba(5, 150, 105, 0.25);
}

.glow-emerald-lg {
  box-shadow:
    0 0 25px rgba(5, 150, 105, 0.3),
    0 0 50px rgba(5, 150, 105, 0.15);
}

.glow-cyan {
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.25);
}

/* Text glow */
.text-glow {
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.35);
}

/* Border glow */
.border-glow {
  border: 1px solid rgba(5, 150, 105, 0.25);
  box-shadow:
    inset 0 0 8px rgba(5, 150, 105, 0.08),
    0 0 12px rgba(5, 150, 105, 0.15);
}

/* Hover glow */
.hover-glow {
  transition:
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-spring);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Gradient line */
.gradient-line {
  background: linear-gradient(90deg, var(--accent), var(--secondary));
  height: 2px;
}

/* Primary button - uses same gradient as logo for visual consistency */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  border: none;
  position: relative;
  overflow: hidden;
  transition:
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.6s var(--ease-out);
}

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

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

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

/* Button shine effect */
.btn-glow {
  position: relative;
  overflow: hidden;
  transition:
    box-shadow var(--duration-normal) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
}

.btn-glow::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.15),
    transparent
  );
  transition: left 0.6s var(--ease-out);
}

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

.btn-glow:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

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

/* ============================================
   LINK STYLES
   ============================================ */

.link-hover {
  position: relative;
  transition: color var(--duration-fast) var(--ease-out);
}

.link-hover::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--duration-normal) var(--ease-out);
}

.link-hover:hover::after {
  width: 100%;
}

.link-hover:hover {
  color: var(--accent);
}

/* ============================================
   BADGE STYLES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.375rem 0.875rem;
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--accent-muted);
  color: var(--accent-text);
  border: 1px solid transparent;
  transition:
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.dark .badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-soft);
}

.badge:hover {
  border-color: var(--accent);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateX(120%);
  transition: transform var(--duration-normal) var(--ease-spring);
  z-index: 100;
  max-width: 360px;
}

.toast.show {
  transform: translateX(0);
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.warning {
  border-left: 4px solid var(--warning);
}

/* ============================================
   CHAT INTERFACE STYLES - 2026 SLEEK REDESIGN
   Mobile-first, minimal, ChatGPT/Claude-inspired
   ============================================ */

:root {
  --header-height: 72px;
}

/* Chat Layout */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--header-height);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
  /* CRITICAL FIX: Prevent pull-to-refresh and overscroll bounce on mobile */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .chat-messages { padding: 1.5rem; }
}

/* Welcome State - Ultra Minimal */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 1rem;
}

.welcome-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
}

.welcome-logo svg {
  width: 100%;
  height: 100%;
}

.welcome-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .welcome-logo { width: 56px; height: 56px; }
  .welcome-title { font-size: 1.5rem; }
}

/* Suggestion Chips */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 500px;
}

.suggestion-chip {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 150ms ease;
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.suggestion-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Input Area */
.chat-input-container {
  padding: 0.75rem 1rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

@media (min-width: 640px) {
  .chat-input-container { padding: 1rem 1.5rem; }
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 768px;
  margin: 0 auto;
}

/* Tools Button & Dropdown */
.tools-container {
  position: relative;
}

.tools-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
  touch-action: manipulation; /* Eliminate 300ms tap delay */
}

.tools-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.tools-btn svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   FILE ATTACHMENT STYLES
   ============================================ */

.attachment-container {
  position: relative;
}

.attachment-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
  touch-action: manipulation; /* Eliminate 300ms tap delay */
}

.attachment-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.attachment-btn.has-file {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}

.attachment-btn svg {
  width: 20px;
  height: 20px;
}

/* File Preview */
.file-preview {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  max-width: 768px;
  margin: 0 auto;
  padding: 0 1rem;
}

.file-preview.hidden {
  display: none;
}

.file-preview-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.file-preview-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-muted);
  color: var(--accent);
  flex-shrink: 0;
}

.file-preview-icon svg {
  width: 20px;
  height: 20px;
}

.file-preview-thumbnail {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

.file-preview-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.file-preview .file-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview .file-size {
  font-size: var(--text-xs);
  color: var(--muted);
}

.file-remove-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms ease;
  touch-action: manipulation;
}

.file-remove-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

.file-remove-btn:focus-visible {
  outline: 2px solid var(--error);
  outline-offset: 2px;
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

.file-remove-btn svg {
  width: 16px;
  height: 16px;
}

/* Upload Progress */
.file-progress {
  margin-top: 0.5rem;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.file-progress.hidden {
  display: none;
}

.file-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--secondary));
  border-radius: var(--radius-full);
  width: 0%;
  transition: width 200ms ease;
}

/* Error State */
.file-preview.error .file-preview-content {
  border-color: var(--error);
  background: rgba(220, 38, 38, 0.05);
}

.file-preview .file-error {
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: 0.25rem;
  padding: 0 1rem;
}

/* Drag and Drop Overlay */
.chat-input-wrapper.drag-over {
  position: relative;
}

.chat-input-wrapper.drag-over::after {
  content: 'Drop file here';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-xl);
  color: var(--accent);
  font-weight: 500;
  z-index: 10;
}

@media (max-width: 640px) {
  .file-preview {
    padding: 0 0.75rem;
  }

  .file-preview-content {
    padding: 0.5rem 0.75rem;
  }

  .file-preview-icon,
  .file-preview-thumbnail {
    width: 32px;
    height: 32px;
  }
}

.tools-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 150ms ease;
  z-index: 50;
}

.tools-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.tool-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--fg);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 150ms ease;
  text-align: left;
}

.tool-item:first-child { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.tool-item:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.tool-item:hover {
  background: var(--accent);
  color: white;
}

.tool-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent);
  color: white;
}

.tool-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Chat Form */
.chat-form {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0.5rem;
  transition: border-color 150ms ease;
}

.chat-form:focus-within {
  border-color: var(--accent);
}

.chat-form textarea {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  padding: 0.5rem;
  font-size: 16px; /* Prevents iOS zoom */
  font-family: inherit;
  line-height: 1.5;
  color: var(--fg);
  background: transparent;
  border: none;
  resize: none;
  outline: none;
}

.chat-form textarea::placeholder {
  color: var(--muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation; /* Eliminate 300ms tap delay */
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  transform: scale(1.05);
}

.send-btn:focus-visible:not(:disabled) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
}

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

.send-btn svg {
  width: 18px;
  height: 18px;
}

/* Character Counter */
.char-counter {
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  max-width: 768px;
  margin: 0 auto;
}

.char-counter.warning { color: var(--warning); }
.char-counter.danger { color: var(--error); font-weight: 500; }
.char-counter.hidden { display: none; }

/* Messages */
.message {
  max-width: 90%;
  margin-bottom: 1rem;
  animation: messageSlideIn 0.25s ease-out;
}

@media (min-width: 768px) {
  .message { max-width: 75%; }
}

.message-user {
  margin-left: auto;
}

.message-assistant {
  margin-right: auto;
}

.message-bubble {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-xl);
  line-height: 1.6;
}

.message-user .message-bubble {
  background: var(--accent-muted);
  color: var(--fg);
}

.dark .message-user .message-bubble {
  background: var(--accent-muted);
  color: white;
}

.message-assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
}

/* Message Footer */
.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 150ms ease;
}

.message:hover .message-footer,
.message:focus-within .message-footer {
  opacity: 1;
}

@media (hover: none) {
  .message-footer { opacity: 0.7; }
}

.message-timestamp {
  font-size: 0.75rem;
  color: var(--muted);
}

.message-actions {
  display: flex;
  gap: 0.25rem;
}

.message-copy-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms ease;
}

.message-copy-btn:hover {
  background: var(--border);
  color: var(--fg);
}

.message-copy-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--border);
  color: var(--fg);
}

.message-copy-btn.copied {
  color: var(--success);
}

.message-copy-btn svg {
  width: 14px;
  height: 14px;
}

/* Typing Indicator */
.thinking-state {
  padding: 0.875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.thinking-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-size: 0.875rem;
}

.thinking-icon {
  animation: pulse-thinking 1.5s ease-in-out infinite;
}

@keyframes pulse-thinking {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Message Slide In Animation */
@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Markdown in Messages */
.message-content > *:first-child { margin-top: 0; }
.message-content > *:last-child { margin-bottom: 0; }

.message-content p {
  margin: 0 0 0.5rem;
  line-height: 1.6;
}

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

.message-content h1,
.message-content h2,
.message-content h3 {
  font-weight: 600;
  margin: 1rem 0 0.5rem;
  line-height: 1.3;
}

.message-content h1 { font-size: 1.125rem; }
.message-content h2 { font-size: 1rem; color: var(--accent); }
.message-content h3 { font-size: 0.9375rem; }

.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin-bottom: 0.25rem;
  line-height: 1.6;
}

.message-content li::marker {
  color: var(--accent);
}

/* Inline Code */
.message-content code {
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.dark .message-content code {
  background: rgba(16, 185, 129, 0.15);
}

/* Code Blocks */
.code-block-wrapper {
  margin: 0.75rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
}

.code-language-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.code-copy-btn {
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 150ms ease;
}

.code-copy-btn:hover {
  background: var(--accent);
  color: white;
}

.message-content pre {
  background: rgba(0, 0, 0, 0.05);
  padding: 0.75rem;
  overflow-x: auto;
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 0;
}

.dark .message-content pre {
  background: rgba(0, 0, 0, 0.3);
}

.code-block-wrapper pre {
  border-radius: 0;
  border: none;
}

.message-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Strong & Links */
.message-content strong { font-weight: 600; }

.message-content a {
  color: var(--accent);
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

/* Blockquotes */
.message-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  background: rgba(5, 150, 105, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-content blockquote p { margin: 0; }

/* Tables - CRITICAL FIX: Add horizontal scroll wrapper for mobile */
.message-content .table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0;
  border-radius: var(--radius-sm);
}

.message-content table {
  width: 100%;
  min-width: 400px; /* Prevent table from shrinking too small */
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0;
}

.message-content th,
.message-content td {
  padding: 0.5rem;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap; /* Prevent text wrap in cells on mobile */
}

@media (min-width: 640px) {
  .message-content th,
  .message-content td {
    white-space: normal; /* Allow wrapping on larger screens */
  }
}

.message-content th {
  background: var(--surface-elevated);
  font-weight: 600;
}

/* System Messages */
.message-system {
  max-width: 100%;
  margin: 0.5rem 0;
}

.message-system .message-bubble {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* Action buttons in system messages go to new line */
.message-system .message-bubble > div {
  flex-basis: 100%;
  margin-top: 0.5rem;
}

.message-system.error .message-bubble {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: var(--error);
}

/* Confirm Dialog */
.confirm-dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-xl);
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 1rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 150ms ease;
  z-index: 10;
  touch-action: manipulation;
}

.scroll-to-bottom-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.scroll-to-bottom-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.scroll-to-bottom-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Chat input position for scroll button */
/* ============================================
   END CHAT STYLES
   ============================================ */


/* ============================================
   ANIMATIONS
   ============================================ */

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

.stagger-item {
  opacity: 0;
  animation: fadeInUp 0.4s var(--ease-out) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }


/* ============================================
   FEATURE FORMS - WORKPAPER/QC/GAP CHECKER
   ============================================ */

/* Feature buttons in welcome state */
.feature-buttons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  max-width: 600px;
  width: 100%;
}

.feature-buttons-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.feature-buttons-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  width: 100%;
}

@media (max-width: 640px) {
  .feature-buttons-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
}

.feature-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border: 2px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-spring);
  text-align: center;
  min-height: 100px;
  box-shadow: var(--shadow-sm);
}

.feature-btn:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

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

.feature-btn svg {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

/* Workpaper button - Emerald/Accent */
.feature-btn[data-feature="workpaper"] {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), rgba(6, 182, 212, 0.1));
  border-color: var(--accent);
}

.feature-btn[data-feature="workpaper"] svg {
  color: var(--accent);
}

.feature-btn[data-feature="workpaper"]:hover {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  border-color: transparent;
}

.feature-btn[data-feature="workpaper"]:hover svg {
  color: white;
}

/* QC button - Cyan/Secondary (matches landing page) */
.feature-btn[data-feature="qc-check"] {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.1), rgba(34, 211, 238, 0.1));
  border-color: var(--secondary);
}

.feature-btn[data-feature="qc-check"] svg {
  color: var(--secondary);
}

.feature-btn[data-feature="qc-check"]:hover {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-soft));
  color: white;
  border-color: transparent;
}

.feature-btn[data-feature="qc-check"]:hover svg {
  color: white;
}

/* Gap check button - Emerald to Cyan gradient (matches landing page) */
.feature-btn[data-feature="gap-check"] {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.1), rgba(6, 182, 212, 0.1));
  border-color: var(--accent);
}

.feature-btn[data-feature="gap-check"] svg {
  color: var(--accent);
}

.feature-btn[data-feature="gap-check"]:hover {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  border-color: transparent;
}

.feature-btn[data-feature="gap-check"]:hover svg {
  color: white;
}

/* Dark mode adjustments */
.dark .feature-btn {
  background: rgba(17, 24, 39, 0.6);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.dark .feature-btn[data-feature="workpaper"] {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.2), rgba(6, 182, 212, 0.15));
}

.dark .feature-btn[data-feature="qc-check"] {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(34, 211, 238, 0.15));
}

.dark .feature-btn[data-feature="gap-check"] {
  background: linear-gradient(135deg, rgba(5, 150, 105, 0.2), rgba(6, 182, 212, 0.15));
}

/* Feature form container */
.feature-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin: var(--space-md) 0;
  animation: fadeInUp 0.3s var(--ease-out);
  max-width: 600px;
}

.dark .feature-form {
  background: rgba(17, 24, 39, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Feature form header */
.feature-form-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.feature-form-header svg {
  width: 32px;
  height: 32px;
  color: var(--accent);
  flex-shrink: 0;
}

.feature-form-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--fg);
  margin: 0;
}

.feature-form-header p {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: var(--space-xs) 0 0;
}

/* Form groups */
.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
  margin-bottom: var(--space-xs);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--fg);
  font-size: var(--text-sm);
  font-family: inherit;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

/* Custom select dropdown styling - muratov-io branding */
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 3rem;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  cursor: pointer;
}

.form-group select:hover {
  border-color: var(--accent);
}

.form-group select:focus {
  border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23059669' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

.dark .form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

.dark .form-group select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2310B981' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}

.form-group select option {
  background: var(--surface);
  color: var(--fg);
  padding: 0.875rem;
}

.form-group select optgroup {
  font-weight: 600;
  color: var(--accent);
  background: var(--surface);
}

/* ============================================
   DATE INPUT - YUSAGI BRANDED STYLING
   Overrides browser default date picker styling
   ============================================ */

/* Base date input styling */
.form-group input[type="date"] {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 3rem;
  cursor: pointer;
  color-scheme: light;
}

.dark .form-group input[type="date"] {
  color-scheme: dark;
}

/* Custom calendar icon (WebKit browsers) */
.form-group input[type="date"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  margin: 0;
  cursor: pointer;
  opacity: 0.6;
  filter: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  transition: opacity 150ms ease;
}

.dark .form-group input[type="date"]::-webkit-calendar-picker-indicator {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394A3B8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
}

.form-group input[type="date"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23059669' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
}

.form-group input[type="date"]:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23059669' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
}

/* Firefox date input */
.form-group input[type="date"]::-moz-focus-inner {
  border: 0;
}

/* Date input placeholder styling (when empty) */
.form-group input[type="date"]:not(:valid) {
  color: var(--muted);
}

/* Mobile date input - larger touch target */
@media (max-width: 640px) {
  .form-group input[type="date"] {
    min-height: 48px;
    font-size: 16px;
  }

  .form-group input[type="date"]::-webkit-calendar-picker-indicator {
    width: 1.5rem;
    height: 1.5rem;
    right: 0.875rem;
  }
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.dark .form-group input:focus,
.dark .form-group select:focus,
.dark .form-group textarea:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Form row for side-by-side fields */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   CUSTOM DROPDOWN - muratov-io style
   Button-based dropdown with custom options panel
   ============================================ */

.custom-dropdown {
  position: relative;
  width: 100%;
}

.dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 0.875rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--fg);
  font-size: var(--text-sm);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.dropdown-trigger:hover {
  border-color: var(--accent);
}

.dropdown-trigger:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.dark .dropdown-trigger:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.dropdown-trigger.open {
  border-color: var(--accent);
}

.dropdown-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.dropdown-arrow {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 200ms ease, color 200ms ease;
}

.dropdown-trigger:hover .dropdown-arrow,
.dropdown-trigger:focus .dropdown-arrow,
.dropdown-trigger.open .dropdown-arrow {
  color: var(--accent);
}

.dropdown-trigger.open .dropdown-arrow {
  transform: rotate(180deg);
}

/* Dropdown options panel */
.dropdown-options {
  position: absolute;
  z-index: 100;
  top: calc(100% + 0.5rem);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 200ms ease;
}

.dropdown-options.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Individual option */
.dropdown-option {
  padding: 0.875rem 1rem;
  font-size: var(--text-sm);
  color: var(--fg);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.dropdown-option:hover {
  background: var(--accent);
  color: white;
}

.dropdown-option.selected {
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 500;
}

.dropdown-option.selected:hover {
  background: var(--accent);
  color: white;
}

.dark .dropdown-option.selected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent);
}

.dark .dropdown-option.selected:hover {
  background: var(--accent);
  color: white;
}

/* Focused state for keyboard navigation */
.dropdown-option.focused {
  background: var(--accent-muted);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.dropdown-option.focused.selected {
  background: var(--accent);
  color: white;
}

/* Option group header (for grouped options) */
.dropdown-optgroup {
  padding: 0.75rem 1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

/* Scrollbar styling for dropdown */
.dropdown-options::-webkit-scrollbar {
  width: 6px;
}

.dropdown-options::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-options::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.dropdown-options::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Mobile-optimized dropdown styles */
@media (max-width: 640px) {
  .dropdown-trigger {
    min-height: 48px;
    padding: 0.875rem 1rem;
    font-size: 16px; /* Prevents iOS zoom */
  }

  .dropdown-options {
    max-height: 50vh;
    border-radius: var(--radius-lg);
  }

  .dropdown-option {
    min-height: 48px;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    font-size: 16px;
  }

  .dropdown-optgroup {
    padding: 0.875rem 1rem 0.625rem;
    font-size: 0.8125rem;
  }
}

/* Very small screens - full-width dropdown */
@media (max-width: 375px) {
  .dropdown-options {
    left: -0.5rem;
    right: -0.5rem;
    width: calc(100% + 1rem);
  }
}

/* Checkbox group */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  font-size: var(--text-sm);
}

.checkbox-item:hover {
  border-color: var(--accent);
}

.checkbox-item.checked {
  background: var(--accent-muted);
  border-color: var(--accent);
  color: var(--accent);
}

.dark .checkbox-item.checked {
  background: rgba(16, 185, 129, 0.15);
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Checkbox label (alternative style for stacked checkboxes) */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  min-height: 44px;
  width: 100%;
}

.checkbox-label:hover {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.checkbox-label span {
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* Checkbox group - stacked layout for forms */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

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

/* Form actions */
.form-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* Form hints */
.form-hint {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Feature icon variants */
.feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  flex-shrink: 0;
}

.feature-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.feature-icon.qc-icon {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-soft));
}

.feature-icon.gap-icon {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
}

/* ============================================
   SLIDE-IN PANEL SYSTEM (Oracle APEX Style)
   Modern right-to-left slide panel UX
   ============================================ */

/* Panel Overlay - backdrop */
.panel-overlay,
.feature-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  z-index: 100;
  transition: background 0.3s ease, backdrop-filter 0.3s ease;
}

.panel-overlay.active,
.feature-modal-overlay.active {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

/* Panel Container - slides from right */
.slide-panel,
.feature-modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  z-index: 101;
  border-radius: 0;
}

.slide-panel.open,
.feature-modal.open {
  transform: translateX(0);
}

.dark .slide-panel,
.dark .feature-modal {
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

/* Panel Header - sticky navigation bar */
.panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 64px;
}

.dark .panel-header {
  background: var(--bg);
}

/* Close button - left side */
.panel-close {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.panel-close:hover {
  background: var(--border);
  color: var(--fg);
  border-color: transparent;
}

.panel-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel-close svg {
  width: 20px;
  height: 20px;
}

/* Panel title section */
.panel-title-section {
  flex: 1;
  min-width: 0;
}

.panel-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: 2px;
}

.panel-breadcrumb svg {
  width: 12px;
  height: 12px;
  opacity: 0.5;
}

.panel-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--fg);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Panel icon badge */
.panel-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent-muted), var(--secondary-muted));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.panel-icon-badge svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

/* Panel Body - scrollable content */
.panel-body,
.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  overscroll-behavior: contain;
}

/* Smooth scroll shadow indicators */
.panel-body {
  background:
    linear-gradient(var(--surface) 30%, transparent),
    linear-gradient(transparent, var(--surface) 70%) 0 100%,
    radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.08), transparent),
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.08), transparent) 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
}

.dark .panel-body {
  background:
    linear-gradient(var(--bg) 30%, transparent),
    linear-gradient(transparent, var(--bg) 70%) 0 100%,
    radial-gradient(farthest-side at 50% 0, rgba(0,0,0,0.2), transparent),
    radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,0.2), transparent) 0 100%;
  background-repeat: no-repeat;
  background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;
  background-attachment: local, local, scroll, scroll;
}

/* Panel Footer - sticky action bar */
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  bottom: 0;
}

.dark .panel-footer {
  background: var(--bg);
}

/* Form inside panel */
.panel-body .feature-form,
.modal-content .feature-form {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  max-width: none;
}

/* Panel sizes */
.slide-panel.panel-sm,
.feature-modal.panel-sm {
  max-width: 400px;
}

.slide-panel.panel-lg,
.feature-modal.panel-lg {
  max-width: 760px;
}

.slide-panel.panel-xl,
.feature-modal.panel-xl {
  max-width: 900px;
}

/* Confirmation panel styles */
.slide-panel.confirm-panel {
  max-width: 420px;
}

.confirm-panel .panel-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
}

/* Success panel styles */
.slide-panel.success-panel {
  max-width: 440px;
}

.success-panel .panel-body {
  padding: var(--space-xl) var(--space-lg);
}

/* Icon badge in panel header */
.panel-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Legacy modal-close support (maps to panel-close) */
.modal-close {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
  position: static;
}

.modal-close:hover {
  background: var(--border);
  color: var(--fg);
  border-color: transparent;
}

/* Mobile Responsive - Full screen panel */
@media (max-width: 640px) {
  .slide-panel,
  .feature-modal {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
  }

  .panel-header {
    padding: var(--space-sm) var(--space-md);
    min-height: 56px;
  }

  .panel-title {
    font-size: var(--text-base);
  }

  .panel-body,
  .modal-content {
    padding: var(--space-md);
  }

  .panel-footer {
    padding: var(--space-sm) var(--space-md);
    padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
    flex-direction: column-reverse;
    gap: var(--space-xs);
  }

  .panel-footer .btn-primary,
  .panel-footer .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  /* Stack form actions on mobile */
  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .btn-primary,
  .form-actions .btn-secondary {
    width: 100%;
    justify-content: center;
    min-height: 48px;
  }

  /* Smaller feature form header on mobile */
  .feature-form-header {
    flex-direction: column;
    text-align: center;
  }

  .feature-form-header h3 {
    font-size: var(--text-base);
  }

  /* Full width form inputs on mobile */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Larger touch targets for checkboxes */
  .checkbox-label {
    padding: var(--space-md);
  }

  /* Mobile form inputs - prevent iOS zoom + better touch */
  .form-group input,
  .form-group textarea {
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
    min-height: 48px;
    padding: 0.75rem 1rem;
  }

  /* Feature icon smaller on mobile */
  .feature-icon {
    width: 40px;
    height: 40px;
  }

  .feature-icon svg {
    width: 20px;
    height: 20px;
  }
}

/* Tablet - optimize for audit tools */
@media (min-width: 641px) and (max-width: 1024px) {
  .slide-panel,
  .feature-modal {
    max-width: 520px;
  }

  .slide-panel.panel-lg,
  .feature-modal.panel-lg {
    max-width: 680px;
  }

  .slide-panel.panel-xl,
  .feature-modal.panel-xl {
    max-width: 800px;
  }
}

/* Desktop large screens - wider panels for productivity */
@media (min-width: 1280px) {
  .slide-panel,
  .feature-modal {
    max-width: 640px;
  }

  .slide-panel.panel-lg,
  .feature-modal.panel-lg {
    max-width: 880px;
  }

  .slide-panel.panel-xl,
  .feature-modal.panel-xl {
    max-width: 1100px;
  }
}

/* Panel slide-out animation for closing */
.slide-panel.closing,
.feature-modal.closing {
  transform: translateX(100%);
}

.panel-overlay.closing,
.feature-modal-overlay.closing {
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
}

/* Keyboard focus styles */
.slide-panel:focus-visible,
.feature-modal:focus-visible {
  outline: none;
}

/* Prevent body scroll when panel open */
body.panel-open {
  overflow: hidden;
}

.form-actions .btn-primary,
.form-actions .btn-secondary {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.form-actions .btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  border: none;
  font-weight: 600;
}

.form-actions .btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.form-actions .btn-primary:active {
  transform: translateY(0);
}

.form-actions .btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.form-actions .btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}

/* Required field indicator */
.required-indicator {
  color: var(--error);
  font-weight: 600;
}

/* Form error message */
.form-error {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-md);
  color: var(--error);
  font-size: var(--text-sm);
  margin-bottom: var(--space-md);
}

.dark .form-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.2);
}

/* ============================================
   FEATURE RESULTS - WORKPAPER/QC/GAP
   ============================================ */

.feature-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin: var(--space-md) 0;
  animation: fadeInUp 0.3s var(--ease-out);
}

.dark .feature-results {
  background: rgba(17, 24, 39, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}

.feature-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.feature-results-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.feature-results-title svg {
  width: 24px;
  height: 24px;
  color: var(--success);
}

.feature-results-title h4 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
}

/* Download actions */
.download-actions {
  display: flex;
  gap: var(--space-sm);
}

.download-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--fg);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.download-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}

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

.download-btn svg {
  width: 16px;
  height: 16px;
}

/* Primary download button - main action (CSV/Excel) */
.download-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  border: none;
  font-weight: 600;
  padding: var(--space-md) var(--space-lg);
}

.download-btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-soft), var(--secondary-soft));
  color: white;
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

/* Secondary download button - alternative action (JSON) */
.download-btn-secondary {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.download-btn-secondary:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  background: var(--secondary-muted);
}

/* Download actions container */
.download-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
  .download-actions {
    flex-direction: column;
  }

  .download-btn {
    justify-content: center;
    min-height: 44px;
  }
}

/* ============================================
   QC CHECK RESULTS
   ============================================ */

.qc-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

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

.qc-summary-item {
  text-align: center;
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.qc-summary-item .value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.qc-summary-item .label {
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.qc-summary-item.pass .value { color: var(--success); }
.qc-summary-item.warn .value { color: var(--warning); }
.qc-summary-item.fail .value { color: var(--error); }

/* QC Check list */
.qc-checks-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.qc-check-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg);
  border-left: 4px solid transparent;
}

.qc-check-item.pass {
  border-left-color: var(--success);
}

.qc-check-item.warning {
  border-left-color: var(--warning);
}

.qc-check-item.fail {
  border-left-color: var(--error);
}

.qc-check-status {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.qc-check-item.pass .qc-check-status {
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
}

.qc-check-item.warning .qc-check-status {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.qc-check-item.fail .qc-check-status {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

.qc-check-content {
  flex: 1;
}

.qc-check-id {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.qc-check-requirement {
  font-size: var(--text-sm);
  color: var(--fg);
  margin-bottom: var(--space-xs);
}

.qc-check-message {
  font-size: var(--text-xs);
  color: var(--muted);
}

/* ============================================
   GAP ANALYSIS RESULTS
   ============================================ */

.gap-coverage {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
}

.gap-coverage-score {
  position: relative;
  width: 80px;
  height: 80px;
}

.gap-coverage-score svg {
  transform: rotate(-90deg);
}

.gap-coverage-score circle {
  fill: none;
  stroke-width: 8;
}

.gap-coverage-score .bg {
  stroke: var(--border);
}

.gap-coverage-score .progress {
  stroke: var(--accent);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s var(--ease-out);
}

.gap-coverage-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.gap-coverage-details h5 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--space-xs);
}

.gap-coverage-details p {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0;
}

/* Gap items list */
.gap-items-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.gap-item {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg);
  border-left: 4px solid transparent;
}

.gap-item.critical {
  border-left-color: var(--error);
  background: rgba(220, 38, 38, 0.05);
}

.gap-item.important {
  border-left-color: var(--warning);
  background: rgba(217, 119, 6, 0.05);
}

.gap-item.minor {
  border-left-color: var(--accent);
  background: rgba(5, 150, 105, 0.05);
}

.dark .gap-item.critical { background: rgba(248, 113, 113, 0.1); }
.dark .gap-item.important { background: rgba(251, 191, 36, 0.1); }
.dark .gap-item.minor { background: rgba(16, 185, 129, 0.1); }

.gap-item-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.gap-item-priority {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

.gap-item.critical .gap-item-priority {
  background: rgba(220, 38, 38, 0.1);
  color: var(--error);
}

.gap-item.important .gap-item-priority {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.gap-item.minor .gap-item-priority {
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent);
}

.gap-item-citation {
  font-size: var(--text-xs);
  color: var(--muted);
}

.gap-item-description {
  font-size: var(--text-sm);
  color: var(--fg);
  margin-bottom: var(--space-sm);
}

.gap-item-recommendation {
  font-size: var(--text-sm);
  color: var(--accent);
  padding: var(--space-sm);
  background: var(--accent-muted);
  border-radius: var(--radius-sm);
}

.dark .gap-item-recommendation {
  background: rgba(16, 185, 129, 0.1);
}

/* ============================================
   WORKPAPER PREVIEW
   ============================================ */

.workpaper-preview {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-height: 400px;
  overflow-y: auto;
}

.workpaper-section {
  margin-bottom: var(--space-lg);
}

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

.workpaper-section h5 {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.workpaper-field {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

.workpaper-field:last-child {
  border-bottom: none;
}

.workpaper-field .field-label {
  font-weight: 500;
  color: var(--muted);
  min-width: 120px;
}

.workpaper-field .field-value {
  color: var(--fg);
}

/* Procedure table in workpaper */
.procedure-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.procedure-table th {
  text-align: left;
  padding: var(--space-sm);
  background: var(--surface-elevated);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--fg);
}

.procedure-table td {
  padding: var(--space-sm);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.procedure-table tr:last-child td {
  border-bottom: none;
}

.procedure-table .proc-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
}

.procedure-table .proc-status {
  display: inline-flex;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
}

.procedure-table .proc-status.not-started {
  background: rgba(107, 114, 128, 0.1);
  color: var(--muted);
}

.procedure-table .proc-status.in-progress {
  background: rgba(217, 119, 6, 0.1);
  color: var(--warning);
}

.procedure-table .proc-status.complete {
  background: rgba(5, 150, 105, 0.1);
  color: var(--success);
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.feature-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  gap: var(--space-md);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.feature-loading p {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ============================================
   MOBILE RESPONSIVENESS FOR FEATURES
   ============================================ */

@media (max-width: 640px) {
  .feature-buttons {
    flex-direction: column;
    gap: var(--space-xs);
  }

  .feature-btn {
    width: 100%;
    justify-content: center;
  }

  .feature-form,
  .feature-results {
    padding: var(--space-md);
    margin: var(--space-sm) 0;
  }

  .feature-form-header {
    flex-direction: column;
    text-align: center;
  }

  .feature-results-header {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }

  .download-actions {
    width: 100%;
    justify-content: center;
  }

  .form-actions {
    flex-direction: column;
  }

  .qc-summary {
    grid-template-columns: 1fr 1fr;
  }

  .gap-coverage {
    flex-direction: column;
    text-align: center;
  }

  .workpaper-preview {
    padding: var(--space-md);
    max-height: 300px;
  }

  .procedure-table {
    font-size: var(--text-xs);
  }

  .procedure-table th,
  .procedure-table td {
    padding: var(--space-xs);
  }
}

/* ============================================
   UX FIX: Enhanced Toast Notification System
   ============================================ */
.toast-notification {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  min-width: 320px;
  max-width: 420px;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transform: translateX(120%);
  transition: transform var(--duration-normal) var(--ease-spring);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast-notification.show {
  transform: translateX(0);
}

.toast-notification.success {
  border-left: 4px solid var(--success);
}

.toast-notification.error {
  border-left: 4px solid var(--error);
}

.toast-notification.warning {
  border-left: 4px solid #f59e0b;
}

.toast-notification.info {
  border-left: 4px solid var(--accent);
}

.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-notification.success .toast-icon { color: var(--success); }
.toast-notification.error .toast-icon { color: var(--error); }
.toast-notification.warning .toast-icon { color: #f59e0b; }
.toast-notification.info .toast-icon { color: var(--accent); }

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--muted);
  transition: color var(--duration-fast) var(--ease-out);
  margin-left: auto;
}

.toast-close:hover {
  color: var(--fg);
}

@media (max-width: 640px) {
  .toast-notification {
    right: 1rem;
    left: 1rem;
    min-width: auto;
    max-width: none;
  }
}

/* ============================================
   UX FIX: Button Loading Animation
   ============================================ */
button.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

button.loading::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

button.loading.btn-secondary::after {
  border-color: rgba(var(--accent-rgb), 0.3);
  border-top-color: var(--accent);
}

@keyframes btn-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   UX FIX: Form Validation States
   ============================================ */
input.border-red-500,
textarea.border-red-500,
select.border-red-500 {
  border-color: var(--error) !important;
}

input.border-green-500,
textarea.border-green-500,
select.border-green-500 {
  border-color: var(--success) !important;
}

input.error,
textarea.error,
.dropdown-trigger.error {
  border-color: var(--error) !important;
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Error summary for forms */
.error-summary {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius-xl);
  padding: 1rem;
  margin-bottom: 1rem;
}

.dark .error-summary {
  background: rgba(127, 29, 29, 0.2);
  border-color: #991B1B;
}

/* ============================================
   UX FIX: Placeholder Contrast (WCAG Compliance)
   ============================================ */
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

.dark input::placeholder,
.dark textarea::placeholder {
  opacity: 0.85;
}

/* ============================================
   UX FIX: Focus-visible Skip Link (Accessibility)
   ============================================ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus-visible {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: auto;
  height: auto;
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  z-index: 9999;
  outline: none;
  box-shadow: var(--shadow-lg);
}

/* ============================================
   UX FIX: Subtle Pulse Animation for Badges
   ============================================ */
@keyframes pulse-subtle {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.98);
  }
}

.animate-pulse-subtle {
  animation: pulse-subtle 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================
   UX FIX: Session Expiry Banner Animation
   ============================================ */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translate(-50%, -10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.animate-fade-in {
  animation: fade-in 0.3s ease-out forwards;
}

/* ============================================
   UX FIX: Modal Focus Trap Improvements
   ============================================ */
.feature-modal-overlay:focus-visible {
  outline: none;
}

.feature-modal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Modal shake animation for when user tries to close during submit */
.feature-modal.shake {
  animation: modalShake 0.3s ease-in-out;
}

@keyframes modalShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* ============================================
   UX FIX: Progress Bar for Long Operations
   ============================================ */
.qc-progress-overlay {
  position: absolute;
  inset: 0;
  background: rgba(var(--bg-rgb, 255, 255, 255), 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
  z-index: 10;
}

.dark .qc-progress-overlay {
  background: rgba(17, 24, 39, 0.95);
}

.qc-progress-content {
  text-align: center;
  padding: 2rem;
}

.qc-progress-content h3 {
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}

.qc-progress-content .progress-step {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: 1rem;
}

.qc-progress-content .progress-bar {
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 0 auto;
}

.qc-progress-content .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--secondary));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.spinner-large {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: btn-spin 0.8s linear infinite;
  margin: 0 auto;
}

/* ============================================
   UX FIX: Character Counter Accessibility
   ============================================ */
.char-count {
  font-size: var(--text-xs);
  color: var(--muted);
  text-align: right;
  margin-top: 0.25rem;
}

.char-count.warning {
  color: #f59e0b;
  font-weight: 500;
}

.char-count.error {
  color: var(--error);
  font-weight: 600;
}

/* ============================================
   UX FIX: Safe Area Insets for Notched Devices
   ============================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .chat-input-container {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }

  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .sticky-cta {
    bottom: calc(1.5rem + env(safe-area-inset-bottom));
  }
}

/* ============================================
   UX FIX: Rate Limit Countdown Display
   ============================================ */
.rate-limit-countdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-lg);
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: 0.5rem;
}

.rate-limit-countdown .countdown-timer {
  font-weight: 600;
  font-family: var(--font-mono);
}

.rate-limit-progress {
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.5rem;
}

.rate-limit-progress-bar {
  height: 100%;
  background: var(--error);
  transition: width 1s linear;
}

/* ============================================
   UX FIX: Enhanced Drag-Drop Zone
   ============================================ */
.chat-input-wrapper {
  position: relative;
}

.chat-input-wrapper.drag-over::before {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-xl);
  background: var(--accent-muted);
  opacity: 0.5;
  pointer-events: none;
  z-index: 5;
}

.chat-input-wrapper.drag-over::after {
  content: 'Drop file to attach';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.75rem 1.5rem;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: var(--text-sm);
  z-index: 10;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

/* ============================================
   UX FIX: Loading Skeleton for Dropdowns
   ============================================ */
.loading-skeleton {
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}

.loading-skeleton::before {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* ============================================
   UX FIX: Larger QC Textarea
   ============================================ */
#qc-content {
  min-height: 300px;
  resize: vertical;
}

@media (min-width: 768px) {
  #qc-content {
    min-height: 400px;
  }
}

/* ============================================
   UX FIX: Dropdown Search Input
   ============================================ */
.dropdown-search {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-size: var(--text-sm);
  outline: none;
}

.dropdown-search:focus {
  border-bottom-color: var(--accent);
}

.dropdown-search::placeholder {
  color: var(--muted);
}

/* ============================================
   UX FIX: Grouped Dropdown Options
   ============================================ */
.dropdown-group-label {
  padding: 0.5rem 1rem;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ============================================
   UX FIX: Mobile Tools Dropdown Positioning
   ============================================ */
@media (max-width: 640px) {
  .tools-dropdown {
    position: fixed;
    bottom: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: calc(100vw - 2rem);
    max-width: 320px;
    opacity: 0;
    visibility: hidden;
  }

  .tools-dropdown.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
  }
}

/* ============================================
   UX FIX: Scroll Progress Bar Thicker
   ============================================ */
#scrollProgress {
  height: 3px;
}

/* ============================================
   UX FIX: Badge Pulse Less Intense
   ============================================ */
.badge-pulse {
  animation: pulse-subtle 3s ease-in-out infinite;
}

/* ============================================
   UX FIX: Trust Indicators Responsive
   ============================================ */
.trust-indicators {
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .trust-indicators {
    gap: 2.5rem;
  }
}

/* ============================================
   UX FIX: CTA Border Emphasis
   ============================================ */
.cta-card {
  border-width: 2px;
  border-color: rgba(var(--accent-rgb), 0.3);
  transition: border-color 0.3s ease;
}

.cta-card:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
}

/* ============================================
   UX FIX: Download Button Progress State
   ============================================ */
.download-btn.downloading {
  position: relative;
  pointer-events: none;
}

.download-btn.downloading::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  animation: download-progress 2s ease-in-out;
}

@keyframes download-progress {
  0% { width: 0; }
  90% { width: 90%; }
  100% { width: 100%; }
}

/* ============================================
   UX FIX: Export Actions Buttons
   ============================================ */
.export-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.export-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.export-btn svg {
  width: 1rem;
  height: 1rem;
}

/* ============================================
   UX FIX: Modal Scroll Indicator Shadows
   ============================================ */
.modal-content {
  position: relative;
}

.modal-content.scrollable::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to bottom, var(--surface), transparent);
  pointer-events: none;
  z-index: 1;
}

.modal-content.scrollable::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20px;
  background: linear-gradient(to top, var(--surface), transparent);
  pointer-events: none;
  z-index: 1;
}

/* ============================================
   LOW PRIORITY UX FIXES - FINAL POLISH
   ============================================ */

/* Welcome logo entrance animation */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.welcome-logo {
  animation: fadeInScale 0.6s var(--ease-out);
}

/* Welcome logo tablet scaling */
@media (min-width: 768px) {
  .welcome-logo {
    width: 64px;
    height: 64px;
  }
  .welcome-title {
    font-size: 1.75rem;
  }
}

/* Textarea height transition for smooth resize */
.chat-form textarea {
  transition: height 150ms ease;
}

/* Badge pulse subtle animation (less intense than default) */
@keyframes pulse-subtle {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(0.98);
  }
}

.badge-pulse {
  animation: pulse-subtle 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Tools button icon rotation when open */
.tools-btn svg {
  transition: transform 150ms ease;
}

.tools-btn[aria-expanded="true"] svg {
  transform: rotate(45deg);
}

/* Tools dropdown mobile centered positioning */
@media (max-width: 640px) {
  .tools-dropdown.open {
    position: fixed;
    bottom: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100vw - 2rem);
    max-width: 320px;
    z-index: 60;
  }
}

/* File preview mobile responsiveness */
@media (max-width: 375px) {
  .file-preview {
    padding: 0 0.5rem;
  }

  .file-preview-content {
    padding: 0.5rem 0.625rem;
  }

  .file-name {
    font-size: 0.8125rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Suggestion chips mobile stacking */
@media (max-width: 360px) {
  .suggestion-chip {
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
    width: 100%;
    justify-content: center;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .suggestion-chips {
    flex-direction: column;
    width: 100%;
  }
}

/* Feature buttons grid optimization */
@media (max-width: 400px) {
  .feature-buttons-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 401px) and (max-width: 640px) {
  .feature-buttons-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Message footer touch optimization - always visible on touch devices */
@media (hover: none) {
  .message-footer {
    opacity: 1;
  }

  .message-timestamp {
    opacity: 0.6;
  }
}

/* Message bubble tablet width optimization */
@media (min-width: 768px) and (max-width: 1024px) {
  .message {
    max-width: 80%;
  }
}

/* Code block copy button animation */
.code-copy-btn.copied {
  transform: scale(1.1);
  transition: transform 150ms var(--ease-spring);
}

/* Typing indicator dots staggered animation */
.thinking-dots {
  display: inline-flex;
  gap: 2px;
}

.thinking-dots span {
  animation: dotPulse 1.4s ease-in-out infinite;
}

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

.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotPulse {
  0%, 60%, 100% {
    opacity: 1;
    transform: translateY(0);
  }
  30% {
    opacity: 0.4;
    transform: translateY(-4px);
  }
}

/* Scroll-to-bottom button hide when keyboard visible (small viewport height) */
@media (max-height: 500px) {
  .scroll-to-bottom-btn {
    display: none;
  }
}

/* Loading skeleton for dropdowns */
.loading-skeleton {
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: var(--text-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Dropdown search input styling */
.dropdown-search {
  width: calc(100% - 1rem);
  margin: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  font-size: var(--text-sm);
  color: var(--fg);
}

.dropdown-search:focus {
  outline: none;
  border-color: var(--accent);
}

/* File preview close animation */
.file-preview {
  transition: opacity 150ms ease, transform 150ms ease;
}

/* QC textarea larger default size */
#qc-content {
  min-height: 300px;
  resize: vertical;
}

@media (min-width: 768px) {
  #qc-content {
    min-height: 400px;
  }
}

/* Character counter warning colors with non-color indicator */
.char-count.warning {
  font-weight: 600;
}

.char-count.error {
  font-weight: 700;
}
