/* Ultra-Modern Apple Liquid Glass Design System (High-Definition OLED & Clean Minimalist UI) */
:root {
  /* Apple OLED Dark Palette */
  --bg-primary: #070a12;
  --bg-secondary: #0f1626;
  
  /* Apple Liquid Glass Surface Tokens */
  --liquid-glass: rgba(18, 26, 43, 0.65);
  --liquid-glass-card: rgba(28, 39, 64, 0.55);
  --liquid-glass-hover: rgba(45, 60, 94, 0.5);
  --liquid-glass-input: rgba(15, 22, 36, 0.7);
  
  /* Crisp Glass Borders & Inner Liquid Highlights */
  --border-liquid: rgba(255, 255, 255, 0.14);
  --border-liquid-bright: rgba(255, 255, 255, 0.28);
  --inner-glow: inset 0 1px 1px 0 rgba(255, 255, 255, 0.22);
  --drop-shadow-liquid: 0 20px 40px -10px rgba(0, 0, 0, 0.6), 0 0 30px rgba(99, 102, 241, 0.2);
  
  /* Apple HD Typography Colors */
  --text-primary: #ffffff;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  /* Apple Intelligence Liquid Gradients */
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --liquid-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 40%, #a855f7 70%, #ec4899 100%);
  --user-bubble-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  
  /* Apple Continuous Smooth Radius (Squircles) */
  --radius-max: 32px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  
  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Helvetica Neue", sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.2px;
  -webkit-font-smoothing: antialiased;
}

/* ----------------------------------------------------
   0. INTRO SPLASH PAGE (3 SECONDS RAINBOW INTRO)
---------------------------------------------------- */
.intro-splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #070a12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.intro-splash.fade-out {
  opacity: 0;
  pointer-events: none;
}

.constellation-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.splash-center-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ultra-Vivid Diffused Spectrum Rainbow Aura Glow */
.rainbow-aura-glow {
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff0055 0%, #a800ff 25%, #00e5ff 50%, #00ff88 75%, #ffee00 90%, #ff0055 100%);
  filter: blur(65px) saturate(320%) brightness(135%) contrast(130%);
  opacity: 0.92;
  animation: rainbowSpin 10s linear infinite, rainbowPulse 3.5s ease-in-out infinite alternate;
  pointer-events: none;
}

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

@keyframes rainbowPulse {
  0% { transform: scale(0.88) rotate(0deg); opacity: 0.5; }
  100% { transform: scale(1.15) rotate(180deg); opacity: 0.75; }
}

.splash-brand-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  z-index: 3;
  animation: floatBrand 5s ease-in-out infinite alternate;
}

@keyframes floatBrand {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}

/* Title: Faalan (Grand Silver Metallic Shimmering Gradient) */
.splash-title {
  position: relative;
  font-size: 76px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-indent: 0.25em;
  margin: 0 auto;
  background: linear-gradient(120deg, #ffffff 0%, #cbd5e1 18%, #8899a6 32%, #ffffff 50%, #7d8b99 68%, #e2e8f0 82%, #ffffff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: silverMetallicShimmer 7s linear infinite;
  filter: drop-shadow(0 14px 40px rgba(255, 255, 255, 0.5));
}

@keyframes silverMetallicShimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* Subtitle: Assistive Intelligence (Refined Subdued Elegance) */
.splash-subtitle {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.46em;
  text-indent: 0.46em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.85);
  margin: 12px auto 0 auto;
  opacity: 0.92;
  text-shadow: 0 2px 14px rgba(15, 23, 42, 0.95);
}

.splash-accent-pill {
  width: 44px;
  height: 2.5px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
  margin-top: 20px;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.7));
  animation: pillGlow 3s ease-in-out infinite alternate;
}

@keyframes pillGlow {
  0% { width: 36px; opacity: 0.5; }
  100% { width: 56px; opacity: 1; }
}

@media (max-width: 768px) {
  .splash-title {
    font-size: 48px;
    letter-spacing: 0.22em;
    text-indent: 0.22em;
  }
  
  .splash-subtitle {
    font-size: 11.5px;
    letter-spacing: 0.36em;
    text-indent: 0.36em;
    margin-top: 8px;
  }
  
  .splash-accent-pill {
    margin-top: 14px;
  }
  
  .rainbow-aura-glow {
    width: 280px;
    height: 280px;
    filter: blur(60px);
  }
}

/* Ambient Liquid Glow Animation */
.bg-glow {
  position: fixed;
  top: -25vh;
  left: -25vw;
  width: 150vw;
  height: 150vh;
  z-index: 0;
  pointer-events: none;
  background: 
    radial-gradient(circle at 25% 20%, rgba(99, 102, 241, 0.18) 0%, transparent 45%),
    radial-gradient(circle at 75% 75%, rgba(236, 72, 153, 0.15) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.12) 0%, transparent 50%);
  filter: blur(80px);
  animation: liquidPulse 12s infinite alternate ease-in-out;
}

