/* ============================================================
   陈伦编程 AI 辅导平台 - 全局样式
   ============================================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --primary: #4f7cff;
  --primary-dark: #3a63db;
  --primary-light: #e8edff;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f6f8fc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 280px;
  --header-h: 56px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --font: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
}

/* ---------- 页面进度条 ---------- */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #4f7cff, #667eea, #764ba2);
  z-index: 99999;
  transition: width 0.3s ease;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(79,124,255,0.5);
}
.page-loader.done {
  width: 100%;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.25s ease 0.15s;
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }
img { max-width: 100%; }

/* ============================================================
   登录/注册页
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.auth-logo {
  text-align: center;
  margin-bottom: 30px;
}
.auth-logo .icon { font-size: 48px; display: block; }
.auth-logo h1 { font-size: 24px; font-weight: 700; margin-top: 8px; color: #1e293b; }
.auth-logo p { color: #64748b; font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: #475569; }
.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 15px;
  transition: border-color .2s;
  outline: none;
}
.form-group input:focus { border-color: var(--primary); }
.form-group .hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: all .2s;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-full { width: 100%; padding: 14px; font-size: 16px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.auth-toggle { text-align: center; margin-top: 20px; color: #64748b; font-size: 14px; }
.auth-toggle a { font-weight: 600; }

.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
}
.toast.success { background: #dcfce7; color: #166534; }
.toast.error   { background: #fee2e2; color: #991b1b; }
.toast.info    { background: #dbeafe; color: #1e40af; }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ============================================================
   主布局（对话页）
   ============================================================ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .3s;
}
.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo { font-size: 22px; font-weight: 800; color: #fff; }
.sidebar-logo .badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
}

.btn-new-chat {
  margin: 12px 16px;
  background: rgba(79,124,255,.2);
  border: 1px dashed rgba(79,124,255,.5);
  color: #93c5fd;
  border-radius: var(--radius-sm);
  padding: 10px;
  width: calc(100% - 32px);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.btn-new-chat:hover { background: rgba(79,124,255,.35); border-color: #4f7cff; color: #fff; }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }

.history-section-title {
  font-size: 11px;
  color: #64748b;
  padding: 8px 12px 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.history-item {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  group: true;
}
.history-item:hover { background: rgba(255,255,255,.06); }
.history-item.active { background: rgba(79,124,255,.25); }
.history-item .icon { font-size: 14px; flex-shrink: 0; opacity: .7; }
.history-item .title {
  flex: 1;
  font-size: 13px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}
.history-item .del-btn {
  display: none;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.history-item:hover .del-btn { display: block; }
.history-item .del-btn:hover { color: var(--danger); }

/* 标签徽章 */
.item-tags { display: flex; flex-wrap: wrap; gap: 3px; padding: 0 12px 6px 36px; }
.item-tag {
  display: inline-block; padding: 1px 6px; border-radius: 10px;
  font-size: 10px; background: rgba(99,102,241,.15); color: #818cf8;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.item-tag:hover { background: rgba(99,102,241,.3); }
.item-tag.active { background: #6366f1; color: #fff; }

/* 标签编辑弹窗 */
.tag-edit-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999;
  display: flex; align-items: center; justify-content: center;
}
.tag-edit-panel {
  background: #1e293b; border: 1px solid rgba(255,255,255,.1); border-radius: 12px;
  padding: 24px; width: 400px; max-width: 90vw; color: #e2e8f0;
}
.tag-edit-panel h3 { font-size: 16px; margin-bottom: 16px; }
.tag-edit-input-row { margin-bottom: 12px; }
.tag-edit-input-row input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.1);
  background: #0f172a; color: #e2e8f0; font-size: 13px; outline: none;
}
.tag-edit-input-row input:focus { border-color: #6366f1; }
.tag-edit-current { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; min-height: 24px; align-items: center; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 12px;
  font-size: 11px; background: rgba(99,102,241,.2); color: #a5b4fc;
}
.tag-chip .tag-remove { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; }
.tag-chip .tag-remove:hover { color: #ef4444; }
.tag-chip.preset { cursor: pointer; transition: background .15s; }
.tag-chip.preset:hover { background: rgba(99,102,241,.3); }
.tag-chip.preset.used { background: rgba(99,102,241,.4); color: #c7d2fe; }
.tag-edit-presets { margin-bottom: 16px; }
.tag-edit-presets > div { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tag-edit-actions .btn { padding: 6px 16px; border-radius: 8px; font-size: 13px; border: none; cursor: pointer; }
.tag-edit-actions .btn-cancel { background: transparent; color: #94a3b8; border: 1px solid rgba(255,255,255,.1); }
.tag-edit-actions .btn-save { background: #6366f1; color: #fff; }

/* 标签筛选提示 */
.tag-filter-bar {
  padding: 6px 16px; font-size: 12px; background: rgba(99,102,241,.1); color: #a5b4fc;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 10px 16px 12px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-name { font-size: 14px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: #64748b; }

/* 快捷链接行：📝 📊 + 🌙 主题切换 */
.sidebar-quick-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  color: #94a3b8; text-decoration: none; font-size: 15px;
  transition: background .2s, color .2s;
  background: none; border: none; outline: none; cursor: pointer;
  padding: 0;
}
.sidebar-link:hover { background: rgba(255,255,255,.1); color: #e2e8f0; }
.sidebar-link:focus { outline: none; }
.sidebar-link:focus-visible { outline: 2px solid rgba(99,102,241,.5); outline-offset: 2px; }

/* ---------- 主内容区 ---------- */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 聊天头部 ---------- */
.chat-header {
  height: var(--header-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.chat-header .session-title {
  font-weight: 700;
  font-size: 16px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.style-selector {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.style-btn {
  padding: 5px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.style-btn.active { background: var(--primary); color: #fff; }
.style-btn:hover:not(.active) { background: #e2e8f0; }

/* ---------- 问题输入区 ---------- */
.problem-area {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: none;
}
.problem-area.show { display: block; }
.problem-area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.problem-area-header h3 { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.problem-textarea {
  width: 100%;
  min-height: 80px;
  max-height: 200px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  resize: vertical;
  outline: none;
  font-family: var(--font);
  background: var(--bg);
  transition: border-color .2s;
}
.problem-textarea:focus { border-color: var(--primary); }

/* ---------- 消息列表 ---------- */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.messages-area::-webkit-scrollbar { width: 6px; }
.messages-area::-webkit-scrollbar-thumb { background: #ddd; border-radius: 6px; }

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px;
}
.welcome-screen .icon { font-size: 64px; margin-bottom: 16px; }
.welcome-screen h2 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.welcome-screen p { color: var(--text-muted); font-size: 15px; margin-bottom: 24px; }
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.quick-action-btn {
  padding: 10px 18px;
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.quick-action-btn:hover { background: var(--primary); color: #fff; }

/* 消息气泡 */
.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 900px;
}
.message.user { flex-direction: row-reverse; align-self: flex-end; max-width: 75%; }
.message.assistant { align-self: flex-start; max-width: 900px; }

.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.message.user .msg-avatar { background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; }
.message.assistant .msg-avatar { background: #f1f5f9; }

.msg-body { max-width: calc(100% - 50px); }
.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: break-word;
  word-break: keep-all;
}
.message.user .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.message.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}
.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}
.message.user .msg-time { text-align: right; }

/* Markdown 样式 */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin: 10px 0 6px;
  font-size: 1em;
  font-weight: 700;
}
.msg-bubble p { margin: 6px 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble code {
  background: rgba(0,0,0,.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Consolas', 'Monaco', monospace;
}
.message.user .msg-bubble code { background: rgba(255,255,255,.2); }
.msg-bubble pre {
  background: #1e293b;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}
.msg-bubble pre code { background: transparent; color: inherit; padding: 0; white-space: pre; }

/* 思考泡泡 */
.thinking-bubble {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: #9a3412;
  margin-bottom: 8px;
  display: none;
}
.thinking-bubble.show { display: block; }
.thinking-bubble summary { cursor: pointer; font-weight: 600; }

/* 打字光标 */
.typing-cursor::after {
  content: '▋';
  animation: blink .8s infinite;
  opacity: 1;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* 消息图片 */
.msg-image { max-width: 240px; border-radius: 8px; margin-top: 6px; cursor: pointer; }

/* 消息图片预览 */
.img-preview-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  display: none;
}
.img-preview-modal img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ---------- 输入区 ---------- */
.input-area {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  flex-shrink: 0;
}
.input-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.toolbar-btn {
  background: none;
  border: none;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: all .2s;
}
.toolbar-btn:hover { background: var(--bg); color: var(--text); }
.problem-toggle-btn.active { color: var(--primary); background: var(--primary-light); }

.input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.msg-input {
  flex: 1;
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 150px;
  font-family: var(--font);
  line-height: 1.5;
  transition: border-color .2s;
}
.msg-input:focus { border-color: var(--primary); }

.send-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .2s;
}
.send-btn:hover { background: var(--primary-dark); }
.send-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

/* 图片预览区 */
.image-preview-area { display: none; margin-bottom: 8px; }
.image-preview-area.show { display: flex; align-items: center; gap: 8px; }
.image-preview-area img { height: 60px; border-radius: 6px; }
.image-preview-area .remove-img { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; }

/* 字符计数 */
.input-hints { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.char-count { font-size: 11px; color: var(--text-muted); }
.hint-text { font-size: 11px; color: var(--text-muted); }

/* ---------- 设置面板 ---------- */
.settings-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 360px;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transform: translateX(100%);
  transition: transform .3s ease;
  z-index: 100;
  overflow-y: auto;
}
.settings-panel.open { transform: translateX(0); }
.settings-panel h2 { font-size: 18px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; }
.settings-panel h2 button { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 12px; }

.api-mode-group { display: flex; gap: 8px; margin-bottom: 12px; }
.api-mode-btn {
  flex: 1; padding: 8px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); background: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transition: all .2s;
}
.api-mode-btn.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.settings-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; outline: none; margin-bottom: 8px;
  transition: border-color .2s;
}
.settings-input:focus { border-color: var(--primary); }

/* ---------- 加载状态 ---------- */
.loading-dots { display: inline-flex; gap: 4px; align-items: center; }
.loading-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted);
  animation: dotBounce 1.2s ease infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.8); opacity: .5; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -var(--sidebar-w); z-index: 200; height: 100vh; transition: left .3s; }
  .sidebar.open { left: 0; }
  .settings-panel { width: 100%; }
}

/* ============================================================
   自定义滚动条（全局）
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }
.dark ::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ============================================================
   消息入场动画
   ============================================================ */
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message { animation: msgSlideIn .35s ease; }
.message.no-anim { animation: none; }

/* ============================================================
   代码块一键复制按钮
   ============================================================ */
.msg-bubble pre {
  position: relative;
}
.msg-bubble pre .code-copy-btn {
  position: absolute; top: 6px; right: 8px;
  background: rgba(255,255,255,.1); border: none;
  color: #94a3b8; border-radius: 4px; padding: 3px 8px;
  font-size: 11px; cursor: pointer; opacity: 0;
  transition: all .2s; font-family: var(--font); line-height: 1.5;
}
.msg-bubble pre:hover .code-copy-btn { opacity: 1; }
.msg-bubble pre .code-copy-btn:hover { background: rgba(255,255,255,.2); color: #fff; }
.msg-bubble pre .code-copy-btn.copied { background: var(--success); color: #fff; opacity: 1; }

/* ============================================================
   回到底部浮动按钮
   ============================================================ */
.scroll-bottom-btn {
  position: fixed; bottom: 110px; right: 28px;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  box-shadow: 0 4px 16px rgba(79,124,255,.45);
  cursor: pointer; display: none; z-index: 50;
  font-size: 18px; align-items: center; justify-content: center;
  transition: all .25s; animation: fadeInUp .3s ease;
}
.scroll-bottom-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(79,124,255,.55); }
.scroll-bottom-btn.show { display: flex; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   AI 回复操作区（评价 + 重新生成）
   ============================================================ */
.msg-actions {
  display: flex; gap: 6px; margin-top: 4px; padding: 0 4px;
}
.msg-actions button {
  background: none; border: none; cursor: pointer;
  font-size: 13px; padding: 2px 6px; border-radius: 4px;
  color: var(--text-muted); transition: all .15s;
}
.msg-actions button:hover { background: var(--bg); color: var(--text); }
.msg-actions button.active { color: var(--primary); }
.msg-actions button.feedback-thanks { color: var(--success); pointer-events: none; }
.dark .msg-actions button:hover { background: rgba(255,255,255,.06); }

/* ============================================================
   停止生成按钮
   ============================================================ */
.stop-btn {
  position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--danger); padding: 6px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow); z-index: 20; display: none;
  transition: all .15s;
}
.stop-btn.show { display: flex; align-items: center; gap: 6px; }
.stop-btn:hover { background: #fef2f2; }

/* ============================================================
   快捷键面板
   ============================================================ */
.shortcut-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 999; display: none; align-items: center; justify-content: center;
}
.shortcut-overlay.show { display: flex; }
.shortcut-panel {
  background: var(--bg-card); border-radius: 16px; padding: 28px 32px;
  max-width: 420px; width: 90%; box-shadow: var(--shadow-lg);
  animation: modalPop .25s ease;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(.95); }
  to   { opacity: 1; transform: scale(1); }
}
.shortcut-panel h2 { font-size: 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.shortcut-list { display: flex; flex-direction: column; gap: 10px; }
.shortcut-item { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.shortcut-item .desc { color: var(--text); }
.shortcut-item .keys { display: flex; gap: 4px; }
.shortcut-item kbd {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 7px; font-size: 11px;
  font-family: 'Consolas', monospace; color: var(--text-muted);
}
.shortcut-close {
  margin-top: 16px; width: 100%; padding: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: 13px;
  color: var(--text-muted); transition: all .15s;
}
.shortcut-close:hover { background: var(--border); }

/* ============================================================
   对话导出按钮
   ============================================================ */
.export-btn {
  background: none; border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  color: var(--text-muted); cursor: pointer; transition: all .15s;
}
.export-btn:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   置顶对话样式
   ============================================================ */
.history-item.pinned { background: rgba(79,124,255,.08); border-left: 2px solid var(--primary); }
.history-item .pin-btn {
  display: none; background: none; border: none; color: #94a3b8;
  font-size: 11px; cursor: pointer; padding: 1px 4px; border-radius: 3px;
}
.history-item:hover .pin-btn { display: block; }
.history-item.pinned .pin-btn { color: var(--primary); display: block; }

.history-item .tag-btn {
  display: none; position: absolute; right: 48px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 12px; padding: 2px 4px;
}
.history-item:hover .tag-btn { display: block; }
.history-item .tag-btn:hover { opacity: .8; }

/* ============================================================
   网络断线提示
   ============================================================ */
.connection-banner {
  position: fixed; top: 3px; left: 50%; transform: translateX(-50%);
  background: var(--danger); color: #fff; padding: 6px 20px;
  border-radius: 0 0 10px 10px; font-size: 12px; font-weight: 600;
  z-index: 9999; display: none; box-shadow: 0 2px 8px rgba(239,68,68,.4);
}
.connection-banner.show { display: block; animation: slideDown .3s ease; }
@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ============================================================
   友好错误页
   ============================================================ */
.error-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); text-align: center; padding: 20px;
}
.error-card {
  background: var(--bg-card); border-radius: 20px; padding: 48px;
  max-width: 480px; box-shadow: var(--shadow); animation: modalPop .3s ease;
}
.error-card .error-icon { font-size: 64px; margin-bottom: 16px; }
.error-card h1 { font-size: 28px; margin-bottom: 8px; }
.error-card p { color: var(--text-muted); margin-bottom: 24px; font-size: 15px; }
.error-card a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 24px; background: var(--primary); color: #fff;
  border-radius: 10px; text-decoration: none; font-weight: 600;
}
.error-card a:hover { text-decoration: none; background: var(--primary-dark); }

/* ============================================================
   头像上传
   ============================================================ */
.avatar-upload { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.avatar-upload:hover .avatar-overlay { opacity: 1; }
.avatar-preview {
  width: 60px; height: 60px; border-radius: 50%; position: relative;
  overflow: hidden; flex-shrink: 0;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; opacity: 0; transition: opacity .2s;
  color: #fff; font-size: 13px;
}

/* ============================================================
   深色模式
   ============================================================ */
body.dark {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 2px 12px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
  --primary-light: rgba(79,124,255,.15);
  color-scheme: dark;
}
body.dark .chat-header { background: var(--bg-card); border-color: var(--border); }
body.dark .input-area { background: var(--bg-card); border-color: var(--border); }
body.dark .problem-area { background: var(--bg-card); border-color: var(--border); }
body.dark .problem-textarea { background: #0f172a; color: #e2e8f0; }
body.dark .msg-input { background: #0f172a; color: #e2e8f0; border-color: var(--border); }
body.dark .message.assistant .msg-bubble { background: var(--bg-card); border-color: var(--border); }
body.dark .style-selector { background: #0f172a; }
body.dark .style-btn:hover:not(.active) { background: rgba(255,255,255,.08); }
body.dark .quick-action-btn { background: rgba(79,124,255,.15); }
body.dark .quick-action-btn:hover { background: var(--primary); }
body.dark .settings-panel { background: var(--bg-card); }
body.dark .settings-input { background: #0f172a; color: #e2e8f0; border-color: var(--border); }
body.dark .btn-secondary { background: rgba(255,255,255,.06); color: #94a3b8; }
body.dark .btn-secondary:hover { background: rgba(255,255,255,.12); }
body.dark .toolbar-btn:hover { background: rgba(255,255,255,.06); }
body.dark .thinking-bubble { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.3); color: #fbbf24; }
body.dark .auth-card { background: var(--bg-card); }
body.dark .auth-logo h1 { color: #e2e8f0; }
body.dark .form-group input { background: #0f172a; color: #e2e8f0; border-color: var(--border); }
body.dark .site-header { background: var(--bg-card); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
body.dark .site-header nav a { color: #94a3b8; }
body.dark .site-header nav a:hover { background: rgba(255,255,255,.06); }
body.dark .site-header nav a.active { background: var(--primary); color: #fff; }
body.dark .error-page { background: var(--bg); }
body.dark .error-card { background: var(--bg-card); }
body.dark .shortcut-panel { background: var(--bg-card); }
body.dark .shortcut-item kbd { background: rgba(255,255,255,.06); border-color: var(--border); }
body.dark .stop-btn { background: var(--bg-card); border-color: var(--border); }
body.dark .stop-btn:hover { background: rgba(239,68,68,.1); }
body.dark .export-btn { border-color: var(--border); }
body.dark .export-btn:hover { background: rgba(255,255,255,.06); }
body.dark .history-item:hover { background: rgba(255,255,255,.04); }
body.dark .history-item.active { background: rgba(79,124,255,.2); }

/* 深色模式切换按钮 */
body.dark .sidebar-link { color: #64748b; }
body.dark .sidebar-link:hover { color: #e2e8f0; background: rgba(255,255,255,.1); }
