/* =============================================
   components.css — UI 组件样式全集
   精致 SaaS · SVG 图标驱动 · 克制留白
   ============================================= */

/* =====================================================
   1. SIDEBAR 侧边栏
   ===================================================== */

.sidebar-header {
  display: flex;
  align-items: center;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--gradient-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow-blue);
  position: relative;
}

/* 品牌标记内嵌一个微型计算器 SVG（深色下白线，浅色下白线） */
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='2' width='16' height='20' rx='2.5'/%3E%3Cpath d='M8 6.5h8M8 10.5h.01M12 10.5h.01M16 10.5h.01M8 14.5h.01M12 14.5h.01M16 14.5h.01M8 18.5h4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px 18px;
  opacity: 0.95;
}

.brand-name {
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
}

/* 新建对话按钮 */
.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  width: calc(100% - var(--space-lg) * 2);
  margin: 0 var(--space-lg) var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.new-chat-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

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

/* 聊天历史列表 */
.chat-history {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs) var(--space-sm);
}

/* 历史对话条目 */
.chat-history-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  margin: var(--space-3xs) 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-default);
  position: relative;
  color: var(--text-secondary);
}

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

.chat-history-item.active {
  background: var(--bg-badge);
  color: var(--text-primary);
}

.chat-history-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 25%;
  bottom: 25%;
  width: 2px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
}

.chat-history-item .chat-title-text {
  flex: 1;
  font-size: var(--text-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--font-medium);
}

.chat-history-item.active .chat-title-text {
  color: var(--text-primary);
}

/* 删除按钮 */
.chat-history-item .delete-btn {
  flex-shrink: 0;
  width: var(--icon-size-md);
  height: var(--icon-size-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  opacity: 0;
  transition: var(--transition-fast);
}

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

.chat-history-item .delete-btn:hover {
  color: var(--accent-red);
  background: var(--priority-p0-bg);
}

/* 侧边栏底部 */
.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-lg);
  border-top: var(--border-width-thin) solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.footer-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--text-xs);
  transition: var(--transition-fast);
}

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

.api-status {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  padding: 0 var(--space-sm);
  letter-spacing: var(--tracking-wide);
}

.api-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-green);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent-green) 18%, transparent);
}

/* =====================================================
   2. ICON BUTTON 通用图标按钮
   ===================================================== */

.icon-btn {
  width: var(--button-height-md);
  height: var(--button-height-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: var(--transition-fast);
  flex-shrink: 0;
}

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

.icon-btn:active {
  transform: scale(0.96);
}

/* =====================================================
   3. CHAT HEADER
   ===================================================== */

.chat-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =====================================================
   4. MESSAGES 消息区
   ===================================================== */

/* 单条消息 */
.message {
  display: flex;
  gap: var(--space-sm);
  max-width: var(--chat-max-width);
  width: 100%;
  margin: 0 auto;
  animation: message-enter var(--duration-normal) var(--ease-out-quart) both;
}

/* 用户消息 */
.message.message-user {
  flex-direction: row-reverse;
}

.message.message-user .message-content {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl) var(--radius-md) var(--radius-xl) var(--radius-xl);
  box-shadow: none;
}

.message.message-user .message-role {
  display: none;
}

/* AI 消息 */
.message.message-assistant .message-content {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius-md) var(--radius-xl) var(--radius-xl) var(--radius-xl);
  box-shadow: none;
}

/* 头像 */
.message-avatar {
  flex-shrink: 0;
  width: var(--avatar-size-md);
  height: var(--avatar-size-md);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
}

.message.message-user .message-avatar {
  background: var(--bg-badge);
  color: var(--accent-blue);
  border-color: transparent;
}

