/* ═══════════════════════════════════════
   CodAI - 全新设计的 UI 样式
   ═══════════════════════════════════════ */

:root {
  /* NvChad-inspired dark palette */
  --bg-primary:   #14141c;
  --bg-secondary: #1c1c28;
  --bg-tertiary:  #222232;
  --bg-hover:     #2a2a3c;
  --bg-input:     #181824;
  --bg-user-msg:  #1e1e48;
  --border:       #2a2a3e;
  --border-light: #343450;
  --border-focus: #7c7cf0;
  --text-primary:   #cdd6f4;
  --text-secondary: #a6adc8;
  --text-tertiary:  #6c7086;
  --text-muted:     #45475a;
  --accent:       #89b4fa;
  --accent-hover: #b4d0fe;
  --accent-dim:   rgba(137,180,250,0.12);
  --accent-glow:  rgba(137,180,250,0.22);
  --success:      #a6e3a1;
  --success-dim:  rgba(166,227,161,0.12);
  --warning:      #f9e2af;
  --error:        #f38ba8;
  --error-dim:    rgba(243,139,168,0.12);
  --route-thinking:    #cba6f7;
  --route-thinking-bg: rgba(203,166,247,0.1);
  --route-ui:    #89dceb;
  --route-ui-bg: rgba(137,220,235,0.1);
  --route-debug:    #fab387;
  --route-debug-bg: rgba(250,179,135,0.1);
  --route-craft:    #f38ba8;
  --radius:    14px;
  --radius-sm:  9px;
  --radius-xs:  5px;
  --font: -apple-system, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', monospace;
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.4);
  --shadow:    0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --transition: 0.18s ease;
  --transition-slow: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 亮色主题（白日风格） */
body.light-theme {
  --bg-primary: #f7f7f8;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f0f3;
  --bg-hover: #e8e8ec;
  --bg-input: #ffffff;
  --bg-user-msg: #eff3ff;
  --border: #e2e2e8;
  --border-light: #d4d4dc;
  --border-focus: #6366f1;
  --text-primary: #1a1b26;
  --text-secondary: #4a4b5c;
  --text-tertiary: #8b8ca0;
  --text-muted: #a0a0b0;
  --accent: #6366f1;
  --accent-hover: #5558e6;
  --accent-dim: rgba(99, 102, 241, 0.08);
  --accent-glow: rgba(99, 102, 241, 0.2);
  --success: #10b981;
  --success-dim: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --error: #ef4444;
  --error-dim: rgba(239, 68, 68, 0.08);
  --route-thinking: #7c3aed;
  --route-thinking-bg: rgba(124, 58, 237, 0.08);
  --route-ui: #0891b2;
  --route-ui-bg: rgba(8, 145, 178, 0.08);
  --route-debug: #ea580c;
  --route-debug-bg: rgba(234, 88, 12, 0.08);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
}

/* 亮色主题特殊覆写 */
body.light-theme .sidebar {
  background: linear-gradient(180deg, #f8f8fc 0%, #f4f4f9 100%);
  border-right: 1px solid rgba(99,102,241,0.1);
  box-shadow: 1px 0 8px rgba(0,0,0,0.04);
}

body.light-theme .sidebar::after {
  background: linear-gradient(180deg, rgba(99,102,241,0.15), rgba(139,92,246,0.08), transparent);
}

body.light-theme .sidebar-header {
  background: rgba(255,255,255,0.7);
  border-bottom-color: rgba(99,102,241,0.08);
}

body.light-theme .logo {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #0891b2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .logo-sub {
  color: #8b8ca0;
}

body.light-theme .conv-item:hover {
  background: rgba(99,102,241,0.06);
  border-color: rgba(99,102,241,0.1);
}

body.light-theme .conv-item.active {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.15);
}

body.light-theme .conv-item::before {
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
}

body.light-theme .conv-title {
  color: #1a1b26;
}

body.light-theme .conv-time {
  color: #8b8ca0;
}

body.light-theme .sidebar-footer {
  background: rgba(248,248,252,0.9);
  border-top-color: rgba(99,102,241,0.08);
}

body.light-theme .sf-btn {
  color: #4a4b5c;
  background: rgba(99,102,241,0.05);
  border: 1px solid rgba(99,102,241,0.08);
}

body.light-theme .sf-btn:hover {
  background: rgba(99,102,241,0.1);
  color: #6366f1;
  border-color: rgba(99,102,241,0.2);
}

body.light-theme .sidebar-footer-btns {
  border-top: 1px solid rgba(99,102,241,0.08);
}

body.light-theme .conversation-list::-webkit-scrollbar-thumb {
  background: rgba(99,102,241,0.15);
}

body.light-theme .icon-logo {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  box-shadow: 0 0 12px rgba(99,102,241,0.3), 0 2px 8px rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.3);
}

