:root {
  /* 叠加层底色通道：深色主题用白色叠加，浅色主题切到黑色 */
  --tint-rgb: 255, 255, 255;
  /* 半透明面板底色通道（侧栏等） */
  --surface-rgb: 13, 18, 24;
  /* 输入框/浅色块（深色主题用黑色加暗，浅色主题换成淡淡的灰） */
  --field: rgba(0, 0, 0, 0.28);
  --field-2: rgba(0, 0, 0, 0.3);
  --field-soft: rgba(0, 0, 0, 0.25);
  --bg: #0d1218;
  --panel: #141c24;
  --panel-2: #1a242e;
  --line: rgba(var(--tint-rgb), 0.08);
  --line-strong: rgba(var(--tint-rgb), 0.14);
  --text: #e7eef5;
  --muted: #8b98a6;
  --muted-2: #63707d;
  --accent: #14b8a6;
  --accent-soft: rgba(20, 184, 166, 0.12);
  --accent-strong: #0f9b8c;
  --bubble-me: linear-gradient(135deg, #14897d, #0f6f66);
  --bubble-other: #1d2732;
  --danger: #f87171;
  --gold: #f0b429;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --sidebar-w: 248px;
  /* 背景装饰层：每套配色可以自己换一套 */
  --bg-grad:
    radial-gradient(1200px 600px at 100% -10%, rgba(20, 184, 166, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(245, 158, 11, 0.06), transparent 60%);
}

* { box-sizing: border-box; }

/* 关键：显式 display 会覆盖 [hidden] 的 UA 样式，必须统一兜底，
   否则 .app / .lightbox 这类 display:grid 的元素无法被 hidden 隐藏 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    var(--bg-grad),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* ---------------------------------------------------- 登录层 */

.login {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vvtop, 0px);
  height: var(--vvh, 100%);
  display: grid;
  place-items: center;
  padding: 24px calc(24px + env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
  background: rgba(8, 12, 16, 0.88);
  z-index: 100;
  overflow-y: auto;
}

.login-card {
  width: min(400px, 100%);
  padding: 30px 28px 24px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: var(--shadow);
}

.login-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-title { margin: 0 0 6px; font-size: 22px; text-align: center; letter-spacing: 0.5px; }
.login-sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: 13px; }

.login-modes {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line);
}
.login-mode {
  flex: 1;
  padding: 8px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.login-mode.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12.5px; letter-spacing: 0.4px; }

.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--field);
  outline: none;
  font-size: 16px; /* iOS 上小于 16px 会触发自动放大 */
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder { color: var(--muted-2); font-size: 14px; }

.login-error {
  min-height: 20px;
  margin: 4px 0 10px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #04211e;
  font-weight: 700;
  letter-spacing: 1px;
  transition: transform 0.12s, filter 0.18s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.login-foot { margin: 16px 0 0; color: var(--muted-2); font-size: 11.5px; text-align: center; }

/* ---------------------------------------------------- 主布局 */

.app {
  /* 贴住「视觉视口」：iOS Safari 弹键盘时 100dvh 不会跟着收缩，
     底部输入框会被键盘盖住。--vvh / --vvtop 由 app.js 用 visualViewport 实时写入。 */
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vvtop, 0px);
  height: var(--vvh, 100%);
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(var(--surface-rgb), 0.72);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.sidebar-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
}
.user-item:hover { background: rgba(var(--tint-rgb), 0.04); }
.user-item.clickable { cursor: pointer; }
.user-item.clickable:active { background: rgba(20, 184, 166, 0.12); }

.avatar,
.user-avatar {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: #06211e;
  background: var(--accent);
  user-select: none;
}
.user-avatar.admin,
.avatar.admin {
  background: linear-gradient(135deg, #f6c453, #d69a1f);
  color: #3a2600;
}

.user-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.user-name-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.user-name {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-ip {
  font-size: 11.5px;
  color: var(--muted-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(240, 180, 41, 0.16);
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  flex: 0 0 auto;
}
.badge.muted { background: rgba(248, 113, 113, 0.14); color: var(--danger); }
.me-mark {
  display: inline-block;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(var(--tint-rgb), 0.08);
  color: var(--muted);
  font-size: 10.5px;
  flex: 0 0 auto;
}

/* 在线列表第二行：账号 */
.user-account {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.me-chip {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: 7px;
}
.link-btn:hover { color: var(--danger); background: rgba(248, 113, 113, 0.1); }

.sidebar-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 110;
}

/* ---------------------------------------------------- 聊天区 */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  isolation: isolate;
}

/* ---- 聊天区自定义背景（管理员设置，电脑端横屏 / 手机端竖屏，亮度可调） ---- */
:root {
  --chat-bg-desktop: none;
  --chat-bg-mobile: none;
  --chat-bg-shade: 0.4;
}
.chat-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--chat-bg-mobile);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.chat-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, var(--chat-bg-shade));
}
@media (min-width: 768px) {
  .chat-bg { background-image: var(--chat-bg-desktop); }
}
.chat > :not(.chat-bg) { position: relative; z-index: 1; }
/* 播放器要盖住消息层，否则歌单弹层看得见却点不动、滚不了 */
.chat > .music-bar { z-index: 6; }

/* ---- 设了聊天背景后：顶部时间条 / 公告 / 播放器 / 系统气泡改成半透明玻璃底，保证字看得清 ---- */
/* 注意：不要在这里用 backdrop-filter。实测部分 Chromium 环境（软件渲染 / 虚拟浏览器）一旦给这些元素加模糊，
   整个聊天区（消息、播放器、时间条）会整片不渲染，只剩背景图。只用半透明底 + 描边保证可读性。 */