.message.message-assistant .message-avatar {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

/* 消息内容 */
.message-content {
  padding: var(--space-sm) var(--space-md);
  max-width: calc(100% - var(--avatar-size-md) - var(--space-sm));
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 消息角色标签 */
.message-role {
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--accent-purple);
  margin-bottom: var(--space-3xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

/* 消息正文 */
.message-body {
  color: inherit;
}

.message-body p {
  margin: var(--space-xs) 0;
  line-height: 1.75;
}

.message-body p:first-child {
  margin-top: 0;
}

.message-body strong {
  font-weight: var(--font-bold);
  color: var(--text-primary);
  background: linear-gradient(120deg, var(--highlight-bg, #fef08a) 0%, var(--highlight-bg-end, #fde68a) 100%);
  padding: 1px 4px;
  border-radius: 3px;
}

.message-body ul,
.message-body ol {
  margin: var(--space-sm) 0;
  padding-left: var(--space-lg);
  list-style: disc;
}

.message-body ol {
  list-style: decimal;
}

.message-body li {
  margin: var(--space-2xs) 0;
  line-height: 1.7;
  color: var(--text-secondary);
}

.message-body li::marker {
  color: var(--accent-blue);
  font-weight: var(--font-bold);
}

.message-body h1 {
  margin: var(--space-lg) 0 var(--space-sm);
  font-weight: var(--font-bold);
  font-size: 1.35em;
  color: var(--text-primary);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border-subtle);
}

.message-body h2 {
  margin: var(--space-md) 0 var(--space-xs);
  font-weight: var(--font-bold);
  font-size: 1.15em;
  color: var(--text-primary);
  padding-left: var(--space-sm);
  border-left: 3px solid var(--accent-purple);
}

.message-body h3 {
  margin: var(--space-sm) 0 var(--space-2xs);
  font-weight: var(--font-semibold);
  font-size: 1.05em;
  color: var(--text-primary);
  padding-left: var(--space-sm);
  border-left: 3px solid var(--accent-blue);
}

.message-body h4 {
  margin: var(--space-sm) 0 var(--space-2xs);
  font-weight: var(--font-semibold);
  font-size: 1em;
  color: var(--text-secondary);
}

.message-body blockquote {
  margin: var(--space-sm) 0;
  padding: var(--space-sm) var(--space-md);
  border-left: 3px solid var(--accent-purple);
  background: var(--bg-tag);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: normal;
}

.message-body blockquote strong {
  color: var(--accent-purple);
}

.message-body hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-md) 0;
}

.message-body pre {
  margin: var(--space-sm) 0;
}

.message-body code {
  background: var(--bg-tag);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.88em;
  color: var(--accent-purple);
  font-family: var(--font-mono);
}

.message-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-sm) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.message-body th {
  background: var(--bg-tag);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  text-align: left;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.9em;
  border: 1px solid var(--border-subtle);
}

.message-body td {
  padding: var(--space-xs) var(--space-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}

/* 可视化占位 / 包装 */
.viz-wrapper {
  margin: var(--space-sm) 0;
}

.viz-placeholder {
  padding: var(--space-md);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* =====================================================
   5. INPUT AREA 输入区
   ===================================================== */

.quick-actions-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-sm);
  background: var(--bg-card);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.quick-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--accent-blue);
  transform: translateY(-1px);
}

.quick-chip:active {
  transform: translateY(0);
}

/* 输入框包装 */
.input-wrapper {
  max-width: var(--chat-max-width);
  margin: 0 auto;
  width: 100%;
  background: var(--bg-card);
  border: var(--border-width-thin) solid var(--border-color);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-fast) var(--ease-default),
              box-shadow var(--duration-fast) var(--ease-default);
}

.input-wrapper:focus-within {
  border-color: var(--border-input-focus);
  box-shadow: var(--shadow-glow-blue), var(--shadow-card);
}

.textarea-container {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  padding: var(--space-xs);
}

.input-wrapper textarea {
  flex: 1;
  min-height: var(--input-area-min-height);
  max-height: var(--input-area-max-height);
  padding: var(--space-xs) var(--space-sm);
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  resize: none;
  outline: none;
  font-family: inherit;
}

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

/* 发送按钮 */
.send-btn {
  flex-shrink: 0;
  width: var(--button-height-lg);
  height: var(--button-height-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--text-primary);
  color: var(--bg-card);
  transition: all 0.2s ease;
  box-shadow: none;
}

