/**
 * LLM Chat - 样式文件
 * 
 * 设计风格：
 * - 深色模式为主
 * - Glassmorphism 效果
 * - 流畅的动画
 * - 响应式设计
 */

/* ============================================
   CSS 变量 - 设计令牌 (Ocean Depths Theme)
   ============================================ */
:root {
  /* 颜色系统 - Ocean Depths */
  --bg-primary: #1a2332;
  --bg-secondary: #213041;
  --bg-tertiary: #2a3d52;
  --bg-hover: #334a63;

  --text-primary: #f1faee;
  --text-secondary: #a8dadc;
  --text-muted: #6b8a99;

  --accent-primary: #2d8b8b;
  --accent-secondary: #a8dadc;
  --accent-gradient: linear-gradient(135deg, #2d8b8b 0%, #a8dadc 100%);

  --border-color: #3a4f66;
  --border-light: #4a5f76;

  --success-color: #22c55e;
  --error-color: #ef4444;
  --warning-color: #f59e0b;

  /* 尺寸 */
  --header-height: 60px;
  --input-height: 80px;
  --border-radius: 12px;
  --border-radius-sm: 8px;

  /* 动画 */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;

  /* 阴影 */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ============================================
   基础重置
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DejaVu Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

/* ============================================
   应用容器布局
   ============================================ */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ============================================
   设置弹窗 - 遮罩层
   ============================================ */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  backdrop-filter: blur(4px);
  animation: overlayFadeIn 0.2s ease;
}

.settings-overlay.hidden {
  display: none !important;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   设置弹窗 - 模态框
   ============================================ */
.settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-width: 1400px;
  height: 90vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  z-index: 201;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.25s ease;
}

.settings-modal.hidden {
  display: none !important;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.settings-modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
}

.close-sidebar-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.close-sidebar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Tab 导航栏 */
.settings-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  border-bottom: 3px solid transparent;
}

.tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--bg-secondary);
}

.tab-icon {
  font-size: 1.2rem;
}

.tab-label {
  font-family: 'DejaVu Sans', sans-serif;
}

/* Tab 内容区 */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* 底部保存区 */
.settings-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 表单分区样式 */
.form-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 14px;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
  margin-bottom: 3px;
  color: var(--text-primary);
}

