/* niceidea.online/txt —— 对话页样式。
   设计 token 与 /image/ 站保持一致，两站来回切不会有断层感。 */

:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --line: #e6e4df;
  --line-soft: #f4f3f0;
  --text: #1f1f1d;
  --muted: #7a7873;
  --faint: #a9a7a2;
  --accent: #1f6feb;
  --accent-soft: #eaf2fe;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --radius: 14px;
  --side-w: 264px;          /* 桌面侧栏宽度（原 220px，过窄导致会话名大量省略） */
  --content-w: 840px;       /* 正文 / 附件托盘 / 输入框 / 底部提示 共用同一宽度，保证永远左右对齐 */
  --dur: 200ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

/* 整页永远不滚动：对话区内部滚动，输入栏钉死在底部。
   缺了 overflow:hidden 时，任何溢出都会把整页撑开、把输入栏顶出屏幕外 */
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button { font: inherit; }
.hidden { display: none !important; }

/* ---------- 骨架 ---------- */

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

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  position: relative;
}

/* ---------- 侧栏 ---------- */

.side {
  width: var(--side-w);
  flex: none;
  background: #fbfbfa;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
  gap: 10px;
}

.side-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.logo { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.logo span { color: var(--accent); }

.new-chat { width: 100%; padding: 9px 0; font-size: 14px; border-radius: 10px; }

.chat-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 -2px;
  padding: 0 2px;
}

.chat-group {
  font-size: 11px;
  color: var(--faint);
  padding: 10px 8px 4px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  color: #5f5e5a;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chat-item:hover { background: #f2f1ee; }
.chat-item.on { background: var(--accent-soft); color: var(--accent); }
.chat-item .t {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item .acts { display: none; gap: 4px; flex: none; }
.chat-item:hover .acts, .chat-item.on .acts { display: flex; }
.chat-item .mini {
  border: none;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  line-height: 0;
}
.chat-item .mini:hover { color: var(--accent); background: #fff; }

.side-ft { border-top: 1px solid var(--line); padding-top: 10px; }

.userbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.userbox .avatar {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500;
}
.userbox .uname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .btn { flex: none; }

.side-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(31, 31, 29, .42);
  animation: fade-in 240ms var(--ease);
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
  background: var(--card);
  position: relative;   /* 给「更多」菜单做定位基准 */
}
.spacer { flex: 1; }

/* 窄屏顶栏中间的会话标题 */
.session-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 模型胶囊：模型选择 + 计费倍率合成一个控件，视觉上是一体的 */
.pill-slot { display: flex; min-width: 0; }
.model-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 0 8px 0 0;
  min-width: 0;
  transition: border-color var(--dur) var(--ease);
}
.model-pill:focus-within { border-color: var(--accent); }
/* select 的边框由外层胶囊负责，自身透明无边框 */
.model-pill .model-pick { display: flex; min-width: 0; }
.model-pill select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  border: none;
  background: transparent;
  outline: none;
  padding: 6px 4px 6px 9px;
  max-width: 42vw;
  min-width: 0;
}
.pill-sep { width: 1px; height: 16px; flex: none; background: var(--line); }
.model-pill .rate {
  font-style: normal;
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
  padding: 0 2px 0 6px;
  cursor: help;
}

/* 顶栏「更多」菜单（窄屏承载 清空对话 / 复制回复 / 积分中心） */
.menu {
  position: absolute;
  top: calc(100% - 2px);
  right: 12px;
  z-index: 20;
  min-width: 168px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  animation: fade-up 140ms var(--ease);
}
.menu-item {
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 9px 11px;
  cursor: pointer;
}
.menu-item:hover { background: var(--line-soft); color: var(--accent); }

.model-pick select:focus { border-color: var(--accent); }

.balance {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  border-radius: 6px;
  padding: 3px 8px;
  transition: background var(--dur) var(--ease);
  cursor: pointer;
}
.balance b { color: var(--accent); font-weight: 500; }
.balance:hover { background: var(--accent-soft); }
.balance.flash { animation: flash 400ms var(--ease); }

