/* ==========================================================================
   Project-4 聊天室 · 样式表
   浅色 / 深色双主题，全部通过 :root 变量驱动，切换只改 <html data-theme>。
   ========================================================================== */

:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #7b8aa3;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --dm: #a855f7;
  --bubble-self: #1d4ed8;
  --bubble-self-text: #ffffff;
  --bubble-other: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --radius: 12px;
  --radius-sm: 8px;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel-2: #0f1728;
  --line: #24314a;
  --line-soft: #1b2537;
  --text: #e6edf7;
  --text-2: #c2cee0;
  --muted: #8fa0b8;
  --accent: #4b8bff;
  --accent-2: #3b7af0;
  --accent-soft: #17233c;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --dm: #c084fc;
  --bubble-self: #2563eb;
  --bubble-self-text: #ffffff;
  --bubble-other: #1a2438;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

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

body {
  /* Windows 上没有 "Segoe UI Variable" 时用 Segoe UI，中文回落微软雅黑 */
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  /* 注意：这里**不要**写 -webkit-font-smoothing: antialiased。
     它在 Windows 的 Chrome / Edge 上会关掉次像素渲染（ClearType），
     14px 的正文立刻变细变淡 —— 手机是高 DPI 看不出来，电脑上一眼就虚。
     让它保持默认（auto），Windows 才会用系统字体渲染。 */
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px 12px;
  transition: background .15s, border-color .15s, color .15s, transform .06s;
}

button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) { background: var(--accent-2); color: #fff; }

button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--accent-soft); }

input, textarea {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}

/* ------------------------------------------------------------------ 顶栏 */
header {
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  position: relative;
  z-index: 5;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: .2px;
  white-space: nowrap;
}

.logo .mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: linear-gradient(140deg, #2563eb, #7c3aed);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .35);
}

header .spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

/* 「通话需 HTTPS」提示：只在私聊 + 非安全上下文时出现 */
.pill.warn {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 38%, transparent);
  font-size: 11.5px;
  padding: 3px 9px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.warn { background: var(--warn); }

.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  border-radius: 9px;
}

/* --------------------------------------------------------------- 主布局 */
main {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr) 268px;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 56px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  flex: none;
}
.panel-head .count {
  margin-left: auto;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.panel-body {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 10px 12px;
}
.panel-body.flush { padding: 0; }

/* 细滚动条 */
.panel-body::-webkit-scrollbar, #log::-webkit-scrollbar,
.log-view::-webkit-scrollbar,
.modal-body::-webkit-scrollbar, .picker::-webkit-scrollbar { width: 8px; height: 8px; }
.panel-body::-webkit-scrollbar-thumb, #log::-webkit-scrollbar-thumb,
.log-view::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb, .picker::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.panel-body::-webkit-scrollbar-thumb:hover, #log::-webkit-scrollbar-thumb:hover,
.log-view::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ------------------------------------------------------------------ 房间 */
.room-list { list-style: none; margin: 0; padding: 6px; }

.room-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background .12s;
  position: relative;
}
.room-item:hover { background: var(--panel-2); }
.room-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.room-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.room-item .nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-item .meta { font-size: 11px; color: var(--muted); font-weight: 400; }
.room-item .lock { font-size: 11px; }

.unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--err);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  line-height: 1;
}

/* --------------------------------------------------------------- 在线用户 */
.user-list { list-style: none; margin: 0; padding: 6px; }

.user-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s;
}
.user-item:hover { background: var(--panel-2); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12.5px;
  font-weight: 650;
  flex: none;
  user-select: none;
  letter-spacing: -.3px;
}
.avatar.lg { width: 34px; height: 34px; border-radius: 11px; font-size: 14px; }

.user-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-item .tagme { font-size: 10.5px; color: var(--muted); }

.role-tag {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  flex: none;
}
.role-tag.mute { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }

