.session-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  scroll-behavior: smooth;
}

#messages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#session-status:not(:empty) {
  margin-top: -0.25rem;
}

#session-status:empty {
  display: none;
}

.session-message {
  display: flex;
  gap: 0.75rem;
  max-width: 100%;
}

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

.session-message--user .session-message__bubble {
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 0.25rem;
}

.session-message--assistant .session-message__bubble,
.session-message--system .session-message__bubble,
.session-message--error .session-message__bubble {
  background: var(--muted);
  color: var(--foreground);
  border-bottom-left-radius: 0.25rem;
}

.session-message--error .session-message__bubble {
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, transparent);
}

.session-message__avatar {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 9999px;
  background: var(--muted);
  display: grid;
  place-items: center;
  color: var(--muted-foreground);
}

.session-message__avatar svg {
  width: 1rem;
  height: 1rem;
}

.session-message--user .session-message__avatar {
  display: none;
}

.session-message__body {
  max-width: min(85%, 42rem);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.session-message--user .session-message__body {
  align-items: flex-end;
}

.session-message__label {
  margin-bottom: 0.375rem;
  padding: 0 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  font-weight: 500;
}

.session-message--user .session-message__label {
  text-align: right;
}

.session-message__bubble {
  width: fit-content;
  max-width: 100%;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}

.session-message__content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.session-message__content--markdown {
  color: #2a2e35;
  font-size: 15px;
  line-height: 1.6;
  text-wrap: pretty;
  white-space: normal;
}

.session-message__content--markdown > *:first-child {
  margin-top: 0;
}

.session-message__content--markdown > *:last-child {
  margin-bottom: 0;
}

.session-message__stream-preview > *:first-child {
  margin-top: 0;
}

.session-message__stream-preview > *:last-child {
  margin-bottom: 0;
}

.session-message__content--markdown p,
.session-message__content--markdown blockquote {
  margin: 0 0 13px;
}

.session-message__content--markdown strong,
.session-message__content--markdown b {
  color: #15181c;
  font-weight: 600;
}

.session-message__content--markdown ul,
.session-message__content--markdown ol {
  margin: 2px 0 12px;
}

.session-message__content--markdown ul {
  list-style: none;
  padding-left: 0;
}

.session-message__content--markdown ol {
  padding-left: 1.35rem;
}

.session-message__content--markdown ul li {
  position: relative;
  padding-left: 15px;
}

.session-message__content--markdown ul li::before {
  content: "";
  position: absolute;
  top: 0.72em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 9999px;
  background: #b4b8bf;
}

.session-message__content--markdown li + li {
  margin-top: 9px;
}

.session-message__content--markdown pre,
.session-message__content--markdown table {
  margin: 4px 0 18px;
}

.session-message__content--markdown code {
  padding: 0.1rem 0.25rem;
  border-radius: 0.25rem;
  background: rgb(0 0 0 / 0.06);
  font-size: 0.875em;
}

.session-message__content--markdown pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgb(0 0 0 / 0.08);
}

.session-message__content--markdown pre code {
  padding: 0;
  background: transparent;
  font-size: 0.875rem;
}

.session-message__content--markdown blockquote {
  padding-left: 0.75rem;
  border-left: 3px solid color-mix(in srgb, var(--muted-foreground) 35%, transparent);
  color: #4b5563;
}

.session-message__content--markdown table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.session-message__content--markdown th,
.session-message__content--markdown td {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
}

.session-message__content--markdown a {
  color: #2b5cb8;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.session-message__time {
  margin-top: 0.375rem;
  padding: 0 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
}

.session-message--user .session-message__time {
  text-align: right;
}

.session-message--thinking .session-message__avatar {
  animation: thinking-pulse 2s ease-in-out infinite;
}

.session-thinking__bubble,
.session-thinking__inline {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
}

.session-thinking__bubble {
  min-width: 6.5rem;
}

.session-thinking__inline {
  gap: 7px;
}

.session-thinking__inline::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 9999px;
  background: #1f8a5b;
  animation: softPulse 1.8s ease-in-out infinite;
}

.session-thinking__text {
  color: #6b7280;
  font-size: 11.5px;
  line-height: 1.4;
}

.session-thinking__dots {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  height: 1rem;
  padding-left: 0.125rem;
}

.session-thinking__dots span {
  width: 3px;
  height: 3px;
  border-radius: 9999px;
  background: #aab0ba;
  animation: blink 1.2s infinite ease-in-out both;
}

.session-thinking__dots span:nth-child(1) {
  animation-delay: 0s;
}

.session-thinking__dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.session-thinking__dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes thinking-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-0.35rem);
    opacity: 1;
  }
}

@keyframes thinking-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.55;
  }
}

@keyframes softPulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 0.25;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .session-messages {
    padding: 1rem 0.75rem;
  }

  .session-message__body {
    max-width: 92%;
  }
}