.icon-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 7px;
  cursor: pointer;
  line-height: 0;
  flex: none;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--accent); border-color: var(--line); }
.only-mobile { display: none; }
.only-desktop { display: inline-flex; }

/* ---------- 消息流 ---------- */

.stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}
.stream > * { width: 100%; max-width: var(--content-w); margin: 0 auto; }

.msg { display: flex; gap: 10px; }
.msg.user { justify-content: flex-end; animation: slide-in-right 180ms var(--ease); }
.msg.ai { animation: fade-up 200ms ease-out; }

.msg.user .body {
  max-width: 76%;
  background: var(--accent-soft);
  border-radius: 13px 13px 4px 13px;
  padding: 10px 13px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.ai .avatar {
  width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 500;
  margin-top: 2px;
}
.msg.ai .body { flex: 1; min-width: 0; }

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
  font-size: 11px;
  color: var(--faint);
  flex-wrap: wrap;
}
.meta .cost { color: var(--accent); }
.meta button {
  border: none; background: transparent; color: var(--faint);
  cursor: pointer; padding: 0; font-size: 11px;
}
.meta button:hover { color: var(--accent); }

/* 正文里的 Markdown 元素 */
.body p { margin: 0 0 9px; }
.body p:last-child { margin-bottom: 0; }
.body h3 { font-size: 15px; font-weight: 500; margin: 14px 0 7px; }
.body h4 { font-size: 14px; font-weight: 500; margin: 12px 0 6px; }
.body ul, .body ol { margin: 0 0 9px; padding-left: 20px; }
.body li { margin: 3px 0; }
.body a { color: var(--accent); }
.body blockquote {
  margin: 0 0 9px; padding: 2px 0 2px 11px;
  border-left: 2px solid var(--line); color: var(--muted);
}
.body code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px;
  background: var(--line-soft);
  border-radius: 4px;
  padding: 1px 5px;
}
.body hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.body table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 0; }
.body th, .body td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.body th { background: var(--line-soft); font-weight: 500; }

/* 表格横向滚动容器。窄屏（360-430px）下 5 列表格只剩 300px 出头，
   不设 min-width 会把中文压成逐字折行；设了则由这里横向滚动，保持可读。 */
.table-wrap {
  margin: 0 0 9px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table { min-width: 100%; }
.table-wrap th, .table-wrap td { min-width: 72px; white-space: nowrap; }
/* 滚动条细一点，别在浅色正文里显得笨重 */
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.code-wrap {
  position: relative;
  margin: 0 0 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.code-wrap pre {
  margin: 0;
  padding: 11px 12px;
  overflow-x: auto;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.65;
}
.code-wrap code { background: none; padding: 0; font-size: inherit; }
.code-wrap .copy {
  position: absolute;
  top: 6px; right: 6px;
  font-size: 11px;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), color var(--dur) var(--ease);
}
.code-wrap:hover .copy { opacity: 1; }
.code-wrap .copy:hover { color: var(--accent); }

.think {
  border-left: 2px solid var(--line);
  padding-left: 10px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 13px;
}
.think > summary {
  cursor: pointer;
  list-style: none;
  color: var(--faint);
  font-size: 12px;
  user-select: none;
}
.think > summary::-webkit-details-marker { display: none; }
.think > summary::before { content: "▸ "; }
.think[open] > summary::before { content: "▾ "; }
.think .inner { white-space: pre-wrap; margin-top: 6px; }

.cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  vertical-align: -2px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

.dots { display: inline-flex; gap: 3px; align-items: center; }
.dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--faint);
  animation: bounce 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: 120ms; }
.dots i:nth-child(3) { animation-delay: 240ms; }

