:root{
  --bg:#ffffff;
  --page-bg:#f5f5f7;
  --text:#0f0f10;
  --text-2:#8b8b90;
  --text-3:#b6b6bb;
  --line:#ececee;
  --card:#ffffff;
  --blue:#4d6bfe;
  --blue-weak:#eef1ff;
  --danger:#f5222d;
  --user-bubble:#f2f3f5;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --r-card:24px;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#141416; --page-bg:#0e0e10; --text:#f2f2f4; --text-2:#9a9aa0; --text-3:#6d6d73;
    --line:#26262a; --card:#1c1c1f; --blue-weak:#232a45; --user-bubble:#26262b;
  }
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none !important}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--text);overflow:hidden;
  font:16px/1.6 -apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  -webkit-font-smoothing:antialiased;
}
button{font:inherit;color:inherit}

.screen{position:fixed;inset:0;display:flex;flex-direction:column;background:var(--bg)}
.screen[hidden]{display:none}

/* ---------- 顶栏 ---------- */
.appbar{
  display:flex;align-items:center;gap:4px;
  padding:calc(6px + var(--safe-t)) 10px 6px;
  background:var(--bg);
}
.bar-title{flex:1;text-align:center;font-size:15px;color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bar-btn{
  width:40px;height:40px;border:0;background:transparent;border-radius:12px;
  display:grid;place-items:center;cursor:pointer;color:var(--text);
}
.bar-btn:active{background:var(--line)}
.bar-btn svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.bar-btn.ghost{pointer-events:none}
.bar-btn.back{background:var(--card);border-radius:50%;width:36px;height:36px}

/* ---------- 聊天 ---------- */
.chat{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;position:relative}
.messages{padding:10px 16px 18px;display:flex;flex-direction:column;gap:20px}

.empty{
  position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:22px;pointer-events:none;padding-bottom:18vh;
}
.empty[hidden]{display:none}
.empty .logo{width:58px;height:58px;border-radius:16px}
.empty .hello{
  font-size:21px;letter-spacing:.06em;color:var(--text);
  font-weight:500;
}

.msg{display:flex;flex-direction:column;max-width:100%}
.msg.user{align-items:flex-end}
.msg .bubble{max-width:82%;word-break:break-word}
.msg.user .bubble{
  background:var(--user-bubble);padding:11px 15px;border-radius:20px;border-bottom-right-radius:6px;
  white-space:pre-wrap;
}
.msg.ai .bubble{max-width:100%;white-space:normal}
.msg.ai .bubble p{margin:0 0 12px}
.msg.ai .bubble p:last-child{margin-bottom:0}
.msg .imgs{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:6px;justify-content:flex-end}
.msg .imgs img{width:96px;height:96px;object-fit:cover;border-radius:14px}
.think{
  border:1px solid var(--line);border-radius:14px;padding:10px 12px;margin-bottom:10px;
  color:var(--text-2);font-size:14px;background:var(--bg);
}
.think summary{cursor:pointer;color:var(--text-2);list-style:none}
.think summary::-webkit-details-marker{display:none}
.think p{margin:8px 0 0;white-space:pre-wrap}

.msg.ai .bubble pre{background:var(--page-bg);padding:12px;border-radius:14px;overflow:auto;margin:10px 0;font:13px/1.55 ui-monospace,Menlo,monospace}
.msg.ai .bubble code{background:var(--page-bg);padding:1px 5px;border-radius:6px;font-size:14px}
.msg.ai .bubble pre code{background:none;padding:0}
.msg.ai .bubble h3{margin:14px 0 8px;font-size:17px}
.msg.ai .bubble ul,.msg.ai .bubble ol{margin:8px 0;padding-left:22px}
.msg.ai .bubble a{color:var(--blue)}
.msg.ai .bubble blockquote{margin:8px 0;padding-left:12px;border-left:3px solid var(--line);color:var(--text-2)}

.typing{display:inline-flex;gap:5px;align-items:center;height:20px}
.typing i{width:6px;height:6px;border-radius:50%;background:var(--text-3);animation:blink 1.2s infinite}
.typing i:nth-child(2){animation-delay:.2s}
.typing i:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,60%,100%{opacity:.25}30%{opacity:1}}

