/* 07-modal.css（style.css 拆分片段，按顺序加载）
 * 主要类：modal-actions、modal、card-modal、album-filter、album-chip、gift-tip、gift-list、gift-card
 */
.modal-actions .btn {
  flex: 0 0 auto;              /* 不压缩 */
  white-space: nowrap;         /* 文字不换行 —— 关键 */
  min-width: 72px;
  text-align: center;
}
/* 名片窄，按钮少放几个 */
.modal.card-modal { width: 380px; }
.card-modal .modal-actions { justify-content: center; }
.card-modal .modal-actions .btn { min-width: 84px; }
/* 主页宽一些，五个按钮够放 */
.modal.home-modal .modal-actions { justify-content: center; }
.modal.home-modal .modal-actions .btn { min-width: 88px; }

/* ==================== 相册筛选 ==================== */
.album-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; max-height: 76px; overflow-y: auto; }
.album-chip {
  border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.album-chip.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

/* ==================== 礼物商店 ==================== */
.modal.gift-modal { width: 520px; max-width: calc(100vw - 24px); }
.gift-tip { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.gift-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-height: 52vh; overflow-y: auto; }
.gift-card {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px;
  background: var(--panel-soft);
}
.gift-card.wearing { border-color: var(--brand); background: var(--brand-soft); }
.gift-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: #fff; background: var(--brand);
}
.frame-green { background: linear-gradient(135deg, #34d399, #059669); }
.frame-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.frame-gold { background: linear-gradient(135deg, #fbbf24, #d97706); }
.frame-fire { background: linear-gradient(135deg, #fb7185, #dc2626); }
.badge-star { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.badge-code { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.badge-night { background: linear-gradient(135deg, #6366f1, #1e1b4b); }
.badge-king { background: linear-gradient(135deg, #f59e0b, #b45309); }
.gift-card b { font-size: 12.5px; text-align: center; }
.gift-price { font-size: 11px; color: var(--muted); }
.gift-card .btn { padding: 4px 10px; font-size: 12px; min-width: 56px; }

/* 头像框（消息 / 成员列表上） */
.avatar-wrap.frame-green .avatar { border: 2px solid #34d399; }
.avatar-wrap.frame-blue .avatar { border: 2px solid #60a5fa; }
.avatar-wrap.frame-gold .avatar { border: 2px solid #fbbf24; }
.avatar-wrap.frame-fire .avatar { border: 2px solid #fb7185; }

/* ==================== 房间音乐 ==================== */
.music-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; font-size: 12.5px;
  background: linear-gradient(90deg, var(--brand-soft), transparent);
  border-bottom: 1px solid var(--brand-line);
}
.music-icon { color: var(--brand); font-size: 14px; }
.music-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-btn {
  border: 1px solid var(--brand-line); background: var(--panel);
  color: var(--brand); border-radius: 999px; padding: 3px 12px; font-size: 12px; cursor: pointer;
}
.music-vol { width: 70px; }
.music-x { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; }

/* ==================== 定时消息 ==================== */
.modal.sched-modal { width: 480px; max-width: calc(100vw - 24px); }
.sched-list { display: flex; flex-direction: column; gap: 6px; max-height: 44vh; overflow-y: auto; margin-bottom: 12px; }
.sched-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-soft); border-radius: 9px; padding: 8px 10px; font-size: 13px;
}
.sched-time { color: var(--brand); font-size: 12px; white-space: nowrap; }
.sched-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

/* ==================== Markdown 加强 ==================== */
.md-h4 { font-size: 14px; }
.md-h5 { font-size: 13.5px; }
.md-h6 { font-size: 13px; color: var(--muted); }
.md-table th, .md-table td { vertical-align: top; }

/* 折叠剧透 */
.md-spoiler {
  margin: 6px 0; border: 1px solid var(--line);
  border-radius: 9px; background: var(--panel-soft); overflow: hidden;
}
.md-spoiler summary {
  cursor: pointer; padding: 7px 12px; font-size: 13px; color: var(--brand);
  list-style: none; user-select: none;
}
.md-spoiler summary::-webkit-details-marker { display: none; }
.md-spoiler summary::before { content: '▸ '; }
.md-spoiler[open] summary::before { content: '▾ '; }
.md-spoiler-body { padding: 2px 12px 10px; font-size: 13.5px; line-height: 1.7; }
.math-inline, .math-block { cursor: context-menu; }
.math-block:hover { background: var(--panel-soft); border-radius: 8px; }

/* ==================== 代码高亮配色 ==================== */
.md-pre .k-com { color: #7c8798; font-style: italic; }
.md-pre .k-str { color: #a5e075; }
.md-pre .k-kw  { color: #ff9d6b; }
.md-pre .k-num { color: #d19a66; }
.md-pre .k-key { color: #7fd1f0; }
.md-pre .k-fn  { color: #ffd479; }

/* 折叠与宏相关的细节 */
.md-spoiler summary:hover { background: var(--brand-soft); }

/* ==================== 发送状态 ==================== */
.messages .msg.pending > .text { opacity: .6; }
.messages .msg.pending > .meta .time { color: var(--brand); }
.messages .msg.failed > .text { border-color: #e0507a; background: rgba(224,80,122,.08); }
.messages .msg.failed > .meta .time { color: #e0507a; cursor: pointer; }
#btn-send.cooling { background: var(--muted); border-color: var(--muted); cursor: not-allowed; }

/* ==================== 称号 ==================== */
.msg .title-tag, .member-title-tag {
  display: inline-block; font-size: 10.5px; font-weight: 600;
  padding: 1px 6px; border-radius: 5px; margin-left: 5px;
  background: var(--brand-soft); color: var(--brand);
  border: 1px solid var(--brand-line);
}
.title-dev { background: linear-gradient(135deg, #f59e0b, #dc2626) !important; color: #fff !important; border-color: transparent !important; }
.title-newbie { background: #e0f2fe !important; color: #0369a1 !important; border-color: #bae6fd !important; }
.title-night { background: #ede9fe !important; color: #5b21b6 !important; border-color: #ddd6fe !important; }
.title-ace { background: #fef3c7 !important; color: #92400e !important; border-color: #fde68a !important; }
.title-coder { background: #ccfbf1 !important; color: #115e59 !important; border-color: #99f6e4 !important; }
.title-veteran { background: #fee2e2 !important; color: #991b1b !important; border-color: #fecaca !important; }
.title-legend { background: linear-gradient(135deg, #8b5cf6, #ec4899) !important; color: #fff !important; border-color: transparent !important; }
.gift-card .gift-icon.title-icon { border-radius: 8px; font-size: 12px; }

/* ============================================================
 * 个人资料弹窗：重新排版（原来 性别/生日 挤在一起、标签换行，看着别扭）
 * ============================================================ */
.modal.profile-modal { width: 440px; max-width: calc(100vw - 24px); }
.modal.profile-modal h3 { margin: 0 0 16px; }

/* 头像行：头像 + 按钮垂直居中 */
.profile-avatar-row {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 18px;
}
.profile-avatar-row .profile-avatar { flex: 0 0 76px; }
.profile-avatar-row .profile-avatar-actions { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.profile-avatar-row .profile-avatar-actions .btn { width: 100%; }
.profile-avatar-hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 0; }

/* 每个字段统一间距、标签一行放下 */
.modal.profile-modal .field { display: block; margin-bottom: 14px; }
.modal.profile-modal .field > span:first-child {
  display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px;
}
.modal.profile-modal input,
.modal.profile-modal select,
.modal.profile-modal textarea {
  width: 100%; box-sizing: border-box;
  border-radius: 10px; padding: 10px 12px;
  border: 1px solid var(--line); background: var(--panel-soft);
  color: var(--text); font-size: 14px; font-family: inherit;
}
.modal.profile-modal input:focus,
.modal.profile-modal select:focus,
.modal.profile-modal textarea:focus { outline: none; border-color: var(--brand); background: var(--panel); }

/* 性别 + 生日：两列等宽、标签都不换行 */
.profile-grid {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.profile-grid .field { margin-bottom: 0; }
.profile-grid .field > span:first-child { white-space: nowrap; }

/* 隐身模式那一行：和上面字段对齐，不要飘在中间 */
.modal.profile-modal .switch.profile-switch {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 16px; font-size: 13.5px;
}
.modal.profile-modal .modal-actions { justify-content: flex-end; }

/* ============================================================
 * 表情回应栏：不要用 height:0 + overflow:hidden（会把内容切一半）
 * 改用 max-height 过渡，收起时不留白，展开时完整显示
 * ============================================================ */
.messages .msg > .reactions {
  grid-column: 2 !important;
  justify-self: start;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 4px !important;
  opacity: 0;
  max-height: 0;
  overflow: visible;          /* 关键：不再裁切 */
  transition: opacity .15s ease, max-height .18s ease;
}
.messages .msg:hover > .reactions,
.messages .msg > .reactions:has(.rx-chip) {
  opacity: 1;
  max-height: 260px;
}
.messages .msg .rx-chip {
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  line-height: 1.5; white-space: nowrap;
}
.messages .msg .rx-add {
  font-size: 12px; padding: 2px 8px; border-radius: 999px;
  border: 1px dashed var(--line); background: transparent;
  color: var(--muted); cursor: pointer; line-height: 1.5;
}
.messages .msg .rx-add:hover { color: var(--brand); border-color: var(--brand-line); }

/* 消息里的图片/语音/沙币卡片也不要被裁 */
.messages .msg > img,
.messages .msg > audio,
.messages .msg > .msg-img,
.messages .msg > .packet {
  grid-column: 2 !important;
  justify-self: start;
  max-width: 100%;
}

/* ==================== 欢迎弹窗 ==================== */
.modal.welcome-modal { width: 420px; max-width: calc(100vw - 24px); }
.welcome-tip { font-size: 13px; color: var(--muted); line-height: 1.7; margin: 0 0 16px; }
.welcome-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.welcome-modal .field { margin-bottom: 6px; }

/* ==================== 商店分页 ==================== */
.gift-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.gift-tab {
  border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted);
  border-radius: 999px; padding: 4px 14px; font-size: 12.5px; cursor: pointer;
}
.gift-tab.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

/* ==================== 新称号配色 ==================== */
.title-owner { background: linear-gradient(135deg, #22c55e, #15803d) !important; color: #fff !important; border-color: transparent !important; }
.title-early { background: linear-gradient(135deg, #f472b6, #be185d) !important; color: #fff !important; border-color: transparent !important; }
.title-quiet { background: #f1f5f9 !important; color: #475569 !important; border-color: #e2e8f0 !important; }
.title-fast { background: #fff7ed !important; color: #c2410c !important; border-color: #fed7aa !important; }
.title-teacher { background: #eef2ff !important; color: #3730a3 !important; border-color: #c7d2fe !important; }
.title-gamer { background: #f0fdf4 !important; color: #166534 !important; border-color: #bbf7d0 !important; }
.title-rich { background: linear-gradient(135deg, #fbbf24, #b45309) !important; color: #fff !important; border-color: transparent !important; }
#me-title { margin-left: 6px; vertical-align: middle; }

/* 连接质量徽标 */
.net-badge { font-size: 11px; color: var(--muted); background: var(--panel-soft); border-radius: 999px; padding: 1px 7px; margin-left: 4px; cursor: help; }
.net-badge.warn { color: #c2410c; background: #fff7ed; }
html[data-theme="dark"] .net-badge.warn { color: #fdba74; background: rgba(251,146,60,.16); }

/* ==================== 连接详情 ==================== */
.modal.net-modal { width: 400px; max-width: calc(100vw - 24px); }
.net-detail { margin-bottom: 12px; }
.net-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13.5px; padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.net-k { color: var(--muted); }
.net-title { font-size: 12.5px; color: var(--brand); margin: 14px 0 6px; font-weight: 600; }
.net-reason { font-size: 12.5px; color: var(--muted); padding: 3px 0; }

/* ==================== 称号墙 ==================== */
.home-titles { margin: 10px 0; }
.home-titles-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.home-titles-row { display: flex; flex-wrap: wrap; gap: 6px; }
.home-titles-row .title-tag {
  cursor: pointer; padding: 3px 10px; font-size: 11.5px;
  border: 1px solid var(--brand-line); background: var(--panel-soft); color: var(--muted);
}
.home-titles-row .title-tag.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

/* 自动称号配色 */
.title-auto1 { background: #fef2f2 !important; color: #b91c1c !important; border-color: #fecaca !important; }
.title-auto2 { background: #f0f9ff !important; color: #075985 !important; border-color: #bae6fd !important; }
.title-auto3 { background: #f8fafc !important; color: #64748b !important; border-color: #e2e8f0 !important; }
.title-auto4 { background: #fffbeb !important; color: #b45309 !important; border-color: #fde68a !important; }

/* ============================================================
 * 称号徽章加强版（原来太淡，几乎看不出来）
 * ============================================================ */
.msg .title-tag,
.member-title-tag,
.home-titles-row .title-tag {
  display: inline-flex !important;
  align-items: center;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  letter-spacing: .3px;
  padding: 2px 9px !important;
  border-radius: 7px !important;
  margin-left: 7px;
  line-height: 1.5;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .12);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .10), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .12s ease;
}
.msg .title-tag:hover { transform: translateY(-1px); }

/* 稀有称号：加一圈光晕，聊天里一眼能看到 */
.title-dev, .title-legend, .title-owner, .title-rich {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .35), 0 2px 8px rgba(220, 38, 38, .35) !important;
  border: none !important;
}
.title-legnd, .title-dev { padding: 2px 11px !important; }

/* 普通称号也要清晰可读 */
.title-newbie, .title-night, .title-ace, .title-coder,
.title-veteran, .title-quiet, .title-fast, .title-teacher,
.title-gamer, .title-early, .title-auto1, .title-auto2,
.title-auto3, .title-auto4 {
  border-width: 1px !important;
  border-style: solid !important;
}

/* 自己名字旁边的称号（顶栏）再大一点 */
#me-title {
  font-size: 11px !important;
  padding: 1.5px 8px !important;
  margin-left: 7px;
}

/* 成员列表里的称号不要挤，必要时换行 */
.member-title-tag { flex: 0 0 auto; }
.room-member { flex-wrap: wrap; }

/* 浅色主题下也够清楚 */
html[data-theme="light"] .msg .title-tag { text-shadow: none; }

/* ============================================================
 * 表情回应栏（最终版）
 * 之前的问题：旧规则里的 height:0 一直在生效，只改 max-height 不够，
 * 所以内容还是被压成 0 高度裁掉。这里把 height 也重置掉。
 * ============================================================ */
.messages .msg > .reactions {
  height: auto !important;
  max-height: 0 !important;
  overflow: visible !important;
  opacity: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 5px !important;
  grid-column: 2 !important;
  justify-self: start !important;
  transition: opacity .14s ease, max-height .18s ease;
}
.messages .msg:hover > .reactions,
.messages .msg > .reactions:has(.rx-chip) {
  max-height: 400px !important;
  opacity: 1 !important;
  margin-top: 4px !important;
}
/* 没有回应且不在悬停时，用 padding 0 彻底不留白 */
.messages .msg > .reactions:not(:has(.rx-chip)):not(:hover) { padding: 0 !important; }
.messages .msg > .reactions {
  padding: 0 !important;
}

/* ---------- 2. 聊天背景弹窗 ---------- */
#modal-bg .modal { width: 420px !important; max-width: calc(100vw - 24px); }
#modal-bg .bg-grid,
#modal-bg .bg-list {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 10px !important;
  margin-bottom: 14px;
}
#modal-bg .bg-item,
#modal-bg .bg-choice {
  position: relative;
  height: 62px !important;              /* 统一高度，格纹/图片也一样高 */
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--panel-soft);
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
  padding: 0 !important;
  box-sizing: border-box;
  transition: border-color .14s, box-shadow .14s;
}
#modal-bg .bg-item:hover { border-color: var(--brand-line); }
#modal-bg .bg-item.active {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 2px var(--brand-soft);
  font-weight: 600;
  color: var(--brand);
}
/* 上传按钮独占一行，跟上面保持同样间距 */
#modal-bg .btn,
#modal-bg button.btn {
  width: 100%;
  margin-top: 4px;
}
#modal-bg .tip { margin-top: 10px; line-height: 1.6; }

/* ============================================================
 * 聊天背景弹窗（最终版）
 * 实际结构：#bg-list > .bg-cell × N，#bg-custom-slot.bg-cell，
 *           #btn-bg-upload.btn.ghost.block
 * 之前的问题：色块高度不一致，"格纹"那个（带图案）把整行挤歪
 * ============================================================ */
#modal-bg .modal.small { width: 430px !important; max-width: calc(100vw - 24px); }

#bg-list {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 10px !important;
  margin: 0 0 10px !important;
}

#modal-bg .bg-cell {
  position: relative;
  width: 100% !important;
  height: 64px !important;            /* 所有色块同一高度 */
  min-height: 64px !important;
  max-height: 64px !important;
  border-radius: 10px !important;
  border: 1.5px solid var(--line) !important;
  background-color: var(--panel-soft);
  background-size: cover !important;
  background-position: center !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 12.5px !important;
  color: var(--text) !important;
  cursor: pointer;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color .14s ease, box-shadow .14s ease, transform .12s ease;
}
#modal-bg .bg-cell:hover { border-color: var(--brand-line) !important; transform: translateY(-1px); }
#modal-bg .bg-cell.active {
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 2px var(--brand-soft) !important;
  font-weight: 700;
}

/* "用我自己的图" 也按同样的尺寸，整行对齐 */
#bg-custom-slot {
  grid-column: span 1;
  height: 64px !important;
  font-size: 12px !important;
}

/* 上传按钮整行、和上面同宽 */
#modal-bg #btn-bg-upload {
  display: block !important;
  width: 100% !important;
  margin: 10px 0 0 !important;
  height: 40px;
  box-sizing: border-box;
}
#modal-bg .tip { margin: 10px 0 0 !important; font-size: 12px; line-height: 1.6; }
#modal-bg .modal-actions { margin-top: 16px !important; }

/* ==================== 我的投票 ==================== */
.modal.mypolls-modal { width: 460px; max-width: calc(100vw - 24px); }
.mypolls-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.mypolls-tab {
  border: 1px solid var(--line); background: var(--panel-soft); color: var(--muted);
  border-radius: 999px; padding: 5px 16px; font-size: 13px; cursor: pointer;
}