.notice {
  font-size: 12px;
  border-radius: 8px;
  padding: 7px 10px;
  white-space: pre-wrap;
}
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: #fdf3e3; color: #8a5a0b; }
.notice.sensitive { background: #fdf3e3; color: #8a5a0b; }

/* 错误条展开动画 */
.expand { display: grid; grid-template-rows: 0fr; animation: expand 220ms var(--ease) forwards; }
.expand > div { overflow: hidden; }

.empty { text-align: center; padding: 34px 0 10px; color: var(--muted); }
.empty h1 { font-size: 20px; font-weight: 500; margin: 0 0 6px; color: var(--text); }
.empty p { margin: 0 0 18px; font-size: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  font-size: 13px;
  color: var(--muted);
  background: #f4f3f0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip:hover { color: var(--accent); background: var(--accent-soft); border-color: #cfe0fb; }

.to-bottom {
  position: absolute;
  bottom: 132px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 12px;
  color: var(--accent);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  animation: fade-up 200ms ease-out;
}

/* ---------- 输入区 ---------- */

.composer {
  flex: none;
  border-top: 1px solid var(--line);
  background: #fcfcfb;
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom, 0px));
}
.composer-box {
  max-width: var(--content-w);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 10px;
  transition: border-color var(--dur) var(--ease);
}
.composer-box:focus-within { border-color: var(--accent); }
.composer-box textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  max-height: 40vh;   /* 跟 autoGrow 的取值同源，软键盘弹出时不会顶满屏幕 */
  background: transparent;
  padding: 0;
  color: var(--text);
}
.composer-ft {
  max-width: var(--content-w);
  margin: 7px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--faint);
}
.composer-ft .disclaimer { margin-left: auto; flex: none; }
/* 计费提示可能较长，允许省略号收尾而不是把整行撑宽 */
.composer-ft #costHint { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 读图警告单独一行：原本拼在 #costHint 里，40+ 字一行在 360px 下必然溢出 */
.composer-warn {
  max-width: var(--content-w);
  margin: 6px auto 0;
  font-size: 11px;
  line-height: 1.5;
  color: #c2410c;
  background: #fdf3e3;
  border-radius: 7px;
  padding: 5px 9px;
  word-break: break-word;
}
/* ---------- 附件（图片 / 文档）---------- */

.composer.dragover .composer-box { border-color: var(--accent); border-style: dashed; }

.attach-btn {
  flex: none;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--faint);
  cursor: pointer;
  padding: 0;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.attach-btn:hover { color: var(--accent); border-color: var(--accent); }

