/* ============================================================
 * 94-ui-fix.css —— 界面修补
 *
 * 这里放的是"修 bug 留下的样式"：
 *   1. 表情回应条跟着气泡左右对齐
 *   2. 更多面板所有格子统一尺寸
 *   3. 表情回应条不被容器裁掉
 *   4. 输入框高度兜底（防止变成一个巨大的框）
 *   5. 个人主页等级行排版
 *   6. 投票区（2026-10 加：投票卡片以前从来没显示过）
 *
 * 和 99-装扮.css 分开放，是为了让每个文件都不超过 500 行。
 * ============================================================ */

/* ---------------- 投票区 ----------------
 * 放在消息区上面，最多占 38% 高度，多了自己滚动，
 * 免得几个投票把聊天记录全顶下去。 */
.poll-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 10px;
  max-height: 38vh;
  overflow-y: auto;
  flex: 0 0 auto;
}
.poll-area:empty {
  display: none;
  padding: 0;
}
.poll-area .poll-box {
  margin: 0;
}

/* ============================================================
 * 表情回应条的位置
 *
 * 规则：跟着消息气泡走 ——
 *   自己的消息（靠右）→ 回应也靠右
 *   别人的消息（靠左）→ 回应也靠左
 * 之前左右不分，全都挤在左边，看着很别扭。
 * ============================================================ */
.msg .reactions,
.msg .reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/* 别人的消息：回应靠左 */
.msg .reactions,
.msg .reaction-bar {
  justify-content: flex-start;
}

/* 自己的消息：回应靠右（.msg.mine 是自己发的） */
.msg.mine .reactions,
.msg.mine .reaction-bar {
  justify-content: flex-end;
}

/* 回应条本身要和气泡对齐：.body 里通常是纵向排列 */
.msg .bubble,
.msg .msg-main {
  display: flex;
  flex-direction: column;
}

.msg.mine .bubble,
.msg.mine .msg-main {
  align-items: flex-end;
}

.msg:not(.mine) .bubble,
.msg:not(.mine) .msg-main {
  align-items: flex-start;
}

/* 回应小药丸 */
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  font-size: 12px;
  line-height: 1.6;
  border-radius: 10px;
  background: var(--panel-soft, #f1f3f5);
  border: 1px solid var(--line, #e5e7eb);
  cursor: pointer;
  user-select: none;
}
.reaction-pill.on {
  background: #e7f6ec;
  border-color: #b7e2c6;
  color: #1f7a45;
}
.reaction-pill:hover {
  filter: brightness(0.97);
}


/* ============================================================
 * 更多面板：所有格子强制统一尺寸
 *
 * 之前"置顶"用的是 head-btn（顶栏小按钮样式）而不是 more-cell，
 * 结果它比别的格子小一圈，而且里面的数字角标把宽度撑开了。
 * 这里做三件事：
 *   ① 尺寸用 !important 锁死，任何遗漏的类名都不会再破坏整齐
 *   ② 角标绝对定位，不参与布局
 *   ③ 图标统一 22px，视觉一致
 * ============================================================ */
.more-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 10px;
}