body.light-theme .message-user .message-content {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: white;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

body.light-theme .message-assistant .message-content {
  background: #ffffff;
  border-color: #e8e8ef;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

body.light-theme .message-assistant .message-content pre {
  background: #f5f5f8;
  border-color: #e2e2e8;
}

body.light-theme .message-assistant .message-content :not(pre) > code {
  background: rgba(99, 102, 241, 0.06);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.12);
}

body.light-theme .input-wrapper {
  background: #ffffff;
  border-color: #e2e2e8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

body.light-theme .input-wrapper:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

body.light-theme .topbar {
  background: #ffffff;
  border-bottom-color: #e8e8ef;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

body.light-theme .quick-btn {
  background: #ffffff;
  border-color: #e2e2e8;
  color: #4a4b5c;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

body.light-theme .quick-btn:hover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.04);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}

body.light-theme .thinking-block {
  background: rgba(124, 58, 237, 0.04);
  border-color: rgba(124, 58, 237, 0.12);
}

body.light-theme .toast-success { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
body.light-theme .toast-error { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
body.light-theme .toast-info { background: #eff6ff; color: #1e40af; border-color: #93c5fd; }
body.light-theme .toast-warning { background: #fffbeb; color: #92400e; border-color: #fbbf24; }

body.light-theme .modal-backdrop {
  background: rgba(0, 0, 0, 0.3);
}

body.light-theme .modal-content {
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

body.light-theme .welcome h2 {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.light-theme .logo {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ═══════════════════════════════════════
   玻璃态主题（Glass / Aurora）
   参考：蓝紫色半透明玻璃态设计
   ═══════════════════════════════════════ */
body.glass-theme {
  --bg-primary:   #0d0d1a;
  --bg-secondary: rgba(20,20,40,0.65);
  --bg-tertiary:  rgba(30,30,60,0.55);
  --bg-hover:     rgba(80,80,160,0.15);
  --bg-input:     rgba(15,15,35,0.7);
  --bg-user-msg:  rgba(89,114,250,0.2);
  --border:       rgba(137,180,250,0.15);
  --border-light: rgba(203,166,247,0.2);
  --border-focus: rgba(137,180,250,0.6);
  --text-primary:   #e8eeff;
  --text-secondary: #b4c0f0;
  --text-tertiary:  #6878b0;
  --text-muted:     #3d4d7a;
  --accent:       #89b4fa;
  --accent-hover: #b4d0fe;
  --accent-dim:   rgba(137,180,250,0.18);
  --accent-glow:  rgba(137,180,250,0.35);
  --success:      #a6e3a1;
  --success-dim:  rgba(166,227,161,0.12);
  --warning:      #f9e2af;
  --error:        #f38ba8;
  --error-dim:    rgba(243,139,168,0.12);
  --route-thinking:    #cba6f7;
  --route-thinking-bg: rgba(203,166,247,0.12);
  --route-ui:    #89dceb;
  --route-ui-bg: rgba(137,220,235,0.1);
  --route-debug:    #fab387;
  --route-debug-bg: rgba(250,179,135,0.1);
  --route-craft:    #f38ba8;
  --shadow-sm: 0 2px 8px rgba(89,114,250,0.15);
  --shadow:    0 8px 32px rgba(89,114,250,0.2);
  --shadow-lg: 0 16px 64px rgba(89,114,250,0.25);
}

/* 玻璃态背景 aurora 效果 */
body.glass-theme::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(89,114,250,0.25) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(203,166,247,0.2) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 50% 50%, rgba(137,220,235,0.06) 0%, transparent 70%),
    #0d0d1a;
  z-index: -1;
  pointer-events: none;
}

body.glass-theme .sidebar {
  background: rgba(10,10,28,0.75);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid rgba(137,180,250,0.12);
  box-shadow: inset -1px 0 0 rgba(137,180,250,0.06), 4px 0 24px rgba(0,0,0,0.4);
}

body.glass-theme .sidebar::after {
  background: linear-gradient(180deg, rgba(137,180,250,0.2), rgba(203,166,247,0.12), transparent);
}

body.glass-theme .sidebar-header {
  background: rgba(255,255,255,0.03);
  border-bottom-color: rgba(137,180,250,0.1);
  backdrop-filter: blur(10px);
}

body.glass-theme .conv-item:hover {
  background: rgba(137,180,250,0.08);
  border-color: rgba(137,180,250,0.15);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

body.glass-theme .conv-item.active {
  background: linear-gradient(135deg, rgba(137,180,250,0.15), rgba(203,166,247,0.1));
  border-color: rgba(137,180,250,0.25);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 8px rgba(137,180,250,0.1);
}

body.glass-theme .sidebar-footer {
  background: rgba(10,10,28,0.6);
  backdrop-filter: blur(10px);
  border-top-color: rgba(137,180,250,0.1);
}

body.glass-theme .sf-btn {
  background: rgba(137,180,250,0.06);
  border: 1px solid rgba(137,180,250,0.1);
  backdrop-filter: blur(4px);
}

body.glass-theme .sf-btn:hover {
  background: rgba(137,180,250,0.14);
  border-color: rgba(137,180,250,0.25);
  box-shadow: 0 2px 12px rgba(137,180,250,0.12);
}

body.glass-theme .main {
  background: transparent;
}

body.glass-theme .topbar {
  background: rgba(13,13,26,0.7);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid rgba(137,180,250,0.1);
  box-shadow: 0 1px 0 rgba(137,180,250,0.05), 0 4px 20px rgba(0,0,0,0.3);
}

body.glass-theme .message-user .message-content {
  background: linear-gradient(135deg, rgba(89,114,250,0.35), rgba(137,180,250,0.25));
  border: 1px solid rgba(137,180,250,0.3);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(89,114,250,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
}

body.glass-theme .message-assistant .message-content {
  background: rgba(20,20,45,0.6);
  border: 1px solid rgba(137,180,250,0.12);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.04);
}

body.glass-theme .message-assistant .message-content pre {
  background: rgba(10,10,25,0.7);
  border: 1px solid rgba(137,180,250,0.1);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}

body.glass-theme .input-wrapper {
  background: rgba(15,15,35,0.75);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(137,180,250,0.15);
  box-shadow: 0 4px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}

body.glass-theme .input-wrapper:focus-within {
  border-color: rgba(137,180,250,0.4);
  box-shadow: 0 0 0 3px rgba(137,180,250,0.12), 0 4px 24px rgba(89,114,250,0.15), inset 0 1px 0 rgba(255,255,255,0.07);
}

body.glass-theme .modal-content {
  background: rgba(15,15,35,0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(137,180,250,0.2);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06);
}

body.glass-theme .modal-backdrop {
  background: rgba(0,0,30,0.6);
  backdrop-filter: blur(4px);
}

body.glass-theme .notice-bubble {
  background: rgba(13,13,30,0.88) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  border: 1px solid rgba(137,180,250,0.25) !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 80px rgba(89,114,250,0.15), inset 0 1px 0 rgba(255,255,255,0.08) !important;
}

body.glass-theme .btn-primary {
  background: linear-gradient(135deg, rgba(89,114,250,0.9), rgba(137,180,250,0.8));
  border: 1px solid rgba(137,180,250,0.4);
  box-shadow: 0 2px 12px rgba(89,114,250,0.3);
}

body.glass-theme .btn-primary:hover {
  background: linear-gradient(135deg, rgba(89,114,250,1), rgba(137,180,250,0.95));
  box-shadow: 0 4px 20px rgba(89,114,250,0.4);
}

body.glass-theme .quick-btn {
  background: rgba(20,20,50,0.6);
  border: 1px solid rgba(137,180,250,0.1);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

body.glass-theme .quick-btn:hover {
  background: rgba(89,114,250,0.15);
  border-color: rgba(137,180,250,0.25);
  box-shadow: 0 4px 16px rgba(89,114,250,0.15);
}

body.glass-theme .thinking-block {
  background: rgba(203,166,247,0.06);
  border-color: rgba(203,166,247,0.15);
  backdrop-filter: blur(4px);
}

body.glass-theme .search-progress-bar {
  background: rgba(10,10,28,0.75);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(137,180,250,0.15);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

body.glass-theme .welcome-card {
  background: rgba(20,20,50,0.5) !important;
  border: 1px solid rgba(137,180,250,0.12) !important;
  backdrop-filter: blur(8px) !important;
}

body.glass-theme .welcome-card:hover {
  background: rgba(89,114,250,0.12) !important;
  border-color: rgba(137,180,250,0.25) !important;
  box-shadow: 0 8px 24px rgba(89,114,250,0.15) !important;
}

body.glass-theme .welcome h2 {
  background: linear-gradient(135deg, #89b4fa, #cba6f7, #89dceb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(137,180,250,0.3));
}

body.glass-theme .toast {
  backdrop-filter: blur(16px);
  background: rgba(15,15,35,0.88);
  border: 1px solid rgba(137,180,250,0.2);
}

body.glass-theme .model-selector {
  background: rgba(15,15,35,0.7);
  border-color: rgba(137,180,250,0.15);
  backdrop-filter: blur(8px);
}

body.glass-theme ::-webkit-scrollbar-thumb {
  background: rgba(137,180,250,0.15);
}

body.glass-theme .code-block-wrapper {
  border-color: rgba(137,180,250,0.1);
}

body.glass-theme .code-block-header {
  background: rgba(10,10,25,0.8);
  border-bottom-color: rgba(137,180,250,0.08);
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ─── 侧边栏 ─── */

.sidebar {
  width: 268px;
  min-width: 268px;
  background: linear-gradient(180deg, #16162a 0%, #14141f 100%);
  border-right: 1px solid rgba(137,180,250,0.08);
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow), opacity var(--transition);
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, rgba(137,180,250,0.15), rgba(203,166,247,0.08), transparent);
  pointer-events: none;
}

.sidebar.collapsed {
  margin-left: -268px;
}

.sidebar-header {
  padding: 14px 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  gap: 10px;
  background: rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.logo {
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #89b4fa 0%, #cba6f7 60%, #89dceb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.logo-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 1px;
  font-family: var(--font-mono);
  opacity: 0.7;
}

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

.conversation-list::-webkit-scrollbar { width: 2px; }
.conversation-list::-webkit-scrollbar-thumb { background: rgba(137,180,250,0.15); border-radius: 2px; }
.conversation-list::-webkit-scrollbar-thumb:hover { background: rgba(137,180,250,0.3); }

.conv-item {
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.14s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1px;
  border: 1px solid transparent;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

.conv-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-meta {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.conv-time {
  font-size: 10px;
  color: var(--text-tertiary);
  opacity: 0.7;
  white-space: nowrap;
}

.conv-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--route-thinking));
  border-radius: 0 1px 1px 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.conv-item:hover { background: rgba(137,180,250,0.06); border-color: rgba(137,180,250,0.08); }
.conv-item.active {
  background: linear-gradient(135deg, rgba(137,180,250,0.1), rgba(203,166,247,0.06));
  border-color: rgba(137,180,250,0.2);
}
.conv-item.active::before { opacity: 1; }

.conv-item .title {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  line-height: 1.4;
}

.conv-item.active .title { color: var(--text-primary); font-weight: 500; }

.conv-item .delete-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  transition: all 0.12s;
  flex-shrink: 0;
}

.conv-item:hover .delete-btn { opacity: 0.45; }
.conv-item .delete-btn:hover { opacity: 1; background: var(--error-dim); color: var(--error); }

/* Paste mode tip */
.paste-mode-tip {
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeInUp 0.2s ease;
}
.paste-mode-tip button {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}
.paste-mode-tip button:hover { background: var(--accent); color: white; }

.sidebar-footer {
  padding: 10px 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.04);
  background: rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.sidebar-footer-btns {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.sf-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 6px;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10.5px;
  font-family: var(--font);
  transition: all 0.15s ease;
}
.sf-btn:hover {
  background: rgba(137,180,250,0.08);
  border-color: rgba(137,180,250,0.2);
  color: var(--accent);
}

.engine-stats {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.6;
  font-family: var(--font-mono);
  opacity: 0.8;
  padding: 4px 2px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

/* ─── 主区域 ─── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

.topbar {
  height: 44px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  background: rgba(20,20,32,0.92);
  flex-shrink: 0;
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(137,180,250,0.15), transparent);
  pointer-events: none;
}

.topbar-center { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 200px; overflow: hidden; }

.route-badge {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.route-thinking { background: var(--route-thinking-bg); color: var(--route-thinking); }
.route-ui { background: var(--route-ui-bg); color: var(--route-ui); }
.route-debug { background: var(--route-debug-bg); color: var(--route-debug); }
.route-craft { background: rgba(243,139,168,0.12); color: var(--route-craft); }

.mode-badge {
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10.5px;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scroll-behavior: smooth;
  scrollbar-width: none;
  flex-shrink: 1;
  min-width: 0;
  padding-bottom: 2px; /* prevent scrollbar overlap */
}
.topbar-actions::-webkit-scrollbar { display: none; }

.model-selector {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 1;
  min-width: 100px;
}

.model-selector:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.model-selector:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.llm-selector {
  max-width: 140px;
  font-size: 11px;
  padding: 5px 8px;
}

.llm-selector.hidden { display: none !important; }

/* Provider selector (multi-API switcher) */
.provider-sel {
  padding: 3px 7px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11px;
  outline: none;
  max-width: 150px;
  cursor: pointer;
}
.provider-sel:focus { border-color: var(--accent); }

/* ─── 深度思考 Toggle 开关 ─── */

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
}

.toggle-label input { display: none; }

.toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  position: relative;
  transition: all var(--transition);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: all var(--transition);
}

.toggle-label input:checked + .toggle-track {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-label input:checked + .toggle-track::after {
  left: 18px;
  background: var(--accent);
}

.toggle-label input:checked ~ .toggle-text {
  color: var(--accent);
}

/* ─── 消息区域 ─── */

/* ─── 实时检索进度面板（Claude 风格：折叠式）─── */
.search-progress-panel {
  margin: 6px 12px 0;
  border-radius: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
  overflow: hidden;
}
.search-progress-panel.hidden { display: none !important; }
.search-progress-panel.sp-fading { opacity: 0; transform: translateY(-8px); pointer-events: none; }

/* ─ 折叠状态的头部行（始终可见）─ */
.sp-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.sp-header:hover { background: var(--bg-hover); }
.sp-spinner {
  width: 9px; height: 9px;
  border: 1.5px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.sp-spinner.sp-spinner-done {
  border: 1.5px solid var(--success);
  animation: none;
  background: var(--success);
  border-radius: 50%;
}
/* 展开箭头 */
.sp-toggle-arrow {
  margin-left: auto;
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.25s ease;
  opacity: 0.5;
  flex-shrink: 0;
}
.search-progress-panel.sp-expanded .sp-toggle-arrow {
  transform: rotate(180deg);
}
/* ─ 展开后的详情区 ─ */
.sp-expand-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
  border-top: 0px solid transparent;
}
.search-progress-panel.sp-expanded .sp-expand-body {
  max-height: 200px;
  border-top: 1px solid var(--border);
}

.sp-results {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 150px;
  overflow-y: auto;
  padding: 4px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sp-scanning {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.sp-scan-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: sp-pulse 1.2s ease-in-out infinite;
}
.sp-scan-dot:nth-child(2) { animation-delay: 0.2s; }
.sp-scan-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes sp-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
.sp-result-item {
  display: grid;
  grid-template-columns: 18px auto 1fr;
  align-items: center;
  gap: 4px;
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  position: relative;
  overflow: hidden;
  transition: background 0.2s;
  min-height: 24px;
}
.sp-result-item:hover { background: var(--bg-secondary); }
.sp-item-new {
  animation: sp-slide-in 0.25s ease-out;
}
@keyframes sp-slide-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
.sp-icon { font-size: 12px; text-align: center; }
.sp-src { font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.sp-preview { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; }
.sp-score-bar {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover, var(--accent)));
  opacity: 0.5;
  border-radius: 0 0 6px 6px;
  transition: width 0.3s ease;
}
.sp-more { font-size: 11px; color: var(--text-muted); padding: 2px 8px; opacity: 0.7; }
.sp-empty { color: var(--text-muted); font-style: italic; padding: 4px 0; }
.sp-web-status {
  padding: 5px 8px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sp-web-status.hidden { display: none; }
.sp-web-spin {
  display: inline-block;
  width: 8px; height: 8px;
  border: 1.5px solid #60a5fa;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.sp-web-status.hidden { display: none; }

/* Progress bar in header */
.sp-progress-track {
  height: 2px;
  background: var(--border);
  overflow: hidden;
  flex: 1;
  border-radius: 2px;
}
.sp-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--route-thinking));
  border-radius: 2px;
  transition: width 0.15s ease;
}
.sp-progress-bar.sp-bar-complete {
  width: 100%;
  animation: sp-bar-fade 1.2s ease 0.3s forwards;
}
@keyframes sp-bar-fade {
  0%   { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; }
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
  pointer-events: auto;
  will-change: scroll-position;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(137,180,250,0.04) 0%, transparent 60%);
}

.messages::-webkit-scrollbar { width: 3px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.messages::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 6px;
  padding: 20px;
}

.welcome-icon {
  font-size: 54px;
  opacity: 0.9;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 28px rgba(137,180,250,0.55));
  animation: icon-float 5s ease-in-out infinite;
}
@keyframes icon-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(1.5deg); }
}

.welcome h2 {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent) 0%, var(--route-thinking) 50%, var(--route-ui) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.04em;
  margin-bottom: 1px;
  line-height: 1.2;
}

.welcome p {
  color: var(--text-tertiary);
  font-size: 12.5px;
  max-width: 280px;
  line-height: 1.6;
}

.welcome-version {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  opacity: 0.6;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
}

.quick-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 18px;
  justify-content: center;
  max-width: 440px;
  padding: 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quick-actions::-webkit-scrollbar { display: none; }

.quick-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
  font-family: var(--font);
  white-space: nowrap;
  letter-spacing: 0.01em;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.quick-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(137,180,250,0.06));
  opacity: 0;
  transition: opacity 0.18s;
}
.quick-btn:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(137,180,250,0.18);
}
.quick-btn:hover::before { opacity: 1; }
.quick-btn:active { transform: translateY(0); box-shadow: none; }

/* ─── 消息气泡 ─── */

.message {
  max-width: 840px;
  margin: 0 auto 14px;
  animation: fadeIn 0.22s ease;
}

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

.message-user {
  display: flex;
  justify-content: flex-end;
}

.message-user .message-content {
  background: linear-gradient(135deg, #2d2a7a 0%, #4a3fc0 50%, #5c4ee8 100%);
  color: #eef0ff;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 10px 16px;
  max-width: 72%;
  box-shadow: 0 3px 16px rgba(99,102,241,0.28), inset 0 1px 0 rgba(255,255,255,0.1);
  font-size: 14px;
  line-height: 1.65;
  position: relative;
  border: 1px solid rgba(137,180,250,0.2);
}

.message-assistant {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-assistant .message-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(137,180,250,0.3);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 14px 18px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.2);
  position: relative;
}

.api-error-msg {
  display: flex; align-items: center; gap: 8px;
  color: var(--error); font-size: 13px; padding: 4px 0;
}

.message-time {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 0 4px;
  margin-top: 4px;
}

.message-user .message-time { text-align: right; }

/* ─── 消息底部（stage 标记 + 操作按钮）─── */

.message-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.stage-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

/* ─── 消息操作按钮 ─── */

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}

