
:root{
  --bg:#0b0e12; --panel:#0f141b; --panel2:#111925;
  --text:#e7eef7; --muted:#8ea0b5;
  --line:rgba(255,255,255,.08);
  --accent:#ffd400;
  --good:#30d158; --bad:#ff453a;
  --radius:16px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font:14px/1.35 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu;
  color:var(--text);
  background: radial-gradient(1200px 600px at 30% 10%, rgba(255,212,0,.06), transparent 60%),
              radial-gradient(900px 500px at 85% 40%, rgba(60,180,255,.05), transparent 60%),
              var(--bg);
}
.backdrop{position:fixed; inset:0; background:rgba(0,0,0,.55); opacity:0; pointer-events:none; transition:.15s; z-index:40}
.backdrop.show{opacity:1; pointer-events:auto}

.topbar{
  height:64px; display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px; border-bottom:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0));
}
.brand{display:flex; gap:10px; align-items:center}
.dot{width:12px; height:12px; border-radius:50%; background:var(--bad); box-shadow:0 0 0 6px rgba(255,69,58,.15)}
.dot.ok{background:var(--good); box-shadow:0 0 0 6px rgba(48,209,88,.14)}
.twrap .title{font-weight:700}
.twrap .sub{font-size:12px;color:var(--muted); margin-top:2px}

.right{display:flex; gap:10px; align-items:center}
.nickWrap{display:flex; gap:8px; align-items:center; background:rgba(255,255,255,.03); border:1px solid var(--line); padding:8px 10px; border-radius:999px}
.nickLbl{font-size:12px; color:var(--muted)}
.nick{background:transparent; border:0; outline:0; color:var(--text); width:160px}
.iconBtn{width:38px; height:38px; border-radius:12px; border:1px solid var(--line); background:rgba(255,255,255,.03); color:var(--text); cursor:pointer}
.iconBtn svg{width:20px;height:20px; fill:#cfd8e3}
.iconBtn:hover{background:rgba(255,255,255,.06)}
.iconBtn.small{width:34px;height:34px;border-radius:10px}

.pill{height:38px;display:inline-flex;align-items:center;justify-content:center;
  padding:0 12px;border-radius:999px;border:1px solid var(--line);
  background:rgba(255,255,255,.03);color:var(--text);font-weight:600;font-size:12px}

.chatLayout{
  height:calc(100vh - 64px);
  display:grid;
  grid-template-columns: 1fr 320px;
  gap:12px;
  padding:12px;
  transition: grid-template-columns .18s ease;
}
.chatMain{
  min-width:0;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  overflow:hidden;
  display:flex; flex-direction:column;
}
.messages{flex:1; overflow:auto; padding:14px}
.msgRow{display:flex; gap:12px; margin-bottom:14px}
.avatar{width:44px;height:44px;border-radius:50%; background:rgba(255,255,255,.06); border:1px solid var(--line); display:flex; align-items:center; justify-content:center; overflow:hidden}
.avatar img{width:100%;height:100%;object-fit:cover}
.bubble{min-width:0}
.meta{display:flex; gap:8px; align-items:baseline}
.nickA{font-weight:700; cursor:pointer}
.time{font-size:12px; color:var(--muted)}
.role{font-size:11px; padding:2px 6px; border-radius:999px; border:1px solid var(--line); color:var(--accent)}
.text{margin-top:4px; white-space:pre-wrap; word-break:break-word}
.text img{max-width:360px; border-radius:12px; border:1px solid var(--line)}
.mention{background:rgba(255,212,0,.12); padding:2px 6px; border-radius:8px}
.replyIcon{margin-left:6px; color:var(--muted); cursor:pointer}

.replyBar{display:none; align-items:center; gap:10px; padding:8px 12px; border-top:1px solid var(--line); background:rgba(255,255,255,.03)}
.replyBar.show{display:flex}
.replyBar .t{color:var(--muted); font-size:12px}
.replyBar .p{flex:1; font-size:13px; color:#dbe6f3; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.btn{border:1px solid var(--line); background:rgba(255,255,255,.05); color:var(--text); padding:10px 12px; border-radius:12px; cursor:pointer}
.btn.ghost{background:transparent}
.btn.send{background:rgba(255,212,0,.14); border-color:rgba(255,212,0,.25); font-weight:700}
.btn.x{width:38px; height:38px; padding:0; display:flex; align-items:center; justify-content:center}

.composer{display:flex; gap:10px; padding:12px; border-top:1px solid var(--line); align-items:flex-end}
.msg{flex:1; resize:none; min-height:40px; max-height:140px; padding:10px 12px; border-radius:14px; border:1px solid var(--line); background:rgba(0,0,0,.25); color:var(--text); outline:0}
.msg:focus{border-color:rgba(255,212,0,.35); box-shadow:0 0 0 4px rgba(255,212,0,.08)}

.emojiPanel{display:none; padding:10px 12px; border-top:1px solid var(--line)}
.emojiPanel.show{display:block}
.emojiGrid{display:grid; grid-template-columns:repeat(10,1fr); gap:6px}
.emojiGrid button{border:1px solid var(--line); background:rgba(255,255,255,.03); border-radius:10px; padding:8px; cursor:pointer}

.sideUsers{
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,0));
  overflow:hidden;
  display:flex; flex-direction:column;
}
.sideHead{padding:12px; border-bottom:1px solid var(--line); display:flex; gap:10px; align-items:center}
.ttlWrap{display:flex; flex-direction:column; min-width:0}
.sideHead .ttl{font-weight:800}
.sub2{font-size:12px;color:var(--muted); margin-top:2px}
.userSearch{margin-left:auto; width:140px; max-width:45%; padding:8px 10px; border-radius:999px; border:1px solid var(--line); background:rgba(0,0,0,.25); color:var(--text)}
.userSearch::placeholder{color:rgba(142,160,181,.8)}
.ttlWrap{display:flex;flex-direction:column;gap:2px}
.sub2{font-size:12px;color:var(--muted)}
.userSearch{width:140px;max-width:45%; padding:8px 10px; border-radius:999px; border:1px solid var(--line);
  background:rgba(0,0,0,.25); color:var(--text)}