.send-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.send-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.send-btn:disabled {
  background: var(--bg-tag);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* 停止按钮（红色调） */
.send-btn.stop-btn {
  background: var(--accent-red);
  color: #fff;
}

/* =====================================================
   6. EMPTY STATE 空状态
   ===================================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  max-width: var(--chat-max-width);
  margin: 0 auto;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-2xl);
  background: var(--bg-badge);
  color: var(--accent-blue);
  margin-bottom: var(--space-xs);
}

.empty-state h2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.empty-state p {
  font-size: var(--text-base);
  color: var(--text-secondary);
  max-width: 440px;
  line-height: var(--leading-relaxed);
}

/* 输入提示 Chips */
.input-hint-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  justify-content: center;
  margin-top: var(--space-lg);
}

.input-hint-chip {
  padding: var(--space-2xs) var(--space-md);
  background: var(--bg-card);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.input-hint-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* =====================================================
   7. CONTEXT PANEL 右侧面板
   ===================================================== */

.context-header {
  display: flex;
  align-items: center;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  flex-shrink: 0;
}

.context-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--text-md);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.context-title-mark {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--bg-badge);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23709ad8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v18h18'/%3E%3Crect x='7' y='12' width='3' height='6' rx='0.5'/%3E%3Crect x='13' y='8' width='3' height='10' rx='0.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}

/* 面板内容区 */
.context-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-md) var(--space-md);
}

/* 面板分区 */
.context-section {
  margin-bottom: var(--space-sm);
  background: var(--bg-card);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  transition: border-color var(--duration-fast) var(--ease-default);
}

.context-section:hover {
  border-color: var(--border-color);
}

.context-section-title {
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.section-hint {
  margin-left: auto;
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  color: var(--text-disabled);
  text-transform: none;
  letter-spacing: 0;
}

/* 可折叠分区 */
.context-section.section-collapsed > *:not(.context-section-title) {
  display: none;
}

.collapse-indicator {
  margin-left: auto;
  font-size: var(--text-2xs);
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-default);
}

/* =====================================================
   8. STAT ROW 统计行
   ===================================================== */

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2xs) 0;
  font-size: var(--text-sm);
}

.stat-row + .stat-row {
  border-top: var(--border-width-thin) solid var(--border-subtle);
}

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

.stat-value {
  color: var(--text-primary);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

/* 版本徽章 */
.version-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-3xs) var(--space-xs);
  background: var(--bg-badge);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-badge);
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-wide);
}

/* =====================================================
   9. PROGRESS BAR 进度条
   ===================================================== */

.progress-bar {
  width: 100%;
  height: 5px;
  background: var(--bg-tag);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-blue);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out-quart);
}

/* =====================================================
   10. LEVEL BADGE / ICEBERG MINI
   ===================================================== */

.mini-iceberg-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-xs) 0;
}

.iceberg-mini {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  margin-top: var(--space-xs);
  position: relative;
}

.water-line-label {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  padding: var(--space-3xs) 0;
  letter-spacing: var(--tracking-wide);
}

.level-stat {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-wide);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  flex-shrink: 0;
}

.level-stat .progress-bar {
  flex: 1;
}

.level-count {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: right;
}

.level-badge-l1 { background: var(--level-1-bg); color: var(--level-1); }
.level-badge-l2 { background: var(--level-2-bg); color: var(--level-2); }
.level-badge-l3 { background: var(--level-3-bg); color: var(--level-3); }
.level-badge-l4 { background: var(--level-4-bg); color: var(--level-4); }
.level-badge-l5 { background: var(--level-5-bg); color: var(--level-5); }
.level-badge-l6 { background: var(--level-6-bg); color: var(--level-6); }

.water-line-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-color), transparent);
  margin: var(--space-3xs) 0;
}

/* =====================================================
   11. PRIORITY GRID
   ===================================================== */

.priority-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xs);
}

.priority-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2xs) var(--space-xs);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: var(--border-width-thin) solid var(--border-subtle);
}

.priority-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: var(--font-bold);
  letter-spacing: var(--tracking-wide);
}

.priority-tag::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: currentColor;
}

.priority-count {
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.priority-p0 { background: var(--priority-p0-bg); color: var(--priority-p0); }
.priority-p1 { background: var(--priority-p1-bg); color: var(--priority-p1); }
.priority-p2 { background: var(--priority-p2-bg); color: var(--priority-p2); }
.priority-p3 { background: var(--priority-p3-bg); color: var(--priority-p3); }

/* =====================================================
   12. QUICK ACTION BTN (面板内)
   ===================================================== */

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  width: 100%;
  padding: var(--space-2xs) var(--space-sm);
  margin-top: var(--space-2xs);
  background: var(--bg-tertiary);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: left;
}

