:root{
  --bg:#12161f; --panel:#1a2030; --panel2:#212a3d;
  --line:#2a3448; --text:#e8eef9; --sub:#8b98b0;
  --me:#2f6df6; --bot:#232d42; --accent:#5aa9ff;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--text);overflow-x:hidden;
  font:16px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  overscroll-behavior:none;
}
.hidden{display:none!important}

/* ---------- 登录 ---------- */
.login{min-height:100%;display:flex;align-items:center;justify-content:center;padding:24px;
  background:radial-gradient(120% 60% at 50% 0%,#1d3a5c 0%,#12161f 60%);}
.login-box{width:100%;max-width:340px;text-align:center}
.login-avatar{width:96px;height:96px;border-radius:50%;border:2px solid #3a74c9;box-shadow:0 8px 30px rgba(60,130,255,.35)}
.login h1{margin:16px 0 4px;font-size:24px;letter-spacing:2px}
.login-sub{margin:0 0 28px;color:var(--sub);font-size:13px}
.login input{width:100%;padding:14px 16px;border-radius:14px;border:1px solid var(--line);
  background:var(--panel);color:var(--text);font-size:16px;outline:none}
.login input:focus{border-color:var(--accent)}
.login button{width:100%;margin-top:14px;padding:14px;border:0;border-radius:14px;
  background:linear-gradient(180deg,#4a8cff,#2f6df6);color:#fff;font-size:17px;font-weight:600}
.login button:active{transform:scale(.99)}
.err{color:#ff7b7b;font-size:13px;height:18px;margin-top:10px}

/* ---------- 聊天 ---------- */
.chat{display:flex;flex-direction:column;height:100%;height:100dvh}
.topbar{display:flex;align-items:center;gap:12px;padding:calc(10px + env(safe-area-inset-top)) 16px 10px;
  background:rgba(22,28,41,.92);backdrop-filter:blur(12px);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:5}
.avatar-wrap{position:relative;flex:0 0 auto}
.avatar-wrap img{width:40px;height:40px;border-radius:50%;display:block;border:1px solid #33507d}
.dot{position:absolute;right:-1px;bottom:-1px;width:11px;height:11px;border-radius:50%;
  background:#27c46a;border:2px solid var(--bg)}
.dot.off{background:#8a93a6}
.who{min-width:0}
.name{font-size:16px;font-weight:600}
.state{font-size:12px;color:var(--sub)}

.list{flex:1;overflow-y:auto;overflow-x:hidden;padding:16px 14px 8px;display:block;scroll-behavior:smooth}
.row{display:flex;gap:10px;align-items:flex-end;width:100%;max-width:100%;min-width:0;margin:0 0 14px}
.row.me{flex-direction:row;justify-content:flex-end}
.ava{width:34px;height:34px;border-radius:50%;flex:0 0 auto;background:var(--panel2);border:1px solid #2f3b52}
.bubble{max-width:76%;padding:10px 14px;border-radius:18px;background:var(--bot);
  border:1px solid #2b3549;word-break:break-word;white-space:pre-wrap;font-size:16px;line-height:1.55;
  animation:pop .16s ease-out}
.row.me .bubble{background:linear-gradient(180deg,#3a7bf8,#2f6df6);border:0;color:#fff}
.bubble.typing{color:var(--sub);font-style:italic}
.bubble img.sticker{max-width:150px;border-radius:12px;display:block}
.time{text-align:center;font-size:11px;color:#61708a;margin:2px 0}
@keyframes pop{from{opacity:.4;transform:translateY(4px) scale(.98)}to{opacity:1;transform:none}}

.composer{display:flex;align-items:flex-end;gap:10px;padding:10px 12px calc(10px + env(safe-area-inset-bottom));
  background:rgba(22,28,41,.96);border-top:1px solid var(--line)}
.input-wrap{flex:1;min-width:0;background:var(--panel);border:1px solid var(--line);border-radius:20px;padding:6px 12px}
textarea{width:100%;border:0;background:transparent;color:var(--text);font:inherit;resize:none;outline:none;
  max-height:120px;padding:6px 0;line-height:1.4}
.send{flex:0 0 auto;width:44px;height:44px;border-radius:50%;border:0;
  background:linear-gradient(180deg,#4a8cff,#2f6df6);color:#fff;display:grid;place-items:center}
.send:active{transform:scale(.95)}
.send:disabled{opacity:.45}

/* 图片按钮 */
.composer .pic{
  flex:0 0 auto;width:40px;height:40px;border-radius:50%;
  border:1px solid var(--line);background:var(--panel);color:var(--muted);
  display:flex;align-items:center;justify-content:center;margin-right:6px;
}
.composer .pic:active{background:var(--panel2)}

/* 消息里的图片 */
.bubble .msgimg{
  display:block;max-width:min(62vw,220px);max-height:280px;
  border-radius:12px;margin:2px 0;
  background:#0002;
}
