:root,
[data-theme="linen"] {
  --bg: #f6f3ec;
  --panel: #fffdf8;
  --ink: #1d2430;
  --muted: #7c8494;
  --line: #e6dfd2;
  --accent: #0f766e;
  --accent-soft: #d9f0ec;
  --bubble: #ffffff;
  --bubble-mine: #d9f0ec;
  --surface: #ffffff;
  --surface-2: #efe9dd;
  --sys-bg: #f0ebdf;
  --danger: #b4423a;
  --ok: #2f9e6f;
  --shadow: 0 10px 30px rgba(29, 36, 48, .08);
  --radius: 16px;
  --glow: radial-gradient(1200px 600px at 15% -10%, #e4efe9 0%, transparent 60%);
}

[data-theme="night"] {
  --bg: #0e131a;
  --panel: #151d27;
  --ink: #e8edf4;
  --muted: #8b97a8;
  --line: #26303d;
  --accent: #4fd1c5;
  --accent-soft: #173b3a;
  --bubble: #1d2632;
  --bubble-mine: #16393a;
  --surface: #1a2330;
  --surface-2: #101821;
  --sys-bg: #101821;
  --danger: #e57373;
  --ok: #5ecb9a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --glow: radial-gradient(1200px 600px at 15% -10%, #173240 0%, transparent 60%);
}

[data-theme="ocean"] {
  --bg: #eef4f9;
  --panel: #ffffff;
  --ink: #16283b;
  --muted: #6b8199;
  --line: #d7e3ef;
  --accent: #1f6feb;
  --accent-soft: #dbe9ff;
  --bubble: #ffffff;
  --bubble-mine: #dbe9ff;
  --surface: #ffffff;
  --surface-2: #e4eef8;
  --sys-bg: #e4eef8;
  --danger: #c0392b;
  --ok: #1f9d8b;
  --shadow: 0 10px 30px rgba(22, 40, 59, .10);
  --glow: radial-gradient(1200px 600px at 15% -10%, #dbe9f7 0%, transparent 60%);
}

[data-theme="forest"] {
  --bg: #eef3ec;
  --panel: #fbfdf9;
  --ink: #1b2a21;
  --muted: #6c8172;
  --line: #d8e3d6;
  --accent: #2f7d4f;
  --accent-soft: #dcefe2;
  --bubble: #ffffff;
  --bubble-mine: #dcefe2;
  --surface: #ffffff;
  --surface-2: #e3ece2;
  --sys-bg: #e7efe5;
  --danger: #a8443a;
  --ok: #2f7d4f;
  --shadow: 0 10px 30px rgba(27, 42, 33, .10);
  --glow: radial-gradient(1200px 600px at 15% -10%, #e2efe4 0%, transparent 60%);
}

[data-theme="sakura"] {
  --bg: #fbf1f2;
  --panel: #fffbfb;
  --ink: #33262b;
  --muted: #927f88;
  --line: #ecdcdd;
  --accent: #b34a6b;
  --accent-soft: #f7dde4;
  --bubble: #ffffff;
  --bubble-mine: #f7dde4;
  --surface: #ffffff;
  --surface-2: #f6e7e8;
  --sys-bg: #f6e7e8;
  --danger: #b4423a;
  --ok: #2f9e6f;
  --shadow: 0 10px 30px rgba(51, 38, 43, .10);
  --glow: radial-gradient(1200px 600px at 15% -10%, #f8e6ea 0%, transparent 60%);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  background: var(--glow), var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  transition: background .25s, color .25s;
}

.hidden { display: none !important; }

/* ---------------- 登录页 ---------------- */
.gate {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
}

.gate-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
}

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }

.brand-mark {
  width: 46px; height: 46px; flex: none;
  border-radius: 14px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; letter-spacing: 1px;
}

.brand h1 { font-size: 21px; letter-spacing: .5px; }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

.tabs {
  display: flex; gap: 6px;
  background: var(--surface-2);
  padding: 4px; border-radius: 12px; margin-bottom: 18px;
}

.tab {
  flex: 1; border: 0; cursor: pointer;
  background: transparent; color: var(--muted);
  padding: 9px 0; border-radius: 9px;
  font-size: 14px; font-weight: 600; transition: .2s;
}
.tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field em { font-style: normal; font-size: 12px; opacity: .8; }

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px; color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#username { letter-spacing: 3px; font-weight: 600; text-transform: lowercase; }

input.masked-input {
  -webkit-text-security: disc;
  text-security: disc;
}

.agree { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
.agree input { margin-top: 3px; accent-color: var(--accent); }
.agree a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted var(--accent); }

.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }

.primary {
  width: 100%; padding: 13px;
  border: 0; border-radius: 12px;
  background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: .5px;
  cursor: pointer; transition: transform .15s, opacity .2s;
}
.primary:active { transform: scale(.985); }
.primary[disabled] { opacity: .6; cursor: default; }

.gate-tip { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

.gate-links { display: flex; justify-content: center; gap: 18px; margin-top: 12px; }
.linklike {
  border: 0; background: none; color: var(--muted);
  font-size: 12px; cursor: pointer; border-bottom: 1px dotted var(--line);
}

/* ---------------- 主界面 ---------------- */
.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.icon-btn {
  width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 11px; cursor: pointer;
  font-size: 17px; line-height: 1; color: var(--ink);
}
.icon-btn:active { opacity: .75; }

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #c4bdb0; display: inline-block; }
.status.online .dot { background: var(--ok); }
.status.offline .dot { background: var(--danger); }

.topbar-right { display: flex; align-items: center; gap: 6px; }
.me-name { font-size: 13px; color: var(--muted); letter-spacing: 1px; }

.ghost {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 7px 12px;
  font-size: 13px; color: var(--muted); cursor: pointer;
}

.notice {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.notice span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice button {
  border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; opacity: .7;
}

.body { flex: 1; display: flex; min-height: 0; position: relative; }

.side {
  width: 232px; flex: none;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 12px;
}

.side-block { margin-bottom: 20px; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); letter-spacing: .5px;
  margin-bottom: 8px;
}
.mini {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 4px 8px; font-size: 12px; color: var(--accent); cursor: pointer;
}

.room-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.room-list button {
  width: 100%; text-align: left; border: 0; background: transparent;
  border-radius: 10px; padding: 9px 10px; font-size: 14px; color: var(--ink);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.room-list button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.room-list .badge { font-size: 11px; color: var(--muted); flex: none; }

.people { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.people li {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted); padding: 5px 8px; border-radius: 8px;
}
.people .me { color: var(--accent); font-weight: 600; }

.avatar {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  background: var(--av, #b9c6d2);
  color: #fff;
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0;
  text-shadow: 0 1px 1px rgba(0,0,0,.15);
}
.avatar.lg { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }

.chat { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.history-more {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 12; pointer-events: none;
}
.history-more button {
  pointer-events: auto; border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--accent); padding: 6px 14px; font: inherit; font-size: 12px;
  box-shadow: 0 4px 14px rgba(20, 26, 32, .12); cursor: pointer;
}
.history-more button:disabled { color: var(--muted); cursor: default; opacity: .8; }

.messages {
  flex: 1; overflow-y: auto;
  padding: 16px max(14px, calc((100% - 860px) / 2)) 8px;
  display: flex; flex-direction: column; gap: 10px;
}
.messages::before { content: ""; flex: 1 0 auto; }
.messages.has-history-hint { padding-top: 56px; }

.msg { max-width: 78%; align-self: flex-start; }
.msg.mine { align-self: flex-end; }
.msg.grouped { margin-top: -7px; }

.name {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; letter-spacing: .5px; color: var(--accent);
  margin-bottom: 3px;
}
.msg.mine .name { justify-content: flex-end; color: var(--muted); }

.bubble {
  background: var(--bubble);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 13px;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 2px 6px rgba(29,36,48,.04);
  cursor: pointer;
}
.msg.mine .bubble {
  background: var(--bubble-mine);
  border-color: var(--accent-soft);
  border-radius: 14px 14px 4px 14px;
}

.bubble img { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; }
.bubble .image-open { display: inline-block; line-height: 0; }
.bubble .image-thumb { width: 180px; height: 180px; max-width: 100%; object-fit: cover; }
.image-placeholder {
  display: flex; align-items: center; justify-content: center;
  width: 180px; height: 110px; max-width: 100%;
  border: 1px dashed var(--line); border-radius: 10px;
  color: var(--muted); font-size: 13px; line-height: 1.4;
  background: var(--surface-2, rgba(0,0,0,.03));
}
.file-chip.video-chip { flex-direction: column; align-items: flex-start; gap: 6px; }
.file-chip .video-thumb { width: 180px; height: 100px; max-width: 100%; object-fit: cover; border-radius: 10px; }

.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--accent); font: inherit; font-size: 13px; max-width: 100%;
  border: 0; background: none; padding: 0; cursor: pointer; text-align: left;
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.time { font-size: 11px; color: var(--muted); opacity: .75; margin-top: 3px; }
.msg.mine .time { text-align: right; }

.sys {
  align-self: center; display: inline-flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 8px;
  font-size: 12px; color: var(--muted);
  background: var(--sys-bg); padding: 4px 12px; border-radius: 20px;
  max-width: 92%;
}
.sys.error { color: var(--danger); }
.sys-tag {
  font-size: 10px; line-height: 1.4; padding: 1px 5px; border-radius: 5px;
  background: var(--line); color: var(--muted); cursor: help;
}
.sys-action {
  border: 1px solid currentColor; background: transparent; color: inherit;
  border-radius: 999px; padding: 2px 9px; font-size: 12px; cursor: pointer;
}
.sys-action:disabled { opacity: .55; cursor: default; }
.sys-action:not(:disabled):hover { background: var(--surface); }

.typing {
  height: 20px; padding: 0 max(18px, calc((100% - 860px) / 2 + 18px));
  font-size: 12px; color: var(--muted); flex: none;
}

.upload-panel {
  margin: 0 max(14px, calc((100% - 860px) / 2)) 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.upload-info { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; gap: 12px; }
.upload-info span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.composer {
  position: relative;
  flex: none;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px max(12px, calc((100% - 860px) / 2)) calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

#input {
  flex: 1; resize: none; max-height: 120px;
  padding: 11px 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface);
  font: inherit; color: var(--ink); outline: none; line-height: 1.45;
}
#input:focus { border-color: var(--accent); }

.send {
  flex: none; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff;
  padding: 11px 18px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.send[disabled] { opacity: .5; }

/* ---------------- 主题选择 ---------------- */
.theme-pop {
  position: fixed; z-index: 40;
  right: 14px; top: 62px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  min-width: 168px;
}
.theme-pop h4 { font-size: 12px; color: var(--muted); font-weight: 500; margin: 2px 6px 8px; }
.theme-item {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: none; color: var(--ink);
  padding: 8px; border-radius: 10px; font-size: 13px; cursor: pointer; text-align: left;
}
.theme-item:hover, .theme-item.active { background: var(--surface-2); }
.swatches { display: flex; gap: 3px; }
.swatch { width: 13px; height: 13px; border-radius: 4px; }

/* ---------------- 底部动作面板 ---------------- */
.sheet {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(10, 14, 20, .38);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 460px;
  background: var(--panel);
  border-radius: 20px 20px 0 0;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.sheet-preview {
  font-size: 12px; color: var(--muted);
  padding: 8px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet-action {
  width: 100%; border: 0; background: none; color: var(--ink);
  text-align: left; padding: 13px 10px; border-radius: 10px;
  font-size: 15px; cursor: pointer;
}
.sheet-action:hover { background: var(--surface-2); }
.sheet-action.danger { color: var(--danger); }
.sheet-cancel {
  width: 100%; border: 0; margin-top: 6px;
  background: var(--surface-2); color: var(--muted);
  padding: 12px; border-radius: 12px; font-size: 14px; cursor: pointer;
}

/* ---------------- 管理后台 ---------------- */
.admin {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.admin-top {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.admin-top h3 { flex: 1; font-size: 16px; }
.admin-body {
  flex: 1; overflow-y: auto;
  padding: 16px max(14px, calc((100% - 980px) / 2)) 40px;
}

.admin-login {
  max-width: 360px; margin: 12vh auto 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
}
.admin-login h4 { font-size: 16px; margin-bottom: 6px; }
.admin-login p { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.stat b { display: block; font-size: 24px; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.admin-tab {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 8px 14px; font-size: 13px;
  color: var(--muted); cursor: pointer;
}
.admin-tab.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); font-weight: 600; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.panel h4 { font-size: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.panel .hint { font-size: 12px; color: var(--muted); font-weight: 400; }

.row-list { display: flex; flex-direction: column; gap: 8px; }

.user-row, .report-row, .word-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
}
.user-row .meta, .report-row .meta { flex: 1; min-width: 0; }
.user-row .meta b { font-size: 13px; }
.user-row .meta div, .report-row .meta div { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

.mini-btn {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 5px 9px; font-size: 12px;
  color: var(--ink); cursor: pointer; flex: none;
}
.mini-btn.warn { color: var(--danger); }
.mini-btn.ok { color: var(--ok); }

.tag {
  font-size: 11px; padding: 2px 7px; border-radius: 6px;
  background: var(--surface); color: var(--muted); flex: none;
}
.tag.red { color: var(--danger); }
.tag.green { color: var(--ok); }

.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input {
  flex: 1; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13px; outline: none;
}
.inline-form button {
  border: 0; border-radius: 10px; padding: 9px 14px;
  background: var(--accent); color: #fff; font-size: 13px; cursor: pointer;
}

.notice-editor textarea {
  width: 100%; min-height: 72px; resize: vertical;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  padding: 10px 12px; font: inherit; font-size: 13px; outline: none;
}
.notice-editor .actions { display: flex; gap: 8px; margin-top: 10px; }

.msg-admin {
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
  font-size: 13px; display: flex; gap: 8px; align-items: flex-start;
}
.msg-admin b { flex: none; color: var(--muted); font-size: 12px; }
.msg-admin span { flex: 1; word-break: break-word; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 24, 30, .45);
  display: grid; place-items: center;
  padding: 20px; z-index: 30;
}
.modal-card {
  width: 100%; max-width: 460px; max-height: 80vh; overflow-y: auto;
  background: var(--panel); border-radius: 20px; padding: 22px;
  box-shadow: var(--shadow);
}
.modal-card h3 { font-size: 18px; margin-bottom: 12px; }
.modal-card ol { padding-left: 20px; color: var(--muted); font-size: 13.5px; line-height: 1.8; }
.modal-card .primary { margin-top: 16px; }

/* 桌面端不需要抽屉按钮 */
@media (min-width: 721px) {
  .only-mobile { display: none; }
}

/* ---------------- 手机端 ---------------- */
@media (max-width: 720px) {
  .side {
    position: absolute; z-index: 20; top: 0; bottom: 0; left: 0;
    width: 80%; max-width: 300px;
    transform: translateX(-102%);
    transition: transform .25s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.12);
  }
  .side.open { transform: translateX(0); }
  .side-mask { position: absolute; inset: 0; background: rgba(0,0,0,.25); z-index: 15; }
  .me-name { display: none; }
  .msg { max-width: 86%; }
  .topbar-right { gap: 4px; }
  .ghost { padding: 7px 10px; }
}

/* ---------------- 管理后台：系统更新 ---------------- */
.update-panel { display: flex; flex-direction: column; gap: 14px; }
.update-meta { display: flex; flex-wrap: wrap; gap: 10px 26px; font-size: 13px; color: var(--muted); }
.update-meta b { color: var(--ink); font-weight: 600; }
.update-note { font-size: 12px; line-height: 1.7; color: var(--muted); }
.update-note strong { color: var(--ink); }
.update-warn {
  font-size: 12px; line-height: 1.7; color: var(--danger);
  background: var(--danger-soft, rgba(190, 60, 60, .08));
  border-radius: 10px; padding: 10px 12px;
}
.update-drop {
  border: 1px dashed var(--line); border-radius: 14px;
  background: var(--surface-2);
  padding: 20px 16px; text-align: center;
}
.update-drop .file-input { display: none; }
.file-pick {
  display: inline-block; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 10px; padding: 8px 16px;
  font-size: 13px; color: var(--ink);
}
.file-pick:hover { border-color: var(--accent); color: var(--accent); }
.update-drop .file-name { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); word-break: break-all; }
.update-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.update-result { font-size: 13px; line-height: 1.8; color: var(--ink); }
.update-result .ok-line { color: var(--ok); font-weight: 600; }

/* ---------------- 图片预览 / 引用 ---------------- */
.pending {
  display: flex; align-items: center; gap: 10px;
  margin: 0 12px 8px; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.pending img {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 9px; flex: none; background: var(--surface-2);
}
.pending-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pending-meta b { font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-meta span { font-size: 11px; color: var(--muted); }
.pending button, .quote-bar button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 6px;
}

.quote-bar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 12px 8px; padding: 8px 10px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 8px;
}
.quote-bar-text { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: baseline; font-size: 12px; }
.quote-bar-text b { flex: none; color: var(--accent); }
.quote-bar-text span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bubble .quote {
  display: block; white-space: normal;
  margin: -2px 0 7px; padding: 6px 9px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 12px; line-height: 1.55; color: var(--muted);
  cursor: pointer;
}
.bubble .quote b { color: var(--accent); font-weight: 600; margin-right: 4px; }
.msg.mine .bubble .quote { background: rgba(255,255,255,.55); }
.bubble .caption { display: block; white-space: pre-wrap; margin-top: 7px; font-size: 13px; }

/* ---------------- @ 提及 ---------------- */
.mention-pop {
  position: absolute; left: 62px; right: 64px; bottom: calc(100% + 8px);
  max-height: 180px; overflow: auto; z-index: 35;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 26px rgba(20, 26, 32, .16); padding: 4px;
}
.mention-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; color: var(--ink);
  padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.mention-item:hover, .mention-item:focus, .mention-item.active { background: var(--accent-soft); }
.mention-item b { color: var(--accent); font-weight: 600; }
.bubble .mention { color: var(--accent); font-weight: 700; }
.bubble .mention.me { background: var(--accent-soft); border-radius: 4px; padding: 0 2px; }

/* ---------------- 轻提示 toast（不进入消息流） ---------------- */
.toast-stack {
  position: fixed; top: calc(env(safe-area-inset-top) + 64px); left: 50%;
  transform: translateX(-50%); z-index: 66;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(92vw, 380px); pointer-events: none;
}
.toast {
  max-width: 100%; padding: 9px 14px; border-radius: 10px;
  background: rgba(27, 35, 45, .92); color: #fff; font-size: 13px; line-height: 1.45;
  box-shadow: 0 8px 24px rgba(20, 26, 32, .22);
  animation: toast-in .16s ease-out;
  word-break: break-word;
}
.toast.error { background: rgba(166, 46, 46, .94); }
.toast.success { background: rgba(20, 110, 90, .94); }
.toast.out { opacity: 0; transform: translateY(-4px); transition: .18s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- 更新维护遮罩 ---------------- */
.maintenance {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(20, 26, 32, .55);
  backdrop-filter: blur(3px);
}
.maintenance-card {
  width: min(420px, 100%);
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 24px; text-align: center;
  box-shadow: 0 20px 60px rgba(10, 20, 26, .28);
}
.maintenance-dot {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border-radius: 50%;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  animation: wg-spin 1s linear infinite;
}
.maintenance.done .maintenance-dot {
  animation: none; border-color: var(--accent); position: relative;
}
.maintenance.done .maintenance-dot::after {
  content: "✓"; position: absolute; inset: 0;
  display: grid; place-items: center; font-size: 17px; color: var(--accent);
}
.maintenance-card h3 { font-size: 17px; margin-bottom: 8px; }
.maintenance-card p { font-size: 13px; line-height: 1.7; color: var(--muted); }
.maintenance-card .maintenance-note { font-size: 12px; margin-top: 6px; }
.maintenance-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 16px;
}
.maintenance-actions.single { grid-template-columns: 1fr; }
.maintenance-actions button { width: 100%; white-space: nowrap; }
@keyframes wg-spin { to { transform: rotate(360deg); } }
.msg.flash .bubble { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- 房主管理房间 ---------------- */
.room-manage-card { text-align: left; }
.room-manage-card h3 { margin-bottom: 14px; }
.room-manage-card .field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.room-manage-card .field input {
  display: block; width: 100%; box-sizing: border-box; margin-top: 5px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font-size: 13px;
}
.room-manage-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.room-manage-actions .primary { grid-column: 1 / -1; padding: 11px; font-size: 14px; }
.room-manage-actions .ghost { padding: 8px; font-size: 12px; }
.danger-text { color: var(--danger) !important; }
.room-list button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 附件预览（点击后才加载） ---------------- */
.preview-card { max-width: 640px; padding: 0; overflow: hidden; }
.preview-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.preview-head h3 { margin: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.preview-quote-btn { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.preview-body {
  min-height: 120px; max-height: 60vh; overflow: auto;
  background: var(--surface-2); display: grid; place-items: center; padding: 10px;
}
.preview-body img, .preview-body video {
  max-width: 100%; max-height: 56vh; border-radius: 10px; display: block;
}
.preview-body audio { width: 100%; }
.preview-body iframe { width: 100%; height: 56vh; border: 0; background: #fff; }
.preview-body pre {
  width: 100%; margin: 0; padding: 12px; box-sizing: border-box;
  white-space: pre-wrap; word-break: break-word; font: 13px/1.7 ui-monospace, monospace;
  color: var(--ink); background: var(--surface); border-radius: 10px;
}
.preview-loading { color: var(--muted); font-size: 13px; padding: 24px; }
.preview-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.preview-actions .primary, .preview-actions .ghost { padding: 10px; font-size: 13px; }
