:root {
  /* Light Mode Colors */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #111827;
  --text-secondary: #6B7280;
  --primary: #4F46E5;
  --primary-dark: #3730A3;
  --success: #059669;
  --error: #DC2626;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.04);
  --border-radius: 16px;
  --transition: all 0.2s ease;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Colors */
[data-theme="dark"] {
  --bg: #0F172A;
  --surface: #1E293B;
  --border: #334155;
  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --primary: #6366F1;
  --primary-dark: #4F46E5;
  --success: #10B981;
  --error: #EF4444;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.2);
}


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: var(--transition-smooth);
}

/* Soft drifting blobs — visible through translucent chat panel */
.page-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.page-ambient__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.42;
  will-change: transform;
  animation: ambientBlobDrift 26s ease-in-out infinite;
}

.page-ambient__blob--1 {
  width: min(58vw, 460px);
  height: min(58vw, 460px);
  background: rgba(99, 102, 241, 0.42);
  top: -18%;
  left: -20%;
  animation-delay: 0s;
}

.page-ambient__blob--2 {
  width: min(50vw, 380px);
  height: min(50vw, 380px);
  background: rgba(56, 189, 248, 0.28);
  bottom: -12%;
  right: -16%;
  animation-delay: -8s;
  animation-duration: 32s;
}

.page-ambient__blob--3 {
  width: min(42vw, 320px);
  height: min(42vw, 320px);
  background: rgba(244, 114, 182, 0.2);
  top: 38%;
  left: 35%;
  animation-delay: -14s;
  animation-duration: 22s;
}

[data-theme="dark"] .page-ambient__blob--1 {
  background: rgba(79, 70, 229, 0.32);
}

[data-theme="dark"] .page-ambient__blob--2 {
  background: rgba(34, 211, 238, 0.18);
}

[data-theme="dark"] .page-ambient__blob--3 {
  background: rgba(167, 139, 250, 0.15);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100vw;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  background: transparent;
  transition: var(--transition-smooth);
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-soft);
  transition: var(--transition-smooth);
  animation: sectionRise 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  --toggle-track-w: 52px;
  --toggle-track-h: 30px;
  --toggle-thumb: 24px;
  --toggle-pad: 3px;
  --toggle-slide: calc(var(--toggle-track-w) - var(--toggle-thumb) - (var(--toggle-pad) * 2));
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.theme-toggle__track {
  position: relative;
  overflow: visible;
  width: var(--toggle-track-w);
  height: var(--toggle-track-h);
  border-radius: 999px;
  background: linear-gradient(145deg, #E8ECF3 0%, #D8DEE9 100%);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.85),
    inset 0 -1px 2px rgba(15, 23, 42, 0.06),
    0 2px 8px rgba(15, 23, 42, 0.08);
  transition:
    background 0.45s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] .theme-toggle__track {
  background: linear-gradient(145deg, #334155 0%, #1E293B 100%);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.06),
    inset 0 -1px 3px rgba(0, 0, 0, 0.35),
    0 2px 12px rgba(0, 0, 0, 0.35);
}

.theme-toggle__glow {
  position: absolute;
  inset: -2px;
  z-index: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 40%, rgba(251, 191, 36, 0.35), transparent 55%);
  opacity: 0.65;
  pointer-events: none;
  transition: transform 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.theme-toggle--dark .theme-toggle__glow {
  opacity: 0.85;
  transform: translateX(35%);
  background: radial-gradient(circle at 70% 45%, rgba(129, 140, 248, 0.45), transparent 55%);
}

.theme-toggle__icon {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  pointer-events: none;
  transition:
    color 0.35s ease,
    opacity 0.35s ease,
    transform 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.theme-toggle__icon--sun {
  left: 8px;
  color: #CA8A04;
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.theme-toggle__icon--moon {
  right: 8px;
  color: #94A3B8;
  opacity: 0.38;
  transform: translateY(-50%) scale(0.92);
}

.theme-toggle--dark .theme-toggle__icon--sun {
  opacity: 0.35;
  color: #78716C;
  transform: translateY(-50%) scale(0.9);
}

.theme-toggle--dark .theme-toggle__icon--moon {
  opacity: 1;
  color: #C7D2FE;
  transform: translateY(-50%) scale(1);
}

.theme-toggle__thumb {
  position: absolute;
  top: var(--toggle-pad);
  left: var(--toggle-pad);
  z-index: 3;
  width: var(--toggle-thumb);
  height: var(--toggle-thumb);
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFFFF 0%, #F1F5F9 100%);
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.15),
    0 1px 2px rgba(15, 23, 42, 0.08);
  transition:
    transform 0.45s cubic-bezier(0.34, 1.35, 0.64, 1),
    background 0.35s ease,
    box-shadow 0.35s ease;
}

.theme-toggle--dark .theme-toggle__thumb {
  transform: translateX(var(--toggle-slide));
  background: linear-gradient(180deg, #F8FAFC 0%, #E2E8F0 100%);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.12);
}

.theme-toggle:hover .theme-toggle__track {
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.9),
    inset 0 -1px 2px rgba(15, 23, 42, 0.05),
    0 4px 14px rgba(79, 70, 229, 0.12);
}

[data-theme="dark"] .theme-toggle:hover .theme-toggle__track {
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.08),
    inset 0 -1px 3px rgba(0, 0, 0, 0.4),
    0 4px 16px rgba(99, 102, 241, 0.2);
}

.theme-toggle:active .theme-toggle__thumb {
  transform: scale(0.94);
}

.theme-toggle:active.theme-toggle--dark .theme-toggle__thumb {
  transform: translateX(var(--toggle-slide)) scale(0.94);
}

/* Toggle track ripple + burst (fired on click via .theme-toggle--burst) */
.theme-toggle__track::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55);
}