/* ---------- 输入卡片 ---------- */
.composer{padding:6px 12px calc(10px + var(--safe-b));background:var(--bg)}
.card{
  border:1px solid var(--line);border-radius:var(--r-card);background:var(--card);
  padding:14px 14px 10px;box-shadow:0 6px 24px rgba(0,0,0,.05);
}
.strip{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:10px}
.strip:empty{display:none}
.strip .thumb{position:relative;width:56px;height:56px;border-radius:12px;overflow:hidden;background:var(--page-bg)}
.strip .thumb img{width:100%;height:100%;object-fit:cover}
.strip .thumb button{
  position:absolute;top:2px;right:2px;width:18px;height:18px;border:0;border-radius:50%;
  background:rgba(0,0,0,.6);color:#fff;font-size:12px;line-height:16px;padding:0;cursor:pointer;
}
#input{
  width:100%;border:0;outline:none;resize:none;background:transparent;color:var(--text);
  font:inherit;line-height:1.5;max-height:132px;padding:2px 2px 8px;
}
#input::placeholder{color:var(--text-3)}
.card-bottom{display:flex;align-items:center;gap:6px}
.pill{
  display:inline-flex;align-items:center;gap:6px;padding:7px 13px;border-radius:999px;
  border:1px solid var(--line);background:transparent;color:var(--text);font-size:14px;cursor:pointer;
}
.pill svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.pill.on{border-color:var(--blue);color:var(--blue);background:var(--blue-weak)}
.card-right{margin-left:auto;display:flex;align-items:center;gap:6px}
.round{
  width:34px;height:34px;border:0;border-radius:50%;background:transparent;color:var(--text);
  display:grid;place-items:center;cursor:pointer;
}
.round:active{background:var(--line)}
.round svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.round.send{background:var(--blue);color:#fff}
.round.send svg{width:20px;height:20px;stroke:none}
.round.send svg.fill{fill:currentColor}

/* ---------- 设置页 ---------- */
.page{background:var(--page-bg)}
.pagebar{
  display:flex;align-items:center;padding:calc(6px + var(--safe-t)) 10px 8px;background:var(--page-bg);
}
.pagebar-title{flex:1;text-align:center;font-size:17px;font-weight:500}
.page-body{flex:1;overflow-y:auto;padding:4px 14px calc(30px + var(--safe-b))}
.group-label{font-size:13px;color:var(--text-3);margin:20px 6px 8px}
.group{background:var(--card);border-radius:16px;overflow:hidden}
.row{
  display:flex;align-items:center;gap:14px;padding:15px 16px;cursor:pointer;
  border-bottom:1px solid var(--line);
}
.row:last-child{border-bottom:0}
.row:active{background:var(--page-bg)}
.row .ico{width:22px;height:22px;color:var(--text);flex:none}
.row .ico svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.row .label{flex:1;font-size:16px}
.row .value{font-size:15px;color:var(--text-3);max-width:46%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .chev{width:18px;height:18px;color:var(--text-3)}
.row .chev svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.footer{text-align:center;color:var(--text-3);font-size:12px;line-height:1.9;margin-top:26px}

/* ---------- 抽屉 ---------- */
.mask{position:fixed;inset:0;background:rgba(0,0,0,.3);opacity:0;pointer-events:none;transition:.22s;z-index:20}
.mask.show{opacity:1;pointer-events:auto}
.drawer{
  position:fixed;top:0;bottom:0;left:0;width:82%;max-width:330px;background:var(--bg);
  transform:translateX(-102%);transition:transform .26s cubic-bezier(.22,.8,.3,1);z-index:21;
  display:flex;flex-direction:column;padding:calc(14px + var(--safe-t)) 12px calc(12px + var(--safe-b));
}
.drawer.show{transform:none;box-shadow:0 0 40px rgba(0,0,0,.16)}
.new-btn{
  width:100%;padding:12px;border-radius:14px;border:1px solid var(--line);background:var(--card);
  font-weight:600;cursor:pointer;
}
.drawer-head{padding:4px 2px 12px}
.drawer-nav{margin-bottom:14px}
.drawer-nav button{
  width:100%;display:flex;align-items:center;gap:10px;padding:12px;border:0;border-radius:12px;
  background:transparent;cursor:pointer;text-align:left;
}
.drawer-nav button:active{background:var(--page-bg)}
.drawer-nav svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.drawer-label{font-size:12px;color:var(--text-3);padding:6px 10px}
.conv-list{flex:1;overflow-y:auto;min-height:0}
.conv-item{display:flex;align-items:center;gap:8px;padding:12px 10px;border-radius:12px;cursor:pointer}
.conv-item:active{background:var(--page-bg)}
.conv-item.active{background:var(--blue-weak)}
.conv-item .t{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px}
.conv-item .del{border:0;background:transparent;color:var(--text-3);font-size:17px;padding:2px 6px;cursor:pointer}

/* ---------- 附件面板 ---------- */
.attach-sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:22;background:var(--bg);
  border-radius:22px 22px 0 0;transform:translateY(104%);transition:transform .26s cubic-bezier(.22,.8,.3,1);
  padding:14px 14px calc(16px + var(--safe-b));
}
.attach-sheet.show{transform:none}
.attach-recent{display:flex;gap:10px;overflow-x:auto;padding-bottom:16px;scrollbar-width:none}
.attach-recent::-webkit-scrollbar{display:none}
.attach-recent:empty{display:none}
.attach-recent img{width:78px;height:78px;object-fit:cover;border-radius:16px;flex:none;border:1px solid var(--line)}
.attach-actions{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.attach-actions button{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;
  padding:22px 8px;border:0;border-radius:20px;background:var(--page-bg);cursor:pointer;font-size:15px;
}
.attach-actions button:active{opacity:.75}
.attach-actions svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}

/* ---------- 通话 ---------- */
.call{
  position:fixed;inset:0;z-index:40;background:#0d0f14;color:#fff;display:none;
  flex-direction:column;align-items:center;padding:calc(40px + var(--safe-t)) 20px calc(28px + var(--safe-b));
}
.call.show{display:flex}
.call-bg{position:absolute;inset:0;background:radial-gradient(circle at 50% 18%,#2b3350 0%,#0d0f14 62%)}
.call-avatar,.call-name,.call-status,.call-transcript,.call-actions,.call-type{position:relative}
.call-avatar{
  width:104px;height:104px;border-radius:50%;background:rgba(255,255,255,.08);
  display:grid;place-items:center;font-size:50px;margin-bottom:18px;
}
.call-name{font-size:20px;font-weight:600}
.call-status{margin-top:6px;font-size:13px;color:rgba(255,255,255,.62)}
.call-transcript{flex:1;width:100%;overflow-y:auto;margin:20px 0;font-size:14px;line-height:1.7;display:flex;flex-direction:column;gap:10px;min-height:0}
.call-transcript .line{max-width:88%;padding:9px 13px;border-radius:14px;background:rgba(255,255,255,.08)}
.call-transcript .line.me{align-self:flex-end;background:rgba(109,134,255,.28)}
.call-actions{display:flex;gap:44px;align-items:center}
.call-btn{width:64px;height:64px;border-radius:50%;border:0;display:grid;place-items:center;cursor:pointer;background:rgba(255,255,255,.14);color:#fff}
.call-btn svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.call-btn.hangup{background:#ff4d4f}
.call-btn.active{background:#6d86ff}
.call-type{margin-top:18px;border:0;background:transparent;color:rgba(255,255,255,.6);font:inherit;cursor:pointer}

/* ---------- 表单 ---------- */
.form{padding:18px 18px 26px}
.form h3{margin:0 0 18px;font-size:20px}
.field{margin-bottom:16px}
.field label{display:block;font-size:13px;color:var(--text-2);margin-bottom:7px}
.field input,.field textarea,.field select{
  width:100%;padding:13px 14px;border-radius:14px;border:1px solid var(--line);
  background:var(--card);color:var(--text);font:inherit;outline:none;
}
.field textarea{min-height:120px;resize:vertical}
.field input:focus,.field textarea:focus,.field select:focus{border-color:var(--blue)}
.actions{display:flex;gap:10px;margin-top:20px}
.actions button{flex:1;padding:13px;border-radius:14px;border:1px solid var(--line);background:var(--card);cursor:pointer}
.actions button.primary{background:var(--blue);border-color:var(--blue);color:#fff}
.actions button.danger{color:var(--danger)}

.toast{
  position:fixed;left:50%;bottom:110px;transform:translate(-50%,10px);background:rgba(0,0,0,.84);
  color:#fff;padding:9px 16px;border-radius:20px;font-size:13px;opacity:0;pointer-events:none;
  transition:.24s;z-index:60;max-width:80vw;text-align:center;
}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ---- 修正：按钮不换行、发送键隐藏、输入区留白 ---- */
.pill{white-space:nowrap;flex:0 0 auto;padding:7px 11px;font-size:13.5px;gap:5px}
.card-bottom{gap:6px}
#input{min-height:30px;padding-bottom:10px}
.chat{min-height:0}
.composer{flex:0 0 auto;padding-bottom:calc(12px + var(--safe-b))}