/* 待发送附件区 */
.attach-tray {
  max-width: var(--content-w);
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* 窄屏时模型胶囊落在这里（输入框上方独立一行） */
.mobile-modelbar {
  max-width: var(--content-w);
  margin: 0 auto 8px;
  display: flex;
}
.mobile-modelbar .model-pill { max-width: 100%; }
.mobile-modelbar select { max-width: 44vw; }
.att {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 240px;
  padding: 5px 24px 5px 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11px;
}
.att.busy { opacity: .6; }
.att img {
  width: 38px; height: 38px; flex: none;
  object-fit: cover;
  border-radius: 6px;
  background: var(--line-soft);
}
.att-ic {
  width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}
.att-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* 压缩包卡片宽一点：包内统计（N 字 · N 张图）比单个文件名长 */
.att.zip { max-width: 280px; }
.att.zip .att-ic { background: #eef3ff; color: #2f5fd0; }
.att-meta b {
  font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.att-meta em { font-style: normal; color: var(--faint); }
.att-x {
  position: absolute;
  top: 2px; right: 4px;
  border: none; background: transparent;
  color: var(--faint);
  font-size: 15px; line-height: 1;
  cursor: pointer; padding: 2px;
}
.att-x:hover { color: #c2410c; }

/* 消息气泡里的附件 */
.msg-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.msg.user .msg-atts { max-width: 76%; margin-left: auto; }
.msg-att-img {
  max-width: 190px;
  max-height: 190px;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: zoom-in;
  display: block;
}
.msg-att-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11px;
}
.msg-att-doc b { font-weight: 500; }
.msg-att-doc em { font-style: normal; color: var(--faint); }

/* ---------- 按钮 ---------- */

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 8px 18px;
  cursor: pointer;
  transition: filter var(--dur) var(--ease), background var(--dur) var(--ease);
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { background: #c9c7c2; cursor: not-allowed; filter: none; }
.btn.send { padding: 8px 16px; flex: none; }
.btn.send.stop { background: #5f5e5a; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn.small { font-size: 12px; padding: 5px 12px; border-radius: 7px; }

/* ---------- 登录弹窗 ---------- */

.mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(31, 31, 29, .42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 180ms var(--ease);
}
.auth-card {
  width: 340px;
  max-width: 100%;
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: scale-in 180ms ease-out;
}
.auth-card h2 { font-size: 18px; font-weight: 500; margin: 0; }
.auth-tip { margin: 0; font-size: 13px; color: var(--muted); }
.tabs { display: flex; gap: 6px; background: #f4f3f0; border-radius: 10px; padding: 4px; }
.tab {
  flex: 1;
  font: inherit;
  font-size: 14px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 0;
  cursor: pointer;
}
.tab.on { background: #fff; color: var(--text); font-weight: 500; }
.fld { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.fld.col { flex-direction: column; align-items: stretch; gap: 5px; }
.fld.col input {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  background: #fcfcfb;
  color: var(--text);
}
.fld.col input:focus { border-color: var(--accent); background: #fff; }
.auth-err { margin: 0; font-size: 13px; color: var(--danger); background: var(--danger-soft); border-radius: 8px; padding: 8px 10px; }
.auth-card .ghost { border: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 8px; }
.auth-card .ghost:hover { color: var(--accent); }

/* ---------- 积分中心 ---------- */

.wallet {
  width: 420px;
  max-width: 100%;
  max-height: min(86vh, 720px);
  background: var(--card);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scale-in 180ms ease-out;
}
.wallet-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.wallet-hd h2 { font-size: 17px; font-weight: 500; margin: 0; }
.wallet-body { overflow-y: auto; padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 18px; }

.wb-card {
  background: var(--accent);
  color: #fff;
  border-radius: 13px;
  padding: 15px 16px 13px;
}
.wb-balance { display: flex; align-items: baseline; gap: 5px; }
.wb-balance b { font-size: 30px; font-weight: 500; line-height: 1.1; }
.wb-balance em { font-style: normal; font-size: 13px; opacity: .85; }
.wb-cny { font-size: 12px; opacity: .8; margin-top: 3px; }
.wb-stats { display: flex; gap: 18px; margin-top: 12px; padding-top: 11px; border-top: 1px solid rgba(255,255,255,.22); }
.wb-stats div { display: flex; flex-direction: column; gap: 1px; }
.wb-stats span { font-size: 11px; opacity: .78; }
.wb-stats b { font-size: 13px; font-weight: 500; }

.wb-sec-hd {
  font-size: 13px; font-weight: 500; color: var(--text);
  margin-bottom: 9px; display: flex; align-items: center; gap: 8px;
}
.link-btn { border: none; background: none; color: var(--accent); font-size: 12px; cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

.redeem-row { display: flex; gap: 8px; }
.redeem-row input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; outline: none; background: #fcfcfb;
  text-transform: uppercase; letter-spacing: .04em;
}
.redeem-row input:focus { border-color: var(--accent); background: #fff; }
.redeem-row .btn { flex: none; padding: 8px 18px; }
.redeem-msg {
  margin: 9px 0 0; font-size: 13px; line-height: 1.6;
  border-radius: 8px; padding: 8px 11px;
}
.redeem-msg.ok { background: #eaf6ef; color: #1a7f4b; }
.redeem-msg.err { background: var(--danger-soft); color: var(--danger); }

.ledger-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; }
.ledger-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}
.ledger-item:last-child { border-bottom: none; }
.ledger-item .lt { flex: 1; min-width: 0; }
.ledger-item .lt .r1 { color: var(--text); }
.ledger-item .lt .r2 { color: var(--faint); font-size: 11px; margin-top: 1px; }
.ledger-item .amt { flex: none; font-weight: 500; }
.ledger-item .amt.plus { color: #1a7f4b; }
.ledger-item .bal { flex: none; color: var(--faint); font-size: 11px; width: 62px; text-align: right; }
.ledger-empty { color: var(--faint); font-size: 13px; padding: 14px 0; text-align: center; }

.wb-help p { margin: 0 0 5px; font-size: 13px; color: var(--text); line-height: 1.65; }
.wb-help p.muted { color: var(--muted); font-size: 12px; margin: 0; }

/* ---------- 轻提示 ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  font-size: 13px;
  color: #fff;
  background: rgba(31, 31, 29, .9);
  border-radius: 999px;
  padding: 8px 16px;
  animation: fade-up 200ms ease-out;
}

/* ---------- 关键帧 ---------- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes scale-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes flash { 0% { background: transparent; } 35% { background: var(--accent-soft); } 100% { background: transparent; } }
@keyframes expand { from { grid-template-rows: 0fr; opacity: 0; } to { grid-template-rows: 1fr; opacity: 1; } }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }

/* ---------- 响应式 ----------
   分档原则：按「可用宽度」决定形态，不按设备判断。
   关键是把两件事拆开 ——
     ① 侧栏形态（抽屉 vs 常驻）：<900px 一律抽屉，保持原有交互不变；
     ② 排版档位（S/M/L/XL）：各自独立，640px 处单独切换。
   之前两者绑在同一个 900px 断点里，导致 640-899px 明明有空间却沿用手机排版。 */

/* 窄屏通用：抽屉侧栏 + 移动端元素上屏 */
@media (max-width: 899px) {
  .only-mobile { display: inline-flex; }
  .only-desktop { display: none; }
  .side {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 40;
    width: 240px;
    transform: translateX(-100%);
    transition: transform 240ms var(--ease);
    box-shadow: 0 0 0 1px var(--line);
  }
  .side.open { transform: none; }
}

/* S 档（360-639）：顶栏只留 汉堡 + 标题 + ⋯，模型胶囊移到输入框上方 */
@media (max-width: 639px) {
  .topbar { padding: 9px 10px; gap: 8px; }
  .pill-slot { display: none; }        /* 胶囊由 JS 挪进 #mobileModelBar */
  .session-title { flex: 1; }
  .balance { font-size: 12px; padding: 3px 5px; }
  /* 左右内边距必须与 .composer 一致（10px），否则正文列与输入框会差 2px 错开 */
  .stream { padding: 16px 10px 8px; gap: 15px; }
  .composer { padding-left: 10px; padding-right: 10px; }
  .composer-box { padding: 8px 8px; gap: 8px; }
  .msg.user .body { max-width: 88%; }
  .composer-ft { font-size: 10.5px; }
  .composer-ft .disclaimer { display: none; }   /* 屏太窄，免责声明让位给计费预估 */
  .to-bottom { bottom: 148px; }
  /* 附件卡在窄屏改单列铺满，避免两张卡挤成半截 */
  .att { max-width: 100%; }
}

/* M 档（640-899）：空间够了，余额留在顶栏，胶囊仍在输入框上方 */
@media (min-width: 640px) and (max-width: 899px) {
  .session-title { flex: 1; }
  .stream { padding: 18px 16px 8px; }
  .msg.user .body { max-width: 86%; }
  .to-bottom { bottom: 140px; }
}

/* L 档（900-1279）：侧栏常驻，顶栏完整，正文中等宽度 */
@media (min-width: 900px) and (max-width: 1279px) {
  :root { --side-w: 236px; --content-w: 760px; }
}

/* XL 档（≥1280）：内容加宽，减少大屏空置 */
@media (min-width: 1280px) {
  :root { --content-w: 840px; }
}

/* 减少动态效果：全局降级为无动画（View Transitions 需单独覆盖，见下） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
