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

:root {
  --bg:          #FAF7F2;
  --primary:     #5C4A3A;
  --accent:      #8B6B4A;
  --user-bubble: #5C4A3A;
  --app-bubble:  #FFFFFF;
  --soft:        #F5F0E8;
  --text:        #2C2C2C;
  --muted:       #7A7A7A;
  --input-bg:    #FFFFFF;
  --border:      #E8E0D4;
  --shadow:      0 2px 8px rgba(92,74,58,0.10);
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ── Top bar ─────────────────────────────────────────── */

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  color: var(--primary);
  font-weight: normal;
  letter-spacing: 0.01em;
}

/* ── Chat area ───────────────────────────────────────── */

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* ── Bubbles ─────────────────────────────────────────── */

.bubble-row {
  display: flex;
  max-width: 100%;
}

.bubble-row.app {
  justify-content: flex-start;
}

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

.bubble {
  max-width: min(480px, 85%);
  padding: 13px 16px;
  border-radius: 18px;
  line-height: 1.65;
  font-size: 0.97rem;
}

.bubble.app {
  background: var(--app-bubble);
  color: var(--text);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}

.bubble.user {
  background: var(--user-bubble);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.bubble-intro-sub {
  margin-top: 8px;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Typing indicator ────────────────────────────────── */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 16px;
  background: var(--app-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
  width: fit-content;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Response cards ──────────────────────────────────── */

.cards-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(480px, 85%);
}

.response-card {
  background: var(--app-bubble);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
}

.card-label {
  font-size: 0.72rem;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.card-text {
  font-size: 0.96rem;
  color: var(--text);
  line-height: 1.6;
  padding-right: 36px;
}

.copy-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
}

.copy-btn:hover {
  color: var(--accent);
  background: var(--soft);
}

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

/* ── Prayer bubble ───────────────────────────────────── */

.prayer-bubble {
  background: var(--soft);
  border-radius: 14px;
  padding: 12px 16px;
  font-style: italic;
  color: var(--primary);
  font-size: 0.93rem;
  max-width: min(480px, 85%);
  line-height: 1.6;
}

/* ── Feedback bubble ─────────────────────────────────── */

.feedback-bubble {
  background: var(--app-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  max-width: min(480px, 85%);
  font-size: 0.93rem;
}

.feedback-q {
  color: var(--text);
  margin-bottom: 10px;
}

.feedback-btns {
  display: flex;
  gap: 8px;
}

.feedback-btn {
  background: var(--soft);
  border: 1.5px solid var(--border);
  color: var(--primary);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.feedback-btn:hover {
  background: var(--border);
}

.feedback-followup {
  margin-top: 12px;
}

.feedback-followup label {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 6px;
  line-height: 1.45;
}

.feedback-followup textarea {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  resize: vertical;
  min-height: 70px;
  outline: none;
}

.feedback-followup textarea:focus {
  border-color: var(--accent);
}

.feedback-submit-btn {
  margin-top: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.88rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.feedback-submit-btn:hover { opacity: 0.85; }

.feedback-thanks {
  color: var(--accent);
  font-size: 0.9rem;
  margin-top: 8px;
}

/* ── Crisis bubble ───────────────────────────────────── */

.crisis-bubble {
  background: var(--app-bubble);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  padding: 16px 18px;
  max-width: min(480px, 85%);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.75;
  white-space: pre-wrap;
}

/* ── Input bar ───────────────────────────────────────── */

.input-bar {
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

#msg-input {
  flex: 1;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 22px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 0.97rem;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

#msg-input:focus {
  border-color: var(--accent);
}

#msg-input::placeholder {
  color: var(--muted);
}

#send-btn {
  flex-shrink: 0;
  background: var(--primary);
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s;
  color: #fff;
}

#send-btn:hover { opacity: 0.85; }
#send-btn:disabled { opacity: 0.4; cursor: default; }

#send-btn svg {
  width: 18px;
  height: 18px;
}

/* ── Scrollbar ───────────────────────────────────────── */

.chat-area::-webkit-scrollbar {
  width: 4px;
}
.chat-area::-webkit-scrollbar-track {
  background: transparent;
}
.chat-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* ── Responsive ──────────────────────────────────────── */

@media (min-width: 600px) {
  .chat-area {
    padding: 24px 24px 16px;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
  }

  .input-bar {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
  }

  .bubble,
  .prayer-bubble,
  .feedback-bubble,
  .crisis-bubble,
  .cards-wrap {
    max-width: 480px;
  }
}