.chat.has-bg .chat-head,
.chat.has-bg .clock-bar,
.chat.has-bg .announce,
.chat.has-bg .music-bar,
.chat.has-bg .sys-msg {
  background: rgba(10, 16, 21, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border-bottom-color: rgba(255, 255, 255, 0.12);
}
html[data-theme="light"] .chat.has-bg .chat-head,
html[data-theme="light"] .chat.has-bg .clock-bar,
html[data-theme="light"] .chat.has-bg .announce,
html[data-theme="light"] .chat.has-bg .music-bar,
html[data-theme="light"] .chat.has-bg .sys-msg {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
/* 公告条原来那层黄色底会叠成脏色，换成淡淡的琥珀描边 */
.chat.has-bg .announce {
  color: #fbe3a5;
  border-bottom-color: rgba(240, 180, 41, 0.28);
}
html[data-theme="light"] .chat.has-bg .announce { color: #8a5a06; }

/* 后台：背景图上传槽 */
.bg-slot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bg-thumb {
  width: 96px; height: 54px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #0d1418 center/cover no-repeat;
}
.bg-slot-ops { display: flex; gap: 8px; flex-wrap: wrap; }
#bgDim { width: 100%; accent-color: var(--tint, #2fc8b7); }

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.chat-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-head-title { min-width: 0; }
.chat-head-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.room-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.room-meta { margin: 2px 0 0; font-size: 12px; color: var(--muted-2); }

.admin-entry { color: var(--gold); }
.admin-entry:hover { background: rgba(240, 180, 41, 0.14); color: var(--gold); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(var(--tint-rgb), 0.03);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.status-pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  transition: background 0.2s;
}
.status-pill.online .dot { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15); }
.status-pill.offline .dot { background: var(--danger); }

/* ---- 顶部当前时间条（北京时间 / 加拿大时间，可切换，按用户记住） ---- */
.clock-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(var(--tint-rgb), 0.025);
  flex: 0 0 auto;
}
.clock-text {
  min-width: 0;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.clock-switch {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(var(--tint-rgb), 0.03);
  color: var(--accent);
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.clock-switch:hover { background: rgba(20, 184, 166, 0.14); }
.clock-switch:active { transform: translateY(1px); }

.announce {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: rgba(240, 180, 41, 0.10);
  border-bottom: 1px solid rgba(240, 180, 41, 0.18);
  color: #f7d27a;
  font-size: 12.5px;
  flex: 0 0 auto;
}
.announce-icon { flex: 0 0 auto; }
.announce-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 6px;
  scroll-behavior: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.empty-tip {
  margin: 24vh auto 0;
  text-align: center;
  color: var(--muted-2);
  font-size: 13px;
}

.day-sep {
  display: flex;
  justify-content: center;
  margin: 18px 0 12px;
}
.day-sep {
  color: var(--muted-2);
  font-size: 11.5px;
}
.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  align-self: center;
  height: 1px;
  background: var(--line);
  margin: 0 12px;
}

.msg {
  display: flex;
  gap: 10px;
  margin: 12px 0;
  align-items: flex-start;
  position: relative;
}
.msg.me { flex-direction: row-reverse; }

.msg .avatar { flex-basis: 30px; width: 30px; height: 30px; font-size: 13px; margin-top: 20px; }
.msg.me .avatar { background-color: #33414f; color: #cfe3ee; }

.msg-body { max-width: min(72%, 620px); min-width: 0; }
.msg-head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 2px 5px;
  font-size: 11.5px;
  color: var(--muted-2);
  flex-wrap: wrap;
}
.msg.me .msg-head { justify-content: flex-end; }
.msg-head .nick { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.msg-head .ip { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.msg.me .msg-head .nick { color: #7fdccf; }

.msg-more {
  flex: 0 0 auto;
  align-self: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(var(--tint-rgb), 0.04);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  opacity: 0.75;
}
.msg-more:hover { background: rgba(248, 113, 113, 0.14); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }

.bubble {
  padding: 9px 13px;
  border-radius: 14px 14px 14px 4px;
  background: var(--bubble-other);
  border: 1px solid var(--line);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg.me .bubble {
  background: var(--bubble-me);
  border-color: rgba(var(--tint-rgb), 0.10);
  border-radius: 14px 14px 4px 14px;
  color: #f0fffd;
}

.bubble.revoked {
  background: rgba(var(--tint-rgb), 0.04) !important;
  border-color: var(--line) !important;
  color: var(--muted-2) !important;
  font-style: italic;
  font-size: 12.5px;
}

.msg .bubble.img {
  padding: 4px;
  background: rgba(var(--tint-rgb), 0.04);
  border: 1px solid var(--line);
}
.msg .bubble.img img {
  display: block;
  max-width: 100%;
  max-height: min(340px, 46vh);
  border-radius: 11px;
  cursor: zoom-in;
  object-fit: contain;
  background: var(--field-soft);
}

.msg .bubble.sticker {
  padding: 0;
  background: none;
  border: 0;
}
.msg .bubble.sticker img {
  display: block;
  width: auto;
  height: auto;
  max-width: 132px;
  max-height: 132px;
  object-fit: contain;
  cursor: default;
}

.jump-bottom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(132px + env(safe-area-inset-bottom));
  padding: 7px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--accent);
  font-size: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}

/* ---------------------------------------------------- 输入区 */

.composer {
  position: relative;
  padding: 10px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex: 0 0 auto;
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 6px;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
}
.composer-row:focus-within { border-color: rgba(20, 184, 166, 0.55); }

.composer-tools { display: flex; gap: 2px; padding-bottom: 3px; }
.tool-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 19px;
  transition: background 0.15s, color 0.15s;
}
.tool-btn:hover, .tool-btn.active { background: rgba(var(--tint-rgb), 0.07); color: var(--accent); }

#messageInput {
  flex: 1;
  min-height: 34px;
  max-height: 132px;
  padding: 6px 4px;
  border: 0;
  background: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
  font-size: 16px; /* iOS 上小于 16px 会触发页面缩放 */
}
#messageInput::placeholder { color: var(--muted-2); font-size: 14px; }

.btn-send {
  flex: 0 0 auto;
  height: 34px;
  min-width: 62px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #04211e;
  font-weight: 700;
  transition: filter 0.15s, transform 0.12s, opacity 0.15s;
}
.btn-send:hover { filter: brightness(1.08); }
.btn-send:active { transform: scale(0.97); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

.composer-hint {
  margin: 6px 2px 0;
  color: var(--muted-2);
  font-size: 11.5px;
}
.composer-hint.active { color: var(--accent); }

/* ---------------------------------------------------- 表情面板 */

.sticker-panel {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: calc(100% - 4px);
  max-width: 460px;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 20;
}
.sticker-tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1;
  padding: 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.5px;
}
.tab.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }

.sticker-body {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: min(268px, 42vh);
  overflow-y: auto;
}
.sticker-body[data-body="stickers"] { grid-template-columns: repeat(4, 1fr); gap: 6px; }

.emoji-cell {
  border: 0;
  background: none;
  border-radius: 8px;
  padding: 6px 0;
  font-size: 21px;
  line-height: 1;
  transition: background 0.12s, transform 0.1s;
}
.emoji-cell:hover { background: rgba(var(--tint-rgb), 0.07); transform: scale(1.14); }

.sticker-cell {
  border: 0;
  background: rgba(var(--tint-rgb), 0.04);
  border-radius: 10px;
  padding: 6px;
  transition: background 0.12s, transform 0.1s;
}
.sticker-cell:hover { background: rgba(20, 184, 166, 0.14); transform: translateY(-2px); }
.sticker-cell img { display: block; width: 100%; height: auto; }

.sticker-empty {
  grid-column: 1 / -1;
  padding: 26px 10px;
  text-align: center;
  color: var(--muted-2);
  font-size: 12.5px;
}

/* ---------------------------------------------------- 图片查看 */

.lightbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 8, 11, 0.9);
  z-index: 200;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------- 操作菜单 */

