:root{--bg:#000;--surface:#0e0e0e;--surface2:#171717;--line:#262626;--red:#e11d2e;--red2:#b81324;--text:#fff;--muted:#9a9a9a}
*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--bg);color:var(--text);font:15px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
[hidden]{display:none!important}
button,input,textarea{font:inherit;color:inherit}
.center{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;height:100%;padding:16px}
.screen{min-height:100%}
.logo{font-weight:800;font-size:28px;letter-spacing:.5px}.logo span{color:var(--red);margin-left:6px}.logo.small{font-size:20px}
.card{width:100%;max-width:380px;background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:24px;display:flex;flex-direction:column;gap:14px;animation:rise .25s ease}
h1{font-size:20px;margin:0}h2{margin:0 0 8px}
label{display:flex;flex-direction:column;gap:6px;color:var(--muted);font-size:13px}
input,textarea{background:var(--surface2);border:1px solid var(--line);border-radius:10px;padding:10px 12px;outline:none;color:var(--text)}
input:focus,textarea:focus{border-color:var(--red)}
button{background:var(--surface2);border:1px solid var(--line);border-radius:10px;padding:10px 14px;cursor:pointer;transition:background .15s}
button:hover{background:#222}
button.primary{background:var(--red);border-color:var(--red);font-weight:600}button.primary:hover{background:var(--red2)}
button.danger{border-color:var(--red);color:var(--red)}
button:disabled{opacity:.6;cursor:wait}
button.link{background:none;border:0;color:var(--muted);text-decoration:underline}
button.icon{padding:6px 10px;font-size:18px;background:none;border:0}
.muted{color:var(--muted)}.small{font-size:12px}.error{color:var(--red);min-height:1.2em;margin:0;font-size:13px}
code{background:var(--surface2);padding:1px 5px;border-radius:5px}
#app{display:grid;grid-template-columns:340px 1fr;height:100%}
#sidebar{display:flex;flex-direction:column;border-right:1px solid var(--line);background:var(--surface);min-height:0}
.side-head{display:flex;justify-content:space-between;align-items:center;padding:12px 14px}
#search{margin:0 12px 8px}
.tabs{display:flex;gap:6px;padding:0 12px 8px}.tabs button{flex:1;padding:6px}.tabs button.active{background:var(--red);border-color:var(--red)}
#list{list-style:none;margin:0;padding:0;overflow-y:auto;flex:1}
#list li{display:flex;gap:10px;padding:10px 14px;cursor:pointer;border-bottom:1px solid var(--line);align-items:center}
#list li:hover{background:var(--surface2)}#list li.sel{background:#1c0a0c;box-shadow:inset 3px 0 var(--red)}
.avatar{width:42px;height:42px;border-radius:50%;background:var(--red2);display:flex;align-items:center;justify-content:center;font-weight:700;flex:none;overflow:hidden}
.avatar img{width:100%;height:100%;object-fit:cover}
.li-main{flex:1;min-width:0}.li-top{display:flex;justify-content:space-between;gap:8px}
.title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.li-sub{color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13px}
.badge{background:var(--red);border-radius:10px;padding:0 7px;font-size:12px;font-weight:700;margin-left:6px}
.side-foot{display:flex;align-items:center;gap:8px;padding:10px 14px;border-top:1px solid var(--line);font-size:12px}
.side-foot #acct{margin-left:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dot{width:8px;height:8px;border-radius:50%;background:var(--muted)}.dot.ok{background:#fff}.dot.bad{background:var(--red);animation:pulse 1s infinite}
#pane{min-width:0;min-height:0;display:flex;flex-direction:column}
#chat{display:flex;flex-direction:column;height:100%;min-height:0}
.chat-head{display:flex;align-items:center;gap:10px;padding:10px 14px;border-bottom:1px solid var(--line);background:var(--surface)}
#btn-back{display:none}
#msgs{flex:1;overflow-y:auto;padding:14px;display:flex;flex-direction:column;gap:6px}
.msg{max-width:min(75%,560px);padding:8px 12px;border-radius:14px;background:var(--surface2);align-self:flex-start;animation:rise .15s ease;overflow-wrap:anywhere}
.msg.out{align-self:flex-end;background:var(--red2)}
.msg .who{color:#ff7a86;font-size:12px;font-weight:600}.msg .txt{white-space:pre-wrap}
.msg .media{color:var(--muted);font-style:italic}.msg .time{font-size:11px;color:#c9c9c9;opacity:.7;text-align:right}
.msg.sending{opacity:.6}.msg.failed{outline:1px solid var(--red);cursor:pointer}
#msgs-status{align-self:center;color:var(--muted);font-size:12px}
#composer{display:flex;gap:8px;padding:10px 14px;border-top:1px solid var(--line);background:var(--surface);padding-bottom:calc(10px + env(safe-area-inset-bottom,0px))}
#input{flex:1;resize:none;max-height:140px}
#toasts{position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:50;display:flex;flex-direction:column;gap:8px;width:min(92vw,420px)}
.toast{background:var(--surface2);border:1px solid var(--line);border-left:3px solid var(--muted);padding:10px 12px;border-radius:10px;animation:rise .2s ease}.toast.error{border-left-color:var(--red)}
dialog{background:var(--surface);color:var(--text);border:1px solid var(--line);border-radius:14px;max-width:420px;width:92vw}
dialog::backdrop{background:rgba(0,0,0,.7)}.row{display:flex;gap:8px;flex-wrap:wrap}
@keyframes rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@keyframes pulse{50%{opacity:.35}}
@media(max-width:760px){
 #app{grid-template-columns:1fr}
 #pane{display:none}
 body.chat-open #sidebar{display:none}body.chat-open #pane{display:flex}
 #btn-back{display:block}.msg{max-width:88%}
 .side-foot{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px))}
}
body.doc{overflow:auto;height:auto}
.card.wide{max-width:680px;margin:24px auto}
a{color:var(--red)}
.update-bar{position:fixed;left:50%;bottom:calc(16px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:60;display:flex;gap:12px;align-items:center;background:var(--surface2);border:1px solid var(--red);border-radius:12px;padding:10px 14px;width:max-content;max-width:92vw}
