/* ============================================================
 * 06-messages.css  （475 行）
 * style.css 的拆分片段（按顺序加载，与原来完全等价）。
 *
 * 这一片主要管这些类：
 *   · .messages（10 处）
 *   · .create-room-modal（10 处）
 *   · .side-tools（7 处）
 *   · .composer（7 处）
 *   · .side-foot-bar（5 处）
 *   · .msg（4 处）
 *   · .ctx-item（4 处）
 *   · .room-list（4 处）
 *   · .modal（4 处）
 *   · .new-room-btn（3 处）
 *   · .fwd-row（3 处）
 *   · .poll-opt（3 处）
 *   · .md-table（3 处）
 *   · .ask-input（3 处）
 *   · .side-rooms（2 处）
 *   · .side-members（2 处）
 *   · .member-more（2 处）
 *   · .md-p（2 处）
 * ============================================================ */
/* 回应小胶囊再紧凑一点 */
.messages .msg .rx-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; }

/* ============================================================
 * 侧栏重排：三个区块各自滚动，谁都不会把谁挤爆
 * ============================================================ */
.sidebar {
  display: flex !important;
  flex-direction: column !important;
  gap: 0;
  overflow: hidden;              /* 由内部区块各自滚动 */
}
.side-section { display: flex; flex-direction: column; min-height: 0; }
.side-rooms { flex: 0 1 auto; }
.side-members { flex: 1 1 auto; min-height: 120px; }

/* 房间列表：最多占 40% 高度，多了内部滚动 */
.side-rooms .room-list {
  max-height: 36vh; overflow-y: auto; padding: 2px 6px 6px;
  flex: 0 1 auto;
}
/* 成员列表：占满剩余空间，内部滚动 */
.side-members .member-list {
  flex: 1 1 auto; overflow-y: auto; padding: 2px 6px 8px; min-height: 0;
}

/* 新建房间：贴着房间列表，样式更轻 */
.new-room-btn {
  margin: 4px 10px 8px; padding: 8px 10px;
  border: 1px dashed var(--brand-line); border-radius: 10px;
  background: transparent; color: var(--brand);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .14s, border-color .14s;
}
.new-room-btn:hover { background: var(--brand-soft); border-style: solid; }

/* 成员标题上的"全部 ›" */
.members-more { margin-left: auto; font-size: 11.5px; color: var(--brand); }
.members-head { display: flex; align-items: center; gap: 6px; }

/* "查看全部 N 人" */
.member-more {
  padding: 7px 10px; font-size: 12.5px; color: var(--brand);
  cursor: pointer; border-radius: 8px; text-align: center;
}
.member-more:hover { background: var(--brand-soft); }