.message:hover .message-actions { opacity: 1; }
@media (hover: none) { .message-actions { opacity: 1; } }

.msg-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-tertiary);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
  font-family: var(--font);
}

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

/* ─── Markdown 渲染 ─── */

.message-assistant .message-content h2 {
  font-size: 17px;
  margin: 16px 0 8px;
  font-weight: 600;
  color: var(--text-primary);
}
.message-assistant .message-content h3 {
  font-size: 15px;
  margin: 14px 0 6px;
  font-weight: 600;
  color: var(--route-thinking);
}
.message-assistant .message-content p { margin: 6px 0; }
.message-assistant .message-content ul,
.message-assistant .message-content ol {
  padding-left: 20px;
  margin: 6px 0;
}
.message-assistant .message-content li { margin: 3px 0; }

.message-assistant .message-content pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.55;
}

.message-assistant .message-content code {
  font-family: var(--font-mono);
  font-size: 13px;
}

.message-assistant .message-content :not(pre) > code {
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  color: var(--accent-hover);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.message-assistant .message-content strong { color: var(--accent-hover); }

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

/* ─── Thinking 块 ─── */

.thinking-block {
  background: linear-gradient(135deg, rgba(203,166,247,0.06) 0%, rgba(137,180,250,0.03) 100%);
  border: 1px solid rgba(203, 166, 247, 0.14);
  border-left: 3px solid var(--route-thinking);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(203,166,247,0.06);
}

.thinking-header {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--route-thinking);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  transition: background var(--transition);
  font-weight: 700;
  letter-spacing: 0.04em;
  user-select: none;
  text-transform: uppercase;
}
.th-icon {
  font-size: 8px;
  animation: th-pulse 2s ease-in-out infinite;
}
.th-toggle-hint {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.5;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
@keyframes th-pulse {
  0%, 100% { opacity: 0.4; text-shadow: none; }
  50% { opacity: 1; text-shadow: 0 0 6px var(--route-thinking); }
}
.thinking-block:has(.thinking-body.open) .th-icon { animation: none; opacity: 1; }
.thinking-block:has(.thinking-body.open) .th-toggle-hint { opacity: 0; }

.thinking-header:hover {
  background: rgba(203, 166, 247, 0.07);
}

.thinking-body {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid rgba(203, 166, 247, 0.1);
  display: none;
  line-height: 1.75;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.1);
}

