/* Ultra-Modern AI Neural Interface 2025 - Futuristic Design System */
:root {
  /* Neural AI Color Palette */
  --neural-void: #000000;
  --neural-dark: #0a0a0f;
  --neural-surface: #151520;
  --neural-glass: rgba(20, 20, 35, 0.3);
  --neural-border: rgba(100, 255, 255, 0.15);
  --neural-glow: rgba(0, 255, 255, 0.4);
  --neural-primary: #00ffff;
  --neural-secondary: #ff00ff;
  --neural-accent: #ffff00;
  --neural-text: #ffffff;
  --neural-text-dim: #8a8aa8;
  --neural-success: #00ff88;
  --neural-warning: #ff8800;
  --neural-error: #ff0066;
  
  /* Advanced Effects */
  --neural-blur: blur(24px);
  --neural-saturate: saturate(200%);
  --neural-shadow: 0 25px 80px rgba(0, 255, 255, 0.2);
  --neural-glow-shadow: 0 0 50px rgba(0, 255, 255, 0.3);
  
  /* Animation Timings */
  --neural-transition: cubic-bezier(0.23, 1, 0.32, 1);
  --neural-fast: 0.15s;
  --neural-medium: 0.3s;
  --neural-slow: 0.6s;
}

/* Light neural theme */
body.ef-chat[data-theme="light"] {
  --neural-void: #f8f9ff;
  --neural-dark: #f0f1f8;
  --neural-surface: #e8eaf5;
  --neural-glass: rgba(240, 245, 255, 0.4);
  --neural-border: rgba(0, 100, 255, 0.2);
  --neural-glow: rgba(0, 100, 255, 0.3);
  --neural-primary: #0066ff;
  --neural-text: #1a1a2e;
  --neural-text-dim: #6a6a8a;
}

* { 
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.ef-chat {
  margin: 0;
  padding: 0;
  background: var(--neural-void);
  color: var(--neural-text);
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, Inter, system-ui, sans-serif;
  font-weight: 400;
  height: 100vh;
  overflow: hidden;
  position: relative;
  cursor: default;
}
.ef-main.ef-immersive {
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* === Neural 3D Environment === */
.robot-environment {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  background: 
    radial-gradient(circle at center, var(--neural-dark), var(--neural-void)),
    linear-gradient(45deg, transparent 49%, rgba(255, 255, 255, 0.02) 50%, transparent 51%),
    linear-gradient(-45deg, transparent 49%, rgba(255, 255, 255, 0.02) 50%, transparent 51%);
  background-size: 100% 100%, 40px 40px, 40px 40px;
  background-position: center, 0 0, 20px 20px;
}

/* Modern geometric mesh background */
.robot-environment::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    /* Primary grid */
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    /* Secondary grid */
    linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    /* Diagonal lines */
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 35px,
      rgba(255, 255, 255, 0.008) 36px,
      rgba(255, 255, 255, 0.008) 37px,
      transparent 38px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 35px,
      rgba(255, 255, 255, 0.008) 36px,
      rgba(255, 255, 255, 0.008) 37px,
      transparent 38px
    );
  background-size: 
    60px 60px,
    60px 60px,
    20px 20px,
    20px 20px,
    100px 100px,
    100px 100px;
  background-position: 
    0 0,
    0 0,
    0 0,
    0 0,
    0 0,
    50px 50px;
  pointer-events: none;
  animation: mesh-drift 60s linear infinite;
}

/* Animated geometric patterns */
.robot-environment::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    /* Hexagonal pattern */
    radial-gradient(circle at 50% 50%, transparent 8px, rgba(255, 255, 255, 0.015) 9px, rgba(255, 255, 255, 0.015) 10px, transparent 11px),
    /* Triangle pattern */
    conic-gradient(from 0deg at 50% 50%, 
      transparent 0deg, 
      rgba(255, 255, 255, 0.01) 60deg,
      transparent 120deg,
      rgba(255, 255, 255, 0.01) 180deg,
      transparent 240deg,
      rgba(255, 255, 255, 0.01) 300deg,
      transparent 360deg
    );
  background-size: 
    80px 80px,
    120px 120px;
  background-position: 
    0 0,
    60px 60px;
  pointer-events: none;
  animation: mesh-pulse 45s ease-in-out infinite;
}

