/* ============================================================
   deepseek伴侣 V0.1.0 — 样式
   设计变量取自 DeepSeek chat-demo 官方 CSS 设计令牌
   ============================================================ */
:root {
  --dsw-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --brand: #4d6bfe;
  --message-list-max-width: 840px;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-base: #151517;            /* neutral-bluish-950 */
  --bg-sidebar: #1b1b1c;         /* neutral-bluish-900 */
  --bg-elevated: #2c2c2e;        /* neutral-bluish-850 */
  --bg-input: #2c2c2e;
  --bg-hover: rgba(255, 255, 255, .08);
  --bg-active: rgba(255, 255, 255, .14);
  --border: rgba(255, 255, 255, .06);
  --border-strong: rgba(255, 255, 255, .12);
  --label-primary: #ebeef2;      /* neutral-bluish-100 */
  --label-secondary: #adb2b8;    /* neutral-bluish-400 */
  --label-tertiary: #81858c;     /* neutral-bluish-600 */
  --code-bg: #2c2c2e;
  --bubble-user: #283152;
  --error: #f25a5a;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg-base: #ffffff;
  --bg-sidebar: #f9fafb;
  --bg-elevated: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: rgba(38, 49, 72, .06);
  --bg-active: rgba(38, 49, 72, .1);
  --border: rgba(38, 49, 72, .1);
  --border-strong: rgba(38, 49, 72, .16);
  --label-primary: #0f1115;
  --label-secondary: #61666b;
  --label-tertiary: #81858c;
  --code-bg: #f1f3f5;
  --bubble-user: #e4ecff;
  --error: #ec1313;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--dsw-font-family);
  background: var(--bg-base);
  color: var(--label-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: var(--label-primary); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ============ 图标按钮 ============ */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: none; background: transparent; color: var(--label-secondary);
  transition: background .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--label-primary); }
.icon-btn--sm { width: 24px; height: 24px; }

/* ============ 侧边栏 ============ */
.sidebar {
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  transition: margin-left .2s ease;
}
.sidebar.collapsed { margin-left: -280px; }
.sidebar__top { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand__logo { display: flex; width: 28px; height: 28px; flex-shrink: 0; }
.brand__logo svg { display: block; border-radius: 8px; }
.brand__name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__ver {
  display: inline-block; margin-left: 6px; padding: 1px 6px;
  font-size: 10px; font-weight: 600; border-radius: 999px;
  background: rgba(77, 107, 254, .15); color: var(--brand); vertical-align: 2px;
}
.btn-new-chat {
  margin: 8px 14px; padding: 9px 14px; border-radius: 10px;
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--label-primary); font-size: 13.5px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.btn-new-chat:hover { background: var(--bg-hover); border-color: var(--brand); }
.search-box {
  margin: 0 14px 8px; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 10px;
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--label-tertiary);
}
.search-box input {
  flex: 1; border: none; background: transparent; outline: none; font-size: 13px;
}
.search-box input::placeholder { color: var(--label-tertiary); }

/* 会话列表 */
.session-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.session-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 10px; margin-bottom: 2px;
  color: var(--label-secondary); font-size: 13.5px; cursor: pointer;
  position: relative; transition: background .15s;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: var(--bg-active); color: var(--label-primary); }