/* --------------------------------------------------------------- 中部聊天 */
#chat-panel { position: relative; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-soft);
  flex: none;
  min-height: 46px;
}
.chat-head h2 { font-size: 14.5px; margin: 0; font-weight: 650; }
.chat-head .sub { font-size: 12px; color: var(--muted); }

#topic {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 8px 14px 0;
  padding: 8px 11px;
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: var(--text-2);
  flex: none;
}
#topic.show { display: flex; }
#topic b { color: var(--text); font-weight: 600; }

/* 三个会话各自一个滚动区：只显示当前会话的那一个 */
.logs {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

#log, .log-view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 6px;
  min-height: 0;
  scroll-behavior: smooth;
}
.log-view.hidden { display: none; }

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

.sys, .err {
  text-align: center;
  font-size: 12px;
  margin: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.sys { color: var(--muted); }
.err { color: var(--err); }
.sys .sys-ico, .err .sys-ico { font-size: 12px; }

/* 消息行 */
.msg-row {
  display: flex;
  gap: 9px;
  margin-bottom: 14px;
  align-items: flex-start;
  position: relative;
}
.msg-row.self { flex-direction: row-reverse; }
.msg-row.cont { margin-top: -8px; }
.msg-row.cont .avatar { visibility: hidden; height: 0; }

.msg-main {
  min-width: 0;
  max-width: min(74%, 620px);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.msg-row.self .msg-main { align-items: flex-end; }

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  /* 以前用 --muted（#94a3b8），浅色底上昵称和时间几乎糊成一片 */
  font-size: 12px;
  color: var(--text-2);
  padding: 0 3px;
}
.msg-meta .who { font-weight: 600; color: var(--text); font-size: 13px; }
.msg-row.self .msg-meta .who { color: var(--accent-2); }
.msg-meta .edited { font-style: italic; font-size: 10.5px; }

.bubble {
  background: var(--bubble-other);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 8px 12px;
  /* 14px 在 1080p 的 Windows 上偏小偏细，14.5 明显好读，又不至于挤 */
  font-size: 14.5px;
  line-height: 1.66;
  /* 明确指定正文色，别再依赖继承：不管外面套了哪层容器，消息正文都是主文字色 */
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  position: relative;
  box-shadow: 0 1px 1px rgba(15, 23, 42, .03);
}
.msg-row.self .bubble {
  background: var(--bubble-self);
  color: var(--bubble-self-text);
  border-color: transparent;
}
.bubble a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
.msg-row.self .bubble a { color: #dbeafe; border-bottom-color: rgba(255,255,255,.5); }
.bubble code {
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.msg-row.self .bubble code { background: rgba(255,255,255,.18); }
.bubble pre {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  overflow-x: auto;
  margin: 6px 0 2px;
  font-size: 12.5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.msg-row.self .bubble pre { background: rgba(0,0,0,.16); border-color: rgba(255,255,255,.2); }

.mention {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border-radius: 5px;
  padding: 0 3px;
  font-weight: 600;
}
.msg-row.self .mention { background: rgba(255,255,255,.24); color: #fff; }
.mention.me { background: var(--warn); color: #fff; }

/* 引用块 */
.quote {
  border-left: 3px solid var(--line);
  background: var(--panel-2);
  border-radius: 0 7px 7px 0;
  padding: 5px 9px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
}
.quote .q-from { font-weight: 600; color: var(--accent); margin-right: 5px; }
.quote .q-text { color: var(--muted); }
.msg-row.self .quote { border-left-color: rgba(255,255,255,.45); background: rgba(255,255,255,.12); }
.msg-row.self .quote .q-from { color: #fff; }
.msg-row.self .quote .q-text { color: rgba(255,255,255,.72); }

/* 撤回 / 不可用 */
.recalled {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  padding: 5px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

/* 媒体 */
.audio-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  padding: 2px 0;
}
.audio-bar .play {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 13px;
  flex: none;
  padding: 0;
}
.msg-row.self .audio-bar .play { background: rgba(255,255,255,.22); color: #fff; }
.audio-bar .play:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }

.audio-wave {
  flex: 1;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  min-width: 90px;
}
.audio-wave i {
  flex: 1;
  min-width: 2px;
  background: currentColor;
  opacity: .28;
  border-radius: 2px;
  transition: opacity .1s;
}
.audio-wave i.on { opacity: 1; }
.audio-time { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.msg-row.self .audio-time { color: rgba(255,255,255,.75); }

.img-msg {
  max-width: 260px;
  max-height: 260px;
  border-radius: 9px;
  cursor: zoom-in;
  display: block;
  border: 1px solid var(--line-soft);
  object-fit: cover;
}
.img-loading {
  width: 200px;
  height: 120px;
  border-radius: 9px;
  background: linear-gradient(100deg, var(--panel-2) 30%, var(--line-soft) 50%, var(--panel-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.file-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  padding: 2px 0;
}
.file-ico {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 16px;
  flex: none;
}
.file-info { flex: 1; min-width: 0; }
.file-info .fname {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-info .fsize { font-size: 11px; color: var(--muted); }
.msg-row.self .file-info .fsize { color: rgba(255,255,255,.75); }
.file-msg .dl {
  padding: 4px 9px;
  font-size: 12px;
  flex: none;
}
.msg-row.self .file-msg .dl { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }

/* 表情回应 */
.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12px;
  line-height: 1.7;
  cursor: pointer;
  user-select: none;
}
.reaction:hover { border-color: var(--accent); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* 悬浮操作条 */
.msg-actions {
  position: absolute;
  top: -12px;
  display: none;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  box-shadow: var(--shadow);
  z-index: 3;
}
.msg-row:not(.self) .msg-actions { left: 44px; }
.msg-row.self .msg-actions { right: 44px; }
.msg-row:hover .msg-actions { display: flex; }
.msg-actions button {
  border: none;
  background: transparent;
  padding: 4px 7px;
  font-size: 13px;
  border-radius: 6px;
  line-height: 1;
}
.msg-actions button:hover { background: var(--accent-soft); }

/* 正在输入 */
#typing {
  height: 20px;
  padding: 0 16px;
  font-size: 11.5px;
  color: var(--muted);
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
}
#typing .dots i {
  display: inline-block;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 2px;
  animation: blink 1.2s infinite;
}
#typing .dots i:nth-child(2) { animation-delay: .2s; }
#typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* 回到底部 */
#toBottom {
  position: absolute;
  right: 20px;
  bottom: 132px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: none;
  place-items: center;
  box-shadow: var(--shadow);
  z-index: 4;
  padding: 0;
}
#toBottom.show { display: grid; }
#toBottom .badge-n {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 17px; height: 17px;
  border-radius: 9px;
  background: var(--err);
  color: #fff;
  font-size: 10px;
  display: grid; place-items: center;
  padding: 0 4px;
}

/* --------------------------------------------------------------- 输入区 */
.composer {
  border-top: 1px solid var(--line-soft);
  padding: 8px 12px 10px;
  flex: none;
  background: var(--panel);
}
.composer.dragover {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -6px;
}

.tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.tools button {
  border: none;
  background: transparent;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-2);
}
.tools button:hover { background: var(--accent-soft); color: var(--accent); }
.tools .sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.tools .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.tools .hintlen { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.input-row { display: flex; gap: 8px; align-items: flex-end; }

#input {
  resize: none;
  max-height: 132px;
  min-height: 40px;
  line-height: 1.55;
  padding: 9px 11px;
  border-radius: 10px;
  overflow-y: auto;
  color: var(--text);
  font-size: 14.5px;
}

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 15px;
  flex: none;
}
.send-btn:disabled { opacity: .35; }

/* 待发送附件预览 */
.attach-preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.attach-preview.show { display: flex; }
.attach-preview img.thumb {
  width: 46px; height: 46px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
}
.attach-preview .ap-ico {
  width: 42px; height: 42px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 18px;
  flex: none;
}
.attach-preview .ap-info { flex: 1; min-width: 0; }
.attach-preview .ap-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview .ap-sub { font-size: 11.5px; color: var(--muted); }

/* 录音条 */
.recorder {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin-bottom: 8px;
  background: color-mix(in srgb, var(--err) 7%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--err) 35%, var(--line));
  border-radius: 10px;
}
.recorder.show { display: flex; }
.recorder .rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--err);
  animation: pulse 1s infinite;
  flex: none;
}
@keyframes pulse { 50% { opacity: .25; transform: scale(.85); } }
.recorder canvas { flex: 1; height: 30px; min-width: 60px; }
.recorder .rec-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--err);
  font-weight: 600;
  flex: none;
}
.recorder .rec-tip { font-size: 11px; color: var(--muted); flex: none; }