/* 底部工具条：紧凑两行 */
.side-foot-bar {
  flex: 0 0 auto;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.side-tools { display: flex; gap: 6px; }
.side-tools .mini-btn { flex: 1; }
.side-foot-bar .support-link { margin: 0; }
.side-foot-bar .btn.block { font-size: 13px; padding: 8px; }
#guest-tip { margin: 6px 10px 10px; font-size: 11px; line-height: 1.5; color: var(--muted); }

/* ============================================================
 * 侧栏底部工具：三个方块按钮 → 一行低调的文字入口
 *   ♥ 支持一下（爱发电）
 *   管理 · 导出 · 全部
 * ============================================================ */
.side-tools {
  display: flex; align-items: center; justify-content: center;
  gap: 0; margin-top: 2px;
}
.side-tools .mini-btn {
  flex: 0 0 auto;
  border: none !important;
  background: none !important;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.side-tools .mini-btn:hover { color: var(--brand); background: var(--brand-soft) !important; }
.side-tools .mini-btn + .mini-btn { border-left: 1px solid var(--line) !important; border-radius: 0; }
.side-tools .mini-btn + .mini-btn:hover { border-left-color: var(--brand-line) !important; }

/* 支持链接更细一些，别太抢 */
.side-foot-bar .support-link { padding: 6px 8px; font-size: 12px; justify-content: center; }
.side-foot-bar { padding: 8px 10px 8px; gap: 2px; }

/* ============================================================
 * Markdown + LaTeX 样式
 * ============================================================ */
.md-p { margin: 0; }
.md-p + .md-p { margin-top: 6px; }
.md-h { font-weight: 600; margin: 4px 0 2px; }
.md-h1 { font-size: 17px; }
.md-h2 { font-size: 15.5px; }
.md-h3 { font-size: 14.5px; }
.md-code {
  background: rgba(0,0,0,.06); border-radius: 5px;
  padding: 1px 5px; font-size: 13px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
}
html[data-theme="dark"] .md-code { background: rgba(255,255,255,.1); }
.md-pre {
  position: relative;
  background: #1f2430; color: #e6e9ef;
  border-radius: 9px; padding: 11px 12px; margin: 6px 0;
  overflow-x: auto; font-size: 12.8px; line-height: 1.55;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  max-width: 100%;
}
.md-pre code { white-space: pre; }
.md-lang {
  position: absolute; top: 6px; right: 10px;
  font-size: 10.5px; color: #8b93a5; text-transform: uppercase;
}
.md-quote {
  margin: 6px 0; padding: 6px 10px;
  border-left: 3px solid var(--brand-line);
  background: var(--brand-soft); border-radius: 0 8px 8px 0;
  color: var(--text); font-size: 13.5px;
}
.md-ul, .md-ol { margin: 6px 0; padding-left: 22px; }
.md-ul li, .md-ol li { margin: 2px 0; }
.md-hr { height: 1px; background: var(--line); margin: 10px 0; border: none; }
.md-link { color: var(--brand); text-decoration: none; border-bottom: 1px solid var(--brand-line); word-break: break-all; }
.md-link:hover { border-bottom-color: var(--brand); }
.msg .text strong { font-weight: 600; }
.msg .text em { font-style: italic; }
.msg .text s { opacity: .6; }

/* 公式 */
.math-inline { display: inline-block; vertical-align: middle; margin: 0 1px; }
.math-block {
  display: block; margin: 8px 0; padding: 4px 0;
  overflow-x: auto; text-align: center;
}
.math-fallback { font-family: monospace; color: #e0507a; }
.katex { font-size: 1.02em; }

/* 输入框支持多行 */
#input-msg {
  resize: none !important;
  line-height: 1.55;
  max-height: 160px;
  overflow-y: auto;
  font-family: inherit;
}

/* ============================================================
 * 输入区布局修正
 *   问题：textarea 默认宽度 100%，把发送按钮挤出可视区
 *   做法：输入框可收缩（min-width:0），按钮固定宽度不参与压缩
 * ============================================================ */
.composer {
  display: flex !important;
  align-items: flex-end !important;      /* 输入框变高时，按钮对齐到底部 */
  gap: 8px !important;
  padding: 10px 12px !important;
}
.composer #input-msg,
.composer textarea#input-msg {
  flex: 1 1 auto !important;
  width: auto !important;                /* 关键：不要 100% */
  min-width: 0 !important;               /* 关键：允许被压缩 */
  max-width: none !important;
  height: 40px;
  min-height: 40px;
  max-height: 170px;
  padding: 9px 14px !important;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
}
.composer #input-msg:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--panel);
}
.composer #btn-send {
  flex: 0 0 auto !important;             /* 关键：按钮不被压缩 */
  width: auto !important;
  min-width: 66px;
  height: 40px;
  padding: 0 18px !important;
  border-radius: 10px;
  white-space: nowrap !important;        /* 关键：文字不换行 */
  writing-mode: horizontal-tb !important;
}
/* 图标按钮统一 40px，和输入框同高 */
.composer .btn.icon {
  flex: 0 0 40px !important;
  width: 40px !important;
  height: 40px !important;
  border-radius: 10px !important;
}
/* 窄屏（手机）隐藏次要按钮，保证输入框和发送按钮够用 */
@media (max-width: 560px) {
  .composer #btn-share-coins,
  .composer #btn-poll { display: none; }
  .composer #btn-send { min-width: 56px; padding: 0 12px !important; }
}

/* ==================== 本轮细节 ==================== */
/* 最近使用表情 */
.emoji-recent { padding: 8px 12px 4px; border-bottom: 1px solid var(--line); }
.emoji-recent-title { font-size: 11.5px; color: var(--muted); display: block; margin-bottom: 4px; }
.emoji-recent-row { display: flex; flex-wrap: wrap; gap: 2px; }
.emoji-recent-empty { font-size: 12px; color: var(--muted); }

/* 右键菜单 */
.ctx-menu {
  position: fixed; z-index: 200;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; min-width: 140px;
  box-shadow: 0 8px 26px rgba(0,0,0,.16);
}
.ctx-item {
  display: block; width: 100%; text-align: left;
  border: none; background: none; color: var(--text);
  font-size: 13.5px; padding: 8px 12px; border-radius: 7px; cursor: pointer;
}
.ctx-item:hover { background: var(--brand-soft); color: var(--brand); }

/* 未读分隔线 */
.unread-divider {
  align-self: center; margin: 6px 0 12px;
  font-size: 11.5px; color: #fff;
  background: var(--brand); opacity: .82;
  padding: 2px 12px; border-radius: 999px;
}

