/* ─────────────────────────────────────────────
   语音情绪对话平台 · DeepSeek 风格设计系统
   零构建，仅依赖 CSS 变量 + 原生选择器
   ───────────────────────────────────────────── */

:root {
  /* 主品牌色：DeepSeek 靛蓝 */
  --accent: #4d6bfe;
  --accent-d: #3d57d9;
  --accent-rgb: 77, 107, 254;          /* RGB 派生: rgba(var(--accent-rgb), a) 让所有 accent 透明色自动跟主题切换 */
  --accent-soft: rgba(var(--accent-rgb), 0.12);
  --accent-soft-2: rgba(var(--accent-rgb), 0.06);

  /* 浅色模式：冷白 + 极浅灰 */
  --bg: #fafafa;
  --surface: #ffffff;
  --panel: #f4f4f6;
  --panel-2: #eaeaec;
  --panel-3: #e4e4e7;

  --text: #111113;
  --text-2: #6e6e7c;
  --text-3: #9e9ea8;
  --text-inverse: #ffffff;

  --border: #e8e8ec;
  --border-2: #d5d5db;
  --border-3: #c0c0c8;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);

  --user-bubble: #eff0f3;
  --asst-bubble: transparent;

  /* 圆角体系 */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  /* 侧边栏：深色（DeepSeek 式，与模式无关） */
  --side: #18181b;
  --side-2: #232327;
  --side-3: #2c2c31;
  --side-text: #f4f4f5;
  --side-dim: #9fa0a8;

  /* 状态色 */
  --danger: #ef4444;
  --danger-rgb: 239, 68, 68;
  --danger-soft: rgba(var(--danger-rgb), 0.12);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --success: #22c55e;

  /* 等宽字体 (代码/数字) — 统一, 改一处全站跟随 */
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  /* 深色模式：深邃背景 */
  --accent: #5c7cff;
  --accent-d: #7a94ff;
  --accent-rgb: 92, 124, 255;          /* dark 覆盖: rgba(var(--accent-rgb), a) 自动切深色 accent, 无需手写覆盖块 */
  --accent-soft: rgba(var(--accent-rgb), 0.16);
  --accent-soft-2: rgba(var(--accent-rgb), 0.08);

  --bg: #0d0d0e;
  --surface: #171717;
  --panel: #1f1f22;
  --panel-2: #27272b;
  --panel-3: #303036;

  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --text-inverse: #000000;

  --border: #27272b;
  --border-2: #303036;
  --border-3: #3f3f46;

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.35), 0 4px 8px rgba(0, 0, 0, 0.25);

  --user-bubble: #27272b;
  --asst-bubble: transparent;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .2s ease, color .2s ease;
}