.thinking-body.open { display: block; animation: fadeIn 0.2s ease; }

/* (thinking block styles defined above) */

/* ─── Artifacts 块 ─── */

.artifact-block {
  background: linear-gradient(135deg, rgba(137,180,250,0.04), rgba(203,166,247,0.03));
  border: 1px solid rgba(137,180,250,0.15);
  border-top: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.artifact-header {
  padding: 8px 12px;
  background: rgba(137,180,250,0.04);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.artifact-icon { font-size: 16px; }
.artifact-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.artifact-download {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background var(--transition);
}

.artifact-download:hover { background: var(--accent-hover); }

.artifact-preview {
  padding: 12px;
  margin: 0 !important;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px !important;
  background: var(--bg-primary) !important;
  border: none !important;
}

/* ─── 代码块 ─── */

.code-block-wrapper {
  position: relative;
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  border: 1px solid rgba(137,180,250,0.1);
  background: #0d0d16;
}

.code-lang-label {
  position: absolute;
  top: 0;
  left: 0;
  padding: 3px 12px;
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--accent);
  background: rgba(137,180,250,0.1);
  border-radius: 0 0 var(--radius-xs) 0;
  border-right: 1px solid rgba(137,180,250,0.15);
  border-bottom: 1px solid rgba(137,180,250,0.15);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 3px 9px;
  font-size: 11px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition);
  font-family: var(--font);
}