.section-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* 预设按钮组 */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.preset-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 10px;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: border-color var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.form-group select {
  cursor: pointer;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.input-with-toggle {
  position: relative;
  display: flex;
}

.input-with-toggle input {
  flex: 1;
  padding-right: 40px;
}

.toggle-visibility-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.toggle-visibility-btn:hover {
  opacity: 1;
}

.save-btn {
  background: var(--accent-gradient);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.save-btn:active {
  transform: translateY(0);
}

.save-status {
  text-align: center;
  font-size: 0.85rem;
  min-height: 20px;
}

.save-status.success {
  color: var(--success-color);
}

.save-status.error {
  color: var(--error-color);
}

/* ============================================
   主题卡片
   ============================================ */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.theme-card {
  position: relative;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.theme-card:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.theme-card.active {
  border-color: var(--accent-primary);
  background: rgba(45, 139, 139, 0.1);
}

.theme-preview {
  display: flex;
  gap: 8px;
  height: 40px;
}

.color-swatch {
  flex: 1;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.theme-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-name {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
  color: var(--text-primary);
}

.theme-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.theme-check {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  background: var(--accent-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: bold;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.theme-card.active .theme-check {
  opacity: 1;
}

/* ============================================
   AI 角色按钮
   ============================================ */
.role-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.role-btn {
  flex: 1;
  min-width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.role-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.role-btn.active {
  background: rgba(var(--accent-primary-rgb, 59, 130, 246), 0.1);
  border-color: var(--accent-primary);
}

.role-icon {
  font-size: 1.5rem;
}

.role-name {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.role-btn.active .role-name {
  color: var(--accent-primary);
}

/* ============================================
   主内容区
   ============================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============================================
   顶部工具栏
   ============================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.header-btn.settings-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   消息显示区域
   ============================================ */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 欢迎消息 */
.welcome-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: 100%;
  color: var(--text-secondary);
  gap: 16px;
}

.welcome-message.hidden {
  display: none;
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 8px;
}

.welcome-message h2 {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
  color: var(--text-primary);
}

.welcome-message p {
  max-width: 400px;
}

.support-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 消息气泡 */
.message {
  display: flex;
  gap: 12px;
  max-width: 90%;
  animation: messageSlideIn 0.3s ease;
  position: relative;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--accent-gradient);
}

.message.assistant .message-avatar {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.message-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  max-width: 100%;
  overflow-wrap: break-word; /* 强制长单词换行 */
  word-break: break-word;    /* 兼容性 */
  min-width: 0;              /* Flexbox 溢出修复 */
}

.message.user .message-content {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* 消息操作按钮 */
.message-actions {
  position: absolute;
  bottom: 8px;
  right: 48px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}

.message:hover .message-actions {
  opacity: 1;
  pointer-events: auto;
}

.msg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.msg-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
  transform: scale(1.1);
}

.msg-action-btn:active {
  transform: scale(0.95);
}

.resend-btn {
  font-weight: bold;
}

/* 移动端：始终显示操作按钮 */
@media (max-width: 768px) {
  .message-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Markdown 内容样式 */
.message-content p {
  margin-bottom: 0.75em;
}

.message-content p:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  margin: 0.5em 0;
  padding-left: 1.5em;
}

.message-content li {
  margin: 0.25em 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 1em 0 0.5em;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
  margin-top: 0;
}

/* 代码块样式 */
.message-content pre {
  margin: 0.75em 0;
  padding: 0;
  background: #0d1117;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  overflow-x: auto; /* 关键：允许水平滚动 */
  max-width: 100%;  /* 关键：限制最大宽度，防止撑破父容器 */
}

/* 浅色主题代码块背景 */
body.light-theme .message-content pre {
  background: #f6f8fa;
  border-color: #d0d7de;
}

body.light-theme .message-content pre code {
  color: #24292f;
}

.message-content pre code {
  display: block;
  padding: 16px;
  overflow-x: auto; /* 双重保险 */
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre; /* 保持代码格式，不强制换行（出现滚动条） */
}

.message-content code {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.9em;
}

.message-content pre code {
  background: transparent;
  padding: 0;
}

.message-content blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 16px;
  margin: 0.75em 0;
  color: var(--text-secondary);
}

.message-content a {
  color: var(--accent-primary);
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

.message-content table {
  border-collapse: collapse;
  margin: 0.75em 0;
  width: 100%;
}

.message-content th,
.message-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.message-content th {
  background: var(--bg-tertiary);
}

/* markdown-body 内的表格（流水线阶段卡片、教学回复区域） */
.markdown-body table {
  border-collapse: collapse;
  margin: 0.75em 0;
  width: 100%;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-tertiary);
}

/* 加载动画 */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 错误消息 */
.message.error .message-content {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error-color);
  color: var(--error-color);
}

/* ============================================
   输入区域
   ============================================ */
.input-container {
  padding: 16px 20px 20px;
  background: transparent;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.input-wrapper:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(45, 139, 139, 0.15), var(--shadow-md);
}

/* 图片预览区域（内置在 wrapper 内） */
.input-wrapper .image-preview-container {
  padding: 12px 16px 0;
  border: none;
  background: transparent;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-wrapper .image-preview-container.hidden {
  display: none;
}

.input-wrapper .image-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.input-wrapper .image-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.input-wrapper .remove-image-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: var(--error-color);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.input-wrapper .remove-image-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

/* 文本输入区 */
.input-wrapper textarea {
  padding: 16px 20px 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  min-height: 48px;
}

.input-wrapper textarea:focus {
  outline: none;
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

/* 底部工具栏 */
.input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border-color);
  opacity: 0.8;
  transition: opacity 0.2s;
  gap: 12px;
}

.input-wrapper:focus-within .input-toolbar {
  opacity: 1;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex: 1;
  text-align: center;
}

/* 工具栏按钮 - ghost 风格 */
.toolbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.toolbar-btn svg {
  display: block;
}

/* 发送按钮 - 精致化 */
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  color: white;
  transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(45, 139, 139, 0.3);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg {
  display: block;
}

/* 停止按钮 */
.stop-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--error-color);
  color: white;
  transition: all 0.2s;
}

.stop-btn:hover {
  background: #dc2626;
  transform: scale(1.05);
}

.stop-btn svg {
  display: block;
}

.hidden {
  display: none !important;
}

/* 响应式 - 移动端 */
@media (max-width: 768px) {
  .input-container {
    padding: 12px 16px 16px;
  }

  .input-wrapper {
    border-radius: 12px;
  }

  .input-wrapper textarea {
    padding: 12px 16px 6px;
    min-height: 40px;
  }

  .toolbar-hint {
    display: none;
  }

  .input-toolbar {
    padding: 6px 10px;
  }
}

/* 多图预览容器样式 */
.image-preview-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  margin-bottom: 8px;
}

.image-preview {
  flex: 1;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
}

/* 单个预览项 */
.preview-item {
  position: relative;
  flex-shrink: 0;
}

.preview-item img {
  max-height: 80px;
  max-width: 120px;
  border-radius: var(--border-radius-sm);
  object-fit: cover;
  display: block;
}

/* 单个图片删除按钮 */
.remove-single-image-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--error-color);
  color: white;
  border: 2px solid var(--bg-tertiary);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  transition: all var(--transition-fast);
  opacity: 0;
}

