:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --primary: #3b82f6;
  --primary-light: #dbeafe;
  --primary-hover: #2563eb;
  --user-bubble: #3b82f6;
  --user-text: #ffffff;
  --ai-bubble: #f1f5f9;
  --ai-text: #0f172a;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  --sidebar-w: 260px;
  --sidebar-rail-w: 44px;
  --topbar-h: 48px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --border: #334155;
  --primary-light: #1e3a5f;
  --user-bubble: #2563eb;
  --ai-bubble: #1e293b;
  --ai-text: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.25s ease;
  z-index: 10;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-w));
}

/* 侧栏收起后左侧窄条：仍可展开、新建、打开设置 */
.sidebar-collapsed-rail {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: var(--sidebar-rail-w);
  flex-shrink: 0;
  padding: 12px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 11;
}

#app:has(.sidebar.collapsed) .sidebar-collapsed-rail {
  display: flex;
}

.sidebar-rail-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.sidebar-rail-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-search {
  padding: 8px 12px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.sidebar-search input:focus {
  border-color: var(--primary);
}

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

.chat-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.chat-item:hover { background: var(--surface-hover); }
.chat-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

.chat-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-delete {
  opacity: 0;
  border: none;
  background: none;
  color: var(--danger);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
}

.chat-item:hover .chat-item-delete { opacity: 1; }

.chat-session-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 6px;
}
.chat-session-indicator.running {
  background: #22c55e;
  box-shadow: 0 0 4px #22c55e88;
  animation: session-pulse 1.5s infinite;
}
.chat-session-indicator.background {
  background: #f59e0b;
  box-shadow: 0 0 4px #f59e0b88;
  animation: session-pulse 2s infinite;
}
.chat-session-indicator.reconnecting {
  background: #ef4444;
  box-shadow: 0 0 4px #ef444488;
  animation: session-pulse 0.8s infinite;
}
@keyframes session-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

/* Buttons */
.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: none;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn-text {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.icon-btn-text:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* Main area */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 8px;
  min-height: var(--topbar-h);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.topbar-models {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  min-width: 0;
}

.model-tag {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
}

.model-tag.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.model-tag.discussion-tag {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
  border-color: transparent;
  font-weight: 600;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 4px;
}
.zoom-controls .zoom-btn {
  min-width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.zoom-controls .zoom-btn:hover {
  background: var(--surface-hover);
  color: var(--primary);
}
.zoom-controls .zoom-level {
  min-width: 36px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

.topbar-layout {
  display: flex;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  background: var(--bg);
}

.layout-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all 0.15s;
}

.layout-btn:hover { color: var(--text); }
.layout-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* Chat columns（min-height:0 保证列内消息区可纵向滚动） */
.chat-columns {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0;
  overflow: hidden;
}

.chat-columns.cols-1 { grid-template-columns: 1fr; }
.chat-columns.cols-2 { grid-template-columns: 1fr 1fr; }
.chat-columns.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.chat-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.chat-column:last-child { border-right: none; }

.column-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.provider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.provider-dot.openai { background: #10b981; }
.provider-dot.gemini { background: #3b82f6; }
.provider-dot.claude { background: #f59e0b; }
.provider-dot.deepseek { background: #ef4444; }
.provider-dot.minimax { background: #8b5cf6; }
.provider-dot.kimi { background: #ec4899; }
.provider-dot.qwen { background: #f97316; }
.provider-dot.glm { background: #06b6d4; }
.provider-dot.doubao { background: #ff6b35; }

.column-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  /* 流式输出时频繁改 scrollTop，用 auto 避免整列持续平滑滑动 */
  scroll-behavior: auto;
  overscroll-behavior: contain;
}

/* Scroll FABs */
.scroll-fab {
  position: fixed;
  z-index: 90;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border, #e0e0e0);
  background: var(--surface, #fff);
  color: var(--text, #333);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: right 0.15s ease, opacity 0.2s, transform 0.2s, background 0.15s;
  opacity: 0.75;
}
.scroll-fab:hover {
  opacity: 1;
  background: var(--surface-hover, #f3f4f6);
  transform: scale(1.08);
}
.scroll-fab-top { bottom: 108px; }
.scroll-fab-bottom { bottom: 70px; }

/* Messages */
.message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

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

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

.message-role {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.message-content {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 13.5px;
  word-break: break-word;
}

.message.user .message-content {
  background: var(--user-bubble);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
  background: var(--ai-bubble);
  color: var(--ai-text);
  border-bottom-left-radius: 4px;
}

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

.message-content pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12.5px;
  line-height: 1.5;
  position: relative;
}

[data-theme="dark"] .message-content pre {
  background: #0f172a;
}

.message-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.message-content code {
  background: rgba(59,130,246,0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-content ul, .message-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.message-content li { margin: 3px 0; }

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

.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

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

.message-content th {
  background: var(--surface-hover);
  font-weight: 600;
}

.copy-code-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 4px 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 4px;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.message-content pre:hover .copy-code-btn { opacity: 1; }
.copy-code-btn:hover { background: rgba(255,255,255,0.2); color: white; }

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 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 bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}

/* Round pagination: load-more banner */
.round-load-more {
  text-align: center;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
  transition: background 0.15s;
}
.round-load-more:active {
  background: var(--surface-hover);
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
  max-width: 260px;
}

.empty-state-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Input area */
.input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

/* Message queue bar */
.msg-queue-bar {
  margin-bottom: 8px;
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
}
.queue-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 0 5px;
}
.queue-label {
  color: var(--text-muted);
  flex: 1;
}
.queue-clear-btn {
  border: none;
  background: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
}
.queue-clear-btn:hover { background: var(--surface-hover); }
.queue-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 100px;
  overflow-y: auto;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--bg);
}
.queue-item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}
.queue-item-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.queue-item-remove:hover { color: var(--danger); }

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 36px;
}

.web-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
  transition: color .18s, opacity .15s, background .18s;
  padding: 4px 8px;
  border-radius: 7px;
}
.web-toggle:hover { color: var(--text); background: rgba(128,128,128,.08); }
.web-toggle:active { transform: scale(0.97); }
.web-toggle input { display: none; }
.web-toggle .toggle-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  transition: background .25s, box-shadow .25s;
  flex-shrink: 0;
}
.web-toggle .toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .25s cubic-bezier(.4,.0,.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.web-toggle input:checked + .toggle-track {
  background: var(--primary);
  box-shadow: 0 0 0 1px rgba(59,130,246,.15), 0 2px 6px rgba(59,130,246,.25);
}
.web-toggle input:checked + .toggle-track::after { transform: translateX(14px); }
.web-toggle .toggle-label {
  font-weight: 500;
  letter-spacing: 0.01em;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 10px;
  background: var(--border);
  flex-shrink: 0;
}

.ontology-mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
  transition: opacity .2s;
}
.ontology-mode-label {
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-size: 12px;
}
.ontology-mode-pills {
  display: flex;
  background: var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.ontology-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s, transform .1s;
  white-space: nowrap;
  line-height: 1.5;
}
.ontology-pill:hover {
  color: var(--text);
  background: rgba(128,128,128,.12);
}
.ontology-pill:active {
  transform: scale(0.93);
}
.ontology-pill.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
  font-weight: 600;
}
.ontology-pill[data-mode="on"].active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(59,130,246,.35);
}
.ontology-pill[data-mode="off"].active {
  background: var(--text-secondary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

.discussion-mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}
.discussion-mode-label {
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-size: 12px;
}
.discussion-mode-pills {
  display: flex;
  background: var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.discussion-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s, transform .1s;
  white-space: nowrap;
  line-height: 1.5;
}
.discussion-pill:hover {
  color: var(--text);
  background: rgba(128,128,128,.12);
}
.discussion-pill:active {
  transform: scale(0.93);
}
.discussion-pill.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(59,130,246,.30);
  font-weight: 600;
}

.chat-mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  user-select: none;
}
.chat-mode-label {
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  font-size: 12px;
}
.chat-mode-pills {
  display: flex;
  background: var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.chat-mode-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s, transform .1s;
  white-space: nowrap;
  line-height: 1.5;
}
.chat-mode-pill:hover {
  color: var(--text);
  background: rgba(128,128,128,.12);
}
.chat-mode-pill:active {
  transform: scale(0.93);
}
.chat-mode-pill.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(59,130,246,.30);
  font-weight: 600;
}

.scheme-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  position: relative;
}
.scheme-selector .scheme-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.scheme-dropdown {
  position: relative;
}
.scheme-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  padding: 5px 8px 5px 10px;
  min-width: 100px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  text-align: left;
}
.scheme-trigger:hover {
  border-color: var(--primary);
}
.scheme-trigger:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.scheme-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}
.scheme-trigger-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scheme-trigger-badge {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 4px;
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  color: #fff;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.scheme-trigger-arrow {
  font-size: 10px;
  opacity: 0.8;
  transition: transform .2s;
  flex-shrink: 0;
}
.scheme-dropdown.open .scheme-trigger-arrow { transform: rotate(180deg); }