.quick-action-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--accent-blue);
  transform: translateX(2px);
}

/* =====================================================
   13. TYPING INDICATOR 打字动画
   ===================================================== */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-xs) 0;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--accent-purple);
  opacity: 0.5;
  animation: typing-bounce 1.4s var(--ease-default) infinite;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* =====================================================
   14. STREAMING CURSOR 流式光标
   ===================================================== */

.streaming-cursor::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent-blue);
  vertical-align: text-bottom;
  animation: blink var(--anim-blink-duration) var(--ease-default) infinite;
}

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

/* =====================================================
   15. KEYBOARD HINTS 快捷键提示
   ===================================================== */

.shortcut-row {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) 0;
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

.shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  background: var(--bg-tertiary);
  border: var(--border-width-thin) solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--text-secondary);
}

/* =====================================================
   16. MESSAGE TOOLBAR 消息工具栏
   ===================================================== */

.message-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-2xs);
  margin-top: var(--space-xs);
  opacity: 0;
  transform: translateY(var(--space-2xs));
  transition: opacity var(--duration-fast) var(--ease-default),
              transform var(--duration-fast) var(--ease-default);
  pointer-events: none;
}

.message.message-assistant:hover .message-toolbar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.message-toolbar-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-sm);
  background: transparent;
  border: var(--border-width-thin) solid transparent;
  color: var(--text-muted);
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

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

.message-toolbar-btn[data-action="copy"]:hover { color: var(--accent-blue); }
.message-toolbar-btn[data-action="regenerate"]:hover { color: var(--accent-green); }
.message-toolbar-btn[data-action="export"]:hover { color: var(--accent-purple); }

/* =====================================================
   17. CHAT SEARCH 对话搜索框
   ===================================================== */

.chat-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-2xs) var(--space-md);
  margin: 0 var(--space-lg) var(--space-xs);
  background: var(--bg-input);
  border: var(--border-width-thin) solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-default);
  flex-shrink: 0;
}

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

.chat-search-input {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
  outline: none;
  padding: var(--space-3xs) 0;
}

.chat-search-input::placeholder {
  color: var(--placeholder-color);
  font-size: var(--text-sm);
}

/* =====================================================
   18. ANIMATIONS 动画
   ===================================================== */

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

/* =====================================================
   18b. DEGRADED CARD & NO-VIZ HINT（容错降级）
   ===================================================== */

.bfe-degraded-card {
  margin: var(--space-sm) 0;
  padding: var(--space-sm) var(--space-md);
  background: color-mix(in oklch, var(--accent-amber) 8%, var(--bg-card));
  border: 1px solid color-mix(in oklch, var(--accent-amber) 30%, var(--border-subtle));
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
}
.bfe-degraded-head {
  display: flex; align-items: center; gap: var(--space-xs);
  cursor: pointer;
  user-select: none;
}
.bfe-degraded-icon { color: var(--accent-amber); font-size: var(--text-sm); }
.bfe-degraded-title {
  font-weight: var(--font-semibold); color: var(--text-primary);
  flex: 1;
}
.bfe-degraded-toggle {
  color: var(--accent-blue); font-size: var(--text-2xs);
  font-weight: var(--font-medium);
}
.bfe-degraded-err {
  margin-top: var(--space-2xs);
  color: var(--accent-red);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
}
.bfe-degraded-raw {
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

.bfe-no-viz-hint {
  display: flex; align-items: flex-start; gap: var(--space-xs);
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: color-mix(in oklch, var(--accent-blue) 6%, var(--bg-tertiary));
  border: 1px solid color-mix(in oklch, var(--accent-blue) 22%, var(--border-subtle));
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}
.bfe-no-viz-icon { flex-shrink: 0; opacity: 0.7; }

@media (prefers-reduced-motion: reduce) {
  .message { animation: none; }
  .typing-indicator span { animation: none; }
}

/* =====================================================
   19. 移动端触控优化
   ===================================================== */

@media (max-width: 768px) {
  .chat-history-item {
    min-height: var(--button-height-lg);
    padding: var(--space-sm);
  }

  .message.message-assistant .message-toolbar {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}