.session-item__title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item__tag {
  font-size: 10px; padding: 1px 6px; border-radius: 999px; flex-shrink: 0;
  background: rgba(77, 107, 254, .15); color: var(--brand);
}
.session-item__tag--cloud { background: rgba(46, 160, 67, .18); color: #3fb950; }
.session-item__del {
  visibility: hidden; border: none; background: none; color: var(--label-tertiary);
  font-size: 13px; padding: 2px 4px; border-radius: 6px; flex-shrink: 0;
}
.session-item:hover .session-item__del { visibility: visible; }
.session-item__del:hover { color: var(--error); background: var(--bg-hover); }
.session-group { padding: 10px 10px 4px; font-size: 11px; color: var(--label-tertiary); }
.session-empty { padding: 24px 14px; text-align: center; color: var(--label-tertiary); font-size: 12.5px; }

/* 账户卡片 */
.account-card {
  margin: 8px 14px 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-elevated); border: 1px solid var(--border);
}
.account-card__row { display: flex; align-items: center; justify-content: space-between; }
.account-card__label { font-size: 11.5px; color: var(--label-tertiary); }
.account-card__balance { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.account-card__sub { font-size: 11px; color: var(--label-tertiary); margin-top: 1px; }
.account-card__btns { display: flex; gap: 8px; margin-top: 10px; }
.mini-btn {
  flex: 1; padding: 6px 0; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-primary);
  transition: background .15s;
}
.mini-btn:hover { background: var(--bg-hover); }
.mini-btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.mini-btn--primary:hover { background: #3964fe; }
.account-card__link {
  display: flex; align-items: center; gap: 6px; margin-top: 10px;
  font-size: 12px; color: var(--label-secondary);
}
.account-card__link:hover { color: var(--brand); text-decoration: none; }
.account-card__btn {
  width: 100%; padding: 0; margin-top: 4px; border: none; background: none;
  font-size: 12px; text-align: left; color: var(--label-secondary);
}
.account-card__btn:hover { color: var(--brand); }

/* ============ 主区域 ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--border); min-height: 52px;
}
.topbar__expand { display: none; }
.sidebar.collapsed ~ .main .topbar__expand { display: inline-flex; }
.model-chip select {
  appearance: none; -webkit-appearance: none;
  padding: 5px 26px 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-strong); background: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2381858c' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  outline: none; cursor: pointer;
}
.session-stats { flex: 1; font-size: 11.5px; color: var(--label-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 8px; font-size: 12.5px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-secondary);
  transition: all .15s;
}
.chip-btn:hover { color: var(--label-primary); border-color: var(--brand); background: var(--bg-hover); }

/* ============ 消息区 ============ */
.chat { flex: 1; overflow-y: auto; }
.message-list { max-width: var(--message-list-max-width); margin: 0 auto; padding: 24px 44px 12px; }
@media (max-width: 768px) {
  .message-list { padding: 16px 16px 8px; }
  .sidebar { position: fixed; z-index: 50; height: 100%; }
}

.welcome { padding-top: 12vh; text-align: center; }
.welcome__title { font-size: 24px; margin: 18px 0 8px; font-weight: 700; }
.welcome__desc { color: var(--label-secondary); font-size: 14px; margin: 0 0 24px; }
.welcome__hints { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.hint-chip {
  padding: 8px 16px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-secondary);
  transition: all .15s;
}
.hint-chip:hover { border-color: var(--brand); color: var(--brand); background: rgba(77,107,254,.08); }
.welcome__nokey { margin-top: 28px; font-size: 12.5px; color: var(--brand); background: rgba(77,107,254,.1); display: inline-block; padding: 7px 14px; border-radius: 999px; }

.msg { margin-bottom: 26px; }
.msg--user { display: flex; justify-content: flex-end; }
.msg__bubble-user {
  max-width: 78%; padding: 10px 16px; border-radius: 14px;
  background: var(--bubble-user); white-space: pre-wrap; word-break: break-word;
  font-size: 14.5px;
}
.msg__assistant { display: flex; flex-direction: column; }
.msg__avatar {
  width: 26px; height: 26px; border-radius: 7px; margin-bottom: 8px;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
}
.msg__avatar svg { width: 17px; height: 17px; }
.msg__content { font-size: 14.5px; word-break: break-word; }
.msg__content p { margin: 0 0 10px; }
.msg__content p:last-child { margin-bottom: 0; }
.msg__content pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; overflow-x: auto;
  font-size: 13px; line-height: 1.55; margin: 10px 0;
}
.msg__content code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.msg__content :not(pre) > code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; }
.msg__content ul, .msg__content ol { margin: 8px 0; padding-left: 22px; }
.msg__content table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.msg__content th, .msg__content td { border: 1px solid var(--border-strong); padding: 6px 10px; font-size: 13px; }
.msg__content blockquote { border-left: 3px solid var(--brand); margin: 10px 0; padding: 2px 14px; color: var(--label-secondary); }
.msg__content h1, .msg__content h2, .msg__content h3, .msg__content h4 { margin: 16px 0 8px; line-height: 1.4; }