.theme-toggle--burst .theme-toggle__track::before {
  animation: toggleRippleOut 0.75s cubic-bezier(0.22, 1, 0.45, 1) forwards;
}

.theme-toggle--burst .theme-toggle__icon--sun,
.theme-toggle--burst .theme-toggle__icon--moon {
  animation: iconTogglePop 0.58s cubic-bezier(0.34, 1.45, 0.64, 1) both;
}

@media (prefers-reduced-motion: no-preference) {
  .theme-toggle__glow {
    animation: toggleGlowBreathe 4.8s ease-in-out infinite;
  }

  .theme-toggle:not(.theme-toggle--dark) .theme-toggle__icon--sun {
    animation: sunIdleSway 7.5s ease-in-out infinite;
  }

  .theme-toggle.theme-toggle--dark .theme-toggle__icon--moon {
    animation: moonIdleDrift 6s ease-in-out infinite;
  }
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-info h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text);
}

.status {
  font-size: 14px;
  color: var(--success);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status::before {
  content: '';
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: statusPulse 2.4s ease-out infinite;
}

/* Search Section */
.search-section {
  padding: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: var(--transition-smooth);
  animation: sectionRise 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

.search-input-wrapper {
  position: relative;
}

#searchInput {
  width: 100%;
  padding: 14px 48px 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  font-size: 16px;
  background: var(--bg);
  outline: none;
  transition: var(--transition);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

#searchInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  background: var(--surface);
}

.search-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: 8px;
  transition: var(--transition);
}

.search-btn:hover {
  background: var(--bg);
  color: var(--text);
}

/* Chat Window */
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
  transition: var(--transition-smooth);
  position: relative;
  isolation: isolate;
  background: var(--bg);
  animation: sectionRise 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}

@supports (background: color-mix(in srgb, white 50%, transparent)) {
  .chat-window {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
  }
}

