:root {
  --bg: #FBEAF0;
  --text: #4B1528;
  --accent: #D4537E;
  --secondary: #993556;
  --bubble: #FFFFFF;
  --online: #2FB36D;
  --line: rgba(153, 53, 86, 0.14);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* In-app browser hint */
.inapp {
  background: var(--secondary);
  color: #fff;
  font-size: 14px;
  padding: 10px 16px;
  text-align: center;
}

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(251, 234, 240, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.avatar-wrap { position: relative; flex: none; }
.avatar {
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.name { font-weight: 650; font-size: 17px; line-height: 1.2; }
.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--secondary);
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--online); }

/* Thread */
.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
}
.day {
  align-self: center;
  font-size: 12px;
  color: var(--secondary);
  opacity: 0.8;
  margin-bottom: 8px;
}

.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 20px;
  overflow-wrap: anywhere;
}
.msg.in {
  align-self: flex-start;
  background: var(--bubble);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 1px rgba(75, 21, 40, 0.06);
  transform-origin: bottom left;
}
.msg.out {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
  transform-origin: bottom right;
}
.msg.out + .msg.in, .msg.in + .msg.out, .chips { margin-top: 8px; }

/* Typing dots */
.typing { display: inline-flex; gap: 4px; padding: 15px 16px; }
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
  opacity: 0.35;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

/* Reply chips, styled like sent messages */
.chips {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border-radius: 20px;
  border-bottom-right-radius: 6px;
  border: 2px solid var(--accent);
  cursor: pointer;
  transform-origin: bottom right;
  transition: transform 0.12s ease, background-color 0.12s ease;
}
.chip.fill { background: var(--accent); color: #fff; }
.chip.fill:hover { background: var(--secondary); border-color: var(--secondary); }
.chip.outline { background: transparent; color: var(--secondary); }
.chip.outline:hover { background: rgba(212, 83, 126, 0.08); }
.chip:active { transform: scale(0.97); }
.chip:focus-visible { outline: 3px solid var(--secondary); outline-offset: 2px; }

/* Animations */
.pop { animation: pop 0.34s cubic-bezier(0.2, 0.9, 0.3, 1.25) both; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.6); }
  to   { opacity: 1; transform: none; }
}
@keyframes bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}
@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%, 60%, 100% { opacity: 0.35; }
  30%           { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .pop { animation: fade 0.2s ease-out both; }
  .typing span { animation-name: pulse; }
  .chip, .chip:active { transition: none; transform: none; }
}