/* 引用中的提示条 */
.reply-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  font-size: 12px;
}
.reply-bar.show { display: flex; }
.reply-bar .rb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.reply-bar .rb-from { font-weight: 600; color: var(--accent); margin-right: 5px; }

/* -------------------------------------------------------------- 右栏小卡 */
.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  margin-bottom: 10px;
  background: var(--panel-2);
}
.card .card-title {
  font-size: 12.5px;
  font-weight: 650;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card .q-text { font-size: 13.5px; font-weight: 600; margin-bottom: 9px; line-height: 1.5; }
.card .q-opts { display: flex; flex-direction: column; gap: 6px; }

.opt {
  text-align: left;
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 8px;
}
.opt.right {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  border-color: var(--ok);
  color: var(--ok);
}
.opt.chosen { border-color: var(--accent); background: var(--accent-soft); }

/* 投票选项：左边是文案，右边是实时票数与比例条 */
.vote-opt { display: block; line-height: 1.45; }
.vote-opt.static { cursor: default; }
.vote-opt .vote-n {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.vote-opt.right .vote-n { color: inherit; opacity: .85; }
.vote-bar {
  display: block;
  height: 4px;
  margin-top: 4px;
  border-radius: 2px;
  background: var(--line-soft);
  overflow: hidden;
}
.vote-bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .25s ease;
}
.vote-opt.right .vote-bar > i { background: var(--ok); }
#voteBox .card { margin-bottom: 0; }

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.score-row:last-child { border-bottom: none; }
.score-row b { color: var(--accent); font-variant-numeric: tabular-nums; }
.score-row .rank { width: 18px; color: var(--muted); font-size: 11.5px; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.stat-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
}
.stat-box .k { font-size: 10.5px; color: var(--muted); }
.stat-box .v { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }

.hint {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.65;
  margin: 6px 0 0;
}
.hint b { color: var(--text-2); font-weight: 600; }
kbd {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 4px;
  font-size: 10.5px;
  font-family: inherit;
}

.btn-row { display: flex; gap: 6px; }
.btn-row > * { flex: 1; min-width: 0; }

/* ------------------------------------------------------------------ 弹层 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 30, .48);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.overlay.hidden { display: none; }

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(2, 8, 23, .3);
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(5px); } }

.modal-head {
  padding: 15px 18px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 650; flex: 1; }
.modal-body { padding: 0 18px 16px; overflow: auto; }
.modal-foot {
  padding: 0 18px 16px;
  display: flex;
  gap: 8px;
}
.modal-foot > * { flex: 1; }

.modal .field { margin-bottom: 11px; }
.modal .field label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 5px;
  font-weight: 500;
}

/* 登录页 */
#loginMask .modal { max-width: 380px; }
#loginMask .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 26px 0 4px;
}
#loginMask .brand .mark {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(140deg, #2563eb, #7c3aed);
  display: grid; place-items: center;
  font-size: 24px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(37, 99, 235, .35);
}
#loginMask .brand h2 { margin: 6px 0 0; font-size: 18px; font-weight: 680; }
#loginMask .brand p { margin: 0; font-size: 12.5px; color: var(--muted); }