@keyframes mesh-drift {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-20px, -10px) rotate(0.5deg); }
  50% { transform: translate(-10px, -20px) rotate(0deg); }
  75% { transform: translate(10px, -10px) rotate(-0.5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes mesh-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1) rotate(0deg); }
  33% { opacity: 0.8; transform: scale(1.02) rotate(1deg); }
  66% { opacity: 0.4; transform: scale(0.98) rotate(-1deg); }
}

/* Circuit board style enhancements */
.robot-background {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  position: relative;
  z-index: 10; /* Above mesh but below interface */
}

/* Additional geometric mesh overlays */
.robot-environment .circuit-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    /* Circuit traces */
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 99px,
      rgba(255, 255, 255, 0.01) 100px,
      rgba(255, 255, 255, 0.01) 102px,
      transparent 103px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 99px,
      rgba(255, 255, 255, 0.01) 100px,
      rgba(255, 255, 255, 0.01) 102px,
      transparent 103px
    ),
    /* Node points */
    radial-gradient(circle at 100px 100px, rgba(255, 255, 255, 0.02) 2px, transparent 3px),
    radial-gradient(circle at 50px 50px, rgba(0, 255, 255, 0.03) 1px, transparent 2px);
  background-size: 
    100px 100px,
    100px 100px,
    100px 100px,
    50px 50px;
  background-position: 
    0 0,
    0 0,
    0 0,
    25px 25px;
  pointer-events: none;
  animation: circuit-flow 30s linear infinite;
  z-index: 5;
}

@keyframes circuit-flow {
  0% { transform: translate(0, 0); opacity: 0.7; }
  25% { transform: translate(-2px, -2px); opacity: 0.9; }
  50% { transform: translate(0, -4px); opacity: 0.8; }
  75% { transform: translate(2px, -2px); opacity: 0.9; }
  100% { transform: translate(0, 0); opacity: 0.7; }
}

.ambient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    /* Mesh accent colors */
    radial-gradient(circle at 20% 20%, rgba(0, 255, 255, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 0, 255, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 60% 40%, rgba(255, 255, 0, 0.04) 0%, transparent 50%),
    /* Grid intersections highlights */
    repeating-conic-gradient(
      from 0deg at 25% 25%,
      transparent 0deg,
      rgba(0, 255, 255, 0.02) 45deg,
      transparent 90deg,
      rgba(255, 0, 255, 0.02) 135deg,
      transparent 180deg,
      rgba(255, 255, 0, 0.02) 225deg,
      transparent 270deg,
      rgba(0, 255, 255, 0.02) 315deg,
      transparent 360deg
    );
  background-size: 
    300px 300px,
    350px 350px,
    280px 280px,
    200px 200px;
  background-position:
    0% 0%,
    100% 100%,
    50% 30%,
    75% 25%;
  pointer-events: none;
  mix-blend-mode: screen;
  animation: neural-ambient 25s ease-in-out infinite;
}

/* Additional mesh overlay for depth */
.robot-environment .mesh-depth {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    /* Isometric grid pattern */
    repeating-linear-gradient(
      30deg,
      transparent,
      transparent 29px,
      rgba(255, 255, 255, 0.005) 30px,
      rgba(255, 255, 255, 0.005) 31px,
      transparent 32px
    ),
    repeating-linear-gradient(
      150deg,
      transparent,
      transparent 29px,
      rgba(255, 255, 255, 0.005) 30px,
      rgba(255, 255, 255, 0.005) 31px,
      transparent 32px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 19px,
      rgba(255, 255, 255, 0.008) 20px,
      rgba(255, 255, 255, 0.008) 21px,
      transparent 22px
    );
  pointer-events: none;
  animation: mesh-depth-shift 40s linear infinite;
}

