/* 03-msg.css（style.css 拆分片段，按顺序加载）
 * 主要类：room-item、member-list、member、member-name、member-tag、chat-head、messages、msg
 */
.room-item:hover { background: var(--panel-soft); }
.room-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--brand-line);
}
.room-item .rcount {
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-soft);
  border-radius: 999px;
  padding: 1px 8px;
}
.room-item.active .rcount { background: #fff; color: var(--brand); }

/* 成员 */
.member-list { padding: 0 8px 8px; }
.member { border-radius: 9px; padding: 6px 9px; }
.member:hover { background: var(--panel-soft); }
.member.me { background: var(--brand-soft); }
.member-name { font-size: 13px; }
.member-tag { font-size: 10px; color: var(--muted); }

/* 聊天区头部 */
.chat-head {
  padding: 0 18px;
  height: 54px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.chat-head strong { font-size: 15px; letter-spacing: -.2px; }

/* 消息区 */
.messages {
  padding: 18px 18px 10px;
  gap: 10px;
  background:
    radial-gradient(1200px 400px at 20% -10%, var(--brand-soft), transparent 70%),
    var(--bg);
}
.msg {
  max-width: min(620px, 74%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 13px;
  box-shadow: 0 1px 2px rgba(18, 24, 40, .04);
  transition: box-shadow .15s, transform .15s;
}
.msg:hover { box-shadow: 0 4px 14px rgba(18, 24, 40, .08); }
.msg .meta { margin-bottom: 3px; gap: 6px; }
.msg .name { font-size: 12.5px; font-weight: 600; }
.msg .time { font-size: 11px; color: var(--muted); }
.msg .text { font-size: 14.5px; line-height: 1.62; word-break: break-word; }

/* 自己的消息 */
.msg.mine {
  background: linear-gradient(180deg, var(--mine), color-mix(in srgb, var(--mine) 70%, var(--panel)));
  border-color: var(--mine-line);
  border-radius: 14px 14px 4px 14px;
  align-self: flex-end;
  margin-left: auto;
}
/* 被 @ 的消息 */
.msg.mentioned {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand-line), 0 4px 16px rgba(59, 111, 245, .12);
}
/* 连续同一个人的消息：收紧间距、隐藏重复头 */
.msg.same { margin-top: -4px; }
.msg.same .meta { display: none; }
.msg.same .avatar { visibility: hidden; }

/* 头像 */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex: 0 0 auto;
  margin-right: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.msg > .avatar { margin: 0; }
/* 头像与内容分两列：不用改 DOM，靠 grid 自动分列 */
.msg {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 9px;
  align-items: start;
}
.msg > .avatar { grid-column: 1; grid-row: 1 / span 30; }
.msg > :not(.avatar) { grid-column: 2; min-width: 0; }
/* 自己的消息：头像在右 */
.msg.mine { grid-template-columns: minmax(0, 1fr) auto; }
.msg.mine > .avatar { grid-column: 2; }
.msg.mine > :not(.avatar) { grid-column: 1; }
/* 系统消息没有头像，不要留空列 */
.msg.system { display: block; }

.msg.mine > .avatar { margin: 0; }

/* 系统提示 */
.msg.system {
  align-self: center;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 0;
}

/* 输入区 */
.composer {
  padding: 12px 16px 14px;
  gap: 8px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.composer input {
  border-radius: 999px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 14.5px;
  transition: border-color .15s, background .15s;
}
.composer input:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--panel);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.btn {
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 86%, #000));
  box-shadow: 0 2px 8px rgba(59, 111, 245, .28);
  border: none;
}
.btn.icon { border-radius: 50%; padding: 0; width: 38px; height: 38px; font-size: 17px; }
.btn.ghost:hover { background: var(--panel-soft); }

/* 引用条 / 公告 / 置顶 */
.quote-bar, .announce-bar, .pinned-bar { backdrop-filter: blur(6px); }
.announce-bar { padding: 9px 16px; }
.pinned-bar { padding: 8px 16px; }

/* 弹窗 */
.modal {
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 22px;
}
.modal h3 { margin: 0 0 14px; font-size: 17px; letter-spacing: -.2px; }
.modal input, .modal select {
  border-radius: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  font-size: 14.5px;
}
.modal input:focus { outline: none; border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }

/* 空状态 */
.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 2;
  padding: 40px 20px;
}
.empty-state .big { font-size: 40px; display: block; margin-bottom: 6px; opacity: .8; }

/* 手机端微调（覆盖 v2，保持与响应式一致） */
@media (max-width: 780px) {
  .messages { padding: 12px 12px 8px; }
  .msg { max-width: 88%; border-radius: 13px 13px 13px 4px; }
  .avatar { width: 26px; height: 26px; font-size: 12px; }
  .topbar { height: 52px; padding: 0 12px; }
  .sidebar-head, .members-head { padding-top: 12px; }
}

/* ==================== 个人资料弹窗 ==================== */
.modal.small { width: 380px; max-width: calc(100vw - 24px); }
.profile-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.profile-avatar { width: 76px; height: 76px; flex: 0 0 auto; }
.avatar.big { width: 76px; height: 76px; font-size: 30px; margin: 0; }
.profile-upload { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.profile-upload .tip { width: 100%; margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* 头像图片样式 */
.avatar.img { object-fit: cover; padding: 0; background: var(--panel-soft); }

/* ==================== 投票编辑器 ==================== */
.modal.poll-modal { width: 440px; max-width: calc(100vw - 24px); }
.poll-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.poll-opt-row { display: flex; align-items: center; gap: 8px; }
.poll-opt-idx {
  width: 22px; height: 22px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand);
  border-radius: 6px; font-size: 12px; font-weight: 600;
}
.poll-opt-row input { flex: 1; }
.poll-opt-del {
  border: none; background: none; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 0 4px;
}
.poll-opt-del:hover { color: var(--danger); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.poll-settings { display: flex; flex-direction: column; gap: 6px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }
.tip.err { color: var(--danger); font-size: 12px; min-height: 16px; margin: 0 0 8px; }

/* ==================== 投票卡片 v2 ==================== */
.poll-card {
  align-self: center;
  width: min(460px, 94%);
  margin: 8px 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 6px 22px rgba(18, 24, 40, .07);
}
.poll-card .poll-q { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.poll-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.poll-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-soft); color: var(--muted);
}
.poll-opts { display: flex; flex-direction: column; gap: 6px; }
.poll-opt {
  position: relative; display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-soft); color: var(--text);
  cursor: pointer; overflow: hidden; font-size: 13.5px;
  transition: border-color .15s, transform .12s;
}
.poll-opt:hover { border-color: var(--brand); }
.poll-opt:active { transform: scale(.99); }
.poll-opt.mine { border-color: var(--brand); background: var(--brand-soft); }
.poll-opt .poll-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--brand-soft); transition: width .3s;
}
.poll-opt.mine .poll-bar { background: var(--brand-line); }
.poll-key {
  position: relative; width: 20px; height: 20px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; font-size: 11px; font-weight: 600; color: var(--muted);
}
.poll-opt.mine .poll-key { background: var(--brand); border-color: var(--brand); color: #fff; }
.poll-label { position: relative; flex: 1; text-align: left; word-break: break-word; }
.poll-num { position: relative; color: var(--muted); font-size: 11px; white-space: nowrap; }
.poll-submit { margin-top: 8px; width: 100%; }
.poll-custom-row { display: flex; gap: 6px; margin-top: 10px; }
.poll-custom-row input { flex: 1; border-radius: 10px; padding: 9px 12px; border: 1px solid var(--line); background: var(--panel-soft); font-size: 13.5px; }
.poll-custom-row input:focus { outline: none; border-color: var(--brand); background: var(--panel); }
.poll-answers { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.poll-answer { font-size: 13px; color: var(--text); word-break: break-word; }
.poll-answer b { color: var(--brand); font-weight: 600; }
.poll-foot { margin-top: 10px; font-size: 11px; color: var(--muted); }

/* 实名投票：选项里的投票人名单 */
.poll-opt { flex-wrap: wrap; }
.poll-voters {
  position: relative;
  flex: 0 0 100%;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--muted);
  text-align: left;
  word-break: break-word;
}
.poll-opt:disabled { cursor: not-allowed; opacity: .82; }
.poll-close { margin-left: 8px; padding: 4px 10px; font-size: 12px; }
.btn.icon.locked { opacity: .55; }
.btn.icon.locked::after {
  content: '🔒';
  position: absolute;
  transform: translate(9px, -9px);
  font-size: 9px;
}
.btn.icon { position: relative; }

/* 游客看投票：选项加锁样式 + 注册提示 */
.poll-opt.locked { opacity: .9; }
.poll-opt.locked:hover { border-color: var(--line); }
.poll-locked {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}
.poll-locked:hover { border-color: var(--brand); color: var(--brand); }

/* ==================== 切房间加载态 ==================== */
.messages.loading { justify-content: flex-start; }
.room-loading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 0; width: 100%; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--brand-line);
  border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.room-loading-text { font-size: 13px; color: var(--muted); }
