/* Agent conversation surface: message bubbles + live streaming.
   Composer/empty-state chrome lives in shell.css; this file is the thread. */

.agent {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-height: 60vh;
}

.agent__messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-3);
  padding-block: var(--space-2);
}

/* Keep the composer within reach as the thread grows. */
.agent .composer {
  position: sticky;
  bottom: var(--space-3);
  z-index: 1;
}

/* One message */
.msg {
  display: flex;
}

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

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

.msg__bubble {
  max-width: min(80%, 42rem);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-bubble);
  line-height: var(--leading-body, 1.5);
  overflow-wrap: anywhere;
}

.msg--user .msg__bubble {
  background: var(--color-accent);
  color: #fff;
  white-space: pre-wrap;
  border-bottom-right-radius: var(--radius-control);
}

.msg--assistant .msg__bubble {
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-line);
  border-bottom-left-radius: var(--radius-control);
}

/* Plain-text streaming bubble — Markdown is rendered only on the final message. */
.msg__bubble--streaming {
  white-space: pre-wrap;
}

.msg__bubble--error {
  background: var(--color-danger-tint);
  color: var(--color-danger);
}

/* Rendered Markdown inside an assistant bubble */
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 var(--space-2); }
.markdown ul,
.markdown ol { margin: var(--space-2) 0; padding-inline-start: var(--space-5); }
.markdown li { margin-block: var(--space-1); }
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 { margin: var(--space-3) 0 var(--space-2); font-size: var(--text-body); font-weight: 700; }
.markdown a { color: var(--color-accent-strong); text-decoration: underline; }
.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-control);
}
.markdown pre {
  background: var(--color-bg);
  padding: var(--space-3);
  border-radius: var(--radius-control);
  overflow-x: auto;
}
.markdown pre code { background: none; padding: 0; }
.markdown blockquote {
  margin: var(--space-2) 0;
  padding-inline-start: var(--space-3);
  border-inline-start: 3px solid var(--color-line);
  color: var(--color-muted);
}

/* Thinking indicator */
.dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: agent-dot 1s ease-in-out infinite;
}

.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes agent-dot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .dots span {
    animation: none;
  }
}
