/* ── Chat Area ──────────────────────────────── */
#chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Scrollbar — desktop */
#chat::-webkit-scrollbar {
  width: 4px;
}
#chat::-webkit-scrollbar-track {
  background: transparent;
}
#chat::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ── Welcome Screen ─────────────────────────── */
#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  min-height: 100%;
  padding: 24px 16px;
  animation: fadeUp 0.5s ease both;
}

#welcome-screen.hidden {
  display: none;
}

.welcome-orb {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  margin-bottom: 18px;
  box-shadow: 0 8px 32px rgba(79, 110, 247, 0.3);
}

#welcome-screen h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

#welcome-screen p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 320px;
  margin-bottom: 28px;
}

.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

.suggestion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.suggestion-card:active,
.suggestion-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.sug-icon {
  font-size: 1.3rem;
  margin-bottom: 8px;
  display: block;
}

.sug-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 3px;
  color: var(--text);
}

.sug-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ── Messages ───────────────────────────────── */
.message {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: fadeUp 0.25s ease both;
  max-width: 100%;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.bot-avatar {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.7rem;
  flex-shrink: 0;
  align-self: flex-end;
}

.message-bubble {
  max-width: min(72%, 400px);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
}

.message.user .message-bubble {
  background: var(--msg-user-bg);
  color: var(--msg-user-text);
  border-bottom-right-radius: 5px;
}

.message.assistant .message-bubble {
  background: var(--msg-bot-bg);
  color: var(--msg-bot-text);
  border-bottom-left-radius: 5px;
}

/* wide widgets inside assistant bubble */
.message.assistant .message-bubble:has(.rich-widget) {
  max-width: min(92%, 520px);
  padding: 0;
  background: transparent;
}

/* ── Scroll to bottom ───────────────────────── */
#scroll-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 10;
}

#scroll-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Typing Indicator ───────────────────────── */
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 4px;
}

.typing-dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: boing 1.3s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.3s;
}
.typing-dot:nth-child(2) {
  animation-delay: -0.15s;
}

/* ── Input Area ─────────────────────────────── */
.input-zone {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  padding-bottom: calc(10px + var(--safe-bottom));
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}

#input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  line-height: 1.4;
  min-height: 36px;
  resize: none;
}

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

.input-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

#mic-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#mic-btn.listening {
  background: var(--error);
  color: white;
  animation: pulse 1.5s infinite;
}

#send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--primary);
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

#send-btn:active {
  transform: scale(0.93);
}

#send-btn:hover {
  background: var(--primary-dark);
}

.footer-note {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Mobile & Desktop Chat Tweaks ──────────────────────────── */
@media (max-width: 480px) {
  .message-bubble {
    max-width: 84%;
  }
  .message.assistant .message-bubble:has(.rich-widget) {
    max-width: 96%;
  }
  .suggestions-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

@media (min-width: 700px) {
  .message-bubble {
    max-width: 60%;
  }
}