.preview-item:hover .remove-single-image-btn {
  opacity: 1;
}

.remove-single-image-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

/* 移除全部按钮 */
.remove-image-btn {
  background: var(--error-color);
  color: white;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.remove-image-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

/* 消息中的多图容器 */
.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

/* 流水线日志样式优化 */
.stage-content {
    overflow: hidden; /* 防止内容溢出容器 */
}

.stage-content pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap; /* 允许换行，防止过长 */
  word-wrap: break-word;
}

.stage-content pre code {
  white-space: pre-wrap; /* 强制换行 */
  word-break: break-all; /* 允许在任意字符间换行 */
}

/* 消息中的图片 */
.message-image {
  max-width: 200px;
  max-height: 150px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: transform var(--transition-fast);
  object-fit: cover;
}

.message-image:hover {
  transform: scale(1.02);
}

/* ============================================
   流水线 Stepper 时间线
   ============================================ */
.pipeline-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-width: 320px;
}

/* 包含 pipeline 的消息固定宽度，防止展开/折叠时宽度跳动 */
.message:has(.pipeline-container) {
  width: 90%;
  max-width: 90%;
}

.message:has(.pipeline-container) .message-content {
  width: 100%;
  flex: 1;
}

/* 水平步骤条 */
.pipeline-stepper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 8px 8px;
  gap: 0;
  position: relative;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  z-index: 1;
}

/* 步骤图标圆圈 */
.step-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  transition: all 0.3s ease;
  position: relative;
  z-index: 2;
}

/* pending 状态 */
.stepper-step[data-status="pending"] .step-icon {
  opacity: 0.5;
  filter: grayscale(0.8);
}

/* active 状态 */
.stepper-step[data-status="active"] .step-icon {
  border-color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.15);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  animation: stepPulse 1.5s infinite ease-in-out;
  opacity: 1;
  filter: none;
}

/* completed 状态 */
.stepper-step[data-status="completed"] .step-icon {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  opacity: 1;
  filter: none;
}

.stepper-step[data-status="completed"] .step-icon::after {
  content: '✓';
  position: absolute;
  bottom: -2px;
  right: -4px;
  font-size: 0.65rem;
  background: #22c55e;
  color: white;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

@keyframes stepPulse {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.1);
  }
}

/* 步骤文字标签 */
.step-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.stepper-step[data-status="active"] .step-label {
  color: var(--accent-primary);
  font-weight: 600;
}

.stepper-step[data-status="completed"] .step-label {
  color: #22c55e;
}

/* 步骤间连接线 */
.step-connector {
  position: absolute;
  top: 18px;
  left: calc(50% + 22px);
  width: calc(100% - 44px);
  height: 2px;
  background: var(--border-color);
  z-index: 0;
  transition: background 0.3s ease;
}

.stepper-step:last-child .step-connector {
  display: none;
}

.stepper-step[data-status="completed"] .step-connector {
  background: #22c55e;
}

/* 诊断摘要徽章（stepper 下方） */
.step-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin-top: 2px;
}

.error-type-badge,
.strategy-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  white-space: nowrap;
}

