:root {
  --bg: #f4f4f1; --panel: #fff; --text: #1d1f23; --soft: #33363c; --muted: #8a8d93; --border: #e7e6e1; --line: rgba(0, 0, 0, 0.06);
  --accent: #2f6fde; --accent-soft: rgba(47, 111, 222, 0.1); --accent-text: #fff; --user: #2f6fde; --user-text: #fff; --danger: #d0453a; --ok: #1d7a3e;
  --code-bg: rgba(31, 35, 40, 0.06); --code-text: #24292f; --code-block-bg: #fafaf8; --table-head: #f6f6f4; --hover: #efeee9;
  --tk-kw: #cf222e; --tk-str: #0a3069; --tk-com: #6e7781; --tk-num: #0550ae; --tk-fn: #8250df; --tk-type: #953800; --tk-attr: #116329;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --app-h: 100dvh;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616; --panel: #222221; --text: #ecebe7; --soft: #d4d3ce; --muted: #8f8e89; --border: #333331; --line: rgba(255, 255, 255, 0.07);
    --accent: #5b8ff0; --accent-soft: rgba(91, 143, 240, 0.16); --user: #3a6fd8; --code-bg: rgba(255, 255, 255, 0.08); --code-text: #e6e5e0; --code-block-bg: #1c1c1b; --table-head: #2a2a29; --hover: #2b2b2a;
    --tk-kw: #ff7b72; --tk-str: #a5d6ff; --tk-com: #8b949e; --tk-num: #79c0ff; --tk-fn: #d2a8ff; --tk-type: #ffa657; --tk-attr: #7ee787;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* 整页固定不动，只让内容区自己滚（避免微信 / Safari 里整页被拖动、回弹） */
html, body { margin: 0; position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.view { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); display: flex; flex-direction: column; overflow: hidden; }

/* 顶栏 */
.bar { display: flex; align-items: center; gap: 4px; min-height: 52px; padding: calc(var(--safe-t) + 4px) 6px 4px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-bottom: 1px solid var(--line); flex: none; z-index: 2; }
.bar > b { padding-left: 10px; font-size: 17px; }
.bar .sp, .sp { flex: 1; }
.bar .title { flex: 1; min-width: 0; text-align: center; line-height: 1.3; border: none; background: none; padding: 2px 4px; border-radius: 10px; }
.bar .title:active { background: var(--hover); }
#switchHint { width: 14px; height: 14px; margin-left: 2px; flex: none; }
.bar .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; font-weight: 600; }
.bar .title span { display: inline-flex; align-items: center; max-width: 100%; font-size: 12px; color: var(--muted); }
.bar .title #deviceName { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link { border: none; background: none; color: var(--accent); padding: 8px 10px; font-size: 15px; display: inline-flex; align-items: center; border-radius: 10px; }
.link:active { background: var(--hover); }
.bar .link svg { width: 22px; height: 22px; }
.link.danger { color: var(--danger); }
.dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-right: 5px; }
.dot.on { background: #22a559; box-shadow: 0 0 0 3px rgba(34, 165, 89, 0.15); }
.pad { padding: 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }

/* 登录 / 配对 / 空状态 */
.center-card { margin: auto; width: min(380px, 100%); text-align: center; padding: 24px 24px calc(24px + var(--safe-b)); }
.center-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.logo { display: block; width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 16px; box-shadow: 0 6px 20px rgba(47, 111, 222, 0.3); }
h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: 0.2px; }
/* 输入框必须 ≥16px，否则 iPhone 点进去会自动放大页面 */
input, textarea, select { font-size: 16px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; outline: none; min-width: 0; width: 100%; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.primary { background: var(--accent); color: var(--accent-text); border: none; border-radius: 12px; padding: 13px; font-size: 16px; font-weight: 600; width: 100%; }
.primary:active { filter: brightness(0.94); }
.primary:disabled { opacity: 0.6; }
.ghost { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 18px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.badge { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.badge svg { width: 30px; height: 30px; }
.center-card > b, .empty > b { display: block; font-size: 18px; margin-bottom: 6px; }
.pair-code { font: 600 36px/1.2 var(--mono); letter-spacing: 8px; margin: 22px 0 10px; padding: 14px 0 14px 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; }
.empty { text-align: center; padding: 48px 16px; }
.empty .ghost { margin-top: 8px; }
.device { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; width: 100%; text-align: left; box-shadow: var(--shadow); }
.device:active { background: var(--hover); }
.device .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.device .ic svg { width: 24px; height: 24px; }
.device .tx { flex: 1; min-width: 0; }
.device b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.device small { color: var(--muted); display: inline-flex; align-items: center; }
.device .chev { color: var(--muted); font-size: 20px; }

/* 对话 */
.log { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 16px 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.msg { margin: 0 0 16px; overflow-wrap: anywhere; }
.msg.user { background: var(--user); color: var(--user-text); padding: 9px 14px; border-radius: 20px 20px 6px 20px; width: fit-content; max-width: 84%; margin-left: auto; white-space: pre-wrap; }
.msg.user .att { display: block; font-size: 12.5px; opacity: 0.8; margin-top: 4px; }
.msg.assistant { color: var(--soft); line-height: 1.75; }
.msg.assistant p { margin: 0 0 0.6em; }
.msg.assistant > :last-child { margin-bottom: 0; }
.msg.assistant b { color: var(--text); }
.msg.assistant .h { color: var(--text); font-weight: 650; margin: 0.9em 0 0.4em; }
.msg.assistant .h1 { font-size: 1.25em; } .msg.assistant .h2 { font-size: 1.15em; } .msg.assistant .h3 { font-size: 1.05em; }
.msg.assistant ul, .msg.assistant ol { margin: 0.2em 0 0.7em; padding-left: 1.4em; }
.msg.assistant code { background: var(--code-bg); color: var(--code-text); padding: 0.1em 0.35em; border-radius: 4px; font: 0.86em var(--mono); }
.msg.assistant blockquote { margin: 0.4em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
.msg.assistant a { color: var(--accent); }
.msg.assistant img { max-width: 100%; border-radius: 10px; }
.msg.assistant .table-wrap { overflow-x: auto; margin: 0.5em 0 1em; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.msg.assistant table { border-collapse: collapse; width: 100%; font-size: 0.9em; }
.msg.assistant th, .msg.assistant td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.msg.assistant th { background: var(--table-head); white-space: nowrap; }
.msg .code { margin: 0.5em 0 1em; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-block-bg); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 0 12px; font-size: 11.5px; color: var(--muted); }
.code-copy { border: none; background: none; color: var(--muted); font-size: 12px; }
.msg .code pre { margin: 0; padding: 6px 12px 12px; overflow-x: auto; font: 12.5px/1.6 var(--mono); color: var(--code-text); }
.msg .code pre code { background: none; padding: 0; font: inherit; }
.tk-kw { color: var(--tk-kw); } .tk-str { color: var(--tk-str); } .tk-com { color: var(--tk-com); font-style: italic; } .tk-num { color: var(--tk-num); } .tk-fn { color: var(--tk-fn); } .tk-type { color: var(--tk-type); } .tk-attr { color: var(--tk-attr); }
.tool { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 7px 10px; margin: 0 0 8px; }
.tool .nm { color: var(--soft); font-weight: 600; flex: none; }
.tool .ar { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 12px; }
.tool .dl { flex: none; border: none; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; padding: 3px 10px; border-radius: 8px; }
.tool .st { flex: none; width: 14px; text-align: center; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.confirm { background: var(--panel); border: 1.5px solid var(--accent); border-radius: 16px; padding: 14px; margin: 0 0 14px; box-shadow: var(--shadow); }
.confirm b { display: block; margin-bottom: 6px; }
.confirm pre { margin: 0 0 12px; max-height: 220px; overflow: auto; font: 12px/1.5 var(--mono); background: var(--code-block-bg); border-radius: 8px; padding: 8px; white-space: pre-wrap; }
.confirm .add { color: var(--ok); } .confirm .del { color: var(--danger); }
.confirm .btns { display: flex; gap: 10px; }
.confirm .btns button { flex: 1; padding: 11px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); font-weight: 600; }
.confirm .btns .yes { background: var(--accent); color: #fff; border-color: var(--accent); }
.confirm.done { border-color: var(--border); box-shadow: none; opacity: 0.75; }
.status { font-size: 13px; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.sys { text-align: center; font-size: 12.5px; color: var(--muted); margin: 6px 0 12px; }
.sys.err { color: var(--danger); }

/* 新对话的欢迎页 */
.hero { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding: 12px 4px 20px; }
.hero .logo { width: 56px; height: 56px; border-radius: 16px; margin: 0 0 18px; }
.hero h2 { font-size: 24px; line-height: 1.3; margin: 0 0 6px; font-weight: 650; }
.hero .sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; display: flex; align-items: center; }
.hero .sub span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sugs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sug { text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; font-size: 14px; line-height: 1.45; color: var(--soft); box-shadow: var(--shadow); }
.sug:active { background: var(--hover); }
.sug i { display: block; font-style: normal; font-size: 18px; margin-bottom: 6px; }
.hero .note { display: flex; align-items: center; gap: 6px; margin-top: 22px; font-size: 12.5px; color: var(--muted); }
.hero .note svg { width: 14px; height: 14px; flex: none; }

/* 输入区 */
.composer { flex: none; padding: 6px 12px calc(10px + var(--safe-b)); background: linear-gradient(to bottom, transparent, var(--bg) 14px); }
.composer .box { background: var(--panel); border: 1px solid var(--border); border-radius: 24px; padding: 6px; box-shadow: var(--shadow); }
.composer .box:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.composer .row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { flex: 1; resize: none; max-height: 140px; border: none; background: none; box-shadow: none; border-radius: 0; padding: 7px 4px; line-height: 1.45; }
.icon { border: none; background: none; color: var(--muted); width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon:active { background: var(--hover); }
.icon svg, .send svg { width: 20px; height: 20px; }
.send { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.send svg { stroke-width: 2.4; }
.send.stop svg { display: none; }
.send.stop::before { content: ""; width: 12px; height: 12px; background: #fff; border-radius: 3px; }
.send:disabled { opacity: 0.5; }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 4px 6px; }
.files span { font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 3px 4px 3px 8px; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.files span em { font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.files button { border: none; background: none; color: var(--muted); padding: 0 4px; }

/* 对话列表抽屉 */
.drawer { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 20; display: flex; }
.drawer-panel { width: min(84vw, 340px); background: var(--panel); display: flex; flex-direction: column; padding-top: var(--safe-t); animation: slide 0.2s ease-out; box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12); }
.drawer-mask { flex: 1; background: rgba(0, 0, 0, 0.3); animation: fade 0.2s; }
@keyframes slide { from { transform: translateX(-100%); } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { display: flex; align-items: center; padding: 14px 8px 10px 18px; }
.drawer-head b { font-size: 18px; }
.search { margin: 0 12px 8px; width: auto; padding: 9px 12px; background: var(--bg); border-color: transparent; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px; overscroll-behavior: contain; }
.conv { display: block; width: 100%; text-align: left; border: none; background: none; padding: 10px 12px; border-radius: 12px; }
.conv:active, .conv.active { background: var(--hover); }
.conv b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv small { color: var(--muted); }
.conv .run { color: var(--accent); }
.drawer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); }
.drawer-foot .ghost { padding: 8px 16px; font-size: 14px; }
.drawer-foot .small { font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: rgba(20, 20, 20, 0.88); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 86vw; text-align: center; }
#pairBack { font-size: 28px; line-height: 1; padding: 4px 12px 8px; }

.device { cursor: pointer; }
.device.off { box-shadow: none; }
.device.off .ic { background: var(--hover); color: var(--muted); }
.device.off b { color: var(--soft); }
.device .forget { flex: none; border: none; background: none; color: var(--muted); font-size: 20px; width: 32px; height: 32px; border-radius: 50%; }
.device .forget:active { background: var(--hover); }

.device.cur { border-color: var(--accent); }
.device .check { color: var(--accent); font-weight: 700; padding: 0 4px; }
.sheet { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.3); animation: fade 0.2s; }
.sheet-panel { position: relative; background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + var(--safe-b)); max-height: 70%; overflow-y: auto; animation: up 0.22s ease-out; }
@keyframes up { from { transform: translateY(100%); } }
.sheet-grip { width: 36px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 12px; }
.sheet-title { display: block; font-size: 16px; margin: 0 4px 12px; }
.wx-tip { display: flex; align-items: flex-start; gap: 10px; text-align: left; font-size: 13px; line-height: 1.5; color: #8a5a00; background: #fff6e0; border: 1px solid #f3dfa8; border-radius: 12px; padding: 10px 12px; margin-bottom: 16px; }
.wx-tip button { flex: none; border: none; background: none; color: var(--accent); font-size: 13px; font-weight: 600; padding: 0; }
@media (prefers-color-scheme: dark) { .wx-tip { color: #f0c96a; background: #2e2716; border-color: #4a3d1c; } }

/* 新对话的文件夹选择（可选） */
.ws-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; margin: 0 4px 6px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); }
.ws-chip svg { width: 14px; height: 14px; flex: none; }
.ws-chip select { border: none; background: none; padding: 4px 6px; width: auto; min-width: 0; max-width: 70vw; font-size: 16px; color: var(--soft); box-shadow: none; }

/* ---------- 输入框上方：模型、文件夹 ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .ws-chip { margin: 0; flex: none; max-width: 70%; }
.chips .ws-chip select { max-width: 52vw; text-overflow: ellipsis; }

/* ---------- 消息操作：复制、重新发送 ---------- */
.msg-acts { display: flex; gap: 2px; margin: -12px 0 12px; }
.msg-acts.right { justify-content: flex-end; }
.msg-acts button { border: none; background: none; color: var(--muted); width: 32px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.msg-acts button:active { background: var(--hover); }
.msg-acts svg { width: 15px; height: 15px; }
.msg.note { width: fit-content; max-width: 90%; margin: 0 auto 14px; font-size: 12.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; }
.msg.from-expert { border-left: 3px solid #d97757; padding-left: 12px; }
.expert-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: #b8603f; margin-bottom: 4px; }
.expert-tag svg, .expert-bar svg { width: 13px; height: 13px; color: #d97757; }
.expert-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: -4px 0 16px; font-size: 12.5px; color: var(--muted); }
.expert-bar .eb-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.expert-bar button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--soft); font-size: 13px; }
.expert-bar button:disabled { opacity: .5; }
.expert-bar .eb-more { padding: 6px 10px; }

/* ---------- 抽屉：额度、菜单 ---------- */
.quota { margin: 0 12px 10px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.quota .q-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 13px; }
.quota .q-top span { color: var(--muted); font-size: 12px; }
.quota .q-bar { height: 5px; border-radius: 3px; background: var(--border); margin-top: 8px; overflow: hidden; }
.quota .q-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.quota.low .q-bar i { background: var(--danger); }
.drawer-menu { padding: 0 8px 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 10px; border: none; background: none; border-radius: 10px; font-size: 14.5px; color: var(--text); text-align: left; }
.menu-item:active { background: var(--hover); }
.menu-item svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.menu-item span { flex: 1; }
.menu-item input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.drawer-menu .hint { padding: 0 10px 6px 38px; color: var(--muted); line-height: 1.5; }
.conv { position: relative; padding-right: 40px; }
.conv .conv-more { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--muted); font-size: 18px; }
.conv .conv-more:active { background: var(--panel); }

/* ---------- 底部操作面板 ---------- */
.sheet-act { display: block; width: 100%; padding: 14px 16px; margin-bottom: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); font-size: 15px; color: var(--text); text-align: center; }
.sheet-act.danger { color: var(--danger); }
.sheet-act:active { background: var(--hover); }

/* ---------- 浏览文件 ---------- */
#filesView .bar .title span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sp { width: 44px; flex: none; }
.file-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: none; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.file-row:active { background: var(--hover); }
.file-row .fi { font-size: 22px; width: 28px; text-align: center; flex: none; }
.file-row .fn { flex: 1; min-width: 0; }
.file-row .fn b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .fn small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.file-row .chev { color: var(--muted); font-size: 20px; }
.files-loading { display: flex; justify-content: center; padding: 40px; }
#filesList .empty { padding: 40px 16px; text-align: center; }

/* 待发送的图片缩略图 */
.files span img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }

/* ---------- 新图标：图片自带形状，不要圆角和投影 ---------- */
img.logo { border-radius: 0 !important; box-shadow: none !important; width: 76px !important; height: 76px !important; object-fit: contain; }
.hero img.logo { width: 64px !important; height: 64px !important; }

/* ---------- 抽屉底部：断开连接 / 取消授权 ---------- */
.drawer-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.foot-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel); color: var(--soft); font-size: 14px; font-weight: 500; }
.foot-btn svg { width: 16px; height: 16px; flex: none; }
.foot-btn:active { background: var(--hover); }
.foot-btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: color-mix(in srgb, var(--danger) 6%, var(--panel)); }
.foot-btn.danger:active { background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }

/* ---------- 二次确认弹框 ---------- */
.dlg { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; }
.dlg-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); animation: fade 0.15s; }
.dlg-box { position: relative; width: min(340px, 100%); background: var(--panel); border-radius: 20px; padding: 22px 20px 16px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); animation: dlg-in 0.18s ease-out; }
@keyframes dlg-in { from { opacity: 0; transform: scale(0.94); } }
.dlg-ic { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.dlg-ic:empty { display: none; }
.dlg-ic.danger { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.dlg-ic svg { width: 24px; height: 24px; }
.dlg-box > b { display: block; font-size: 17px; margin-bottom: 6px; }
.dlg-box > p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.dlg-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-btns button { padding: 12px; border-radius: 12px; font-size: 15px; font-weight: 600; border: 1px solid var(--border); background: var(--panel); color: var(--text); }
.dlg-btns button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.dlg-btns button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---------- 浏览文件：分组标题、底部按钮 ---------- */
.files-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 14px 4px 6px; }
.files-group:first-child { padding-top: 2px; }
.files-foot { flex: none; padding: 10px 16px calc(10px + var(--safe-b)); background: var(--panel); border-top: 1px solid var(--line); }
.files-foot .primary { width: 100%; }

/* ---------- 长时间不操作的锁屏 ---------- */
.lock { position: fixed; left: 0; right: 0; top: 0; height: var(--app-h); z-index: 55; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); animation: fade .2s; }
.lock-box { width: min(340px, 100%); text-align: center; }
.lock-box .logo { margin: 0 auto 16px; }
.lock-box > b { display: block; font-size: 20px; margin-bottom: 8px; }
.lock-box > p { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 0 0 22px; }
.lock-box .primary { width: 100%; }