::selection { background: var(--accent-soft); color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-3); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ───────── 动画 ───────── */
@keyframes popIn {
  0% { opacity: 0; transform: translateY(10px) scale(0.985); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
@keyframes stream-blink {
  50% { opacity: 0; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ───────── 布局 ───────── */
.app { display: flex; height: 100vh; }

/* ───────── 侧边栏 ───────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--side);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 16px;
}
.brand .logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.brand b {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: .2px;
  color: var(--side-text);
}

.new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: transparent;
  color: var(--side-text);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
}
.new-chat:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
}
.new-chat:active { transform: translateY(1px); }
.new-chat .plus { font-size: 16px; line-height: 1; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  margin: 10px -4px 0;
  padding: 0 4px;
  min-height: 0;
}

.chat-group-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--side-dim);
  padding: 12px 10px 4px;
  letter-spacing: .4px;
  text-transform: uppercase;
  opacity: .85;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--side-dim);
  font-size: 13px;
  transition: background .12s, color .12s;
  position: relative;
  overflow: hidden;
}
.chat-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  opacity: 0;
  transition: opacity .12s;
}
.chat-item:hover {
  background: var(--side-2);
  color: var(--side-text);
}
.chat-item.on {
  background: var(--side-2);
  color: var(--side-text);
}
.chat-item.on::before { opacity: 1; }
.chat-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-ren,
.chat-del {
  border: none;
  background: transparent;
  color: var(--side-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: var(--radius-xs);
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s;
  flex-shrink: 0;
}
.chat-item:hover .chat-ren,
.chat-item:focus-within .chat-ren,
.chat-item:hover .chat-del,
.chat-item:focus-within .chat-del { opacity: .65; }
.chat-ren:hover,
.chat-del:hover {
  opacity: 1 !important;
  color: var(--side-text);
  background: rgba(255,255,255,0.08);
}
.chat-del:hover { color: #ff6b6b; }

.quota {
  font-size: 11px;
  color: var(--side-dim);
  padding: 0 8px 10px;
  line-height: 1.5;
}
.quota b { color: var(--side-text); font-weight: 600; }

.side-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  color: var(--side-dim);
  font-size: 13px;
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, color .12s;
  border: none;
  background: transparent;
  width: 100%;
  font: inherit;
  text-align: left;
  margin: 1px 0;
}
.side-link:hover {
  background: var(--side-2);
  color: var(--side-text);
}
.side-link.on {
  color: var(--side-text);
  background: var(--side-2);
}
.side-link .icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.side-bottom {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.theme-toggle { margin-bottom: 4px; }

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background .12s;
}
.user-box:hover { background: var(--side-2); }
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-box .name {
  font-size: 13px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--side-text);
  font-weight: 500;
}
.user-box .logout {
  width: auto;
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

/* ───────── 主区域 ───────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
  position: relative;
}

/* ───────── 消息区 ───────── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 12px;
  position: relative;
}
.messages-inner { max-width: 768px; margin: 0 auto; }

.row {
  display: flex;
  margin: 24px 0;
  animation: popIn .28s cubic-bezier(.2,.8,.2,1);
}
.row.user,
.row.asr { justify-content: flex-end; }
.row.asst { justify-content: flex-start; align-items: flex-start; gap: 12px; }
.row.sys { justify-content: center; }

.avatar.asst-av {
  width: 28px;
  height: 28px;
  font-size: 14px;
  background: var(--panel-2);
  color: var(--text-2);
  flex-shrink: 0;
  border-radius: 50%;
}
.asst-body { flex: 1; min-width: 0; }
.asst-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 6px;
}

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  transition: background .2s, color .2s;
}
.row.user .bubble {
  background: var(--user-bubble);
  color: var(--text);
  border-bottom-right-radius: 5px;
}
.row.asst .bubble {
  background: var(--asst-bubble);
  border: none;
  box-shadow: none;
  border-radius: 0;
  max-width: 100%;
  padding: 0;
  white-space: normal;
  color: var(--text);
}
.asr-txt {
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
  max-width: 78%;
}
.sys-txt {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}
.audio-row { display: flex; justify-content: flex-start; margin: -6px 0 22px; }
.audio-row audio { max-width: 78%; border-radius: var(--radius-md); }

/* ───────── 输入区 ───────── */
.composer-wrap { padding: 8px 20px 22px; }

.composer-wrap.centered {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 20px 10vh;
}
.composer-wrap.centered .composer {
  width: 100%;
  max-width: 760px;
}

.welcome-stage {
  text-align: center;
  max-width: 640px;
  margin: 0 0 32px;
  animation: fadeIn .4s ease;
}
.welcome-stage h1 {
  font-size: 34px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--text) 0%, var(--accent) 110%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-stage p {
  font-size: 16px;
  color: var(--text-3);
  margin: 0;
}
.welcome-stage .suggest {
  margin-top: 28px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.welcome-stage .chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: transform .12s, border-color .15s, color .15s, background .15s;
  box-shadow: var(--shadow);
}
.welcome-stage .chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft-2);
  transform: translateY(-1px);
}

.composer {
  max-width: 768px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 12px 16px 12px;
  box-shadow: var(--shadow-md);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.composer:focus-within {
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 2px 24px rgba(var(--accent-rgb), 0.1), var(--shadow-md);
}
html[data-theme="dark"] .composer:focus-within {
  box-shadow: 0 2px 28px rgba(var(--accent-rgb), 0.16), var(--shadow-md);
}
.composer textarea {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  max-height: 180px;
  padding: 6px 2px;
  background: transparent;
  color: var(--text);
}
.composer textarea::placeholder { color: var(--text-3); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.mic,
.think-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.mic:hover,
.think-btn:hover {
  background: var(--panel);
  color: var(--text);
  transform: translateY(-1px);
}
.mic:active,
.think-btn:active { transform: translateY(0); }

.mic.rec {
  background: var(--danger-soft);
  border-color: rgba(var(--danger-rgb),.35);
  color: var(--danger);
  animation: pulse 1.4s infinite;
}
html[data-theme="dark"] .mic.rec { background: rgba(var(--danger-rgb), 0.14); }

.think-btn.on {
  background: var(--accent-soft);
  border-color: rgba(var(--accent-rgb),.35);
  color: var(--accent);
}

/* ───────── SVG 图标全局样式 ───────── */
.icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.brand .logo .icon-svg,
.card .logo .icon-svg,
.avatar.asst-av .icon-svg,
.user-box .logout .icon-svg,
.theme-icon .icon-svg {
  display: block;
  margin: auto;
}
.theme-icon { display: inline-flex; align-items: center; justify-content: center; }
.side-link .icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; }

/* ───────── Toast 提示 ───────── */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text);
  min-width: 180px;
  max-width: 320px;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform .25s cubic-bezier(.2,.8,.2,1), opacity .2s ease;
}
.toast-item.show { transform: translateX(0); opacity: 1; }
.toast-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.toast-msg { line-height: 1.4; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warn); }
.toast-info .toast-icon { color: var(--accent); }