.action-menu {
  position: fixed;
  z-index: 220;
  min-width: 190px;
  max-width: 82vw;
  padding: 6px;
  border-radius: 13px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
}
.menu-item:hover { background: rgba(var(--tint-rgb), 0.06); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(248, 113, 113, 0.12); }

/* ---------------------------------------------------- 管理后台 */

.admin-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 130;
}

.admin-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line-strong);
  box-shadow: -16px 0 44px rgba(0, 0, 0, 0.45);
  z-index: 140;
  animation: slideIn 0.22s ease;
}
@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  border-bottom: 1px solid var(--line);
}
.admin-head h2 { margin: 0; font-size: 16px; letter-spacing: 0.4px; }

.admin-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
}

.admin-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.admin-section h3 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-count { color: var(--muted-2); font-size: 11.5px; text-transform: none; letter-spacing: 0; }

.admin-field { display: block; margin-bottom: 12px; }
.admin-field > span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12.5px; }
.admin-inline { display: flex; gap: 8px; }
.admin-inline input { flex: 1; min-width: 0; }

.admin-panel input[type="text"],
.admin-panel select {
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--field-2);
  outline: none;
  font-size: 15px;
  min-width: 0;
}
.admin-panel input[type="text"]:focus,
.admin-panel select:focus { border-color: var(--accent); }
.admin-panel select { width: 100%; }

.btn-small {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(20, 184, 166, 0.14);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.btn-small:hover { background: rgba(20, 184, 166, 0.22); }
.btn-small:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-mini {
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(var(--tint-rgb), 0.05);
  color: var(--text);
  font-size: 12px;
}
.btn-mini:hover { background: rgba(var(--tint-rgb), 0.12); }
.btn-mini.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.28); }
.btn-mini.danger:hover { background: rgba(248, 113, 113, 0.14); }

.mini-danger {
  padding: 2px 7px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  border-radius: 6px;
  background: none;
  color: var(--danger);
  font-size: 11px;
}
.mini-danger:hover { background: rgba(248, 113, 113, 0.14); }

.admin-sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.admin-sticker {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(var(--tint-rgb), 0.03);
  padding: 6px;
}
.admin-sticker img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--field-soft);
  border-radius: 7px;
}
.admin-sticker-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 5px;
}
.admin-sticker-name {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-upload {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}
.admin-upload input[type="text"] {
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--field-2);
  outline: none;
  font-size: 14px;
  min-width: 0;
}

.admin-tip { margin: 8px 0 0; color: var(--muted-2); font-size: 11.5px; }

.admin-list { display: flex; flex-direction: column; gap: 6px; }
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(var(--tint-rgb), 0.03);
  border: 1px solid var(--line);
}
.admin-row.audit { align-items: flex-start; }
.admin-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-row-title { font-size: 13px; }
.admin-row-sub {
  font-size: 11.5px;
  color: var(--muted-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-row-ops { display: flex; gap: 5px; flex: 0 0 auto; }
.admin-empty { padding: 12px; text-align: center; color: var(--muted-2); font-size: 12px; }

.admin-section.danger { border-bottom: 0; }
.btn-danger {
  width: 100%;
  padding: 11px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  font-weight: 700;
  font-size: 13.5px;
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

/* ---------------------------------------------------- Toast */

.toast {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top));
  transform: translate(-50%, -8px);
  max-width: 86vw;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { color: #ffd9a8; border-color: rgba(240, 180, 41, 0.35); }

/* ---------------------------------------------------- 滚动条 */

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: rgba(var(--tint-rgb), 0.12);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(var(--tint-rgb), 0.22); background-clip: content-box; }

/* ---------------------------------------------------- 响应式 */

.only-mobile { display: none !important; }
.icon-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 17px;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: rgba(var(--tint-rgb), 0.07); color: var(--text); }

@media (max-width: 820px) {
  /* 只在窄屏收起侧栏，配色变量仍由主题决定 */
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: min(82vw, 310px);
    z-index: 120;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top);
  }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: inline-flex !important; align-items: center; justify-content: center; }
  .msg-body { max-width: 78%; }
  .composer { padding-left: 12px; padding-right: 12px; }
  .sticker-panel {
    left: 8px;
    right: 8px;
    max-width: none;
    bottom: calc(100% - 2px);
  }
  .jump-bottom { bottom: calc(124px + env(safe-area-inset-bottom)); }
  .messages { padding: 14px 12px 6px; }
  .chat-head { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .announce { padding: 8px 12px; }
  .room-title { font-size: 15px; max-width: 40vw; }

  /* 触控目标放大 */
  .tool-btn { width: 40px; height: 40px; }
  .btn-send { height: 40px; padding: 0 16px; }
  #messageInput { min-height: 40px; padding: 8px 4px; }
  .msg-more { width: 32px; height: 32px; font-size: 16px; }
  .link-btn { padding: 8px 10px; }

  /* 操作菜单改成底部弹出，更适合拇指 */
  .action-menu {
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0;
    min-width: 0;
    max-width: none;
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    animation: sheetUp 0.18s ease;
  }
  @keyframes sheetUp {
    from { transform: translateY(16px); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
  }
  .menu-item { padding: 14px 14px; font-size: 15px; text-align: center; }

  /* 管理后台占满屏 */
  .admin-panel {
    width: 100%;
    border-left: 0;
  }
  .admin-body { padding-left: 14px; padding-right: 14px; }
  .admin-sticker-grid { grid-template-columns: repeat(3, 1fr); }
  .admin-upload { grid-template-columns: 1fr auto; }
  .admin-upload .btn-small { padding: 10px 12px; }
  .btn-mini { padding: 8px 12px; font-size: 13px; }
  .admin-row-ops { gap: 6px; }
  .admin-inline input { font-size: 16px; }
}

@media (max-width: 420px) {
  .sticker-body { grid-template-columns: repeat(7, 1fr); }
  .sticker-body[data-body="stickers"] { grid-template-columns: repeat(3, 1fr); }
  .btn-send { padding: 0 13px; min-width: 56px; }
  .msg .bubble.sticker img { max-width: 112px; max-height: 112px; }
  .login-card { padding: 24px 20px 20px; }
  .status-pill { display: none; }
  .admin-sticker-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================ v10：账号体系 / 引用 / 分页 / 媒体 */

/* 登录页：站点关闭提示 */
.login-closed {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 11px 13px;
  background: rgba(240, 180, 41, 0.1);
  border: 1px solid rgba(240, 180, 41, 0.3);
  border-radius: 10px;
  color: #ffd9a8;
  font-size: 13px;
  line-height: 1.5;
}
.login-closed-icon { flex: 0 0 auto; font-size: 15px; }

/* 三个登录 tab 收紧 */
.login-modes { flex-wrap: nowrap; gap: 4px; }
.login-mode { padding: 9px 4px; font-size: 12.5px; }

/* 通用抽屉（个人中心 / 搜索 / 媒体 / 管理后台共用） */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 130;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line-strong);
  box-shadow: -16px 0 44px rgba(0, 0, 0, 0.45);
  z-index: 140;
  animation: slideIn 0.22s ease;
}