/* 思考过程 */
.reasoning {
  border-left: 3px solid var(--border-strong);
  margin: 4px 0 10px; padding: 6px 12px; font-size: 12.5px;
  color: var(--label-tertiary); background: var(--bg-hover);
  border-radius: 0 8px 8px 0; white-space: pre-wrap; max-height: 200px; overflow-y: auto;
}

/* token 消耗 & 计费 */
.usage-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px;
  margin-top: 8px; font-size: 11.5px; color: var(--label-tertiary);
}
.usage-line .u-item { display: inline-flex; align-items: center; gap: 4px; }
.usage-line .u-item b { color: var(--label-secondary); font-weight: 600; }
.usage-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); display: inline-block; }

.msg__actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg__actions { opacity: 1; }
.msg__err { color: var(--error); font-size: 13px; margin-top: 6px; }

.typing-cursor { display: inline-block; width: 7px; height: 15px; background: var(--brand); vertical-align: -2px; animation: blink .8s infinite; border-radius: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* ============ 输入区 ============ */
.composer-wrap { padding: 0 44px 14px; }
@media (max-width: 768px) { .composer-wrap { padding: 0 16px 10px; } }
.summary-banner {
  max-width: var(--message-list-max-width); margin: 0 auto 8px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 10px; font-size: 12px;
  background: rgba(77,107,254,.1); color: var(--brand);
}
.summary-banner span { flex: 1; }
.composer { max-width: var(--message-list-max-width); margin: 0 auto; }
/* 模型选择器（输入栏内，列表来自官方 /models） */
.model-pick { display: flex; align-items: center; gap: 2px; min-width: 0; flex-shrink: 1; }
.model-pick select {
  max-width: 168px; padding: 4px 6px; font-size: 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-primary);
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--label-tertiary) 50%),
                    linear-gradient(135deg, var(--label-tertiary) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 20px; cursor: pointer; text-overflow: ellipsis;
}
.model-pick select:focus { outline: none; border-color: var(--brand); }
.model-pick .icon-btn--sm { width: 24px; height: 24px; flex-shrink: 0; color: var(--label-tertiary); }
.model-pick .icon-btn--sm:hover { color: var(--brand); }

.think-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-tertiary);
  flex-shrink: 0; transition: all .15s;
}
.think-toggle:hover { color: var(--label-primary); border-color: var(--brand); }
.think-toggle.on { color: var(--brand); border-color: var(--brand); background: rgba(77,107,254,.12); }
.think-toggle.on { color: var(--brand); border-color: var(--brand); background: rgba(77,107,254,.1); }
.composer__box {
  background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: 16px; padding: 12px 14px 8px;
  transition: border-color .15s;
}
.composer__box:focus-within { border-color: var(--brand); }
.composer__box textarea {
  width: 100%; border: none; background: transparent; outline: none;
  resize: none; font-size: 14.5px; line-height: 1.6; max-height: 200px;
}
.composer__box textarea::placeholder { color: var(--label-tertiary); }
.composer__actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.composer__tip { flex: 1; font-size: 11px; color: var(--label-tertiary); }
.send-btn {
  width: 34px; height: 34px; border-radius: 10px; border: none;
  background: var(--brand); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; transition: opacity .15s, background .15s;
}
.send-btn:hover { background: #3964fe; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn--stop { background: var(--error); }
.composer__disclaimer { text-align: center; font-size: 11px; color: var(--label-tertiary); margin: 8px 0 0; }

/* ============ 弹窗 ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal__mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal__panel {
  position: relative; width: 400px; max-width: calc(100vw - 32px);
  max-height: 86vh; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 16px; box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
}
.modal__panel--wide { width: 560px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.modal__head h3 { margin: 0; font-size: 16px; }
.modal__body { padding: 4px 18px 12px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 8px 18px 16px; }
.modal__note { font-size: 12.5px; color: var(--label-secondary); margin: 4px 0 12px; line-height: 1.6; }
.modal__error {
  padding: 8px 12px; border-radius: 8px; font-size: 12.5px;
  background: rgba(242, 90, 90, .12); color: var(--error); margin-top: 8px;
}
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--label-secondary); margin-bottom: 5px; }
.field > span b { color: var(--brand); }
.field > span i { font-style: normal; color: var(--label-tertiary); font-size: 11px; }
.field input[type="text"], .field input[type="password"], .field input[type="number"],
.field textarea, .field select {
  width: 100%; padding: 9px 12px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid var(--border-strong); background: var(--bg-input); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.field--inline { display: flex; align-items: center; gap: 8px; }
.field--inline span { margin: 0; }
.switch-row { padding: 6px 0; font-size: 13px; }
.field input[type="range"] { width: 100%; accent-color: var(--brand); }
.open-platform-links { display: flex; gap: 10px; margin-top: 4px; }
.open-platform-links .btn { flex: 1; justify-content: center; display: inline-flex; align-items: center; gap: 6px; }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.settings-grid--price { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) { .settings-grid, .settings-grid--price { grid-template-columns: 1fr; } }
.settings-sub { font-size: 13px; margin: 8px 0 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.settings-grid--price .field > span { font-size: 11.5px; line-height: 1.4; }
.theme-switch { display: flex; gap: 8px; }
.theme-switch button {
  flex: 1; padding: 8px 0; border-radius: 9px; font-size: 13px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-secondary);
}
.theme-switch button.active { border-color: var(--brand); color: var(--brand); background: rgba(77,107,254,.1); }
.compress-stats { background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 2; }

/* 按钮 */
.btn {
  padding: 8px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; transition: all .15s;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: #3964fe; }
.btn--primary:disabled { opacity: .5; cursor: not-allowed; }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--label-primary); text-decoration: none; }
.btn--ghost:hover { background: var(--bg-hover); text-decoration: none; }

