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

html, body {
  background: radial-gradient(1200px 800px at 20% -10%, #1e1b3a 0%, #0d0d16 55%), #0d0d16;
  color: #f2f1f8;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  height: 100vh;
  height: 100dvh;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
  position: relative;
}

/* ---------------- Header ---------------- */

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(18, 18, 28, 0.6);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.avatar-ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(from 180deg, #7c5cff, #ff5ca8, #7c5cff);
  padding: 2px;
}

.avatar-ring.big { width: 64px; height: 64px; margin: 0 auto 14px; }

.avatar-ring .dot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #14141f;
  position: relative;
}

.avatar-ring .dot::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: linear-gradient(145deg, #b39bff, #7c5cff);
  box-shadow: 0 0 10px rgba(124, 92, 255, 0.9);
}

.brand-text { min-width: 0; }

.brand-text h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.status-line {
  font-size: 11px;
  color: #8f8fb0;
  display: block;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #a9a9c0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn .icon-speaker-off { display: block; }
.icon-btn .icon-speaker-on { display: none; }

.icon-btn.active {
  background: linear-gradient(145deg, #7c5cff, #6144e0);
  border-color: transparent;
  color: white;
  box-shadow: 0 0 14px rgba(124, 92, 255, 0.55);
}

.icon-btn.active .icon-speaker-off { display: none; }
.icon-btn.active .icon-speaker-on { display: block; }

.pill-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cfcfe4;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.pill-btn:hover {
  border-color: #7c5cff;
  color: #f0f0f5;
  background: rgba(124, 92, 255, 0.12);
}

/* ---------------- Messages ---------------- */

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: rise 0.25s ease both;
}

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

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

.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  background: linear-gradient(145deg, #b39bff, #7c5cff);
  box-shadow: 0 0 8px rgba(124, 92, 255, 0.55);
}

.msg {
  max-width: 76%;
  padding: 11px 15px;
  border-radius: 18px;
  line-height: 1.45;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.msg.user {
  background: linear-gradient(145deg, #8a6bff, #6f4bff);
  color: white;
  border-bottom-right-radius: 5px;
}

.msg.aarzu {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 5px;
}

.msg.typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 13px 16px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9b9d6;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ---------------- Input bar ---------------- */

#chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(18, 18, 28, 0.6);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 22px;
  padding: 13px 18px;
  color: white;
  font-size: 15px;
  transition: border-color 0.2s ease;
}

#chat-input:focus {
  outline: none;
  border-color: #7c5cff;
}

.mic-btn, .send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s ease;
}

.mic-btn:active, .send-btn:active { transform: scale(0.92); }

.mic-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cfcfe4;
}

.mic-btn svg, .send-btn svg { width: 19px; height: 19px; position: relative; z-index: 1; }

.mic-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #ff5c8a;
  opacity: 0;
}

.mic-btn.listening {
  background: linear-gradient(145deg, #ff6b9d, #ff5c8a);
  color: white;
  border-color: transparent;
}

.mic-btn.listening .mic-pulse {
  opacity: 0.55;
  animation: pulse 1.3s infinite ease-out;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.9); opacity: 0; }
}

.send-btn {
  background: linear-gradient(145deg, #8a6bff, #6f4bff);
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.45);
}

/* ---------------- Onboarding overlay ---------------- */

#onboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 14, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

#onboard-overlay.hidden { display: none; }

.onboard-card {
  background: rgba(30, 30, 44, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.onboard-card p {
  font-size: 16px;
  margin-bottom: 18px;
  color: #f0f0f5;
}

.onboard-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.onboard-actions button {
  padding: 13px;
  border-radius: 14px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.onboard-actions button:active { transform: scale(0.97); }

.primary-btn {
  background: linear-gradient(145deg, #8a6bff, #6f4bff);
  color: white;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.4);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #f0f0f5;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ---------------- Scrollbar ---------------- */

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* ---------------- Voice call button (header) ---------------- */

.call-icon-btn {
  background: linear-gradient(145deg, #7c5cff, #6144e0);
  border-color: transparent;
  color: white;
  box-shadow: 0 0 14px rgba(124, 92, 255, 0.45);
}

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

/* ---------------- Full-screen voice call overlay ---------------- */

#voice-call-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: radial-gradient(900px 700px at 50% 20%, #221f42 0%, #08080f 65%), #08080f;
  display: flex;
  align-items: center;
  justify-content: center;
}

#voice-call-overlay.hidden { display: none; }

.call-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}

.voice-orb {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-core {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: linear-gradient(145deg, #b39bff, #7c5cff 55%, #5c3dff);
  box-shadow: 0 0 40px rgba(124, 92, 255, 0.65), 0 0 90px rgba(124, 92, 255, 0.35);
  z-index: 2;
}

.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(124, 92, 255, 0.5);
}

/* Listening: calm, steady breathing pulse */
.voice-orb.listening .orb-core { animation: orb-breathe 2.2s ease-in-out infinite; }
.voice-orb.listening .orb-ring { animation: orb-expand 2.2s ease-out infinite; }
.voice-orb.listening .r2 { animation-delay: 0.5s; }
.voice-orb.listening .r3 { animation-delay: 1s; }

/* Thinking: slow rotating shimmer, dimmer */
.voice-orb.thinking .orb-core {
  background: linear-gradient(145deg, #8f8fb0, #6a6a8c);
  animation: orb-rotate 1.6s linear infinite;
  box-shadow: 0 0 30px rgba(140, 140, 180, 0.45);
}
.voice-orb.thinking .orb-ring { opacity: 0; }

/* Speaking: energetic, faster pulse in warm tones */
.voice-orb.speaking .orb-core {
  background: linear-gradient(145deg, #ff9bd0, #ff5ca8 55%, #ff3d8f);
  box-shadow: 0 0 45px rgba(255, 92, 168, 0.6), 0 0 100px rgba(255, 92, 168, 0.3);
  animation: orb-breathe 0.9s ease-in-out infinite;
}
.voice-orb.speaking .orb-ring {
  border-color: rgba(255, 92, 168, 0.5);
  animation: orb-expand 0.9s ease-out infinite;
}
.voice-orb.speaking .r2 { animation-delay: 0.2s; }
.voice-orb.speaking .r3 { animation-delay: 0.4s; }

@keyframes orb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes orb-expand {
  0% { transform: scale(0.7); opacity: 0.7; }
  100% { transform: scale(1.9); opacity: 0; }
}

@keyframes orb-rotate {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(0.92); }
  100% { transform: rotate(360deg) scale(1); }
}

.call-status {
  font-size: 15px;
  color: #cfcfe4;
  letter-spacing: 0.3px;
}

.call-transcript {
  min-height: 44px;
  text-align: center;
  color: #8f8fb0;
  font-size: 14px;
  padding: 0 12px;
  max-width: 340px;
}

.call-controls {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 10px;
}

.call-side-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #cfcfe4;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.call-side-btn.muted {
  background: rgba(255, 92, 138, 0.18);
  border-color: rgba(255, 92, 138, 0.5);
  color: #ff5c8a;
}

.end-call-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #ff6b6b, #e0384b);
  color: white;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(224, 56, 75, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}

.end-call-btn:active { transform: scale(0.92); }
.end-call-btn svg { width: 24px; height: 24px; }