/* 抽屉里的输入框统一外观 */
.drawer input[type="text"],
.drawer input[type="password"],
.drawer input[type="number"],
.drawer input[type="search"],
.drawer select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(var(--tint-rgb), 0.05);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.drawer input:focus,
.drawer select:focus { border-color: var(--accent); }
.drawer input::placeholder { color: var(--muted-2); font-size: 13px; }

/* 消息行定位（操作按钮用绝对定位） */
.msg { position: relative; }

/* 消息操作按钮：桌面 hover 出现，移动端常显 */
.msg-actions {
  position: absolute;
  top: 14px;
  right: -2px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 3;
}
.msg.me .msg-actions { right: auto; left: -2px; }
.msg:hover .msg-actions,
.msg:focus-within .msg-actions { opacity: 1; }

.msg-action-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(12, 18, 24, 0.9);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-action-btn:hover { color: var(--accent); border-color: rgba(20, 184, 166, 0.45); }

/* 引用块（显示在气泡上方） */
.bubble-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  max-width: 100%;
  margin: 0 0 5px;
  padding: 7px 10px;
  text-align: left;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: rgba(var(--tint-rgb), 0.05);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
}
.bubble-quote:hover { background: rgba(20, 184, 166, 0.12); }
.bubble-quote-nick {
  font-size: 12px;
  font-weight: 600;
  color: #7fdccf;
}
.bubble-quote-text {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 图片气泡里的文字 */
.bubble-caption {
  padding: 9px 4px 2px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}

/* 引用条（输入区上方） */
.quote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(20, 184, 166, 0.1);
  border: 1px solid rgba(20, 184, 166, 0.28);
}
.quote-bar-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.quote-bar-label {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.quote-bar-text {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quote-bar-close {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.quote-bar-close:hover { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }

/* 待发送附件预览 */
.attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.attach-thumb-wrap { position: relative; flex: 0 0 auto; }
.attach-thumb {
  display: block;
  max-width: 150px;
  max-height: 110px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  object-fit: cover;
}
.attach-remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(var(--tint-rgb), 0.22);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.attach-remove:hover { background: var(--danger); }
.attach-info {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted-2);
  word-break: break-word;
}

/* 消息区外层 + 历史加载条 */
.messages-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.messages { flex: 1 1 auto; min-height: 0; }

.history-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 8px 12px 2px;
}
.history-btn {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(var(--tint-rgb), 0.05);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.history-btn:hover { color: var(--accent); border-color: rgba(20, 184, 166, 0.4); }
.history-btn:disabled { opacity: 0.6; cursor: default; }

/* 头像图片版 */
.avatar.has-img,
.user-avatar.has-img,
.avatar-preview.has-img,
.msg .avatar.has-img,
.msg.me .avatar.has-img {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
}

/* 侧栏底部：我的资料 */
.me-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.me-chip:hover { background: rgba(var(--tint-rgb), 0.07); }
.me-avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: #33414f;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #cfe3ee;
}
.me-name {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge.member { background: rgba(96, 165, 250, 0.14); color: #93c5fd; }

/* 消息定位高亮 */
.msg.flash .bubble {
  box-shadow: 0 0 0 2px var(--accent);
  transition: box-shadow 0.3s ease;
}

/* 个人中心 */
.avatar-edit { display: flex; align-items: center; gap: 14px; }
.avatar-preview {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background-color: #33414f;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #cfe3ee;
}
.avatar-edit-ops { flex: 1; min-width: 0; }

/* 搜索 */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input { flex: 1; min-width: 0; }
.search-count { margin-bottom: 8px; font-size: 12px; color: var(--muted-2); }
.search-item {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(var(--tint-rgb), 0.04);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.search-item:hover { background: rgba(20, 184, 166, 0.1); border-color: rgba(20, 184, 166, 0.3); }
.search-item-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.search-item-nick { font-size: 12.5px; font-weight: 600; color: #7fdccf; }
.search-item-time { font-size: 11.5px; color: var(--muted-2); }
.search-item-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  word-break: break-word;
}
.search-item-thumb { display: block; margin-top: 7px; max-height: 92px; border-radius: 8px; }

/* 历史图片 */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-cell {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(var(--tint-rgb), 0.04);
  cursor: pointer;
  aspect-ratio: 1 / 1;
}
.media-cell img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-more { margin-top: 14px; text-align: center; }

/* 站点开关 */
.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(var(--tint-rgb), 0.04);
}
.switch-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.switch-title { font-size: 13px; }
.switch-sub { font-size: 11.5px; line-height: 1.45; color: var(--muted-2); }
.switch-btn {
  position: relative;
  flex: 0 0 auto;
  width: 48px;
  height: 27px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(120, 140, 160, 0.25);
  cursor: pointer;
  transition: background 0.18s ease;
}
.switch-btn.on { background: #14b8a6; border-color: #14b8a6; }
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}
.switch-btn.on .switch-knob { transform: translateX(21px); }

/* 用户管理 */
.user-add { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.user-add-row { display: flex; gap: 8px; }
.user-add-row input { flex: 1; min-width: 0; }
.user-row { flex-wrap: wrap; gap: 8px; }
.user-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-name-txt { font-weight: 600; }
.user-note {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--muted-2);
}
.user-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-pwd-wrap { display: flex; align-items: center; gap: 6px; }
.user-pwd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--muted);
  word-break: break-all;
}
.user-pwd-wrap.revealed .user-pwd { color: #ffd9a8; }
.user-last { font-size: 11.5px; color: var(--muted-2); }

@media (max-width: 820px) {
  .drawer { width: 100vw; border-left: 0; }
  .msg-actions { opacity: 1; top: 12px; }
  .msg-action-btn { width: 26px; height: 26px; font-size: 13px; }
  .attach-thumb { max-width: 100px; max-height: 84px; }
  .media-grid { grid-template-columns: repeat(3, 1fr); }
  .user-add-row { flex-wrap: wrap; }
  .switch-row { gap: 8px; }
  .history-bar { padding: 6px 10px 0; }
}


/* ============================================================ v13：单一登录 / 表情分组 / IP 与时间戳 / 独立日志 */

/* 登录页：唯一的用户名 + 密码入口，文案全部来自后台 */
.login-sub { cursor: default; }

/* 消息时间戳：小字，比日期分隔更轻 */
.time-sep {
  display: flex;
  justify-content: center;
  margin: 12px 0 2px;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.4px;
}

/* 长按气泡时不弹系统菜单，交给自己的操作菜单 */
.msg { -webkit-touch-callout: none; }
.msg .bubble { -webkit-touch-callout: none; }

/* 表情包选项卡：分组多了可以横向滑动 */
.sticker-tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.sticker-tabs::-webkit-scrollbar { display: none; }
.sticker-tabs .tab {
  flex: 0 0 auto;
  padding: 10px 14px;
  white-space: nowrap;
}

/* 表情包列表：任何宽高的图都只缩不放，绝不拉变形 */
.sticker-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
}
.sticker-cell img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 64px;
  object-fit: contain;
}

