:root {
  --primary: #C75F96;
  --primary-dark: #b05083;
  --bg: #f5f5f5;
  --bot-bubble: #ffffff;
  --user-bubble: #C75F96;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── App Shell ─────────────────────────── */
#app {
  width: 100%;
  max-width: 640px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* ─── Progress Bar ───────────────────────── */
.progress-bar-container {
  width: 100%;
  height: 4px;
  background: rgba(0,0,0,0.06);
  position: absolute;
  top: 0; left: 0;
  z-index: 100;
}
.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.4s ease;
}

/* ─── Chat Scroll ────────────────────────── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px 14px 140px;
  scroll-behavior: smooth;
}
.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 4px; }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Message Row ────────────────────────── */
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 90%;
  animation: fadeUp 0.22s ease-out forwards;
}
.message-row.bot  { align-self: flex-start; }
.message-row.user { align-self: flex-end; flex-direction: row-reverse; }

/* ─── Avatar ─────────────────────────────── */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-bottom: 2px;
}

/* ─── Bubbles ────────────────────────────── */
.bubble {
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.bot-bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  padding: 10px 14px;
}
.user-bubble {
  background: var(--user-bubble);
  color: #fff;
  padding: 10px 16px;
  border-bottom-right-radius: 4px;
}

/* ─── Chat text, image, video, iframe ───── */
.chat-text { display: block; }

.chat-image {
  width: 100%;
  max-width: 340px;
  border-radius: 10px;
  display: block;
}

.chat-video {
  width: 100%;
  max-width: 340px;
  border-radius: 10px;
  display: block;
  background: #000;
}

.chat-iframe {
  display: block;
  background: transparent;
}

/* ─── Audio Player (WhatsApp style) ─────── */
.audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 260px;
  padding: 8px 0;
}

.play-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.play-btn:hover { background: var(--primary-dark); transform: scale(1.04); }

.waveform {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  position: relative;
  overflow: hidden;
}

.wf-bar {
  flex: 1;
  background: #d4d4d8;
  border-radius: 2px;
  transition: background 0.2s;
}

/* progress overlay as a clip path trick */
.wf-progress {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(199,95,150,0.7) 0%, transparent 100%);
  pointer-events: none;
  transition: width 0.1s linear;
}

.audio-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 32px;
}

.audio-error .play-btn { background: #aaa; cursor: not-allowed; }

/* ─── Typing Indicator ───────────────────── */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 2px 4px;
}
.typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingPulse 1.4s infinite both;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ─── Choices Container ──────────────────── */
.choices-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 14px 16px;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
  max-width: 640px;
  margin: 0 auto;
  box-shadow: 0 -4px 14px rgba(0,0,0,0.05);
}

.choice-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 13px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(199,95,150,0.25);
  font-family: var(--font);
}
.choice-btn:hover  { opacity: 0.9; transform: translateY(-1px); }
.choice-btn:active { transform: translateY(0); }

/* ─── Text Input Footer ──────────────────── */
.chat-input-footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 12px 14px 16px;
  background: #fff;
  border-top: 1px solid var(--border);
  z-index: 50;
  box-shadow: 0 -4px 14px rgba(0,0,0,0.04);
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input {
  flex: 1;
  background: #fff;
  border: 1px solid #d4d4d8;
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.chat-input::placeholder { color: #a1a1aa; }
.chat-input:focus { border-color: var(--primary); }

.chat-send-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.2s;
  white-space: nowrap;
}
.chat-send-btn:hover { background: var(--primary-dark); }

/* ─── Animations ─────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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