@keyframes mesh-depth-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(10px, -5px); }
  50% { transform: translate(5px, 10px); }
  75% { transform: translate(-5px, 5px); }
  100% { transform: translate(0, 0); }
}

@keyframes neural-ambient {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* === Ultra-Modern AI Interface === */
.ai-interface {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  max-height: min(85vh, 700px);
  display: flex;
  flex-direction: column;
  background: var(--neural-glass);
  backdrop-filter: var(--neural-blur) var(--neural-saturate);
  border: 1px solid var(--neural-border);
  border-radius: 28px;
  box-shadow: var(--neural-shadow);
  z-index: 100;
  overflow: hidden;
  animation: neural-interface-enter 0.8s var(--neural-transition);
  margin: 20px;
  min-height: 500px;
}

@keyframes neural-interface-enter {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95) rotateX(5deg);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotateX(0deg);
    filter: blur(0px);
  }
}

/* === Neural Header === */
.neural-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px 28px;
  background: var(--neural-surface);
  border-bottom: 1px solid var(--neural-border);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.neural-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    var(--neural-primary) 20%, 
    var(--neural-secondary) 50%, 
    var(--neural-accent) 80%, 
    transparent 100%);
  animation: neural-scan 3s ease-in-out infinite;
}

@keyframes neural-scan {
  0%, 100% { transform: translateX(-100%); opacity: 0; }
  50% { transform: translateX(100%); opacity: 1; }
}

.ai-status-indicator {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-core {
  width: 8px;
  height: 8px;
  background: var(--neural-primary);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--neural-glow);
  animation: neural-pulse 2s ease-in-out infinite;
}

.neural-rings {
  position: absolute;
  width: 100%;
  height: 100%;
}

.ring {
  position: absolute;
  border: 1px solid var(--neural-primary);
  border-radius: 50%;
  opacity: 0;
  animation: neural-ring 3s ease-out infinite;
}

.ring-1 {
  width: 100%;
  height: 100%;
  animation-delay: 0s;
}

.ring-2 {
  width: 80%;
  height: 80%;
  top: 10%;
  left: 10%;
  animation-delay: 0.5s;
}

.ring-3 {
  width: 60%;
  height: 60%;
  top: 20%;
  left: 20%;
  animation-delay: 1s;
}

@keyframes neural-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

@keyframes neural-ring {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 0; }
}

.ai-identity {
  flex: 1;
}

.ai-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--neural-text);
  letter-spacing: -0.02em;
}

.ai-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--neural-text-dim);
}

.typing-indicator {
  color: var(--neural-success);
  animation: neural-blink 1.5s ease-in-out infinite;
}

@keyframes neural-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

.interface-controls {
  display: flex;
  gap: 8px;
}

.neural-btn {
  width: 32px;
  height: 32px;
  background: var(--neural-glass);
  border: 1px solid var(--neural-border);
  border-radius: 8px;
  color: var(--neural-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--neural-fast) var(--neural-transition);
}

.neural-btn:hover {
  background: var(--neural-surface);
  color: var(--neural-text);
  transform: translateY(-1px);
}

/* === Neural Stream === */
.neural-stream {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--neural-glass);
  min-height: 0; /* Allow proper flex shrinking */
}

.neural-stream::-webkit-scrollbar {
  width: 6px;
}

.neural-stream::-webkit-scrollbar-track {
  background: transparent;
}

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

/* === Neural Input === */
.neural-input {
  padding: 24px 28px;
  background: var(--neural-surface);
  border-top: 1px solid var(--neural-border);
  flex-shrink: 0;
}

