/**
 * chat.css - 聊天区域样式
 */

/* ===== Message List ===== */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  position: relative;
}

/* ===== Compact Overlay（自动压缩提示） ===== */
.compact-overlay {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  margin: -24px -32px 16px -32px;
  background: rgba(245, 158, 11, 0.1);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--color-warning-text);
  font-size: 15px;
  font-weight: 500;
  pointer-events: none;
  animation: compact-breathe 2.5s ease-in-out infinite;
}

.compact-overlay svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

@keyframes compact-breathe {
  0%, 100% { opacity: 1; background: rgba(245, 158, 11, 0.08); }
  50%      { opacity: 0.7; background: rgba(245, 158, 11, 0.16); }
}

/* Message list 呼吸状态 - 与 session 列表同步 */
.message-list.session-running {
  animation: breathe-chat-running 2.5s ease-in-out infinite;
}

.message-list.session-waiting {
  animation: breathe-chat-waiting 2.5s ease-in-out infinite;
}

@keyframes breathe-chat-running {
  0%, 100% { background-color: var(--breathe-chat-running-low); }
  50%      { background-color: var(--breathe-chat-running-high); }
}

@keyframes breathe-chat-waiting {
  0%, 100% { background-color: var(--breathe-chat-waiting-low); }
  50%      { background-color: var(--breathe-chat-waiting-high); }
}

.welcome-message {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

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

/* ===== Message Item ===== */
.message {
  margin-bottom: 20px;
  animation: message-in 0.3s ease;
  flex-wrap: wrap;
}

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

/* 消息时间标签 */
.message-time {
  width: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary, #999);
  margin-bottom: 4px;
  order: -1;
  user-select: none;
}

.message-bubble {
  max-width: 80%;
  padding: 12px 18px;
  border-radius: 20px;
  line-height: 1.65;
}

/* User Message */
.message.user {
  display: flex;
  justify-content: flex-end;
}

.message.user .message-bubble {
  background: var(--primary-gradient);
  color: var(--text-inverse);
  border-radius: 20px 20px 6px 20px;
  max-width: 65%;
  box-shadow: 0 2px 8px var(--primary-shadow);
}

/* 用户气泡内的引用块 */
.user-quote-block {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
}

.user-quote-bar {
  width: 3px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.7);
}

.user-quote-text {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Assistant Message */
.message.assistant {
  display: flex;
  justify-content: flex-start;
}

.message.assistant .message-bubble {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px 20px 20px 6px;
  max-width: 75%;
  padding: 16px 20px;
}

/* System Message */
.message.system {
  display: flex;
  justify-content: center;
}

.message.system .message-bubble {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  padding: 8px 16px;
}

/* Container startup hint */
.container-hint {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--primary-color);
  font-size: 15px;
  font-weight: 500;
  padding: 14px 24px !important;
  animation: container-hint-fadein 0.3s ease-out;
}
@keyframes container-hint-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.container-hint-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--primary-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: container-hint-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes container-hint-spin {
  to { transform: rotate(360deg); }
}

/* ===== Message Content ===== */
.message-content {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

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

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

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

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

/* ===== Code Block ===== */
.message-content pre {
  margin: 12px 0;
  border-radius: var(--border-radius-lg);
  overflow: hidden;
}

.message-content pre code {
  display: block;
  padding: 12px 16px;
  background-color: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-family-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
}

.message-content code {
  font-family: var(--font-family-mono);
  font-size: 0.9em;
  padding: 2px 6px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
}

.message.user .message-content code {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Code Block Header */
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: var(--code-header-bg);
  font-size: var(--font-size-sm);
  color: var(--terminal-text-muted);
}

.code-block-language {
  text-transform: uppercase;
  font-weight: 500;
}

.code-block-copy {
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--terminal-text-muted);
  border-radius: 999px;
  color: var(--terminal-text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-block-copy:hover {
  background-color: rgba(128, 128, 128, 0.2);
  color: var(--terminal-text);
  border-color: var(--terminal-text);
}

/* Code Block Actions */
.code-block-actions {
  display: flex;
  gap: 8px;
}

.code-block-preview {
  padding: 4px 8px;
  background: none;
  border: 1px solid var(--color-success-text);
  border-radius: 999px;
  color: var(--color-success-text);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.code-block-preview:hover {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
  border-color: var(--color-success-text);
}

/* ===== Mermaid 图表 ===== */
.mermaid-container {
  margin: 12px 0;
  padding: 16px;
  background-color: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  overflow-x: auto;
  text-align: center;
}

.mermaid-container svg {
  max-width: 100%;
  height: auto;
}

.mermaid-placeholder {
  color: var(--text-tertiary);
  font-size: var(--font-size-sm);
  padding: 20px 0;
}

/* Mermaid 全屏查看 */
.mermaid-container.mermaid-rendered {
  cursor: zoom-in;
  position: relative;
}

.mermaid-container.mermaid-rendered:hover::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  opacity: 0.85;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cpolyline points='9 21 3 21 3 15'/%3E%3Cline x1='21' y1='3' x2='14' y2='10'/%3E%3Cline x1='3' y1='21' x2='10' y2='14'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px;
}

.mermaid-fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}

.mermaid-fullscreen-container {
  position: relative;
  cursor: grab;
  user-select: none;
}

.mermaid-fullscreen-container.dragging {
  cursor: grabbing;
}

.mermaid-fullscreen-container svg {
  max-width: 95vw;
  max-height: 90vh;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.3));
}

.mermaid-fullscreen-toolbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 10001;
}

.mermaid-fullscreen-toolbar button {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.mermaid-fullscreen-toolbar button:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.mermaid-fullscreen-zoom-text {
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: center;
  user-select: none;
}

.mermaid-fullscreen-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

/* ===== Panels Area (预览面板 + 终端面板的容器) ===== */
.panels-area {
  width: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.3s ease, min-width 0.3s ease;
  border-right: 1px solid var(--border-color);
}

.panels-area.show {
  width: 50%;
  min-width: 400px;
}

/* ===== Preview Panel (独立面板) ===== */
.preview-panel {
  display: none;
  flex-direction: column;
  background-color: var(--bg-primary);
  overflow: hidden;
  flex: 1;
  min-height: 150px;
}

.preview-panel.show {
  display: flex;
}

/* ===== Panels Resizer (终端面板顶部的拖拽条) ===== */
.panels-resizer {
  display: none;
  height: 4px;
  background-color: var(--border-color);
  cursor: ns-resize;
  flex-shrink: 0;
  transition: background-color var(--transition-fast);
}

.panels-resizer:hover {
  background-color: var(--color-primary);
}

/* 只要终端面板打开，就显示拖拽条 */
.panels-area.terminal-only .panels-resizer,
.panels-area.both-panels .panels-resizer {
  display: block;
}

/* ===== Terminal Panel (独立面板) ===== */
.terminal-panel {
  display: none;
  flex-direction: column;
  background-color: var(--terminal-bg);
  height: 300px;
  min-height: 36px; /* 只需显示 header 栏 */
  max-height: calc(100% - 54px); /* 留出 resizer 和一点空间 */
  flex-shrink: 0;
}

.terminal-panel.show {
  display: flex;
}

/* 当只有终端面板时，让它保持在底部 */
.panels-area.terminal-only {
  justify-content: flex-end;
}

/* 当只有终端时，resizer 需要吸附到终端顶部 */
.panels-area.terminal-only .panels-resizer {
  margin-top: auto;
}

/* 当两个面板都显示时，预览面板自动填充剩余空间 */
.panels-area.both-panels .preview-panel {
  flex: 1;
  min-height: 50px;
  /* 不设置 max-height，让 flex 自动计算 */
}

.preview-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  flex-shrink: 0;
}

.preview-panel-tabs {
  display: flex;
  gap: 4px;
}

.preview-tab {
  padding: 6px 12px;
  border: none;
  background: none;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.preview-tab:hover {
  background-color: var(--bg-secondary);
}

.preview-tab.active {
  background-color: var(--color-primary);
  color: white;
}

.preview-panel-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.preview-panel-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: 999px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.preview-fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preview-fullscreen-btn i,
.preview-fullscreen-btn svg {
  width: 14px;
  height: 14px;
}

.preview-fullscreen-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--color-primary);
}

/* 全屏状态 */
.preview-panel.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  min-height: unset;
  border-radius: 0;
}

.preview-panel-close {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.preview-panel-close:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.preview-panel-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 0;    /* 允许 flex 子项缩小，防止内容撑开 */
}

.preview-view {
  display: none;
  width: 100%;
  height: 100%;
}

.preview-view.active {
  display: flex;
  flex-direction: column;
}

.preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: var(--bg-primary);
}

.preview-code {
  margin: 0;
  padding: 16px;
  height: 100%;
  overflow: auto;
  background-color: var(--code-bg);
}

.preview-code code {
  color: var(--code-text);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  white-space: pre-wrap;
  word-break: break-all;
}

.preview-code-editor {
  display: none;
  width: 100%;
  height: 100%;
  padding: 16px;
  margin: 0;
  border: none;
  resize: none;
  background-color: var(--code-bg);
  color: var(--code-text);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  white-space: pre;
  overflow: auto;
  box-sizing: border-box;
}

.preview-code-editor:focus {
  outline: none;
}

/* Monaco Editor Container */
.monaco-container {
  width: 100%;
  height: 100%;
  min-height: 200px;
}

/* Chat area transition for panel */
.chat-area {
  transition: flex 0.3s ease;
}

/* ===== Code Block Collapse ===== */
pre.collapsed code {
  display: none;
}

pre.collapsed {
  margin-bottom: 8px;
}

pre.collapsed .code-block-header {
  border-radius: 12px;
  cursor: pointer;
  background-color: var(--code-header-bg);
}

/* 展开按钮 */
.code-expand-btn {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--terminal-text-muted);
  border-radius: 999px;
  color: var(--terminal-text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-left: 8px;
}

.code-expand-btn:hover {
  background-color: rgba(128, 128, 128, 0.2);
  color: var(--terminal-text);
  border-color: var(--terminal-text);
}

/* ===== Preview List ===== */
.preview-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  overflow-y: auto;
}

.preview-list-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
}

.preview-list-item {
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-list-item:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--color-primary);
}

.preview-list-item.active {
  border-color: var(--color-primary);
  background-color: var(--purple-light);
}

.preview-list-item::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E");
  flex-shrink: 0;
}

.preview-list-item-title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== Preview Subviews ===== */
.preview-subview {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  min-height: 0;    /* flex 子项中防止内容溢出 */
}

.preview-subview.active {
  display: flex;
}

.preview-back-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

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

.preview-back-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--color-primary);
}

.preview-current-title {
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#previewContentSubview .preview-iframe {
  flex: 1;
  min-height: 0;    /* 允许 iframe 在 flex 布局中正确缩小 */
}

/* ===== Thinking Block ===== */
.thinking-block {
  margin: 8px 0;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.thinking-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
}

