/* ============================================================
   AI 投资辩论 — 群聊界面样式
   ============================================================ */

:root {
  /* 角色颜色 */
  --color-tech: #00bcd4;
  --color-fund: #4caf50;
  --color-sent: #ff9800;
  --color-risk: #f44336;
  --color-cio:  #0088fe;
  --color-sec:  #607d8b;
  --color-gen:  #9c27b0;
  --color-user: #1976d2;

  /* 基础色调 */
  --bg-primary: #f0f2f5;
  --bg-sidebar: #ffffff;
  --bg-chat: #f0f2f5;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #666;
  --text-muted: #999;
  --border-color: #e8e8e8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   布局
   ============================================================ */

.app {
  display: flex;
  height: 100vh;
}

/* ============================================================
   侧边栏
   ============================================================ */

.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 10;
}

.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-dolphin {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--color-cio), var(--color-tech));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-new-chat {
  width: 100%;
  height: 38px;
  border: 1px dashed var(--border-color);
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-new-chat:hover {
  background: var(--color-cio);
  color: white;
  border-color: var(--color-cio);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.session-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.2s;
}

.session-item:hover {
  background: var(--bg-primary);
}

.session-item.active {
  background: #e6f4ff;
}

.session-item .topic {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.session-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-item .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.session-item .status-dot.running {
  background: var(--color-fund);
  animation: pulse 1.5s infinite;
}

.session-item .status-dot.done {
  background: var(--text-muted);
}

.session-item .status-dot.waiting {
  background: #f59e0b;
  animation: pulse 2s infinite;
}

/* 未读角标 */
.unread-badge {
  display: inline-block;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* 异步任务卡片 */
.async-task-bubble {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(255, 152, 0, 0.08);
  border: 1px solid rgba(255, 152, 0, 0.2);
  border-left: 3px solid #ff9800;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 10px 0;
  margin-left: 46px;
  max-width: calc(100% - 46px);
}

.async-task-bubble.completed {
  border-left-color: #4caf50;
  background: rgba(76, 175, 80, 0.08);
  border-color: rgba(76, 175, 80, 0.2);
}

.async-task-bubble.failed {
  border-left-color: #f44336;
  background: rgba(244, 67, 54, 0.08);
  border-color: rgba(244, 67, 54, 0.2);
}

.async-task-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #ff9800;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.async-task-icon {
  font-size: 14px;
}

.async-task-icon.spinning {
  display: inline-block;
  animation: pulse 1.5s infinite;
}

.async-task-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  word-break: break-word;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 152, 0, 0.2);
}

.async-task-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 152, 0, 0.12);
}

.async-task-robot {
  font-size: 12px;
  color: var(--text-secondary);
}

.async-task-robot b {
  color: #ff9800;
  font-weight: 600;
}

.async-task-status {
  font-size: 12px;
  color: var(--text-muted);
}

.async-task-status b {
  color: #ff9800;
  font-weight: 600;
}

.async-task-status .hourglass-spin {
  display: inline-block;
  animation: rotate 1.5s linear infinite;
}