/* 图片查看：底部按钮条 */
.lightbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  cursor: default;
}
.lightbox img { cursor: zoom-out; }
.lightbox-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.lightbox-btn {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid rgba(var(--tint-rgb), 0.22);
  background: rgba(var(--tint-rgb), 0.09);
  color: #f2f6f7;
  font-size: 13px;
  cursor: pointer;
}
.lightbox-btn:hover { background: rgba(var(--tint-rgb), 0.18); }

/* 后台：表情包上传行与分组徽标 */
.admin-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.admin-upload input[type="text"] { flex: 1 1 130px; min-width: 0; }
.admin-sticker-grp {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(20, 184, 166, 0.4);
  color: var(--accent);
  font-size: 10px;
  line-height: 16px;
}

/* 后台：日志抽屉里的行更紧凑 */
#auditPanel .admin-row { padding: 9px 0; }

/* ---------------------------------------------------- 头像裁剪 */

.crop-layer {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 10, 14, 0.82);
}

.crop-card {
  width: min(340px, 100%);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  padding: 16px 16px 14px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
}
.crop-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 650; }

.crop-stage {
  position: relative;
  width: 288px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  touch-action: none;
  cursor: grab;
}
.crop-stage.dragging { cursor: grabbing; }
#cropCanvas { display: block; width: 100%; height: 100%; }

/* 圆形遮罩：圆圈内就是头像最终可见的部分 */
.crop-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72%;
  height: 72%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(20, 184, 166, 0.75);
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.crop-zoom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 2px 10px;
  color: var(--muted-2);
  font-size: 11.5px;
}
.crop-zoom input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.crop-foot { display: flex; align-items: center; gap: 12px; }
.crop-preview {
  flex: 0 0 auto;
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(var(--tint-rgb), 0.05);
}
.crop-foot .admin-tip { margin: 0; }

.crop-ops {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.crop-ops .btn-small { flex: 1; }
.crop-ops .btn-primary { flex: 1.4; }

@media (max-width: 820px) {
  .clock-bar { padding: 6px 12px; }
  .clock-text { font-size: 11.5px; }
  .crop-stage { width: 100%; }
}

/* ---------------------------------------------------- 系统消息（模块） */

.sys-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: min(560px, 86%);
  margin: 10px auto;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(var(--tint-rgb), 0.04);
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  word-break: break-word;
}

.sys-msg-tag {
  flex: 0 0 auto;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  line-height: 18px;
}

.sys-msg-text { flex: 1 1 auto; }

@media (max-width: 820px) {
  .sys-msg { max-width: 92%; font-size: 12px; }
}

/* 撤回后的原文（仅管理员可见） */
.revoke-ghost {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(var(--tint-rgb), 0.14);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.revoke-ghost-by {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 11.5px;
}

/* ---------------------------------------------------- 模块管理（后台） */

.mod-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.mod-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.mod-tab:hover { border-color: var(--line-strong); color: var(--text); }

.mod-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.mod-tab .mod-tab-dot {
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(var(--tint-rgb), 0.06);
  color: var(--muted-2);
  font-size: 10.5px;
  line-height: 16px;
}

.mod-tab.active .mod-tab-dot { color: var(--accent); }

.mod-body {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 12px 14px 14px;
}

.mod-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.mod-info { min-width: 0; }
.mod-title { font-size: 14px; font-weight: 600; }
.mod-desc { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.mod-form { margin-top: 12px; display: flex; flex-direction: column; gap: 14px; }

.mod-field { display: flex; flex-direction: column; gap: 6px; }
.mod-field-label { font-size: 13px; color: var(--text); }
.mod-field-hint { color: var(--muted-2); font-size: 11.5px; line-height: 1.5; }

.mod-field input[type="text"],
.mod-field input[type="number"],
.mod-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-soft);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.mod-field textarea { resize: vertical; min-height: 62px; line-height: 1.5; }

.mod-field input:focus,
.mod-field textarea:focus { border-color: var(--accent); }

.mod-switch { padding: 0; }
.mod-switch .switch-main { min-width: 0; }

.mod-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.btn-small.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

.btn-small.ghost.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.4); }