/* Toast */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 18px; border-radius: 10px; font-size: 13px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: toastIn .25s ease;
}
.toast--success { border-color: rgba(63, 185, 80, .5); color: #3fb950; }
.toast--error { border-color: rgba(242, 90, 90, .5); color: var(--error); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }


/* ============ 侧边栏遮罩（移动端） ============ */
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 55;
}

/* ============ 移动端：完整放进一屏 ============ */
@media (max-width: 768px) {
  :root { --message-list-max-width: 100%; }
  .sidebar {
    position: fixed; z-index: 60; height: 100vh; height: 100dvh;
    width: 82vw; max-width: 300px; box-shadow: 0 12px 40px rgba(0,0,0,.35);
  }
  .sidebar.collapsed { margin-left: -100vw; }
  .topbar__expand { display: inline-flex; }
  .topbar { padding: 6px 10px; min-height: 44px; gap: 6px; }
  .topbar__actions { gap: 2px; }
  .chip-btn { padding: 5px 8px; font-size: 12px; gap: 4px; }
  .chip-btn svg { display: none; }
  .session-stats { display: none; }
  .message-list { padding: 10px 14px 4px; }
  .welcome { padding-top: 6vh; }
  .welcome__title { font-size: 19px; margin: 14px 0 6px; }
  .welcome__desc { font-size: 13px; margin-bottom: 16px; padding: 0 8px; }
  .welcome__hints { gap: 8px; }
  .hint-chip { padding: 7px 12px; font-size: 12px; }
  .welcome__nokey { margin-top: 18px; font-size: 11.5px; }
  .msg { margin-bottom: 18px; }
  .msg__bubble-user { max-width: 86%; font-size: 14px; }
  .msg__content { font-size: 14px; }
  .msg__content pre { padding: 10px; font-size: 12px; border-radius: 8px; }
  .composer-wrap { padding: 0 8px calc(6px + env(safe-area-inset-bottom)); }
  .summary-banner { padding: 5px 9px; font-size: 11px; margin-bottom: 5px; border-radius: 8px; gap: 5px; }
  .summary-banner span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .composer__box { padding: 6px 8px 5px; border-radius: 14px; }
  .composer__box textarea { font-size: 14px; max-height: 96px; line-height: 1.5; }
  .composer__actions { margin-top: 4px; gap: 6px; }
  .model-pick select { max-width: 132px; font-size: 11.5px; padding: 3px 18px 3px 5px; }
  .composer__tip { display: none; }
  .composer__disclaimer { display: none; }
  .think-toggle { padding: 4px 9px; font-size: 11.5px; }
  .send-btn { width: 32px; height: 32px; border-radius: 9px; }
  .modal__panel { width: calc(100vw - 20px); max-height: 88vh; }
  .toast-wrap { top: 54px; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid--price { grid-template-columns: 1fr 1fr; }
}


/* ============================================================
   V0.4.0 — DeepSeek APP 风格：大字、宽间距、底部操作栏
   ============================================================ */
:root { --chat-font: 17px; --chat-line: 1.9; }

/* 顶栏标题 */
.topbar { min-height: 56px; }
.topbar__heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.topbar__title {
  font-size: 16.5px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__heading .session-stats { font-size: 11px; }

/* 消息区 */
.message-list { max-width: 768px; padding: 30px 26px 6px; }
.msg { margin-bottom: 38px; }
.msg--user { display: flex; justify-content: flex-end; }
.msg__bubble-user {
  max-width: 84%; padding: 13px 18px;
  border-radius: 18px 18px 6px 18px;
  background: var(--bubble-user);
  font-size: calc(var(--chat-font) - 1px); line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
  cursor: pointer; transition: filter .15s;
}
.msg__bubble-user:hover { filter: brightness(1.08); }
.msg__assistant { display: block; }
.msg__content {
  font-size: var(--chat-font); line-height: var(--chat-line);
  letter-spacing: .012em; word-break: break-word;
}
.msg__content p { margin: 0 0 .95em; }
.msg__content p:last-child { margin-bottom: 0; }
.msg__content li { margin: .28em 0; }
.msg__content h1, .msg__content h2, .msg__content h3, .msg__content h4 { line-height: 1.5; }
.msg__content pre { font-size: calc(var(--chat-font) - 4px); line-height: 1.7; padding: 14px 16px; }
.msg__content table th, .msg__content table td { font-size: calc(var(--chat-font) - 3.5px); }
.msg__disclaimer {
  margin: 14px 0 0; font-size: 12.5px; line-height: 1.6;
  color: var(--label-tertiary); font-style: italic;
}
.msg__actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: .8; }
.msg__actions .icon-btn { width: 30px; height: 30px; border-radius: 8px; color: var(--label-tertiary); }
.msg__actions .icon-btn:hover { color: var(--label-primary); background: var(--bg-hover); }

/* 流式光标（纯 CSS，避免频繁插入节点） */
.msg__content.is-streaming::after {
  content: ""; display: inline-block; width: 2px; height: 1.05em;
  margin-left: 2px; background: var(--brand); vertical-align: -.16em;
  border-radius: 1px; animation: blink 1s steps(1) infinite;
}

/* 思考过程：读秒 + 折叠 */
.reasoning-wrap { margin: 0 0 16px; padding-left: 13px; border-left: 2px solid var(--border-strong); }
.reasoning-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 2px 0; border: none; background: none;
  color: var(--label-tertiary); font-size: 13.5px; text-align: left;
}
.reasoning-head:hover { color: var(--label-secondary); }
.reasoning-spark { flex-shrink: 0; }
.reasoning-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reasoning-chevron { flex-shrink: 0; transition: transform .2s ease; }
.reasoning-wrap.collapsed .reasoning-chevron { transform: rotate(-90deg); }
.reasoning {
  border: none; background: transparent; border-radius: 0;
  margin: 8px 0 0; padding: 0 4px 0 0;
  font-size: calc(var(--chat-font) - 3.5px); line-height: 1.85;
  color: var(--label-tertiary); white-space: pre-wrap; word-break: break-word;
  max-height: 300px; overflow-y: auto;
}
.reasoning-wrap.collapsed .reasoning { display: none; }

