:root{
  --green:#95ec69;
  --green-deep:#3eb575;
  --side-bg:#2e2e2e;
  --side-hover:#393939;
  --side-active:#1f1f1f;
  --main-bg:#f5f5f5;
  --line:#e3e3e3;
  --text:#181818;
  --text-2:#8a8a8a;
  --blue:#576b95;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font:14px/1.6 -apple-system,"Segoe UI","Microsoft YaHei",sans-serif;
  color:var(--text);background:var(--main-bg);overflow:hidden;
  -webkit-font-smoothing:antialiased;
}
.hide{display:none !important}
button{font-family:inherit;cursor:pointer;border:none;background:none}

/* ---------- 登录 ---------- */
.login-wrap{
  position:fixed;inset:0;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(135deg,#3a3a3a,#5b5b5b);
}
.login-box{
  width:340px;background:#fff;border-radius:12px;padding:34px 30px 26px;
  box-shadow:0 18px 60px rgba(0,0,0,.3);text-align:center;
}
.login-logo{
  width:60px;height:60px;margin:0 auto 14px;border-radius:14px;
  background:var(--green);color:#fff;font:700 26px/60px -apple-system,sans-serif;
}
.login-box h1{font-size:19px;font-weight:600}
.login-sub{color:var(--text-2);font-size:12px;margin:4px 0 20px}
.seg{display:flex;background:#f0f0f0;border-radius:8px;padding:3px;margin-bottom:16px}
.seg-btn{flex:1;padding:7px;font-size:13px;color:var(--text-2);border-radius:6px}
.seg-btn.active{background:#fff;color:var(--text);font-weight:600;box-shadow:0 1px 3px rgba(0,0,0,.1)}
.login-box input{
  width:100%;padding:11px 12px;margin-bottom:10px;border:1px solid var(--line);
  border-radius:6px;font-size:14px;outline:none;background:#fafafa;
}
.login-box input:focus{border-color:var(--green-deep);background:#fff}
.btn-primary{
  width:100%;padding:11px;background:var(--green-deep);color:#fff;border-radius:6px;
  font-size:15px;font-weight:600;margin-top:4px;
}
.btn-primary:hover{filter:brightness(1.06)}
.btn-primary:disabled{opacity:.5;cursor:not-allowed}
.login-err{min-height:18px;color:#e64340;font-size:12px;margin-top:8px}

/* ---------- 布局 ---------- */
.app{display:flex;height:100vh}
.side{
  width:290px;flex:0 0 290px;background:var(--side-bg);color:#e8e8e8;
  display:flex;flex-direction:column;
}
.me{display:flex;align-items:center;gap:10px;padding:18px 16px 14px}
.avatar{
  width:38px;height:38px;flex:0 0 38px;border-radius:6px;background:var(--green-deep);
  color:#fff;font:600 16px/38px;text-align:center;
}
.me-name{font-size:15px;font-weight:600}
.me-dept{font-size:11px;color:#8a8a8a;height:14px;overflow:hidden}

.search{padding:0 12px 12px}
.search input{
  width:100%;padding:7px 10px;background:#242424;border:none;border-radius:5px;
  color:#eee;font-size:13px;outline:none;
}
.search input::placeholder{color:#6b6b6b}

.conv-list{flex:1;overflow-y:auto}
.conv{
  display:flex;gap:10px;padding:11px 14px;cursor:pointer;
  border-bottom:1px solid #262626;
}
.conv:hover{background:var(--side-hover)}
.conv.active{background:var(--side-active)}
.conv .avatar{width:40px;height:40px;flex:0 0 40px;line-height:40px;font-size:15px}
.conv-main{flex:1;min-width:0}
.conv-top{display:flex;justify-content:space-between;align-items:baseline;gap:6px}
.conv-name{font-size:14px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.conv-time{font-size:11px;color:#7d7d7d;flex:0 0 auto}
.conv-bot{display:flex;justify-content:space-between;align-items:center;gap:6px;margin-top:2px}
.conv-last{
  font-size:12px;color:#9a9a9a;white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;max-width:190px;
}
.badge{
  flex:0 0 auto;background:#fa5151;color:#fff;font-size:11px;min-width:18px;
  height:18px;line-height:18px;text-align:center;border-radius:9px;padding:0 5px;
}
.side-foot{
  display:flex;align-items:center;gap:8px;padding:10px 14px;
  border-top:1px solid #262626;font-size:11px;
}
.net{color:#6b6b6b}
.net.on{color:#7fe07f}
.mini-btn{
  margin-left:auto;color:#9a9a9a;font-size:11px;padding:3px 7px;
  border:1px solid #3d3d3d;border-radius:4px;
}
.mini-btn + .mini-btn{margin-left:0}
.mini-btn:hover{color:#fff;border-color:#5a5a5a}

/* ---------- 聊天区 ---------- */
.main{flex:1;display:flex;flex-direction:column;min-width:0;background:var(--main-bg)}
.empty{margin:auto;text-align:center;color:var(--text-2)}
.empty-logo{font-size:52px;margin-bottom:12px}
.empty-sub{font-size:12px;margin-top:6px;color:#b0b0b0}

.chat{display:flex;flex-direction:column;height:100%}
.chat-head{
  height:58px;flex:0 0 58px;background:#f7f7f7;border-bottom:1px solid var(--line);
  display:flex;align-items:center;justify-content:space-between;padding:0 22px;
}
.chat-title{font-size:16px;font-weight:600}
.chat-state{font-size:12px;color:var(--text-2)}

.msg-scroll{flex:1;overflow-y:auto;padding:20px 24px}
.msgs{display:flex;flex-direction:column;gap:16px}

.sys-msg{text-align:center;color:#b5b5b5;font-size:12px}
.time-sep{text-align:center;color:#b5b5b5;font-size:12px;margin:4px 0}

.msg{display:flex;gap:10px;max-width:78%}
.msg .avatar{width:36px;height:36px;flex:0 0 36px;line-height:36px;font-size:14px;border-radius:5px}
.msg-col{display:flex;flex-direction:column;min-width:0}
.msg-name{font-size:11px;color:var(--text-2);margin-bottom:4px;padding:0 2px}
.msg.me{flex-direction:row-reverse;align-self:flex-end}
.msg.me .msg-name{text-align:right}
.bubble{
  background:#fff;border-radius:5px;padding:9px 12px;word-break:break-word;
  white-space:pre-wrap;box-shadow:0 1px 1px rgba(0,0,0,.05);position:relative;
  max-width:100%;
}
.msg.me .bubble{background:var(--green)}
.bubble a{color:var(--blue);text-decoration:none}
.bubble a:hover{text-decoration:underline}
.msg-time{font-size:10px;color:#b5b5b5;margin-top:3px;padding:0 2px}
.msg.me .msg-time{text-align:right}

/* 文件卡片 */
.bubble.file{padding:0;background:#fff;overflow:hidden;min-width:210px}
.msg.me .bubble.file{background:var(--green)}
.file-card{display:flex;align-items:center;gap:10px;padding:12px}
.file-ico{
  width:38px;height:38px;flex:0 0 38px;border-radius:6px;background:#5b8ff9;color:#fff;
  font:700 11px/38px;text-align:center;
}
.file-meta{min-width:0;flex:1}
.file-name{
  font-size:13px;color:var(--text);white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;max-width:230px;
}
.file-size{font-size:11px;color:var(--text-2)}

/* 语音条 */
.bubble.voice{
  background:#fff;padding:0;cursor:pointer;min-width:112px;
  display:flex;align-items:center;gap:8px;padding:11px 13px;border-radius:6px;
}
.msg.me .bubble.voice{background:var(--green)}
.voice-wave{display:flex;align-items:center;gap:2px;height:16px}
.voice-wave i{width:2px;background:#5a5a5a;border-radius:1px;display:block}
.msg.me .bubble.voice .voice-wave i{background:#2f6b2f}
.voice-dur{font-size:12px;color:#555;margin-left:2px}
.msg.me .bubble.voice .voice-dur{color:#22591f}
.voice-play{font-size:13px;color:#5a5a5a}

/* 图片 */
.bubble img{max-width:280px;max-height:280px;border-radius:5px;display:block;cursor:zoom-in}

/* 未读分隔 */
.unread-tip{
  display:flex;align-items:center;gap:8px;color:#fa5151;font-size:12px;
  margin:2px 0 10px;
}
.unread-tip::before,.unread-tip::after{content:"";flex:1;height:1px;background:#f3c9c9}

.typing-tip{
  height:22px;line-height:22px;padding:0 24px;font-size:12px;color:var(--text-2);
}

/* ---------- 输入区 ---------- */
.composer{
  flex:0 0 auto;background:#f7f7f7;border-top:1px solid var(--line);
  padding:8px 20px 12px;position:relative;
}
.tools{display:flex;align-items:center;gap:6px;margin-bottom:4px}
.tool{
  width:32px;height:32px;border-radius:5px;font-size:17px;line-height:1;
}
.tool:hover{background:#e8e8e8}
.tool.rec-active{position:relative}
.tool.recording{background:#fa5151;animation:pulse 1.1s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.55}}
.rec-hint{font-size:12px;color:#fa5151;margin-left:6px}
#input{
  width:100%;height:88px;border:none;background:transparent;resize:none;
  font:14px/1.6 inherit;outline:none;padding:4px 0;
}
.send-row{display:flex;align-items:center;justify-content:flex-end;gap:10px}
.btn-primary.sm{width:auto;padding:7px 20px;font-size:13px;margin:0}
.net-tip{font-size:11px;color:var(--text-2)}

/* 表情面板 */
.emoji-picker{
  position:absolute;bottom:118px;left:20px;width:300px;max-height:230px;overflow-y:auto;
  background:#fff;border:1px solid var(--line);border-radius:8px;
  box-shadow:0 8px 26px rgba(0,0,0,.16);padding:8px;
  display:grid;grid-template-columns:repeat(10,1fr);gap:2px;z-index:20;
}
.emoji-picker button{
  font-size:19px;padding:4px;border-radius:4px;line-height:1.1;
}
.emoji-picker button:hover{background:#f0f0f0}

/* ---------- 弹窗 ---------- */
.modal{
  position:fixed;inset:0;background:rgba(0,0,0,.4);display:flex;
  align-items:center;justify-content:center;z-index:50;
}
.modal-box{
  width:400px;max-height:70vh;background:#fff;border-radius:10px;
  display:flex;flex-direction:column;overflow:hidden;
  box-shadow:0 16px 50px rgba(0,0,0,.28);
}
.modal-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 18px;border-bottom:1px solid var(--line);
}
.modal-head h3{font-size:15px;font-weight:600}
.close{font-size:22px;color:var(--text-2);line-height:1;padding:0 4px}
.close:hover{color:var(--text)}
.users-list{overflow-y:auto;padding:6px 0}
.user-row{display:flex;align-items:center;gap:10px;padding:9px 18px;cursor:pointer}
.user-row:hover{background:#f5f5f5}
.user-row .avatar{width:34px;height:34px;flex:0 0 34px;line-height:34px;font-size:13px}
.user-row .u-name{font-size:14px}
.user-row .u-dept{font-size:11px;color:var(--text-2)}

/* 提示 */
.toast{
  position:fixed;top:26px;left:50%;transform:translateX(-50%);
  background:rgba(0,0,0,.78);color:#fff;padding:9px 18px;border-radius:6px;
  font-size:13px;z-index:99;
}
.toast.err{background:#fa5151}