*{margin:0;padding:0;box-sizing:border-box}
body{font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",sans-serif;background:#f5f5f5;height:100vh;overflow:hidden;color:#191919}
.page{height:100%;width:100%}
.hidden{display:none!important}

#authPage{display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#07c160,#1aad19)}
.login-box{background:#fff;padding:36px 28px;border-radius:16px;width:90%;max-width:360px;text-align:center;box-shadow:0 8px 32px rgba(0,0,0,.15)}
.logo{font-size:48px;margin-bottom:8px}
.login-box h1{font-size:22px;margin-bottom:16px}
.auth-tabs{display:flex;margin-bottom:16px;border-radius:8px;overflow:hidden;border:1px solid #e0e0e0}
.auth-tab{flex:1;padding:10px;border:none;background:#f5f5f5;cursor:pointer;font-size:14px}
.auth-tab.active{background:#07c160;color:#fff;font-weight:600}
#authUser,#authPass{width:100%;padding:12px;border:1px solid #e0e0e0;border-radius:8px;font-size:16px;outline:none;margin-bottom:12px}
#authBtn{width:100%;padding:12px;background:#07c160;color:#fff;border:none;border-radius:8px;font-size:16px;font-weight:600}
.error{color:#e64340;font-size:13px;margin-top:8px;min-height:18px}

#mainPage{display:flex;height:100%}
#sidebar{width:280px;background:#f7f7f7;border-right:1px solid #e0e0e0;display:flex;flex-direction:column;flex-shrink:0}
.sidebar-header{padding:14px 16px;background:#2e2e2e;color:#fff;display:flex;justify-content:space-between;align-items:center;font-weight:600}
#logoutBtn{background:none;border:1px solid #666;color:#ccc;padding:4px 10px;border-radius:4px;font-size:12px}
.tabs{display:flex;border-bottom:1px solid #e0e0e0}
.tab{flex:1;padding:12px 4px;border:none;background:none;font-size:14px;color:#888;position:relative;cursor:pointer}
.tab.active{color:#07c160;font-weight:600}
.tab.active::after{content:'';position:absolute;bottom:0;left:20%;width:60%;height:2px;background:#07c160}
.tab-content{flex:1;overflow-y:auto}
.search-box{padding:10px;display:flex;gap:6px}
.search-box input{flex:1;padding:8px 10px;border:1px solid #e0e0e0;border-radius:6px;font-size:14px;outline:none}
.search-box button{padding:8px 12px;background:#07c160;color:#fff;border:none;border-radius:6px;font-size:13px}
.group-actions{padding:10px}
#createGroupBtn{width:100%;padding:10px;background:#07c160;color:#fff;border:none;border-radius:6px;font-size:14px}
.section-title{padding:10px 16px 4px;font-size:12px;color:#888}
.list{list-style:none}
.list-item{padding:12px 16px;display:flex;align-items:center;gap:12px;border-bottom:1px solid #f0f0f0;cursor:pointer}
.list-item:active,.list-item:hover{background:#e8e8e8}
.avatar{width:40px;height:40px;border-radius:6px;background:#07c160;color:#fff;display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:600;flex-shrink:0}
.avatar.g{background:#576b95}
.item-info{flex:1;min-width:0}
.item-name{font-size:15px;font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.item-desc{font-size:12px;color:#888;margin-top:2px}
.badge{display:inline-block;background:#e64340;color:#fff;font-size:11px;min-width:16px;height:16px;line-height:16px;border-radius:8px;padding:0 4px;margin-left:2px}
.badge.hidden{display:none}
.btn-sm{padding:4px 10px;border:none;border-radius:4px;font-size:12px;cursor:pointer}
.btn-ok{background:#07c160;color:#fff}
.btn-no{background:#f0f0f0;color:#666}

#chatArea{flex:1;display:flex;flex-direction:column;background:#f5f5f5;min-width:0}
.empty-state{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;color:#888}
.empty-icon{font-size:56px;margin-bottom:12px;opacity:.5}
#chatView{flex:1;display:flex;flex-direction:column;height:100%;overflow:hidden}
.chat-header{padding:12px 16px;background:#f7f7f7;border-bottom:1px solid #e0e0e0;display:flex;align-items:center;gap:10px;font-weight:600;font-size:16px;flex-shrink:0}
.back-btn{display:none;background:none;border:none;font-size:20px;padding:0 4px}
.hdr-btn{margin-left:auto;background:none;border:1px solid #576b95;color:#576b95;padding:4px 10px;border-radius:4px;font-size:12px}
.hdr-btn.leave{border-color:#e64340;color:#e64340}

.message-list{flex:1;overflow-y:auto;padding:12px;min-height:0}
.message{display:flex;gap:8px;max-width:75%;margin-bottom:10px}
.message.self{margin-left:auto;flex-direction:row-reverse}
.message .avatar{width:34px;height:34px;font-size:13px}
.bubble-wrap{display:flex;flex-direction:column}
.message.self .bubble-wrap{align-items:flex-end}
.sender-name{font-size:11px;color:#888;margin-bottom:2px;padding:0 4px}
.bubble{padding:9px 12px;border-radius:8px;font-size:15px;line-height:1.4;word-break:break-word}
.message:not(.self) .bubble{background:#fff;border-top-left-radius:2px}
.message.self .bubble{background:#95ec69;border-top-right-radius:2px}
.bubble img{max-width:160px;max-height:160px;border-radius:6px;display:block}
.bubble video{max-width:200px;max-height:150px;border-radius:6px;display:block}
.msg-time{font-size:10px;color:#aaa;margin-top:3px;padding:0 4px}

.input-area{padding:10px 12px;background:#f7f7f7;border-top:1px solid #e0e0e0;display:flex;gap:6px;align-items:center;flex-shrink:0}
.icon-btn{width:36px;height:36px;display:flex;align-items:center;justify-content:center;font-size:18px;background:#eee;border:none;border-radius:6px;flex-shrink:0;cursor:pointer}
#messageInput{flex:1;padding:10px 12px;border:1px solid #e0e0e0;border-radius:8px;font-size:15px;outline:none;min-width:0}
#sendBtn{padding:10px 16px;background:#07c160;color:#fff;border:none;border-radius:8px;font-size:15px;font-weight:600;white-space:nowrap}

.modal{position:fixed;inset:0;background:rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center;z-index:100}
.modal-content{background:#fff;padding:20px;border-radius:12px;width:90%;max-width:320px}
.modal-content h3{margin-bottom:12px}
#groupNameInput{width:100%;padding:12px;border:1px solid #e0e0e0;border-radius:8px;font-size:15px;margin-bottom:16px}
.modal-actions{display:flex;gap:10px;justify-content:flex-end}
.modal-actions button{padding:10px 18px;border-radius:6px;font-size:14px;border:none}
#cancelCreate{background:#f0f0f0}
#confirmCreate{background:#07c160;color:#fff}

@media(max-width:768px){
  #sidebar{width:100%;position:absolute;z-index:10;height:100%}
  #sidebar.hidden-mobile{display:none}
  #chatArea{width:100%}
  .back-btn{display:block}
  .message{max-width:85%}
}

.emoji-panel {
  flex-shrink: 0;
  max-height: 160px;
  overflow-y: auto;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.emoji-panel.hidden { display: none !important; }
.emoji-panel span {
  width: 36px;
  height: 36px;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  user-select: none;
}
.emoji-panel span:active { background: #eee; }