/* 用户消息操作菜单 */
.msg-menu {
  position: fixed; z-index: 210; min-width: 132px; padding: 6px;
  border-radius: 12px; background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; animation: menuIn .12s ease;
}
.msg-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: none; background: none; border-radius: 8px;
  font-size: 14px; color: var(--label-primary); text-align: left;
}
.msg-menu button:hover { background: var(--bg-hover); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px); } }

/* 修改内容弹窗 */
.edit-textarea {
  width: 100%; min-height: 220px; max-height: 52vh; padding: 12px 14px;
  border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--bg-input); color: var(--label-primary);
  font-size: 15px; line-height: 1.7; resize: vertical; outline: none;
}
.edit-textarea:focus { border-color: var(--brand); }

/* 输入区：更接近 App 的圆角胶囊 */
.composer__box { border-radius: 24px; padding: 14px 18px 10px; }
.composer__box textarea { font-size: 16px; line-height: 1.65; }

/* 欢迎页：大字宽间距 */
.welcome { padding-top: 11vh; }
.welcome__title { font-size: 27px; line-height: 1.5; letter-spacing: .3px; }
.welcome__desc { font-size: 15px; line-height: 1.85; max-width: 560px; margin-left: auto; margin-right: auto; }

/* 移动端 */
@media (max-width: 768px) {
  .message-list { padding: 14px 18px 4px; }
  .msg { margin-bottom: 30px; }
  .msg__content { line-height: 1.85; }
  .msg__bubble-user { font-size: calc(var(--chat-font) - 1px); padding: 11px 15px; }
  .msg__actions { opacity: 1; margin-left: -6px; }
  .msg__disclaimer { font-size: 12px; margin-top: 12px; }
  .composer__box { border-radius: 20px; padding: 10px 14px 8px; }
  .composer__box textarea { font-size: 15.5px; }
  .topbar__title { font-size: 15.5px; }
  .welcome__title { font-size: 20px; }
  .welcome__desc { font-size: 14px; }
  .reasoning { max-height: 240px; }
}