/* 上下文用量标签 */
.ctx-chip { padding: 5px 10px; font-size: 13px; }
.ctx-chip svg { width: 15px; height: 15px; transform: rotate(-90deg); }
.ctx-chip circle { fill: none; stroke-width: 2.6; }
.ctx-chip .bg { stroke: rgba(127,127,127,.25); }
.ctx-chip .fg { stroke: #3b82f6; stroke-linecap: round; }
.ctx-chip.warn .fg { stroke: #f59e0b; }
.ctx-chip.hot .fg { stroke: #ef4444; }

/* 会员与客服 */
.sup { display: flex; flex-direction: column; gap: 8px; padding-bottom: calc(24px + var(--safe-b)); }
.sup-h { font-weight: 600; margin: 14px 2px 2px; }
.sup-card { background: var(--panel); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.sup-card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0; }
.sup-card .price { font-size: 20px; font-weight: 700; }
.sup-card .desc { color: var(--muted); font-size: 13px; }
.sup-card button.small, .sup-btn { flex: none; white-space: nowrap; border: 1px solid var(--border); background: var(--panel); border-radius: 10px; padding: 6px 12px; font-size: 14px; }
.sup-card button.buy { flex: none; white-space: nowrap; background: var(--accent); color: var(--accent-text); border: none; border-radius: 10px; padding: 8px 16px; font-weight: 600; }
.sup-imgs { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.sup-imgs figure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.sup-imgs img { width: 150px; height: 150px; object-fit: contain; background: #fff; border-radius: 10px; display: block; margin-bottom: 4px; }
.sup-tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); white-space: nowrap; }
.sup-tag.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.sup-tag.bad { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.sup-result { margin-top: 8px; font-size: 14px; }
.sup-chat { display: flex; flex-direction: column; gap: 8px; }
.sup-chat .m { max-width: 86%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.sup-chat .m.u { align-self: flex-end; background: var(--user); color: var(--user-text); }
.sup-chat .m.a { align-self: flex-start; background: var(--panel); box-shadow: var(--shadow); }
.sup-ask { display: flex; gap: 8px; margin-top: 4px; }
.sup-ask input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--panel); }
.sup-ask .primary { width: auto; padding: 10px 16px; font-size: 15px; }
.sup-no { font-family: ui-monospace, Menlo, monospace; border-bottom: 1px dashed var(--muted); cursor: pointer; }
.sup-step { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.sup-way { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.wx-id { font-family: ui-monospace, Menlo, monospace; user-select: all; }
.sup-sorry { background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; font-size: 13px; color: var(--soft); }

/* ---------- 会员与客服：三个切页、精简的套餐卡片、付款面板、收款码放大 ---------- */
@media (prefers-color-scheme: dark) { :root { --muted: #a3a29c; } }
.sup-tabs { display: flex; gap: 4px; margin: 0 14px; padding: 4px; background: var(--hover); border-radius: 12px; flex: none; }
.sup-tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 4px; font-size: 14.5px; font-weight: 600; color: var(--muted); position: relative; }
.sup-tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.sup-badge { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; margin-left: 5px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-style: normal; vertical-align: 1px; }
.sup-quota .row b { font-size: 16px; }
.sup-left { font-size: 13px; color: var(--accent); font-weight: 600; white-space: nowrap; }
.sup-seg { display: flex; gap: 4px; padding: 4px; background: var(--hover); border-radius: 12px; margin-top: 6px; }
.sup-seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 7px 4px; font-size: 14px; color: var(--muted); }
.sup-seg button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.sup-seg em { font-style: normal; font-size: 11px; color: var(--ok); margin-left: 4px; }
.sup-plans { display: flex; flex-direction: column; gap: 10px; }
.plan-card { background: var(--panel); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); border: 1.5px solid transparent; }
.plan-card.hot { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.plan-card.pack { margin-top: 10px; }
.pc-top { display: flex; align-items: center; gap: 8px; }
.pc-top b { font-size: 17px; }
.pc-top .spacer { flex: 1; }
.pc-top .price { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.pc-top .price small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.pc-line { margin-top: 6px; font-size: 14.5px; font-weight: 600; color: var(--soft); }
.pc-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.plan-card .hl-num { color: var(--accent); font-weight: 700; }
.plan-card .hl-model { color: var(--text); font-weight: 600; }
.plan-card .hl-deal { color: #d9480f; font-weight: 600; }
@media (prefers-color-scheme: dark) { .plan-card .hl-deal { color: #ff9b5e; } }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.plan-card button.buy { flex: none; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 10px; padding: 8px 20px; font-weight: 600; font-size: 14.5px; }
.plan-card button.buy.ghost { background: var(--accent-soft); color: var(--accent); }
.sup-tag.hot { background: color-mix(in srgb, #e8590c 14%, transparent); color: #e8590c; }
.sup-note { font-size: 12.5px; color: var(--muted); margin: 12px 4px 0; line-height: 1.6; }
.sup-sheet { position: absolute; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; animation: sheet-up .22s ease-out; }
.sup-sheet .bar { justify-content: space-between; }
.sup-sheet .sheet-x { margin-left: auto; }
.sup-sheet .sup { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sup-no-big { font-family: var(--mono); font-size: 15px; font-weight: 600; word-break: break-all; }
.step-h { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.step-h i { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-style: normal; font-size: 13px; font-weight: 700; display: grid; place-items: center; flex: none; }
.step-h b { font-size: 15.5px; }
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 12px 0 6px; }
.qr-box img.qr { width: 220px; max-width: 70vw; height: auto; border-radius: 12px; background: #fff; display: block; cursor: zoom-in; -webkit-touch-callout: default; }
.qr-btns { display: flex; justify-content: center; gap: 10px; }
.qr-viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.qr-viewer img { width: min(86vw, 420px); height: auto; border-radius: 14px; background: #fff; -webkit-touch-callout: default; user-select: auto; }
.qr-viewer p { color: rgba(255, 255, 255, .82); font-size: 14px; text-align: center; max-width: 420px; margin: 0; line-height: 1.6; }
.qr-acts { display: flex; gap: 12px; width: min(86vw, 420px); }
.qr-acts .primary { flex: 1; }
.ghost-btn { flex: 1; border: 1px solid rgba(255, 255, 255, .3); background: transparent; color: #fff; border-radius: 12px; padding: 13px; font-size: 16px; }

/* 任务清单 */
.plan-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px 8px; margin: 0 0 10px; font-size: 14px; }
.plan-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.plan-card ul { list-style: none; margin: 0; padding: 0; }
.plan-card li { display: flex; align-items: flex-start; gap: 9px; padding: 4px 0; line-height: 1.45; }
.plan-card li i { flex: none; width: 15px; height: 15px; margin-top: 2px; border-radius: 50%; border: 1.6px solid var(--muted); box-sizing: border-box; position: relative; }
.plan-card li.completed { color: var(--muted); }
.plan-card li.completed span { text-decoration: line-through; }
.plan-card li.completed i { border-color: var(--accent); background: var(--accent); }
.plan-card li.completed i::after { content: ''; position: absolute; left: 4px; top: 1.2px; width: 3px; height: 7px; border: solid #fff; border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); }
.plan-card li.in_progress { font-weight: 600; }
.plan-card li.in_progress i { border-color: var(--accent); border-right-color: transparent; animation: plan-spin .8s linear infinite; }
.plan-card.idle li.in_progress i { animation: none; border-right-color: var(--accent); background: var(--accent-soft); }
.plan-card.all-done .plan-head span:last-child { color: var(--accent); }
@keyframes plan-spin { to { transform: rotate(360deg); } }
.sup-expire { font-size: 12.5px; color: #c76a16; margin-top: 4px; }

/* 兑换码 */
.sup-redeem { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 12px; font-size: 14px; }
.sup-redeem input { flex: 1; min-width: 160px; height: 36px; border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 10px; padding: 0 10px; font-family: var(--mono); text-transform: uppercase; }
.sup-redeem-msg { width: 100%; font-size: 13px; color: var(--muted); }
.sup-redeem-msg:empty { display: none; }
.sup-redeem-msg.ok { color: var(--ok); }
.sup-redeem-msg.bad { color: var(--danger); }

/* 数学公式（KaTeX 输出的 MathML）、待办列表 */
math { font-family: 'STIX Two Math', 'Cambria Math', 'Latin Modern Math', math; font-size: 1.08em; }
.math-block { margin: 8px 0; overflow-x: auto; overflow-y: hidden; }
.math-block math { display: block; }
li.task-item { list-style: none; margin-left: -1.1em; }
.katex-error { color: inherit !important; opacity: .7; }
