/* ============================================================
    AI Chat 样式 — ChatGPT 风格：白底黑字、简洁高级、丝滑
   ============================================================ */

/* ==================== CSS 变量 ==================== */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-sidebar: #f9fafb;
  --bg-hover: #ececf1;
  --bg-user-bubble: #f0f0f0;
  --bg-ai-bubble: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #999999;
  --border-color: #e5e5e5;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --accent-light: #e8f0fe;
  --danger: #e53e3e;
  --danger-hover: #c53030;
  --success: #38a169;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 280px;
  --sidebar-collapsed: 0px;
  --topbar-height: 56px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ==================== 全局重置 ==================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==================== 布局 ==================== */
body {
  display: flex;
}

/* ---- 侧边栏 ---- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), min-width var(--transition);
  z-index: 100;
  overflow: hidden;
}
.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.sidebar-header {
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.btn-new-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-new-chat:hover {
  background: var(--bg-hover);
  border-color: #ccc;
}

.btn-toggle-sidebar {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-toggle-sidebar:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 侧边栏历史 */
.sidebar-history {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

.history-loading, .history-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.history-empty i {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.4;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.history-item:hover {
  background: var(--bg-hover);
}
.history-item.active {
  background: var(--accent-light);
}
.history-item.active .history-title {
  color: var(--accent);
  font-weight: 500;
}

.history-item-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.history-item-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.history-title {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.history-delete {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-item:hover .history-delete {
  opacity: 1;
}
.history-delete:hover {
  background: #fee2e2;
  color: var(--danger);
}

/* 侧边栏底部 */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
}

.user-info-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
}
.user-avatar-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 14px;
}

/* ---- 主区域 ---- */
.main-area {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ---- 顶部导航栏 ---- */
.top-bar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
  gap: 12px;
  flex-shrink: 0;
}

.top-bar-spacer { flex: 1; }

.btn-open-sidebar {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-open-sidebar:hover {
  background: var(--bg-hover);
}

/* 积分显示 */
.points-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--accent-light);
  border-radius: 20px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}

.btn-recharge {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all var(--transition);
  margin-left: 2px;
}
.btn-recharge:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
}

/* 用户下拉 */
.user-dropdown {
  position: relative;
}

.btn-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-user:hover {
  background: var(--bg-hover);
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
  animation: dropdownIn 0.15s ease-out;
}
.dropdown-menu.show { display: block; }

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: 12px 16px;
}
.dropdown-header p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.dropdown-item:hover {
  background: var(--bg-hover);
}

.btn-login {
  padding: 8px 20px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: #fff;
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-login:hover {
  background: var(--accent);
  color: #fff;
}

/* ==================== 模态框 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s ease;
  backdrop-filter: blur(2px);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  float: right;
  font-size: 28px;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

/* 登录/注册 Tab */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 3px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.auth-tab.active {
  background: #fff;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.auth-form h2 {
  font-size: 22px;
  margin-bottom: 4px;
  font-weight: 600;
}
.auth-subtitle {
  color: var(--text-tertiary);
  margin-bottom: 20px;
  font-size: 14px;
}
.auth-subtitle strong {
  color: var(--accent);
}

/* 表单 */
.input-group {
  margin-bottom: 16px;
}
.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: all var(--transition);
  outline: none;
  font-family: var(--font-sans);
}
.input-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

.code-row {
  display: flex;
  gap: 8px;
}
.code-row input {
  flex: 1;
}
.btn-send-code {
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-send-code:hover {
  background: var(--accent-light);
}
.btn-send-code:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,115,232,0.3);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-full { width: 100%; }

.auth-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef2f2;
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ==================== 充值模态框 ==================== */
.recharge-modal {
  max-width: 640px;
}

.recharge-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.plan-card {
  text-align: center;
  padding: 24px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}
.plan-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.plan-popular {
  border-color: var(--accent);
  background: var(--accent-light);
}

.plan-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  background: var(--bg-secondary);
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.plan-badge-hot {
  background: #fef3c7;
  color: #d97706;
}