/* 滚动条：细一点，别抢视觉 */
.messages::-webkit-scrollbar,
.room-list::-webkit-scrollbar,
.member-list::-webkit-scrollbar,
.dm-list::-webkit-scrollbar { width: 8px; height: 8px; }
.messages::-webkit-scrollbar-thumb,
.room-list::-webkit-scrollbar-thumb,
.member-list::-webkit-scrollbar-thumb,
.dm-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.14); border-radius: 999px;
}
.messages::-webkit-scrollbar-thumb:hover,
.room-list::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,.26); }
html[data-theme="dark"] .messages::-webkit-scrollbar-thumb,
html[data-theme="dark"] .room-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); }
.messages::-webkit-scrollbar-track,
.room-list::-webkit-scrollbar-track { background: transparent; }

/* 输入框去掉右下角拖拽把手 */
.composer #input-msg { resize: none !important; }

/* 置顶的房间：左侧一条小标记 */
.room-item.is-pinned .rname::before {
  content: '📌'; font-size: 10px; margin-right: 3px; opacity: .7;
}

/* ==================== 本轮新增 ==================== */
/* 转发多选 */
.fwd-row { cursor: pointer; }
.fwd-row.picked { background: var(--brand-soft); border-radius: 9px; }
.fwd-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand); }

/* 投票柱状图 */
.poll-track {
  height: 7px; background: var(--panel-soft); border-radius: 999px;
  overflow: hidden; margin-top: 4px;
}
.poll-bar { height: 100%; background: var(--brand-line); border-radius: 999px; transition: width .25s; }
.poll-bar.mine { background: var(--brand); }
.poll-opt { padding: 7px 0; cursor: pointer; }
.poll-opt:hover .poll-bar { opacity: .85; }
.poll-opt-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.poll-opt-num { color: var(--muted); font-size: 12px; white-space: nowrap; }
.poll-opt.mine .poll-opt-label { color: var(--brand); font-weight: 500; }