.thinking-header:hover {
  background-color: var(--border-color);
}

.thinking-icon {
  transition: transform var(--transition-fast);
  display: inline-flex;
  align-items: center;
}

.thinking-icon svg {
  width: 14px;
  height: 14px;
}

.thinking-block.expanded .thinking-icon {
  transform: rotate(90deg);
}

.thinking-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.thinking-content {
  display: none;
  padding: 12px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  background-color: var(--bg-secondary);
  white-space: pre-wrap;
}

.thinking-block.expanded .thinking-content {
  display: block;
}

/* ===== Input Area ===== */
.input-area {
  padding: 16px 20px;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  padding: 10px 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.prompt-input {
  flex: 1;
  padding: 0;
  border: none;
  border-radius: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  resize: none;
  min-height: 40px;
  max-height: 200px;
  background-color: transparent;
  color: var(--text-primary);
  transition: none;
  margin-bottom: 8px;
}

.prompt-input:focus {
  outline: none;
  border-color: transparent;
  box-shadow: none;
}

.prompt-input:disabled {
  background-color: transparent;
  cursor: not-allowed;
  opacity: 0.5;
}

.input-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

/* Send button - circular Style B */
#sendBtn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px var(--primary-shadow);
  font-size: 0;
  overflow: hidden;
}

#sendBtn::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background: var(--text-inverse);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 7-7 7 7'/%3E%3Cpath d='M12 19V5'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 7-7 7 7'/%3E%3Cpath d='M12 19V5'/%3E%3C/svg%3E");
}

#sendBtn:hover {
  box-shadow: 0 4px 14px var(--primary-shadow);
  transform: translateY(-1px);
}

/* Abort button - purple fill when active */
#abortBtn:not(:disabled) {
  background: var(--primary-gradient);
  color: #fff;
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px var(--primary-shadow);
}

#abortBtn:not(:disabled):hover {
  background: var(--primary-gradient);
  border-color: var(--color-primary-hover);
  box-shadow: 0 4px 14px var(--primary-shadow);
  transform: translateY(-1px);
}

/* ===== Status Bar ===== */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background-color: var(--bg-secondary);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-color);
  height: 32px;
  min-height: 32px;
  box-sizing: border-box;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Context Usage */
.status-item.context-usage {
  margin-left: auto;
  padding: 2px 8px;
  background-color: var(--bg-tertiary);
  border-radius: 999px;
  cursor: default;
}

.context-usage-text {
  font-size: 11px;
  color: var(--text-secondary);
}

.context-usage.warning .context-usage-text {
  color: var(--color-warning);
  font-weight: 500;
}

.context-usage.critical .context-usage-text {
  color: var(--color-error);
  font-weight: 600;
}

.context-compact-btn {
  margin-left: 6px;
  padding: 2px 6px;
  font-size: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

/* Permission Indicator */
.permission-indicator {
  padding: 4px 10px;
  background-color: var(--color-primary);
  color: white;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 500;
  animation: permission-pulse 2s infinite;
  transition: all 0.2s;
}

.permission-indicator:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.05);
}

.permission-indicator-icon {
  margin-right: 4px;
}

.permission-indicator-count {
  display: inline-block;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background-color: rgba(255,255,255,0.3);
  border-radius: 999px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  margin-right: 4px;
}

.permission-indicator-text {
  font-size: 12px;
}

@keyframes permission-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(124, 58, 237, 0);
  }
}

/* ===== Permission Cards (统一审批卡片) ===== */
.permission-unified-dialog {
  max-width: 600px;
  width: 90vw;
}

.permission-unified-dialog .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
}

.permission-unified-dialog .header-text {
  font-weight: 600;
  font-size: 15px;
}

.permission-cards-container {
  max-height: 60vh;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.permission-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.permission-card.new-card {
  animation: card-slide-in 0.3s ease;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

@keyframes card-slide-in {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.permission-card.removing {
  animation: card-slide-out 0.3s ease forwards;
}

@keyframes card-slide-out {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.permission-card.timeout-warning {
  border-color: var(--color-warning);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.permission-card.timed-out {
  opacity: 0.6;
  background-color: var(--bg-tertiary);
}

.permission-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.permission-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.permission-card-icon {
  font-size: 16px;
  display: inline-flex;
  align-items: center;
}

.permission-card-icon svg {
  width: 16px;
  height: 16px;
}

.permission-card-name {
  font-size: 14px;
}

.permission-card-countdown {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 2px 10px;
  background-color: var(--bg-tertiary);
  border-radius: 999px;
}

.permission-card-countdown.warning {
  color: var(--color-error);
  background-color: rgba(239, 68, 68, 0.1);
  font-weight: 600;
}

.permission-card-body {
  padding: 12px;
}

.permission-card-body .permission-input-preview {
  margin: 0;
}

.permission-card-body .permission-input-preview pre {
  margin: 0;
  padding: 8px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}

.permission-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.permission-card-actions .btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
}

.btn-session-allow-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 999px;
  background-color: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-session-allow-small:hover {
  background-color: var(--color-primary);
  color: white;
}

/* Question Card 样式 */
.question-card .permission-card-body {
  padding: 16px;
}

.question-card .question-item {
  margin-bottom: 16px;
}

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

.question-card .question-header {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.question-card .question-text {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 12px;
}

.question-card .question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-card .question-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.question-card .question-option:hover {
  border-color: var(--color-primary);
}

.question-card .question-option input[type="radio"],
.question-card .question-option input[type="checkbox"] {
  margin-top: 3px;
}

.question-card .question-option-content {
  flex: 1;
}

.question-card .question-option-label {
  font-size: 13px;
  font-weight: 500;
}

.question-card .question-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.question-card .question-option-other .question-other-input {
  margin-top: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  background-color: var(--bg-primary);
}

.question-card .question-option-other .question-other-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 超时消息 */
.permission-card .timeout-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
  font-size: 13px;
}

/* 工作目录外警告 */
.permission-card.outside-workdir {
  border-color: var(--color-warning);
}

.permission-card .permission-warning {
  padding: 6px 12px;
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
  font-size: 12px;
  border-bottom: 1px solid var(--border-color);
}

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

.context-compact-btn.compacting {
  animation: spin 1s linear infinite;
}

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

/* ===== Streaming Indicator ===== */
.streaming-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.streaming-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-primary);
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite;
}

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

/* ===== Error Message ===== */
.error-message {
  padding: 12px 16px;
  background-color: var(--color-error-bg);
  border: 1px solid var(--color-error-text);
  border-radius: 12px;
  color: var(--color-error);
  font-size: var(--font-size-sm);
}

.error-message-title {
  font-weight: 600;
  margin-bottom: 4px;
}

/* ===== Typing Cursor ===== */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: var(--color-primary);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}

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

/* ===== Streaming Message ===== */
.message.streaming .message-bubble {
  background-color: var(--bg-secondary);
}

.message.streaming .message-text {
  display: inline;
}

/* ===== Message Actions Menu ===== */
.message-bubble {
  position: relative;
}

.message-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 10;
}

.message-bubble:hover .message-actions {
  opacity: 1;
}

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

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

/* 用户消息的按钮样式调整 */
.message.user .message-action-btn {
  background-color: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.8);
}

.message.user .message-action-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
  color: white;
}

.message-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  min-width: 120px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: none;
  overflow: hidden;
}

.message-menu.show {
  display: block;
}

.message-menu-item {
  padding: 10px 14px;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast);
  white-space: nowrap;
}

.message-menu-item:hover {
  background-color: var(--bg-tertiary);
}

.message-menu-item:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

/* ===== Assistant Actions (ChatGPT Style) ===== */
.assistant-actions {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding-top: 8px;
}

/* Agent 运行中或等待授权时隐藏消息操作按钮 */
body.agent-busy .assistant-actions {
  display: none;
}

.assistant-action-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.assistant-action-icon:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.assistant-action-icon:active {
  transform: scale(0.95);
}

.assistant-action-icon svg {
  width: 16px;
  height: 16px;
}

/* 自定义快速 tooltip */
.assistant-action-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 0;
  padding: 4px 8px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
  pointer-events: none;
  margin-bottom: 4px;
  box-shadow: var(--shadow-sm);
}

.assistant-action-icon:hover::after {
  opacity: 1;
  visibility: visible;
}

/* 导出菜单 */
.assistant-action-export-wrap {
  position: relative;
}

.export-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  min-width: 150px;
  overflow: hidden;
}

.export-menu.show {
  display: block;
}

.export-menu-item {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.export-menu-item:hover {
  background: var(--bg-tertiary);
}

/* ===== Terminal Panel ===== */
.terminal-container {
  font-family: var(--font-family-mono);
  font-size: 12px;
  padding: 12px;
  overflow-y: auto;
  height: 100%;
  background-color: var(--bg-secondary);
}

.terminal-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}

.terminal-entry {
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
}

.terminal-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
}

.terminal-entry-status {
  font-size: 10px;
  width: 14px;
  text-align: center;
}

.terminal-entry-tool {
  font-weight: 600;
  color: var(--text-primary);
}

.terminal-entry-command {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.terminal-entry-time {
  font-size: 11px;
  color: var(--text-muted);
}

.terminal-entry-output {
  background-color: var(--code-bg);
  color: var(--code-text);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
  line-height: 1.4;
  max-height: 200px;
  overflow-y: auto;
}

/* Terminal entry status colors */
.terminal-entry.running .terminal-entry-status {
  color: var(--color-warning);
  animation: pulse 1s ease-in-out infinite;
}

.terminal-entry.completed .terminal-entry-status {
  color: var(--color-success);
}

.terminal-entry.failed .terminal-entry-status {
  color: var(--color-error);
}

.terminal-entry.failed .terminal-entry-output {
  background-color: var(--code-bg);
  color: var(--color-error);
}

/* ===== File Reference ===== */
.input-area {
  position: relative;
}

/* ===== Quote Preview Card (消息引用卡片，在输入框内顶部) ===== */
.quote-preview {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 8px;
  border-radius: 8px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  overflow: hidden;
  animation: quoteSlideIn 0.15s ease;
}

@keyframes quoteSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.quote-preview-bar {
  width: 3px;
  flex-shrink: 0;
  background-color: var(--color-primary);
}

.quote-preview-body {
  flex: 1;
  padding: 5px 8px;
  min-width: 0;
}

.quote-preview-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 1px;
}

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

.quote-preview-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.quote-preview-close:hover {
  color: var(--text-primary);
}

.file-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 20px 0 20px;
}

.file-ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background-color: var(--purple-light);
  border: none;
  border-radius: 999px;
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 500;
}

.file-ref-icon {
  font-size: 12px;
}