.plan-card h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.plan-points {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.plan-points span {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.plan-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.btn-plan {
  width: 100%;
  padding: 10px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-plan:hover {
  background: var(--bg-hover);
}
.btn-plan-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-plan-primary:hover {
  background: var(--accent-hover);
}

/* ==================== 聊天容器 ==================== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 欢迎页 */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 20px;
}

.chat-welcome h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.welcome-logo {
  margin-bottom: 8px;
}

.model-select-welcome {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.model-select-welcome label {
  font-size: 14px;
  color: var(--text-secondary);
}
.model-select-welcome select {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  cursor: pointer;
  outline: none;
  font-family: var(--font-sans);
}
.model-select-welcome select:focus {
  border-color: var(--accent);
}

/* 消息列表 */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  scroll-behavior: smooth;
}

/* 消息行 */
.message-row {
  display: flex;
  padding: 16px 40px;
  gap: 16px;
  transition: background var(--transition);
}
.message-row:hover {
  background: #fafafa;
}
.message-row.assistant {
  background: var(--bg-secondary);
}
.message-row.assistant:hover {
  background: #f3f3f4;
}

.message-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}
.message-avatar.user {
  background: var(--accent);
  color: #fff;
}
.message-avatar.assistant {
  background: #10a37f;
  color: #fff;
}

.message-body {
  flex: 1;
  min-width: 0;
}

.message-role {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.message-content {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-primary);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.message-content p { margin-bottom: 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content code {
  background: #f1f1f1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.message-content pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 10px 0;
  font-size: 13px;
  line-height: 1.5;
}
.message-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* 思考过程折叠 */
.thinking-toggle {
  margin-top: 6px;
}
.thinking-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.thinking-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.thinking-toggle-btn i {
  transition: transform var(--transition);
}
.thinking-toggle-btn.open i {
  transform: rotate(180deg);
}

.thinking-content {
  display: none;
  margin-top: 8px;
  padding: 12px 16px;
  background: #fffbe6;
  border: 1px solid #f0e5b0;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #7c6f3c;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 300px;
  overflow-y: auto;
}
.thinking-content.show {
  display: block;
}

/* 模型标签 */
.model-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
  margin-left: 8px;
  vertical-align: middle;
}

/* 流式输出光标 */
.streaming-cursor::after {
  content: '▋';
  animation: blink 1s step-end infinite;
  color: var(--accent);
}
@keyframes blink {
  50% { opacity: 0; }
}

/* ==================== 底部输入区（常驻） ==================== */
.chat-input-area {
  padding: 12px 40px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-primary);
  flex-shrink: 0;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 8px;
  background: var(--accent-light);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--accent);
  animation: fadeIn 0.2s ease;
}
.file-preview button {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.file-preview button:hover {
  background: rgba(26,115,232,0.15);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.08);
}

.btn-upload {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font-size: 17px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
}
.btn-upload:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.model-select-inline {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
  font-family: var(--font-sans);
  max-width: 130px;
  margin-bottom: 2px;
}
.model-select-inline:focus {
  border-color: var(--accent);
}

.message-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-primary);
  background: transparent;
  resize: none;
  max-height: 200px;
  min-height: 24px;
  line-height: 1.5;
  font-family: var(--font-sans);
  padding: 5px 4px;
}
.message-input::placeholder {
  color: var(--text-tertiary);
}

.btn-send {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
}
.btn-send:hover {
  background: var(--accent-hover);
  transform: scale(1.05);
}
.btn-send:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

.input-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
}