/* 进展时间线 */
.async-task-timeline {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.timeline-entry {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.4;
}

.timeline-entry .timeline-icon {
  color: #4caf50;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}

.timeline-entry .timeline-robot {
  color: #ff9800;
  font-weight: 600;
  margin-right: 4px;
}

/* 附件卡片（微信风格） */
.async-task-attachments {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.2s;
  cursor: pointer;
}
.attachment-card:hover {
  background: rgba(255,255,255,0.12);
}
.attachment-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.attachment-card-info {
  flex: 1;
  min-width: 0;
}
.attachment-card-name {
  font-size: 13px;
  color: var(--text-primary, #e0e0e0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.attachment-card-size {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-top: 2px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.participants-legend {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
}

/* ============================================================
   主聊天区
   ============================================================ */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-header {
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.btn-menu {
  display: none;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

.header-info h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.header-agents {
  display: flex;
  gap: 6px;
}

.agent-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  color: white;
  font-weight: 500;
}

.agent-badge.tech { background: var(--color-tech); }
.agent-badge.fund { background: var(--color-fund); }
.agent-badge.sent { background: var(--color-sent); }
.agent-badge.risk { background: var(--color-risk); }
.agent-badge.cio  { background: var(--color-cio); }
.agent-badge.gen  { background: var(--color-gen); }

/* 用户菜单 */
.user-menu {
  margin-left: auto;
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

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

.user-btn svg {
  transition: transform 0.2s;
}

.user-btn.active svg {
  transform: rotate(180deg);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 1000;
}

.user-dropdown.show {
  display: block;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--bg-hover);
}

.dropdown-item:first-child {
  border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 8px 8px;
}


/* ============================================================
   消息区
   ============================================================ */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

/* 欢迎页 */
.welcome {
  text-align: center;
  padding: 40px 20px;
  max-width: 600px;
  margin: 0 auto;
}

.welcome-icon {
  margin-bottom: 16px;
}

.welcome h2 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.welcome p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.welcome-roles {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.role-card {
  width: 90px;
  padding: 12px 8px;
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}

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

.role-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
}

.role-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: block;
  object-fit: cover;
}

.role-card.tech .role-avatar { background: var(--color-tech); }
.role-card.fund .role-avatar { background: var(--color-fund); }
.role-card.sent .role-avatar { background: var(--color-sent); }
.role-card.risk .role-avatar { background: var(--color-risk); }
.role-card.cio-card .role-avatar { background: var(--color-cio); font-size: 11px; }

.role-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.role-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.welcome-examples {
  margin-top: 8px;
}

.welcome-examples p {
  font-size: 13px;
  margin-bottom: 12px;
}

.example-btn {
  display: inline-block;
  margin: 4px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.example-btn:hover {
  border-color: var(--color-cio);
  color: var(--color-cio);
  background: #e6f4ff;
}

/* 用户消息 */
.msg-user {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.msg-user .user-content {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.msg-user .user-name {
  font-size: 12px;
  color: #4a9ede;
  font-weight: 600;
  margin-bottom: 4px;
  padding-right: 4px;
}

.msg-user .bubble {
  padding: 12px 16px;
  background: linear-gradient(135deg, #e8f4fd, #fff);
  color: #1a3a5c;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  border-left: 4px solid #4a9ede;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.user-copy-btn {
  position: absolute;
  bottom: -22px;
  left: 0;
  color: #b0b0b0;
  opacity: 0;
  transition: opacity 0.2s;
}

.msg-user .bubble:hover .user-copy-btn {
  opacity: 1;
  color: #999;
}

.user-copy-btn:hover {
  color: #666 !important;
  background: rgba(0,0,0,0.05);
}

/* 阶段分隔线 */
.phase-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0 16px;
  padding: 0 20px;
}

.phase-divider::before,
.phase-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.phase-divider .phase-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 4px 12px;
  background: var(--bg-primary);
  border-radius: 12px;
}

/* Agent 消息 */
.msg-agent {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-start;
  width: 100%;
}

.msg-agent .avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  max-width: 36px;
  max-height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 600;
  margin-top: 2px;
  overflow: hidden;
}

.msg-agent .avatar img {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  object-fit: cover;
  border-radius: 50%;
}

.msg-agent .avatar.tech { background: var(--color-tech); }
.msg-agent .avatar.fund { background: var(--color-fund); }
.msg-agent .avatar.sent { background: var(--color-sent); }
.msg-agent .avatar.risk { background: var(--color-risk); }
.msg-agent .avatar.cio  { background: var(--color-cio); font-size: 11px; }
.msg-agent .avatar.sec  { background: var(--color-sec); }
.msg-agent .avatar.gen  { background: var(--color-gen); }

.msg-agent .content {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 46px);
  overflow: hidden;
}

.msg-agent .agent-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.msg-agent .agent-name.tech { color: var(--color-tech); }
.msg-agent .agent-name.fund { color: var(--color-fund); }
.msg-agent .agent-name.sent { color: var(--color-sent); }
.msg-agent .agent-name.risk { color: var(--color-risk); }
.msg-agent .agent-name.cio  { color: var(--color-cio); }
.msg-agent .agent-name.sec  { color: var(--color-sec); }
.msg-agent .agent-name.gen  { color: var(--color-gen); }

/* 模型名称标签 */
.model-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 400;
  color: #fff;
  background: linear-gradient(135deg, #0088fe, #0066cc);
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* AI Agent 标签 */
.agent-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  color: #0088fe;
  background: rgba(0, 136, 254, 0.1);
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.3px;
  white-space: nowrap;
  line-height: 16px;
}

.typing-indicator .model-badge {
  opacity: 0.8;
}

/* Token 用量标签 */
.token-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 400;
  color: #999;
  background: #f0f0f0;
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 4px;
  line-height: 16px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

.msg-agent .bubble {
  background: var(--bg-card);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 12px 16px 28px 16px;
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: break-word;
  color: var(--text-primary);
  position: relative;
}

/* 复制按钮组 */
.bubble-actions {
  position: absolute;
  bottom: 6px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.copy-btn, .copy-more-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  color: #ccc;
  display: flex;
  align-items: center;
}

.msg-agent .bubble:hover .copy-btn,
.msg-agent .bubble:hover .copy-more-btn {
  color: #999;
}

.copy-btn:hover, .copy-more-btn:hover {
  color: #666 !important;
  background: rgba(0,0,0,0.05);
}

/* 反馈按钮 */
.feedback-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  color: transparent;
  transition: color 0.2s;
  margin-left: 2px;
}
.msg-agent .bubble:hover .feedback-btn {
  color: #999;
}
.feedback-btn:hover {
  color: #666 !important;
  background: rgba(0,0,0,0.05);
}
.feedback-btn.active.thumb-up {
  color: #4caf50 !important;
}
.feedback-btn.active.thumb-down {
  color: #f44336 !important;
}

/* 右键菜单 */
.bubble-context-menu {
  position: fixed;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 4px 0;
  min-width: 140px;
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.ctx-item:hover {
  background: var(--bg-primary);
}

.ctx-item svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

/* 关联问题按钮 */
.suggest-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}

.suggest-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--color-cio);
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}

