:root{
  --bg:#15121c; --bg2:#1d1926; --line:#2c2639;
  --me:#6d5bd0; --her:#241f31; --fg:#eee9f5; --dim:#9b93ad;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
  background:var(--bg); color:var(--fg);
  font:16px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  display:flex; flex-direction:column;
  height:100dvh; overscroll-behavior:none;
  padding-bottom:env(safe-area-inset-bottom);
}
header{
  display:flex; align-items:center; gap:8px;
  padding:calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom:1px solid var(--line); background:var(--bg2);
  position:sticky; top:0; z-index:5;
}
header .name{font-weight:600; letter-spacing:.02em; margin-right:auto; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-size:15px}
.push-btn{
  border:1px solid var(--line); border-radius:999px;
  padding:4px 10px; min-height:28px; height:28px;
  background:#262033; color:var(--dim);
  font-size:12px; font-weight:500; line-height:1;
}
.push-btn.on{
  border-color:#5ad18a66; background:#1c3227; color:#7fe3a8;
}
.push-btn:disabled{opacity:.5}
#dot{width:8px;height:8px;border-radius:50%;background:#555;flex-shrink:0}
#dot.on{background:#5ad18a;box-shadow:0 0 8px #5ad18a88}
#dot.off{background:#d15a5a}

.net-banner{
  background:#4a2230; color:#ffd6df; border-bottom:1px solid #6e3146;
  font-size:12.5px; text-align:center; padding:6px 12px;
  flex-shrink:0; z-index:4;
}

main{
  flex:1; overflow-y:auto; padding:12px 14px 8px;
  display:flex; flex-direction:column; gap:8px;
  -webkit-overflow-scrolling:touch;
}

.history-tip{
  align-self:center; display:inline-flex; align-items:center; justify-content:center; gap:6px;
  color:var(--dim); font-size:12.5px; padding:4px 12px 8px;
  user-select:none;
}
.history-tip.clickable{cursor:pointer}
.spinner{
  width:13px; height:13px; border-radius:50%;
  border:2px solid #9b93ad44; border-top-color:#cfc6e8;
  animation:cb-spin .75s linear infinite;
}
@keyframes cb-spin{to{transform:rotate(360deg)}}

.m{
  position:relative; max-width:82%; padding:9px 13px; border-radius:16px;
  white-space:pre-wrap; word-break:break-word; font-size:15px;
}
.m.her{align-self:flex-start; background:var(--her); border-bottom-left-radius:5px}
.m.me{align-self:flex-end; background:var(--me); border-bottom-right-radius:5px}
.m.pending{opacity:.55}
.m.sending{opacity:.65}
.m.failed{box-shadow:inset 0 0 0 1px #e05252aa}

.msg-img{
  display:block; max-width:100%; max-height:280px; min-height:60px; min-width:80px;
  border-radius:10px; object-fit:cover; cursor:zoom-in; background:#171320;
}
.msg-text{white-space:pre-wrap; word-break:break-word}
.msg-img + .msg-text{margin-top:6px}

.voice-bar{
  display:flex; align-items:center; gap:9px;
  min-width:190px; padding:6px 10px; border-radius:12px;
  background:rgba(255,255,255,.08);
}
.msg-text + .voice-bar, .msg-img + .voice-bar{margin-top:6px}
.voice-play{
  width:32px; min-width:32px; height:32px; min-height:32px; padding:0;
  border-radius:50%; background:rgba(255,255,255,.16); color:#fff;
  font-size:12px; line-height:32px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}
.voice-play:active{transform:scale(.93)}
.voice-track{
  flex:1; height:24px; display:flex; align-items:center;
  cursor:pointer; touch-action:manipulation; min-width:72px;
}
.voice-rail{
  width:100%; height:4px; border-radius:999px;
  background:rgba(255,255,255,.22); overflow:hidden;
}
.voice-fill{
  width:0%; height:100%; border-radius:999px;
  background:#efe9fa; transition:width .08s linear;
}
.voice-dur{
  font-size:12px; color:#ffffffc9; font-variant-numeric:tabular-nums;
  min-width:34px; text-align:right; flex-shrink:0;
}

.msg-meta{
  display:flex; align-items:center; justify-content:flex-end; gap:6px;
  margin-top:4px;
}
.m .t{display:inline-block; font-size:11px; color:#ffffff66; line-height:1}

.retry-btn{
  border:0; width:22px; height:22px; min-height:22px; padding:0;
  border-radius:50%; background:#e05252; color:#fff;
  font-size:13px; font-weight:700; line-height:22px; text-align:center;
  cursor:pointer; flex-shrink:0; touch-action:manipulation;
}
.retry-btn:active{transform:scale(.92)}

.sys{align-self:center; color:var(--dim); font-size:12.5px}

.compose-preview{
  display:flex; align-items:center; gap:10px;
  padding:8px 12px; border-top:1px solid var(--line); background:#181421;
  flex-shrink:0;
}
.compose-thumb{
  width:52px; height:52px; border-radius:10px; object-fit:cover;
  border:1px solid var(--line); background:#171320; cursor:zoom-in; flex-shrink:0;
}
.compose-info{flex:1; min-width:0}
.compose-meta{font-size:13px; color:var(--fg); font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.compose-sub{font-size:11.5px; color:var(--dim); margin-top:2px}
.compose-clear{
  width:30px; min-width:30px; height:30px; min-height:30px; padding:0;
  border-radius:50%; background:#2c2639; color:#dfd9ee;
  font-size:18px; line-height:30px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}
.compose-clear:active{background:#3a324b}

form{
  display:flex; align-items:flex-end; gap:8px;
  padding:10px 12px calc(12px + env(safe-area-inset-bottom));
  border-top:1px solid var(--line); background:var(--bg2);
}
textarea{
  flex:1; resize:none; border:1px solid var(--line); background:#171320; color:var(--fg);
  border-radius:18px; padding:10px 14px; font:inherit; max-height:132px; min-height:44px; outline:none;
}
textarea:focus{border-color:#5a4bb5}
button{
  border:0; border-radius:18px; padding:0 18px; min-height:44px;
  background:var(--me); color:#fff; font:inherit; font-weight:600;
  cursor:pointer;
}
button:disabled{opacity:.45; cursor:default}
.icon-btn{
  width:44px; min-width:44px; padding:0; border-radius:18px;
  background:#2a233d; color:#e5defa; font-size:20px; font-weight:500;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.icon-btn:active{background:#372e4f}

#login{
  position:fixed; inset:0; background:var(--bg); display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:14px; padding:24px; z-index:20;
}
#login h1{font-size:20px; margin:0 0 4px}
#login p{color:var(--dim); font-size:14px; margin:0}
#login input{
  width:100%; max-width:300px; padding:13px 16px; border-radius:14px;
  border:1px solid var(--line); background:#171320; color:var(--fg); font:inherit; outline:none; text-align:center;
}
#login button{width:100%; max-width:300px}
.err{color:#ff8b8b; font-size:13px; min-height:18px}

.lightbox{
  position:fixed; inset:0; background:rgba(10,8,14,.92);
  display:flex; align-items:center; justify-content:center;
  padding:20px; z-index:50; cursor:zoom-out;
}
.lightbox img{
  max-width:100%; max-height:100%; border-radius:8px; object-fit:contain;
}

[hidden]{display:none!important}