/* ============================================================
   V0.5.0 — 用户气泡浅蓝 + 长文折叠、输入框加大、标题可编辑
   ============================================================ */

/* ---------- 1. 用户气泡：浅蓝底 + 超长折叠 ---------- */
.bubble-wrap {
  position: relative; max-width: 84%;
  display: flex; flex-direction: column; align-items: flex-end;
}
.bubble-wrap > .msg__bubble-user { max-width: 100%; }
.bubble-wrap.collapsed > .msg__bubble-user {
  max-height: var(--bubble-clamp, 300px); overflow: hidden;
}
.bubble-fade { display: none; }
.bubble-wrap.is-collapsible.collapsed .bubble-fade {
  display: block; position: absolute; left: 1px; right: 1px; bottom: 1px; height: 64px;
  background: linear-gradient(to bottom,
    rgba(255, 255, 255, 0) 0%,
    var(--bubble-user) 46%,
    var(--bubble-user) 100%);
  border-radius: 0 0 6px 17px; pointer-events: none;
}
.bubble-toggle {
  position: absolute; right: 10px; bottom: 8px;
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  display: none; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--label-secondary);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .16);
  transition: transform .15s;
}
.bubble-wrap.is-collapsible .bubble-toggle { display: inline-flex; }
.bubble-toggle:hover { color: var(--brand); border-color: var(--brand); }
.bubble-toggle svg { transition: transform .2s ease; }
.bubble-wrap:not(.collapsed) .bubble-toggle svg { transform: rotate(180deg); }
/* 折叠时按钮压在渐隐层之上，保证可点 */
.bubble-wrap.collapsed .bubble-toggle { z-index: 2; }

/* ---------- 2. 输入框：对齐 DeepSeek APP 的大尺寸 ---------- */
.composer { max-width: 768px; }
.composer__box {
  border-radius: 26px; padding: 16px 18px 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .04);
}
.composer__box textarea {
  font-size: 16.5px; line-height: 1.6; min-height: 58px; padding: 3px 2px 5px;
}
.composer__box textarea::placeholder { color: var(--label-tertiary); }
.composer__actions { margin-top: 10px; gap: 9px; }
.composer__tip { font-size: 11.5px; }
.think-toggle { padding: 8px 13px; font-size: 13px; gap: 6px; }
.model-pick select { padding: 7px 22px 7px 9px; font-size: 12.5px; border-radius: 10px; }
.model-pick .icon-btn--sm { width: 26px; height: 26px; }
.send-btn { width: 40px; height: 40px; border-radius: 50%; }
.send-btn svg { width: 19px; height: 19px; }
.composer__disclaimer { font-size: 11.5px; margin-top: 10px; }

/* ---------- 3. 顶栏标题：可重命名 ---------- */
.topbar__title-row { display: flex; align-items: center; gap: 3px; min-width: 0; }
.topbar__title { cursor: pointer; }
.topbar__rename { opacity: 0; transition: opacity .15s; }
.topbar__heading:hover .topbar__rename,
.topbar__rename:focus-visible { opacity: 1; }
@media (hover: none) { .topbar__rename { opacity: .55; } }

