/* Message list: runs, dividers, typing, receipts, call events, chip. */

#thread-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

#thread-list {
  display: flex;
  flex-direction: column;
  padding: 14px 12px 8px;
  min-height: 100%;
  justify-content: flex-end;
}

@media (min-width: 900px) {
  #thread-list {
    max-width: var(--thread-max);
    margin: 0 auto;
    padding: 14px 24px 8px;
    width: 100%;
  }
}

/* ── Day dividers ────────────────────────────────────────────────────── */

.day-divider {
  text-align: center;
  font-size: 11px;
  color: var(--text-2);
  margin: 6px 0 12px;
}
.day-divider b {
  font-weight: 600;
}

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

.msg-row {
  display: flex;
  margin-bottom: var(--run-gap);
}
.msg-row.run-end {
  margin-bottom: var(--group-gap);
}
.msg-row.in {
  justify-content: flex-start;
}
.msg-row.out {
  justify-content: flex-end;
}

.bubble {
  max-width: var(--bubble-max);
  padding: var(--bubble-pad);
  font-size: var(--bubble-font);
  line-height: var(--bubble-line);
  border-radius: var(--bubble-r);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  min-width: 0;
}
.in .bubble {
  background: var(--bubble-in);
  color: var(--text-1);
}
.out .bubble {
  background: var(--accent);
  color: var(--on-accent);
}
/* Tail corner on the last bubble of a run */
.in.run-end .bubble,
.in.tail .bubble {
  border-radius: var(--bubble-r) var(--bubble-r) var(--bubble-r) var(--bubble-tail-r);
}
.out.run-end .bubble,
.out.tail .bubble {
  border-radius: var(--bubble-r) var(--bubble-r) var(--bubble-tail-r) var(--bubble-r);
}

.msg-row.failed .bubble {
  opacity: 0.55;
}

/* Streaming assistant bubble that is about to become a voice note */
.bubble.note-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
}
.bubble.note-pending .icon {
  font-size: 16px;
  color: var(--accent);
}
.bubble.note-pending .pending-dots {
  display: inline-flex;
  gap: 3px;
}
.bubble.note-pending .pending-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-pulse 1.2s ease-in-out infinite;
}
.bubble.note-pending .pending-dots i:nth-child(2) {
  animation-delay: 0.18s;
}
.bubble.note-pending .pending-dots i:nth-child(3) {
  animation-delay: 0.36s;
}

/* ── Studio photos ───────────────────────────────────────────────────── */

.bubble.photo {
  padding: 4px;
  background: var(--bubble-in, rgba(255, 255, 255, 0.06));
}
.bubble.photo img {
  display: block;
  width: min(62vw, 240px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 14px;
  cursor: pointer;
}
.bubble.photo.photo-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
  padding: 10px 14px;
}
.bubble.photo.photo-pending .photo-cam {
  font-size: 15px;
}
.bubble.photo.photo-pending .pending-dots {
  display: inline-flex;
  gap: 3px;
}
.bubble.photo.photo-pending .pending-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-pulse 1.2s ease-in-out infinite;
}
.bubble.photo.photo-pending .pending-dots i:nth-child(2) {
  animation-delay: 0.18s;
}
.bubble.photo.photo-pending .pending-dots i:nth-child(3) {
  animation-delay: 0.36s;
}
.bubble.photo.photo-failed {
  color: var(--text-3);
  font-size: 13px;
  padding: 10px 14px;
}
.typing-bubble .typing-cam {
  margin-left: 6px;
  font-size: 13px;
  opacity: 0.8;
}

.photo-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.photo-overlay img {
  max-width: 96vw;
  max-height: 96vh;
  border-radius: 8px;
}

/* ── Receipts ────────────────────────────────────────────────────────── */

.receipt {
  align-self: flex-end;
  font-size: 11px;
  color: var(--text-2);
  margin: 3px 4px 12px 0;
}
.receipt.not-delivered {
  color: var(--danger);
}

/* ── Call event rows ─────────────────────────────────────────────────── */

.call-event {
  text-align: center;
  font-size: 11px;
  color: var(--text-2);
  margin: 8px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.call-event .icon {
  font-size: 13px;
  color: var(--text-3);
}

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

.typing-row {
  display: flex;
  justify-content: flex-start;
  margin-bottom: var(--group-gap);
}
.typing-bubble {
  background: var(--bubble-in);
  padding: 11px 15px;
  border-radius: var(--bubble-r) var(--bubble-r) var(--bubble-r) var(--bubble-tail-r);
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-bubble i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-pulse 1.2s ease-in-out infinite;
}
.typing-bubble i:nth-child(2) {
  background: var(--text-2);
  animation-delay: 0.18s;
}
.typing-bubble i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes typing-pulse {
  0%,
  60%,
  100% {
    opacity: 0.45;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .typing-bubble i,
  .bubble.note-pending .pending-dots i {
    animation: none;
  }
}

/* ── New-message chip ────────────────────────────────────────────────── */

#new-msg-chip {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: var(--hairline-w) solid var(--hairline);
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
  border-radius: 16px;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-float);
  z-index: 4;
  min-height: 32px;
}
#new-msg-chip .icon {
  font-size: 14px;
  color: var(--accent);
}

/* Wrapper so the chip anchors to the scroller, above the composer */
.thread-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Loading older messages spinner row */
.paging-row {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 0 10px;
}

/* Empty state */
.thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13px;
  padding: 40px 24px;
  text-align: center;
}
.thread-empty .empty-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-disc);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 2px;
}
.thread-empty .empty-title {
  color: var(--text-2);
  font-size: 14px;
}