.input-neural-container {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.input-field-wrapper {
  flex: 1;
  position: relative;
}

.neural-text-input {
  width: 100%;
  padding: 16px 18px;
  background: var(--neural-glass);
  border: 1px solid var(--neural-border);
  border-radius: 14px;
  color: var(--neural-text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: all var(--neural-medium) var(--neural-transition);
  backdrop-filter: var(--neural-blur);
  resize: none;
  min-height: 20px;
}

.neural-text-input::placeholder {
  color: var(--neural-text-dim);
}

.neural-text-input:focus {
  border-color: var(--neural-primary);
  box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.2);
}

.input-neural-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 14px;
  background: linear-gradient(45deg, var(--neural-primary), var(--neural-secondary));
  opacity: 0;
  filter: blur(20px);
  transition: opacity var(--neural-medium);
  pointer-events: none;
}

.neural-text-input:focus + .input-neural-glow {
  opacity: 0.1;
}

.input-actions {
  display: flex;
  gap: 8px;
}

.neural-action-btn, .neural-send-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--neural-fast) var(--neural-transition);
  cursor: pointer;
  flex-shrink: 0;
}

.neural-action-btn {
  background: var(--neural-glass);
  border: 1px solid var(--neural-border);
  color: var(--neural-text-dim);
}

.neural-action-btn:hover {
  background: var(--neural-surface);
  color: var(--neural-text);
  transform: translateY(-2px);
}

.neural-send-btn {
  background: linear-gradient(135deg, var(--neural-primary), var(--neural-secondary));
  border: none;
  color: var(--neural-void);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 255, 255, 0.3);
}

.neural-send-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 30px rgba(0, 255, 255, 0.4);
}

.neural-send-btn:active {
  transform: translateY(0px) scale(0.98);
}

.send-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: all 0.6s;
}

/* === Neural Messages === */
.ai-message, .user-message {
  display: flex;
  gap: 14px;
  margin-bottom: 0; /* Remove bottom margin since we use gap in container */
  opacity: 0;
  animation: neural-message-enter 0.6s var(--neural-transition) forwards;
  align-items: flex-start;
}

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

@keyframes neural-message-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Different animation for user messages */
.user-message {
  animation: user-message-enter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes user-message-enter {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
  margin-top: 2px; /* Align with text baseline */
}

.ai-message .message-avatar {
  background: linear-gradient(135deg, var(--neural-primary), var(--neural-secondary));
  color: var(--neural-void);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
  animation: neural-ai-glow 3s ease-in-out infinite;
}

@keyframes neural-ai-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5), 0 0 40px rgba(255, 0, 255, 0.2);
  }
}

.user-message .message-avatar {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #ffffff;
  border: 2px solid rgba(102, 126, 234, 0.3);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.message-content {
  flex: 1;
  background: var(--neural-glass);
  backdrop-filter: var(--neural-blur);
  border: 1px solid var(--neural-border);
  border-radius: 18px;
  padding: 16px 20px;
  font-size: 15px;
  line-height: 1.6;
  position: relative;
  overflow: hidden;
  word-wrap: break-word;
  min-width: 0; /* Prevent flex overflow */
}

.ai-message .message-content {
  border-color: rgba(0, 255, 255, 0.25);
  background: linear-gradient(135deg, rgba(0, 255, 255, 0.08), rgba(0, 200, 255, 0.05));
  box-shadow: 0 4px 20px rgba(0, 255, 255, 0.1);
}

.user-message .message-content {
  border-color: rgba(102, 126, 234, 0.35);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.1));
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
  font-weight: 500;
}

.message-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neural-primary), transparent);
  opacity: 0.3;
}

/* AI message specific enhancements */
.ai-message .message-content::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.3), transparent);
  opacity: 0.5;
}

/* User message badge */
.user-message .message-avatar::after {
  content: '✓';
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--neural-void);
  font-weight: bold;
}

/* === Neural Loading States === */
.robot-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--neural-text);
  z-index: 10;
}

.loading-robot {
  font-size: 48px;
  animation: neural-loading-pulse 2s ease-in-out infinite;
}