/* 会话列表：重命名按钮 */
.session-item__rename {
  visibility: hidden; border: none; background: none; color: var(--label-tertiary);
  padding: 2px; border-radius: 6px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.session-item:hover .session-item__rename { visibility: visible; }
.session-item__rename:hover { color: var(--brand); background: var(--bg-hover); }

/* 重命名弹窗 */
#renameInput {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg-input);
  color: var(--label-primary); font-size: 15.5px; outline: none;
}
#renameInput:focus { border-color: var(--brand); }
.rename-hint { margin-top: 8px; font-size: 12px; color: var(--label-tertiary); min-height: 17px; line-height: 1.5; }
.rename-hint b { color: var(--brand); }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .bubble-wrap { max-width: 86%; }
  .bubble-toggle { width: 25px; height: 25px; right: 8px; bottom: 7px; }
  .composer__box { border-radius: 24px; padding: 14px 14px 10px; }
  .composer__box textarea { font-size: 16px; min-height: 50px; }
  .composer__actions { margin-top: 8px; gap: 7px; }
  .think-toggle { padding: 7px 11px; font-size: 12px; }
  .model-pick select { padding: 6px 19px 6px 7px; font-size: 12px; max-width: 128px; }
  .send-btn { width: 38px; height: 38px; }
  .session-item__del, .session-item__rename { visibility: visible; }
}

/* 消息从底部向上排布，短对话贴近输入框（与 DeepSeek APP 一致） */
.chat { display: flex; flex-direction: column; }
.message-list { width: 100%; margin-top: auto; margin-bottom: 0; }


/* ============================================================
   V0.6.0 — 附件上传、思考强度、继续输出、欢迎页位置
   ============================================================ */

/* ---------- 欢迎页上移（不再贴底） ---------- */
.message-list.is-welcome { margin-top: 0; }
.message-list.is-welcome .welcome { padding-top: clamp(56px, 20vh, 210px); }

/* ---------- 输入区：附件按钮 / 思考强度 ---------- */
.attach-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--label-secondary); }
.attach-btn:hover { color: var(--brand); border-color: var(--brand); background: transparent; }
.attach-btn.on { color: var(--brand); border-color: var(--brand); background: rgba(77,107,254,.1); }

.effort-select {
  appearance: none; -webkit-appearance: none;
  padding: 7px 20px 7px 9px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border-strong); background: transparent; color: var(--label-secondary);
  background-image: linear-gradient(45deg, transparent 50%, var(--label-tertiary) 50%),
                    linear-gradient(135deg, var(--label-tertiary) 50%, transparent 50%);
  background-position: calc(100% - 11px) 55%, calc(100% - 7px) 55%;
  background-size: 4px 4px, 4px 4px; background-repeat: no-repeat;
  outline: none; cursor: pointer; flex-shrink: 0;
}
.effort-select:focus { border-color: var(--brand); }

/* 已选附件 */
.composer__files { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.file-chip {
  position: relative; display: flex; align-items: center; gap: 8px;
  max-width: 220px; padding: 6px 8px 6px 6px; border-radius: 12px;
  background: var(--bg-hover); border: 1px solid var(--border);
}
.file-chip__thumb {
  width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
  background: var(--bg-elevated);
}
.file-chip__ico {
  width: 38px; height: 38px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(77,107,254,.12); color: var(--brand);
}
.file-chip__meta { min-width: 0; }
.file-chip__name { font-size: 12.5px; color: var(--label-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 132px; }
.file-chip__size { font-size: 10.5px; color: var(--label-tertiary); }
.file-chip__del {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--label-secondary);
  font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0;
}
.file-chip__del:hover { color: var(--error); border-color: var(--error); }

/* 附件选择器 */
.attach-menu {
  position: fixed; z-index: 215; width: 272px; padding: 6px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.28);
  display: flex; flex-direction: column; gap: 2px;
}
.attach-menu button {
  display: flex; align-items: center; gap: 11px; text-align: left;
  padding: 9px 10px; border: none; background: none; border-radius: 10px; color: var(--label-primary);
}
.attach-menu button:hover { background: var(--bg-hover); }
.attach-menu__ico {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(77,107,254,.12); color: var(--brand);
}
.attach-menu b { display: block; font-size: 13.5px; font-weight: 600; }
.attach-menu i { display: block; font-style: normal; font-size: 11px; color: var(--label-tertiary); margin-top: 1px; }

