/* --- Chat Area --- */
.chat-area {
  flex-grow: 1;
  padding: var(--padding-md) 24px; /* 调整内边距 */
  padding-bottom: calc(var(--padding-md) + 50px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: transparent; /* Removed glass effect, will inherit from page-container */
  position: relative;
}

.chat-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0; /* 移除高度以隐藏渐变 */
  background: none;
  pointer-events: none;
}

.chat-output {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Message Styling --- */
.message-group {
  display: flex;
  gap: 12px; /* 减小间距 */
  max-width: 90%; /* 略微调整最大宽度 */
  align-items: flex-start;
  margin-bottom: var(--padding-md); /* 调整外边距 */
  animation: messageSlideIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
  width: 40px; /* 减小头像尺寸 */
  height: 40px;
  border-radius: var(--radius-full); /* 参考图2，方形圆角头像 */
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: 500;
  font-size: 0.9em;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08); /* 调整阴影 */
  transition: var(--transition-fast);
}

.message-avatar:hover { transform: scale(1.05); }

.ai-avatar {
  /* 统一玻璃效果 */
  background: var(--unified-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--unified-border);
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.1);
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.3), 0 2px 4px rgba(0,0,0,0.1);
}

.user-avatar {
  background: var(--accent);
  color: var(--button-text);
  border: 1px solid var(--accent-hover);
}

.ai-content-wrapper {
  display: flex;
  align-items: flex-start;
  gap: var(--padding-sm);
  flex-grow: 1;
  max-width: calc(100% - 42px - var(--padding-sm));
  position: relative;
}

.message-bubble {
  padding: 16px var(--padding-md);
  border-radius: var(--radius-lg);
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  position: relative;
  max-width: 100%;
  border: none; /* 确保没有边框 */
  outline: none; /* 移除焦点边框 */
  font-size: 1em; /* 调整字体大小 */
  line-height: 1.6;
  flex-grow: 1;
  cursor: pointer;
  transition: var(--transition-normal);
  /* backdrop-filter: blur(8px); */
  /* -webkit-backdrop-filter: blur(8px); */
  position: relative;
  overflow: hidden;
}





.ai-message-group { align-self: flex-start; }
.ai-message-group .message-bubble {
  /* 统一玻璃效果 */
  background: var(--unified-glass);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--unified-border);
  box-shadow: 
    inset 0px 1px 2px rgba(255, 255, 255, 0.35), 
    0 8px 24px rgba(0,0,0,0.12);
  /* 增强聊天文字对比度 */
  color: var(--text-primary); /* 使用深色文字变量 */
  text-shadow: 0 0 1px rgba(255,255,255,0.8); /* 添加白色阴影增强可读性 */
  border-radius: var(--radius-lg);
  transition: all 0.3s ease; /* Add transition for hover */
}

.ai-message-group .message-bubble:hover {
  transform: translateY(-2px) scale(1.01);
  background: var(--unified-glass);
  opacity: 0.9;
  box-shadow:
    inset 0px 1px 3px rgba(255, 255, 255, 0.4),
    0 12px 28px rgba(0,0,0,0.15);
}

.user-message-group {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.user-message-group .message-bubble {
  background: transparent; /* 用户消息透明背景 */
  color: var(--accent);
  border: none; /* 移除边框 */
  border-radius: var(--radius-lg);
  box-shadow: none; /* 移除阴影 */
}

.user-message-group .message-bubble:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.2), 0 2px 8px rgba(0, 123, 255, 0.15);
}

.message-bubble p {
  margin: 0 0 var(--padding-md) 0;
  text-align: justify;
  text-justify: inter-word;
  font-weight: 400;
  letter-spacing: 0.3px;
}

.message-bubble p:last-child { margin-bottom: 0; }

.message-tip {
  font-size: 0.9em; /* 增加字体大小 */
  font-weight: 600; /* 增加字体重量，更显眼 */
  opacity: 0.85; /* 增加不透明度 */
  margin-top: var(--padding-sm);
  padding-top: var(--padding-sm);
  font-style: normal; /* 移除斜体，更正式 */
  color: var(--text-primary); /* 使用主要文字颜色 */
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5); /* 增加阴影效果 */
}

/* Make initial instruction/warning text visible with proper contrast */

/* --- Overrides (2025-06-30): Hide avatars and use dashed border for AI replies --- */
.message-avatar {
  display: none !important;
}

.ai-message-group .message-bubble {
  border: 1.5px dashed var(--unified-border) !important;
}

.ai-message-group .message-bubble p:first-child {
  color: rgba(0, 0, 0, 0.9); /* 增加对比度 */
  font-weight: 700; /* 更粗的字体重量，更显眼 */
  font-size: 1.05em; /* 增加字体大小 */
  text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7); /* 增强阴影效果 */
}