.loading-text {
  margin: 16px 0 8px 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--neural-text-dim);
}

.loading-progress {
  width: 120px;
  height: 2px;
  background: var(--neural-surface);
  border-radius: 1px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-progress::after {
  content: '';
  display: block;
  width: 40px;
  height: 100%;
  background: linear-gradient(90deg, var(--neural-primary), var(--neural-secondary));
  border-radius: 1px;
  animation: neural-loading-bar 1.5s ease-in-out infinite;
}

@keyframes neural-loading-pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.1); opacity: 1; }
}

@keyframes neural-loading-bar {
  0% { transform: translateX(-120px); }
  100% { transform: translateX(200px); }
}

.robot-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--neural-error);
  z-index: 10;
}

.error-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.error-text {
  font-size: 14px;
  font-weight: 500;
}

/* === Neural Typing Indicator === */
.neural-typing {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  opacity: 0;
  animation: neural-message-enter 0.4s var(--neural-transition) forwards;
}

.neural-typing .message-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
}

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

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--neural-primary);
  border-radius: 50%;
  animation: neural-typing-dot 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes neural-typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-10px); opacity: 1; }
}

/* === Responsive Neural Design === */
@media (max-width: 768px) {
  /* Optimize mesh for mobile performance */
  .robot-environment::before {
    background-size: 
      40px 40px,
      40px 40px,
      15px 15px,
      15px 15px,
      80px 80px,
      80px 80px;
  }
  
  .robot-environment::after {
    background-size: 
      60px 60px,
      80px 80px;
  }
  
  .mesh-depth {
    opacity: 0.8; /* Reduce complexity on mobile */
  }
  
  .circuit-overlay {
    background-size: 
      80px 80px,
      80px 80px,
      80px 80px,
      40px 40px;
  }
  
  .ai-interface {
    width: 96vw;
    max-height: 90vh;
    border-radius: 24px;
    margin: 10px;
    min-height: 450px;
  }
  
  .neural-header {
    padding: 20px 24px;
  }
  
  .ai-title {
    font-size: 17px;
  }
  
  .ai-subtitle {
    font-size: 12px;
  }
  
  .neural-stream {
    padding: 20px 24px;
    gap: 18px;
  }
  
  .neural-input {
    padding: 20px 24px;
  }
  
  .neural-text-input {
    padding: 14px 16px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  .message-content {
    padding: 14px 18px;
    font-size: 14px;
  }
  
  .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .neural-action-btn, .neural-send-btn {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 480px) {
  /* Further optimize mesh for small screens */
  .robot-environment::before,
  .robot-environment::after {
    animation-duration: 120s; /* Slower animations to save battery */
  }
  
  .mesh-depth {
    opacity: 0.6;
    background-size: 40px 40px, 40px 40px, 30px 30px;
  }
  
  .circuit-overlay {
    opacity: 0.7;
    background-size: 60px 60px, 60px 60px, 60px 60px, 30px 30px;
  }
  
  .ai-interface {
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
    margin: 0;
  }
  
  .neural-header {
    padding: 18px 20px;
    border-radius: 0;
  }
  
  .neural-stream {
    padding: 18px 20px;
  }
  
  .neural-input {
    padding: 18px 20px;
  }
  
  .input-neural-container {
    gap: 10px;
  }
  
  .input-actions {
    gap: 8px;
  }
  
  .neural-action-btn, .neural-send-btn {
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 320px) {
  .ai-interface {
    min-height: 100vh;
  }
  
  .neural-header {
    padding: 16px 18px;
  }
  
  .neural-stream {
    padding: 16px 18px;
  }
  
  .neural-input {
    padding: 16px 18px;
  }
  
  .ai-title {
    font-size: 16px;
  }
  
  .message-content {
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* === Accessibility & Motion === */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: high) {
  :root {
    --neural-border: rgba(255, 255, 255, 0.4);
    --neural-text-dim: rgba(255, 255, 255, 0.8);
  }
}

/* === Neural Particle Effects === */
.ai-interface::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 10% 20%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(255, 0, 255, 0.08) 0%, transparent 50%);
  opacity: 0.6;
  pointer-events: none;
  animation: neural-particles 15s ease-in-out infinite;
}

@keyframes neural-particles {
  0%, 100% { transform: rotate(0deg) scale(1); }
  33% { transform: rotate(120deg) scale(1.1); }
  66% { transform: rotate(240deg) scale(0.9); }
}

/* Remove old styles completely */
.chat-glass-card,
.glass-header,
.bot-avatar-glass,
.titles-glass,
.glass-controls,
.chat-stream-glass,
.chat-input-glass,
.input-container-glass,
.btn-glass {
  display: none !important;
}
.robot-environment {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  background: radial-gradient(circle at 50% 50%, rgba(0, 122, 255, 0.1), transparent 70%);
}

.robot-background {
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0;
  left: 0;
}

.robot-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-secondary);
}