/* 拖拽提示 */
.drop-hint {
  position: fixed; inset: 12px; z-index: 300; border-radius: 18px;
  border: 2px dashed var(--brand); background: rgba(77,107,254,.08);
  display: flex; align-items: center; justify-content: center;
  color: var(--brand); font-size: 16px; font-weight: 600;
  backdrop-filter: blur(2px); pointer-events: none;
}

/* 用户气泡里的附件条 */
.bubble-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; justify-content: flex-end; }
.bubble-files img { width: 76px; height: 76px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); }
.bubble-files .bf-doc {
  display: inline-flex; align-items: center; gap: 5px; max-width: 190px;
  padding: 5px 9px; border-radius: 9px; font-size: 11.5px;
  background: rgba(77,107,254,.14); color: var(--brand);
}
.bubble-files .bf-doc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 继续输出 ---------- */
.continue-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 7px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--brand); color: var(--brand); background: rgba(77,107,254,.08);
  transition: background .15s;
}
.continue-btn:hover { background: rgba(77,107,254,.16); }
.continue-btn:disabled { opacity: .5; cursor: not-allowed; }
.msg__stopped { margin: 10px 0 0; font-size: 12.5px; color: var(--label-tertiary); font-style: italic; }

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  .attach-btn { width: 32px; height: 32px; }
  .effort-select { padding: 6px 18px 6px 8px; font-size: 11.5px; }
  .model-pick select { max-width: 118px; }
  .composer__files { gap: 6px; margin-bottom: 8px; }
  .file-chip { max-width: 190px; }
  .file-chip__thumb, .file-chip__ico { width: 32px; height: 32px; }
  .attach-menu { width: calc(100vw - 24px); left: 12px !important; }
  .bubble-files img { width: 62px; height: 62px; }
}

/* 隐藏的原生文件输入：保留可点击能力（部分 WebView 对 display:none 的 input 不弹选择器） */
.file-input {
  position: absolute; width: 1px; height: 1px; opacity: 0;
  overflow: hidden; clip: rect(0 0 0 0); pointer-events: none;
}


/* ============================================================
   V0.7.0 — 键入渐显动画
   ============================================================ */

/* 键入模式：最新一段流式文字从透明渐显到不透明 */
.fade-chunk { animation: dsb-fade-in .55s ease both; }
@keyframes dsb-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .fade-chunk { animation: none; }
}

/* 手机端输入栏：控件多，改为两行（模型/深度思考/键入 | 强度/附件/发送） */
.actions-break { display: none; }
@media (max-width: 768px) {
  .composer__actions { flex-wrap: wrap; row-gap: 7px; }
  .actions-break { display: block; flex-basis: 100%; height: 0; margin: 0; }
  .model-pick { flex: 0 1 auto; max-width: 132px; }
  .model-pick select { max-width: 132px; }
  #btnThinking { margin-left: auto; }
  .attach-btn { margin-left: auto; }
}


/* ============================================================
   V0.8.0 — 分支切换 < 2/2 >
   ============================================================ */

.branch-nav {
  display: inline-flex; align-items: center; gap: 1px;
  margin-top: 6px; color: var(--label-tertiary);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
  user-select: none;
}
.msg--user .branch-nav { margin-right: 2px; }
.branch-btn {
  width: 24px; height: 24px; padding: 0; border: none; border-radius: 50%;
  background: none; color: currentColor;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.branch-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--label-primary); }
.branch-btn:disabled { opacity: .28; cursor: default; }
.branch-idx { min-width: 30px; text-align: center; letter-spacing: .3px; }
.branch-nav .branch-spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .branch-nav { margin-top: 4px; font-size: 12px; }
  .branch-btn { width: 26px; height: 26px; }
}

.msg__user-col { display: flex; flex-direction: column; align-items: flex-end; min-width: 0; }

/* 用户消息列：限制整体宽度，气泡按内容自然撑开（避免被挤成窄条） */
.msg__user-col { max-width: 84%; }
.msg__user-col > .bubble-wrap { max-width: 100%; }
@media (max-width: 768px) {
  .msg__user-col { max-width: 86%; }
}