/* 定时消息编辑器 */

.sched-box { display: flex; flex-direction: column; gap: 10px; }
.sched-list { display: flex; flex-direction: column; gap: 10px; }

.sched-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-soft);
}

.sched-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.sched-row textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-soft);
  color: var(--text);
  font-size: 13px;
  resize: vertical;
  min-height: 52px;
  outline: none;
}

.sched-row textarea:focus { border-color: var(--accent); }

.sched-time {
  width: 72px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-soft);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  outline: none;
}

.sched-time:focus { border-color: var(--accent); }

.sched-label { color: var(--muted-2); font-size: 11.5px; }
.sched-hint { color: var(--muted-2); font-size: 11px; }

.sched-days { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.sched-day {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(var(--tint-rgb), 0.04);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.sched-day.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sched-lead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.sched-lead-num {
  width: 60px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-soft);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  outline: none;
}

.sched-lead-text {
  flex: 1 1 160px;
  min-width: 120px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-soft);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
}

.sched-lead-text:focus,
.sched-lead-num:focus { border-color: var(--accent); }

.sched-line .switch-btn.mini { transform: scale(0.85); transform-origin: left center; }

@media (max-width: 820px) {
  .mod-body { padding: 10px 12px 12px; }
  .sched-lead-text { flex-basis: 100%; }
}

/* ============================================================ v26 追加样式
   只追加，不覆盖：模块管理独立页、历史媒体分类、视频/文件消息、
   资源已删除占位、上传进度、系统消息图标。 */

/* ---------- 系统消息：图标 ---------- */
.sys-msg-icon {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

/* ---------- 媒体抽屉：分类标签 ---------- */
.media-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.media-tab {
  flex: 1 1 0;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(var(--tint-rgb), 0.05);
  border: 1px solid rgba(var(--tint-rgb), 0.08);
  border-radius: 9px;
  cursor: pointer;
}
.media-tab.active {
  color: #fff;
  background: rgba(20, 184, 166, 0.18);
  border-color: rgba(20, 184, 166, 0.55);
}

/* 视频 / 文件格子：没有缩略图，用图标 + 文案 */
.media-cell.media-video,
.media-cell.media-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  text-align: center;
  background: rgba(var(--tint-rgb), 0.06);
}
.media-play {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  background: rgba(20, 184, 166, 0.6);
}
.media-file-icon { font-size: 20px; line-height: 1; }
.media-name {
  max-width: 100%;
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-size { font-size: 10px; color: var(--text-faint, rgba(255,255,255,0.45)); }

/* ---------- 气泡内：视频 ---------- */
.bubble.video {
  padding: 4px;
  max-width: min(74%, 420px);
  background: rgba(var(--tint-rgb), 0.06);
}
.bubble-video {
  display: block;
  width: 100%;
  max-width: 400px;
  max-height: 320px;
  border-radius: 12px;
  background: #000;
}
.bubble.video .bubble-caption {
  margin: 6px 4px 2px;
}

/* ---------- 气泡内：文件卡片 ---------- */
.bubble.file {
  padding: 0;
  background: transparent;
}
.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--text, #f1f5f9);
  background: rgba(var(--tint-rgb), 0.07);
  border: 1px solid rgba(var(--tint-rgb), 0.1);
}
.file-card:hover { background: rgba(var(--tint-rgb), 0.11); }
.file-icon { flex: 0 0 auto; font-size: 20px; line-height: 1; }
.file-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size { font-size: 11px; color: var(--text-dim); }

/* ---------- 资源已删除 ---------- */
.bubble.gone {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  padding: 9px 12px;
  background: rgba(var(--tint-rgb), 0.05);
  border: 1px dashed rgba(var(--tint-rgb), 0.18);
}
.media-cell.gone {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px dashed rgba(var(--tint-rgb), 0.16);
}

/* ---------- 上传进度 ---------- */
.upload-progress {
  margin: 0 10px 6px;
  padding: 6px 10px 8px;
  border-radius: 10px;
  background: rgba(var(--tint-rgb), 0.05);
}
.upload-progress-bar {
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
  background: rgba(var(--tint-rgb), 0.1);
}
.upload-progress-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #14b8a6, #22d3ee);
  transition: width 0.15s linear;
}
.upload-progress-text {
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-dim);
}

/* ---------- 模块管理独立页 ---------- */
#modPanel .admin-body { padding-bottom: 28px; }
#modPanel .mod-tabs { position: sticky; top: 0; z-index: 2; }

/* 移动端微调 */
@media (max-width: 560px) {
  .bubble-video { max-width: 100%; max-height: 240px; }
  .file-card { max-width: 200px; padding: 9px 10px; }
  .media-name { font-size: 10px; }
  .upload-progress { margin: 0 8px 5px; }
}