.skeleton { width: min(560px, 86%); display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.sk-line {
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--panel-soft) 25%, var(--line) 37%, var(--panel-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
.sk-line.right { align-self: flex-end; width: 62%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
/* 换房间时旧消息淡出，避免"闪一下全白" */
.messages.switching { opacity: .35; transition: opacity .12s; }
.room-item.active { transition: background .12s, color .12s; }

/* ==================== 房间介绍面板 ==================== */
.modal.room-modal { width: 460px; max-width: calc(100vw - 24px); }
.room-meta { margin: -6px 0 14px; font-size: 12px; color: var(--muted); }
.room-block { margin-bottom: 12px; }
.room-block-title {
  display: inline-block;
  font-size: 11px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--brand); background: var(--brand-soft);
  padding: 2px 8px; border-radius: 999px; margin-bottom: 6px;
}
.room-block-text {
  margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  background: var(--panel-soft); border-radius: 10px; padding: 10px 12px;
}
.room-block-text.empty { color: var(--muted); font-style: italic; }
textarea {
  width: 100%; border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--line); background: var(--panel-soft);
  font-family: inherit; font-size: 14px; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ==================== 批量管理（重做） ==================== */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px 6px;
  padding: 5px 6px 5px 10px;
  border-radius: 10px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-line);
  font-size: 12px;
  white-space: nowrap;
}
.bulk-count { flex: 1; color: var(--brand); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.bulk-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.bulk-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.bulk-btn:hover { border-color: var(--brand); color: var(--brand); }
.bulk-btn.danger { color: var(--danger); border-color: #f3c9c7; }
.bulk-btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.bulk-btn:disabled { opacity: .45; cursor: not-allowed; }

/* 房间项里的勾选框 */
.room-item.bulk { padding-left: 8px; }
.bulk-cb {
  width: 15px; height: 15px; margin-right: 8px;
  accent-color: var(--brand);
  flex: 0 0 auto;
  cursor: pointer;
}
.bulk-cb:disabled { opacity: .35; cursor: not-allowed; }
.room-item.bulk-off { opacity: .45; }
.room-item.bulk-off .rname { text-decoration: line-through; }
.room-del { display: none; }                 /* 批量模式下不再显示单个删除按钮 */
.room-item.bulk .room-del { display: none; }

/* 顶栏个人头像 */
.me-avatar {
  width: 30px; height: 30px; font-size: 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 0;
}
.me-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.me-avatar:hover { transform: scale(1.06); }
.avatar.img { padding: 0; overflow: hidden; }
.avatar.img img { width: 100%; height: 100%; object-fit: cover; }

/* ==================== 表情包 ==================== */
.emoji-tabs {
  display: flex; gap: 4px; padding: 6px 10px 0;
  border-bottom: 1px solid var(--line);
}
.emoji-tab {
  border: none; background: none; cursor: pointer;
  font-size: 12.5px; color: var(--muted);
  padding: 6px 10px; border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
}
.emoji-tab:hover { color: var(--text); background: var(--panel-soft); }
.emoji-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.emoji-tab.add { margin-left: auto; color: var(--brand); }
.sticker-pane { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 10px; }
.sticker-cat { font-size: 11px; color: var(--muted); margin: 6px 0 4px; }
.sticker-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sticker-item {
  border: 1px solid var(--line); background: var(--panel-soft);
  border-radius: 8px; padding: 2px; cursor: pointer; line-height: 0;
  transition: transform .12s, border-color .15s;
}
.sticker-item:hover { transform: scale(1.08); border-color: var(--brand); }
.sticker-item img { width: 64px; height: 64px; object-fit: contain; display: block; }
.msg-image.sticker { max-width: 140px; max-height: 140px; border: none; background: transparent; }

/* ==================== 表情回应 ==================== */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
.rx-chip {
  border: 1px solid var(--line); background: var(--panel-soft);
  border-radius: 999px; padding: 1px 8px; font-size: 12px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.rx-chip:hover { border-color: var(--brand); }
.rx-chip.mine { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.rx-add {
  border: 1px dashed var(--line); background: none; color: var(--muted);
  border-radius: 999px; padding: 1px 7px; font-size: 11px; cursor: pointer; opacity: .55;
  transition: opacity .15s;
}
.reactions:hover .rx-add { opacity: 1; }
.rx-add:hover { color: var(--brand); border-color: var(--brand); }
.rx-picker {
  display: inline-flex; gap: 2px; padding: 2px 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow);
}