.file-ref-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-ref-remove {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.file-ref-remove:hover {
  color: var(--color-error);
}

/* File Suggestions Dropdown */
.file-suggestions {
  position: absolute;
  bottom: calc(100% - 8px);
  left: 20px;
  right: 20px;
  max-height: 240px;
  overflow-y: auto;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.file-suggestion-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.file-suggestion-item:hover,
.file-suggestion-item.highlighted {
  background-color: var(--bg-tertiary);
}

.file-suggestion-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.file-suggestion-name {
  font-weight: 500;
  color: var(--text-primary);
}

.file-suggestion-path {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== History Loading Indicator ===== */
.loading-history {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.loading-history-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* No More History Notice */
.no-more-history {
  text-align: center;
  padding: 12px;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  background-color: var(--bg-tertiary);
  border-radius: 12px;
  margin-bottom: 16px;
}

/* ===== Interactive Terminal Panel ===== */
.terminal-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background-color: var(--terminal-header-bg);
  border-bottom: 1px solid var(--terminal-border);
  flex-shrink: 0;
}

.terminal-panel-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}

.terminal-tab {
  padding: 4px 12px;
  border: none;
  background: none;
  font-size: 12px;
  color: var(--terminal-text-muted);
  cursor: pointer;
  border-radius: 4px 4px 0 0;
  transition: all var(--transition-fast);
}

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

.terminal-tab.active {
  background-color: var(--terminal-bg);
  color: var(--terminal-text);
}

.terminal-tab-add {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  font-size: 16px;
  color: var(--terminal-text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.terminal-tab-add:hover {
  background-color: var(--terminal-bg);
  color: var(--terminal-text);
}

/* ===== Container Selector ===== */
.container-selector {
  padding: 4px 8px;
  border: 1px solid var(--terminal-border);
  border-radius: 8px;
  font-size: 12px;
  background-color: var(--terminal-bg);
  color: var(--terminal-text);
  cursor: pointer;
  min-width: 120px;
  max-width: 200px;
}

.container-selector:focus {
  outline: none;
  border-color: var(--color-primary);
}

.container-selector option[disabled] {
  color: var(--terminal-text-muted);
  font-style: italic;
}

.terminal-tab-refresh {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--terminal-border);
  border-radius: 8px;
  background: var(--terminal-bg);
  color: var(--terminal-text-muted);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.terminal-tab-refresh:hover {
  background-color: var(--bg-tertiary);
  color: var(--terminal-text);
}

.terminal-tab-refresh.loading {
  animation: spin 1s linear infinite;
}

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

/* Container Status */
.terminal-container-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--terminal-text-muted);
}

.terminal-container-status.docker {
  background-color: rgba(0, 119, 170, 0.15);
  color: #0099cc;
}

[data-theme="dark"] .terminal-container-status.docker {
  background-color: rgba(0, 170, 255, 0.2);
  color: #00aaff;
}

.terminal-container-status .docker-icon {
  font-size: 12px;
}

.terminal-container-status.agent {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
}

.terminal-container-status .agent-icon {
  font-size: 12px;
}

.terminal-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-panel-btn {
  padding: 2px 8px;
  border: 1px solid var(--terminal-border);
  background: transparent;
  border-radius: 8px;
  font-size: 11px;
  color: var(--terminal-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.terminal-panel-btn:hover {
  background-color: var(--terminal-bg);
  color: var(--terminal-text);
  border-color: var(--terminal-text-muted);
}

.terminal-panel-close {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--terminal-text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.terminal-panel-close:hover {
  background-color: var(--terminal-bg);
  color: var(--terminal-text);
}

.terminal-panel-content {
  flex: 1;
  overflow: hidden;
  background-color: var(--terminal-bg);
}

/* xterm.js 容器样式 */
#xtermContainer {
  width: 100%;
  height: 100%;
  padding: 4px;
}

#xtermContainer .xterm {
  height: 100%;
}

#xtermContainer .xterm-viewport {
  overflow-y: auto;
}

/* 终端连接状态 */
.terminal-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--terminal-text-muted);
  margin-left: 8px;
}

.terminal-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--terminal-text-muted);
}

.terminal-status-dot.connected {
  background-color: var(--color-online);
}

.terminal-status-dot.connecting {
  background-color: var(--color-warning);
  animation: pulse 1s ease-in-out infinite;
}

.terminal-status-dot.disconnected {
  background-color: var(--color-offline);
}

/* ===== Agent Mode Switcher (Chat Panel) ===== */
.agent-mode-switcher {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.agent-mode-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background-color: var(--purple-light);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--font-size-sm);
  color: var(--color-primary);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
  font-weight: 500;
}

.agent-mode-indicator:hover {
  background-color: var(--purple-light);
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.agent-mode-indicator .mode-icon {
  font-size: 14px;
}

.agent-mode-indicator .mode-label {
  font-weight: 500;
}

.agent-mode-dropdown {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 200px;
  overflow: hidden;
  padding: 4px;
}

.agent-mode-dropdown.show {
  display: block;
}

.agent-mode-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background-color: transparent;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s;
  border-radius: 8px;
}

.agent-mode-option:hover {
  background-color: var(--purple-light);
}

.agent-mode-option:active {
  background-color: var(--bg-secondary);
}

/* 编辑模式下隐藏 Agent 模式选择器 */
body.mode-edit .agent-mode-switcher {
  display: none;
}

/* ===== Permission Popups Container (审批流容器) ===== */
.permission-popups-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

/* 审批流整体卡片 */
.permission-popups-container {
  background-color: var(--bg-primary);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  min-width: 480px;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: container-slide-in 0.3s ease;
}

@keyframes container-slide-in {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 审批流头部 */
.permission-flow-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  color: white;
  flex-shrink: 0;
}

.permission-flow-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
}

.permission-flow-title .flow-icon {
  font-size: 20px;
}

.permission-flow-count {
  background-color: rgba(255, 255, 255, 0.25);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
}

/* 审批流内容区域 */
.permission-flow-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== 权限请求区块 ===== */
.permission-section {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
}

/* ===== 问卷区块 ===== */
.question-section {
  background-color: var(--bg-primary);
  border: 1px solid #a78bfa;
  border-radius: 10px;
  overflow: hidden;
}

