*{margin:0;padding:0;box-sizing:border-box}
body{font-family:-apple-system,sans-serif;background:#f5f5f5;height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden;position:fixed;width:100%}
#status-bar{background:#fff;padding:4px 10px;font-size:10px;color:#999;display:flex;align-items:center;gap:6px;border-bottom:1px solid #eee;min-height:26px}
.dot{width:6px;height:6px;border-radius:50%;display:inline-block}
.dot.on{background:#4caf50}.dot.off{background:#f44336}
#main{display:flex;flex:1;overflow:hidden;min-height:0;height:0}
#sidebar{width:180px;background:#fff;border-right:1px solid #eee;display:flex;flex-direction:column;flex-shrink:0;height:100%;overflow:hidden}
#sidebar h3{padding:8px 10px;font-size:12px;color:#333;border-bottom:1px solid #eee}
.contact-list{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;min-height:0}
.contact-item{padding:8px 10px;cursor:pointer;border-bottom:1px solid #f5f5f5;display:flex;align-items:center;gap:6px;font-size:11px}
.contact-item:hover,.contact-item.active{background:#e8f4fd}
.badge{font-size:8px;padding:1px 5px;border-radius:6px;color:#fff}
.badge-friend{background:#2196f3}.badge-group{background:#ff9800}
#chat{flex:1;display:flex;flex-direction:column;background:#f5f5f5;min-height:0;height:100%;overflow:hidden}
#chat-header{background:#fff;padding:8px 10px;font-size:13px;font-weight:600;border-bottom:1px solid #eee;flex-shrink:0}
#messages{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:8px;display:flex;flex-direction:column;gap:6px;min-height:0}
.msg{max-width:75%;padding:6px 10px;border-radius:10px;font-size:12px;line-height:1.4;word-break:break-word}
.msg.self{align-self:flex-end;background:#95ec69;border-bottom-right-radius:3px}
.msg.other{align-self:flex-start;background:#fff;border-bottom-left-radius:3px}
.msg .meta{font-size:8px;color:#999;margin-top:3px}
.msg img{max-width:150px;max-height:150px;border-radius:6px;cursor:pointer}
.msg video{max-width:180px;border-radius:6px}
.msg audio{width:160px}
#input-area{background:#fff;padding:6px;display:flex;gap:6px;border-top:1px solid #eee;flex-shrink:0}
#input-area input{flex:1;padding:6px 10px;border:1px solid #ddd;border-radius:16px;font-size:12px;outline:none}
#input-area button{padding:6px 12px;background:#2196f3;color:#fff;border:none;border-radius:16px;font-size:12px;cursor:pointer}
#input-area button:disabled{background:#ccc}
#btn-bar{display:flex;gap:4px}
#btn-bar button{padding:3px 8px;font-size:9px;border:1px solid #ddd;border-radius:10px;background:#fff;cursor:pointer;color:#666}
#token-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center;z-index:999}
#token-modal.hidden{display:none}
#token-modal .box{background:#fff;padding:18px;border-radius:10px;width:260px;text-align:center}
#token-modal input{width:100%;padding:8px;margin:10px 0;border:1px solid #ddd;border-radius:6px;font-size:12px}
#token-modal button{padding:8px 20px;background:#2196f3;color:#fff;border:none;border-radius:6px;font-size:12px;cursor:pointer}
#empty-state{flex:1;display:flex;align-items:center;justify-content:center;color:#999;font-size:12px}

/* Emoji Panel */
#emoji-toggle{background:none;border:1px solid #ddd;border-radius:5px;font-size:13px;padding:1px 6px;cursor:pointer;margin-right:4px;line-height:1}
#emoji-panel{display:none;position:absolute;bottom:40px;left:8px;background:#fff;border:1px solid #ddd;border-radius:10px;padding:8px;width:280px;max-height:260px;overflow:hidden;box-shadow:0 3px 12px rgba(0,0,0,.12);z-index:999}
#emoji-panel.open{display:block}
#emoji-panel button{width:30px;height:30px;border:none;background:#f5f5f5;border-radius:5px;cursor:pointer;transition:background .15s;display:flex;align-items:center;justify-content:center;padding:0}
#emoji-panel button:hover{background:#e0e0e0}

/* Record button */
#record-btn {
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#record-btn.recording {
  background: #f44336;
  animation: pulse-rec 0.8s infinite;
  transform: scale(1.1);
}
@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,67,54,0.5); }
  50% { box-shadow: 0 0 0 10px rgba(244,67,54,0); }
}
#record-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}
/* Lightbox */
.lightbox{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.85);display:flex;align-items:center;justify-content:center;z-index:9999;cursor:zoom-out}
.lightbox.hidden{display:none}
.lb-close{position:absolute;top:12px;right:18px;font-size:32px;color:#fff;cursor:pointer;z-index:10000;line-height:1;user-select:none}
.lb-content{max-width:92vw;max-height:92vh;display:flex;align-items:center;justify-content:center}
.lb-content img{max-width:92vw;max-height:92vh;border-radius:6px;object-fit:contain;cursor:default}
.lb-content video{max-width:92vw;max-height:92vh;border-radius:6px;outline:none;cursor:default}