.more-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* 所有格子（不论原来挂什么类）尺寸完全一致 */
.more-cell,
.more-slot > button {
  position: relative;
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  min-height: 46px !important;
  max-width: 46px !important;
  max-height: 46px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: 1px solid var(--line, #e5e8ec);
  border-radius: 12px;
  background: var(--panel, #fff);
  color: var(--text, #1f2933);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.more-cell:hover,
.more-slot > button:hover {
  border-color: var(--brand, #2f6fed);
  color: var(--brand, #2f6fed);
  background: var(--brand-soft, #f2f7ff);
}

/* 格子里的图标统一大小 */
.more-cell .ico,
.more-slot > button .ico {
  width: 22px;
  height: 22px;
}

/* 数字角标：绝对定位在右上角，绝不撑大格子 */
.more-cell .rbadge,
.more-cell .more-badge,
.more-slot > button > span:not(.ico) {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 10px;
  height: 17px;
  padding: 0 5px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: #e5484d;
  border: 2px solid var(--panel, #fff);
  border-radius: 9px;
  white-space: nowrap;
  pointer-events: none;
}

/* 角标隐藏时不占位 */
.more-cell .rbadge.hidden,
.more-cell .more-badge.hidden {
  display: none !important;
}

/* 文字标签统一 */
.more-label {
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted, #5b6875);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 隐藏的格子不占位 */
.more-slot.hidden { display: none !important; }

/* 窄屏：4 列改 4 列但缩小间距（保持整齐） */
@media (max-width: 420px) {
  .more-grid { gap: 12px 6px; }
  .more-cell, .more-slot > button {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    max-height: 42px !important;
  }
  .more-label { font-size: 11px; }
}


/* ============================================================
 * 表情回应条：不被消息容器裁掉
 *
 * 之前的问题：回应条挂在消息里，消息容器有 overflow:hidden / 固定宽度，
 * 结果右边的表情被切掉（截图上只剩半颗心）。
 * ============================================================ */
.msg,
.msg .body,
.msg .msg-main,
.msg .bubble {
  overflow: visible !important;      /* 让回应条能超出气泡范围 */
}

.msg .reactions,
.msg .reaction-bar {
  display: flex !important;
  flex-wrap: wrap !important;        /* 放不下就换行，不要横着切掉 */
  gap: 4px !important;
  margin-top: 5px !important;
  max-width: 100% !important;
  overflow: visible !important;
}

/* 回应的小药丸不要被压扁 */
.reaction-pill,
.rx-chip {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
  max-width: none !important;
}

/* 消息气泡本身也允许换行，长内容不撑破 */
.msg .bubble {
  overflow-wrap: anywhere;
}

/* 自己的消息（靠右）：呼应靠右对齐 */
.msg.mine .reactions { justify-content: flex-end !important; }
.msg:not(.mine) .reactions { justify-content: flex-start !important; }

/* 手机上回应条可以占满整行，避免被挤 */
@media (max-width: 640px) {
  .msg { max-width: 92% !important; }
  .msg .reactions { width: 100% !important; }
}


/* ============================================================
 * 输入框高度兜底
 * 即使 JS 没执行（或算错了），也不会变成一个巨大的框
 * ============================================================ */
#input-msg,
.composer textarea#input-msg {
  box-sizing: border-box;
  min-height: 40px;
  max-height: 170px;
  overflow-y: auto;
  resize: none;
}
/* 空的时候按一行显示（:placeholder-shown 表示当前显示的是提示文字） */
#input-msg:placeholder-shown {
  height: 40px !important;
}




/* ============================================================
 * 个人主页：等级行排版
 *
 * 真实结构（从 index.html 读出来的）：
 *   <div class="home-level">
 *     <div class="home-level-line">
 *       <span id="home-level-text">Lv.10 · 4025 经验 · 648 沙币</span>
 *       <span id="home-level-next">距离下一级还差 175 经验（在线 +2/分钟，发言 +5）</span>
 *     </div>
 *     <div class="home-level-track"><div id="home-level-bar"></div></div>
 *   </div>
 *
 * 之前的问题：两个 span 挤在一行里，都换行，结果
 *   "648 沙币" 掉到第二行、"距离下一级…" 也被拆成两行，很乱。
 *
 * 现在：两个 span 各自不拆行；放不下时整体换成上下两行。
 * ============================================================ */
.home-level {
  margin: 10px 0 4px;
}

.home-level-line {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: baseline !important;
  justify-content: space-between !important;
  gap: 4px 12px !important;
}

/* 左边：Lv.X · N 经验 · M 沙币 —— 整块不拆行 */
#home-level-text {
  flex: 0 1 auto !important;
  white-space: nowrap !important;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.7;
}

/* 右边：距离下一级还差 X 经验 —— 整块不拆行 */
#home-level-next {
  flex: 0 0 auto !important;
  white-space: nowrap !important;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted, #7b8794);
}

/* 进度条 */
.home-level-track {
  margin-top: 6px;
  height: 8px;
  border-radius: 4px;
  background: var(--panel-soft, #eef1f5);
  overflow: hidden;
}
#home-level-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #34a853, #4dc97a);
  transition: width .3s ease;
}

/* 窄屏：上下排列，右边那句允许换行 */
@media (max-width: 520px) {
  .home-level-line {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
  }
  #home-level-text { font-size: 14px; }
  #home-level-next { white-space: normal !important; }
}

/* 个人主页底部按钮：小屏允许换行，别把按钮压成一竖条 */
@media (max-width: 480px) {
  #modal-homepage .modal-actions {
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: center !important;
  }
  #modal-homepage .modal-actions .btn {
    flex: 1 1 auto;
    min-width: 88px;
  }
}


/* ---------------- GitHub 登录按钮 ---------------- */
.oauth-row {
  margin: 10px 0 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--line, #e5e8ec);
}
.oauth-row .btn.block { width: 100%; }


/* ============================================================
 * 专注模式：聊天区用满整个宽度（用户反馈"只有中间一块有消息"）
 *
 * 注意：消息行 .msg 是网格布局（38px 头像列 + 内容列），
 * 这里只能放宽"容器"和"气泡文字"的上限，绝不能给 .msg 加 width/max-width
 * 的强制值 —— 那会把网格挤变形（头像跑偏、右边被切掉，窄窗口上尤其明显）。
 * ============================================================ */
body.zen .messages {
  max-width: none !important;      /* 原来是 860px，宽屏上只剩中间一条 */
  padding-left: 14px !important;
  padding-right: 14px !important;
  overflow-x: hidden !important;   /* 兜底：任何情况下都不许横向溢出 */
}
/* 气泡里的文字别拉太长，太长的行读起来累 */
body.zen .msg > .text {
  max-width: min(78ch, 100%) !important;
}
/* 图片这类宽内容也别把网格撑破 */
body.zen .messages img:not(.avatar) { max-width: 100% !important; }

/* ============================================================
 * 空头像容器：不渲染成一个空方框
 * （用户截图里有一行"空图标 + 头像"，就是空的 avatar-wrap 撑出来的）
 * ============================================================ */
.avatar-wrap:empty { display: none !important; }
.avatar-wrap > *:only-child.status-dot { display: none !important; }
/* 头像加载失败也别留一个空框 */
.avatar.img { background: var(--panel-soft, #f1f4f8); }


/* ============================================================
 * 补齐"JS 里用了但从来没有样式"的 4 个类
 * （用 tools/hunt-bugs.mjs 扫出来的：这些元素一直是裸的）
 * ============================================================ */

/* 表情面板里的表情按钮 */
.emoji-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background .12s, transform .12s;
}
.emoji-btn:hover { background: var(--panel-soft, #f1f4f8); transform: scale(1.12); }
.emoji-btn:active { transform: scale(.96); }

/* 房间列表里"我自己的房间" */
.room-item.mine-room .rname::after {
  content: '我的';
  margin-left: 6px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 400;
  vertical-align: middle;
  border-radius: 999px;
  background: var(--brand-soft, #e6f4ea);
  color: var(--brand, #34a853);
}

/* 表情选择面板里的每个贴纸格子 */
.sticker-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 4px;
  border: 1px solid var(--line, #e5e8ec);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .12s, transform .12s;
}
.sticker-cell:hover { border-color: var(--brand, #34a853); transform: translateY(-1px); }
.sticker-cell img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* 表单提示文字：普通提示(.info) 与 错误提示(.err) 分开上色 */
.form-msg { margin-top: 6px; font-size: 12.5px; line-height: 1.6; }
.form-msg.info { color: var(--muted, #5b6875); }
.form-msg.err { color: #c0392b; }
.form-msg:empty { display: none; }
