:root{
  --bg:#f6f7f9; --panel:#fff; --ink:#16181d; --muted:#6b7280;
  --line:#e4e6eb; --me:#2f6df6; --me-ink:#fff; --bot:#fff;
  --accent:#2f6df6; --ok:#22a06b; --bad:#e0453c;
}
@media (prefers-color-scheme:dark){
  :root{
    --bg:#111317; --panel:#181b21; --ink:#e8eaed; --muted:#9aa0a6;
    --line:#2a2e36; --bot:#1f232b;
  }
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font:16px/1.55 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;
  display:flex; flex-direction:column;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header{
  display:flex; align-items:center; gap:12px; padding:10px 14px;
  background:var(--panel); border-bottom:1px solid var(--line); flex-wrap:wrap;
}
.brand{font-weight:700; display:flex; align-items:center; gap:8px}
.brand-logo{width:24px; height:24px; border-radius:6px; display:block}
.ver{font-weight:400; color:var(--muted); font-size:12px}
.modes{display:flex; gap:4px; margin-left:auto}
.mode{
  border:1px solid var(--line); background:transparent; color:var(--muted);
  padding:5px 12px; border-radius:999px; cursor:pointer; font-size:14px;
}
.mode.on{background:var(--accent); border-color:var(--accent); color:#fff}
.right{display:flex; align-items:center; gap:10px; margin-left:auto}
.tts{font-size:13px; color:var(--muted); display:flex; align-items:center; gap:4px; cursor:pointer}
.dot{color:var(--muted); font-size:12px}
.dot.ok{color:var(--ok)} .dot.bad{color:var(--bad)}
.subbar{
  padding:8px 14px; background:var(--panel); border-bottom:1px solid var(--line);
  font-size:14px; color:var(--muted);
}
.subbar select{
  font:inherit; padding:3px 6px; border-radius:6px;
  border:1px solid var(--line); background:var(--bg); color:var(--ink);
}
main{flex:1; overflow-y:auto; padding:16px; display:flex; flex-direction:column; gap:12px}
.msg{max-width:min(680px,86%); padding:10px 14px; border-radius:14px; white-space:pre-wrap; word-break:break-word}
.msg.me{align-self:flex-end; background:var(--me); color:var(--me-ink); border-bottom-right-radius:4px}
.msg.bot{align-self:flex-start; background:var(--bot); border:1px solid var(--line); border-bottom-left-radius:4px}
.msg.err{align-self:center; background:transparent; border:1px dashed var(--bad); color:var(--bad); font-size:14px}
.msg img{max-width:100%; border-radius:10px; display:block; margin-bottom:6px}
.meta{font-size:11px; color:var(--muted); margin-top:6px}
.msg.me .meta{color:rgba(255,255,255,.75)}
/* 翻译模式:原文+译文摆在同一个框里,不分两个气泡 */
.msg .trans{
  margin-top:6px; padding-top:6px;
  border-top:1px dashed rgba(255,255,255,.4);
}
.msg.bot .trans{border-top-color:var(--line)}
.msg .trans.pending{opacity:.6}
.blink::after{content:"▍"; animation:b 1s steps(2) infinite}
@keyframes b{50%{opacity:0}}
#imgPreview{position:relative; padding:0 14px 6px; align-self:flex-start}
#imgPreview img{max-height:96px; border-radius:10px; display:block}
#imgClear{
  position:absolute; top:-4px; right:6px; width:24px; height:24px; border-radius:50%;
  border:none; background:#000a; color:#fff; cursor:pointer; font-size:16px; line-height:1;
}
/* 摄像头直拍:全屏取景,拍完直接复用看图流程 */
#camOverlay{
  position:fixed; inset:0; z-index:20; background:#000;
  display:flex; align-items:center; justify-content:center;
}
#camVideo{width:100%; height:100%; object-fit:cover}
.camControls{
  position:absolute; left:0; right:0; bottom:0;
  padding:20px 24px calc(20px + env(safe-area-inset-bottom, 0px));
  display:flex; align-items:center; justify-content:space-between;
}
.camControls button{
  border:none; background:#0006; color:#fff; border-radius:50%;
  width:52px; height:52px; font-size:22px; cursor:pointer;
}
#camShutter{
  width:68px; height:68px; font-size:34px; background:#fff3; border:3px solid #fff;
}
footer{
  display:flex; gap:8px; padding:10px 12px; align-items:flex-end;
  background:var(--panel); border-top:1px solid var(--line);
}
footer button{
  border:1px solid var(--line); background:var(--bg); color:var(--ink);
  border-radius:10px; padding:9px 12px; font-size:18px; cursor:pointer; line-height:1;
}
#sendBtn{background:var(--accent); border-color:var(--accent); color:#fff; font-size:15px; padding:11px 16px}
#micBtn.rec{background:var(--bad); border-color:var(--bad); color:#fff}
/* 持续开麦:两句话之间的空档(没在录音,但循环还没关)也要看得出来,
   不然用户会以为按失败了 */
#micBtn.loop{box-shadow:0 0 0 3px var(--accent)}
#micBtn.loop.rec{box-shadow:0 0 0 3px var(--bad)}
button:disabled{opacity:.45; cursor:default}
#input{
  flex:1; resize:none; max-height:140px; font:inherit; padding:10px 12px;
  border-radius:10px; border:1px solid var(--line); background:var(--bg); color:var(--ink);
}
#toast{
  position:fixed; left:50%; bottom:84px; transform:translateX(-50%);
  background:#000c; color:#fff; padding:8px 14px; border-radius:8px; font-size:14px; z-index:9;
}
.hidden{display:none !important}