.userlist{overflow:auto; padding:10px}
.userItem{display:flex; align-items:center; gap:10px; padding:8px 8px; border-radius:12px; cursor:pointer}
.userItem:hover{background:rgba(255,255,255,.04)}
.userDot{width:9px;height:9px;border-radius:50%; background:var(--good)}
.userDot.away{background:#ffcc00}
.userDot.offline{background:#667085}
.userDot.dnd{background:var(--bad)}
.userDot.busy{background:#b000ff}
.userName{font-weight:700}
.userSub{font-size:12px; color:var(--muted)}
.userRole{margin-left:auto; font-size:11px; color:var(--muted)}

.userAv{width:30px;height:30px;border-radius:50%;overflow:hidden;border:1px solid var(--line);
  background:rgba(255,255,255,.06);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:12px}
.userAv img{width:100%;height:100%;object-fit:cover}
.userCol{min-width:0}
.userName{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}
.userSub{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}

.drawer{position:fixed; top:74px; right:14px; width:min(420px, calc(100vw - 28px)); max-height:calc(100vh - 88px);
  border:1px solid var(--line); border-radius:var(--radius); background:rgba(10,14,18,.92);
  backdrop-filter: blur(10px);
  display:none; flex-direction:column; z-index:50;
}
.drawer.show{display:flex}
.drawerTop{display:flex; justify-content:space-between; align-items:center; padding:12px; border-bottom:1px solid var(--line)}
.drawerTitle{font-weight:800}
.drawerBody{padding:12px; overflow:auto}
.block{margin-bottom:12px}
.label{font-size:12px;color:var(--muted); margin-bottom:6px}
.input{width:100%; padding:10px 12px; border:1px solid var(--line); border-radius:12px; background:rgba(0,0,0,.25); color:var(--text)}
.hint{font-size:12px;color:var(--muted); margin-top:6px}

.statusRow{display:flex;flex-wrap:wrap;gap:8px}
.chip{border:1px solid var(--line); background:rgba(255,255,255,.03); color:var(--text);
  padding:8px 10px; border-radius:999px; cursor:pointer; font-weight:600; font-size:12px}
.chip:hover{background:rgba(255,255,255,.06)}

.mediaGrid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.mediaItem{position:relative;display:block;border:1px solid var(--line);border-radius:14px;overflow:hidden;background:rgba(255,255,255,.02)}
.mediaItem img{width:100%;height:110px;object-fit:cover;display:block}
.mediaCap{position:absolute;left:8px;right:8px;bottom:8px;font-size:11px;color:var(--text);
  background:rgba(0,0,0,.45);padding:4px 6px;border-radius:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* Blab-like behaviour: desktop userlist internal, no overlay.
   Mobile: userlist becomes slide-in overlay */
@media (max-width: 920px){
  .chatLayout{grid-template-columns:1fr}
  .sideUsers{position:fixed; top:64px; right:-340px; width:320px; height:calc(100vh - 64px); z-index:45; transition:right .18s}
  body.usersOpen .sideUsers{right:0}
  body.usersOpen .backdrop{opacity:1; pointer-events:auto}
  .nick{width:120px}
}


/* message actions */
.msg { position: relative; }
.msg-actions { position:absolute; right:10px; top:8px; display:none; gap:6px; }
.msg:hover .msg-actions { display:inline-flex; }
.msg-actions .ma{
  font-size:12px;
  padding:4px 6px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  color: inherit;
  cursor:pointer;
}
.msg-actions .ma:hover{ background: rgba(255,255,255,.08); }

/* modal */
.modal{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.55);backdrop-filter:blur(6px);z-index:999;}
.modal.hidden{display:none;}
.modalCard{width:min(1100px,92vw);padding:14px;border-radius:18px;background:rgba(12,12,12,.86);border:1px solid rgba(255,255,255,.10);box-shadow:0 30px 80px rgba(0,0,0,.65);}
.modalHead{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;}
.modalTitle{font-weight:700;}
.modalActions{display:flex;gap:8px;flex-wrap:wrap;}


/* users panel toggle: widen chat instead of leaving empty space */
body:not(.usersOpen) .chatLayout{ grid-template-columns: 1fr 0px; }
body:not(.usersOpen) .sideUsers{ opacity:0; pointer-events:none; transform:translateX(20px); overflow:hidden; }
.sideUsers{ transition: transform .18s ease, opacity .18s ease; }


/* popover (emoji) */
.pop{position:fixed;right:18px;bottom:90px;width:min(520px,92vw);max-height:60vh;overflow:hidden;background:rgba(12,12,12,.92);border:1px solid rgba(255,255,255,.10);border-radius:18px;box-shadow:0 30px 80px rgba(0,0,0,.65);z-index:1000;}
.pop.hidden{display:none;}
.popHead{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;border-bottom:1px solid rgba(255,255,255,.08);}
.popBody{padding:10px;display:grid;grid-template-columns:repeat(10,1fr);gap:8px;overflow:auto;max-height:52vh;}
.emojiBtn{font-size:20px;line-height:1;padding:8px;border-radius:12px;border:1px solid rgba(255,255,255,.08);background:rgba(0,0,0,.25);cursor:pointer;}
.emojiBtn:hover{background:rgba(255,255,255,.08);}
.cmdItem{padding:10px 12px;border:1px solid rgba(255,255,255,.08);border-radius:14px;background:rgba(0,0,0,.22);margin:10px 0;}
.cmdName{font-weight:700;}
.cmdEx{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;opacity:.9;margin-top:6px;}
.mention{padding:1px 6px;border-radius:10px;border:1px solid rgba(255,255,255,.12);background:rgba(180,124,88,.12);}
.mediaPreview{margin-top:8px;border-radius:14px;overflow:hidden;border:1px solid rgba(255,255,255,.10);max-width:420px;}
.mediaPreview img{display:block;width:100%;height:auto;}
.mediaPreview audio{width:100%;}