/* ---------- v27：视频封面 / 音频消息 ---------- */
/* 视频格子有封面图时铺满整格，播放图标浮在中间 */
.media-cell.media-video { position: relative; padding: 0; overflow: hidden; }
.media-cell.media-video img { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-cell.media-video .media-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.media-thumb-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.media-cell.media-audio {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  text-align: center;
  background: rgba(var(--tint-rgb), 0.06);
}

/* 气泡内：音频播放条 */
.bubble.audio {
  padding: 6px;
  max-width: min(74%, 420px);
  background: rgba(var(--tint-rgb), 0.06);
}
.audio-card {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.audio-icon { font-size: 16px; line-height: 1; }
.audio-meta { min-width: 0; }
.audio-meta .file-name { font-size: 12px; color: var(--text, #fff); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.audio-meta .file-size { font-size: 11px; color: var(--text-dim); }
.audio-player { width: 100%; min-width: 220px; height: 34px; margin-top: 4px; }
/* ---------------- 系统更新面板 ---------------- */
.upd-row{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid rgba(255,255,255,.06);font-size:13px}
.upd-k{color:#8b98a5;flex:0 0 76px}
.upd-v{color:#e6eef5;word-break:break-all}
.upd-row .mono{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px}
.upd-h{font-size:15px;margin:0 0 10px;color:#e6eef5;font-weight:500}
.upd-notes{font-size:13px;line-height:1.7;color:#c8d2dc;margin:0 0 10px;white-space:pre-wrap}
.upd-list{margin:0;padding-left:18px;font-size:13px;line-height:1.85;color:#c8d2dc}
.upd-list b{color:#57e0c4;font-weight:500;margin-right:2px}
.upd-steps{list-style:none;margin:0;padding:0;font-size:13px}
.upd-step{display:flex;gap:8px;padding:6px 0;color:#9fb0bf;line-height:1.6}
.upd-step.ok{color:#e6eef5}
.upd-step.fail{color:#ff9a9a}
.upd-step-icon{flex:0 0 16px;text-align:center}
.upd-step.ok .upd-step-icon{color:#57e0c4}
.upd-step.fail .upd-step-icon{color:#ff9a9a}
.upd-log{margin-top:10px;max-height:240px;overflow:auto;background:rgba(0,0,0,.25);border-radius:8px;padding:10px;font-size:12px;line-height:1.55;color:#b6c4d0;white-space:pre-wrap}
/* ============================================================
   配色模板（个人配色，存在 users.theme / settings.admin_theme）
   默认 :root 即「暗夜青」，其余靠 html[data-theme] 覆盖变量
   ============================================================ */

/* 深海蓝 */
html[data-theme="ocean"] {
  --bg: #0a1220;
  --panel: #0f1b2d;
  --panel-2: #142439;
  --text: #e3ecf7;
  --muted: #8fa1b6;
  --muted-2: #6a7c92;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-strong: #2563eb;
  --bubble-me: linear-gradient(135deg, #2563eb, #1d4ed8);
  --bubble-other: #17263c;
  --danger: #fb7185;
  --gold: #60a5fa;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.42);
  --bg-grad:
    radial-gradient(1200px 600px at 100% -10%, rgba(59, 130, 246, 0.16), transparent 62%),
    radial-gradient(900px 500px at -10% 110%, rgba(14, 165, 233, 0.08), transparent 60%);
}

/* 月光白（浅色） */
html[data-theme="light"] {
  --tint-rgb: 17, 24, 39;
  --surface-rgb: 255, 255, 255;
  --field: rgba(17, 24, 39, 0.055);
  --field-2: rgba(17, 24, 39, 0.07);
  --field-soft: rgba(17, 24, 39, 0.05);
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --line: rgba(17, 24, 39, 0.10);
  --line-strong: rgba(17, 24, 39, 0.18);
  --text: #1f2937;
  --muted: #5b6673;
  --muted-2: #8b95a1;
  --accent: #0f9d8f;
  --accent-soft: rgba(15, 157, 143, 0.12);
  --accent-strong: #0b8377;
  --bubble-me: linear-gradient(135deg, #12a597, #0b8377);
  --bubble-other: #eaf0f4;
  --danger: #dc2626;
  --gold: #b45309;
  --shadow: 0 8px 26px rgba(15, 23, 42, 0.14);
  --bg-grad:
    radial-gradient(1200px 600px at 100% -10%, rgba(15, 157, 143, 0.10), transparent 62%),
    radial-gradient(900px 500px at -10% 110%, rgba(180, 83, 9, 0.05), transparent 60%);
}
html[data-theme="light"] .login { background: rgba(243, 245, 248, 0.94); }
html[data-theme="light"] .bubble.revoked { color: var(--muted) !important; }
html[data-theme="light"] .msg.me .avatar { background-color: #d9e6ee; color: #1f2937; }
html[data-theme="light"] .msg.me .msg-head .nick { color: #0b8377; }

/* 森野绿 */
html[data-theme="forest"] {
  --bg: #0b1410;
  --panel: #10201a;
  --panel-2: #16291f;
  --text: #e4f1e8;
  --muted: #93ad9d;
  --muted-2: #6c8478;
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.14);
  --accent-strong: #10b981;
  --bubble-me: linear-gradient(135deg, #13866a, #0d6b55);
  --bubble-other: #163024;
  --danger: #f87171;
  --gold: #a3e635;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.38);
  --bg-grad:
    radial-gradient(1200px 600px at 100% -10%, rgba(52, 211, 153, 0.12), transparent 62%),
    radial-gradient(900px 500px at -10% 110%, rgba(163, 230, 53, 0.06), transparent 60%);
}

/* 暖阳橘 */
html[data-theme="sunset"] {
  --bg: #17110d;
  --panel: #221812;
  --panel-2: #2c1f17;
  --text: #f6ebe3;
  --muted: #bfa192;
  --muted-2: #93796c;
  --accent: #fb923c;
  --accent-soft: rgba(251, 146, 60, 0.14);
  --accent-strong: #ea7c22;
  --bubble-me: linear-gradient(135deg, #c2611f, #9c4a12);
  --bubble-other: #33231a;
  --danger: #f87171;
  --gold: #fbbf24;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.40);
  --bg-grad:
    radial-gradient(1200px 600px at 100% -10%, rgba(251, 146, 60, 0.13), transparent 62%),
    radial-gradient(900px 500px at -10% 110%, rgba(251, 191, 36, 0.07), transparent 60%);
}

/* 玫瑰粉 */
html[data-theme="rose"] {
  --bg: #150e14;
  --panel: #201621;
  --panel-2: #2a1d2c;
  --text: #f7e8f2;
  --muted: #bf9cb6;
  --muted-2: #92748c;
  --accent: #f472b6;
  --accent-soft: rgba(244, 114, 182, 0.14);
  --accent-strong: #db4f9c;
  --bubble-me: linear-gradient(135deg, #b03a73, #8c2a59);
  --bubble-other: #33233a;
  --danger: #fb7185;
  --gold: #fbcfe8;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.40);
  --bg-grad:
    radial-gradient(1200px 600px at 100% -10%, rgba(244, 114, 182, 0.13), transparent 62%),
    radial-gradient(900px 500px at -10% 110%, rgba(168, 85, 247, 0.08), transparent 60%);
}

/* ============================================================
   配色选择器（个人中心）
   ============================================================ */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
}

.theme-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  font-size: 12px;
}
.theme-item:hover { border-color: var(--accent); }
.theme-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.theme-item .theme-swatch {
  display: flex;
  gap: 4px;
  height: 24px;
}
.theme-item .theme-swatch i {
  flex: 1;
  border-radius: 5px;
  border: 1px solid var(--line);
}
.theme-item .theme-name { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.theme-item .theme-check { color: var(--accent); font-size: 11px; }

.theme-preview {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.theme-preview .tp-bubble {
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.theme-preview .tp-me { background: var(--bubble-me); color: #f0fffd; }
.theme-preview .tp-other { background: var(--bubble-other); border: 1px solid var(--line); color: var(--text); }

/* ============================================================
   表情回应
   ============================================================ */

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.msg.me .reactions { justify-content: flex-end; }

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(var(--tint-rgb), 0.05);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.reaction-chip:hover { border-color: var(--accent); color: var(--text); }
.reaction-chip.mine {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.reaction-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted-2);
  font-size: 13px;
  line-height: 1;
  opacity: 0.75;
}
.reaction-add:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }

/* ============================================================
   正在输入
   ============================================================ */

.typing-hint {
  position: absolute;
  left: 16px;
  bottom: 96px;
  max-width: 60%;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(var(--tint-rgb), 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  z-index: 8;
}


/* 登录页「记住用户名和密码」 */
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 2px;
  color: var(--muted);
  font-size: 12.5px;
  user-select: none;
  cursor: pointer;
}
.remember-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent, #2ee6c5);
  cursor: pointer;
}

/* ---------------------------------------------------- 附件菜单（＋ 展开） */

.attach-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 10px;
}
.attach-tray[hidden] { display: none; }

.tray-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.tray-btn:hover { border-color: rgba(var(--tint-rgb), 0.3); color: var(--accent); }
.tray-btn[hidden] { display: none; }

#attachBtn { font-size: 18px; line-height: 1; font-weight: 400; }
#attachBtn.active { background: rgba(var(--tint-rgb), 0.07); color: var(--accent); }

@media (max-width: 640px) {
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer-row { gap: 6px; padding: 5px; }
  .tool-btn { width: 30px; height: 30px; }
  #attachBtn { font-size: 17px; }
  .btn-send { min-width: 54px; padding: 0 12px; height: 32px; }
}
/* ---------------------------------------------------------- 音乐播放器（模块 music-player） */

.music-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(var(--tint-rgb), 0.05);
  border-bottom: 1px solid var(--line);
}

.music-bar[hidden] { display: none; }

.music-play {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.music-play.playing { background: var(--accent); border-color: var(--accent); color: #fff; }

.music-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.music-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.music-title {
  font-size: 13px;
  color: var(--text, #e9ecef);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.music-sub { font-size: 11px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-sub[hidden] { display: none; }

.music-progress {
  height: 4px;
  border-radius: 4px;
  background: rgba(var(--tint-rgb), 0.12);
  cursor: pointer;
  overflow: hidden;
}
.music-progress-fill { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.15s linear; }

.music-time { flex: 0 0 auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.music-btn {
  flex: 0 0 auto;
  height: 26px;
  min-width: 26px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.music-btn:hover { color: var(--accent); border-color: var(--accent); }
.music-mode { min-width: 44px; }

.music-list {
  position: absolute;
  right: 10px;
  top: calc(100% + 6px);
  z-index: 30;
  width: 300px;
  max-height: 340px;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
  padding: 10px;
}
.music-list[hidden] { display: none; }

.music-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.music-list-title { font-size: 12px; color: var(--muted); }
.music-list-close {
  border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1;
}

.music-lists { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.music-list-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.music-list-tab.active { border-color: var(--accent); color: var(--accent); background: rgba(var(--tint-rgb), 0.07); }
.music-list-tab:disabled { opacity: 0.45; cursor: default; }

.music-tracks { display: flex; flex-direction: column; gap: 2px; }
.music-track {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text, #e9ecef);
  font-size: 12.5px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.music-track:hover { background: rgba(var(--tint-rgb), 0.07); }
.music-track.current { background: rgba(var(--tint-rgb), 0.12); color: var(--accent); }
.music-track-idx { flex: 0 0 18px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.music-track-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-track-dur { flex: 0 0 auto; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.music-empty { color: var(--muted-2); font-size: 12px; padding: 10px 4px; }

/* ---------------------------------------------------------- 模块后台：折叠 / 排序 / 音乐编辑器 */

.mod-move { display: flex; gap: 6px; margin: 2px 0 6px; }
.mod-move-btn { padding: 0 8px; height: 26px; font-size: 12px; }
.mod-move-btn:disabled { opacity: 0.35; cursor: default; }

.mod-fold-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 10px 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(var(--tint-rgb), 0.04);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}
.mod-fold-bar:hover { border-color: var(--accent); color: var(--accent); }
.mod-fold-caret { color: var(--muted-2); font-size: 12px; }

.mod-form[hidden] { display: none; }

.music-admin { display: flex; flex-direction: column; gap: 14px; }
.music-admin-head { display: flex; align-items: center; justify-content: space-between; }
.music-admin-title { font-size: 12.5px; color: var(--muted); }
.music-admin-tools { display: flex; align-items: center; gap: 6px; }

.music-lib { display: flex; flex-direction: column; gap: 6px; }
.music-lib-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.music-lib-name {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text, #e9ecef);
  font-size: 12.5px;
  padding: 2px 0;
}
.music-lib-name:focus { outline: 1px solid var(--accent); border-radius: 6px; }
.music-lib-meta { flex: 0 0 auto; font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.music-server-lib { display: flex; flex-direction: column; gap: 6px; }
.music-server-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.music-server-text { font-size: 12px; color: var(--muted); }

.music-playlists { display: flex; flex-direction: column; gap: 10px; }
.music-pl {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--panel-2);
}
.music-pl.active { border-color: var(--accent); }
.music-pl-top { display: flex; align-items: center; gap: 6px; }
.music-pl-name {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px dashed var(--line);
  color: var(--text, #e9ecef);
  font-size: 13px;
  padding: 4px 0;
}
.music-pl-body { margin-top: 8px; }
.music-pl-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow: auto; }
.music-chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.music-chip.on { border-color: var(--accent); color: var(--accent); background: rgba(var(--tint-rgb), 0.08); }
.music-pl-count { margin-top: 6px; font-size: 11px; color: var(--muted-2); }

@media (max-width: 640px) {
  .music-bar { padding: 6px 8px; gap: 5px; flex-wrap: wrap; }
  .music-main { flex: 1 1 calc(100% - 42px); }
  .music-time { display: none; }
  .music-list { left: 6px; right: 6px; width: auto; }
  .music-lib-meta { display: none; }
}