/* 错误类型徽章颜色 */
.error-type-badge[data-type="correct"] {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.error-type-badge[data-type="slip"] {
  background: rgba(234, 179, 8, 0.15);
  color: #a16207;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.error-type-badge[data-type="conceptual"] {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-type-badge[data-type="malgorithm"] {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-type-badge[data-type="impasse"] {
  background: rgba(168, 85, 247, 0.15);
  color: #7c3aed;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* 教学策略徽章颜色 */
.strategy-badge[data-strategy="PRAISE"] {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.strategy-badge[data-strategy="DIRECT"] {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.strategy-badge[data-strategy="SOCRATIC"] {
  background: rgba(249, 115, 22, 0.15);
  color: #c2410c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.strategy-badge[data-strategy="SCAFFOLDED"] {
  background: rgba(168, 85, 247, 0.15);
  color: #7c3aed;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* 意图分析徽章 */
.intent-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  white-space: nowrap;
}

.intent-badge[data-intent="NEW_PROBLEM"] {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.intent-badge[data-intent="FOLLOW_UP"] {
  background: rgba(249, 115, 22, 0.15);
  color: #c2410c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.intent-badge[data-intent="CHITCHAT"] {
  background: rgba(156, 163, 175, 0.15);
  color: #6b7280;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

/* 角色徽章 */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.6;
  white-space: nowrap;
}

.role-badge[data-role="peer"] {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.role-badge[data-role="tutee"] {
  background: rgba(249, 115, 22, 0.15);
  color: #c2410c;
  border: 1px solid rgba(249, 115, 22, 0.3);
}

.role-badge[data-role="challenger"] {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.role-badge[data-role="instructor"] {
  background: rgba(59, 130, 246, 0.15);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.role-badge[data-role="mentor"] {
  background: rgba(168, 85, 247, 0.15);
  color: #7c3aed;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* ============================================
   阶段详情卡片
   ============================================ */
.stages-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-card {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
  transition: border-color 0.2s ease;
}

.stage-card.active {
  border-color: var(--accent-primary);
}

.stage-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: none;
  width: 100%;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.stage-header:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.stage-header .stage-title {
  flex: 1;
  text-align: left;
}

.stage-header .stage-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.stage-header .expand-arrow {
  font-size: 0.7rem;
  transition: transform var(--transition-fast);
  margin-left: 4px;
}

.stage-card:not(.collapsed) .expand-arrow {
  transform: rotate(180deg);
}

.stage-content {
  padding: 10px 14px;
  border-top: 1px solid var(--border-color);
  overflow: hidden;
}

.stage-card.collapsed .stage-content {
  display: none;
}

/* ============================================
   最终教学回复突出区域
   ============================================ */
.final-response-section {
  border-left: 3px solid var(--accent-primary);
  padding: 0;
  margin-top: 4px;
}

.final-response-section .response-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.06);
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}

.final-response-section .response-content {
  padding: 12px 14px;
}

/* ============================================
   参考答案折叠面板
   ============================================ */
.ground-truth-panel {
  margin-top: 16px;
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.ground-truth-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.9rem;
  gap: 8px;
  transition: all var(--transition-fast);
}

.ground-truth-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ground-truth-toggle .toggle-icon {
  font-size: 1.1rem;
}

.ground-truth-toggle .toggle-text {
  font-weight: 500;
}

.ground-truth-toggle .expand-icon {
  margin-left: auto;
  font-size: 0.8rem;
  transition: transform var(--transition-fast);
}

.ground-truth-panel:not(.collapsed) .expand-icon {
  transform: rotate(180deg);
}

.ground-truth-content {
  padding: 14px 16px;
  border-top: 1px dashed var(--border-color);
  background: rgba(99, 102, 241, 0.05);
  font-size: 0.95rem;
  line-height: 1.6;
}

.ground-truth-content.hidden {
  display: none;
}

/* 标准答案中的标题样式 */
.ground-truth-content h2 {
  font-size: 1rem;
  margin: 16px 0 8px;
  font-weight: 700;
  font-family: 'DejaVu Sans', sans-serif;
  color: var(--accent-primary);
}

.ground-truth-content h2:first-child {
  margin-top: 0;
}

/* 标准答案中的步骤列表 */
.ground-truth-content ol,
.ground-truth-content ul {
  margin: 8px 0;
  padding-left: 20px;
}

.ground-truth-content li {
  margin: 4px 0;
}

/* ============================================
   滚动条样式
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================
   响应式设计
   ============================================ */
@media (max-width: 768px) {
  .settings-modal {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }

  @keyframes modalSlideIn {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  /* Tab 导航 - 移动端只显示图标 */
  .settings-tabs {
    padding: 0;
  }

  .tab-btn {
    flex-direction: column;
    padding: 12px 8px;
    gap: 4px;
  }

  .tab-label {
    font-size: 0.7rem;
  }

  .tab-icon {
    font-size: 1.4rem;
  }

  /* 主题卡片 - 移动端单列 */
  .theme-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .message {
    max-width: 95%;
  }

  .header {
    padding: 0 12px;
  }

  .messages-container {
    padding: 12px;
  }

  .input-container {
    padding: 12px;
  }

  /* 移动端 Stepper */
  .pipeline-stepper {
    padding: 8px 4px 6px;
  }

  .step-icon {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  .step-connector {
    top: 15px;
    left: calc(50% + 18px);
    width: calc(100% - 36px);
  }

  .step-label {
    font-size: 0.65rem;
  }

  .step-badges {
    gap: 2px;
  }

  .error-type-badge,
  .strategy-badge {
    font-size: 0.6rem;
    padding: 0px 5px;
  }

  .stage-header {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .final-response-section .response-header {
    font-size: 0.8rem;
    padding: 6px 12px;
  }

  .final-response-section .response-content {
    padding: 10px 12px;
  }

  /* 移动端折叠面板 */
  .ground-truth-panel {
    margin-top: 12px;
  }

  .ground-truth-toggle {
    padding: 8px 12px;
  }

  .ground-truth-content {
    padding: 12px 14px;
  }
}

/* ============================================
   打印样式
   ============================================ */
@media print {

  .settings-overlay,
  .settings-modal,
  .header,
  .input-container {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .messages-container {
    overflow: visible;
    height: auto;
  }

  /* 打印时展开折叠面板 */
  .ground-truth-content.hidden {
    display: block !important;
  }

  .ground-truth-toggle {
    display: none;
  }
}