/* 区块头部 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.section-header.question-header {
  background-color: rgba(167, 139, 250, 0.1);
  border-bottom-color: rgba(167, 139, 250, 0.3);
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-count {
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 10px;
}

/* 区块底部按钮 */
.section-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.section-footer .btn-primary,
.section-footer .btn-secondary,
.section-footer .btn-session-allow {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.section-footer .btn-primary {
  background-color: var(--color-primary);
  color: white;
  border: none;
}

.section-footer .btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.section-footer .btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.section-footer .btn-secondary:hover {
  background-color: var(--bg-tertiary);
  color: var(--color-error);
  border-color: var(--color-error);
}

.section-footer .btn-session-allow {
  background-color: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.section-footer .btn-session-allow:hover {
  background-color: var(--color-primary);
  color: white;
}

/* ===== 权限请求项（带复选框） ===== */
.section-items {
  max-height: 300px;
  overflow-y: auto;
}

.perm-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background-color 0.15s;
  border-bottom: 1px solid var(--border-color);
}

.perm-item:last-child {
  border-bottom: none;
}

.perm-item:hover {
  background-color: var(--bg-secondary);
}

.perm-item.outside-workdir {
  background-color: rgba(245, 158, 11, 0.05);
}

.perm-item-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

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

.perm-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.perm-item-icon {
  font-size: 16px;
}

.perm-item-name {
  font-weight: 500;
  font-size: 14px;
  color: var(--text-primary);
}

.perm-item-authkey {
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 8px;
  font-family: var(--font-family-mono);
}

.perm-item-warning {
  font-size: 11px;
  color: var(--color-warning);
  margin-left: auto;
}

.perm-item-preview {
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  overflow: hidden;
}

.perm-item-preview pre {
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  font-family: var(--font-family-mono);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  color: var(--text-secondary);
}

/* ===== 问卷样式 ===== */
.question-section .questions-container {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.question-item {
  /* 每个问题 */
}

.question-tag {
  font-size: 11px;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-weight: 500;
}

.question-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.question-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.question-option:hover {
  border-color: #a78bfa;
  background-color: rgba(167, 139, 250, 0.05);
}

.question-option input[type="radio"],
.question-option input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: #7c3aed;
}

.question-option-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.question-option-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.question-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.question-option-other .question-other-input {
  margin-top: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.question-option-other .question-other-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.question-option-other .question-other-input:focus {
  outline: none;
  border-color: #7c3aed;
}

/* 单个审批项 */
.permission-popup {
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  animation: item-slide-in 0.3s ease;
  position: relative;
}

.permission-popup:last-child {
  border-bottom: none;
}

@keyframes item-slide-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.permission-popup.removing {
  animation: item-slide-out 0.3s ease forwards;
}

@keyframes item-slide-out {
  from {
    opacity: 1;
    max-height: 500px;
  }
  to {
    opacity: 0;
    max-height: 0;
    padding: 0;
    margin: 0;
    border: none;
  }
}

.permission-popup.timeout-warning {
  background-color: rgba(245, 158, 11, 0.05);
}

.permission-popup.timed-out {
  opacity: 0.5;
  background-color: var(--bg-tertiary);
}

/* 审批项头部 */
.permission-popup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.permission-popup .popup-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.permission-popup .popup-icon {
  font-size: 18px;
  display: inline-flex;
  align-items: center;
}

.permission-popup .popup-icon svg {
  width: 18px;
  height: 18px;
}

.permission-popup .popup-name {
  color: var(--text-primary);
}

.permission-popup .popup-auth-key {
  font-size: 12px;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 400;
}

.permission-popup .popup-countdown {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 10px;
  background-color: var(--bg-tertiary);
  border-radius: 999px;
  font-weight: 500;
}

.permission-popup .popup-countdown.warning {
  color: var(--color-error);
  background-color: rgba(239, 68, 68, 0.1);
  font-weight: 600;
}

/* 审批项主体 */
.permission-popup .popup-body {
  padding: 16px 20px;
  max-height: 250px;
  overflow-y: auto;
}

.permission-popup .permission-input-preview {
  margin: 0;
}

.permission-popup .permission-input-preview pre {
  margin: 0;
  padding: 12px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 12px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 弹窗警告 */
.permission-popup .permission-warning {
  padding: 8px 12px;
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
  font-size: 13px;
  font-weight: 500;
}

/* 审批项底部按钮 */
.permission-popup .popup-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  background-color: var(--bg-tertiary);
}

.permission-popup .btn-primary {
  padding: 8px 16px;
  background-color: var(--color-primary);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.permission-popup .btn-primary:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

.permission-popup .btn-secondary {
  padding: 8px 16px;
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.permission-popup .btn-secondary:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.permission-popup .btn-session-allow {
  padding: 8px 16px;
  background-color: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.permission-popup .btn-session-allow:hover {
  background-color: var(--color-primary);
  color: white;
}

/* 弹窗内问卷样式 */
.permission-popup .questions-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.permission-popup .question-item {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.permission-popup .question-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.permission-popup .question-header {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.permission-popup .question-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.permission-popup .question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.permission-popup .question-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.permission-popup .question-option:hover {
  border-color: var(--color-primary);
  background-color: var(--bg-tertiary);
}

.permission-popup .question-option input[type="radio"],
.permission-popup .question-option input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}

.permission-popup .question-option-content {
  flex: 1;
}

.permission-popup .question-option-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.permission-popup .question-option-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.permission-popup .question-option-other .question-other-input {
  margin-top: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.permission-popup .question-option-other .question-other-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.permission-popup .question-option-other .question-other-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* 超时状态 */
.permission-popup .timeout-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 16px;
  font-size: 14px;
}

/* Diff 预览样式 */
.permission-popup .permission-diff-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.permission-popup .permission-diff-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  font-size: 12px;
  color: var(--text-secondary);
}

.permission-popup .permission-diff-content {
  padding: 12px;
  background-color: var(--code-bg);
  font-family: var(--font-family-mono);
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}

.permission-popup .diff-line {
  display: block;
  padding: 1px 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.permission-popup .diff-line-removed {
  background-color: var(--color-error-bg);
  color: var(--color-error-text);
}

.permission-popup .diff-line-added {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
}

.permission-popup .permission-file-path {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  padding: 6px 10px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.permission-popup .permission-file-path-icon {
  font-size: 14px;
}

/* ===== Agent Setup Dialog ===== */
.agent-setup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.agent-setup-dialog {
  background-color: var(--bg-primary);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 560px;
  width: 90%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.agent-setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.agent-setup-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.agent-setup-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.agent-setup-close:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.agent-setup-content {
  padding: 20px;
  overflow-y: auto;
}

.agent-setup-content > p {
  margin: 0 0 20px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.agent-setup-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.agent-setup-step {
  display: flex;
  gap: 16px;
  padding: 16px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
}

.agent-setup-step .step-number {
  width: 28px;
  height: 28px;
  background-color: var(--color-primary, #7c3aed);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.agent-setup-step .step-content {
  flex: 1;
  min-width: 0;
}

.agent-setup-step .step-content h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.agent-setup-step .step-content p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.agent-setup-step .step-content pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  overflow-x: auto;
}

.agent-setup-step .step-content code {
  font-family: 'SF Mono', Menlo, Monaco, monospace;
  font-size: 12px;
  color: var(--text-primary);
}

.agent-setup-step .btn {
  margin-top: 8px;
}

.context-env-setup {
  opacity: 0.8;
  font-style: italic;
}

.context-env-setup:hover {
  opacity: 1;
}

/* ===== Chrome Extension Setup Dialog (New) ===== */
.agent-setup-dialog-wide {
  max-width: 640px;
}

.copy-command {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  background-color: var(--bg-tertiary);
  border-radius: 8px;
  overflow-x: auto;
}

.copy-command code {
  flex: 1;
  font-family: 'SF Mono', Menlo, Monaco, monospace;
  font-size: 12px;
  color: var(--text-primary);
  word-break: break-all;
}

.copy-command .btn-copy {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

.copy-command .btn-copy:hover {
  background: var(--color-primary-hover);
}

.agent-connected-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
  border-radius: 8px;
  margin-bottom: 16px;
  color: #166534;
  font-size: 14px;
}

.agent-connected-banner .connected-icon {
  font-size: 18px;
  display: inline-flex;
  align-items: center;
}

.agent-connected-banner .connected-icon svg {
  width: 18px;
  height: 18px;
  color: var(--color-online);
}

/* OS 支持信息区块 */
.os-support-info {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.os-support-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.os-support-title svg {
  width: 14px;
  height: 14px;
}

.os-support-cards {
  display: flex;
  gap: 10px;
}

.os-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
}

.os-card .os-icon {
  font-size: 24px;
  line-height: 1;
}

.os-card .os-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.os-card.os-supported .os-status {
  color: var(--color-online);
}

.os-card.os-supported .os-status svg {
  width: 16px;
  height: 16px;
}

.os-card.os-unsupported {
  opacity: 0.7;
}

.os-card.os-unsupported .os-status-text {
  font-size: 11px;
  color: var(--text-tertiary);
}

.extension-id-input {
  margin-top: 8px;
}

.extension-id-input input {
  width: 100%;
  padding: 10px 12px;
  font-family: 'SF Mono', Menlo, Monaco, monospace;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.extension-id-input input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.configure-status {
  margin-top: 12px;
  font-size: 13px;
}

.configure-status .status-progress {
  color: var(--color-primary);
}

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

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

.agent-setup-footer {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.agent-setup-footer h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-primary);
}

.agent-setup-footer p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.agent-setup-footer ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.agent-setup-footer ul li {
  margin-bottom: 4px;
}

.agent-setup-footer code {
  font-family: 'SF Mono', Menlo, Monaco, monospace;
  font-size: 12px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 8px;
}

.agent-setup-step.step-disabled {
  opacity: 0.6;
}

.agent-setup-step.step-disabled .step-number {
  background-color: var(--text-muted, #94a3b8);
}

.agent-setup-step .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.agent-setup-step .step-instructions {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 13px;
}

.agent-setup-step .step-instructions p {
  margin: 4px 0;
}

.agent-setup-step .step-instructions code {
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 8px;
}

/* ===== Dark Mode Overrides ===== */
[data-theme="dark"] .message.assistant .message-bubble {
  background-color: var(--bg-secondary);
}

[data-theme="dark"] .input-wrapper {
  background-color: var(--bg-tertiary);
}

/* 用户消息气泡：暗色模式霓虹描边 — 暗色底 + 彩色描边 + 彩色文字 + 外发光 */
[data-theme="dark"] .message.user .message-bubble {
  background: var(--msg-user-bg, var(--primary-gradient));
  color: var(--msg-user-text, #fff);
  border: var(--msg-user-border, none);
  box-shadow: var(--msg-user-shadow, 0 2px 8px var(--primary-shadow));
}

/* Send button 霓虹描边 — 暗色底 + 彩色描边 + 彩色箭头 + 外发光 */
[data-theme="dark"] #sendBtn.btn-primary {
  background: var(--send-btn-bg, var(--primary-gradient));
  color: var(--send-btn-text, #fff);
  border: var(--send-btn-border, none);
  box-shadow: var(--send-btn-glow, none);
}

/* Send button 箭头图标颜色跟随 */
[data-theme="dark"] #sendBtn::after {
  background: var(--send-btn-text, var(--text-inverse));
}

/* Abort button 霓虹描边 */
[data-theme="dark"] #abortBtn.btn-primary:not(:disabled) {
  background: var(--send-btn-bg, var(--primary-gradient));
  color: var(--send-btn-text, #fff);
  border: var(--send-btn-border, none);
  box-shadow: var(--send-btn-glow, none);
}

/* Section footer buttons 霓虹描边 */
[data-theme="dark"] .section-footer .btn-primary {
  background-color: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, white);
  border: var(--btn-primary-border, none);
  box-shadow: var(--btn-primary-glow, none);
}

[data-theme="dark"] .section-footer .btn-primary:hover {
  background-color: var(--btn-primary-hover-bg, var(--color-primary-hover));
}

/* Permission popup button 霓虹描边 */
[data-theme="dark"] .permission-popup .btn-primary {
  background-color: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, white);
  border: var(--btn-primary-border, none);
  box-shadow: var(--btn-primary-glow, none);
}

[data-theme="dark"] .permission-popup .btn-primary:hover {
  background-color: var(--btn-primary-hover-bg, var(--color-primary-hover));
}

/* Preview tab 霓虹描边 */
[data-theme="dark"] .preview-tab.active {
  background-color: var(--tab-active-bg, var(--color-primary));
  color: var(--tab-active-text, white);
  border: var(--tab-active-border, none);
  box-shadow: var(--tab-active-glow, none);
}

/* Copy command button 霓虹描边 */
[data-theme="dark"] .copy-command .btn-copy {
  background: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, white);
  border: var(--btn-primary-border, none);
  box-shadow: var(--btn-primary-glow, none);
}

[data-theme="dark"] .copy-command .btn-copy:hover {
  background: var(--btn-primary-hover-bg, var(--color-primary-hover));
}

/* Session allow button hover 霓虹描边 */
[data-theme="dark"] .btn-session-allow-small:hover {
  background-color: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, white);
  border-color: transparent;
  border: var(--btn-primary-border, 1px solid var(--color-primary));
  box-shadow: var(--btn-primary-glow, none);
}

/* Permission flow header 霓虹描边 */
[data-theme="dark"] .permission-flow-header {
  background: var(--btn-primary-bg, linear-gradient(135deg, var(--color-primary), #7c3aed));
  color: var(--btn-primary-text, white);
  border-bottom: var(--btn-primary-border, none);
  box-shadow: var(--btn-primary-glow, none);
}

/* Tip inline button 霓虹描边 */
[data-theme="dark"] .tip-inline-btn.primary {
  background: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, #fff);
  border: var(--btn-primary-border, none);
  box-shadow: var(--btn-primary-glow, none);
}

[data-theme="dark"] .tip-inline-btn.primary:hover {
  background: var(--btn-primary-hover-bg, var(--color-primary-hover));
  opacity: 1;
}

/* Tip tooltip button 霓虹描边 */
[data-theme="dark"] .tip-tooltip-btn.primary {
  background: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, #fff);
  border: var(--btn-primary-border, none);
  box-shadow: var(--btn-primary-glow, none);
}

[data-theme="dark"] .tip-tooltip-btn.primary:hover {
  background: var(--btn-primary-hover-bg, var(--color-primary-hover));
  opacity: 1;
}

/* Context compact button hover */
[data-theme="dark"] .context-compact-btn:hover {
  background-color: var(--btn-primary-bg, var(--color-primary));
  color: var(--btn-primary-text, white);
  box-shadow: var(--btn-primary-glow, none);
}

/* ===== Chat Header ===== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  flex-shrink: 0;
  min-height: 40px;
}

.chat-header-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 12px;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.chat-header-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

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

.chat-header-btn.active {
  background-color: var(--purple-light);
  color: var(--color-primary);
}

.chat-header-btn svg {
  width: 18px;
  height: 18px;
}

/* ===== Chat Overlay Panel (search results / directory) ===== */
.chat-overlay-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* Search input bar inside overlay */
.chat-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-search-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px 10px;
  transition: border-color var(--transition-fast);
}

.chat-search-input-wrapper:focus-within {
  border-color: var(--color-primary);
}

.chat-search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-search-icon svg {
  width: 16px;
  height: 16px;
}

.chat-search-input {
  flex: 1;
  border: none;
  background: none;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  outline: none;
  padding: 4px 0;
  font-family: var(--font-family);
}

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

/* Directory header bar inside overlay */
.chat-directory-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-directory-bar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
}

.chat-directory-bar-title svg {
  width: 15px;
  height: 15px;
  opacity: 0.6;
}

.dir-sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background-color 0.15s;
}
.dir-sort-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}
.dir-sort-btn svg {
  width: 15px;
  height: 15px;
}

.chat-directory-bar-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* Close button (shared for search & directory) */
.chat-overlay-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.chat-overlay-close:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-overlay-close svg {
  width: 16px;
  height: 16px;
}

/* Version management bar (reuses directory bar layout) */
.chat-version-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* Version panel content */
.version-panel {
  padding: 16px 16px 20px;
}

/* ── 主按钮（一键开启 / 保存并开启）── */
.version-enable-btn {
  display: block;
  width: 100%;
  padding: 10px 0;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.18s, box-shadow 0.18s;
  margin-bottom: 10px;
  letter-spacing: 0.01em;
}
.version-enable-btn:hover { opacity: 0.88; box-shadow: 0 3px 10px rgba(124,58,237,0.28); }
.version-enable-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
/* 自定义配置区内的较小版本 */
.version-enable-btn.version-enable-btn-sm {
  width: auto;
  display: inline-block;
  padding: 6px 14px;
  font-size: 12.5px;
  margin-bottom: 0;
}

/* ── 副文案说明 ── */
.version-info {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 10px;
}

/* ── 灰色自定义配置入口 ── */
.version-custom-link {
  display: inline-block;
  font-size: 11.5px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-underline-offset: 2px;
  transition: color 0.15s;
  margin-bottom: 0;
}
.version-custom-link:hover { color: var(--text-secondary); text-decoration: underline; }

/* ── 自定义配置展开区 ── */
.version-custom-area {
  display: none;
  margin-top: 12px;
}
.version-custom-area.open { display: block; }

/* 分隔线 */
.version-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.version-divider::before,
.version-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}
.version-divider span {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 自定义配置底部操作行 */
.version-custom-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* 仅保存配置（低调纯文字） */
.version-save-only-btn {
  padding: 0;
  border: none;
  background: none;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
  text-underline-offset: 2px;
}
.version-save-only-btn:hover { color: var(--text-secondary); text-decoration: underline; }

/* ── 已启用：状态卡 ── */
.version-status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--green-bg, #f0fdf4);
  border: 1px solid var(--green-border, #bbf7d0);
  border-radius: 8px;
  margin-bottom: 12px;
}
.version-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.version-status-dot.active {
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
  animation: ver-pulse 2s infinite;
}
.version-status-dot.inactive { background: #9ca3af; }
@keyframes ver-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  70%  { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.version-status-card-text { flex: 1; }
.version-status-card-title { font-size: 13px; font-weight: 600; color: #16a34a; }
.version-status-card-sub { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }

/* 暗色适配：状态卡 */
[data-theme="dark"] .version-status-card,
.dark .version-status-card {
  background: #052e16;
  border-color: #166534;
}
[data-theme="dark"] .version-status-card-title,
.dark .version-status-card-title { color: #4ade80; }

/* ── 已启用：操作行（暂停按钮） ── */
.version-action-row {
  margin-bottom: 12px;
}
.version-pause-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.version-pause-btn svg { width: 13px; height: 13px; }
.version-pause-btn:hover {
  color: #d97706;
  border-color: #d97706;
  background: #fffbeb;
}
[data-theme="dark"] .version-pause-btn:hover,
.dark .version-pause-btn:hover {
  background: #1c1200;
}

/* ── 高级配置折叠区 ── */
.version-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
  transition: color 0.15s;
}
.version-advanced-toggle:hover { color: var(--text-secondary); }
.version-advanced-toggle svg { width: 14px; height: 14px; transition: transform 0.2s; }
.version-advanced-toggle.open svg { transform: rotate(90deg); }

.version-advanced {
  display: none;
  padding-top: 4px;
}
.version-advanced.open { display: block; }

.version-advanced-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 5px;
}

.version-git-user-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.version-git-user-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.version-git-user-input:focus { border-color: var(--color-primary); }
.version-git-user-input[readonly] { opacity: 0.55; cursor: default; }

.version-gitignore-editor {
  width: 100%;
  min-height: 100px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}
.version-gitignore-editor:focus { border-color: var(--color-primary); }

.version-save-row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.version-save-btn {
  padding: 4px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.version-save-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.version-save-btn.primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.version-save-btn.primary:hover { opacity: 0.85; }

.version-msg {
  font-size: 12px;
  margin-top: 6px;
  padding: 4px 0;
}
.version-msg.success { color: #059669; }
.version-msg.error { color: #dc2626; }

/* =========================================================
   引导页（未开启版本管理时）
   ========================================================= */
.ver-onboard {
  padding: 24px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.ver-onboard-icon {
  width: 56px; height: 56px;
  background: var(--primary-gradient, linear-gradient(135deg, #7c3aed, #6366f1));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(124,58,237,0.2);
  color: #fff;
}
.ver-onboard-icon svg { width: 28px; height: 28px; }
.ver-onboard-title {
  font-size: 18px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 6px; text-align: center;
}
.ver-onboard-subtitle {
  font-size: 13px; color: var(--text-secondary); text-align: center;
  line-height: 1.55; margin-bottom: 20px; max-width: 340px;
}

/* 动画展示区 */
.ver-showcase {
  width: 100%; flex: 1; min-height: 0;
  position: relative; margin-bottom: 20px;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}
.ver-showcase-label {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 7px 12px;
  background: linear-gradient(to bottom, var(--bg-primary) 70%, transparent);
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  display: flex; align-items: center; gap: 5px; z-index: 5;
}
.ver-showcase-label svg { width: 13px; height: 13px; }
.ver-showcase-slides { position: absolute; inset: 0; }
.ver-showcase-slide {
  position: absolute; inset: 0;
  opacity: 0; transform: translateX(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  overflow: hidden;
}
.ver-showcase-slide.active { opacity: 1; transform: translateX(0); }
.ver-showcase-slide.leaving { opacity: 0; transform: translateX(-30px); }
.ver-showcase-dots {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; z-index: 10;
}
.ver-showcase-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(0,0,0,0.15); transition: all 0.3s; cursor: pointer;
}
.ver-showcase-dot.active { width: 20px; border-radius: 3px; background: var(--color-primary); }
[data-theme="dark"] .ver-showcase-dot { background: rgba(255,255,255,0.15); }
[data-theme="dark"] .ver-showcase-dot.active { background: var(--color-primary); }

/* CTA 按钮 */
.ver-onboard-cta {
  width: 100%; padding: 12px 0; border: none; border-radius: 10px;
  background: var(--primary-gradient, linear-gradient(135deg, #7c3aed, #6366f1));
  color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: opacity 0.18s, box-shadow 0.18s, transform 0.18s;
  box-shadow: 0 4px 16px rgba(124,58,237,0.25); flex-shrink: 0;
  font-family: inherit;
}
.ver-onboard-cta:hover { opacity: 0.92; box-shadow: 0 6px 24px rgba(124,58,237,0.35); transform: translateY(-1px); }
.ver-onboard-cta:active { transform: translateY(0); }
.ver-onboard-cta:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }
.ver-onboard-foot {
  font-size: 11px; color: var(--text-muted); text-align: center;
  margin-top: 10px; line-height: 1.5;
}
.ver-onboard-foot a { color: var(--text-secondary); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.ver-onboard-foot a:hover { color: var(--color-primary); }

/* ── 展示区预览 — 时光机 ── */
.ver-preview-tl { padding: 32px 16px 28px; position: relative; height: 100%; overflow: hidden; }
.ver-preview-tl::before {
  content: ''; position: absolute; left: 24px; top: 32px; bottom: 0;
  width: 2px; background: linear-gradient(to bottom, var(--border-color) 0%, transparent 100%);
}
.ver-preview-fade, .ver-preview-dir .ver-preview-fade {
  position: absolute; bottom: 0; left: 0; right: 0; height: 60px;
  background: linear-gradient(to bottom, transparent, var(--bg-tertiary));
  pointer-events: none; z-index: 3;
}
.vp-node {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 12px; position: relative;
  animation: vpFadeIn 0.4s ease forwards; opacity: 0;
}
@keyframes vpFadeIn { to { opacity: 1; } }
.vp-dot {
  width: 10px; height: 10px; border-radius: 50%;
  border: 2.5px solid var(--color-primary); background: var(--bg-primary);
  flex-shrink: 0; margin-top: 4px; margin-left: 20px;
  position: relative; z-index: 2;
}
.vp-dot-feat { border-color: #22c55e; }
.vp-dot-fix { border-color: #ef4444; }
.vp-dot-refactor { border-color: #3b82f6; }
.vp-dot-perf { border-color: #7c3aed; }
.vp-dot-ms { border-color: #f59e0b; background: #fef3c7; width: 14px; height: 14px; margin-left: 18px; margin-top: 2px; }
.vp-card {
  flex: 1; background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: 8px; padding: 8px 10px;
}
.vp-card-head { display: flex; align-items: center; gap: 5px; margin-bottom: 3px; }
.vp-type {
  font-size: 9px; font-weight: 700; padding: 1px 5px;
  border-radius: 3px; font-family: var(--font-mono, 'SF Mono', monospace);
}
.vp-type-feat { background: #dcfce7; color: #166534; }
.vp-type-fix { background: #fee2e2; color: #991b1b; }
.vp-type-refactor { background: #dbeafe; color: #1e40af; }
.vp-type-perf { background: #ede9fe; color: #6d28d9; }
.vp-type-style { background: #fef3c7; color: #92400e; }
.vp-card-title { font-size: 11px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.vp-card-tags { display: flex; gap: 3px; margin-top: 3px; flex-wrap: wrap; }
.vp-tag {
  font-size: 8.5px; padding: 1px 5px; border-radius: 99px; font-weight: 600;
}
.vp-tag-api { background: #eff6ff; color: #1d4ed8; }
.vp-tag-sec { background: #fef2f2; color: #dc2626; }
.vp-tag-db { background: #fefce8; color: #a16207; }
.vp-tag-mid { background: #fdf4ff; color: #a21caf; }
.vp-tag-dep { background: #f0fdf4; color: #15803d; }
.vp-tag-ms { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }
.vp-card-stat {
  font-size: 9px; color: var(--text-muted); margin-top: 3px;
  font-family: var(--font-mono, monospace);
}
.vp-green { color: #16a34a; font-weight: 600; }
.vp-red { color: #dc2626; font-weight: 600; }

/* ── 展示区预览 — 目录版本视图 ── */
.ver-preview-dir { padding: 32px 14px 28px; height: 100%; overflow: hidden; position: relative; }
.vp-dir-label {
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px; padding-left: 4px;
  display: flex; align-items: center; gap: 4px;
}
.vp-dir-label svg { width: 12px; height: 12px; }
.vp-dir-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 11px; margin-bottom: 5px;
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: 8px;
  animation: vpFadeIn 0.35s ease forwards; opacity: 0;
}
.vp-dir-badge {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; font-weight: 700;
}
.vp-dir-badge-feat { background: #dcfce7; color: #16a34a; }
.vp-dir-badge-fix { background: #fee2e2; color: #dc2626; }
.vp-dir-badge-refactor { background: #dbeafe; color: #2563eb; }
.vp-dir-body { flex: 1; min-width: 0; }
.vp-dir-title {
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  line-height: 1.3; margin-bottom: 2px;
  display: flex; align-items: center; gap: 5px;
}
.vp-ai-badge {
  font-size: 8.5px; background: var(--purple-light, #f5f3ff); color: var(--color-primary);
  padding: 1px 5px; border-radius: 3px; font-weight: 700; white-space: nowrap;
}
.vp-dir-desc { font-size: 10px; color: var(--text-secondary); line-height: 1.4; }
.vp-dir-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 3px;
  font-size: 9.5px; color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}

/* =========================================================
   时光机（已启用版本管理后）
   ========================================================= */

/* 时光机顶栏 */
.tm-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.tm-bar-left { display: flex; align-items: center; gap: 6px; }
.tm-bar-icon {
  width: 28px; height: 28px;
  background: var(--primary-gradient, linear-gradient(135deg, #7c3aed, #6366f1));
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.tm-bar-icon svg { width: 15px; height: 15px; }
.tm-bar-title { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.tm-bar-stat { font-size: 11px; color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.tm-bar-right { display: flex; align-items: center; gap: 2px; }
.tm-bar-btn {
  width: 28px; height: 28px; border: none; background: none;
  border-radius: 5px; cursor: pointer; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.tm-bar-btn svg { width: 15px; height: 15px; }
.tm-bar-btn:hover { background: var(--bg-tertiary); color: var(--text-secondary); }
.tm-bar-btn.active-filter { color: var(--color-primary); background: var(--purple-light, #f5f3ff); }

/* 筛选栏 */
.tm-filters {
  display: none; padding: 6px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary); gap: 4px; flex-wrap: wrap;
}
.tm-filters.open { display: flex; }
.tm-filter-chip {
  font-size: 11px; padding: 3px 10px; border-radius: 6px;
  border: 1px solid var(--border-color); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer; font-family: inherit;
  transition: all 0.15s; font-weight: 500;
}
.tm-filter-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.tm-filter-chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* 状态提示条 */
.tm-status-strip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 14px;
  background: var(--green-bg, #f0fdf4);
  border-bottom: 1px solid var(--green-border, #dcfce7);
  flex-shrink: 0;
}
[data-theme="dark"] .tm-status-strip, .dark .tm-status-strip {
  background: #052e16; border-bottom-color: #166534;
}
.tm-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #22c55e; animation: ver-pulse 2s infinite; flex-shrink: 0;
}
.tm-status-text { font-size: 11px; color: #16a34a; font-weight: 500; }
[data-theme="dark"] .tm-status-text, .dark .tm-status-text { color: #4ade80; }

/* 暂停状态 */
.tm-status-strip.paused { background: #fffbeb; border-bottom-color: #fef3c7; }
[data-theme="dark"] .tm-status-strip.paused, .dark .tm-status-strip.paused { background: #451a03; border-bottom-color: #92400e; }
.tm-status-dot.paused { background: #f59e0b; animation: none; }
.tm-status-strip.paused .tm-status-text { color: #d97706; }
[data-theme="dark"] .tm-status-strip.paused .tm-status-text, .dark .tm-status-strip.paused .tm-status-text { color: #fbbf24; }
.tm-status-toggle {
  margin-left: auto; background: none; border: none; cursor: pointer; padding: 2px 4px;
  color: #9ca3af; display: flex; align-items: center; border-radius: 4px; transition: color 0.15s, background 0.15s;
}
.tm-status-toggle:hover { color: #d97706; background: rgba(217, 119, 6, 0.08); }
.tm-status-toggle svg { width: 14px; height: 14px; }
.tm-status-strip.paused .tm-status-toggle { color: #16a34a; }
.tm-status-strip.paused .tm-status-toggle:hover { color: #16a34a; background: rgba(22, 163, 106, 0.08); }
[data-theme="dark"] .tm-status-toggle, .dark .tm-status-toggle { color: #6b7280; }
[data-theme="dark"] .tm-status-toggle:hover, .dark .tm-status-toggle:hover { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
[data-theme="dark"] .tm-status-strip.paused .tm-status-toggle, .dark .tm-status-strip.paused .tm-status-toggle { color: #4ade80; }
[data-theme="dark"] .tm-status-strip.paused .tm-status-toggle:hover, .dark .tm-status-strip.paused .tm-status-toggle:hover { color: #4ade80; background: rgba(74, 222, 128, 0.1); }

/* 时间轴主体 — 中心轴左右交替布局 */
.tm-timeline {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 0;
  position: relative;
}
.tm-timeline::-webkit-scrollbar { width: 4px; }
.tm-timeline::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* inner wrapper — 自然撑开高度，轴线基于此定位 */
.tm-timeline-inner {
  position: relative;
  padding: 16px 0 40px;
  min-height: 100%;
}

/* 中心轴线 — 基于 inner 的完整高度，不会被滚动截断 */
.tm-timeline::before { display: none; }
.tm-axis-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, transparent 0%, var(--border-color) 16px, var(--border-color) calc(100% - 40px), transparent 100%);
  transform: translateX(-1px);
  pointer-events: none;
  z-index: 0;
}

/* 日期分隔 — 居中 */
.tm-date {
  text-align: center;
  position: relative; z-index: 2;
  margin: 4px 0 10px;
  padding: 0;
}
.tm-date::after { display: none; }
.tm-date-label {
  display: inline-block;
  background: var(--bg-secondary, #fafafa);
  padding: 3px 14px; border-radius: 999px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--border-color);
}

/* HEAD 标记 — 居中 */
.tm-head-marker {
  text-align: center;
  position: relative; z-index: 2;
  margin: 4px 0 12px;
  padding: 0;
}
.tm-head-inner {
  display: inline-flex; align-items: center; gap: 6px;
}
.tm-head-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--color-success, #22c55e);
  animation: ver-pulse 2s infinite;
}
.tm-head-text { font-size: 11px; color: var(--color-success, #22c55e); font-weight: 600; }

/* ===== 节点 — 左右交替 ===== */
.tm-node {
  position: relative;
  margin-bottom: 6px;
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  padding: 0 8px;
}
.tm-node.left  { justify-content: flex-start; padding-right: calc(50% + 18px); }
.tm-node.right { justify-content: flex-end;   padding-left:  calc(50% + 18px); }

/* 中心圆点 */
.tm-node-dot {
  position: absolute; left: 50%; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--bg-primary); border: 2.5px solid var(--border-color);
  transform: translate(-50%, 0); z-index: 3;
  transition: all 0.25s ease;
}
.tm-node:hover .tm-node-dot {
  border-color: var(--color-primary); background: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(124,58,237,0.12);
  transform: translate(-50%, 0) scale(1.15);
}
.tm-node-dot.feat { border-color: #22c55e; }
.tm-node-dot.fix { border-color: #ef4444; }
.tm-node-dot.refactor { border-color: #3b82f6; }
.tm-node-dot.perf { border-color: #7c3aed; }
.tm-node-dot.style { border-color: #f59e0b; }
.tm-node-dot.docs { border-color: #6b7280; }
.tm-node-dot.test { border-color: #1e40af; }
.tm-node-dot.chore { border-color: var(--text-muted); }
.tm-node-dot.rollback { border-color: #d97706; }
.tm-node-dot.ext { border-color: var(--text-muted); width: 9px; height: 9px; }

/* 连接线（卡片到中心点） */
.tm-connector {
  position: absolute; top: 19px; height: 1px;
  background: var(--border-color); z-index: 1;
  transition: background 0.2s;
}
.tm-node.left .tm-connector  { left: calc(50% - 18px); right: calc(50% + 6px); }
.tm-node.right .tm-connector { left: calc(50% + 6px);  right: calc(50% - 18px); }
.tm-node:hover .tm-connector { background: var(--color-primary); }

/* 卡片 */
.tm-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  transition: all 0.25s ease;
  position: relative;
}
.tm-node:hover .tm-card {
  border-color: var(--color-primary);
  box-shadow: 0 2px 10px rgba(124,58,237,0.1);
}
.tm-node.external .tm-card {
  background: var(--bg-tertiary); border-style: dashed; opacity: 0.75;
}
.tm-node.external:hover .tm-card { opacity: 1; }

/* 卡片内容 */
.tm-node-header {
  display: flex; align-items: center; gap: 5px; margin-bottom: 3px; flex-wrap: wrap;
}
.tm-node-time {
  font-size: 10px; color: var(--text-muted); font-weight: 500;
  font-family: var(--font-mono, monospace);
}
.tm-node-hash {
  font-size: 9px; color: var(--text-muted);
  font-family: var(--font-mono, monospace);
  background: var(--bg-tertiary); padding: 0px 4px; border-radius: 3px;
}
.tm-node-source {
  font-size: 8.5px; padding: 0px 5px; border-radius: 3px; font-weight: 600;
}
.tm-source-ai { background: var(--purple-light, #f5f3ff); color: var(--color-primary); }
.tm-source-user { background: #fef3c7; color: #92400e; }

/* 标题 */
.tm-node-title {
  font-size: 12px; font-weight: 600; color: var(--text-primary);
  line-height: 1.35; margin-bottom: 3px;
}
.tm-cc-type {
  font-size: 9.5px; font-weight: 700; padding: 1px 4px;
  border-radius: 3px; font-family: var(--font-mono, monospace);
  margin-right: 3px; display: inline-block;
}
.tm-cc-feat { background: #dcfce7; color: #166534; }
.tm-cc-fix { background: #fee2e2; color: #991b1b; }
.tm-cc-refactor { background: #dbeafe; color: #1e40af; }
.tm-cc-perf { background: #ede9fe; color: #6d28d9; }
.tm-cc-style { background: #fef3c7; color: #92400e; }
.tm-cc-docs { background: #f3f4f6; color: #6b7280; }
.tm-cc-test { background: #dbeafe; color: #1e40af; }
.tm-cc-chore { background: #f3f4f6; color: #6b7280; }
.tm-cc-rollback { background: #fef3c7; color: #d97706; }

/* 标签 */
.tm-node-tags { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 3px; }
.tm-tag {
  font-size: 9px; padding: 1px 6px; border-radius: 99px;
  font-weight: 600; border: 1px solid var(--border-color);
  background: var(--bg-tertiary); color: var(--text-secondary);
}

/* 统计 */
.tm-node-stats { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.tm-stat {
  font-size: 9.5px; padding: 1px 5px; border-radius: 3px;
  font-weight: 600; font-family: var(--font-mono, monospace);
}
.tm-stat-files { background: #f3f4f6; color: #555; }
.tm-stat-add { background: #dcfce7; color: #166534; }
.tm-stat-del { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .tm-stat-files { background: #27272a; color: #a1a1aa; }
[data-theme="dark"] .tm-stat-add { background: #052e16; color: #4ade80; }
[data-theme="dark"] .tm-stat-del { background: #450a0a; color: #fca5a5; }

/* 文件标签 */
.tm-node-files { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.tm-file-tag {
  font-size: 9px; color: var(--text-muted); background: var(--bg-tertiary);
  padding: 1px 5px; border-radius: 3px;
  font-family: var(--font-mono, monospace);
  max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 操作行 */
.tm-node-actions {
  display: flex; gap: 3px; margin-top: 5px;
  opacity: 0; transition: opacity 0.15s;
}
.tm-node:hover .tm-node-actions { opacity: 1; }
.tm-act-btn {
  font-size: 10px; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--border-color); background: var(--bg-primary);
  color: var(--text-secondary); cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.tm-act-btn:hover { border-color: var(--color-primary); color: var(--color-primary); background: var(--purple-light, #f5f3ff); }
.tm-act-btn.danger:hover { border-color: var(--color-error, #ef4444); color: var(--color-error, #ef4444); background: #fee2e2; }
.tm-act-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 入场动画 */
.tm-node {
  opacity: 0; transform: translateY(16px);
  animation: tmNodeIn 0.35s ease forwards;
}
@keyframes tmNodeIn { to { opacity: 1; transform: translateY(0); } }
.tm-node:nth-child(1)  { animation-delay: 0.03s; }
.tm-node:nth-child(2)  { animation-delay: 0.06s; }
.tm-node:nth-child(3)  { animation-delay: 0.09s; }
.tm-node:nth-child(4)  { animation-delay: 0.12s; }
.tm-node:nth-child(5)  { animation-delay: 0.15s; }
.tm-node:nth-child(6)  { animation-delay: 0.18s; }
.tm-node:nth-child(7)  { animation-delay: 0.21s; }
.tm-node:nth-child(8)  { animation-delay: 0.24s; }
.tm-node:nth-child(9)  { animation-delay: 0.27s; }
.tm-node:nth-child(10) { animation-delay: 0.30s; }

/* diff 面板 */
.tm-diff-panel {
  margin-top: 8px; border-top: 1px solid var(--border-color); padding-top: 8px;
}
.tm-diff-loading { font-size: 11px; color: var(--text-muted); padding: 8px 0; }
.tm-diff-code {
  background: var(--bg-tertiary); border-radius: 6px;
  overflow: auto; max-height: 300px;
  font-family: var(--font-mono, monospace); font-size: 12px; line-height: 1.7;
}
.tm-diff-code .diff-line { padding: 0 10px; white-space: pre; min-height: 20px; }
.tm-diff-code .diff-hunk { background: #dbeafe; color: #1e40af; }
.tm-diff-code .diff-add { background: #dcfce7; color: #166534; }
.tm-diff-code .diff-del { background: #fee2e2; color: #991b1b; }
.tm-diff-code .diff-meta { color: var(--text-muted); font-style: italic; }
[data-theme="dark"] .tm-diff-code .diff-hunk { background: #172554; color: #93c5fd; }
[data-theme="dark"] .tm-diff-code .diff-add { background: #052e16; color: #86efac; }
[data-theme="dark"] .tm-diff-code .diff-del { background: #450a0a; color: #fca5a5; }

/* 设置面板 */
.tm-settings-panel {
  display: none;
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 14px 16px 18px;
  z-index: 20;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  animation: tmSettingsUp 0.2s ease;
}
.tm-settings-panel.open { display: block; }
@keyframes tmSettingsUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.tm-settings-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.tm-settings-title { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.tm-settings-close {
  width: 24px; height: 24px; border: none; background: none;
  cursor: pointer; color: var(--text-muted);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
}
.tm-settings-close svg { width: 14px; height: 14px; }
.tm-settings-close:hover { background: var(--bg-tertiary); color: var(--text-secondary); }
.tm-settings-row { margin-bottom: 8px; }
.tm-settings-label {
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px;
}
.tm-settings-input {
  width: 100%; padding: 5px 8px;
  border: 1px solid var(--border-color); border-radius: 5px;
  background: var(--bg-secondary); color: var(--text-primary);
  font-size: 12px; font-family: inherit; outline: none;
  transition: border-color 0.15s;
}
.tm-settings-input:focus { border-color: var(--color-primary); }
.tm-settings-textarea {
  min-height: 64px; resize: vertical;
  font-family: var(--font-mono, monospace); font-size: 11px;
}
.tm-settings-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.tm-settings-save {
  font-size: 11px; padding: 4px 14px; border-radius: 5px;
  border: 1px solid var(--color-primary); background: var(--color-primary);
  color: #fff; cursor: pointer; transition: all 0.15s;
  font-family: inherit; font-weight: 600;
}
.tm-settings-save:hover { opacity: 0.88; }
.tm-settings-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* Shared result list */
.chat-overlay-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
  position: relative;
}
.chat-overlay-list::-webkit-scrollbar {
  width: 4px;
}
.chat-overlay-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
.chat-overlay-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-overlay-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* Result card (shared for search results & directory items) */
.chat-overlay-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid transparent;
}

.chat-overlay-item:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chat-overlay-item-number {
  font-size: 10px;
  color: var(--color-primary);
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.08);
  border-radius: 6px;
  letter-spacing: -0.02em;
}

.chat-overlay-item-role {
  font-size: 11px;
  font-weight: 600;
  min-width: 24px;
  flex-shrink: 0;
  padding-top: 2px;
}

.chat-overlay-item-role.user {
  color: var(--color-primary);
}

.chat-overlay-item-role.assistant {
  color: var(--color-success);
}

.chat-overlay-item-content {
  flex: 1;
  min-width: 0;
}

.chat-overlay-item-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.chat-overlay-item-text mark {
  background-color: rgba(245, 158, 11, 0.4);
  color: inherit;
  border-radius: 2px;
  padding: 0 2px;
}

/* Search scope checkboxes */
.chat-search-scope {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 16px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-search-scope-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.chat-search-scope-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Time in overlay result cards */
.chat-overlay-item-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 3px;
  font-variant-numeric: tabular-nums;
}

/* Flash highlight on scroll-to-message */
@keyframes srch-flash {
  0%   { box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.5); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.message.srch-flash {
  animation: srch-flash 1.5s ease-out;
  border-radius: 12px;
}

/* ===== Git View in Directory ===== */

/* Toggle area wrapper */
.git-view-toggle-area {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Small toggle for directory bar (self-contained, matches prototype) */
.toggle-switch-sm { position: relative; width: 34px; height: 18px; flex-shrink: 0; display: inline-block; }
.toggle-switch-sm input { opacity: 0; width: 0; height: 0; }
.toggle-switch-sm .toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--toggle-bg); border-radius: 18px; transition: background-color var(--transition-fast); }
.toggle-switch-sm .toggle-slider:before { content: ""; position: absolute; height: 14px; width: 14px; left: 2px; bottom: 2px; background-color: var(--toggle-knob); border-radius: 50%; transition: transform var(--transition-fast); }
.toggle-switch-sm input:checked + .toggle-slider { background-color: var(--color-primary); }
.toggle-switch-sm input:checked + .toggle-slider:before { transform: translateX(16px); }

/* Git view label */
.git-view-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  transition: color 0.15s;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.git-view-label svg {
  width: 14px;
  height: 14px;
}
.git-view-label.active {
  color: var(--color-primary);
}

/* Git mode: subdued text for directory items */
.chat-overlay-item.git-mode .chat-overlay-item-text {
  color: var(--text-muted);
  font-size: 12px;
  -webkit-line-clamp: 1;
}
.chat-overlay-item.git-mode:not(.off-lineage) .chat-overlay-item-text {
  color: var(--text-primary);
}
.chat-overlay-item.git-mode:hover .chat-overlay-item-text {
  color: var(--text-secondary);
}

/* Change summary row */
.dir-item-changes {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* Change tags */
.dir-change-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  font-family: var(--font-family-mono, monospace);
  font-size: 10px;
  line-height: 14px;
}
.dir-change-tag.files {
  background: rgba(124, 58, 237, 0.08);
  color: var(--color-primary);
}
.dir-change-tag.additions {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}
.dir-change-tag.deletions {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}
.dir-change-tag.commit-hash {
  background: transparent;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.03em;
}

/* File name tags */
.dir-change-files {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.dir-change-file {
  font-family: var(--font-family-mono, monospace);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 3px;
  line-height: 16px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
}
.chat-overlay-item:hover .dir-change-file {
  color: var(--text-secondary);
}

/* Small purple dot indicator (git-off mode) */
.chat-overlay-item-git-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
  margin-top: 6px;
  opacity: 0.5;
}

/* Hover action buttons on directory items */
.chat-overlay-item {
  position: relative;
}
.dir-item-actions {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  gap: 4px;
  align-items: center;
  z-index: 2;
  background: linear-gradient(90deg, transparent, var(--bg-tertiary) 8px);
  padding-left: 16px;
}
.chat-overlay-item:hover .dir-item-actions,
.dir-ext-change:hover .dir-item-actions {
  display: flex;
}
.dir-item-action-btn {
  padding: 4px 10px;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.dir-item-action-btn:hover {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(124, 58, 237, 0.25);
}
.dir-item-action-btn.danger {
  border-color: var(--color-danger);
  color: var(--text-muted);
}
.dir-item-action-btn.danger:hover {
  background: var(--color-danger);
  color: var(--text-inverse);
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.25);
}
.dir-item-action-btn.retract {
  border-color: var(--color-warning);
  color: var(--text-muted);
}
.dir-item-action-btn.retract:hover {
  background: var(--color-warning);
  color: var(--text-inverse);
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.25);
}

/* External change entry in directory */
.dir-ext-change {
  padding: 6px 12px 6px 32px;
  border-left: 2px solid var(--border-color);
  margin-left: 20px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  border-radius: 0 6px 6px 0;
}
.dir-ext-change::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.4;
}
.dir-ext-change:hover {
  background: var(--bg-tertiary);
  border-left-color: var(--color-primary);
}
.dir-ext-change:hover::before {
  background: var(--color-primary);
  opacity: 0.7;
}
.dir-ext-change .dir-ext-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Lineage: off-lineage items (greyed out) ===== */
.chat-overlay-item.off-lineage {
  opacity: 0.35;
  transition: opacity 0.2s ease;
}
.chat-overlay-item.off-lineage:hover {
  opacity: 0.65;
}

.dir-ext-change.off-lineage {
  opacity: 0.3;
  transition: opacity 0.2s ease;
}
.dir-ext-change.off-lineage:hover {
  opacity: 0.55;
}

/* 角色标签（孤儿 AI 快照标识） */
.dir-role-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  letter-spacing: 0.02em;
  margin-right: 4px;
}
.dir-role-badge.role-ai {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

/* ===== Spotlight Confirm（聚光灯确认） ===== */
.chat-overlay-list.spotlight-mode > * {
  opacity: 0.15;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.chat-overlay-list.spotlight-mode > .spotlight-target {
  opacity: 1;
  pointer-events: auto;
  box-shadow: 0 0 0 2px var(--color-primary), 0 0 16px rgba(139, 92, 246, 0.2);
  border-radius: 8px;
  z-index: 2;
  position: relative;
}
.chat-overlay-list.spotlight-mode > .spotlight-confirm-card {
  opacity: 1;
  pointer-events: auto;
}
.spotlight-confirm-card {
  margin: 8px 4px;
  padding: 14px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  animation: spotlightSlideIn 0.2s ease;
}
@keyframes spotlightSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.spotlight-confirm-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.spotlight-confirm-msg {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}
.spotlight-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.spotlight-confirm-actions button {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}
.spotlight-confirm-actions .spotlight-btn-cancel {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.spotlight-confirm-actions .spotlight-btn-cancel:hover {
  background: var(--border-color);
}
.spotlight-confirm-actions .spotlight-btn-confirm {
  background: var(--color-primary, #3b82f6);
  color: var(--text-inverse);
}
.spotlight-confirm-actions .spotlight-btn-confirm:hover {
  opacity: 0.85;
}
.spotlight-confirm-actions .spotlight-btn-confirm.spotlight-btn-warn {
  background: var(--color-error);
}
.spotlight-confirm-actions .spotlight-btn-confirm.spotlight-btn-danger {
  background: var(--color-error);
}

/* 撤回弹窗中的安全提示高亮 */
.spotlight-safe-text {
  color: var(--color-success, #059669);
  font-weight: 600;
}

/* 回滚弹窗中的科普展开区 */
.spotlight-confirm-explain {
  margin-bottom: 12px;
}
.spotlight-explain-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.15s;
}
.spotlight-explain-link:hover {
  color: var(--text-primary);
}
.spotlight-explain-content {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
  text-align: left;
}
.spotlight-explain-content p {
  margin: 0 0 6px;
}
.spotlight-explain-content p:last-child {
  margin-bottom: 0;
}
.spotlight-explain-content b {
  color: var(--text-primary);
}

/* ===== Lineage: SVG arrow overlay ===== */
.lineage-arrows-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

/* ===== Diff Overlay ===== */
.diff-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.diff-modal {
  background: var(--bg-primary);
  border-radius: var(--border-radius-lg, 12px);
  box-shadow: var(--shadow-lg, 0 25px 50px rgba(0,0,0,0.25));
  width: 90vw;
  max-width: 900px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.diff-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.diff-header-title {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.diff-header-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.diff-header-close:hover {
  background: var(--bg-hover);
}
.diff-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}
.diff-file-list {
  width: 220px;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  flex-shrink: 0;
}
.diff-file-item {
  padding: 8px 12px;
  font-size: 12px;
  font-family: var(--font-family-mono, monospace);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color-light, rgba(0,0,0,0.05));
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.diff-file-item:hover {
  background: var(--bg-hover);
}
.diff-file-item.active {
  background: var(--bg-active, var(--bg-hover));
  font-weight: 600;
}
.diff-file-item .diff-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diff-file-item .diff-file-stat {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.diff-file-stat .stat-add { color: var(--color-success-text); }
.diff-file-stat .stat-del { color: var(--color-error-text); }
.diff-content {
  flex: 1;
  overflow: auto;
  padding: 0;
  font-family: var(--font-family-mono, monospace);
  font-size: 12px;
  line-height: 1.5;
}
.diff-content pre {
  margin: 0;
  padding: 12px;
  white-space: pre;
}
.diff-line {
  padding: 0 12px;
  min-height: 20px;
}
.diff-line.diff-add {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}
.diff-line.diff-del {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}
.diff-line.diff-hunk {
  background: rgba(124, 58, 237, 0.05);
  color: var(--color-primary);
  font-weight: 600;
  padding-top: 8px;
  padding-bottom: 4px;
}
.diff-line.diff-meta {
  color: var(--text-muted);
  font-style: italic;
}
.diff-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

/* Dark mode adjustments */
[data-theme="dark"] .dir-change-tag.files {
  background: rgba(167, 139, 250, 0.15);
}
[data-theme="dark"] .dir-change-tag.additions {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}
[data-theme="dark"] .dir-change-tag.deletions {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}
[data-theme="dark"] .diff-line.diff-add {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}
[data-theme="dark"] .diff-line.diff-del {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}
[data-theme="dark"] .diff-line.diff-hunk {
  background: rgba(167, 139, 250, 0.08);
}

/* --- 聊天区 tip 插槽 --- */
.chat-tip-slot { padding: 4px 8px; }

/* ===== 通用引导/提示系统 (tips.js) ===== */

/* --- Inline Tip（内联提示条） --- */
.tip-inline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin: 4px 8px;
  background: var(--tip-bg, #fffbeb);
  border: 1px solid var(--tip-border, #fbbf24);
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  animation: tipSlideIn 0.3s ease;
}
@keyframes tipSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tip-inline-icon {
  flex-shrink: 0;
  color: var(--tip-icon, #f59e0b);
  margin-top: 1px;
}
.tip-inline-icon i,
.tip-inline-icon svg {
  width: 16px;
  height: 16px;
}
.tip-inline-body { flex: 1; min-width: 0; }
.tip-inline-text {
  color: var(--tip-text, #92400e);
  font-size: 12px;
}
.tip-inline-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}
.tip-inline-btn {
  padding: 3px 10px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.tip-inline-btn.primary {
  background: var(--color-primary);
  color: #fff;
}
.tip-inline-btn.primary:hover { opacity: 0.85; }
.tip-inline-btn.primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.tip-inline-dismiss {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--tip-text, #92400e);
  opacity: 0.7;
  cursor: pointer;
  user-select: none;
}
.tip-inline-dismiss:hover { opacity: 1; }
.tip-inline-dismiss input[type="checkbox"] {
  width: 12px;
  height: 12px;
  accent-color: var(--tip-icon, #f59e0b);
}
.tip-inline-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--tip-text, #92400e);
  opacity: 0.5;
  cursor: pointer;
  padding: 2px;
  font-size: 16px;
  line-height: 1;
}
.tip-inline-close:hover { opacity: 1; }

/* Inline tip 成功/错误状态 */
.tip-inline-success {
  background: #ecfdf5;
  border-color: #34d399;
}
.tip-inline-success .tip-inline-icon { color: #059669; }
.tip-inline-success .tip-inline-text { color: #065f46; }

.tip-inline-error {
  background: #fef2f2;
  border-color: #f87171;
}
.tip-inline-error .tip-inline-icon { color: #dc2626; }
.tip-inline-error .tip-inline-text { color: #991b1b; }

/* --- Tooltip Guide（气泡指引） --- */
.tip-tooltip {
  position: absolute;
  z-index: 1000;
  width: 240px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  font-size: 13px;
  line-height: 1.5;
  animation: tipFadeIn 0.25s ease;
}
@keyframes tipFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
/* arrow */
.tip-tooltip::before {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  transform: rotate(45deg);
}
.tip-tooltip.bottom { top: calc(100% + 10px); left: 50%; transform: translateX(-50%); }
.tip-tooltip.bottom::before { top: -6px; left: 50%; margin-left: -5px; }
.tip-tooltip.right { left: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
.tip-tooltip.right::before { left: -6px; top: 50%; margin-top: -5px; transform: rotate(-45deg); }

.tip-tooltip-step {
  font-size: 11px;
  color: var(--color-primary);
  font-weight: 600;
  margin-bottom: 4px;
}
.tip-tooltip-title {
  font-weight: 600;
  margin-bottom: 3px;
}
.tip-tooltip-desc {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 10px;
}
.tip-tooltip-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tip-tooltip-dots {
  display: flex;
  gap: 4px;
}
.tip-tooltip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-color);
}
.tip-tooltip-dot.active {
  background: var(--color-primary);
}
.tip-tooltip-btns {
  display: flex;
  gap: 6px;
}
.tip-tooltip-btn {
  padding: 3px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: var(--bg-primary);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}
.tip-tooltip-btn:hover { background: var(--bg-hover); }
.tip-tooltip-btn.primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.tip-tooltip-btn.primary:hover { opacity: 0.85; }

/* --- Dark mode --- */
[data-theme="dark"] .tip-inline {
  --tip-bg: #422006;
  --tip-border: #b45309;
  --tip-text: #fbbf24;
  --tip-icon: #f59e0b;
}
[data-theme="dark"] .tip-inline-success {
  background: #064e3b;
  border-color: #059669;
}
[data-theme="dark"] .tip-inline-success .tip-inline-icon { color: #34d399; }
[data-theme="dark"] .tip-inline-success .tip-inline-text { color: #a7f3d0; }

[data-theme="dark"] .tip-inline-error {
  background: #7f1d1d;
  border-color: #dc2626;
}
[data-theme="dark"] .tip-inline-error .tip-inline-icon { color: #f87171; }
[data-theme="dark"] .tip-inline-error .tip-inline-text { color: #fecaca; }

/* ===== Back to Latest Button ===== */
.back-to-latest-btn {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: var(--bg-primary);
  color: var(--color-primary);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 10;
  transition: all 0.2s ease;
}

.back-to-latest-btn:hover {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.back-to-latest-btn svg {
  width: 14px;
  height: 14px;
}

/* ===== File History View ===== */

#historyView {
  overflow: hidden;
}

.history-version-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--color-primary);
  color: white;
  font-size: var(--font-size-sm);
  flex-shrink: 0;
}

.history-version-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-back-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: var(--font-size-xs);
  white-space: nowrap;
  flex-shrink: 0;
}

.history-back-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

.history-selector {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
}

.history-loading,
.history-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: var(--font-size-sm);
}

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

.history-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  transition: background-color 0.15s, border-color 0.15s;
}

.history-item:hover {
  background-color: var(--bg-hover);
  border-color: var(--color-primary);
}

.history-item.active {
  background-color: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.history-item.active .history-item-time,
.history-item.active .history-item-author {
  color: rgba(255, 255, 255, 0.8);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.history-item-hash {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.history-item-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.history-item-message {
  font-size: var(--font-size-sm);
  line-height: 1.4;
  word-break: break-word;
}

.history-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.history-item-author {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.history-item-actions {
  display: flex;
  gap: 4px;
}

.history-action-btn {
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

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

.history-item.active .history-action-btn {
  border-color: rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.9);
}

.history-item.active .history-action-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
  color: white;
}

/* 版本提示条按钮区 */
.history-bar-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.history-mode-btn {
  padding: 3px 10px;
  font-size: var(--font-size-xs);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.15s;
}

.history-mode-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.history-mode-btn.active {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  border-color: rgba(255, 255, 255, 0.5);
}

.history-code-container {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.history-code-container .monaco-container {
  width: 100%;
  height: 100%;
  min-height: 200px;
}