.form-err {
  color: var(--err);
  font-size: 12.5px;
  min-height: 19px;
  margin: 2px 0 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 表情选择器 */
.picker {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  width: 292px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(2, 8, 23, .18);
  padding: 8px;
  grid-template-columns: repeat(9, 1fr);
  gap: 2px;
  z-index: 20;
}
.picker.show { display: grid; }
.picker button {
  border: none;
  background: transparent;
  font-size: 19px;
  padding: 4px 0;
  border-radius: 7px;
  line-height: 1.35;
}
.picker button:hover { background: var(--accent-soft); transform: scale(1.12); }

.composer { position: relative; }

/* 灯箱 */
#lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

/* 搜索结果 */
.search-item {
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.search-item:hover { background: var(--accent-soft); }
.search-item .s-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.search-item mark { background: color-mix(in srgb, var(--warn) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Toast */
#toasts {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  font-size: 12.5px;
  padding: 8px 15px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(2, 8, 23, .22);
  animation: toastIn .2s ease-out;
  max-width: 70vw;
  text-align: center;
}
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* 高亮闪烁（跳转到某条消息） */
@keyframes flash { 0%, 100% { background: transparent; } 30% { background: color-mix(in srgb, var(--warn) 22%, transparent); } }
.msg-row.flash .bubble { animation: flash 1.4s ease-out; }

/* 响应式 */
/* 抽屉按钮：桌面不显示，窄屏才出现 */
.drawer-btn { display: none; position: relative; }

/* 红点：侧栏里来了新东西，但入口本身是收起的 —— 给个提示点 */
.drawer-btn .dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--err);
  box-shadow: 0 0 0 2px var(--bg);
  pointer-events: none;
}
.drawer-btn .dot.hidden { display: none; }

/* 窄屏抽屉的遮罩：点一下就收起滑出的侧栏 */
.drawer-mask {
  position: fixed;
  left: 0; right: 0; top: 56px; bottom: 0;
  background: rgba(15, 23, 42, .34);
  z-index: 65;
}
.drawer-mask.hidden { display: none; }

/* 右栏塞了抢答 / 投票 / 服务端指标 / 演示工具四块。
   小屏上放不下时让它整体滚动，而不是被 .panel 的 overflow:hidden 裁掉。 */
#right-panel { overflow-y: auto; }

/* ≤1080：右栏（抢答 / 投票）改成从右侧滑出的抽屉。
   这里以前直接 display:none —— 结果平板和手机上抢答、投票彻底没了入口。 */
@media (max-width: 1080px) {
  main { grid-template-columns: 210px minmax(0, 1fr); }

  #right-panel {
    position: fixed;
    top: 56px; right: 0; bottom: 0;
    width: min(88vw, 340px);
    z-index: 70;
    transform: translateX(102%);
    transition: transform .22s ease;
    border-radius: 0;
    box-shadow: -10px 0 28px rgba(15, 23, 42, .16);
  }
  body.drawer-right #right-panel { transform: none; }
  #btnDrawerRight { display: inline-flex; }
}