.loading-robot {
  font-size: 80px;
  margin-bottom: 20px;
  animation: pulse 2s ease-in-out infinite;
}

.loading-text {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 15px;
}

.loading-progress {
  width: 200px;
  height: 2px;
  background: var(--glass-border);
  border-radius: 1px;
  overflow: hidden;
}

.loading-progress::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: var(--brand);
  animation: loading 2s ease-in-out infinite;
  transform: translateX(-100%);
}

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

@keyframes loading {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.robot-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #ff3b30;
}

.error-icon {
  font-size: 60px;
  margin-bottom: 15px;
}

/* === Ambient Effects === */
.ambient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 80%, rgba(0, 122, 255, 0.1), transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.05), transparent 50%),
    radial-gradient(circle at 40% 40%, rgba(0, 122, 255, 0.05), transparent 50%);
  pointer-events: none;
  animation: ambient-drift 20s ease-in-out infinite alternate;
}

@keyframes ambient-drift {
  0% { transform: translateX(0) translateY(0); }
  100% { transform: translateX(10px) translateY(-10px); }
}

/* === Liquid Glass Chat Card === */
.chat-glass-card {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 480px);
  height: min(85vh, 700px);
  background: var(--glass-bg);
  backdrop-filter: var(--blur) var(--saturate);
  -webkit-backdrop-filter: var(--blur) var(--saturate);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.chat-glass-card:hover {
  transform: translate(-50%, -50%) scale(1.02);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
}

/* === Glass Header === */
.glass-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: var(--blur);
}

.bot-avatar-glass {
  position: relative;
  width: 50px;
  height: 50px;
  margin-right: 16px;
  border-radius: 16px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--brand-glow);
}

.avatar-glow {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, var(--brand), transparent, var(--brand));
  border-radius: 18px;
  animation: glow-rotate 3s linear infinite;
  z-index: -1;
}

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

.avatar-icon {
  font-size: 24px;
  z-index: 2;
}

.titles-glass {
  flex: 1;
}