/* ==================== 确认对话框 ==================== */
.confirm-modal {
  max-width: 380px;
  text-align: center;
}
.confirm-modal h3 {
  font-size: 18px;
  margin-bottom: 8px;
}
.confirm-modal p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}
.confirm-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.btn-cancel {
  padding: 10px 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-cancel:hover { background: var(--bg-hover); }
.btn-danger {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--danger);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover { background: var(--danger-hover); }

/* ==================== Toast ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  color: var(--text-primary);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ==================== 加载动画 ==================== */
.typing-dots {
  display: inline-flex;
  gap: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ==================== 滚动条 ==================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================================
   响应式 —— 手机端适配
   ============================================================ */

/* 平板及以下（≤1024px） */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 200;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.collapsed {
    left: -280px;
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
  }
  .sidebar.collapsed .sidebar-expanded-text,
  .sidebar.collapsed .sidebar-history,
  .sidebar.collapsed .sidebar-footer {
    visibility: hidden;
    opacity: 0;
  }
  .sidebar.collapsed .sidebar-header {
    border-bottom: none;
  }

  .message-row {
    padding: 14px 20px;
    gap: 12px;
  }
  .chat-input-area {
    padding: 10px 16px 14px;
  }
  .recharge-plans {
    grid-template-columns: 1fr;
  }
}

/* 手机端（≤640px） */
@media (max-width: 640px) {
  :root {
    --topbar-height: 48px;
    font-size: 14px;
  }

  /* 顶部栏 */
  .top-bar {
    padding: 0 10px;
    gap: 8px;
  }

  .btn-open-sidebar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .points-display {
    padding: 4px 10px;
    font-size: 12px;
    gap: 4px;
  }

  .btn-recharge {
    width: 18px;
    height: 18px;
    font-size: 12px;
  }

  .btn-user {
    padding: 6px 8px;
    font-size: 13px;
    gap: 4px;
  }
  .btn-user span:last-child {
    display: none; /* 隐藏下拉箭头文字节省空间 */
  }

  .btn-login {
    padding: 6px 14px;
    font-size: 13px;
  }

  .dropdown-menu {
    width: 200px;
    right: -10px;
  }

  /* 侧边栏 */
  .sidebar {
    width: 260px;
    min-width: 260px;
  }
  .sidebar.collapsed {
    left: -260px;
    width: 260px;
    min-width: 260px;
  }

  /* 欢迎页 */
  .chat-welcome {
    padding: 24px 16px;
    gap: 12px;
  }
  .chat-welcome h1 {
    font-size: 20px;
    text-align: center;
  }
  .welcome-logo svg {
    width: 48px;
    height: 48px;
  }
  .model-select-welcome {
    flex-direction: column;
    width: 100%;
  }
  .model-select-welcome select {
    width: 100%;
    max-width: 280px;
  }

  /* 消息 */
  .chat-messages {
    padding: 12px 0;
  }
  .message-row {
    padding: 12px 12px;
    gap: 10px;
  }
  .message-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 12px;
  }
  .message-role {
    font-size: 12px;
  }
  .message-content {
    font-size: 14px;
    line-height: 1.65;
  }
  .message-content pre {
    padding: 12px;
    font-size: 12px;
    margin: 8px -8px;
    border-radius: var(--radius-sm);
  }

  /* 输入区 */
  .chat-input-area {
    padding: 8px 10px 12px;
  }

  .input-row {
    padding: 5px 8px;
    gap: 4px;
    border-radius: var(--radius-md);
  }

  .btn-upload {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  /* 移动端隐藏模型下拉，减少拥挤 */
  .model-select-inline {
    display: none;
  }

  .message-input {
    font-size: 14px;
    padding: 4px 2px;
  }

  .btn-send {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 14px;
  }

  .file-preview {
    padding: 6px 10px;
    font-size: 12px;
    margin-bottom: 6px;
  }

  .input-disclaimer {
    font-size: 10px;
    margin-top: 6px;
  }

  /* 模态框 */
  .modal-box {
    padding: 24px 20px;
    width: 94%;
    max-width: 100%;
    border-radius: var(--radius-md);
  }

  .auth-tabs {
    margin-bottom: 16px;
  }
  .auth-form h2 {
    font-size: 20px;
  }
  .auth-subtitle {
    font-size: 13px;
    margin-bottom: 16px;
  }
  .input-group {
    margin-bottom: 12px;
  }

  /* 充值 */
  .recharge-modal {
    max-width: 100%;
  }
  .recharge-plans {
    gap: 8px;
  }
  .plan-card {
    padding: 18px 12px;
  }
  .plan-card h3 {
    font-size: 18px;
  }
  .plan-points {
    font-size: 20px;
  }
  .plan-price {
    font-size: 24px;
  }

  /* toast */
  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }
  .toast {
    max-width: 100%;
    font-size: 13px;
    padding: 10px 14px;
  }
}