@keyframes liquidPulse {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.08) rotate(5deg); }
}

/* Main App Wrapper */
#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  z-index: 1;
}

/* ----------------------------------------------------
   AUTHENTICATION SCREEN (DEVICE-PROPORTIONAL FLOATING CARD)
---------------------------------------------------- */
.auth-container {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(7, 10, 18, 0.84);
  backdrop-filter: blur(35px) saturate(210%);
  -webkit-backdrop-filter: blur(35px) saturate(210%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.auth-container.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: none !important;
}

.auth-card-wrapper {
  position: relative;
  width: 100%;
  max-width: 520px; /* Grand spacious desktop width */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* Diffused Rainbow Aura Floating Behind Login Card */
.auth-card-glow-aura {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff0055 0%, #8800ff 25%, #00d4ff 50%, #00ff88 75%, #ffea00 90%, #ff0055 100%);
  filter: blur(65px) saturate(250%);
  opacity: 0.7;
  pointer-events: none;
  animation: cardAuraRotate 14s linear infinite;
  z-index: 0;
}

@keyframes cardAuraRotate {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--liquid-glass-card);
  border: 1px solid var(--border-liquid-bright);
  border-radius: var(--radius-max);
  padding: 48px 42px; /* Spacious proportions */
  box-shadow: 0 32px 65px -12px rgba(0, 0, 0, 0.78), 0 0 45px rgba(99, 102, 241, 0.32), var(--inner-glow);
  backdrop-filter: blur(35px) saturate(200%);
  -webkit-backdrop-filter: blur(35px) saturate(200%);
  animation: cardAppear 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

/* Faalan Brand Badge with Thin Rainbow Stroke */
.brand-rainbow-badge {
  display: inline-block;
  padding: 10px 28px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(23, 32, 51, 0.95), rgba(15, 23, 42, 0.95)) padding-box,
              linear-gradient(135deg, #ff0055, #7a00ff, #00e5ff, #00ff66, #ffea00, #ff0055) border-box;
  border: 1.5px solid transparent;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35), var(--inner-glow);
  margin-bottom: 10px;
  animation: rainbowBorderRotate 8s linear infinite;
}

@keyframes rainbowBorderRotate {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

.brand-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(255, 255, 255, 0.45);
}

.brand-subtitle {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #c7d2fe;
  margin-top: 6px;
}

/* Form inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-input {
  width: 100%;
  height: 54px; /* Spacious input for Desktop */
  padding: 0 20px;
  background: var(--liquid-glass-input);
  border: 1px solid var(--border-liquid);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  box-shadow: var(--inner-glow);
  transition: var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3.5px rgba(59, 130, 246, 0.3), var(--inner-glow);
  background: rgba(18, 26, 43, 0.85);
}

.btn-primary {
  width: 100%;
  height: 54px; /* Grand primary button */
  border: none;
  border-radius: var(--radius-lg);
  background: var(--liquid-gradient);
  color: #ffffff;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  margin-top: 12px;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(99, 102, 241, 0.55);
}

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

.auth-error {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 13.5px;
  display: none;
}

.auth-error.show {
  display: block;
}

/* Modern Dark Slate Floating EN / TH Language Toggle (Below Login Box) */
.auth-floating-lang {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  width: 100%;
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-toggle-capsule {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), var(--inner-glow);
}

.lang-segment {
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 7px 20px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: var(--transition-fast);
}

.lang-segment:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.lang-segment.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Mobile & iPhone 17 Pro Max Proportional Adaptation */
@media (max-width: 768px) {
  .auth-card-wrapper {
    max-width: 92vw;
  }

  .auth-card {
    padding: 38px 26px; /* Sleek vertical iPhone ratio */
    border-radius: 28px;
  }

  .brand-title {
    font-size: 28px;
  }

  .brand-subtitle {
    font-size: 12px;
  }

  .form-input {
    height: 50px;
    font-size: 15px;
  }

  .btn-primary {
    height: 50px;
    font-size: 15.5px;
  }

  .auth-card-glow-aura {
    width: 320px;
    height: 320px;
    filter: blur(50px);
  }
}

/* ----------------------------------------------------
   LIQUID GLASS CHAT WORKSPACE
---------------------------------------------------- */
.chat-workspace {
  width: 100%;
  height: 100dvh;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--liquid-glass);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border-right: 1px solid var(--border-liquid);
  box-shadow: var(--inner-glow);
  display: flex;
  flex-direction: column;
  z-index: 20;
  transition: transform var(--transition-smooth);
}

.sidebar-header {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-liquid);
}

.app-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--liquid-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.app-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.app-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-liquid);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--inner-glow);
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: scale(1.04);
}

.btn-icon:active {
  transform: scale(0.96);
}

.btn-new-chat {
  margin: 18px 20px;
  height: 46px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-liquid-bright);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--inner-glow);
  transition: var(--transition-fast);
}