/* 日期跳转 */
.jump-date {
  width: 116px; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; font-size: 12.5px; background: var(--panel-soft); color: var(--text);
}
.jump-date:focus { outline: none; border-color: var(--brand); }
.messages .msg.flash > .text { animation: msgFlash 1.4s ease; }
@keyframes msgFlash {
  0% { box-shadow: 0 0 0 3px var(--brand); }
  100% { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
}

/* 等级标签 */
.lv-tag {
  font-size: 10px; font-weight: 600; color: #b8860b;
  background: rgba(255,200,60,.18); border-radius: 5px; padding: 1px 5px;
  flex: 0 0 auto;
}
html[data-theme="dark"] .lv-tag { color: #ffd166; background: rgba(255,209,102,.14); }

/* 房间表情包分页 */
.sticker-scope { display: flex; gap: 6px; padding: 8px 12px 0; }
.scope-tab {
  border: none; background: none; color: var(--muted);
  font-size: 13px; padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.scope-tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ==================== 新建房间弹窗 ==================== */
.modal.create-room-modal { width: 420px; max-width: calc(100vw - 24px); }
.create-room-modal .field { position: relative; display: block; margin-bottom: 14px; }
.create-room-modal .field > span:first-child {
  display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px;
}
.create-room-modal input,
.create-room-modal textarea {
  width: 100%; border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--line); background: var(--panel-soft);
  color: var(--text); font-size: 14.5px; font-family: inherit;
}
.create-room-modal textarea { resize: vertical; min-height: 76px; max-height: 160px; line-height: 1.6; }
.create-room-modal input:focus,
.create-room-modal textarea:focus { outline: none; border-color: var(--brand); background: var(--panel); }
.cr-count {
  position: absolute; right: 4px; bottom: -16px;
  font-size: 11px; color: var(--muted);
}
.create-room-modal .field { margin-bottom: 20px; }
.create-room-modal #cr-tip { margin: 0 0 12px; }
.create-room-modal .modal-actions { margin-top: 6px; }

/* 侧栏里旧的输入条：彻底不显示 */
#create-room-bar { display: none !important; }
/* 新建房间按钮更好按 */
.new-room-btn { padding: 10px; font-size: 13.5px; }

/* ============================================================
 * 消息操作改成右键 / 长按菜单
 *   原来的悬浮按钮条不再出现（它会盖在消息上，很难看）
 * ============================================================ */
.messages .msg .msg-actions { display: none !important; }

/* 消息可以被选中复制 */
.messages .msg .text { user-select: text; -webkit-user-select: text; }
.messages .msg { -webkit-touch-callout: none; }

/* 菜单里多一行"危险操作"（撤回） */
.ctx-item.danger { color: #e0507a; }
.ctx-item.danger:hover { background: rgba(224,80,122,.1); }

/* 解析弹窗 */
.modal.raw-modal { width: 520px; max-width: calc(100vw - 24px); }
.raw-tip { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; line-height: 1.6; }
.raw-text {
  background: var(--panel-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  max-height: 42vh; overflow-y: auto; margin: 0 0 8px;
  user-select: text; -webkit-user-select: text;
}
.raw-text::selection { background: var(--brand-soft); }
.raw-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 12px; }

/* Markdown 新语法：表格 / 任务清单 / 图片 / 嵌套列表 */
.md-table { border-collapse: collapse; margin: 8px 0; font-size: 13.5px; max-width: 100%; display: block; overflow-x: auto; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.md-table th { background: var(--panel-soft); font-weight: 600; }
.md-tasklist { list-style: none; padding-left: 4px; }
.md-task { display: flex; align-items: flex-start; gap: 6px; }
.md-check { color: var(--brand); font-size: 14px; line-height: 1.4; }
.md-task.done { opacity: .6; text-decoration: line-through; }
.md-sub { margin: 2px 0 2px 14px; }
.md-img-wrap { display: inline-flex; flex-direction: column; gap: 2px; margin: 4px 0; }
.md-img { max-width: 220px; max-height: 220px; border-radius: 9px; cursor: zoom-in; display: block; }
.md-img-cap { font-size: 11.5px; color: var(--muted); }

/* 字数提示：接近上限才出现 */
.len-hint {
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
  align-self: center; margin-right: 2px;
}
.len-hint.over { color: #e0507a; font-weight: 600; }

/* ==================== 通用输入弹窗 ==================== */
.modal.ask-modal { width: 460px; max-width: calc(100vw - 24px); }
.ask-label { font-size: 13.5px; color: var(--text); margin: 0 0 8px; line-height: 1.6; }
.ask-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.ask-input {
  width: 100%; border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--line); background: var(--panel-soft);
  color: var(--text); font-size: 14.5px; font-family: inherit;
  line-height: 1.6; resize: vertical; max-height: 240px;
}
.ask-input.multiline { min-height: 120px; }
.ask-input:focus { outline: none; border-color: var(--brand); background: var(--panel); }

/* 确认弹窗里的确定按钮（危险操作红色） */
#ask-ok.danger { background: #e0507a; border-color: #e0507a; }
#ask-ok.danger:hover { background: #cf3f6a; }

/* ==================== 个人主页 ==================== */
.modal.home-modal { width: 460px; max-width: calc(100vw - 24px); }
.home-top { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.home-avatar { width: 76px; height: 76px; flex: 0 0 auto; }
.home-id h2 { margin: 0 0 4px; font-size: 19px; }
.home-account { margin: 0; font-size: 12px; color: var(--muted); }
.home-tags { margin: 4px 0 0; font-size: 12px; color: var(--brand); }
.home-level { margin: 10px 0 6px; }
.home-level-line { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.home-level-track { height: 8px; background: var(--panel-soft); border-radius: 999px; overflow: hidden; }
.home-level-bar { height: 100%; background: linear-gradient(90deg, var(--brand), #4ade80); border-radius: 999px; transition: width .3s; }
.home-bio {
  margin: 10px 0; font-size: 13.5px; line-height: 1.7;
  background: var(--panel-soft); border-radius: 10px; padding: 10px 12px;
  white-space: pre-wrap; word-break: break-word;
}
.home-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 14px; }
.home-stat { text-align: center; background: var(--panel-soft); border-radius: 10px; padding: 8px 4px; }
.home-stat-k { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.home-stat-v { font-size: 14px; color: var(--text); }

/* ==================== 多选模式 ==================== */
body.selecting .messages .msg { cursor: pointer; }
body.selecting .messages .msg .text { outline: 1px dashed var(--line); }
.messages .msg.picked .text { outline: 2px solid var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.select-bar {
  position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%);
  z-index: 120; display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
  font-size: 13.5px;
}
.select-bar .btn { padding: 6px 14px; font-size: 13px; border-radius: 999px; }

/* ==================== 公告展开 ==================== */
.announce-toggle {
  border: none; background: none; color: var(--brand);
  font-size: 12px; cursor: pointer; padding: 0 4px; white-space: nowrap;
}
.announce-bar.expanded { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
.announce-bar.expanded .announce-text { white-space: pre-wrap; line-height: 1.7; }

/* ==================== 日期时间轴 ==================== */
.date-rail {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 4px;
  max-height: 60%; overflow-y: auto; padding: 4px;
}
.rail-dot {
  border: none; background: var(--panel); color: var(--muted);
  border: 1px solid var(--line);
  font-size: 10.5px; padding: 2px 6px; border-radius: 6px;
  cursor: pointer; white-space: nowrap; opacity: .7;
}
.rail-dot:hover { opacity: 1; color: var(--brand); border-color: var(--brand-line); background: var(--brand-soft); }
.chat-pane { position: relative; }

/* 语音消息的文字 */
.msg .voice-text { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ============================================================
 * 弹窗按钮布局修正
 *   之前 5 个按钮挤在一行，文字被压成竖排（"发私聊"变成三行）
 * ============================================================ */
.modal-actions {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}