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

html, body { height: 100%; }
body { margin: 0; overflow-x: hidden; }
img, svg { max-width: 100%; height: auto; }

:root {
  --brand: #2563EB;
  --assistant-bg: #F1F5F9;
  --assistant-text: #0F172A;
  --error-bg: #FEE2E2;
  --error-text: #B91C1C;
}

.app-shell { min-height: 100vh; min-height: 100dvh; height: 100dvh; }
.chat-card { min-height: 0; }
@media (min-width: 640px) {
  .chat-card { height: min(860px, calc(100dvh - 3rem)); }
}

.header-accent {
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, #2563EB, #60A5FA);
}

.messages { scroll-behavior: smooth; overscroll-behavior: contain; }
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #E2E8F0; border-radius: 8px; }

/* Message rows */
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; animation: bubble-in .28s ease-out both; }
.msg--user { flex-direction: row-reverse; }
.msg__avatar {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9999px;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.msg__body { display: flex; flex-direction: column; min-width: 0; max-width: min(78%, 560px); }
.msg--user .msg__body { align-items: flex-end; }

.bubble {
  padding: 11px 15px; border-radius: 18px; font-size: 15px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.msg--assistant .bubble { background: var(--assistant-bg); color: var(--assistant-text); border-bottom-left-radius: 6px; }
.msg--user .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.msg--error .bubble {
  background: var(--error-bg); color: var(--error-text); border-bottom-left-radius: 6px;
  display: flex; gap: 8px; align-items: flex-start;
}
.msg--error .msg__avatar { background: var(--error-text); }

.msg__meta { margin-top: 4px; padding: 0 4px; font-size: 12px; color: #64748B; }

/* Typing indicator */
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 15px 16px; }
.typing span {
  width: 7px; height: 7px; border-radius: 9999px; background: #64748B;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Suggestion chips */
.suggestions { display: none; }
.suggestions.is-visible { display: flex; }
.chip {
  min-height: 40px; padding: 8px 14px; border-radius: 9999px;
  border: 1px solid #BFDBFE; background: #EFF6FF; color: #1D4ED8;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background-color .15s, border-color .15s;
  animation: bubble-in .3s ease-out both;
}
.chip:hover { background: #DBEAFE; border-color: #93C5FD; }
.chip:active { background: #BFDBFE; }
.chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 480px) { .suggestions { padding-left: 0; } }

.kbd {
  display: inline-block; padding: 0 5px; border: 1px solid #E2E8F0; border-bottom-width: 2px;
  border-radius: 5px; background: #F8FAFC; font-family: inherit; font-size: 11px; color: #475569;
}

.composer-input { field-sizing: content; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .messages { scroll-behavior: auto; }
}
