:root{
  --bg-app:#1e1f27;
  --bg-sidebar:#17181f;
  --bg-main:#242530;
  --bg-composer:#2c2d3a;
  --bg-bubble:#2a2b38;
  --text:#e7e7ec;
  --text-dim:#9a9ba8;
  --accent:#7c6cff;
  --error:#ff6b6b;
  --online:#3ddc84;
}
*{box-sizing:border-box;}
html,body{height:100%;margin:0;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg-app);
  color:var(--text);
}
#app{display:flex;height:100vh;}

/* Sidebar */
#sidebar{
  width:240px;
  background:var(--bg-sidebar);
  display:flex;
  flex-direction:column;
  padding:14px 10px;
  gap:10px;
  flex-shrink:0;
}
.sidebar-header{padding:6px 8px 10px;border-bottom:1px solid #2a2b36;}
.brand{font-weight:700;font-size:15px;}
#room-list{display:flex;flex-direction:column;gap:2px;overflow-y:auto;flex:1;min-height:60px;}
.room-item{
  padding:8px 10px;border-radius:8px;cursor:pointer;color:var(--text-dim);
  font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.room-item:hover{background:#22232e;color:var(--text);}
.room-item.active{background:var(--accent);color:#fff;}
#new-room-btn{
  background:none;border:1px dashed #3a3b47;color:var(--text-dim);
  border-radius:8px;padding:7px;cursor:pointer;font-size:13px;
}
#new-room-btn:hover{color:var(--text);border-color:var(--accent);}

#bot-roster{border-top:1px solid #2a2b36;padding-top:10px;}
.roster-title{font-size:11px;text-transform:uppercase;color:var(--text-dim);margin-bottom:6px;letter-spacing:.05em;}
.roster-item{display:flex;align-items:center;gap:8px;padding:4px 6px;font-size:13px;color:var(--text-dim);}
.roster-item .dot{width:8px;height:8px;border-radius:50%;background:var(--online);flex-shrink:0;}
.roster-item .dot.busy{background:#f5b93d;animation:pulse 1s infinite;}
@keyframes pulse{0%,100%{opacity:1;}50%{opacity:.3;}}

.conn-status{font-size:11px;color:var(--text-dim);padding:4px 6px;}
.conn-status.ok{color:var(--online);}
.conn-status.down{color:var(--error);}

/* Main */
#main{flex:1;display:flex;flex-direction:column;min-width:0;}
#room-header{
  height:52px;flex-shrink:0;display:flex;align-items:center;padding:0 18px;
  background:var(--bg-main);border-bottom:1px solid #2a2b36;font-weight:600;
}

#messages{flex:1;overflow-y:auto;padding:16px 18px;display:flex;flex-direction:column;gap:12px;background:var(--bg-main);}

.msg{display:flex;gap:10px;max-width:820px;}
.msg .avatar{
  width:36px;height:36px;border-radius:50%;background:var(--bg-bubble);
  display:flex;align-items:center;justify-content:center;font-size:18px;flex-shrink:0;
}
.msg .body{display:flex;flex-direction:column;gap:2px;}
.msg .meta{display:flex;align-items:baseline;gap:8px;}
.msg .author{font-weight:600;font-size:14px;}
.msg .time{font-size:11px;color:var(--text-dim);}
.msg .text{font-size:14px;line-height:1.45;white-space:pre-wrap;word-break:break-word;background:var(--bg-bubble);padding:8px 12px;border-radius:10px;border-top-left-radius:2px;}
.msg.human .text{background:var(--accent);color:#fff;border-radius:10px;border-top-right-radius:2px;}
.msg.human{flex-direction:row-reverse;}
.msg.human .body{align-items:flex-end;}
.msg.error .text{background:#3a1f22;color:var(--error);border:1px solid #5a2a2e;}
.msg.progress .text{background:transparent;border:1px dashed #3a3b47;color:var(--text-dim);font-style:italic;font-size:12.5px;padding:5px 10px;}
.msg.progress .avatar{opacity:.55;font-size:14px;width:28px;height:28px;}
.msg.system{opacity:.75;}
.msg.system .text{background:transparent;border:none;color:var(--text-dim);font-style:italic;padding:2px 0;}
.msg.system .avatar{width:28px;height:28px;font-size:14px;}

.author.c-claude{color:#c9b8ff;}
.author.c-codex{color:#8fe3a9;}
.author.c-opencode{color:#ffbf80;}
.author.c-merlin{color:#8fd0ff;}

#typing-bar{min-height:22px;padding:0 18px;font-size:12px;color:var(--text-dim);font-style:italic;background:var(--bg-main);}

#composer{
  display:flex;gap:10px;padding:14px 18px;background:var(--bg-composer);position:relative;flex-shrink:0;
}
#msg-input{
  flex:1;background:#1c1d26;border:1px solid #3a3b47;border-radius:10px;
  padding:11px 14px;color:var(--text);font-size:14px;outline:none;
}
#msg-input:focus{border-color:var(--accent);}
#composer button{
  background:var(--accent);border:none;color:#fff;border-radius:10px;
  padding:0 18px;font-weight:600;cursor:pointer;font-size:14px;
}
#composer button:hover{opacity:.9;}

#mention-menu{
  position:absolute;bottom:64px;left:18px;background:#1c1d26;border:1px solid #3a3b47;
  border-radius:8px;overflow:hidden;min-width:180px;box-shadow:0 8px 24px rgba(0,0,0,.4);
}
#mention-menu.hidden{display:none;}
.mention-opt{padding:8px 12px;font-size:13px;cursor:pointer;display:flex;gap:8px;align-items:center;}
.mention-opt:hover, .mention-opt.sel{background:var(--accent);color:#fff;}

::-webkit-scrollbar{width:8px;}
::-webkit-scrollbar-thumb{background:#3a3b47;border-radius:4px;}