/* ≤760：左栏（会话 / 房间 / 在线用户）也改成抽屉。
   以前这里 display:none，手机上就再也进不去私聊界面 ——
   私信其实早就收到了，只是没有任何入口能把它打开。 */
@media (max-width: 760px) {
  main {
    grid-template-columns: 1fr;
    padding: 0; gap: 0;
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
  }

  #left-panel {
    position: fixed;
    top: 56px; left: 0; bottom: 0;
    width: min(88vw, 320px);
    z-index: 70;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 10px 0 28px rgba(15, 23, 42, .16);
  }
  body.drawer-left #left-panel { transform: none; }
  #btnDrawerLeft { display: inline-flex; }

  .panel { border-radius: 0; border-left: none; border-right: none; }
  .msg-main { max-width: 84%; }
  header { padding: 0 10px; gap: 8px; }
  .logo span.t { display: none; }
}

/* =========================================================================
   会话列表：公共频道 + 每个私聊对象
   私聊是独立界面，这里就是它的入口。未读角标按会话分别计。
   ========================================================================= */
.conv-list { list-style: none; margin: 0; padding: 6px; }

.conv-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.conv-item:hover { background: var(--panel-2); }
.conv-item.active { background: var(--accent-soft); }
.conv-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 7px; bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.conv-ico {
  width: 28px; height: 28px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 14px;
  background: var(--panel-2);
  flex: none;
}
.conv-item.active .conv-ico { background: color-mix(in srgb, var(--accent) 18%, transparent); }