.titles-glass h1 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.sub-glass {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.glass-controls {
  display: flex;
  gap: 8px;
}

.glass-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: var(--input-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.glass-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

/* === Chat Stream Glass === */
.chat-stream-glass {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-stream-glass::-webkit-scrollbar {
  display: none;
}

/* === Message Styling === */
.msg {
  margin-bottom: 16px;
  display: flex;
  animation: message-appear 0.3s ease-out;
}

@keyframes message-appear {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

.msg.bot {
  justify-content: flex-start;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
}

.msg.bot .bubble {
  background: var(--bot-glass);
  border-bottom-left-radius: 6px;
  margin-right: auto;
}

.msg.user .bubble {
  background: var(--user-glass);
  border-bottom-right-radius: 6px;
  margin-left: auto;
  color: var(--text);
}

/* === Glass Input === */
.chat-input-glass {
  padding: 20px 24px;
  border-top: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
}

.input-container-glass {
  display: flex;
  align-items: center;
  background: var(--input-glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 4px;
  backdrop-filter: var(--blur);
  transition: all 0.2s ease;
}

.input-container-glass:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 20px var(--brand-glow);
}

#chatInput {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 12px 16px;
  outline: none;
  font-family: inherit;
}

#chatInput::placeholder {
  color: var(--text-secondary);
}

.btn-glass {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0 2px;
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

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

.btn-glass.primary:hover {
  background: #0056d6;
  box-shadow: 0 4px 15px var(--brand-glow);
}

/* === Enhanced Header === */
.ef-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--blur) var(--saturate);
  border-bottom: 1px solid var(--glass-border);
}

/* === Responsive Design === */
@media (max-width: 640px) {
  .chat-glass-card {
    width: 95vw;
    height: 90vh;
    border-radius: 16px;
  }
  
  .glass-header {
    padding: 16px 20px;
  }
  
  .chat-stream-glass {
    padding: 16px 20px;
  }
  
  .chat-input-glass {
    padding: 16px 20px;
  }
}

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

.brand {
  display:flex;
  align-items:center;
  gap:10px;
  color:var(--text);
  text-decoration:none;
}
.brand .mark {
  background:linear-gradient(135deg,var(--brand),var(--brand-2));
  color:#fff;
  font-weight:800;
  letter-spacing:0.5px;
  border-radius:10px;
  width:34px;
  height:34px;
  display:grid;
  place-items:center;
  box-shadow:0 8px 24px var(--ring);
}
.brand .text { font-weight:600 }
.brand small { color:var(--muted); font-weight:500 }

.switcher .switch-link {
  color:var(--muted);
  text-decoration:none;
  border:1px solid #263041;
  padding:8px 12px;
  border-radius:10px;
  transition:.2s;
}
.switcher .switch-link:hover {
  border-color:#31415a;
  color:#cbd5e1;
}

.ef-main {
  max-width:920px;
  margin: 24px auto;
  padding: 0 16px;
}

.chat-card {
  background: linear-gradient(180deg, rgba(22,27,34,0.85), rgba(22,27,34,0.65));
  border:1px solid #212734;
  border-radius:18px;
  box-shadow: var(--shadow);
  overflow:hidden;
}

/* Light surface */
body.ef-chat[data-theme="light"] .chat-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.72));
  border-color: #e5e7eb;
}

.chat-header {
  display:flex;
  gap:12px;
  align-items:center;
  padding:18px;
  border-bottom:1px solid #1f2633;
  background: linear-gradient(180deg, rgba(16,21,28,0.9), rgba(16,21,28,0.6));
}
body.ef-chat[data-theme="light"] .chat-header {
  border-bottom-color: #e5e7eb;
  background: linear-gradient(180deg, rgba(250,251,252,0.95), rgba(250,251,252,0.75));
}
.bot-avatar {
  width:38px;
  height:38px;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:#1f2631;
  box-shadow: inset 0 0 0 1px #2a3446;
}
body.ef-chat[data-theme="light"] .bot-avatar {
  background:#eef2f7;
  box-shadow: inset 0 0 0 1px #d0d7e3;
}

.titles h1 { margin:0; font-size:18px }
.titles .sub { margin:4px 0 0; color:var(--muted); font-size:13px }

.chat-stream {
  height:56vh;
  overflow:auto;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:12px;
  color-scheme: dark; /* ensure dark scrollbars for WebKit */
  overscroll-behavior: contain; /* stop scroll chaining to page (prevents white track at bottom) */

  /* Firefox scrollbar inside chat */
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* WebKit scrollbar for chat stream */
.chat-stream::-webkit-scrollbar {
  width: 10px;
  background: transparent !important;
}
.chat-stream::-webkit-scrollbar-track {
  background: transparent !important;
  background-color: transparent !important;
}
.chat-stream::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scroll-thumb), rgba(14,165,233,0.25));
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.msg { display:flex; }
.msg.bot { justify-content:flex-start }
.msg.user { justify-content:flex-end }

