:root {
  --bg: #faf9f5; --surface: #ffffff; --drawer: #f3f1ea; --line: #e6e2d8; --line-2: #d9d4c7;
  --text: #1f1e1d; --text-2: #5e5d59; --text-3: #8f8b82;
  --accent: #c96442; --accent-press: #b5573a; --accent-soft: #f5e4dc;
  --bubble: #efede6; --code: #f2f0e9; --danger: #b3412f; --ok: #4f8a5b; --warn: #c98a2c;
  --shadow: 0 1px 2px rgba(31, 30, 29, .04), 0 6px 24px rgba(31, 30, 29, .06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino", "Songti SC", "Noto Serif SC", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --top: env(safe-area-inset-top); --bottom: env(safe-area-inset-bottom);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624; --surface: #30302e; --drawer: #1f1e1d; --line: #3a3936; --line-2: #4a4945;
    --text: #f0efea; --text-2: #c2c0b6; --text-3: #8f8c84;
    --accent: #d97757; --accent-press: #c96442; --accent-soft: #3d2c25;
    --bubble: #393937; --code: #2b2a28; --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 28px rgba(0, 0, 0, .28);
  }
}
:root[data-theme="dark"] {
  --bg: #262624; --surface: #30302e; --drawer: #1f1e1d; --line: #3a3936; --line-2: #4a4945;
    --text: #f0efea; --text-2: #c2c0b6; --text-3: #8f8c84;
    --accent: #d97757; --accent-press: #c96442; --accent-soft: #3d2c25;
    --bubble: #393937; --code: #2b2a28; --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 28px rgba(0, 0, 0, .28);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.6 var(--font); -webkit-text-size-adjust: 100%; touch-action: manipulation; }
/* 页面本身不滚动（iOS 弹键盘时会把页面往上推，固定住再由脚本贴着可视区域） */
body { position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
.md, .bubble, textarea, input, pre, code { -webkit-user-select: text; user-select: text; }
#app { position: fixed; left: 0; right: 0; top: 0; height: 100dvh; display: flex; flex-direction: column; will-change: transform; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.top { flex: none; display: flex; align-items: center; gap: 4px; padding: calc(var(--top) + 6px) 8px 6px; background: var(--bg); position: relative; z-index: 3; }
.top .ib { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--text-2); }
.top .ib:active { background: var(--bubble); }
.top .ttl { flex: 1; min-width: 0; display: flex; justify-content: center; }
.top .ttl button { max-width: 100%; display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 10px; font-size: 15.5px; font-weight: 600; }
.top .ttl button:active { background: var(--bubble); }
.top .ttl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .ttl svg.i { width: 16px; height: 16px; color: var(--text-3); }
.banner { flex: none; margin: 0 12px 6px; padding: 7px 12px; border-radius: 10px; font-size: 13px; background: var(--bubble); color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.banner.bad { background: rgba(179, 65, 47, .1); color: var(--danger); }

/* ---------- 消息区 ---------- */
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.thread { max-width: 760px; margin: 0 auto; padding: 8px 18px 28px; }
.m-user { display: flex; flex-direction: column; align-items: flex-end; margin: 18px 0 6px; }
.m-user .bubble { background: var(--bubble); padding: 10px 15px; border-radius: 20px; max-width: 85%; white-space: pre-wrap; word-break: break-word; font-size: var(--msg-fs, 16px); line-height: 1.55; }
.m-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; max-width: 85%; }
.fchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 12.5px; color: var(--text-2); max-width: 220px; }
.fchip img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.fchip .fi { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--bubble); color: var(--text-3); }
.fchip .fi svg.i { width: 16px; height: 16px; }
.fchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-ai { margin: 14px 0 4px; }
.md { word-break: break-word; font-size: var(--msg-fs, 16px); line-height: 1.68; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3 { font-size: 17px; margin: 18px 0 8px; line-height: 1.4; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 12px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 0 0 12px; padding-left: 12px; border-left: 3px solid var(--line-2); color: var(--text-2); }
.md pre { position: relative; background: var(--code); padding: 12px 14px; border-radius: 12px; overflow-x: auto; font: 13px/1.55 var(--mono); margin: 0 0 12px; }
.md code { font: 14px var(--mono); background: var(--code); padding: 1px 5px; border-radius: 5px; }
.md pre code { background: none; padding: 0; font-size: 13px; }
.md .cp { position: absolute; top: 6px; right: 6px; padding: 3px 8px; border-radius: 7px; font-size: 12px; color: var(--text-3); background: var(--surface); border: 1px solid var(--line); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 14px; margin: 0 0 12px; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.md th { background: var(--code); }
.md a { color: var(--accent); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.m-err { color: var(--danger); font-size: 14px; margin: 6px 0; padding: 10px 12px; border-radius: 12px; background: rgba(179, 65, 47, .08); }
.m-acts { display: flex; gap: 2px; margin-top: 4px; color: var(--text-3); }
.m-acts button { width: 34px; height: 30px; display: grid; place-items: center; border-radius: 8px; }
.m-acts button:active { background: var(--bubble); }
.m-acts svg.i { width: 17px; height: 17px; }
.m-time { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.more { display: block; margin: 8px auto 0; color: var(--text-3); font-size: 13px; padding: 6px 14px; border-radius: 10px; }
.more:active { background: var(--bubble); }

/* 工具步骤：连续的几步收成一行，点开看每一步 */
.steps { margin: 6px 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.steps > .sh { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; font-size: 14px; color: var(--text-2); }
.steps > .sh .sl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps > .sh .chev { transition: transform .2s; color: var(--text-3); }
.steps.open > .sh .chev { transform: rotate(90deg); }
.steps .ico { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--bubble); color: var(--text-2); flex: none; }
.steps .ico svg.i { width: 15px; height: 15px; }
.steps .sb { display: none; border-top: 1px solid var(--line); padding: 4px 0; }
.steps.open .sb { display: block; }
.step { padding: 7px 12px 7px 14px; }
.step .row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.step .row b { font-weight: 500; flex: none; }
.step .row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 12.5px var(--mono); color: var(--text-3); }
.step .st { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ok); }
.step .st.err { background: var(--danger); }
.step .st.running { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.step pre { margin: 6px 0 2px 16px; padding: 8px 10px; border-radius: 9px; background: var(--code); font: 11.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow: auto; color: var(--text-2); }
@keyframes pulse { 50% { opacity: .35; } }

/* 提问和计划卡片 */
.card { margin: 10px 0 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.card.live { border-color: var(--accent); }
.card .ch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.card .ch svg.i { width: 17px; height: 17px; color: var(--accent); }
.card .ch em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--text-3); }
.card .q { font-weight: 600; margin: 10px 0 8px; font-size: 15px; }
.opts { display: flex; flex-direction: column; gap: 7px; }
.opt { text-align: left; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 15px; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt small { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.acts { display: flex; gap: 8px; margin-top: 12px; }
.btn { flex: 1; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 15px; text-align: center; }
.btn:active { background: var(--bubble); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-press); }
.btn.danger { color: var(--danger); }
.plan-body { max-height: 46vh; overflow-y: auto; padding: 2px 2px 0; }

/* 正在回复：Claude 的星芒 */
.thinking { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; color: var(--text-3); font-size: 14px; }
.spark { color: var(--accent); }
.spark.live { animation: spark 2.4s ease-in-out infinite; }
@keyframes spark { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(45deg) scale(.86); } 100% { transform: rotate(90deg) scale(1); } }
.tobottom { position: absolute; right: 16px; bottom: 100%; margin-bottom: 10px; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text-2); }

/* ---------- 首页（新对话） ---------- */
.home { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 24px 40px; text-align: center; }
.home h1 { font: 400 30px/1.25 var(--serif); margin: 14px 0 6px; letter-spacing: -.2px; }
.home p { margin: 0; color: var(--text-3); font-size: 14px; }
.home .ctx { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 13.5px; color: var(--text-2); max-width: 100%; }
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill svg.i { width: 15px; height: 15px; color: var(--text-3); }
.pill:active { background: var(--bubble); }

/* ---------- 输入卡片 ---------- */
.composer { flex: none; position: relative; padding: 6px 12px calc(var(--bottom) + 10px); background: linear-gradient(to bottom, transparent, var(--bg) 14px); }
.cbox { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; }
.atts { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
.att { position: relative; flex: none; width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--line); background: var(--bubble); overflow: hidden; display: grid; place-items: center; font-size: 10.5px; color: var(--text-3); text-align: center; }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att .nm { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 4px; background: rgba(0, 0, 0, .45); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .pg { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .35); color: #fff; font-size: 13px; font-weight: 600; }
.att .pg.err { background: rgba(179, 65, 47, .75); font-size: 11px; padding: 4px; }
.att .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; }
.att .x svg.i { width: 12px; height: 12px; stroke-width: 2.2; }
.cbox textarea { display: block; width: 100%; border: 0; outline: none; resize: none; background: none; padding: 4px 2px 6px; font-size: 16px; line-height: 1.5; max-height: 170px; }
.cbox textarea::placeholder { color: var(--text-3); }
.crow { display: flex; align-items: center; gap: 6px; }
.crow .cb { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; color: var(--text-2); flex: none; }
.crow .cb:active { background: var(--bubble); }
.crow .cb svg.i { width: 19px; height: 19px; }
.crow .tag { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 500; }
.crow .tag svg.i { width: 15px; height: 15px; }
.crow .grow { flex: 1; }
.crow .model { display: inline-flex; align-items: center; gap: 3px; padding: 6px 8px; border-radius: 10px; font-size: 13.5px; color: var(--text-2); max-width: 46%; }
.crow .model span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crow .model svg.i { width: 14px; height: 14px; color: var(--text-3); }
.crow .model:active { background: var(--bubble); }
.send { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; flex: none; transition: opacity .15s; }
.send:disabled { opacity: .35; }
.send.stop { background: var(--text); color: var(--bg); }
.send svg.i { width: 18px; height: 18px; stroke-width: 2.2; }
.slash { position: absolute; left: 12px; right: 12px; bottom: 100%; max-width: 760px; margin: 0 auto 6px; max-height: 44vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 6px; }
.slash button { width: 100%; text-align: left; padding: 8px 10px; border-radius: 10px; display: block; }
.slash button:active, .slash button.on { background: var(--bubble); }
.slash b { font: 500 14px var(--mono); }
.slash small { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 抽屉（对话列表） ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 18, 14, .32); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 360px); background: var(--drawer); z-index: 21; transform: translateX(-102%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; padding-top: var(--top); box-shadow: 8px 0 30px rgba(0, 0, 0, .08); }
.drawer.on { transform: none; }
.dh { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; }
.dh b { font: 400 20px var(--serif); flex: 1; }
.dsearch { margin: 2px 14px 8px; display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 40px; border-radius: 12px; background: var(--bubble); color: var(--text-3); }
.dsearch input { flex: 1; border: 0; outline: none; background: none; font-size: 15px; color: var(--text); }
.dsearch svg.i { width: 17px; height: 17px; }
.dnew { margin: 0 14px 6px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; font-weight: 500; color: var(--accent); }
.dnew:active { background: var(--bubble); }
.dlist { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.dsec { padding: 14px 10px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .3px; }
.ditem { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 11px; text-align: left; }
.ditem.on { background: var(--bubble); }
.ditem:active { background: var(--bubble); }
.ditem .t { flex: 1; min-width: 0; }
.ditem .t b { display: block; font-weight: 400; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ditem .t span { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ditem .run { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; flex: none; }
.ditem .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.ditem .dot.error { background: var(--danger); } .ditem .dot.ask, .ditem .dot.plan { background: var(--warn); }
@keyframes rot { to { transform: rotate(360deg); } }
.dfoot { border-top: 1px solid var(--line); padding: 10px 16px calc(var(--bottom) + 10px); font-size: 13px; color: var(--text-2); }
.dfoot .pc { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 0; }
.dfoot .pc .st { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dfoot .pc .st.on { background: var(--ok); }
.dfoot .pc b { font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--text-3); }
.quota .bar { height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; }
.quota .bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.quota .bar i.warn { background: var(--warn); } .quota .bar i.full { background: var(--danger); }
.quota small { grid-column: 2 / -1; margin-top: -3px; }

/* ---------- 底部弹层 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; background: rgba(20, 18, 14, .32); animation: fade .2s; }
.sheet { background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 14px calc(var(--bottom) + 14px); max-height: 86dvh; overflow-y: auto; animation: up .26s cubic-bezier(.2, .8, .2, 1); }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 2px auto 10px; }
.sheet h3 { margin: 2px 6px 10px; font-size: 16px; }
.sheet .sub { margin: -6px 6px 12px; font-size: 13px; color: var(--text-3); }
.sheet .li { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 12px; text-align: left; font-size: 15.5px; }
.sheet .li:active { background: var(--bubble); }
.sheet .li .tx { flex: 1; min-width: 0; }
.sheet .li .tx small { display: block; font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .li .ck { color: var(--accent); }
.sheet .li.danger { color: var(--danger); }
.sheet .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.sheet .seg { display: flex; gap: 6px; padding: 4px 6px 6px; flex-wrap: wrap; }
.sheet .seg button { flex: 1; min-width: 52px; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; }
.sheet .seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sheet .label { margin: 12px 8px 6px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.sheet input.tf, .sheet textarea.tf { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); outline: none; font-size: 16px; }
.sheet textarea.tf { font: 13px/1.5 var(--mono); min-height: 110px; resize: none; }
.sheet .acts { padding: 0 2px; }
.sw { width: 44px; height: 26px; border-radius: 13px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.sw.on { background: var(--accent); }
.sw.on::after { transform: translateX(18px); }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { background: transparent; } }

/* ---------- 配对 ---------- */
.pair { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(var(--top) + 30px) 28px calc(var(--bottom) + 30px); text-align: center; }
.pair h1 { font: 400 28px/1.3 var(--serif); margin: 18px 0 8px; }
.pair p { color: var(--text-2); margin: 0 0 26px; font-size: 15px; max-width: 340px; }
.pair .btn { width: 100%; max-width: 320px; flex: none; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; margin-bottom: 10px; }
.pair ol { text-align: left; color: var(--text-3); font-size: 13.5px; max-width: 320px; padding-left: 20px; margin: 18px 0 0; }
.scan { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; flex-direction: column; }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan .frame { position: absolute; left: 50%; top: 46%; width: min(68vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
.scan .frame::before { content: ''; position: absolute; inset: 0; border-radius: 24px; border: 2px solid rgba(255, 255, 255, .9); }
.scan .tip { position: absolute; left: 0; right: 0; top: calc(46% + min(34vw, 150px) + 24px); color: #fff; text-align: center; font-size: 15px; padding: 0 30px; }
.scan .close { position: absolute; top: calc(var(--top) + 12px); right: 14px; width: 42px; height: 42px; border-radius: 50%; background: rgba(255, 255, 255, .18); color: #fff; display: grid; place-items: center; }
.scan .alt { position: absolute; left: 50%; bottom: calc(var(--bottom) + 30px); transform: translateX(-50%); color: #fff; padding: 11px 20px; border-radius: 999px; background: rgba(255, 255, 255, .18); font-size: 15px; white-space: nowrap; }

.toast { position: fixed; left: 50%; top: calc(var(--top) + 60px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 86%; box-shadow: var(--shadow); animation: fade .2s; }
.empty { text-align: center; color: var(--text-3); font-size: 14px; padding: 30px 10px; }

/* 等你做选择 */
.ditem.waiting { box-shadow: inset 3px 0 0 var(--warn); animation: pend-glow 1.6s ease-in-out infinite; }
@keyframes pend-glow { 0%, 100% { background-color: transparent; } 50% { background-color: rgba(201, 138, 44, .2); } }
.ditem .ptag { flex: none; font-style: normal; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 9px; color: var(--warn); background: rgba(201, 138, 44, .15); }
.top .ib.alert { position: relative; }
.top .ib.alert::after { content: ''; position: absolute; top: 9px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 2px var(--bg); animation: pend-dot 1.2s ease-in-out infinite; }
.pend { flex: none; display: flex; align-items: center; gap: 8px; margin: 0 12px 6px; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 500; text-align: left; color: var(--warn); background: rgba(201, 138, 44, .12); border: 1px solid rgba(201, 138, 44, .3); }
.pend span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pend i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; animation: pend-dot 1.2s ease-in-out infinite; }
.pend svg.i { width: 16px; height: 16px; }
@keyframes pend-dot { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .ditem.waiting, .pend i, .top .ib.alert::after { animation: none; } }

.dlist, .drawer { overflow-x: hidden; }
.scroll::-webkit-scrollbar, .dlist::-webkit-scrollbar, .atts::-webkit-scrollbar { display: none; }
.md pre { padding-right: 58px; }

/* 抽屉：服务器切换和设置入口 */
.dh .ib { margin-left: auto; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--text-2); }
.dh .ib:active { background: var(--bubble); }
.dsrv { margin: 0 14px 8px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.dsrv span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dsrv svg.i { width: 17px; height: 17px; color: var(--text-3); }
.dsrv:active { background: var(--bubble); }
.drawer, .sheet, .page { touch-action: pan-y; }

/* 思考强度滑动条 */
.eff { margin: 14px 6px 4px; padding: 14px 14px 10px; border-radius: 14px; background: var(--bg); touch-action: none; }
.eff-h { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); margin-bottom: 16px; }
.eff-h b { color: var(--accent); font-weight: 600; }
.eff-track { position: relative; height: 6px; border-radius: 3px; background: var(--line); margin: 0 10px; }
.eff-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); transition: width .12s; }
.eff-track i { position: absolute; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--surface); opacity: .9; }
.eff-knob { position: absolute; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25), 0 0 0 1px rgba(0, 0, 0, .04); transition: left .12s; }
.eff-labels { position: relative; height: 18px; margin: 14px 10px 0; font-size: 12px; color: var(--text-3); }
.eff-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.eff-labels span.on { color: var(--accent); font-weight: 600; }
.eff-tip { margin: 12px 0 0; font-size: 12px; color: var(--text-3); text-align: center; }

/* 设置页 */
.page { position: fixed; inset: 0; z-index: 25; background: var(--bg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: -8px 0 30px rgba(0, 0, 0, .08); }
.page.on { transform: none; }
.pbody { flex: 1; overflow-y: auto; padding: 4px 16px calc(var(--bottom) + 24px); }
.psec { margin: 18px 6px 8px; font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.pgroup { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.prow { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 14px; text-align: left; font-size: 15.5px; border-top: 1px solid var(--line); }
.pgroup > .prow:first-child { border-top: 0; }
button.prow:active { background: var(--bubble); }
.prow svg.i { width: 20px; height: 20px; color: var(--text-2); }
.prow .pt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pv { flex: none; max-width: 52%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.prow svg.pc { width: 16px; height: 16px; color: var(--text-3); }
.prow.danger, .prow.danger svg.i { color: var(--danger); }
.prow.col { flex-direction: column; align-items: stretch; gap: 10px; }
.prow .prt { display: flex; align-items: center; gap: 12px; }
.pseg { display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: var(--bubble); }
.pseg button { flex: 1; padding: 7px 4px; border-radius: 9px; font-size: 14px; color: var(--text-2); }
.pseg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.dotst { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.dotst.on { background: var(--ok); }
.pfoot { text-align: center; font-size: 12px; color: var(--text-3); margin: 24px 0 0; line-height: 1.7; }

/* 工具步骤的详情：命令和输出、子助手的步骤、后台任务 */
.steps > .sh > i.st { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; flex: none; }
button.step { width: 100%; text-align: left; display: block; }
button.step:active { background: var(--bubble); }
.step .row em.bg { flex: none; font-style: normal; font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--bubble); color: var(--text-3); }
.step .row .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .2s; }
.step.open .row .chev { transform: rotate(90deg); }
.sd { margin: 0 12px 8px 30px; display: flex; flex-direction: column; gap: 6px; }
.sd pre { margin: 0; padding: 9px 11px; border-radius: 10px; background: var(--code); font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; max-height: 300px; overflow: auto; color: var(--text-2); -webkit-user-select: text; user-select: text; }
.sd pre.sh-cmd { color: var(--text); }
.sd pre.sh-cmd span { color: var(--accent); font-weight: 600; }
.sd-p { font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; }
.sd-p.mono { font: 12px var(--mono); }
.sd-m { font-size: 12px; color: var(--text-3); }
.sd-sub { border-left: 2px solid var(--line); padding-left: 10px; display: flex; flex-direction: column; gap: 4px; }
.sd-sub .row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.sd-sub .row b { font-weight: 500; flex: none; }
.sd-sub .row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11.5px var(--mono); color: var(--text-3); }
.sd-sub .st { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--ok); }
.sd-sub .st.err { background: var(--danger); } .sd-sub .st.running { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.sd-more { font-size: 11.5px; color: var(--text-3); }
.sd-txt { padding: 8px 10px; border-radius: 10px; background: var(--bubble); }
.sd-txt .md { font-size: 13.5px; }
.sd-task { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.sd-task .st { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sd-task .st.running { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }

/* 回复里的文件链接、本轮生成的文件 */
.flink { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 1px 7px 1px 5px; margin: 0 1px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font: 500 .92em var(--font); vertical-align: baseline; word-break: break-all; text-align: left; }
.flink svg.i { width: 15px; height: 15px; }
.flink span { overflow: hidden; text-overflow: ellipsis; }
.outs { margin: 10px 0 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.outs-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13.5px; color: var(--text-2); border-bottom: 1px solid var(--line); }
.outs-h svg.i { width: 17px; height: 17px; color: var(--accent); }
.outs-h em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--text-3); }
.orow { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; text-align: left; border-top: 1px solid var(--line); }
.outs-h + .orow { border-top: 0; }
.orow:active { background: var(--bubble); }
.orow .oi { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.orow .oi svg.i { width: 17px; height: 17px; }
.orow .on { flex: 1; min-width: 0; }
.orow .on b { display: block; font-weight: 500; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow .on small { display: block; font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow .os { font-size: 12px; color: var(--text-3); flex: none; }
.orow svg.chev { width: 15px; height: 15px; color: var(--text-3); }
.outs-o { padding: 8px 12px; font-size: 12px; color: var(--text-3); border-top: 1px solid var(--line); }

/* 文件预览 */
.viewer { position: fixed; inset: 0; z-index: 35; background: var(--bg); display: flex; flex-direction: column; transform: translateY(100%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
.viewer.on { transform: none; }
.viewer .top { border-bottom: 1px solid var(--line); }
.viewer .ib:disabled { opacity: .35; }
.vbody { flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; }
.vload, .vmsg { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px; text-align: center; color: var(--text-2); font-size: 14px; }
.vmsg svg.i { width: 40px; height: 40px; color: var(--text-3); }
.vmsg b { font-size: 16px; color: var(--text); word-break: break-all; }
.vimg { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; touch-action: pinch-zoom pan-x pan-y; }
.vimg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.vbody video { width: 100%; max-height: 100%; background: #000; margin: auto 0; }
.vbody audio { width: calc(100% - 32px); margin: 0 16px 30px; }
.vbody iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.vtip { flex: none; padding: 8px 14px calc(var(--bottom) + 8px); font-size: 12px; color: var(--text-3); text-align: center; border-top: 1px solid var(--line); }
.vtext { padding: 16px 18px calc(var(--bottom) + 24px); -webkit-user-select: text; user-select: text; }
.vtext pre { margin: 0; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; }
.vtext table { border-collapse: collapse; font-size: 13px; }
.vtext th, .vtext td { border: 1px solid var(--line); padding: 4px 8px; white-space: nowrap; }
.vact { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 30px calc(var(--bottom) + 40px); font-size: 12.5px; color: var(--text-3); }
.vact .btn { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; }
