/* ============================================================
 * 微信风聊天室 · 美化版样式
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --green: #07C160;
  --green-deep: #06AD56;
  --green-grad: linear-gradient(135deg, #0BD07A 0%, #07C160 55%, #06A952 100%);
  --self-bubble: linear-gradient(135deg, #9BEF7D 0%, #7DE56A 60%, #6BDD60 100%);
  --sidebar: #23252b;
  --sidebar-2: #2b2e36;
  --sidebar-hover: rgba(255, 255, 255, .05);
  --sidebar-active: rgba(7, 193, 96, .14);
  --chat-bg: #f2f4f7;
  --chat-bg-grad: linear-gradient(180deg, #eef3f8 0%, #f4f6f9 100%);
  --border: #e8eaee;
  --text: #1d2129;
  --text-sub: #8a919f;
  --red: #fa5151;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 33, .05), 0 2px 8px rgba(20, 24, 33, .04);
  --shadow-md: 0 6px 24px rgba(20, 24, 33, .10);
  --shadow-lg: 0 16px 48px rgba(20, 24, 33, .16);
}
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text); background: #e8ecf1; overflow: hidden;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }

/* ============ 登录 / 注册页 ============ */
#login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(7, 193, 96, .18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(16, 174, 239, .16), transparent 60%),
    linear-gradient(160deg, #e9f9ef 0%, #f4fbf6 45%, #eef4fd 100%);
}
.login-card {
  width: 370px; max-width: 92vw; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px); border-radius: 20px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, .7) inset;
  padding: 38px 34px; text-align: center;
  animation: cardIn .45s cubic-bezier(.2, .9, .3, 1.2);
}
.login-card + .login-card { margin-left: 22px; }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.login-logo {
  width: 84px; height: 84px; margin: 0 auto 6px; border-radius: 24px;
  background: var(--green-grad); color: #fff; font-size: 44px; line-height: 84px;
  box-shadow: 0 10px 24px rgba(7, 193, 96, .35);
}
.login-card h1 { font-size: 22px; margin: 12px 0 4px; letter-spacing: 1px; }
.login-sub { color: var(--text-sub); font-size: 13px; margin-bottom: 24px; }
.login-card input {
  width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 12px;
  padding: 0 14px; font-size: 15px; outline: none; transition: border .2s, box-shadow .2s; background: #fff;
}
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(7, 193, 96, .14); }
#roomPassInput, #passInput, #regPwdInput, #regPwd2Input { margin-top: 12px; }
.color-row { display: flex; justify-content: center; gap: 9px; margin: 18px 0 20px; flex-wrap: wrap; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent;
  transition: transform .15s, box-shadow .15s;
}
.color-swatch:hover { transform: scale(1.18); }
.color-swatch.sel { border-color: #333; transform: scale(1.12); box-shadow: 0 0 0 3px rgba(7, 193, 96, .2); }
#loginBtn, #registerSubmitBtn {
  width: 100%; height: 46px; border: none; border-radius: 12px; background: var(--green-grad);
  color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; letter-spacing: 4px;
  transition: transform .15s, box-shadow .2s, filter .2s;
  box-shadow: 0 6px 16px rgba(7, 193, 96, .3);
}
#loginBtn:hover, #registerSubmitBtn:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 10px 22px rgba(7, 193, 96, .38); }
#loginBtn:disabled { opacity: .65; cursor: wait; transform: none; }
.btn-ghost {
  width: 100%; height: 42px; margin-top: 12px; border: 1px solid var(--green); border-radius: 12px;
  background: #fff; color: var(--green); font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s, transform .15s;
}
.btn-ghost:hover { background: #f0fbf4; transform: translateY(-1px); }
.login-tip { color: var(--text-sub); font-size: 12px; margin-top: 16px; }

/* ============ 主界面 ============ */
#app { display: flex; height: 100vh; height: 100dvh; background: var(--chat-bg); }

/* --- 侧边栏 --- */
#sidebar {
  width: 268px; min-width: 268px; background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #d6dae3; display: flex; flex-direction: column; z-index: 60;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 12px;
}
.me { display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.me-name { font-size: 15px; color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { font-size: 11px; color: var(--green); text-shadow: 0 0 8px rgba(7, 193, 96, .8); }
.conn.off { color: var(--red); text-shadow: none; }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; color: #fff; font-size: 17px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.avatar.img { overflow: hidden; padding: 0; box-shadow: none; }
.avatar.img img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.avatar.big { width: 68px; height: 68px; font-size: 30px; border-radius: 18px; }
.search {
  margin: 2px 12px 10px; height: 32px; border: none; border-radius: 10px; background: rgba(255, 255, 255, .08);
  color: #e8eaf0; padding: 0 12px; font-size: 13px; outline: none; transition: background .2s;
}
.search:focus { background: rgba(255, 255, 255, .13); }
.search::placeholder { color: #7c8394; }
.contact-list { flex: 1; overflow-y: auto; list-style: none; padding: 2px 8px 8px; }
.contact {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; position: relative;
  border-radius: 12px; transition: background .15s; margin-bottom: 1px;
}
.contact:hover { background: var(--sidebar-hover); }
.contact.active { background: var(--sidebar-active); }
.contact.active::before {
  content: ''; position: absolute; left: -4px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 2px; background: var(--green); box-shadow: 0 0 8px rgba(7, 193, 96, .7);
}
.c-name { flex: 1; font-size: 14px; color: #e9ebf2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact.offline .c-name { color: #8b93a3; }
.badge {
  min-width: 19px; height: 19px; border-radius: 10px; background: var(--red); color: #fff;
  font-size: 11px; display: none; align-items: center; justify-content: center; padding: 0 5px;
  box-shadow: 0 2px 6px rgba(250, 81, 81, .45);
}
.badge.show { display: inline-flex; }
.sep { padding: 12px 12px 4px; font-size: 11px; color: #6f7788; letter-spacing: 2px; list-style: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5a6172; flex-shrink: 0; }
.dot.on { background: var(--green); box-shadow: 0 0 6px rgba(7, 193, 96, .9); }
.accept-btn {
  border: none; background: var(--green-grad); color: #fff; border-radius: 8px;
  padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; flex-shrink: 0;
  transition: filter .15s, transform .15s;
}
.accept-btn:hover { filter: brightness(1.1); transform: scale(1.04); }
.del-btn {
  border: none; background: transparent; color: #f06a6a; font-size: 14px;
  cursor: pointer; padding: 2px 7px; border-radius: 8px; flex-shrink: 0; transition: background .15s;
}
.del-btn:hover { background: rgba(240, 106, 106, .18); }
.add-friend .c-name { color: #3ddc84; }
.req-bar {
  background: #fff7e8; border-bottom: 1px solid #f2ddac; padding: 9px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 13px; flex-shrink: 0;
  animation: msgIn .25s ease;
}
.req-bar .req-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-bar .accept-btn, .req-bar .reject-btn { padding: 5px 14px; }
.announce-bar {
  background: linear-gradient(135deg, #fff7e8, #fff3dc); border-bottom: 1px solid #f2ddac;
  padding: 9px 14px; font-size: 13px; display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; cursor: default; animation: msgIn .25s ease;
}
.announce-bar .a-icon { flex-shrink: 0; }
.announce-bar .a-text { flex: 1; min-width: 0; word-break: break-all; line-height: 1.5; }
.announce-bar.admin { cursor: pointer; }
.announce-bar.admin:hover { background: linear-gradient(135deg, #fff3da, #ffecc8); }
.announce-bar .a-edit { color: var(--green); font-size: 12px; flex-shrink: 0; }
.msg-audio { display: block; min-width: 180px; height: 40px; }
/* 微信式语音条 */
.voice-bubble { display: inline-flex; align-items: center; gap: 8px; min-width: 110px; color: var(--green); }
.bubble.voice { padding: 8px 12px; }
.voice-play {
  width: 30px; height: 30px; border-radius: 50%; border: none; background: rgba(255, 255, 255, .92);
  color: var(--green); font-size: 12px; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.msg.self .voice-bubble { color: #0b7a3a; }
.voice-dur { font-size: 12px; color: #666; min-width: 30px; }
.msg.self .voice-dur { color: #3f7a2a; }
.voice-wave { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.voice-wave i { width: 3px; height: 5px; background: currentColor; border-radius: 1px; }
.voice-bubble.playing .voice-wave i { animation: wave 1s ease-in-out infinite; }
.voice-bubble.playing .voice-wave i:nth-child(2) { animation-delay: .15s; }
.voice-bubble.playing .voice-wave i:nth-child(3) { animation-delay: .3s; }
.voice-bubble.playing .voice-wave i:nth-child(4) { animation-delay: .45s; }
.voice-bubble.playing .voice-wave i:nth-child(5) { animation-delay: .6s; }
@keyframes wave { 0%, 100% { height: 5px; } 50% { height: 14px; } }
.msg-read { font-size: 11px; color: #b6bcc8; margin-top: 3px; }
.msg.self .msg-read { align-self: flex-end; }
.mic-recording { color: #fff !important; background: #e04b4b !important; border-radius: 10px; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.rec-bar {
  background: #fdecec; border-bottom: 1px solid #f5c6c6; color: #e04b4b;
  font-size: 13px; padding: 8px 14px; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e04b4b; animation: pulse 1s infinite; flex-shrink: 0; }
#recTime { font-weight: 700; font-variant-numeric: tabular-nums; }
.reject-btn {
  border: 1px solid #c9ced8; background: #fff; color: #6b7280; border-radius: 8px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; flex-shrink: 0; transition: background .15s;
}
.reject-btn:hover { background: #f3f4f6; }
.sidebar-footer { padding: 10px 16px; font-size: 12px; color: #6f7788; border-top: 1px solid rgba(255, 255, 255, .07); }

/* --- 聊天区 --- */
#chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg-grad); }
#chatHeader {
  height: 64px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; flex-shrink: 0; box-shadow: 0 1px 4px rgba(20, 24, 33, .04);
}
.header-left { display: flex; align-items: center; min-width: 0; }
.chat-title { font-size: 17px; font-weight: 700; }
.chat-sub { font-size: 12px; color: var(--text-sub); margin-top: 2px; }
.menu-btn {
  display: none; border: none; background: transparent; font-size: 22px; color: var(--text);
  cursor: pointer; margin-right: 8px; padding: 2px 8px; border-radius: 8px; line-height: 1;
}
.menu-btn:hover { background: #f0f2f5; }
.invite-btn {
  border: 1px solid var(--green); background: #fff; color: var(--green);
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .2s, transform .15s; margin-left: 8px;
}
.invite-btn:hover { background: #f0fbf4; transform: translateY(-1px); }
.online-badge {
  font-size: 12px; color: var(--green); background: #e9f9f0; padding: 5px 12px;
  border-radius: 14px; white-space: nowrap; margin-left: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 5px;
}
.online-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 5px rgba(7,193,96,.8); }
.invite-btn.danger { color: #e04b4b; border-color: #e04b4b; }
.invite-btn.danger:hover { background: #fdf0f0; }
.messages { flex: 1; overflow-y: auto; padding: 14px 0 8px; }
.msg { display: flex; gap: 10px; padding: 6px 18px; align-items: flex-start; animation: msgIn .22s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.self { flex-direction: row-reverse; }
.msg-col { max-width: 64%; display: flex; flex-direction: column; }
.msg.self .msg-col { align-items: flex-end; }
.msg-name { font-size: 12px; color: #9aa1af; margin: 0 0 3px 3px; }
.bubble {
  background: #fff; border-radius: 14px; padding: 9px 14px; font-size: 15px; line-height: 1.6;
  position: relative; word-break: break-word; white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}
.msg.self .bubble { background: var(--self-bubble); }
.bubble::before {
  content: ''; position: absolute; top: 13px; left: -6px;
  border: 6px solid transparent; border-right-color: #fff; border-left-width: 0;
}
.msg.self .bubble::before {
  left: auto; right: -6px; border-right-color: transparent;
  border-left-color: #7de56a; border-left-width: 6px;
}
.msg-img { max-width: 240px; max-height: 240px; border-radius: 12px; display: block; cursor: zoom-in; }
.time-chip {
  text-align: center; font-size: 11px; color: #9aa1af; padding: 10px 0 6px;
}
.time-chip::before {
  content: ''; display: inline-block; vertical-align: middle; width: 7px; height: 7px;
  border-radius: 50%; background: #c3c9d4; margin-right: 6px;
}
.empty-tip { text-align: center; color: #aab2c0; font-size: 14px; padding: 90px 20px; line-height: 2; }

/* --- 输入区 --- */
#inputBar {
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
  position: relative; flex-shrink: 0; backdrop-filter: blur(10px);
}
.input-row { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; }
.icon-btn {
  width: 40px; height: 40px; border: none; background: transparent; font-size: 21px;
  cursor: pointer; border-radius: 10px; flex-shrink: 0; transition: background .15s, transform .15s;
}
.icon-btn:hover { background: #f0f2f5; transform: scale(1.05); }
#input {
  flex: 1; resize: none; border: none; outline: none; font-size: 15px; line-height: 1.5;
  max-height: 120px; padding: 9px 12px; font-family: inherit; background: #f2f4f7;
  border-radius: 12px; transition: background .2s;
}
#input:focus { background: #eef1f5; }
#sendBtn {
  width: 82px; height: 40px; border: none; border-radius: 12px; background: var(--green-grad);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; flex-shrink: 0;
  transition: filter .2s, transform .15s; box-shadow: 0 4px 12px rgba(7, 193, 96, .28);
}
#sendBtn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.emoji-panel {
  position: absolute; bottom: 66px; left: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-md); padding: 12px; width: 340px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; z-index: 10;
}
.emoji-panel button {
  border: none; background: transparent; font-size: 21px; padding: 5px; cursor: pointer; border-radius: 8px;
}
.emoji-panel button:hover { background: #f0f2f5; }
.mention-panel {
  position: absolute; bottom: 66px; left: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-md); padding: 8px; width: 200px;
  display: flex; flex-direction: column; gap: 2px; z-index: 10; max-height: 220px; overflow-y: auto;
}
.mention-panel button {
  border: none; background: transparent; text-align: left; font-size: 14px; color: var(--text);
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.mention-panel button:hover { background: #e9f9f0; color: var(--green); }
.mention-panel .m-empty { color: var(--text-sub); font-size: 13px; padding: 8px 10px; }

/* --- 弹窗 / 图片查看 / 提示 --- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 18, 25, .5); z-index: 90;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.modal-card {
  width: 350px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
  background: #fff; border-radius: 20px; padding: 26px;
  box-shadow: var(--shadow-lg); animation: cardIn .3s ease;
}
.modal-card h3 { font-size: 18px; margin-bottom: 18px; }
.modal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-label { font-size: 13px; color: var(--text-sub); margin: 12px 0 6px; }
.modal-row input {
  flex: 1; height: 40px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; font-size: 15px; outline: none;
}
.modal-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(7, 193, 96, .12); }
.emoji-avatar-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0 10px; }
.emoji-opt {
  width: 40px; height: 40px; font-size: 23px; border: 2px solid transparent;
  background: #f2f4f7; border-radius: 10px; cursor: pointer; line-height: 1;
}
.emoji-opt:hover { background: #e8eaee; }
.emoji-opt.sel { border-color: var(--green); background: #e9f9f0; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions button {
  flex: 1; height: 44px; border: none; border-radius: 12px; background: var(--green-grad);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.modal-actions .btn-ghost { border: 1px solid var(--green); background: #fff; color: var(--green); }
.logout-btn { border-color: #e04b4b !important; color: #e04b4b !important; }
.logout-btn:hover { background: #fdf0f0 !important; }

.lightbox {
  position: fixed; inset: 0; background: rgba(8, 10, 14, .92); z-index: 95;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;
}
.lightbox img { max-width: 92vw; max-height: 76vh; border-radius: 12px; box-shadow: var(--shadow-lg); }
.lightbox-bar { display: flex; gap: 12px; margin-top: 18px; }
.lightbox-bar .invite-btn {
  color: #fff; border-color: rgba(255, 255, 255, .7); background: rgba(255, 255, 255, .12);
  text-decoration: none; padding: 10px 20px; border-radius: 12px; margin-left: 0;
}
.lightbox-bar .invite-btn:hover { background: rgba(255, 255, 255, .26); }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(8px);
  background: rgba(20, 24, 33, .88); color: #fff; font-size: 13px; padding: 11px 20px;
  border-radius: 24px; z-index: 99; opacity: 0; transition: opacity .25s, transform .25s;
  pointer-events: none; max-width: 82vw; backdrop-filter: blur(6px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }

/* --- 滚动条 --- */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #cfd5de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b6bdc9; }
#sidebar ::-webkit-scrollbar-thumb { background: #434a59; }

/* --- 手机端：侧边栏抽屉 --- */
@media (max-width: 640px) {
  .menu-btn { display: inline-flex; align-items: center; }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 272px; min-width: 272px;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.3, .8, .3, 1);
    box-shadow: 8px 0 32px rgba(0, 0, 0, .3);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebarBackdrop {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 55;
    display: block; opacity: 0; pointer-events: none; transition: opacity .28s;
  }
  #sidebarBackdrop.show { opacity: 1; pointer-events: auto; }
  .msg { padding: 6px 12px; }
  .msg-col { max-width: 78%; }
  .msg-img { max-width: 190px; max-height: 190px; }
}