/* ───────── 消息时间戳 ───────── */
.msg-time {
  font-size: 11px;
  color: var(--text-3);
  opacity: 0.45;
  transition: opacity .15s;
  white-space: nowrap;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}
.row:hover .msg-time,
.row.asst:hover .msg-time,
.row.user:hover .msg-time { opacity: 1; }
.row.user .bubble { position: relative; padding-bottom: 22px; }
.row.user .msg-time { position: absolute; right: 12px; bottom: 6px; margin-left: 0; }
.asr-txt { position: relative; padding-bottom: 16px; }
.asr-txt .msg-time { position: absolute; right: 0; bottom: 0; margin-left: 0; font-size: 10px; }

/* ───────── 录音波形 ───────── */
.waveform {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}
.wave-bar {
  width: 4px;
  min-height: 4px;
  background: linear-gradient(180deg, #f59e0b, var(--danger));
  border-radius: var(--radius-full);
  transition: height .06s linear;
}

/* ───────── 代码块语言标签 ───────── */
.code-lang {
  position: absolute;
  top: 6px;
  left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.code-block { padding-top: 32px; }   /* padding-top 唯一, 保留 (.code-copy 的 top/right 在 1542 定义, 此处曾重复 6px 被覆盖, 已删) */


.spacer { flex: 1; }

.send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .12s, box-shadow .15s;
  flex-shrink: 0;
}
.send.on {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(var(--accent-rgb),.3);
}
.send.on:hover {
  background: var(--accent-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb),.35);
}
.send svg { width: 17px; height: 17px; }
.send.stop {
  background: var(--danger);
  box-shadow: 0 2px 8px rgba(var(--danger-rgb),.25);
}
.send.stop:hover { background: #dc2626; }

.composer-meta {
  max-width: 768px;
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
}
.composer-meta .consent {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.composer-meta .consent:hover { color: var(--text-2); }
.composer-meta .consent.on { color: var(--accent); }
.composer-meta .withdraw {
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.composer-meta .withdraw:hover { color: #dc2626; }
.composer-meta .meta-hint { margin-left: auto; }

/* ───────── 情绪徽章 ───────── */
.emo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  border-radius: var(--radius-full);
  padding: 5px 10px;
  line-height: 1;
  transition: transform .12s;
}
.emo-badge:hover { transform: translateY(-1px); }
.emo-icon { font-size: 13px; }
.emo-name { font-weight: 500; }
.emo-bar {
  width: 36px;
  height: 4px;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.08);
  overflow: hidden;
  flex-shrink: 0;
}
html[data-theme="dark"] .emo-bar { background: rgba(255,255,255,0.12); }
.emo-bar i {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .3s ease;
}
.emo-pct {
  font-size: 11px;
  opacity: .85;
  font-variant-numeric: tabular-nums;
}

.emo-joy     { color: #b45309; background: rgba(245, 158, 11, 0.14); }
.emo-joy .emo-bar i     { background: #f59e0b; }
.emo-anger   { color: #b91c1c; background: rgba(var(--danger-rgb), 0.14); }
.emo-anger .emo-bar i   { background: #ef4444; }
.emo-sorrow  { color: #1d4ed8; background: rgba(59, 130, 246, 0.14); }
.emo-sorrow .emo-bar i  { background: #3b82f6; }
.emo-surprise{ color: #7c3aed; background: rgba(139, 92, 246, 0.14); }
.emo-surprise .emo-bar i{ background: #8b5cf6; }
.emo-neutral { color: #374151; background: rgba(107, 114, 128, 0.14); }
.emo-neutral .emo-bar i { background: #6b7280; }
.emo-fear    { color: #0f766e; background: rgba(20, 184, 166, 0.14); }
.emo-fear .emo-bar i    { background: #14b8a6; }
.emo-disgust { color: #15803d; background: rgba(34, 197, 94, 0.14); }
.emo-disgust .emo-bar i { background: #22c55e; }

html[data-theme="dark"] .emo-joy     { color: #fbbf24; background: rgba(245, 158, 11, 0.18); }
html[data-theme="dark"] .emo-anger   { color: #f87171; background: rgba(var(--danger-rgb), 0.18); }
html[data-theme="dark"] .emo-sorrow  { color: #60a5fa; background: rgba(59, 130, 246, 0.18); }
html[data-theme="dark"] .emo-surprise{ color: #a78bfa; background: rgba(139, 92, 246, 0.18); }
html[data-theme="dark"] .emo-neutral { color: #d1d5db; background: rgba(107, 114, 128, 0.18); }
html[data-theme="dark"] .emo-fear    { color: #2dd4bf; background: rgba(20, 184, 166, 0.18); }
html[data-theme="dark"] .emo-disgust { color: #4ade80; background: rgba(34, 197, 94, 0.18); }

.asst-emo { margin-bottom: 8px; }

/* ───────── Markdown body ───────── */
.markdown-body { line-height: 1.75; color: var(--text); }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }
.markdown-body p { margin: .65em 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 1.1em 0 .55em;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.01em;
}
.markdown-body h1 { font-size: 1.55em; }
.markdown-body h2 { font-size: 1.3em; }
.markdown-body h3 { font-size: 1.12em; }
.markdown-body ul, .markdown-body ol { margin: .55em 0; padding-left: 1.5em; }
.markdown-body li { margin: .28em 0; }
.markdown-body blockquote {
  margin: .7em 0;
  padding: .25em 1em;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
  background: var(--panel);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.markdown-body pre {
  margin: .7em 0;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--panel);
  overflow-x: auto;
  border: 1px solid var(--border);
}
.markdown-body pre code {
  background: transparent;
  padding: 0;
  font-size: .88em;
  font-family: var(--mono);
}
.markdown-body code {
  background: var(--panel);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: .9em;
  font-family: var(--mono);
  border: 1px solid var(--border);
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: .7em 0;
  font-size: .95em;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th { background: var(--panel); font-weight: 600; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 1.1em 0; }
.markdown-body a { color: var(--accent); }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }

/* ───────── 登录/注册 ───────── */
.center-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 400px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  position: relative;
  transition: background .2s, border-color .2s;
  animation: popIn .35s cubic-bezier(.2,.8,.2,1);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}
.card .logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.25);
}
.theme-btn-standalone {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, transform .1s;
  color: var(--text);
}
.theme-btn-standalone:hover {
  background: var(--panel-2);
  border-color: var(--border-2);
  transform: translateY(-1px);
}
.card h1 {
  font-size: 26px;
  margin: 18px 0 6px;
  text-align: left;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.card .sub {
  font-size: 14px;
  color: var(--text-2);
  text-align: left;
  margin-bottom: 26px;
}
.card label {
  display: block;
  font-size: 13px;
  margin: 18px 0 7px;
  color: var(--text-2);
  font-weight: 500;
}
.card input[type="text"],
.card input[type="password"],
.card input:not([type="checkbox"]) {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s;
}
.card input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.card .checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.card .checkbox-row input { width: auto; }

.btn-primary {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .12s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(var(--accent-rgb),.18);
}
.btn-primary:hover {
  background: var(--accent-d);
  box-shadow: 0 4px 14px rgba(var(--accent-rgb),.25);
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }

.err {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  min-height: 18px;
  text-align: center;
  background: var(--danger-soft);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}
.err:empty { display: none; }
.alt {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-2);
}
.alt a { font-weight: 500; }

/* ───────── 通用内容页（Keys / Stats / Admin / Privacy） ───────── */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 28px 56px;
  height: 100%;
  overflow-y: auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: 26px;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-sub {
  font-size: 14px;
  color: var(--text-2);
  margin: 0;
  line-height: 1.5;
}
.page-create {
  width: auto;
  margin: 0;
  padding: 10px 18px;
  font-size: 14px;
}

/* 汇总卡片 */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 22px 0 6px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  transition: transform .12s, border-color .15s;
}
.summary-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.summary-card .n {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.summary-card .l {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 5px;
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-top: 22px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  white-space: nowrap;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
  transition: background .12s;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--panel); }

.k-name { font-weight: 500; }
.k-key code {
  background: var(--panel);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--mono);
}
.k-time { color: var(--text-2); font-size: 13px; }
.k-act { text-align: right; }

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  opacity: .5;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: opacity .12s, background .12s, transform .1s;
  color: var(--text);
}
.icon-btn:hover {
  opacity: 1;
  background: var(--panel);
  transform: translateY(-1px);
}

.page-foot {
  margin-top: 22px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.empty {
  color: var(--text-2);
  font-size: 13px;
  padding: 32px 16px;
  text-align: center;
}
.info {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.75;
}
.info code {
  background: var(--panel);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .9em;
}

.btn-mini {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  transition: background .12s, border-color .12s, transform .1s;
  font: inherit;
}
.btn-mini:hover {
  background: var(--panel-2);
  border-color: var(--border-2);
  transform: translateY(-1px);
}

/* ───────── 管理页专用 ───────── */
.uname { display: flex; align-items: center; gap: 10px; }
.uname .av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.uname .nm { font-weight: 500; color: var(--text); }
.uname .me { color: var(--text-3); font-size: 12px; margin-left: 4px; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); font-size: 13px; white-space: nowrap; }

.today-cell { display: flex; align-items: center; gap: 10px; }
.today-cell .mini-bar {
  width: 64px;
  height: 5px;
  background: var(--panel-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  flex-shrink: 0;
}
.today-cell .mini-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width .4s ease;
}
.today-cell .mini-fill.hot { background: var(--danger); }

/* ───────── 统计页专用 ───────── */
.stats-section { margin: 20px 0; }
.stats-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 14px;
  letter-spacing: .3px;
}
.srow { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.sname {
  width: 70px;
  font-size: 14px;
  color: var(--text);
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.strack {
  flex: 1;
  height: 8px;
  background: var(--panel-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  min-width: 0;
}
.sfill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.sval {
  width: 48px;
  text-align: right;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.stats-empty {
  color: var(--text-3);
  padding: 72px 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.7;
}
.stats-empty .big { font-size: 48px; display: block; margin-bottom: 12px; opacity: .5; }
.stats-forbidden { padding: 88px 0; text-align: center; color: var(--text-2); }
.stats-forbidden .big { font-size: 52px; display: block; margin-bottom: 14px; }
.stats-forbidden .back { font-size: 13px; color: var(--text-3); margin-top: 16px; }

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  box-shadow: var(--shadow);
}
.refresh-btn:hover {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border-2);
  transform: translateY(-1px);
}
.refresh-btn:disabled { opacity: .55; cursor: default; transform: none; }

/* ───────── 模态框 ───────── */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 460px;
  max-width: 92vw;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: popIn .25s cubic-bezier(.2,.8,.2,1);
}
.modal h3 { margin: 0 0 16px; font-size: 18px; font-weight: 650; }
.modal label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin: 10px 0 7px;
  font-weight: 500;
}
.modal input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.modal input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.btn-ghost {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--radius-md);
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .1s;
}
.btn-ghost:hover {
  background: var(--panel);
  border-color: var(--border-2);
  color: var(--text);
  transform: translateY(-1px);
}
.warn-line {
  font-size: 13px;
  color: #9a6a00;
  background: var(--warn-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}
html[data-theme="dark"] .warn-line {
  color: #fcd34d;
  background: rgba(180, 130, 0, 0.12);
  border-color: rgba(252, 211, 77, 0.25);
}
.key-box {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border);
}
.key-box code {
  flex: 1;
  word-break: break-all;
  font-size: 13px;
  background: transparent;
  padding: 0;
  border: none;
  color: var(--text);
  font-family: var(--mono);
}

/* ───────── 隐私政策 ───────── */
.pp {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 72px;
  height: 100%;
  overflow-y: auto;
}
.pp h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.pp .sub {
  font-size: 14px;
  color: var(--text-2);
  margin: 0 0 26px;
  line-height: 1.5;
}
.pp h2 {
  font-size: 16px;
  font-weight: 650;
  margin: 28px 0 10px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.pp p, .pp li {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-2);
  margin: .55em 0;
}
.pp ul { padding-left: 1.4em; }
.pp a { color: var(--accent); }
.pp .back { margin-top: 32px; }
.pp code {
  background: var(--panel);
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  font-size: .88em;
  border: 1px solid var(--border);
  font-family: var(--mono);
}

/* ───────── 移动端适配 ───────── */
.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 640px) {
  .sidebar {
    position: absolute;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 20;
    transition: left .22s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 19;
    animation: fadeIn .15s ease;
  }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .menu-btn {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background .12s;
  }
  .menu-btn:hover { background: var(--panel); }
  .mobile-title { font-weight: 650; font-size: 15px; }

  .messages { padding: 18px 14px 10px; }
  .messages-inner, .composer, .composer-meta { max-width: 100%; }
  .bubble { max-width: 88%; }
  .welcome-stage h1 { font-size: 26px; }
  .page { padding: 18px 14px 36px; }
  .summary-cards { grid-template-columns: 1fr; }
  .table-wrap .data-table { min-width: 560px; }
  .card { padding: 28px 22px; }
}

/* ───────── 代码块复制 / 消息操作 / 流式光标 / 回到最新 ───────── */
.code-block { position: relative; }
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .12s, color .12s, transform .1s;
  font: inherit;
}
.code-block:hover .code-copy { opacity: 1; }
.code-copy:hover {
  background: var(--panel);
  color: var(--text);
  transform: translateY(-1px);
}
.stream-cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: stream-blink 1s steps(2, start) infinite;
}
.msg-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity .15s;
}
.row.asst:hover .msg-actions,
.row.asst:focus-within .msg-actions { opacity: 1; }
.msg-act {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s, transform .1s;
  font: inherit;
}
.msg-act:hover {
  color: var(--text);
  background: var(--panel);
  border-color: var(--border-2);
  transform: translateY(-1px);
}
.jump-bottom {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 32px;
  text-align: center;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 5;
  transition: background .12s, transform .12s;
}
.jump-bottom:hover {
  background: var(--panel);
  transform: translateX(-50%) translateY(-1px);
}

@media (max-width: 640px) {
  .msg-actions { opacity: 1; }
  .code-copy { opacity: 1; }
}

/* ───────── 重播语音按钮 ───────── */
.asst-audio { margin-top: 8px; }
.replay-btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  padding: 5px 13px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 13px;
  font: inherit;
  transition: background .12s, border-color .12s, transform .1s;
}
.replay-btn:hover {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: rgba(var(--accent-rgb), 0.4);
  transform: translateY(-1px);
}

/* ───────── 录音音量条 + VAD ───────── */
.rec-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 8px;
}
.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s infinite;
}
.rec-level {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--panel-2);
  overflow: hidden;
}
.rec-level i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #f59e0b, var(--danger));
  transition: width .06s linear;
}
.rec-txt { font-size: 11px; color: var(--text-3); white-space: nowrap; }

/* ───────── 深度思考 ───────── */
.think-block {
  margin: 4px 0 10px;
  border-left: 3px solid var(--border-2);
  border-radius: 4px;
  background: var(--panel);
  overflow: hidden;
}
.think-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  user-select: none;
  transition: color .12s, background .12s;
}
.think-head:hover {
  color: var(--text-2);
  background: var(--panel-2);
}
.think-icon { font-size: 13px; }
.think-chev { margin-left: auto; font-size: 11px; }
.think-body {
  padding: 2px 14px 10px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-3);
  white-space: pre-wrap;
  word-break: break-word;
}
