.message-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 20px 20px; /* 右侧留空给滚动条 */
  background: linear-gradient(180deg, #f5f7fa 0%, #fafbfc 100%);
  min-height: 0; /* 重要：让flex容器可以正确计算滚动 */
  max-height: 100%; /* 限制最大高度 */
  position: relative;
  scroll-behavior: smooth; /* 平滑滚动 */
}

.message-item {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease-in;
  max-width: 100%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  flex-shrink: 0;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.message-body {
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  max-width: 85%;
  word-wrap: break-word;
  transition: box-shadow 0.2s ease;
}

.message-body:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.message-user .message-body {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
}

.message-user .user-message-text {
  color: white;
}

.message-assistant .message-body {
  background: white;
  border: 1px solid #e8e8e8;
}

.user-message-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: #262626;
}

.assistant-message-text {
  line-height: 1.8;
  color: #262626;
}

/* Markdown样式 */
.assistant-message-text h1,
.assistant-message-text h2,
.assistant-message-text h3,
.assistant-message-text h4,
.assistant-message-text h5,
.assistant-message-text h6 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-weight: 600;
}

.assistant-message-text h1 {
  font-size: 24px;
}

.assistant-message-text h2 {
  font-size: 20px;
}

.assistant-message-text h3 {
  font-size: 18px;
}

.assistant-message-text p {
  margin-bottom: 12px;
}

.assistant-message-text ul,
.assistant-message-text ol {
  margin-left: 24px;
  margin-bottom: 12px;
}

.assistant-message-text li {
  margin-bottom: 4px;
}

.assistant-message-text code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  color: #d73a49;
}

.assistant-message-text pre {
  margin: 12px 0;
  border-radius: 6px;
  overflow: hidden;
}

.assistant-message-text blockquote {
  border-left: 4px solid #ddd;
  padding-left: 16px;
  margin-left: 0;
  color: #666;
  font-style: italic;
}

.assistant-message-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.assistant-message-text th,
.assistant-message-text td {
  border: 1px solid #ddd;
  padding: 8px 12px;
  text-align: left;
}

.assistant-message-text th {
  background: #f5f5f5;
  font-weight: 600;
}

/* 流式输出动画 */
.assistant-message-text.streaming {
  position: relative;
}

.cursor-blink {
  display: inline-block;
  animation: blink 1s infinite;
  color: #1890ff;
  margin-left: 2px;
}

@keyframes blink {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0;
  }
}

.message-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
}

/* 滚动条样式 - 优化 */
.message-list::-webkit-scrollbar {
  width: 6px;
}

.message-list::-webkit-scrollbar-track {
  background: transparent;
}

.message-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
  transition: background 0.2s;
}

.message-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.35);
}