.bubble {
  max-width:72%;
  padding:12px 14px;
  border-radius:14px;
  line-height:1.4;
  font-size:15px;
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}
.msg.bot .bubble {
  background: var(--bot);
  border: 1px solid rgba(38,48,69,0.65);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.msg.user .bubble {
  background: var(--user);
  color:#fff;
}
.bubble .options {
  margin-top:8px;
  color:#cbd5e1;
  font-size:14px;
}
.review { display:grid; gap:6px; }

.chat-input {
  display:flex;
  gap:10px;
  padding:14px;
  border-top:1px solid #1f2633;
  background: rgba(16,21,28,0.65);
  backdrop-filter: blur(6px);
}
body.ef-chat[data-theme="light"] .chat-input {
  border-top-color:#e5e7eb;
  background: rgba(255,255,255,0.72);
}

.chat-input input[type="text"] {
  flex:1;
  background:#0f1520;
  border:1px solid #223049;
  color:#cfe1ff;
  border-radius:12px;
  padding:12px 12px;
  outline:none;
  transition:.2s;
}
.chat-input input[type="text"]:focus {
  border-color:#345a9c;
  box-shadow:0 0 0 3px var(--ring);
}
body.ef-chat[data-theme="light"] .chat-input input[type="text"] {
  background:#ffffff;
  border-color:#d0d7e3;
  color:#0b1321;
}
body.ef-chat[data-theme="light"] .chat-input input[type="text"]::placeholder {
  color:#94a3b8;
}

.btn {
  border:1px solid #21314d;
  background:#142038;
  color:#dbeafe;
  padding:10px 14px;
  border-radius:12px;
  cursor:pointer;
  transition:.2s;
}
.btn:hover {
  border-color:#2b4574;
  background:#192948;
}
.btn.primary {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border: none;
  color:#fff;
  box-shadow: 0 8px 24px rgba(14,165,233,0.35);
}
.btn.icon {
  width:44px;
  display:grid;
  place-items:center;
  padding:0;
}

/* Theme toggle btn */
.btn.theme-toggle {
  border-color: #263041;
  background: transparent;
  color: var(--text);
}
.btn.theme-toggle:hover {
  background: rgba(148,163,184,0.08);
}

/* Typing indicator */
.typing {
  display:inline-flex;
  align-items:center;
  gap:6px;
}
.typing .dot {
  width:6px; height:6px; border-radius:50%;
  background: currentColor;
  opacity: .45;
  animation: blink 1.2s infinite ease-in-out;
}
.typing .dot:nth-child(2){ animation-delay: .15s }
.typing .dot:nth-child(3){ animation-delay: .3s }
@keyframes blink { 0%, 80%, 100% { opacity:.25 } 40% { opacity:.9 } }

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 640px){
  .bubble{ max-width: 88% }
  .chat-stream{ height: 60vh }
}

/* 3D robot container */
.bot-3d {
  width: 100%;
  height: clamp(260px, 34vh, 420px);
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 70% -30%, rgba(37,99,235,0.10), rgba(14,165,233,0.04)), transparent;
  border-bottom: 1px solid rgba(148,163,184,0.12);
  position: relative;
}
body.ef-chat[data-theme="light"] .bot-3d {
  background: radial-gradient(1200px 600px at 70% -30%, rgba(37,99,235,0.08), rgba(2,6,23,0.03)), transparent;
  border-bottom-color: #e5e7eb;
}
.bot-3d canvas, .bot-3d model-viewer { display:block; max-width:100%; height:100%; }
.bot-3d model-viewer { outline: none; contain: strict; }

/* Hero section for 3D robot */
.bot-hero {
  max-width: 920px;
  margin: 12px auto 16px;
  padding: 0 16px;
}