.chat-window::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: min(72vh, 520px);
  background:
    radial-gradient(ellipse 85% 65% at 12% 18%, rgba(99, 102, 241, 0.11), transparent 58%),
    radial-gradient(ellipse 75% 55% at 88% 72%, rgba(56, 189, 248, 0.07), transparent 52%);
  animation: chatAurora 20s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] .chat-window::before {
  background:
    radial-gradient(ellipse 85% 65% at 12% 18%, rgba(129, 140, 248, 0.14), transparent 58%),
    radial-gradient(ellipse 75% 55% at 88% 72%, rgba(45, 212, 191, 0.06), transparent 52%);
}

.chat-window > * {
  position: relative;
  z-index: 1;
}

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  animation: slideIn 0.3s ease;
}

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

.avatar-small {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: var(--border-radius);
  font-size: 16px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  box-shadow: var(--shadow-soft);
  transition: var(--transition);
}

.message.bot .message-content {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message.user .message-content {
  background: var(--primary);
  color: #FFFFFF;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.timestamp {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  opacity: 0.8;
  font-weight: 400;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.quick-reply {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-soft);
  border-bottom-left-radius: 4px;
}

.quick-reply:hover {
  background: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

@media (prefers-reduced-motion: no-preference) {
  .welcome-message .quick-reply:nth-child(1) {
    animation: quickEnter 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) 0.35s both;
  }

  .welcome-message .quick-reply:nth-child(2) {
    animation: quickEnter 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) 0.45s both;
  }

  .welcome-message .quick-reply:nth-child(3) {
    animation: quickEnter 0.45s cubic-bezier(0.34, 1.2, 0.64, 1) 0.55s both;
  }
}

/* Chat Input */
.chat-input-section {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  position: sticky;
  bottom: 0;
  transition: var(--transition-smooth);
  animation: sectionRise 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

#messageInput {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  font-size: 16px;
  resize: none;
  outline: none;
  transition: var(--transition);
  min-height: 52px;
  max-height: 120px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  line-height: 1.4;
  border-bottom-left-radius: 4px;
}

#messageInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  background: var(--surface);
}

.voice-btn, .send-btn {
  width: 52px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: var(--surface);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.voice-btn:hover {
  background: var(--bg);
  color: var(--text);
  transform: scale(1.05);
}

.send-btn {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

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

.send-btn:disabled {
  background: var(--text-secondary);
  border-color: var(--text-secondary);
  cursor: not-allowed;
  transform: none;
}

.action-buttons {
  display: flex;
  justify-content: center;
}

.action-btn {
  background: var(--success);
  color: var(--bg);
  border: none;
  border-radius: var(--border-radius);
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  box-shadow: var(--shadow);
}

.action-btn:hover {
  background: #047857;
  transform: translateY(-1px);
}

.footer-text {
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 14px;
  font-weight: 400;
  opacity: 0.8;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--surface);
  margin: 20% auto;
  padding: 28px;
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  transition: var(--transition-smooth);
}

.modal-content h3 {
  margin-bottom: 18px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.modal-content p {
  margin-bottom: 18px;
  color: var(--text-secondary);
  line-height: 1.5;
  font-size: 16px;
}

.modal-content--voice .voice-modal-title {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-content--voice .voice-modal-hint {
  margin-bottom: 14px !important;
  font-size: 13px !important;
  line-height: 1.45;
}

.voice-live {
  min-height: 4rem;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

#phoneInput {
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 18px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: var(--transition);
  border-bottom-left-radius: 4px;
}

#phoneInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  background: var(--surface);
}

#submitCallBtn, #stopVoiceBtn {
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 14px 28px;
  font-size: 16px;
  cursor: pointer;
  width: 100%;
  font-weight: 500;
  transition: var(--transition);
  box-shadow: var(--shadow-soft);
}

#submitCallBtn:hover, #stopVoiceBtn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

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

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

@keyframes ambientBlobDrift {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(5%, 4%) scale(1.05);
  }
  66% {
    transform: translate(-4%, 6%) scale(0.97);
  }
}

@keyframes chatAurora {
  0% {
    transform: translateX(-4%) skewX(-1deg);
  }
  100% {
    transform: translateX(4%) skewX(1deg);
  }
}

