/* ====== CHAT ====== */
.chat-body{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.chat-users-list-wrapper{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.chat-search-box{display:flex;align-items:center;gap:8px;padding:12px 16px;border-bottom:1px solid var(--line-color);background:var(--box-bg);position:relative;flex-shrink:0}
.chat-search-input-wrap{position:relative;flex:1;min-width:0}
.chat-search-input-wrap>i{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--accent);pointer-events:none;font-size:.85rem;z-index:1}
.chat-search-input{flex:1;background:var(--bg-color);border:1px solid var(--line-color);border-radius:22px;padding:11px 16px;color:var(--text-color-override);font-size:16px !important;outline:none;min-width:0;width:100%;padding-left:38px !important;padding-right:38px}
.chat-search-clear{background:transparent;border:none;color:var(--text-secondary);cursor:pointer;font-size:.8rem;padding:6px;display:none}
.chat-search-clear.show{display:block}
.chat-users-list{flex:1;overflow-y:auto;padding:8px}
.chat-user-item{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;cursor:pointer;border:1px solid transparent;margin-bottom:4px;transition:all .2s}
.chat-user-item:hover{background:var(--box-hover-bg);border-color:var(--line-color)}
.chat-user-item.admin-row{background:linear-gradient(135deg,rgba(var(--accent-rgb),.08),rgba(var(--accent-rgb),.02))}
.chat-user-avatar{width:48px;height:48px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--accent-2));color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:1.15rem;flex-shrink:0;overflow:hidden;border:2px solid rgba(var(--accent-rgb),.4);position:relative}
.chat-user-avatar.small{width:38px;height:38px;font-size:.95rem}
.chat-user-avatar img{width:100%;height:100%;object-fit:cover}
.chat-user-avatar.admin-avatar{border-color:#1d9bf0}
.chat-user-avatar .admin-crown{position:absolute;top:-7px;left:50%;transform:translateX(-50%);color:#fbbf24;font-size:.65rem}
.chat-user-info{flex:1;min-width:0}
.chat-user-name{font-size:.9rem;font-weight:600;color:var(--text-color-override);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:flex;align-items:center;gap:4px}
.chat-user-preview{font-size:.72rem;color:var(--text-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}
.chat-user-username{font-size:.68rem;color:var(--accent);font-weight:600;margin-top:2px;display:inline-flex;align-items:center;gap:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-unread-badge{background:linear-gradient(135deg,var(--accent),var(--accent-2));color:#fff;font-size:.6rem;font-weight:800;min-width:22px;height:22px;padding:0 7px;border-radius:11px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.chat-empty{text-align:center;padding:50px 20px;color:var(--text-secondary);font-size:.85rem;opacity:.8}
.chat-empty i{font-size:2.2rem;color:var(--accent);opacity:.5;display:block;margin-bottom:10px}
.chat-conversation{flex:1;display:flex;flex-direction:column;min-height:0}
.chat-conv-header{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--line-color);background:var(--box-bg);flex-shrink:0}
.chat-profile-btn{background:transparent;border:1px solid var(--line-color);color:var(--accent);cursor:pointer;font-size:.85rem;padding:7px 11px;border-radius:10px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.chat-profile-btn.chat-profile-btn-lg{font-size:1.35rem !important;padding:0 !important;border-radius:50% !important;width:46px !important;height:46px !important;display:flex !important;align-items:center !important;justify-content:center !important}
.chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:6px;background-color:var(--bg-color);position:relative}
.chat-msg{max-width:82%;display:flex;flex-direction:column;gap:2px;word-wrap:break-word;position:relative;z-index:1}
.chat-msg.mine{align-self:flex-end;align-items:flex-end}
.chat-msg.theirs{align-self:flex-start;align-items:flex-start}
.chat-msg-text{padding:10px 14px;border-radius:20px;font-size:.86rem;line-height:1.45;word-break:break-word;white-space:pre-wrap}
.chat-msg.mine .chat-msg-text{background:linear-gradient(135deg,#9333ea,#c084fc);color:#fff;border-bottom-right-radius:6px}
.chat-msg.theirs .chat-msg-text{background:rgba(255,255,255,.14);border:1px solid var(--line-color);color:var(--text-color-override);border-bottom-left-radius:6px}
body.light-mode .chat-msg.theirs .chat-msg-text{background:#fff;border-color:rgba(0,0,0,.08)}
.chat-msg-time{font-size:.6rem;color:#94a3b8;padding:0 8px;display:flex;align-items:center;gap:4px}
.chat-msg-time .read-status{color:#60a5fa;font-size:.65rem}
.chat-msg-actions{display:flex;gap:4px;opacity:0;transition:opacity .2s;margin-top:-4px;margin-bottom:4px}
.chat-msg:hover .chat-msg-actions{opacity:1}
.chat-msg-action-btn{background:var(--box-bg);border:1px solid var(--line-color);color:var(--text-secondary);cursor:pointer;font-size:.65rem;padding:4px 8px;border-radius:8px;display:inline-flex;align-items:center;gap:3px}
.chat-msg-action-btn.delete:hover{color:#ef4444}
.chat-msg-photo{max-width:100%;border-radius:14px;overflow:hidden;cursor:pointer;display:inline-block}
.chat-msg-photo img{display:block;width:100%;max-width:240px;height:auto;border-radius:14px}
.chat-input-row{display:flex;gap:8px;padding:12px;border-top:1px solid var(--line-color);background:var(--box-bg);align-items:center;flex-shrink:0}
.chat-input{flex:1;background:var(--bg-color);border:1px solid var(--line-color);border-radius:22px;padding:12px 18px;color:var(--text-color-override);font-size:16px !important;outline:none;min-width:0}
.chat-send-btn{width:46px;height:46px;border-radius:50%;border:none;background:linear-gradient(135deg,var(--accent),var(--accent-2));color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:.95rem;flex-shrink:0}
.chat-mic-btn{width:46px;height:46px;border-radius:50%;background:var(--box-bg);border:1px solid var(--line-color);color:var(--accent);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:1rem;flex-shrink:0}
.chat-reply-preview{display:flex;align-items:center;gap:8px;padding:8px 14px;background:rgba(var(--accent-rgb),.08);border-top:1px solid var(--line-color);font-size:.72rem;color:var(--text-secondary);flex-shrink:0}
.chat-reply-preview .reply-line{width:3px;height:30px;background:var(--accent);border-radius:3px}
.chat-reply-preview .reply-content{flex:1;min-width:0}
.chat-reply-preview .reply-name{color:var(--accent);font-weight:600;font-size:.7rem}
.chat-reply-preview .reply-text{color:var(--text-color-override);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.72rem;margin-top:2px}
.chat-reply-preview .reply-close{background:transparent;border:none;color:var(--text-secondary);cursor:pointer;font-size:.85rem;padding:4px}