.code-block-wrapper:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.copy-btn.copied { background: var(--success); color: white; border-color: var(--success); opacity: 1; }

/* ─── 附件预览 ─── */

.attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 820px;
  margin: 0 auto 8px;
  padding: 0 4px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  max-width: 200px;
  animation: fadeIn 0.2s ease;
}

.attachment-icon { font-size: 14px; }
.attachment-name {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 10px;
  padding: 2px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.attachment-remove:hover {
  background: var(--error-dim);
  color: var(--error);
}

/* ─── 输入区域 ─── */

.input-area {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: linear-gradient(to top, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  flex-shrink: 0;
  position: relative;
}

.input-area::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-dim), var(--route-thinking-bg), transparent);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.03);
}

.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(137,180,250,0.18), 0 4px 20px rgba(0,0,0,0.3), inset 0 1px 0 rgba(137,180,250,0.05);
  background: rgba(20,20,32,0.95);
}

#userInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 200px;
  padding: 5px 0;
  line-height: 1.6;
  caret-color: var(--accent);
}

#userInput::placeholder { color: var(--text-muted); font-style: italic; }

.btn-send {
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--route-thinking));
  border: none;
  color: #14141c;
  font-size: 16px;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 2px 8px rgba(137,180,250,0.25);
}

.btn-send:disabled {
  opacity: 0.22;
  cursor: not-allowed;
  background: var(--bg-tertiary);
  box-shadow: none;
}
.btn-send:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(137,180,250,0.4);
}
.btn-send:not(:disabled):active { transform: scale(0.95); }

.input-hints {
  max-width: 820px;
  margin: 5px auto 0;
  min-height: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

.input-hint-text {
  font-size: 11px;
  color: var(--text-tertiary);
}

.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--route-thinking);
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(203,166,247,0.08);
  border: 1px solid rgba(203,166,247,0.15);
  padding: 3px 10px;
  border-radius: 20px;
}

/* Keyboard shortcut hints */
.input-shortcuts {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--text-muted);
}
.input-shortcuts kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 5px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-bottom: 2px solid var(--border-light);
  border-radius: 4px;
  font-size: 9.5px;
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  line-height: 1.4;
}
.input-shortcuts .sc-sep { color: var(--text-muted); margin: 0 4px; }
.input-shortcuts span:not(.sc-sep) { color: var(--text-tertiary); }

.dot-pulse {
  display: inline-flex;
  gap: 3px;
}

.dot-pulse::before, .dot-pulse::after, .dot-pulse span {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s infinite ease-in-out;
}

.dot-pulse::before { animation-delay: 0s; }
.dot-pulse span { animation-delay: 0.2s; }
.dot-pulse::after { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ─── 按钮 ─── */

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-weight: 500;
}

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

/* Send button overrides btn-primary to use gradient */
.btn-send.btn-primary { background: linear-gradient(135deg, var(--accent), var(--route-thinking)); color: #14141c; }
.btn-send.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #d6b9ff); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  border-radius: 50%;
}

/* ─── Toast 通知 ─── */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 4px 16px rgba(0,0,0,0.3);
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, toastFadeOut 0.4s ease 3.1s forwards;
  pointer-events: auto;
  transform-origin: bottom right;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  max-width: 340px;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}

.toast-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.toast-body { flex: 1; }
.toast-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }
.toast-text  { font-size: 13px; line-height: 1.4; }