.conv-main { flex: 1; min-width: 0; }
.conv-nm {
  font-size: 13px;
  font-weight: 550;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-last {
  font-size: 12px;
  color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 1px;
}
.conv-item.active .conv-nm { color: var(--accent); }

/* 通话按钮：只在私聊视图出现 */
.call-btn { font-size: 15px; }
.call-btn:hover { background: var(--accent-soft); }

/* 选人列表 */
.pick-list { margin-top: 10px; max-height: 46vh; overflow: auto; }
.pick-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 9px; cursor: pointer; font-size: 13.5px;
}
.pick-row:hover { background: var(--panel-2); }
.pick-row .st { margin-left: auto; font-size: 11px; color: var(--muted); }

/* =========================================================================
   音视频通话浮层
   ========================================================================= */
#callMask { background: rgba(2, 8, 23, .82); backdrop-filter: blur(6px); }

.call-card {
  width: min(720px, 92vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

.call-videos {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #0b1220;
  display: grid;
  place-items: center;
}
.call-videos video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
/* 视频通话时把远端铺满，本地缩到右下角画中画 */
.call-videos.video #remoteVideo { display: block; }
.call-videos.video #localVideo {
  display: block;
  position: absolute;
  right: 12px; bottom: 12px;
  width: 26%; height: 30%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .25);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.call-videos.video .call-avatar { display: none; }

.call-avatar {
  width: 96px; height: 96px;
  border-radius: 28px;
  display: grid; place-items: center;
  font-size: 34px; font-weight: 700; color: #fff;
  animation: ringPulse 1.6s ease-in-out infinite;
}
@keyframes ringPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 99, 235, .45); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 18px rgba(37, 99, 235, 0); }
}

.call-info { padding: 14px 18px 4px; text-align: center; }
.call-peer { font-size: 16px; font-weight: 650; }
.call-state { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.call-actions {
  display: flex; justify-content: center; gap: 14px;
  padding: 14px 18px 20px;
}
.round {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 18px;
  cursor: pointer;
  transition: transform .1s, background .12s;
}
.round:hover { transform: translateY(-1px); background: var(--line-soft); }
.round.danger { background: var(--err); border-color: var(--err); color: #fff; }
.round.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.round.off { opacity: .45; }

/* 私聊气泡配色（与房间消息区分开）
   ⚠️ 这里必须排除自己的消息（:not(.self)）。
   这两个选择器带了 id，优先级 (1,2,0) 高于 `.msg-row.self .bubble` 的 (0,2,0)：
   一旦不加 :not(.self)，自己的气泡底色会被改成「主色 6% 混白」的近白色，
   而文字仍是白色 —— 白字压白底，一个字都看不清。
   这就是「电脑上字很淡、是白色的」的真凶。 */
#logDm .msg-row:not(.self) .bubble {
  background: color-mix(in srgb, var(--dm) 10%, var(--panel));
  border-color: color-mix(in srgb, var(--dm) 32%, var(--line));
}
/* 公共频道气泡配色（同样只给对方的气泡上色） */
#logPublic .msg-row:not(.self) .bubble {
  background: color-mix(in srgb, var(--accent) 6%, var(--panel));
}

/* 双保险：自己的气泡无论在哪个会话里都保持主色 + 白字 */
#log .msg-row.self .bubble,
#logPublic .msg-row.self .bubble,
#logDm .msg-row.self .bubble {
  background: var(--bubble-self);
  color: var(--bubble-self-text);
  border-color: transparent;
}

/* 敏感词过滤提示 */
.censor-tip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 5px;
  font-size: 11px;
  color: var(--warn);
}