/* 菜单向上展开，避免被底部裁切 */
.scheme-menu {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  min-width: 100%;
  max-height: min(280px, 60vh);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  padding: 4px 0;
}
.scheme-dropdown.open .scheme-menu {
  display: block;
}
.scheme-option {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s;
}
.scheme-option:hover {
  background: var(--surface-hover);
}
.scheme-option.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}
[data-theme="dark"] .scheme-option.selected {
  background: var(--primary-light);
  color: #93c5fd;
}
.scheme-option-label { display: inline; }
.scheme-option-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  border-radius: 4px;
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  color: #fff;
  letter-spacing: 0.02em;
}
.scheme-option-auto .scheme-option-badge { opacity: 0.95; }
.scheme-option.selected .scheme-option-badge {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
}
[data-theme="dark"] .scheme-option-badge {
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  color: #e9d5ff;
}
[data-theme="dark"] .scheme-option.selected .scheme-option-badge {
  background: linear-gradient(135deg, #5b21b6, #6d28d9);
  color: #fff;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

#user-input {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  resize: none;
  outline: none;
  min-height: 20px;
  max-height: 120px;
  line-height: 1.5;
}

#user-input::placeholder { color: var(--text-muted); }

.send-btn, .stop-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.send-btn {
  background: var(--primary);
  color: white;
}

.send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.stop-btn {
  background: var(--danger);
  color: white;
}

.stop-btn:hover { opacity: 0.9; }

.summarize-btn {
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  transition: all 0.15s;
  background: var(--primary);
  color: white;
  padding: 0 12px;
  font-size: 12px;
  white-space: nowrap;
}

.summarize-btn:hover { background: var(--primary-hover); transform: scale(1.02); }
.summarize-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.summarize-btn .summarize-btn-text { line-height: 1; }

/* Send button state icons */
.send-btn .btn-icon { display: flex; align-items: center; justify-content: center; }
.send-btn .btn-status-text { display: none; font-size: 11px; margin-left: 4px; white-space: nowrap; }

/* State: reconnecting */
.send-btn.state-reconnecting {
  background: var(--warning, #f59e0b);
  width: auto;
  min-width: 36px;
  padding: 0 10px;
  gap: 4px;
}
.send-btn.state-reconnecting .btn-icon-send { display: none; }
.send-btn.state-reconnecting .btn-icon-reconnect { display: flex; animation: spin 1s linear infinite; }
.send-btn.state-reconnecting .btn-status-text { display: inline; }

/* State: background (task running in backend but frontend disconnected) */
.send-btn.state-background {
  background: var(--info, #3b82f6);
  width: auto;
  min-width: 36px;
  padding: 0 10px;
  gap: 4px;
}
.send-btn.state-background .btn-icon-send { display: none; }
.send-btn.state-background .btn-icon-background { display: flex; }
.send-btn.state-background .btn-status-text { display: inline; }

/* Pulse dot for background state */
.pulse-dot {
  width: 10px;
  height: 10px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

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

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

/* Stop button pulse animation when running */
.stop-btn.state-running {
  animation: stop-pulse 1.5s ease-in-out infinite;
}

@keyframes stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* Session status hint */
.session-status-hint {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
  padding: 4px 8px;
  border-radius: 4px;
}
.session-status-hint.interrupted {
  color: var(--warning, #f59e0b);
  background: rgba(245, 158, 11, 0.1);
}

/* Prompt bar */
.prompt-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.prompt-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.prompt-item:last-child { border-bottom: none; }
.prompt-item:hover { background: var(--primary-light); }

.prompt-item-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.prompt-item-content {
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Settings overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 24px;
  overflow-y: auto;
}

.settings-panel {
  background: var(--surface);
  border-radius: var(--radius);
  width: 92%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.settings-panel-header h2 {
  font-size: 17px;
  font-weight: 700;
}

/* 一键下载选项弹窗 */
.export-options-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex;
  justify-content: center;
  align-items: center;
}

.export-options-modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 92%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.export-options-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.export-options-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.export-options-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.export-option-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.export-options-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.settings-panel-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.settings-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}

.settings-group-title:first-child {
  margin-top: 0;
}

.sp-model-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.sp-model-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.sp-model-header span:nth-child(2) { flex: 1; }

.sp-model-body {
  padding: 0 12px 12px;
  display: none;
}

.sp-model-body.open { display: block; }

.sp-mode-select {
  margin-bottom: 10px;
}
.sp-agent-note {
  font-size: 12px;
  color: var(--text-muted);
  margin: 8px 0 0;
}

.sp-model-body label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 8px 0 3px;
}

.sp-model-body input,
.sp-model-body select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.sp-model-body input:focus,
.sp-model-body select:focus {
  border-color: var(--primary);
}

.sp-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 13px;
}

.sp-setting-row select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.sp-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -4px 0 10px 0;
  line-height: 1.4;
}

.sp-experts-list {
  margin-bottom: 10px;
}

.sp-expert-row {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.sp-expert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.sp-expert-id {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.sp-expert-model {
  width: 110px;
  flex-shrink: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}

.sp-expert-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.sp-expert-remove:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.sp-expert-system {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  resize: vertical;
  min-height: 44px;
}

.sp-add-expert-btn {
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

.sp-add-expert-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.sp-save-btn {
  width: 100%;
  margin-top: 16px;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.sp-save-btn:hover { background: var(--primary-hover); }

.sp-toast {
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
  color: var(--success);
  min-height: 20px;
}

/* Thinking block (deep reasoning) */
.think-block {
  margin-bottom: 8px;
  border: 1px solid #d8b4fe;
  border-radius: 8px;
  overflow: hidden;
  font-size: 13px;
}
[data-theme="dark"] .think-block { border-color: #7c3aed; }

.think-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #faf5ff;
  cursor: pointer;
  user-select: none;
  color: #6b21a8;
  font-weight: 500;
  transition: background 0.15s;
}
[data-theme="dark"] .think-toggle { background: #2e1065; color: #c4b5fd; }
.think-toggle:hover { background: #f3e8ff; }
[data-theme="dark"] .think-toggle:hover { background: #3b0764; }

.think-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 10px;
}
.think-arrow.open { transform: rotate(90deg); }
.think-label { flex: 1; }
.think-timer { font-weight: 400; font-size: 12px; opacity: 0.7; }

.think-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: #faf5ff;
}
[data-theme="dark"] .think-body { background: #1a0533; }
.think-body.open { max-height: 100000px; overflow-y: auto; }

.think-inner {
  padding: 8px 12px;
  color: #6b21a8;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.85;
}
[data-theme="dark"] .think-inner { color: #c4b5fd; }

.response-area { margin-top: 0; word-break: break-word; overflow-wrap: break-word; }

/* Tool event blocks */
.tool-call-group {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}
.tool-call-group .tool-event-block { margin: 6px 0; }
.tool-call-group .tool-event-block:first-child { margin-top: 0; }
.tool-call-group .tool-event-block:last-child { margin-bottom: 0; }

.tool-event-block {
  margin: 6px 0;
  border-radius: 8px;
  font-size: 13px;
  overflow: hidden;
}
.tool-call { border: 1px solid #86efac; }
.tool-result { border: 1px solid #6ee7b7; }
[data-theme="dark"] .tool-call { border-color: #166534; }
[data-theme="dark"] .tool-result { border-color: #065f46; }

.agent-response-block {
  border: 1px solid var(--border);
  padding: 8px 10px;
  background: var(--surface);
}
.agent-response-block strong { color: var(--primary); }
.agent-response-text { margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

/* ============================================================
   讨论模式：时间线（X=角色名，Y=从上到下，每人独立气泡）
   ============================================================ */
.message.discussion-response {
  padding: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* ── 四阶段讨论布局 ── */

.phase-section { margin-bottom: 14px; }
.phase-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface) 100%);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border-left: 4px solid var(--primary);
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.phase-num {
  color: var(--primary);
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
}
.phase-desc {
  color: var(--text);
  font-weight: 500;
}

.expert-created-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--primary);
}
.expert-created-info .expert-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.expert-created-info .expert-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}
.expert-created-info .expert-tag-model {
  font-size: 9px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
}
.expert-created-info .expert-tag[data-expert-id] {
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.expert-created-info .expert-tag[data-expert-id]:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* 方案推荐提示 */
.scheme-recommended-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1));
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text);
  border-left: 3px solid var(--accent, #8b5cf6);
}
.scheme-recommended-info strong {
  color: var(--accent, #8b5cf6);
  font-weight: 600;
}
.scheme-recommended-info .scheme-reason {
  color: var(--text-secondary);
  font-size: 11px;
}

/* 执行计划卡片 */
.discussion-plan-card {
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), rgba(16, 185, 129, 0.06));
  border-radius: var(--radius-sm);
  margin: 10px 0;
  border-left: 3px solid var(--primary, #3b82f6);
}
.discussion-plan-card .plan-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
}
.discussion-plan-card .plan-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.discussion-plan-card .plan-step-item {
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.1);
}
[data-theme="dark"] .discussion-plan-card .plan-step-item {
  background: rgba(255, 255, 255, 0.04);
}
.discussion-plan-card .plan-step-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.discussion-plan-card .plan-step-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary, #3b82f6);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.discussion-plan-card .plan-step-topic {
  flex: 1;
  font-weight: 600;
}
.discussion-plan-card .plan-step-experts {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--primary, #3b82f6);
  opacity: .85;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 3px;
}
.discussion-plan-card .plan-step-desc {
  padding-left: 28px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.5;
}
.discussion-plan-card .plan-step-goal {
  padding-left: 28px;
  font-size: 11px;
  color: var(--primary, #3b82f6);
  margin-top: 2px;
  opacity: 0.9;
}
.issues-list-info .issue-experts {
  font-size: 10px;
  color: var(--primary, #3b82f6);
  opacity: .85;
  margin-left: 6px;
  padding: 1px 6px;
  background: rgba(59, 130, 246, 0.08);
  border-radius: 3px;
  white-space: nowrap;
}

/* Expert popover */
.expert-popover {
  position: fixed;
  z-index: 9999;
  width: 300px;
  max-height: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: epFadeIn .15s ease;
}
@keyframes epFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.ep-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.ep-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.ep-model {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
}
.ep-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 2px;
}
.ep-close:hover { color: var(--danger); }
.ep-domain {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}
.ep-body {
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.expert-model-tag {
  font-size: 10px;
  font-weight: 400;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  white-space: nowrap;
}

/* Expert tool group (collapsible) */
.expert-tool-group {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  font-size: 12px;
}
.etg-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  color: #166534;
  background: #f0fdf4;
  transition: background .15s;
}
[data-theme="dark"] .etg-toggle { background: #052e16; color: #86efac; }
.etg-toggle:hover { background: #dcfce7; }
[data-theme="dark"] .etg-toggle:hover { background: #064e3b; }
.etg-arrow {
  display: inline-block;
  transition: transform .2s;
  font-size: 10px;
}
.etg-arrow.open { transform: rotate(90deg); }
.etg-count { font-weight: 400; opacity: .7; }
.etg-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.etg-body.open { max-height: 100000px; overflow-y: auto; }
.etg-body .tool-event-block {
  margin: 0;
  border-radius: 0;
  border: none;
  border-top: 1px solid var(--border);
}
.etg-body .tool-event-block:first-child { border-top: none; }

.discussion-host-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--surface);
  overflow: hidden;
}
.discussion-host-card.host-guidance {
  border-color: #fbbf24;
  background: #fffbeb;
}
[data-theme="dark"] .discussion-host-card.host-guidance {
  border-color: #92400e;
  background: #451a03;
}
.discussion-host-card.host-guidance .discussion-host-title { color: #b45309; }
[data-theme="dark"] .discussion-host-card.host-guidance .discussion-host-title { color: #fbbf24; }

.discussion-host-card.host-final {
  border: 2px solid var(--primary);
  background: var(--primary-light);
}
[data-theme="dark"] .discussion-host-card.host-final { background: #1e3a5f; }
.discussion-host-card.host-final .discussion-host-title { color: var(--primary); }

.discussion-simple-answer-actions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.btn-force-discussion {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-force-discussion:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}
.btn-force-discussion:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.discussion-continue-actions {
  margin-top: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.btn-continue-discussion {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-continue-discussion:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}
.btn-continue-discussion:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.issues-list-info {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}
.issues-list-info .issue-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
}
.issues-list-info .issue-num {
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}

.issue-section {
  margin: 14px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

/* 步骤讨论摘要面板 */
.issue-summary-panel {
  position: sticky;
  top: 0;
  right: 0;
  width: 240px;
  min-width: 160px;
  max-width: 400px;
  max-height: calc(100vh - 200px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  flex-shrink: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.issue-with-summary {
  display: flex;
  gap: 0;
}

.issue-with-summary .issue-main {
  flex: 1;
  min-width: 0;
}

/* 可拖拽的分隔线 */
.summary-resize-handle {
  width: 6px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  transition: background 0.15s;
}

.summary-resize-handle:hover,
.summary-resize-handle.dragging {
  background: var(--primary);
}

.summary-resize-handle::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 24px;
  background: var(--border);
  border-radius: 1px;
}

.summary-resize-handle:hover::before,
.summary-resize-handle.dragging::before {
  background: white;
}

.issue-summary-header {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 6px;
}

.issue-summary-header::before {
  content: '📝';
}

.issue-summary-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}

.issue-summary-content {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-primary);
}
.issue-summary-content h3 { font-size: 12px; font-weight: 600; margin: 8px 0 4px; }
.issue-summary-content ul { margin: 2px 0; padding-left: 16px; }
.issue-summary-content li { margin: 2px 0; }

/* 摘要条目 - 头像样式 */
.summary-item {
  display: flex;
  gap: 8px;
  padding: 6px;
  margin-bottom: 4px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  animation: summaryFadeIn 0.3s ease;
  transition: background 0.15s;
}

.summary-item:hover {
  background: var(--surface-hover);
}

.summary-item-clickable {
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.summary-item-clickable:hover {
  background: rgba(59, 130, 246, 0.08);
}
.summary-item-clickable:active {
  background: var(--surface-active, rgba(0, 0, 0, 0.06));
  transform: scale(0.98);
}

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

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

.summary-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}

.summary-avatar.host {
  background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
  font-size: 12px;
}

.summary-body {
  flex: 1;
  min-width: 0;
}

.summary-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-text {
  color: var(--text-secondary);
  word-break: break-word;
  font-size: 11px;
  line-height: 1.45;
}

.summary-empty {
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 12px;
}

/* 讨论进展条目（摘要面板内） */
.summary-progress {
  margin: 6px 4px;
  padding: 6px 8px;
  border-radius: 6px;
  border-left: 3px solid var(--primary);
  background: var(--primary-light, rgba(59, 130, 246, 0.06));
  font-size: 11px;
  line-height: 1.5;
  animation: summaryFadeIn 0.3s ease;
}
.summary-progress-header {
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.summary-progress-header::before {
  content: '📋';
  font-size: 11px;
}
.summary-progress-text {
  color: var(--text-secondary);
  word-break: break-word;
}

/* 在窄屏上隐藏摘要面板 */
@media (max-width: 700px) {
  .issue-summary-panel {
    display: none;
  }
  .summary-resize-handle {
    display: none;
  }
  .issue-with-summary {
    display: block;
  }
}
.issue-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .issue-header { background: #1e3a5f; }
.issue-badge {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.issue-desc { flex: 1; font-weight: 500; }
.issue-experts-label {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.issue-body { padding: 8px; }

.discussion-backend-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary, #f5f5f5);
}
.discussion-backend-loading .loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary, #4a90d9);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
.data-retrieval-loading {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0;
}
.data-retriever-card {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.data-retriever-title {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
}
.data-retriever-subtitle {
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-retriever-body { padding: 8px 10px; }
.data-retriever-body .response-area { font-size: 12px; }

.data-retriever-summary {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.retriever-items-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 6px;
}
.retriever-items-summary {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.retriever-items-summary::-webkit-details-marker { display: none; }
.retriever-items-summary::before { content: '▸ '; }
.retriever-items-details[open] .retriever-items-summary::before { content: '▾ '; }
.retriever-items-list {
  margin: 0;
  padding: 6px 10px 10px 14px;
  max-height: 320px;
  overflow-y: auto;
  list-style: none;
  counter-reset: retriever-num;
  border-top: 1px solid var(--border);
}
.retriever-item {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  counter-increment: retriever-num;
}
.retriever-item:last-child { margin-bottom: 0; }
.retriever-item-num {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
}
.retriever-item-inner { min-width: 0; }
.retriever-item-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}
.retriever-item-title a {
  color: var(--primary);
  text-decoration: none;
}
.retriever-item-title a:hover { text-decoration: underline; }
.retriever-item-content {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.issue-consensus-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.issue-consensus-badge.no-consensus { color: var(--text-muted); }

/* -- 辩论驱动 UI -- */
.debate-stage-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  margin: 4px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  border-radius: 6px;
  border-left: 3px solid var(--primary);
}
.debate-stage-label { flex: 1; }
.debate-conflict-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.conflict-analysis-panel {
  margin: 6px 0;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.conflict-section { margin-bottom: 8px; }
.conflict-section:last-child { margin-bottom: 0; }
.conflict-section-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--text-primary);
}
.conflict-agreements ul,
.conflict-blindspots ul {
  margin: 0;
  padding-left: 16px;
  color: var(--text-secondary);
}
.conflict-agreements li,
.conflict-blindspots li {
  margin-bottom: 2px;
  line-height: 1.4;
}
.conflict-item {
  padding: 6px 8px;
  margin-bottom: 4px;
  background: color-mix(in srgb, var(--warning, #f59e0b) 6%, transparent);
  border-radius: 6px;
  border-left: 3px solid var(--warning, #f59e0b);
}
.conflict-desc { font-weight: 500; margin-bottom: 2px; color: var(--text-primary); }
.conflict-experts { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.conflict-question { font-size: 12px; color: var(--primary); font-style: italic; margin-bottom: 4px; }
.conflict-position {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.conflict-pos-expert { font-weight: 600; color: var(--text-primary); }

.conflict-resolution-badge {
  padding: 6px 10px;
  margin: 4px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  font-size: 12px;
}
.resolution-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.resolution-id { font-weight: 600; color: var(--text-primary); }
.resolution-status { font-weight: 600; font-size: 11px; }
.resolution-evidence { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.resolution-conclusion { color: var(--text-secondary); line-height: 1.4; }

/* -- 冲突点 ID 标签 -- */
.conflict-id {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--warning, #f59e0b);
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}

/* -- 质疑/回应/认同卡片 -- */
.challenge-cards-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
}
.challenge-card {
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  transition: opacity 0.3s, border-color 0.3s;
}
.challenge-card--challenge {
  border-left-color: #ef4444;
  background: color-mix(in srgb, #ef4444 6%, transparent);
}
.challenge-card--response {
  border-left-color: #3b82f6;
  background: color-mix(in srgb, #3b82f6 6%, transparent);
}
.challenge-card--agree {
  border-left-color: #22c55e;
  background: color-mix(in srgb, #22c55e 6%, transparent);
}
.challenge-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.challenge-card-id {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--text-muted);
  border-radius: 4px;
}
.challenge-card--challenge .challenge-card-id { background: #ef4444; }
.challenge-card--response .challenge-card-id { background: #3b82f6; }
.challenge-card--agree .challenge-card-id { background: #22c55e; }
.challenge-card-type {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}
.challenge-card-target {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}
.challenge-card-ref {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
}
.challenge-card-from {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}
.challenge-card-topic {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.challenge-card-content {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
}

/* -- 状态覆盖 -- */
.challenge-card--responded {
  border-left-color: #3b82f6 !important;
}
.challenge-card--resolved {
  border-left-color: #22c55e !important;
  opacity: 0.65;
}
.challenge-resolved-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #22c55e;
  margin-left: 6px;
}

/* -- 交叉讨论段落 -- */
.discussion-segment {
  border-left: 3px solid var(--segment-target-color, var(--border));
  padding-left: 12px;
  margin: 10px 0;
  transition: border-color 0.2s;
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  padding: 8px 12px 8px 12px;
}
.discussion-segment.tag-challenge {
  background: color-mix(in srgb, #ef4444 5%, var(--surface));
}
.discussion-segment.tag-response {
  background: color-mix(in srgb, #3b82f6 5%, var(--surface));
}
.discussion-segment.tag-agree {
  background: color-mix(in srgb, #22c55e 5%, var(--surface));
}
.discussion-segment-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.discussion-segment > h3 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.4;
}
.discussion-tag-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
  color: #fff;
  vertical-align: middle;
  white-space: nowrap;
}
.discussion-mention-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.8em;
  font-weight: 600;
  color: #fff;
  vertical-align: middle;
}
.discussion-topic {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 2px;
}

/* -- 专家区域 -- */
.discussion-experts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
}

.discussion-expert {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--surface);
  flex-shrink: 0;
}

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

/* -- Fin 点评（非最终轮） -- */
.discussion-host {
  display: flex;
  flex-direction: column;
  margin: 6px 8px 8px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.discussion-guidance {
  border: 1px solid #fbbf24;
  background: #fffbeb;
}
[data-theme="dark"] .discussion-guidance {
  border-color: #92400e;
  background: #451a03;
}

.discussion-guidance .discussion-host-title {
  color: #b45309;
}
[data-theme="dark"] .discussion-guidance .discussion-host-title {
  color: #fbbf24;
}

.discussion-guidance .discussion-host-title::before {
  content: '🎯';
  font-size: 14px;
}

/* -- 最终结论 -- */
.discussion-final {
  border-color: var(--primary);
  border-width: 2px;
}

.discussion-final .discussion-round-header {
  background: var(--primary-light);
  color: var(--primary);
}
[data-theme="dark"] .discussion-final .discussion-round-header {
  background: #1e3a5f;
}

.discussion-conclusion {
  border: 2px solid var(--primary);
  background: var(--primary-light);
}
[data-theme="dark"] .discussion-conclusion {
  background: #1e3a5f;
}

.discussion-conclusion .discussion-host-title {
  color: var(--primary);
}

.discussion-conclusion .discussion-host-title::before {
  content: '📋';
  font-size: 14px;
}

/* -- 共用 Fin 样式 -- */
.discussion-host-title {
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 13px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.discussion-host-body {
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: break-word;
}
.discussion-host-body pre,
.gc-content pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 10px;
  border-radius: 6px;
  font-size: 12px;
  margin: 6px 0;
}
.discussion-host-body code,
.gc-content code {
  background: var(--border);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}
.discussion-host-body pre code,
.gc-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* -- 其他 -- */
.error-text { color: var(--danger); }
.retry-refresh-btn {
  display: inline-block;
  margin-left: 8px;
  padding: 3px 12px;
  font-size: 12px;
  color: var(--danger);
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  transition: background .15s, color .15s;
}
.retry-refresh-btn:hover {
  background: var(--danger);
  color: #fff;
}
.provider-dot.discussion { background: linear-gradient(135deg, var(--primary), #8b5cf6); }

.tool-event-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  background: #f0fdf4;
  color: #166534;
  transition: background 0.15s;
}
[data-theme="dark"] .tool-event-toggle { background: #052e16; color: #86efac; }
.tool-event-toggle:hover { background: #dcfce7; }
[data-theme="dark"] .tool-event-toggle:hover { background: #064e3b; }

.tool-event-arrow {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 10px;
}
.tool-event-arrow.open { transform: rotate(90deg); }
.tool-event-label { flex: 1; }

.tool-event-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: #f0fdf4;
}
[data-theme="dark"] .tool-event-body { background: #022c22; }
.tool-event-body.open { max-height: 100000px; overflow-y: auto; }

.tool-event-inner {
  padding: 6px 10px;
  color: #166534;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  opacity: 0.9;
}
[data-theme="dark"] .tool-event-inner { color: #6ee7b7; }

/* 网页搜索结果结构化展示 */
.tool-event-block.web-search .tool-event-inner {
  font-family: inherit;
  white-space: normal;
  padding: 8px 0;
}
.web-search-result-list { display: flex; flex-direction: column; gap: 10px; }
.web-search-result-item {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0,0,0,0.04);
  border-left: 3px solid var(--primary);
}
[data-theme="dark"] .web-search-result-item { background: rgba(255,255,255,0.06); }
.web-search-result-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}
.web-search-result-content {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 4px;
}
.web-search-result-source { font-size: 11px; }
.web-search-link {
  color: var(--primary);
  text-decoration: none;
}
.web-search-link:hover { text-decoration: underline; }

/* ============================================================
   Phase 3 群聊布局
   ============================================================ */
.gc-message {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  transition: background .15s;
  animation: gc-bubble-in 0.25s ease-out;
}
@keyframes gc-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.gc-message:hover { background: var(--surface-hover); }
.gc-message-highlight {
  animation: gc-highlight-pulse 2s ease-out;
}
@keyframes gc-highlight-pulse {
  0%   { box-shadow: 0 0 0 2px var(--primary, #3b82f6); background: rgba(59, 130, 246, 0.12); }
  70%  { box-shadow: 0 0 0 2px var(--primary, #3b82f6); background: rgba(59, 130, 246, 0.06); }
  100% { box-shadow: none; background: transparent; }
}
.gc-message.gc-host {
  background: rgba(245, 158, 11, 0.04);
}
[data-theme="dark"] .gc-message.gc-host {
  background: rgba(245, 158, 11, 0.06);
}

.gc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.gc-avatar-host {
  background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
  font-size: 17px;
}

.gc-body { flex: 1; min-width: 0; }
.gc-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.gc-name .expert-model-tag {
  margin-left: 0;
}

.gc-content {
  font-size: 13.5px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: break-word;
}
.gc-content .think-block { margin: 6px 0; }
.gc-content .expert-tool-group { margin: 6px 0; }
.gc-content .fin-tool-group-wrapper { margin: 6px 0; }
.gc-content .response-area { margin-top: 4px; }

/* Effective Reasoning Chain Card */
.er-card {
  margin: 12px 0;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}
[data-theme="dark"] .er-card { border-color: #1e40af; }
.er-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  font-weight: 600;
  color: #1e3a5f;
}
[data-theme="dark"] .er-card-header { background: linear-gradient(135deg, #172554, #1e3a8a); color: #93c5fd; }
.er-card-icon { font-size: 16px; }
.er-card-title { flex: 1; }
.er-stats { font-size: 11px; font-weight: 400; opacity: 0.7; }
.er-card-body { padding: 10px 14px; background: #f8fafc; }
[data-theme="dark"] .er-card-body { background: #0f172a; }
.er-path { margin-bottom: 12px; }
.er-path:last-child { margin-bottom: 0; }
.er-path-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #e0f2fe;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
[data-theme="dark"] .er-path-header { background: #1e3a8a; }
.er-path-title { font-weight: 600; color: #1d4ed8; }
[data-theme="dark"] .er-path-title { color: #60a5fa; }
.er-path-conf { color: #475569; font-size: 11px; }
[data-theme="dark"] .er-path-conf { color: #94a3b8; }
.er-path-steps { padding-left: 8px; }
.er-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  border-left: 3px solid #cbd5e1;
  margin-left: 4px;
  line-height: 1.5;
}
[data-theme="dark"] .er-step { border-left-color: #475569; }
.er-step-premise { border-left-color: #22c55e; background: #f0fdf4; }
[data-theme="dark"] .er-step-premise { border-left-color: #16a34a; background: #052e16; }
.er-step-conclusion { border-left-color: #3b82f6; background: #eff6ff; font-weight: 500; }
[data-theme="dark"] .er-step-conclusion { border-left-color: #2563eb; background: #172554; }
.er-step-middle { border-left-color: #f59e0b; }
[data-theme="dark"] .er-step-middle { border-left-color: #d97706; }
.er-step-type {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  min-width: 50px;
}
[data-theme="dark"] .er-step-type { color: #94a3b8; }
.er-conf {
  flex-shrink: 0;
  font-size: 10px;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 5px;
  border-radius: 3px;
}
[data-theme="dark"] .er-conf { background: #334155; color: #cbd5e1; }
.er-step-content { flex: 1; color: #1e293b; }
[data-theme="dark"] .er-step-content { color: #e2e8f0; }
.er-ground {
  flex-shrink: 0;
  font-size: 10px;
  color: #8b5cf6;
  opacity: 0.8;
}
[data-theme="dark"] .er-ground { color: #a78bfa; }
.er-arrow {
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  padding: 2px 0;
  margin-left: 16px;
}
[data-theme="dark"] .er-arrow { color: #64748b; }

/* Audit scoreboard */
.er-audit {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f1f5f9;
}
[data-theme="dark"] .er-audit { background: #1e293b; border-bottom-color: #334155; }
.er-audit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.er-audit-health {
  font-weight: 600;
  font-size: 13px;
}
.er-scale {
  font-size: 11px;
  color: #64748b;
}
[data-theme="dark"] .er-scale { color: #94a3b8; }
.er-scale-label { font-weight: 500; margin-right: 4px; }
.er-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.er-metric {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
}
[data-theme="dark"] .er-metric { background: #0f172a; }
.er-metric-icon { font-size: 12px; flex-shrink: 0; }
.er-metric-label { color: #64748b; flex: 1; }
[data-theme="dark"] .er-metric-label { color: #94a3b8; }
.er-metric-value { font-weight: 600; color: #1e40af; }
[data-theme="dark"] .er-metric-value { color: #60a5fa; }
.er-risks {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: #fef3c7;
  font-size: 11px;
}
[data-theme="dark"] .er-risks { background: #422006; }
.er-risk-item {
  padding: 2px 0;
  color: #92400e;
}
[data-theme="dark"] .er-risk-item { color: #fbbf24; }

.resume-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: var(--text-secondary, #888);
  font-size: 13px;
}
.resume-indicator .typing-indicator { display: inline-flex; }

/* 引用角标链接样式 */
.citation-link {
  display: inline;
  color: var(--accent, #3b82f6);
  text-decoration: none;
  font-size: 0.85em;
  font-weight: 600;
  vertical-align: super;
  padding: 0 1px;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.citation-link:hover {
  background: var(--accent, #3b82f6);
  color: #fff;
  text-decoration: none;
}
.citation-link:active {
  opacity: 0.8;
}

/* ============================================================
   Fin 工具调用展示
   ============================================================ */

/* 工具组可折叠容器 */
.fin-tool-group-wrapper {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.fin-tool-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  transition: background 0.15s;
}
.fin-tool-group-header:hover { background: var(--surface-hover); }
.fin-tool-group-arrow {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}
.fin-tool-group-wrapper.expanded .fin-tool-group-arrow { transform: rotate(90deg); }
.fin-tool-group-label {
  font-weight: 600;
  color: var(--text);
}
.fin-tool-group-count {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: auto;
}
.fin-tool-group-body {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.fin-tool-group-wrapper.expanded .fin-tool-group-body { display: flex !important; }

/* 旧版 fin-tool-group 兼容（可由 wrapper 替代） */
.fin-tool-group {
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fin-tool-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.fin-tool-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  background: var(--surface-hover);
  user-select: none;
  transition: background 0.15s;
}
.fin-tool-toggle:hover {
  background: var(--border);
}

.fin-tool-arrow {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}
.fin-tool-item.expanded .fin-tool-arrow {
  transform: rotate(90deg);
}

.fin-tool-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.fin-tool-status {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 2px 6px;
  background: var(--border);
  border-radius: 4px;
}

.fin-tool-details {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.fin-tool-item.expanded .fin-tool-details {
  display: block !important;
}

.fin-tool-section {
  margin-bottom: 10px;
}
.fin-tool-section:last-child {
  margin-bottom: 0;
}

.fin-tool-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.fin-tool-section-content {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}
.fin-tool-section-content pre {
  margin: 0;
  padding: 8px;
  background: var(--surface-hover);
  border-radius: 4px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.fin-tool-result-section {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

/* Search History Panel */
.search-history-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  transition: max-height 0.2s ease;
}
.search-history-panel.collapsed .search-history-content {
  display: none;
}
.search-history-panel.collapsed .search-history-arrow {
  transform: rotate(-90deg);
}

.search-history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-secondary);
}
.search-history-header:hover {
  background: var(--surface-hover);
}

.search-history-icon {
  font-size: 14px;
}
.search-history-title {
  font-weight: 500;
}
.search-history-count {
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.search-history-count:empty,
.search-history-count[data-count="0"] {
  display: none;
}
.search-history-download {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.search-history-header:hover .search-history-download {
  opacity: 1;
}
.search-history-download:hover {
  background: var(--surface-hover);
  color: var(--primary);
}
.search-history-arrow {
  margin-left: auto;
  font-size: 10px;
  transition: transform 0.2s ease;
}

.search-history-content {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.search-history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-history-empty {
  color: var(--text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 12px;
}

.search-history-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-history-item:hover {
  background: var(--surface-hover);
}

.search-history-item-id {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--primary);
  min-width: 24px;
}
.search-history-item-content {
  flex: 1;
  min-width: 0;
}
.search-history-item-title {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-history-item-summary {
  color: var(--text-secondary);
  font-size: 11px;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-history-item-time {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 10px;
}

.search-history-item.new {
  animation: highlight-new 1s ease;
}
@keyframes highlight-new {
  0% { background: rgba(var(--primary-rgb), 0.2); }
  100% { background: var(--bg); }
}

/* ═══════════════════════════════════════════════════════════════
   思维导图浮窗（主区左下角，侧栏右侧；悬停头像展开）
═══════════════════════════════════════════════════════════════ */
.mindmap-float-root {
  position: fixed;
  z-index: 200;
  left: calc(var(--sidebar-w) + 16px);
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 0;
  pointer-events: none;
}
#app:has(.sidebar.collapsed) .mindmap-float-root {
  left: calc(var(--sidebar-rail-w) + 16px);
}
#app:has(.sidebar.collapsed) .mindmap-float-popover {
  width: min(var(--mm-popover-w, 380px), calc(100vw - var(--sidebar-rail-w) - 32px));
  max-width: calc(100vw - var(--sidebar-rail-w) - 24px);
}
/* 勿对整棵子树统一 pointer-events:auto：隐藏中的 popover 仍会挡住下方聊天区的滚轮 */
.mindmap-float-popover {
  --mm-popover-w: 380px;
  --mm-popover-max-h: min(52vh, 480px);
  position: relative;
  width: min(var(--mm-popover-w), calc(100vw - var(--sidebar-w) - 32px));
  max-width: calc(100vw - var(--sidebar-w) - 24px);
  /* 明确高度，便于内部 flex 画布吃满剩余空间 */
  height: min(var(--mm-popover-max-h), calc(100vh - 120px));
  max-height: min(var(--mm-popover-max-h), calc(100vh - 120px));
  min-width: 260px;
  min-height: 200px;
  margin-bottom: 0;
  padding-bottom: 10px;
  margin-bottom: -6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.12));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
}
.mindmap-float-popover.mm-resizing,
.mindmap-float-popover.mm-dragging-root {
  transition: none;
}
.mindmap-float-resize-handle {
  position: absolute;
  right: 2px;
  bottom: 8px;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 8;
  border-radius: 4px;
  background: linear-gradient(135deg, transparent 50%, var(--border) 50%),
    linear-gradient(225deg, transparent 50%, var(--border) 50%);
  background-size: 7px 7px;
  background-position: 9px 9px, 2px 2px;
  background-repeat: no-repeat;
  opacity: 0.65;
}
.mindmap-float-resize-handle:hover {
  opacity: 1;
  background-color: var(--surface-hover);
}
.mindmap-float-drag-handle {
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  margin-right: 2px;
  color: var(--text-muted);
  letter-spacing: -2px;
  user-select: none;
  flex-shrink: 0;
}
.mindmap-float-drag-handle:active {
  cursor: grabbing;
}
.mindmap-size-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  flex-shrink: 0;
}
.mindmap-size-preset {
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.3;
}
.mindmap-size-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.mindmap-size-preset.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.mindmap-panel-reset-pos {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
}
.mindmap-panel-reset-pos:hover {
  background: var(--surface-hover);
  color: var(--primary);
}
[data-theme="dark"] .mindmap-float-popover {
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.45));
}
.mindmap-float-root:hover .mindmap-float-popover,
.mindmap-float-root.is-pinned .mindmap-float-popover,
.mindmap-float-root.is-open .mindmap-float-popover,
.mindmap-float-popover:fullscreen,
.mindmap-float-popover.mm-pseudo-fullscreen {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.mindmap-float-anchor {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: linear-gradient(145deg, var(--primary-light), var(--surface));
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, border-color 0.15s;
  pointer-events: auto;
}
.mindmap-float-anchor:hover {
  transform: scale(1.05);
  border-color: var(--primary);
}
.mindmap-float-anchor-icon {
  font-size: 22px;
  line-height: 1;
}
.mindmap-icon-svg {
  display: block;
  flex-shrink: 0;
}
.mindmap-float-anchor .mindmap-icon-svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
  opacity: 0.92;
}
.mindmap-panel-icon.mindmap-icon-svg-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mindmap-panel-icon.mindmap-icon-svg-wrap .mindmap-icon-svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
  opacity: 0.9;
}
/* 全屏：原生 Fullscreen API */
.mindmap-float-popover:fullscreen {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0;
  filter: none;
}
.mindmap-float-popover:fullscreen .mindmap-float-resize-handle {
  display: none;
}
/* 全屏：侧栏等环境不支持 API 时的伪全屏 */
.mindmap-float-popover.mm-pseudo-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  z-index: 10000;
  border-radius: 0;
  filter: none;
}
.mindmap-float-popover.mm-pseudo-fullscreen .mindmap-float-resize-handle {
  display: none;
}
.mindmap-float-root.is-mindmap-fullscreen .mindmap-float-anchor {
  visibility: hidden;
  pointer-events: none;
}
.mindmap-float-anchor-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  pointer-events: none;
}
.mindmap-float-root.mindmap-just-updated .mindmap-float-anchor-pulse {
  animation: mindmap-pulse 0.85s ease-out 1;
}
@keyframes mindmap-pulse {
  0% { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.mindmap-panel {
  position: relative;
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  transition: all 0.25s ease;
}
.mindmap-panel.mindmap-panel--float {
  margin: 0;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mindmap-panel.collapsed .mindmap-panel-body {
  display: none;
}
.mindmap-panel.collapsed .mindmap-panel-toggle-btn {
  transform: rotate(-90deg);
}
.mindmap-panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  cursor: pointer;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  user-select: none;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.mindmap-panel-header:hover {
  background: var(--surface-hover, rgba(0,0,0,0.03));
}
.mindmap-panel-icon {
  font-size: 18px;
}
.mindmap-panel-title {
  flex: 1;
  min-width: 72px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.mindmap-panel.final .mindmap-panel-header {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, var(--surface) 100%);
  border-color: rgba(59, 130, 246, 0.35);
}
.mindmap-panel.final .mindmap-panel-title {
  color: var(--primary);
}
.mindmap-panel-pin-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
  opacity: 0.75;
}
.mindmap-panel-pin-btn:hover {
  opacity: 1;
  background: var(--surface-hover);
}
.mindmap-float-root.is-pinned .mindmap-panel-pin-btn {
  opacity: 1;
  color: var(--primary);
}
.mindmap-panel-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 10px;
  padding: 4px 8px;
  transition: transform 0.2s;
}
.mindmap-panel-body {
  position: relative;
  overflow: auto;
  border-top: 1px solid var(--border);
}
/* 浮窗内：body 作为纵向 flex 容器，才能把剩余高度交给画布，viewport 内上下滚动 */
.mindmap-panel--float .mindmap-panel-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.mindmap-panel--float.collapsed .mindmap-panel-body {
  flex: none;
  max-height: 0 !important;
  overflow: hidden;
  padding: 0;
  border-top: none;
}
.mindmap-panel--float .mindmap-canvas {
  flex: 1;
  min-height: 0;
  height: auto;
  max-height: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mindmap-canvas {
  width: 100%;
  max-height: 60vh;
  min-height: 300px;
  overflow: scroll;
  padding: 12px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.mindmap-zoom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 4;
}
.mindmap-zoom-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mindmap-zoom-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--primary);
}
.mindmap-zoom-level {
  min-width: 44px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}
.mindmap-zoom-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.mindmap-zoom-inner {
  display: inline-block;
  vertical-align: top;
  transform-origin: top left;
  transition: transform 0.1s ease-out;
}
.mindmap-zoom-inner .mindmap-svg {
  display: block;
}
.mindmap-svg {
  max-width: none;
  max-height: none;
}
.mindmap-node {
  transition: filter 0.15s;
}
.mindmap-node:hover {
  filter: brightness(0.97);
}
.mindmap-node.draggable:active {
  filter: brightness(0.95);
}
.mindmap-raw-toggle {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 2;
}
/* 浮窗内画布顶部有缩放条，避免 📝 与工具条重叠 */
.mindmap-panel--float .mindmap-raw-toggle {
  top: 44px;
  z-index: 6;
}
.mindmap-raw-toggle button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
}
.mindmap-raw-toggle button:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.mindmap-raw {
  margin: 0;
  padding: 12px 16px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  background: var(--bg);
}
/* 浮窗文本视图：占满剩余高度并独立滚动 */
.mindmap-panel--float .mindmap-raw {
  flex: 1;
  min-height: 0;
  max-height: none;
  -webkit-overflow-scrolling: touch;
}

/* 对话流内嵌的思维导图（兼容旧展示） */
.mindmap-panel-inline {
  margin: 8px 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.mindmap-panel-inline .mindmap-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.mindmap-panel-inline .mindmap-body {
  max-height: 320px;
  overflow: auto;
}
.mindmap-panel-inline .mindmap-content {
  margin: 0;
  padding: 12px 16px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* ═══════════════ 本体推理右侧边栏 ═══════════════ */

.ontology-drawer {
  position: relative;
  z-index: 210;
  width: var(--ontology-drawer-w, 420px);
  max-width: 70vw;
  min-width: 280px;
  height: 100vh;
  display: none;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
}
.ontology-drawer:not(.resizing) {
  transition: width 0.25s ease;
}
.ontology-resize-handle {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.ontology-resize-handle:hover,
.ontology-resize-handle.active {
  background: var(--primary, #3b82f6);
  opacity: 0.5;
}
.ontology-drawer.open {
  display: flex;
}
.ontology-drawer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  user-select: none;
  flex-shrink: 0;
}
.ontology-drawer.final .ontology-drawer-header {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, var(--surface) 100%);
  border-color: rgba(59, 130, 246, 0.35);
}
.ontology-drawer.final .ontology-panel-title {
  color: var(--primary);
}
.onto-dl-menu {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  padding: 4px;
  min-width: 160px;
  animation: onto-dl-fade-in 0.12s ease;
}
@keyframes onto-dl-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.onto-dl-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s;
}
.onto-dl-opt:hover {
  background: var(--surface-hover, rgba(255,255,255,0.06));
}

.ontology-drawer-action {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ontology-drawer-action:hover {
  background: var(--surface-hover);
  color: var(--primary);
}
.ontology-drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ontology-drawer-close:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.ontology-drawer-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ontology-panel-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.ontology-panel-title {
  flex: 1;
  min-width: 60px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.ontology-toggle-btn {
  position: relative;
}
.ontology-toggle-icon {
  font-size: 16px;
  line-height: 1;
}
.ontology-toggle-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  border: 1.5px solid var(--surface);
}

/* Tab 栏 */
.ontology-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.ontology-tab {
  flex: 1;
  padding: 7px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.ontology-tab:hover {
  color: var(--text);
  background: var(--surface-hover, rgba(0,0,0,0.02));
}
.ontology-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Phase tab bar (second-level) */
.ontology-phase-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  padding: 0 4px;
}
.ontology-phase-tab {
  padding: 5px 10px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.ontology-phase-tab:hover {
  color: var(--text);
  background: var(--surface-hover, rgba(0,0,0,0.02));
}
.ontology-phase-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Tab 内容区域 */
.ontology-tab-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Zoom 栏 */
.ontology-zoom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.ontology-zoom-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ontology-zoom-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
  color: var(--primary);
}
.ontology-zoom-level {
  min-width: 44px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

/* Toolbar separator */
.ontology-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Layer filter buttons */
.ontology-layer-filters {
  display: flex;
  gap: 3px;
  margin-left: auto;
}
.ontology-layer-btn {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  opacity: 0.55;
}
.ontology-layer-btn:hover {
  border-color: var(--text-secondary);
  opacity: 0.8;
}
.ontology-layer-btn.active {
  opacity: 1;
  font-weight: 600;
  color: var(--text);
}
.ontology-layer-btn.active[data-layer="fact"] {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  color: #3b82f6;
}
.ontology-layer-btn.active[data-layer="interpretation"] {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
}
.ontology-layer-btn.active[data-layer="conclusion"] {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

/* Viewport — 唯一滚动层（缩放通过 SVG 尺寸实现，保证可横向/纵向滚动） */
.ontology-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  touch-action: pan-x pan-y;
}
.ontology-viewport.ontology-viewport-panning {
  cursor: grabbing;
  user-select: none;
}
.ontology-inner {
  display: inline-block;
  vertical-align: top;
}
.ontology-inner .ontology-graph-svg,
.ontology-inner .ontology-chain-svg {
  display: block;
  max-width: none;
  max-height: none;
}

/* 原始数据视图 */
.ontology-raw {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 12px 16px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

/* 节点样式 */
.ontology-node {
  transition: filter 0.15s, opacity 0.15s;
}
.ontology-node:hover {
  filter: brightness(1.08);
}
[data-theme="dark"] .ontology-node:hover {
  filter: brightness(1.15);
}

/* Entity detail panel */
.ontology-node-detail {
  position: absolute;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 180px;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 20;
  animation: ond-fadein 0.18s ease;
  pointer-events: auto;
}
@keyframes ond-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ond-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ond-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text, #111);
}
.ond-type {
  font-size: 0.714rem;
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}
.ond-value {
  font-size: 1.571rem;
  font-weight: 800;
  color: var(--text, #111);
  margin: 4px 0 6px;
  line-height: 1.2;
}
.ond-props {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border, #e5e7eb);
}
.ond-prop {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.857rem;
}
.ond-prop-key {
  color: var(--text-secondary, #555);
  white-space: nowrap;
}
.ond-prop-val {
  color: var(--text, #111);
  font-weight: 600;
  text-align: right;
}
.ond-evidence {
  font-size: 0.786rem;
  color: var(--text-secondary, #555);
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border, #e5e7eb);
  line-height: 1.45;
}
.ond-evidence-label {
  font-weight: 600;
  color: var(--text-secondary, #444);
}
.ond-source {
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(59, 130, 246, 0.06);
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.1);
}
[data-theme="dark"] .ond-source {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.18);
}
.ond-source-label {
  font-size: 0.714rem;
  font-weight: 600;
  color: #3b82f6;
  margin-bottom: 3px;
}
.ond-source-item {
  font-size: 0.786rem;
  color: var(--text, #333);
  line-height: 1.5;
  word-break: break-all;
  padding: 2px 0;
}
.ond-source-item + .ond-source-item {
  border-top: 1px dashed rgba(59, 130, 246, 0.15);
  margin-top: 2px;
  padding-top: 4px;
}
.ond-source-item .ond-link {
  color: #3b82f6;
  font-weight: 600;
}
.ond-link {
  color: var(--accent, #3b82f6);
  text-decoration: none;
  word-break: break-all;
  cursor: pointer;
}
.ond-link:hover {
  text-decoration: underline;
  color: var(--accent-hover, #2563eb);
}
.ond-prop-val .ond-link {
  font-weight: 600;
}

/* Reasoning step detail panel */
.ontology-step-detail {
  position: absolute;
  top: 8px;
  right: 8px;
  max-width: 380px;
  min-width: 260px;
  max-height: calc(100% - 16px);
  overflow-y: auto;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  padding: 12px 14px;
  z-index: 50;
  animation: ond-fadein 0.15s ease;
}
.osd-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.osd-type {
  font-size: 11px;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.osd-conf {
  font-size: 12px;
  font-weight: 700;
}
.osd-id {
  font-size: 10px;
  color: var(--text-secondary, #999);
  margin-left: auto;
  font-family: monospace;
}
.osd-content {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text, #222);
  white-space: pre-wrap;
  word-break: break-word;
  padding: 8px 10px;
  background: var(--surface, #f8f9fa);
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  margin-bottom: 8px;
}
.osd-section {
  margin-top: 6px;
}
.osd-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary, #666);
  display: block;
  margin-bottom: 4px;
}
.osd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.osd-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid var(--border, #ddd);
  background: var(--bg, #fff);
  color: var(--text-secondary, #555);
  white-space: nowrap;
}

/* User question card */
.gc-user-question {
  border-left: 3px solid #f59e0b;
}
.gc-avatar-question {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #fff;
  font-size: 14px;
}
.uq-question-text {
  font-size: 13.5px;
  line-height: 1.6;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  margin-bottom: 10px;
  color: var(--text);
}
.uq-answer-area {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.uq-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  min-height: 36px;
  font-family: inherit;
}
.uq-input:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.uq-submit-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.uq-submit-btn:hover {
  opacity: 0.9;
}
.uq-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.uq-answered {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.uq-timeout {
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.05);
}

/* 澄清问答卡片：视觉上与普通提问区分 */
.gc-user-question--clarify {
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.06), rgba(99, 102, 241, 0.02));
  border-left: 3px solid rgba(99, 102, 241, 0.45);
  border-radius: 8px;
  padding-left: 8px;
}
.gc-user-question--clarify .uq-question-text {
  white-space: pre-wrap;
  line-height: 1.55;
}
.uq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.uq-skip-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}
.uq-skip-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}
.uq-skip-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── SubAgent 时间线输出 ── */
.subagent-wrapper {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-secondary);
}
.subagent-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
.subagent-icon { font-size: 14px; flex-shrink: 0; }
.subagent-label { font-weight: 600; color: var(--text); flex-shrink: 0; }
.subagent-task {
  color: var(--text-secondary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
.subagent-status {
  flex-shrink: 0;
  color: #f59e0b;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.subagent-status.done { color: #10b981; }
.subagent-done-icon { font-weight: 700; }
.subagent-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid var(--border);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.subagent-spinner-sm {
  display: inline-block;
  width: 8px; height: 8px;
  border: 1.5px solid var(--border);
  border-top-color: #10b981;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.subagent-body { padding: 0; }
.subagent-timeline { display: flex; flex-direction: column; }
.subagent-step {
  border-bottom: 1px solid var(--border);
  padding: 6px 10px;
}
.subagent-step:last-child { border-bottom: none; }
.subagent-step-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.subagent-step-icon {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  color: #f59e0b;
}
.subagent-step-done { color: #10b981; font-weight: 700; }
.subagent-step-title { flex: 1; }
.subagent-step-args {
  margin: 0 0 4px 22px;
}
.subagent-step-args pre,
.subagent-step-result pre {
  margin: 0;
  padding: 6px;
  background: var(--bg);
  border-radius: 4px;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.subagent-step-result { margin: 0 0 0 22px; }
.subagent-step-result:empty { display: none; }

.subagent-step-progress {
  margin: 4px 0 6px 22px;
  padding: 6px 8px;
  background: var(--bg);
  border-left: 2px solid var(--accent, #4a9eff);
  border-radius: 3px;
  font-size: 11.5px;
  color: var(--text-secondary);
}
.subagent-step-progress:empty { display: none; }
.subagent-step-progress .progress-line {
  padding: 1px 0;
  line-height: 1.5;
  word-break: break-word;
}
.subagent-step-progress .progress-start {
  color: var(--text);
  font-weight: 500;
}
.subagent-step-progress .progress-heartbeat {
  color: var(--text-secondary);
  font-style: italic;
  opacity: 0.85;
}
.subagent-step-progress .progress-end {
  color: var(--accent, #4a9eff);
  font-weight: 500;
}

.fin-tool-progress-section .fin-tool-progress-content {
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg);
  border-left: 2px solid var(--accent, #4a9eff);
  border-radius: 3px;
  padding: 6px 8px;
}
.fin-tool-progress-section .progress-line {
  padding: 1px 0;
  line-height: 1.5;
  word-break: break-word;
}
.fin-tool-progress-section .progress-start { color: var(--text); font-weight: 500; }
.fin-tool-progress-section .progress-heartbeat { font-style: italic; opacity: 0.85; }
.fin-tool-progress-section .progress-end { color: var(--accent, #4a9eff); font-weight: 500; }

/* 主持人识别的用户需求卡片 */
.fin-host-goal {
  margin: 8px 0 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.08), rgba(74, 158, 255, 0.02));
  border-left: 3px solid var(--accent, #4a9eff);
  border-radius: 4px;
  font-size: 12.5px;
  line-height: 1.6;
}
.fin-host-goal-header {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 12.5px;
}
.fin-host-goal-row {
  display: flex;
  gap: 8px;
  margin: 3px 0;
  align-items: flex-start;
}
.fin-host-goal-label {
  flex: 0 0 auto;
  min-width: 56px;
  color: var(--text-secondary);
  font-size: 11.5px;
  padding-top: 1px;
}
.fin-host-goal-value {
  flex: 1 1 auto;
  color: var(--text);
  word-break: break-word;
}
.fin-host-goal-type {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(74, 158, 255, 0.15);
  color: var(--accent, #4a9eff);
  flex: 0 0 auto;
}
.fin-host-goal-type-personal { background: rgba(255, 152, 0, 0.15); color: #ff9800; }
.fin-host-goal-type-objective { background: rgba(76, 175, 80, 0.15); color: #4caf50; }
.fin-host-goal-type-hybrid { background: rgba(156, 39, 176, 0.15); color: #9c27b0; }
.subagent-content-block {
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: break-word;
  border-top: 1px solid var(--border);
}
.subagent-content-block p { margin-bottom: 6px; }
.subagent-content-block p:last-child { margin-bottom: 0; }
.subagent-content-block h3 { font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.subagent-content-block h4 { font-size: 12.5px; font-weight: 600; margin: 8px 0 3px; }
.subagent-content-block ul, .subagent-content-block ol { padding-left: 18px; margin: 4px 0; }
.subagent-content-block li { margin: 2px 0; }
.subagent-content-block table { font-size: 11px; }
.subagent-content-block pre { font-size: 11px; padding: 8px; margin: 4px 0; }
.subagent-content-block a { color: var(--primary); text-decoration: none; }
.subagent-content-block a:hover { text-decoration: underline; }

/* ============================================================
   Responsive — Mobile (<= 768px)
   ============================================================ */

/* ---- 1. Global / Shell ---- */
@media (max-width: 768px) {
  #app { height: 100dvh; }

  /* ---- 2. Sidebar: full-screen overlay + backdrop ---- */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 1000;
    width: min(82vw, 320px);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  }
  .sidebar:not(.collapsed) {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    margin-left: 0;
    transform: translateX(-100%);
  }

  /* Collapsed rail hidden on mobile — use hamburger in topbar */
  .sidebar-collapsed-rail { display: none !important; }

  /* Backdrop overlay when sidebar is open */
  .sidebar::after {
    content: '';
    position: fixed;
    inset: 0;
    left: 100%;
    width: 100vw;
    background: rgba(0,0,0,0.35);
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
    z-index: -1;
  }
  .sidebar:not(.collapsed)::after {
    opacity: 1;
    pointer-events: auto;
  }

  /* ---- 3. Topbar: compact mobile layout ---- */
  .topbar {
    padding: 6px 10px;
    gap: 6px;
    min-height: 44px;
    flex-wrap: wrap;
  }
  /* Hide zoom controls & layout switcher on mobile */
  .zoom-controls { display: none; }
  .topbar-layout { display: none; }

  /* Model tags scrollable and compact */
  .topbar-models { gap: 4px; }
  .model-tag { font-size: 10px; padding: 2px 8px; }

  /* ---- 4. Input toolbar: wrap on narrow screens ---- */
  .input-toolbar {
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
    row-gap: 6px;
  }
  .toolbar-divider {
    display: none;
  }
  .ontology-mode-selector,
  .discussion-mode-selector,
  .chat-mode-selector {
    flex: 0 0 auto;
    gap: 4px;
  }
  .ontology-mode-label,
  .discussion-mode-label,
  .chat-mode-label {
    font-size: 11px;
  }
  .ontology-pill,
  .discussion-pill,
  .chat-mode-pill {
    font-size: 11px;
    padding: 3px 8px;
  }
  .web-toggle { padding: 3px 6px; font-size: 12px; }
  .web-toggle .toggle-label { font-size: 11px; }

  /* Input area spacing */
  .input-area {
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }
  .input-wrapper { padding: 6px 10px; }
  #user-input { font-size: 16px; /* prevent iOS zoom on focus */ }

  #main {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  /* ---- 5. Chat columns: force single column on mobile ---- */
  .chat-columns.cols-2,
  .chat-columns.cols-3 {
    grid-template-columns: 1fr !important;
  }
  .chat-column { border-right: none; }

  /* Messages: compact padding */
  .message { padding: 10px 12px; }
  .message-content { font-size: 14px; }

  /* ---- 6. Ontology drawer: full-screen on mobile ---- */
  .ontology-drawer {
    position: fixed;
    inset: 0;
    width: 100vw !important;
    max-width: 100vw;
    min-width: 0;
    height: 100dvh;
    z-index: 1100;
    border-left: none;
    border-radius: 0;
  }
  .ontology-resize-handle { display: none; }
  .ontology-zoom-bar {
    flex-wrap: wrap;
    gap: 4px;
  }
  .ontology-layer-filters {
    flex-wrap: wrap;
    gap: 3px;
  }
  .ontology-layer-btn {
    font-size: 11px;
    padding: 3px 8px;
  }

  /* ---- 7. Mindmap float: bottom-center on mobile ---- */
  .mindmap-float-root {
    left: 50% !important;
    transform: translateX(-50%);
    bottom: 100px !important;
  }
  .mindmap-float-popover {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    min-width: 0;
  }
  .mindmap-float-anchor {
    width: 40px;
    height: 40px;
  }
  .mindmap-size-presets { display: none; }
  .mindmap-float-resize-handle { display: none; }

  /* ---- 8. Settings panel: full-screen on mobile ---- */
  .settings-overlay {
    padding-top: 0;
    align-items: stretch;
  }
  .settings-panel {
    width: 100%;
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }
  .settings-panel-body { padding: 14px 14px; }
  .sp-model-card { margin-bottom: 10px; }
  .sp-setting-row { flex-wrap: wrap; gap: 6px; }

  /* ---- 9. Export options modal ---- */
  .export-options-modal {
    width: 94%;
    max-width: none;
    margin: auto 3%;
  }

  /* ---- 10. Scroll FAB: bigger touch targets ---- */
  .scroll-fab {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  /* ---- 11. Search history panel ---- */
  .search-history-panel {
    max-height: 50vh;
  }
}

/* ============================================================
   Mobile-mode (mobile.html): ensure input pinned to bottom
   on tablets (>768px) where the narrow media query won't fire
   ============================================================ */
.mobile-mode #app {
  height: 100dvh;
  height: -webkit-fill-available;
}
.mobile-mode #main {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
.mobile-mode .input-area {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.mobile-mode .sidebar-collapsed-rail { display: none !important; }
.mobile-mode .zoom-controls { display: none; }
.mobile-mode .topbar-layout { display: none; }

/* ============================================================
   Mobile Voting — results area, status, tally, voter popup,
   template button, ActionSheet, template tag
   ============================================================ */
.mobile-voting-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}
.mvr-status {
  text-align: center;
  padding: 14px 0 8px;
  font-size: 14px;
  color: var(--text-secondary);
  min-height: 24px;
}
.mvr-welcome {
  padding-top: 30vh;
  font-size: 15px;
  color: var(--text-secondary);
  opacity: .6;
}
.mvr-status-progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mvr-status-done {
  color: var(--primary, #8b5cf6);
  font-weight: 600;
}
.mvr-dot {
  width: 5px; height: 5px;
  background: var(--primary, #8b5cf6);
  border-radius: 50%;
  animation: mvrDotPulse 1.4s infinite ease-in-out;
}
.mvr-dot:nth-child(2) { animation-delay: .2s; }
.mvr-dot:nth-child(3) { animation-delay: .4s; }
@keyframes mvrDotPulse {
  0%,80%,100% { transform: scale(.5); opacity: .3; }
  40% { transform: scale(1); opacity: 1; }
}

/* Tally */
.mvr-tally {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.mvr-tally.mvr-tally-final {
  border-color: #a78bfa;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.3);
}
.mvr-tally-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.mvr-tally-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.mvr-tally-total {
  font-size: 13px;
  color: var(--text-secondary);
}
.mvr-tally-row { margin-bottom: 10px; }
.mvr-tally-winner { }
.mvr-tally-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.mvr-tally-option {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.mvr-tally-count {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.mvr-tally-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.mvr-tally-bar {
  height: 100%;
  background: var(--primary, #8b5cf6);
  border-radius: 3px;
  transition: width .4s ease;
}
.mvr-tally-winner .mvr-tally-bar {
  background: linear-gradient(90deg, var(--primary, #8b5cf6), #a78bfa);
}
.mvr-tally-voters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* Voter tags (clickable) */
.mvr-voter-tag {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  background: color-mix(in srgb, var(--primary, #8b5cf6) 10%, transparent);
  color: var(--primary, #8b5cf6);
  border-radius: 12px;
  cursor: pointer;
  transition: background .15s;
  user-select: none;
}
.mvr-voter-tag:active {
  background: color-mix(in srgb, var(--primary, #8b5cf6) 20%, transparent);
}

/* Conclusion */
.mvr-conclusion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.mvr-conclusion-toggle, .mvr-summary-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.mvr-collapse-arrow {
  font-size: 12px;
  color: var(--text-secondary);
  transition: transform 0.2s;
}
.mvr-conclusion-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.mvr-conclusion-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* Summary process */
.mvr-summary-process {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.mvr-summary-process-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.mvr-summary-process-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

/* Voter detail popup */
.mvr-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mvr-popup {
  width: 100%;
  max-width: 500px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: mvrSlideUp .25s ease;
}
@keyframes mvrSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.mvr-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.mvr-popup-model {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.mvr-popup-close {
  border: none;
  background: none;
  font-size: 22px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
}
.mvr-popup-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.mvr-popup-pill {
  padding: 4px 12px;
  font-size: 13px;
  background: var(--primary, #8b5cf6);
  color: #fff;
  border-radius: 14px;
}
.mvr-popup-section {
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.mvr-popup-section-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Template button (in input-wrapper) */
.mvr-template-btn {
  display: none;
  border: none;
  background: none;
  color: var(--primary, #8b5cf6);
  cursor: pointer;
  padding: 6px;
  flex-shrink: 0;
  border-radius: 6px;
  transition: background .15s;
}
.mvr-template-btn:active {
  background: color-mix(in srgb, var(--primary, #8b5cf6) 12%, transparent);
}
.mobile-mode .mvr-template-btn {
  display: flex;
  align-items: center;
}
.mvr-multi-toggle {
  display: none;
}
.mobile-mode .mvr-multi-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  padding: 4px 6px;
  border-radius: 6px;
  user-select: none;
}
.mobile-mode .mvr-multi-toggle:active {
  background: var(--hover-bg, rgba(0,0,0,0.05));
}
.mvr-multi-toggle input {
  margin: 0;
  width: 14px;
  height: 14px;
}
.mvr-multi-label {
  white-space: nowrap;
}

/* Template tag (above input) */
.mvr-template-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  margin: 0 12px;
  background: color-mix(in srgb, var(--primary, #8b5cf6) 8%, transparent);
  border-radius: 8px;
  font-size: 12px;
  color: var(--primary, #8b5cf6);
}
.mvr-template-tag-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mvr-template-tag-close {
  border: none;
  background: none;
  color: var(--primary, #8b5cf6);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* ActionSheet overlay */
.mvr-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.mvr-sheet {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: mvrSlideUp .25s ease;
}
.mvr-sheet-header {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 14px;
}
.mvr-sheet-section {
  margin-bottom: 12px;
}
.mvr-sheet-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-left: 2px;
}
.mvr-sheet-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--bg, var(--bg-primary));
  color: var(--text);
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background .12s, border-color .12s;
}
.mvr-sheet-item:active {
  background: color-mix(in srgb, var(--primary, #8b5cf6) 8%, transparent);
  border-color: var(--primary, #8b5cf6);
}
.mvr-sheet-ai {
  color: var(--primary, #8b5cf6);
  font-weight: 600;
  border-style: dashed;
}
.mvr-sheet-custom-row {
  display: flex;
  gap: 8px;
}
.mvr-sheet-custom-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg, var(--bg-primary));
  color: var(--text);
  outline: none;
}
.mvr-sheet-custom-input:focus {
  border-color: var(--primary, #8b5cf6);
}
.mvr-sheet-custom-ok {
  padding: 10px 16px;
  border: none;
  background: var(--primary, #8b5cf6);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.mvr-sheet-cancel {
  display: block;
  width: 100%;
  text-align: center;
  border: none;
  background: var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 6px;
}

/* ============================================================
   Small phones (< 400px)
   ============================================================ */
@media (max-width: 400px) {
  .topbar { padding: 4px 8px; }
  .model-tag { font-size: 9px; padding: 2px 6px; }
  .input-toolbar {
    padding: 4px 6px;
    gap: 3px;
  }
  .ontology-mode-selector,
  .discussion-mode-selector,
  .chat-mode-selector,
  .voting-mode-selector {
    flex: 1 1 100%;
  }
  .mindmap-float-root {
    bottom: 80px !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   投票模式样式
   ═══════════════════════════════════════════════════════════════ */

.voting-mode-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}
.voting-mode-label {
  font-weight: 500;
  white-space: nowrap;
}
.voting-mode-pills {
  display: flex;
  background: var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.voting-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.voting-pill:hover {
  color: var(--text);
  background: rgba(128,128,128,.12);
}
.voting-pill.active {
  background: #8b5cf6;
  color: #fff;
  box-shadow: 0 1px 4px rgba(139,92,246,.30);
  font-weight: 600;
}

/* 投票选项编辑器 */
.voting-options-editor {
  padding: 10px 14px;
  background: var(--surface, var(--bg-secondary));
  border-bottom: 1px solid var(--border);
}
.voting-options-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.voting-options-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.voting-multi-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.voting-multi-toggle input {
  margin: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}
.toggle-label-sm {
  font-size: 12px;
}
.voting-opt-add-btn {
  border: 1px dashed var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-left: auto;
  transition: background 0.15s, color 0.15s;
}
.voting-opt-add-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.voting-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.voting-opt-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg, var(--bg-primary));
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.voting-opt-tag:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 15%, transparent);
}
.voting-opt-text {
  outline: none;
  flex: 1;
  min-width: 0;
  color: var(--text);
  line-height: 1.4;
}
.voting-opt-text:empty::before {
  content: '输入选项...';
  color: var(--text-secondary);
  opacity: .5;
}
.voting-opt-del {
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.voting-opt-del:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* 投票模型面板 */
.voting-model-panel {
  margin-top: 12px;
  padding: 8px 0;
}
.voting-model-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.voting-model-act-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 4px;
  cursor: pointer;
}
.voting-model-act-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.voting-model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.voting-model-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.voting-model-item:hover {
  background: var(--bg-secondary);
}
.voting-model-item input {
  margin: 0;
  width: 14px;
  height: 14px;
}

/* 投票内联模型选择 */
.voting-models-inline {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.voting-models-inline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.voting-models-inline-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.voting-models-toggle-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
}
.voting-models-toggle-btn:hover {
  text-decoration: underline;
}
.voting-models-inline-summary {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.voting-models-inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.voting-model-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.voting-model-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.voting-model-chip.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 投票确认卡片 */
.voting-confirm-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}
.voting-confirm-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.voting-regen-section {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.voting-regen-input-row {
  display: flex;
  gap: 6px;
}
.voting-regen-feedback {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.voting-regen-feedback:focus {
  border-color: var(--primary);
}
.voting-regen-btn {
  border: 1px dashed var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  align-self: flex-start;
}
.voting-regen-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.voting-regen-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.voting-regen-count {
  font-size: 12px;
  opacity: 0.7;
}
.voting-confirm-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.voting-multi-toggle-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}
.voting-multi-toggle-inline input {
  margin: 0;
  width: 14px;
  height: 14px;
}
.voting-confirm-btn {
  margin-left: auto;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}
.voting-confirm-btn:hover {
  opacity: .9;
}
.voting-confirm-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* 已确认选项 — 表格样式 */
.voting-confirmed-card {
  background: var(--surface, var(--bg-secondary));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0;
}
.voting-confirmed-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}
.voting-confirmed-table {
  width: 100%;
  border-collapse: collapse;
}
.voting-confirmed-row td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}
.voting-confirmed-row:last-child td {
  border-bottom: none;
}
.voting-confirmed-num {
  width: 32px;
  text-align: center;
  font-weight: 600;
  color: var(--primary);
  opacity: 0.8;
}
.voting-confirmed-text {
  line-height: 1.5;
}

/* ═══ 搜索进度卡片 ═══ */
.voting-search-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 10px 0;
  transition: all 0.3s ease;
}
.voting-search-card.search-done {
  border-color: #52c41a44;
  background: linear-gradient(135deg, var(--bg-secondary), rgba(82, 196, 26, 0.04));
}
.voting-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.voting-search-icon { font-size: 14px; }
.voting-search-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent, #7c5cfc);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.voting-search-queries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.voting-search-query {
  display: inline-block;
  background: rgba(124, 92, 252, 0.08);
  border: 1px solid rgba(124, 92, 252, 0.2);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 投票结果卡片 */
/* ═══ 投票卡片 ═══ */
.voting-cast-card {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 5px 0;
  font-size: 12px;
  animation: fadeSlideIn .35s ease;
  transition: border-color .2s;
}
.voting-cast-card:hover { border-color: rgba(139, 92, 246, 0.3); }
.voting-cast-expanded { border-color: rgba(139, 92, 246, 0.4); }
.voting-cast-abstain {
  opacity: 0.6;
  border-style: dashed;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}
.voting-cast-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.voting-cast-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 110px;
  flex-shrink: 0;
}
.voting-cast-icon { font-size: 14px; }
.voting-cast-model {
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}
.voting-cast-right {
  flex: 1;
  min-width: 0;
}
.voting-cast-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.voting-cast-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.25);
}
.voting-cast-pill-empty {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
  font-weight: 400;
}
.voting-cast-expand-btn {
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.voting-cast-expand-btn:hover {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}
.voting-cast-summary {
  margin-top: 6px;
  padding: 6px 10px;
  background: rgba(139, 92, 246, 0.05);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}
.voting-cast-reason {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 4px;
  padding-left: 2px;
}
.voting-cast-detail {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.voting-cast-detail-inner {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
}
.voting-cast-detail-inner p { margin: 0 0 8px; }
.voting-cast-detail-inner h1, .voting-cast-detail-inner h2,
.voting-cast-detail-inner h3, .voting-cast-detail-inner h4 {
  margin: 10px 0 5px;
  font-size: 13px;
}
.voting-cast-detail-inner ul, .voting-cast-detail-inner ol {
  padding-left: 18px;
  margin: 4px 0;
}
.voting-cast-detail-inner li { margin-bottom: 3px; }
.voting-cast-detail-inner strong { color: var(--text); }
.voting-cast-detail-inner code {
  background: var(--bg-tertiary, var(--border));
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.voting-cast-detail-inner blockquote {
  border-left: 3px solid var(--border);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--text-secondary);
}

/* ═══ 投票汇总 ═══ */
.voting-tally-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.voting-tally-card.voting-tally-final {
  border-color: #a78bfa;
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.3);
}
.voting-tally-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.voting-tally-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.voting-tally-total {
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-tertiary, var(--border));
  padding: 2px 8px;
  border-radius: 10px;
}
.voting-tally-row {
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .2s;
}
.voting-tally-winner {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
}
.voting-tally-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.voting-tally-medal {
  font-size: 14px;
  min-width: 18px;
}
.voting-tally-option {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.voting-tally-bar-wrap {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.voting-tally-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 5px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.voting-tally-winner .voting-tally-bar {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}
.voting-tally-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 75px;
  text-align: right;
  white-space: nowrap;
}
.voting-tally-voters {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding-left: 26px;
}

/* ═══ 主持人总结 ═══ */
.voting-summary-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid #8b5cf6;
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
}
.voting-summary-title {
  font-size: 14px;
  font-weight: 700;
  color: #8b5cf6;
  margin-bottom: 12px;
}
.voting-summary-content {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.voting-summary-content p { margin: 0 0 8px; }
.voting-summary-content h1, .voting-summary-content h2,
.voting-summary-content h3, .voting-summary-content h4 {
  margin: 12px 0 6px;
  color: var(--text);
}
.voting-summary-content ul, .voting-summary-content ol {
  padding-left: 20px;
  margin: 6px 0;
}
.voting-summary-content li { margin-bottom: 4px; }
.voting-summary-content strong { color: var(--text); }
.voting-summary-content code {
  background: var(--bg-tertiary, var(--border));
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ═══ 投票模式：回答中指示器 ═══ */
.voting-answering-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 0;
  color: var(--text-secondary);
  font-size: 13px;
}
.voting-answering-indicator.voting-done {
  color: var(--primary, #8b5cf6);
}
.voting-answering-dot {
  width: 6px;
  height: 6px;
  background: var(--primary, #8b5cf6);
  border-radius: 50%;
  animation: votingDotPulse 1.4s infinite ease-in-out;
}
.voting-answering-dot:nth-child(1) { animation-delay: 0s; }
.voting-answering-dot:nth-child(2) { animation-delay: 0.2s; }
.voting-answering-dot:nth-child(3) { animation-delay: 0.4s; }
.voting-done .voting-answering-dot { display: none; }
@keyframes votingDotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.voting-answering-text {
  margin-left: 4px;
  font-weight: 500;
}

/* ═══ 投票模式：模型回答结果卡片 ═══ */
.voting-result-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  animation: fadeSlideIn .3s ease;
}
.voting-result-abstain {
  opacity: 0.7;
  border-style: dashed;
}
.voting-result-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.voting-result-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.voting-result-pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.25);
}
.voting-result-pill-empty {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
  font-weight: 400;
}
.voting-result-summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  padding: 8px 10px;
  background: rgba(139, 92, 246, 0.04);
  border-radius: 6px;
  margin-bottom: 8px;
}
.voting-result-summary p { margin: 0 0 6px; }
.voting-result-summary p:last-child { margin: 0; }
.voting-result-reason {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
  padding-left: 2px;
}
.voting-result-analysis {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 4px;
}
.voting-result-analysis-inner {
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
}
.voting-result-analysis-inner p { margin: 0 0 8px; }
.voting-result-analysis-inner h1,
.voting-result-analysis-inner h2,
.voting-result-analysis-inner h3,
.voting-result-analysis-inner h4 {
  margin: 10px 0 5px;
  font-size: 13px;
}
.voting-result-analysis-inner ul,
.voting-result-analysis-inner ol {
  padding-left: 18px;
  margin: 4px 0;
}
.voting-result-analysis-inner li { margin-bottom: 3px; }
.voting-result-analysis-inner strong { color: var(--text); }
.voting-result-analysis-inner code {
  background: var(--bg-tertiary, var(--border));
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}
.voting-result-analysis-inner blockquote {
  border-left: 3px solid var(--border);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--text-secondary);
}

/* 移动端折叠详情 */
.voting-result-expand-btn {
  font-size: 11px;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: auto;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.voting-result-expand-btn:hover {
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.08);
}
.voting-result-detail-collapsed {
  display: none;
}

/* ═══════ Voting Results Wrapper ═══════ */
.voting-results-wrapper {
  margin: 12px 0 8px;
  border-radius: 10px;
  overflow: hidden;
}

/* Progress bar */
.voting-early-status {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 14px 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  animation: voting-pulse 1.5s ease-in-out infinite;
}
@keyframes voting-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.voting-error-card {
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  margin: 14px 0;
  font-size: 13px;
  color: #991b1b;
  display: flex;
  align-items: center;
  gap: 8px;
}
[data-theme="dark"] .voting-error-card {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.voting-progress-area {
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.voting-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.voting-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #8b5cf6, #6d28d9);
  border-radius: 3px;
  transition: width .4s ease;
}
.voting-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* Tally area */
.voting-tally-area {
  margin-bottom: 6px;
}
.voting-tally-area:empty {
  display: none;
}

/* Collapse sections */
.voting-collapse-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
}
.voting-collapse-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background .15s;
}
.voting-collapse-toggle:hover {
  background: var(--surface-hover, rgba(0,0,0,.04));
}
.voting-collapse-arrow {
  font-size: 10px;
  transition: transform .2s;
  color: var(--text-secondary);
}
.voting-collapse-arrow.open {
  transform: rotate(90deg);
}
.voting-collapse-body {
  display: none;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}
.voting-collapse-body.open {
  display: block;
}

/* Individual cast items inside details collapse */
.voting-cast-item {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface);
  margin-bottom: 6px;
}
.voting-cast-item:last-child {
  margin-bottom: 0;
}
.voting-cast-item-abstain {
  opacity: .65;
}
.voting-cast-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.voting-cast-item-model {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
}
.voting-cast-item-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.voting-cast-item-detail {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.voting-cast-item-reason {
  margin-bottom: 4px;
}
.voting-cast-item-summary,
.voting-cast-item-analysis {
  margin-top: 4px;
}
.voting-cast-item-analysis {
  font-size: 11.5px;
  max-height: 200px;
  overflow-y: auto;
}

/* Explain section body (host summary) */
.voting-explain-section .voting-collapse-body {
  font-size: 13px;
  line-height: 1.7;
}

/* Voting done toast */
.voting-done-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 16px 32px;
  border-radius: 12px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.voting-done-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