@keyframes statusPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45);
    transform: scale(1);
  }
  55% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    transform: scale(1.08);
  }
}

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

@keyframes toggleRippleOut {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.55);
  }
  100% {
    opacity: 0;
    box-shadow: 0 0 0 22px rgba(129, 140, 248, 0);
  }
}

@keyframes toggleGlowBreathe {
  0%, 100% {
    opacity: 0.58;
  }
  50% {
    opacity: 0.92;
  }
}

@keyframes sunIdleSway {
  0%, 100% {
    transform: translateY(-50%) rotate(-7deg) scale(1);
  }
  50% {
    transform: translateY(-50%) rotate(7deg) scale(1.05);
  }
}

@keyframes moonIdleDrift {
  0%, 100% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-54%) scale(1.07);
  }
}

@keyframes iconTogglePop {
  0% {
    transform: translateY(-50%) scale(1);
  }
  35% {
    transform: translateY(-50%) scale(1.24);
  }
  65% {
    transform: translateY(-50%) scale(0.88);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

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

.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Mobile Optimizations */
@media (max-width: 768px) {
  .app-container {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
  }

  .app-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .header-info h1 {
    font-size: 16px;
  }

  .status {
    font-size: 13px;
  }

  .header-actions {
    gap: 6px;
  }

  .theme-toggle {
    min-width: 52px;
    min-height: 44px;
    padding: 7px 0;
    align-items: center;
  }

  .search-section {
    padding: 16px;
  }

  .chat-window {
    padding: 16px;
    padding-bottom: 120px; /* Space for sticky input */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  .message {
    gap: 10px;
    margin-bottom: 16px;
  }

  .message-content {
    max-width: 85%;
    padding: 12px 16px;
    font-size: 15px;
  }

  .avatar-small {
    width: 32px;
    height: 32px;
  }

  .chat-input-section {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom)); /* Safe area for iOS */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
  }

  .input-wrapper {
    gap: 8px;
    margin-bottom: 12px;
  }

  #messageInput {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  .voice-btn, .send-btn {
    width: 48px;
    height: 48px;
    font-size: 16px;
  }

  .action-buttons {
    margin-bottom: 8px;
  }

  .action-btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
  }

  .footer-text {
    font-size: 11px;
    margin-top: 8px;
  }

  .modal-content {
    margin: 20% auto;
    width: 95%;
    max-width: 360px;
    padding: 20px;
  }

  .quick-replies {
    flex-direction: column;
    gap: 6px;
  }

  .quick-reply {
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .app-header {
    padding: 12px 14px;
  }

  .header-content {
    gap: 10px;
  }

  .avatar {
    width: 36px;
    height: 36px;
  }

  .header-actions {
    gap: 4px;
  }

  .theme-toggle {
    min-width: 52px;
    min-height: 44px;
    padding: 7px 0;
  }

  .search-section {
    padding: 14px;
  }

  .chat-window {
    padding: 14px;
    padding-bottom: 140px;
  }

  .message-content {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 14px;
  }

  .chat-input-section {
    padding: 14px;
  }

  .input-wrapper {
    gap: 6px;
  }

  .voice-btn, .send-btn {
    width: 44px;
    height: 44px;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .theme-toggle, .voice-btn, .send-btn, .search-btn, .action-btn, .quick-reply {
    min-height: 44px; /* iOS touch target minimum */
    min-width: 44px;
  }

  .theme-toggle {
    min-width: 52px;
    min-height: 44px;
    padding: 8px 6px;
  }

  .message-content {
    border-radius: 18px; /* Larger radius for touch */
  }

  .message.user .message-content {
    border-bottom-right-radius: 6px;
  }

  .message.bot .message-content {
    border-bottom-left-radius: 6px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #000000;
    --text-secondary: #000000;
  }

  [data-theme="dark"] {
    --border: #FFFFFF;
    --text-secondary: #FFFFFF;
  }
}

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


/* Safe Area for Notches */
@supports (padding: max(0px)) {
  .app-container {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .chat-input-section {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