.btn-new-chat:hover {
  background: var(--liquid-gradient);
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-new-chat:active {
  transform: translateY(0) scale(0.98);
}

.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.history-item {
  padding: 13px 16px;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover {
  background: var(--liquid-glass-hover);
  color: var(--text-primary);
  transform: translateX(2px);
}

.history-item.active {
  background: rgba(99, 102, 241, 0.22);
  color: #ffffff;
  border: 1px solid rgba(99, 102, 241, 0.4);
  box-shadow: var(--inner-glow);
}

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

.history-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 18px 20px;
  border-top: 1px solid var(--border-liquid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9, 13, 22, 0.6);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e, #fb7185);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.35);
}

.user-email {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Main Content Area */
.main-chat-area {
  flex: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
}

/* Header Bar */
.top-nav {
  height: var(--header-height);
  padding: 0 24px;
  padding-top: env(safe-area-inset-top);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--liquid-glass);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  border-bottom: 1px solid var(--border-liquid);
  box-shadow: var(--inner-glow);
  z-index: 10;
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-menu-btn {
  display: none;
}

.current-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #c7d2fe;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--inner-glow);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 12px #34d399;
  animation: pulseGreen 2s infinite ease-in-out;
}

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

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scroll-behavior: smooth;
}

.welcome-screen {
  margin: auto;
  text-align: center;
  max-width: 600px;
  padding: 40px 24px;
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.welcome-icon {
  width: 76px;
  height: 76px;
  border-radius: 26px;
  background: var(--liquid-gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  box-shadow: 0 18px 40px rgba(99, 102, 241, 0.45);
}

.welcome-icon svg {
  width: 42px;
  height: 42px;
  color: white;
}

.welcome-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin-bottom: 12px;
  color: #ffffff;
}

.welcome-desc {
  font-size: 15.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
}

.suggestion-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.chip {
  padding: 16px 18px;
  border-radius: var(--radius-xl);
  background: var(--liquid-glass-card);
  border: 1px solid var(--border-liquid);
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--inner-glow);
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chip:hover {
  background: var(--liquid-glass-hover);
  border-color: var(--accent-indigo);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4), var(--inner-glow);
}

.chip:active {
  transform: translateY(0) scale(0.98);
}

/* Chat Message Bubbles */
.message-row {
  display: flex;
  gap: 16px;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  animation: messageSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.message-row.user .msg-avatar {
  background: var(--user-bubble-gradient);
  color: white;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.message-row.ai .msg-avatar {
  background: var(--liquid-gradient);
  color: white;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

.msg-bubble {
  max-width: 82%;
  padding: 16px 20px;
  border-radius: var(--radius-xl);
  font-size: 15px;
  line-height: 1.65;
}

.message-row.user .msg-bubble {
  background: var(--user-bubble-gradient);
  color: #ffffff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}

.message-row.ai .msg-bubble {
  background: var(--liquid-glass-card);
  border: 1px solid var(--border-liquid);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--inner-glow);
}

/* Code Blocks & Typography Formatting */
.msg-bubble p { margin-bottom: 12px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble pre {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid var(--border-liquid);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  margin: 12px 0;
  box-shadow: var(--inner-glow);
}

.msg-bubble code {
  background: rgba(255, 255, 255, 0.14);
  padding: 3px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
}

/* Typing Dots */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c7d2fe;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

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

/* Floating Input Dock */
.input-area-wrapper {
  padding: 18px 24px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-primary) 75%, transparent);
  position: relative;
  z-index: 10;
}

.input-box-container {
  max-width: 880px;
  margin: 0 auto;
  background: var(--liquid-glass-card);
  border: 1px solid var(--border-liquid-bright);
  border-radius: var(--radius-max);
  padding: 8px 14px 8px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 25px rgba(99, 102, 241, 0.2), var(--inner-glow);
  backdrop-filter: blur(30px) saturate(200%);
  -webkit-backdrop-filter: blur(30px) saturate(200%);
  transition: var(--transition-fast);
}

.input-box-container:focus-within {
  border-color: var(--accent-indigo);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.6), 0 0 35px rgba(99, 102, 241, 0.35), var(--inner-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15.5px;
  font-family: inherit;
  resize: none;
  max-height: 130px;
  min-height: 26px;
  line-height: 1.5;
  padding: 8px 0;
}

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

.btn-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--liquid-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition-fast);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.btn-send:hover {
  transform: scale(1.08);
}

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

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

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

/* Mobile Sidebar Drawer Overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* ----------------------------------------------------
   RESPONSIVE LAYOUT RULES (DESKTOP LANDSCAPE VS IPHONE PORTRAIT)
---------------------------------------------------- */
@media (min-width: 992px) and (orientation: landscape) {
  .sidebar {
    position: relative;
    transform: none !important;
  }
  
  .mobile-menu-btn {
    display: none !important;
  }
}

@media (max-width: 991px), (orientation: portrait) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.7);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex !important;
  }

  .msg-bubble {
    max-width: 88%;
  }

  .suggestion-chips {
    grid-template-columns: 1fr;
  }
}