.suggest-btn:hover {
  background: #e6f4ff;
  border-color: var(--color-cio);
  transform: translateX(4px);
}

/* 报告确认 */
.report-confirm-box {
  padding: 8px 0;
}
.report-confirm-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.hourglass-spin {
  display: inline-block;
  animation: hourglass-rotate 1.2s ease-in-out infinite;
}
@keyframes hourglass-rotate {
  0%   { transform: rotate(0deg); }
  50%  { transform: rotate(180deg); }
  100% { transform: rotate(180deg); }
}

/* Toast 提示 */
.toast-success {
  position: fixed;
  top: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #4caf50;
  color: #fff;
  padding: 16px 40px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(76,175,80,0.4);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.msg-agent .bubble.cio-bubble {
  border-left: 4px solid var(--color-cio);
  background: linear-gradient(135deg, #f0f8ff, #fff);
}

.msg-agent .bubble.tech-bubble {
  border-left: 4px solid var(--color-tech);
  background: linear-gradient(135deg, #f0fafb, #fff);
}

.msg-agent .bubble.fund-bubble {
  border-left: 4px solid var(--color-fund);
  background: linear-gradient(135deg, #f2faf3, #fff);
}

.msg-agent .bubble.sent-bubble {
  border-left: 4px solid var(--color-sent);
  background: linear-gradient(135deg, #fff8f0, #fff);
}

.msg-agent .bubble.risk-bubble {
  border-left: 4px solid var(--color-risk);
  background: linear-gradient(135deg, #fef2f2, #fff);
}

.msg-agent .bubble.sec-bubble {
  border-left: 4px solid var(--color-sec);
  background: linear-gradient(135deg, #f4f6f7, #fff);
}

.msg-agent .bubble.gen-bubble {
  border-left: 4px solid var(--color-gen);
  background: linear-gradient(135deg, #f8f0fc, #fff);
}

/* Markdown 内容样式 */
.msg-agent .bubble h1,
.msg-agent .bubble h2,
.msg-agent .bubble h3 {
  margin-top: 12px;
  margin-bottom: 6px;
}

.msg-agent .bubble h1 { font-size: 16px; }
.msg-agent .bubble h2 { font-size: 15px; }
.msg-agent .bubble h3 { font-size: 14px; }

.msg-agent .bubble p {
  margin-bottom: 8px;
}

.msg-agent .bubble ul, .msg-agent .bubble ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.msg-agent .bubble li {
  margin-bottom: 2px;
}

.msg-agent .bubble strong {
  font-weight: 600;
}

.msg-agent .bubble table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  width: 100%;
  background: white;
  border-radius: 8px;
  overflow-x: auto;
  display: block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.msg-agent .bubble th,
.msg-agent .bubble td {
  border: 1px solid #e8e8e8;
  padding: 8px 12px;
  text-align: left;
  white-space: normal;
}

.msg-agent .bubble th {
  background: linear-gradient(180deg, #f8f9fa 0%, #f0f2f5 100%);
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #d0d0d0;
  white-space: nowrap;
}

.msg-agent .bubble td {
  background: white;
}

.msg-agent .bubble tr:hover td {
  background: #f8f9fa;
}

/* 观点列（第一列）不要太窄 */
.msg-agent .bubble td:first-child,
.msg-agent .bubble th:first-child {
  white-space: nowrap;
  min-width: 60px;
}

.msg-agent .bubble a,
.msg-user .bubble a {
  text-decoration: none;
  color: #0077cc;
}

/* 思考过程（工具调用） */
.thinking-section {
  margin-bottom: 8px;
}

.thinking-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}

.thinking-toggle:hover {
  color: var(--text-secondary);
}

.thinking-fold-btn {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.thinking-toggle .arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.thinking-toggle .arrow.open {
  transform: rotate(90deg);
}

.thinking-items {
  display: none;
  padding: 8px 12px;
  background: #f5f6f7;
  border-radius: var(--radius-sm);
  margin-top: 4px;
}

.thinking-items.open {
  display: block;
}

/* 单个工具调用块 */
.thinking-item-block {
  margin-bottom: 8px;
  padding: 8px 10px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #eee;
}

.thinking-item-block:last-child {
  margin-bottom: 0;
}

.thinking-item-header {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.thinking-item-header .tool-toggle-btn {
  margin-left: auto;
  color: #0088fe;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}

.thinking-item-header .tool-status {
  font-size: 11px;
  width: 16px;
  text-align: center;
}

.thinking-item-header .tool-status.done {
  color: var(--color-fund);
}

.thinking-item-header .tool-status.pending {
  color: var(--text-muted);
  animation: rotate 1.5s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.thinking-item-header .tool-name {
  font-weight: 600;
  color: var(--color-user);
  font-size: 12px;
}

.thinking-item-header .tool-args {
  color: var(--text-muted);
  font-size: 11px;
  word-break: break-all;
}

/* 缓存标签 */
.tool-cached-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: #52c41a;
  border-radius: 3px;
  padding: 0 5px;
  line-height: 16px;
  vertical-align: middle;
  margin-left: 4px;
}

/* 工具调用状态标签 */
.tool-status-label {
  display: inline-block;
  font-size: 10px;
  color: var(--color-sent);
  margin-left: 4px;
  font-weight: 500;
}

/* 加载中的点动画 */
.loading-dots {
  display: inline-block;
}

.loading-dots span {
  animation: loading-dot 1.4s infinite;
  opacity: 0;
}

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

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

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

@keyframes loading-dot {
  0%, 20% { opacity: 0; }
  40% { opacity: 1; }
  100% { opacity: 0; }
}
}

.thinking-item-block.cached {
  opacity: 0.75;
}

.tool-live-item.cached .tool-live-name {
  opacity: 0.7;
}

/* 工具返回结果 */
.tool-result-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #e8e8e8;
}

.tool-result-preview {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tool-result-preview .result-label {
  color: var(--color-fund);
  font-weight: 600;
  margin-right: 4px;
}

.tool-result-preview .result-text {
  word-break: break-all;
}

.tool-result-preview .result-table-preview {
  margin-top: 8px;
  font-size: 11px;
  overflow-x: auto;
}

.tool-result-preview .result-table-preview table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11px;
  background: white;
  border-radius: 4px;
  overflow: hidden;
}

.tool-result-preview .result-table-preview th,
.tool-result-preview .result-table-preview td {
  border: 1px solid #e8e8e8;
  padding: 4px 8px;
  text-align: left;
}

.tool-result-preview .result-table-preview th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 10px;
}

.tool-result-preview .result-table-preview td {
  font-size: 11px;
}

.tool-result-preview .result-expand {
  color: var(--color-user);
  font-size: 11px;
  margin-left: 4px;
  cursor: pointer;
}

.tool-result-preview .result-expand:hover {
  text-decoration: underline;
}

.tool-result-full {
  margin-top: 6px;
  padding: 8px 10px;
  background: #f5f7fa;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 400px;
  overflow-y: auto;
}

.tool-result-full.open {
  display: block;
}

.tool-result-full table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11px;
  background: white;
  margin: 8px 0;
}

.tool-result-full th,
.tool-result-full td {
  border: 1px solid #e8e8e8;
  padding: 6px 10px;
  text-align: left;
}

.tool-result-full th {
  background: #f8f9fa;
  font-weight: 600;
}

/* 实时工具调用列表（typing indicator 下方） */
.typing-tools-list {
  margin-top: 6px;
  font-size: 11px;
}

.tool-live-item {
  padding: 4px 8px;
  margin-bottom: 3px;
  background: #f8f9fa;
  border-radius: 4px;
  color: var(--text-secondary);
}

.tool-live-header {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.tool-live-header .tool-toggle-btn {
  margin-left: auto;
  color: #0088fe;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}

.tool-live-calling {
  color: var(--color-sent);
  font-size: 11px;
  margin-right: 4px;
  display: inline-block;
  animation: rotate 1.5s linear infinite;
}

.tool-live-done {
  color: var(--color-fund);
  font-size: 11px;
  margin-right: 4px;
}

.tool-live-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 4px;
}

.tool-live-args {
  color: var(--text-muted);
  font-size: 10px;
}

.tool-live-result {
  margin-top: 2px;
  font-size: 10px;
  color: var(--color-fund);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-live-result-full {
  margin-top: 6px;
  padding: 8px 10px;
  background: #f5f7fa;
  border-radius: 4px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-height: 600px;
  overflow-y: auto;
}

.tool-live-result-full table {
  border-collapse: collapse;
  width: 100%;
  font-size: 11px;
  background: white;
  margin: 8px 0;
}

.tool-live-result-full th,
.tool-live-result-full td {
  border: 1px solid #e8e8e8;
  padding: 4px 8px;
  text-align: left;
}

.tool-live-result-full th {
  background: #f0f2f5;
  font-weight: 600;
}

/* Typing 动画 */
.typing-indicator {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.typing-indicator .avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  max-width: 36px;
  max-height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
}

.typing-indicator .avatar img {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
  max-height: 36px !important;
  object-fit: cover;
  border-radius: 50%;
}

.typing-indicator .content {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 46px);
}

.typing-indicator .bubble {
  background: var(--bg-card);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.4s infinite;
}

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

@keyframes typing {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* 流式文本预览 */
.typing-stream-text {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  max-height: 400px;
  overflow-y: auto;
  border-left: 3px solid var(--color-user);
}

.typing-stream-text p { margin: 0 0 8px 0; }
.typing-stream-text p:last-child { margin-bottom: 0; }
.typing-stream-text table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12px; }
.typing-stream-text th, .typing-stream-text td { border: 1px solid var(--border-color); padding: 4px 8px; text-align: left; }
.typing-stream-text th { background: var(--bg-main); font-weight: 600; }
.typing-stream-text h1, .typing-stream-text h2, .typing-stream-text h3 { margin: 12px 0 6px; }
.typing-stream-text ul, .typing-stream-text ol { padding-left: 20px; }
.typing-stream-text blockquote { border-left: 3px solid var(--color-user); padding-left: 12px; color: var(--text-secondary); margin: 8px 0; }
.typing-stream-text strong { color: var(--color-user); }

/* 深度思考内容（typing indicator 中） */
.typing-think-text {
  background: linear-gradient(135deg, #f0f8ff, #e6f4ff);
  border-radius: var(--radius);
  padding: 0;
  margin-top: 8px;
  border-left: 3px solid #0088fe;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.typing-think-text .think-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #0088fe;
  background: rgba(0, 136, 254, 0.06);
}

.typing-think-text .think-body {
  padding: 8px 12px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  max-height: 300px;
  overflow-y: auto;
  line-height: 1.6;
}

.typing-think-text .think-body p { margin: 0 0 6px 0; }
.typing-think-text .think-body p:last-child { margin-bottom: 0; }

.typing-think-text.collapsed .think-body {
  display: none;
}

/* 最终消息中的深度思考内容（reasoning_content） */
.reasoning-content {
  background: linear-gradient(135deg, #f0f8ff, #e6f4ff);
  border-radius: var(--radius-sm);
  padding: 12px 16px 12px 20px;
  margin-bottom: 8px;
  border-left: 3px solid #0088fe;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
}

.reasoning-content p { margin: 0 0 6px 0; }
.reasoning-content p:last-child { margin-bottom: 0; }
.reasoning-content strong { color: #0066cc; }
.reasoning-content ul, .reasoning-content ol { padding-left: 20px; margin: 4px 0; }

/* 引用来源样式 */
.citations-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 136, 254, 0.2);
}

.citations-header {
  font-size: 12px;
  font-weight: 600;
  color: #0088fe;
  margin-bottom: 8px;
}

.citations-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.citation-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.citation-index {
  color: #0088fe;
  font-weight: 600;
  flex-shrink: 0;
}

.citation-link {
  color: #0066cc;
  text-decoration: none;
  transition: all 0.2s;
  word-break: break-word;
}

.citation-link:hover {
  color: #0088fe;
  text-decoration: underline;
}

/* ============================================================
   输入区
   ============================================================ */

.input-area {
  padding: 16px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-primary);
  border-radius: 24px;
  padding: 4px 4px 4px 20px;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--color-cio);
}

.input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  padding: 8px 0;
  color: var(--text-primary);
}

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

.btn-send {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--color-cio);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.2s;
}

.btn-send:hover {
  background: #0066cc;
  transform: scale(1.05);
}

.btn-send.btn-stop {
  background: #f44336;
  animation: pulse 2s infinite;
}

.btn-send.btn-stop:hover {
  background: #d32f2f;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(244, 67, 54, 0);
  }
}

.btn-send:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ============================================================
   响应式
   ============================================================ */

/* 回到底部按钮 */
.scroll-to-bottom-btn {
  position: fixed;
  bottom: 100px;
  right: 30px;
  padding: 10px 20px;
  background: var(--color-cio);
  color: white;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 136, 254, 0.3);
  z-index: 100;
  transition: all 0.3s;
  animation: fadeIn 0.3s ease;
}

.scroll-to-bottom-btn:hover {
  background: #0066cc;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 136, 254, 0.4);
}

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

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  .btn-menu {
    display: block;
  }

  .msg-user .bubble {
    max-width: 85%;
  }
}

/* ============================================================
   滚动条美化
   ============================================================ */

.messages::-webkit-scrollbar,
.sidebar-list::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track,
.sidebar-list::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb,
.sidebar-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.messages::-webkit-scrollbar-thumb:hover,
.sidebar-list::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ============================================================
   报告下载卡片
   ============================================================ */

.report-download {
  margin: 20px 0 16px;
}

.report-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, #faf4ff, #f0e6ff);
  border: 1px solid #e0d0f0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.report-icon {
  flex-shrink: 0;
}

.report-info {
  flex: 1;
  min-width: 0;
}

.report-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-cio);
  margin-bottom: 2px;
}

.report-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.report-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--color-cio);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s;
}

.report-btn:hover {
  background: #0066cc;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,136,254,0.3);
}