.toast-success {
  background: rgba(2,44,34,0.93); border: 1px solid rgba(74,222,128,0.22); color: #86efac;
}
.toast-success::before { background: #4ade80; }
.toast-success .toast-icon { background: rgba(74,222,128,0.12); color: #4ade80; }
.toast-success .toast-label { color: #4ade80; }

.toast-error {
  background: rgba(64,8,8,0.93); border: 1px solid rgba(248,113,113,0.22); color: #fca5a5;
}
.toast-error::before { background: #f87171; }
.toast-error .toast-icon { background: rgba(248,113,113,0.12); color: #f87171; }
.toast-error .toast-label { color: #f87171; }

.toast-info {
  background: rgba(15,23,60,0.93); border: 1px solid rgba(99,102,241,0.22); color: #a5b4fc;
}
.toast-info::before { background: #818cf8; }
.toast-info .toast-icon { background: rgba(99,102,241,0.12); color: #818cf8; }
.toast-info .toast-label { color: #818cf8; }

.toast-warning {
  background: rgba(55,28,5,0.93); border: 1px solid rgba(251,191,36,0.22); color: #fde68a;
}
.toast-warning::before { background: #fbbf24; }
.toast-warning .toast-icon { background: rgba(251,191,36,0.12); color: #fbbf24; }
.toast-warning .toast-label { color: #fbbf24; }

@keyframes toastSlideIn {
  0%   { opacity: 0; transform: translateX(40px) scale(0.88); }
  60%  { opacity: 1; transform: translateX(-4px) scale(1.02); }
  80%  { transform: translateX(2px) scale(0.99); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastFadeOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(20px) scale(0.92); }
}

/* ─── 公告弹窗外层 ─── */
.notice-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.notice-modal-wrap.visible {
  opacity: 1;
  pointer-events: auto;
}
.notice-modal-wrap.notice-hiding {
  opacity: 0;
  pointer-events: none;
}

/* ─── 公告弹窗气泡入场动画 ─── */

.notice-bubble {
  animation: noticeBubbleIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  transform-origin: center center;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
  /* 公告板质感 */
  background: linear-gradient(160deg, var(--bg-secondary) 0%, color-mix(in srgb, var(--bg-secondary) 85%, var(--accent) 15%) 100%) !important;
  border: 1px solid rgba(137,180,250,0.25) !important;
  box-shadow: 0 0 0 1px rgba(137,180,250,0.08), 0 24px 64px rgba(0,0,0,0.55), 0 0 40px rgba(99,102,241,0.08) !important;
}
.notice-hiding .notice-bubble {
  transform: translateY(14px) scale(0.93);
  opacity: 0;
}

/* 公告顶部渐变色条 */
.notice-bubble::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #a78bfa, var(--accent));
  border-radius: 14px 14px 0 0;
}

@keyframes noticeBubbleIn {
  0%   { opacity: 0; transform: translateY(12px) scale(0.88); }
  60%  { opacity: 1; transform: translateY(-3px) scale(1.02); }
  80%  { transform: translateY(1px) scale(0.99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── 模态框 ─── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  background: linear-gradient(160deg, var(--bg-secondary) 0%, color-mix(in srgb, var(--bg-secondary) 92%, var(--accent) 8%) 100%);
  border: 1px solid rgba(137,180,250,0.18);
  border-radius: 18px;
  width: 440px;
  max-width: 92vw;
  box-shadow: 0 0 0 1px rgba(137,180,250,0.06), 0 32px 80px rgba(0,0,0,0.6), 0 0 60px rgba(99,102,241,0.08);
  animation: modalIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

/* 顶部渐变色条 */
.modal-content::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #a78bfa, #38bdf8, var(--accent));
  background-size: 200% 100%;
  animation: modalBarShimmer 3s linear infinite;
  z-index: 1;
}

@keyframes modalBarShimmer {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

@keyframes modalIn {
  0%   { opacity: 0; transform: translateY(16px) scale(0.9); }
  60%  { opacity: 1; transform: translateY(-3px) scale(1.01); }
  80%  { transform: translateY(1px) scale(0.995); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-body { padding: 20px; }

/* ─── 自定义确认框 ─── */
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-modal.hidden { display: none; }
.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.confirm-box {
  position: relative;
  background: linear-gradient(160deg, var(--bg-secondary) 0%, color-mix(in srgb, var(--bg-secondary) 88%, #ef4444 12%) 100%);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: 18px;
  padding: 0;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 0 0 1px rgba(248,113,113,0.06), 0 32px 80px rgba(0,0,0,0.6);
  animation: modalIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.confirm-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ef4444, #f97316, #ef4444);
  border-radius: 18px 18px 0 0;
}
.confirm-inner {
  padding: 28px 24px 20px;
  text-align: center;
}
.confirm-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.2);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  color: #f87171;
}
.confirm-title {
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.confirm-msg {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}
.confirm-actions {
  display: flex; gap: 10px;
}
.confirm-cancel {
  flex: 1; padding: 10px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.confirm-cancel:hover { background: var(--bg-hover); color: var(--text-primary); }
.confirm-ok {
  flex: 1; padding: 10px;
  border-radius: 10px;
  font-size: 13px; font-weight: 600;
  background: #ef4444;
  border: 1px solid rgba(248,113,113,0.4);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}
.confirm-ok:hover { background: #dc2626; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group select, .form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group select:focus, .form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ─── 侧边栏遮罩 (移动端) ─── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 49;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ─── 置信度标记 ─── */

.confidence-badge {
  font-size: 10px;
  color: var(--text-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  font-family: var(--font-mono);
  transition: opacity var(--transition);
}

/* ─── 中止按钮 ─── */

.abort-btn {
  color: var(--error) !important;
  border-color: var(--error) !important;
  animation: abortPulse 1.5s infinite;
  flex-shrink: 0;
  z-index: 10;
}

@keyframes abortPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ─── Token 用量 ─── */

.token-usage {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  padding: 4px 0;
}

/* ─── 对话条目计数 ─── */

.conv-count {
  font-size: 10px;
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
  margin-right: 4px;
  font-family: var(--font-mono);
}

/* ─── 实用类 ─── */

.hidden { display: none !important; }

/* ─── 响应式 ─── */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    height: 100%;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.collapsed { margin-left: -268px; }

  .message-user .message-content { max-width: 85%; }
  .quick-actions { flex-direction: row; flex-wrap: nowrap; align-items: center; overflow-x: auto; justify-content: flex-start; padding: 0 4px; }
  .quick-btn { text-align: center; padding: 4px 9px; font-size: 10.5px; }

  .messages { padding: 16px 12px; }
  .input-area { padding: 10px 12px 14px; }
}

@media (max-width: 480px) {
  .topbar-center .mode-badge { display: none; }
}

/* ─── UI 优化 ─── */

/* 改进按钮间距和对齐 */
.topbar-actions button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
}

/* 改进模态框响应式 */
.modal-content {
  max-width: 90vw;
  max-height: 90vh;
}

/* 改进消息区域间距 */
.message {
  margin-bottom: 12px;
}

.message-content {
  line-height: 1.6;
  word-wrap: break-word;
}

/* 改进输入框样式 */
#userInput {
  resize: none;
  max-height: 200px;
}

/* 改进快速按钮布局 — 已在上方定义，此处仅保留覆盖 */

/* 改进侧边栏对话列表 */
.conversation-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

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

/* 改进代码块样式 */
.message-content pre {
  border-radius: var(--radius-sm);
  overflow-x: auto;
  padding: 12px;
  margin: 8px 0;
}

.message-content code {
  font-size: 13px;
  line-height: 1.5;
}

/* 改进表格样式 */
.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 13px;
}

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

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

/* 改进列表样式 */
.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 24px;
}

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

/* 改进链接样式 */
.message-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  transition: all var(--transition);
}

.message-content a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* 改进引用块样式 */
.message-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  margin: 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* 改进分割线 */
/* 改进分割线 */
.message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* 改进图片样式 */
.message-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

/* 文件信息标签 */
.file-info-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-right: 4px;
  margin-bottom: 4px;
}

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

/* 移动端优化 */
@media (max-width: 768px) {
  .topbar-actions {
    gap: 4px;
  }
  
  .topbar-actions .btn-sm {
    padding: 4px 6px;
    font-size: 11px;
  }
  
  .model-selector {
    min-width: 70px;
    font-size: 11px;
    padding: 4px 6px;
  }
  
  .toggle-label {
    font-size: 11px;
  }
  
  .toggle-track {
    width: 30px;
    height: 16px;
  }
  
  .toggle-track::after {
    width: 12px;
    height: 12px;
    top: 1px;
    left: 1px;
  }
  
  .toggle-label input:checked + .toggle-track::after {
    left: 15px;
  }
  
  .modal-content {
    max-width: 95vw;
    margin: 8px;
  }
  
  .input-wrapper {
    padding: 4px 4px 4px 12px;
  }
  
  .btn-send {
    width: 32px;
    height: 32px;
    min-width: 32px;
  }

  .sidebar-footer > div {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .topbar {
    padding: 0 8px;
    gap: 6px;
  }
  
  .topbar-actions .model-selector {
    min-width: 60px;
    max-width: 80px;
  }

  .toggle-text {
    display: none;
  }
  
  .topbar-actions .model-quick-btn {
    padding: 2px 5px;
    font-size: 10px;
  }
  .topbar-actions #packBtn {
    display: none;
  }
  
  .welcome h2 {
    font-size: 21px;
  }

  .welcome-icon {
    font-size: 42px;
  }

  .quick-btn { padding: 4px 9px; font-size: 10px; }
  .quick-actions { gap: 5px; }
}

/* 消息内文件附件显示 */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

/* 文件标注 - 聊天气泡下方文件名 */
.msg-file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
  justify-content: flex-end;
}
.msg-file-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(102,126,234,0.15);
  color: var(--text-secondary);
  font-size: 10px;
  border: 1px solid rgba(102,126,234,0.25);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 命令方块行格式 — MC 指令独特UI系统 */
.cmd-block-line {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 3px 0;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.04);
  transition: all 0.15s ease;
  position: relative;
  background: rgba(0,0,0,0.2);
}
.cmd-block-line:hover {
  border-color: rgba(255,255,255,0.08);
  background: rgba(0,0,0,0.3);
}
.cmd-block-line:hover .cb-copy-btn { opacity: 1; }

.cmd-block-annotation {
  font-size: 0.68em;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  min-width: 74px;
  justify-content: center;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.cb-type-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
  flex-shrink: 0;
}

.cb-repeat {
  background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(109,40,217,0.15));
  color: #c4b5fd;
}
.cb-chain {
  background: linear-gradient(135deg, rgba(34,197,94,0.15), rgba(22,163,74,0.1));
  color: #6ee7b7;
}
.cb-impulse {
  background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(234,88,12,0.1));
  color: #fdba74;
}

.cmd-block-cmd {
  font-size: 0.83em;
  color: var(--text-primary);
  font-family: var(--font-mono);
  word-break: break-all;
  line-height: 1.5;
  flex: 1;
  padding: 6px 10px;
}

.cb-copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 13px;
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.05);
}
.cb-copy-btn:hover { color: var(--accent); background: var(--accent-dim); }

/* artifact 按钮 */
.artifact-btn {
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.artifact-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 快捷模型按钮 */
.model-quick-btn {
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.model-quick-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.model-quick-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

/* 打包文件列表 */
.pack-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  margin-bottom: 4px;
  cursor: pointer;
  background: var(--bg-input);
  transition: background 0.15s;
}
.pack-file-item:hover { background: var(--bg-hover); }
.pack-file-cb { flex-shrink: 0; }
.pack-file-name { flex: 1; font-size: 13px; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-file-size { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }

/* 附件图标 */
.att-icon { font-size: 14px; flex-shrink: 0; }

/* ═══ 输入区新UI ═══ */

.input-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 820px;
  margin: 0 auto 5px;
  gap: 8px;
}

.input-model-pills {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.input-model-pills::-webkit-scrollbar { display: none; }

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.model-pill:hover { background: var(--bg-hover); color: var(--text-secondary); border-color: var(--border-light); }
.model-pill.active {
  background: linear-gradient(135deg, rgba(137,180,250,0.15), rgba(203,166,247,0.1));
  color: var(--accent);
  border-color: rgba(137,180,250,0.45);
  box-shadow: 0 0 0 2px rgba(137,180,250,0.1), 0 1px 6px rgba(137,180,250,0.15);
}
.model-pill[data-model="craft"].active {
  background: rgba(243,139,168,0.12);
  color: #f38ba8;
  border-color: rgba(243,139,168,0.4);
  box-shadow: 0 0 0 2px rgba(243,139,168,0.08);
}

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

.input-status-chip {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* Mini toggle */
.toggle-label-mini {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  user-select: none;
}
.toggle-label-mini input { display: none; }
.toggle-track-mini {
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}
.toggle-track-mini::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  transition: all 0.2s;
}
.toggle-label-mini input:checked + .toggle-track-mini {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.toggle-label-mini input:checked + .toggle-track-mini::after {
  left: 14px;
  background: var(--accent);
}
.toggle-label-mini input:checked ~ span { color: var(--accent); }

/* Right side of input: stop + send stacked */
.input-right-btns {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

/* abort-btn in topbar */
.abort-btn.hidden { display: none !important; }
button.abort-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
}

/* Token usage inline below input */
.token-usage-inline {
  font-size: 11px;
  color: var(--text-tertiary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.token-usage-inline:hover { color: var(--text-secondary); }
.token-usage-inline.hidden { display: none; }

/* Cost detail panel (bottom sheet style) */
#costDetailPanel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 16px 20px 24px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 60vh;
  overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
}
#costDetailPanel.open { transform: translateY(0); }
.cost-panel-handle {
  width: 36px; height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 0 auto 14px;
}
.cost-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.cost-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cost-row:last-child { border-bottom: none; }
.cost-label { color: var(--text-secondary); }
.cost-value { color: var(--text-primary); font-weight: 500; font-family: var(--font-mono); }
.cost-total { color: var(--accent); font-size: 14px; font-weight: 600; }

@media (max-width: 768px) {
  .input-meta-bar { margin-bottom: 5px; }
  .model-pill { padding: 2px 8px; font-size: 10px; }
  .input-status-chip { display: none; }
}

/* Craft 模式颜色 */
.model-pill[data-model="craft"] { }
.model-pill[data-model="craft"].active { background: rgba(236,72,153,0.12); color: #f472b6; border-color: rgba(236,72,153,0.5); }
body.light-theme .model-pill[data-model="craft"].active { background: rgba(219,39,119,0.08); color: #db2777; border-color: rgba(219,39,119,0.4); }

/* 下载按钮 */
.copy-btn + .copy-btn {
  margin-left: 4px;
}

/* 欢迎屏幕新 logo 容器 */
.welcome-icon svg text { user-select: none; }

/* 知识库状态实时显示 */
.kb-live-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 600;
  background: rgba(52,211,153,0.1); color: var(--success);
  border: 1px solid rgba(52,211,153,0.2);
}

/* 输出格式优化 — 命令方块注释更明显 — 已在上方重定义，保留light覆盖 */
body.light-theme .cmd-block-line { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.06); }
body.light-theme .cmd-block-annotation { border-right-color: rgba(0,0,0,0.08); }

/* code-block-wrapper pre gets top padding for language label */
.code-block-wrapper pre {
  padding-top: 28px !important;
  background: #0d0d16 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  font-size: 12.5px !important;
  line-height: 1.6 !important;
}

/* ═══ MC 指令输出UI系统 ═══
   专为 Minecraft Bedrock 命令设计的输出容器
   ─────────────────────────────────────── */

/* 命令序列容器 — 多行命令块的父容器 */
.mc-cmd-sequence {
  border: 1px solid rgba(137,180,250,0.15);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 12px 0;
  background: rgba(0,0,0,0.25);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.mc-cmd-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: linear-gradient(135deg, rgba(137,180,250,0.08), rgba(203,166,247,0.05));
  border-bottom: 1px solid rgba(137,180,250,0.1);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mc-cmd-header-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}

.mc-cmd-count {
  margin-left: auto;
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 400;
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.mc-cmd-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* 单条命令: 更大的点击区域 + 一键复制 */
.mc-cmd-sequence .cmd-block-line {
  margin: 0;
  border-radius: 5px;
}

/* 命令统计栏 */
.mc-cmd-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 10px;
  border-top: 1px solid rgba(255,255,255,0.04);
  gap: 8px;
}

.mc-stat-badge {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 8px;
  font-family: var(--font-mono);
}

.mc-stat-badge.repeat { color: #c4b5fd; border-color: rgba(139,92,246,0.3); background: rgba(139,92,246,0.1); }
.mc-stat-badge.chain { color: #6ee7b7; border-color: rgba(34,197,94,0.25); background: rgba(34,197,94,0.08); }
.mc-stat-badge.impulse { color: #fdba74; border-color: rgba(249,115,22,0.25); background: rgba(249,115,22,0.08); }

/* 无序列容器时单行命令 */
.message-content .cmd-block-line + .cmd-block-line { margin-top: 2px; }

/* 输出代码块顶栏 */
.code-block-wrapper {
  position: relative;
}
.code-block-wrapper .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
}
.code-block-wrapper .copy-btn + .copy-btn {
  right: 56px;
  margin-left: 0;
}

/* ═══════════════════════════════════════
   v3.2 UI 升级样式
   ═══════════════════════════════════════ */

/* ── 流式打字光标 ── */
.stream-cursor {
  display: inline-block;
  animation: blink-cursor 0.8s step-end infinite;
  color: var(--accent);
  font-weight: 400;
  margin-left: 1px;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── 余额低预警 ── */
.balance-low {
  animation: balance-pulse 2s ease-in-out infinite;
}
.balance-zero {
  color: var(--error) !important;
  animation: balance-pulse 1s ease-in-out infinite;
}
@keyframes balance-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ── 欢迎卡片网格 ── */
.welcome-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin-top: 20px;
}
.welcome-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.welcome-card:hover {
  border-color: var(--border-focus);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.wc-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim);
  border-radius: 10px;
  color: var(--accent);
  margin-bottom: 6px;
}
.wc-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}
.wc-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

/* ── 模型速度标签 ── */
.pill-tag {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-left: 2px;
  vertical-align: middle;
}
.pill-fast {
  background: rgba(166, 227, 161, 0.15);
  color: var(--success);
}
.pill-slow {
  background: rgba(203, 166, 247, 0.15);
  color: var(--route-thinking);
}

/* ── 消息朗读按钮激活态 ── */
.msg-action-btn.speaking {
  color: var(--accent);
  animation: balance-pulse 1s ease-in-out infinite;
}

/* ── 移动端左滑删除 ── */
.conv-item {
  position: relative;
  overflow: hidden;
}
.conv-swipe-delete {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 72px;
  background: var(--error);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  cursor: pointer;
  flex-shrink: 0;
}
.conv-item.swipe-open .conv-swipe-delete {
  transform: translateX(0);
}
.conv-item.swipe-open > .conv-main,
.conv-item.swipe-open > .conv-meta {
  transform: translateX(-72px);
  transition: transform 0.22s ease;
}

/* ── 欢迎卡片移动端适配 ── */
@media (max-width: 600px) {
  .welcome-cards {
    grid-template-columns: repeat(2, 1fr);
    max-width: 340px;
  }
}
@media (max-width: 380px) {
  .welcome-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .wc-desc { display: none; }
}

/* ── 连接状态指示点 ── */
.conn-status {
  display: inline-flex; align-items: center; gap: 5px;
}
.conn-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.conn-native .conn-dot { background: var(--text-tertiary); }
.conn-warn .conn-dot { background: var(--warning); }
.conn-ok .conn-dot { background: var(--success); }
