/* ============================================================
   ChatStream · 样式
   深色侧栏 + 浅色会话区的私聊风格
   ============================================================ */

:root {
  --side-bg: #0e1621;
  --side-bg-soft: #16212e;
  --side-line: #223042;
  --side-text: #c8d5e3;
  --side-text-dim: #7a8b9e;
  --chat-bg: #f2f5f9;
  --card: #ffffff;
  --line: #e3e9f1;
  --text: #1e2635;
  --text-dim: #6b7a90;
  --accent: #2563eb;
  --accent-soft: #e8f0ff;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(21, 36, 55, .06), 0 2px 8px rgba(21, 36, 55, .05);
  --shadow-md: 0 12px 32px rgba(15, 25, 40, .16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--chat-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--text-dim); }
button { font-family: inherit; }

/* ---------------- 启动遮罩 ---------------- */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--side-bg);
  color: var(--side-text);
  font-size: 14px;
  letter-spacing: .12em;
  z-index: 90;
}

/* ---------------- 登录 / 注册 ---------------- */

.auth-view {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 620px at 12% -10%, #1c3d6b 0%, transparent 58%),
    radial-gradient(900px 520px at 105% 110%, #12324f 0%, transparent 55%),
    var(--side-bg);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 20px;
  padding: 30px 30px 24px;
  box-shadow: var(--shadow-md);
  animation: rise .32s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.auth-brand { text-align: center; margin-bottom: 20px; }

.logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 19px;
  color: #fff;
  background: linear-gradient(135deg, #4f8ef7, #2563eb);
  box-shadow: 0 8px 20px rgba(37, 99, 235, .32);
}

.logo.sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 12px;
  margin: 0;
  box-shadow: none;
}

.auth-brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: .01em;
}

.auth-brand .muted {
  margin: 6px 0 0;
  font-size: 12.5px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #f0f3f8;
  border-radius: 12px;
  margin-bottom: 18px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--text-dim);
  border-radius: 9px;
  cursor: pointer;
  transition: .18s;
}

.tab.active {
  background: #fff;
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.form { display: grid; gap: 13px; }

.form label {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 500;
}

.form input {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: .16s;
  font-family: inherit;
}

.form input:focus {
  border-color: #a9c4f5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.primary {
  border: 0;
  border-radius: 11px;
  padding: 12px 18px;
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  cursor: pointer;
  transition: .16s;
}

.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px); }
.primary[disabled] { opacity: .6; cursor: not-allowed; }

.auth-error {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #dc2626;
  text-align: center;
}

/* ---------------- 主框架 ---------------- */

.app-view {
  display: flex;
  height: 100%;
  height: 100dvh;
}

/* ---------------- 侧栏 ---------------- */

.sidebar {
  width: 286px;
  flex: 0 0 286px;
  background: var(--side-bg);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 15px;
  color: #eaf2fb;
}

.me {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 4px 12px 10px;
  padding: 10px;
  background: var(--side-bg-soft);
  border-radius: 13px;
}

.me-meta { flex: 1; min-width: 0; }

.me-name {
  font-size: 14px;
  font-weight: 600;
  color: #f0f6fd;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-status {
  font-size: 11.5px;
  color: #4ade80;
  margin-top: 2px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #24374d;
  flex: 0 0 auto;
}

.avatar.lg { width: 40px; height: 40px; }
.avatar.sm { width: 26px; height: 26px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--side-text-dim);
  width: 30px;
  height: 30px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: .16s;
}

.icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 10px;
}

.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb {
  background: #23324a;
  border-radius: 8px;
}

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 6px 6px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--side-text-dim);
}

.mini {
  border: 1px solid var(--side-line);
  background: rgba(255, 255, 255, .03);
  color: var(--side-text);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: .16s;
}

.mini:hover { background: rgba(255, 255, 255, .1); border-color: #34506f; }
.mini.wide { flex: 1; padding: 8px 10px; }
.chat .mini { border-color: var(--line); color: var(--text-dim); background: #fff; }
.chat .mini:hover { color: var(--accent); border-color: #b9cef3; background: #f7faff; }

.topic { margin-bottom: 2px; }

.topic-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #dbe6f2;
  transition: .14s;
}

.topic-row:hover { background: rgba(255, 255, 255, .05); }

.topic-arrow {
  font-size: 10px;
  color: var(--side-text-dim);
  transition: transform .18s;
  width: 12px;
  text-align: center;
}

.topic.open .topic-arrow { transform: rotate(90deg); }

.topic-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.badge {
  min-width: 19px;
  height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.subs { display: none; margin: 2px 0 6px 14px; }
.topic.open .subs { display: block; }

.sub-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 13.2px;
  color: #b7c6d8;
  cursor: pointer;
  transition: .14s;
}

.sub-row:hover { background: rgba(255, 255, 255, .05); color: #eaf2fb; }

.sub-row.active {
  background: linear-gradient(90deg, rgba(59, 130, 246, .28), rgba(59, 130, 246, .12));
  color: #fff;
  font-weight: 600;
}

.sub-row::before {
  content: "#";
  color: var(--side-text-dim);
  font-size: 12px;
}

.sub-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sub-empty {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--side-text-dim);
}

/* 话题行 / 子话题行尾的管理按钮，悬停才显形 */
.row-more {
  opacity: 0;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--side-text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 1px 5px 3px;
  border-radius: 6px;
  cursor: pointer;
  transition: .14s;
}

.topic-row:hover .row-more,
.sub-row:hover .row-more { opacity: 1; }

.row-more:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* 浮动管理菜单 */
.ctx-menu {
  position: fixed;
  z-index: 70;
  min-width: 158px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 5px;
  box-shadow: var(--shadow-md);
  animation: fade .12s ease;
}

.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 11px;
  font-size: 13.2px;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: .12s;
}

.ctx-menu button:hover { background: #f1f5f9; }
.ctx-menu button.danger { color: #dc2626; }
.ctx-menu button.danger:hover { background: #fef2f2; }

.members { display: grid; gap: 2px; }

.member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 9px;
  font-size: 13px;
  color: #c2d0e0;
}

.member .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #46586d;
  flex: 0 0 auto;
}

.member.online .dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }
.member span.nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .role {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(59, 130, 246, .18);
  color: #8ab4f8;
}

.side-foot {
  display: flex;
  gap: 8px;
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .05);
}

/* ---------------- 会话区 ---------------- */

.chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  position: relative;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.chat-head-main { flex: 1; min-width: 0; }

.chat-title {
  font-size: 15.5px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msgs {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

.msgs::-webkit-scrollbar { width: 10px; }
.msgs::-webkit-scrollbar-thumb {
  background: #ccd6e3;
  border-radius: 10px;
  border: 3px solid var(--chat-bg);
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-dim);
}

.empty-logo {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #e6ecf5;
  color: #93a5bb;
  font-weight: 700;
  font-size: 20px;
}

.day-divider {
  text-align: center;
  margin: 16px 0 10px;
  font-size: 11.5px;
  color: var(--text-dim);
}

.day-divider span {
  background: #e7edf5;
  padding: 3px 12px;
  border-radius: 20px;
}

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-top: 10px;
  animation: pop .18s ease;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg.self { flex-direction: row-reverse; }

.msg .body { max-width: min(560px, 72%); display: grid; gap: 4px; }
.msg.self .body { justify-items: end; }

.msg .meta {
  font-size: 11.5px;
  color: var(--text-dim);
  padding: 0 6px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 14px;
  padding: 9px 13px;
  font-size: 14.5px;
  line-height: 1.58;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: var(--shadow-sm);
}

.msg.self .bubble {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: transparent;
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}

.bubble.media {
  padding: 5px;
  background: var(--card);
  overflow: hidden;
}

.msg.self .bubble.media {
  background: #dbe7fb;
  border-color: transparent;
}

.bubble img,
.bubble video {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: 11px;
  cursor: zoom-in;
  background: #0b1220;
}

.bubble video { cursor: default; }

.caption {
  padding: 7px 9px 4px;
  font-size: 13.6px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.msg.self .caption { color: #f2f7ff; }

.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  min-width: 200px;
  text-decoration: none;
  color: inherit;
}

.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 16px;
  flex: 0 0 auto;
}

.msg.self .file-icon { background: rgba(255, 255, 255, .22); color: #fff; }

.file-info { min-width: 0; }

.file-name {
  font-size: 13.6px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 250px;
}

.file-size { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.msg.self .file-size { color: rgba(255, 255, 255, .78); }

.typing {
  min-height: 20px;
  padding: 0 24px 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}

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

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 16px 16px;
  margin: 0 4px;
}

.composer-tools { display: flex; padding-bottom: 6px; }
.chat .composer-tools .icon-btn:hover { background: #e8eef7; color: var(--accent); }

#input {
  flex: 1;
  min-height: 44px;
  max-height: 168px;
  resize: none;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 13px;
  padding: 12px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: .16s;
  box-shadow: var(--shadow-sm);
}

#input:focus { border-color: #b4cbf3; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }

.send {
  height: 44px;
  padding: 0 22px;
  border-radius: 13px;
}

.attach {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 6px 10px;
  margin-bottom: 4px;
  font-size: 12.5px;
  max-width: 240px;
  box-shadow: var(--shadow-sm);
}

.attach img { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; }
.attach .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach button { border: 0; background: transparent; cursor: pointer; color: var(--text-dim); font-size: 15px; }

.upload-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.upload-bar .bar {
  flex: 1;
  height: 5px;
  background: #dde5ef;
  border-radius: 4px;
  overflow: hidden;
}

.upload-bar .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width .2s;
}

/* ---------------- 弹窗 ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 28, .5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 60;
  animation: fade .16s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(460px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-md);
}

.modal-card h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.modal-card .hint {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
}

.modal-card label {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.modal-card input,
.modal-card textarea {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--text);
  background: #fbfcfe;
}

.modal-card input:focus,
.modal-card textarea:focus { border-color: #a9c4f5; background: #fff; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.modal-actions .ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-dim);
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
}

.danger {
  border: 0;
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #f05252, #dc2626);
  cursor: pointer;
  transition: .16s;
}

.danger:hover { filter: brightness(1.05); }
.danger[disabled] { opacity: .6; cursor: not-allowed; }

.modal-error { color: #dc2626; font-size: 12.5px; min-height: 16px; margin: 4px 0 0; }

.avatar-editor { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar-editor img { width: 62px; height: 62px; border-radius: 50%; object-fit: cover; background: #eef2f8; }

.code-list { display: grid; gap: 8px; margin-top: 12px; max-height: 260px; overflow-y: auto; }

.code-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  background: #fbfcfe;
}

.code-item code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: .06em;
  color: var(--accent);
  font-weight: 600;
}

.code-item .state { font-size: 11.5px; color: var(--text-dim); margin-left: auto; }
.code-item.used { opacity: .55; }

/* ---------------- 提示 / 图片预览 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  background: rgba(20, 30, 44, .93);
  color: #fff;
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 95;
  max-width: 80vw;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, .92);
  display: grid;
  place-items: center;
  z-index: 80;
  cursor: zoom-out;
  padding: 24px;
}

.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; }

.only-mobile { display: none; }

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

@media (max-width: 820px) {
  .only-mobile { display: grid; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-102%);
    transition: transform .24s ease;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: none; }

  .msg .body { max-width: 84%; }
  .composer { padding: 8px 10px 12px; }
  .msgs { padding: 14px 12px 6px; }
  .chat-head { padding: 11px 14px; }
  .chat-act .act-label { display: none; }
  .chat-act { padding: 0 9px; }
}

/* ============================================================
   附件缩略卡：固定尺寸，不再按原图撑开消息流
   ============================================================ */

.bubble.media {
  padding: 4px;
  width: fit-content;
  max-width: 100%;
}

.thumb {
  position: relative;
  display: block;
  width: 240px;
  padding: 0;
  border: 0;
  border-radius: 11px;
  overflow: hidden;
  background: #0b1220;
  line-height: 0;
  cursor: zoom-in;
  transition: box-shadow .16s;
}

.thumb-image { height: 180px; }
.thumb-video { height: 135px; cursor: pointer; }

/* 覆盖 .bubble img / .bubble video 的「按原图展示」规则 */
.thumb img,
.thumb video {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 0;
  background: transparent;
  cursor: inherit;
}

.thumb:hover { box-shadow: 0 0 0 2px rgba(37, 99, 235, .42); }

.thumb-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 8px 7px;
  background: linear-gradient(transparent, rgba(8, 12, 20, .78));
  color: #fff;
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  transition: .16s;
  pointer-events: none;
}

.thumb:hover .thumb-hint { opacity: 1; }

.thumb-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #fff;
  background: rgba(8, 12, 20, .3);
  transition: .16s;
  pointer-events: none;
}

.thumb-video:hover .thumb-play { background: rgba(8, 12, 20, .45); }

.thumb-badge {
  position: absolute;
  right: 6px;
  top: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(8, 12, 20, .62);
  color: #fff;
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: .02em;
  pointer-events: none;
}

.thumb-badge:empty { display: none; }

/* 文件卡片：固定宽度，长文件名省略 */
.bubble.media .file-card {
  width: 240px;
  max-width: 100%;
  min-width: 0;
  padding: 9px 11px;
  box-sizing: border-box;
}

.bubble.media .file-info { min-width: 0; flex: 1; }
.bubble.media .file-name { max-width: 100%; }

.file-dl {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-size: 15px;
}

.msg.self .file-dl { color: rgba(255, 255, 255, .85); }

/* ---------------- 全屏预览 ---------------- */

.lightbox {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}

.lightbox img,
.lightbox video {
  max-width: min(92vw, 1280px);
  max-height: 76vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

.lightbox-bar { display: flex; gap: 10px; }

.lightbox-bar a,
.lightbox-bar button {
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: .16s;
}

.lightbox-bar a:hover,
.lightbox-bar button:hover { background: rgba(255, 255, 255, .2); }

/* ============================================================
   消息操作 / 搜索 / 附件 / 拖拽
   ============================================================ */

.chat { position: relative; }

/* ---------------- 搜索 ---------------- */

/* ---------------- 顶栏操作按钮 ---------------- */

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.chat-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}

.chat-act:hover { color: var(--accent); border-color: #b9cef3; background: #f7faff; }
.chat-act .act-icon { font-size: 12px; line-height: 1; }

/* 顶栏按钮统一尺寸，避免高度参差 */
.chat-actions .mini,
.chat-actions .chat-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* ---------------- 搜索命令面板 ---------------- */

.cmd-modal {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 11vh 16px 16px;
  background: rgba(8, 12, 20, .48);
  backdrop-filter: blur(2px);
  animation: cmdFade .14s ease;
}

.cmd-box {
  width: min(660px, 100%);
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(9, 17, 30, .3);
  overflow: hidden;
  animation: cmdRise .18s ease;
}

@keyframes cmdFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cmdRise {
  from { opacity: 0; transform: translateY(-10px) scale(.99); }
  to { opacity: 1; transform: none; }
}

/* 图标 / 输入框 / 关闭按钮：统一 30px 行高垂直居中 */
.cmd-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 52px;
  padding: 0 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.cmd-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-dim);
}

.cmd-head input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
}

.cmd-head input::placeholder { color: #9aa7b8; }

.cmd-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: .15s;
}

.cmd-close:hover { background: #eef2f8; color: var(--text); }

.cmd-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}

.cmd-tip { padding: 14px 12px; font-size: 12.5px; color: var(--text-dim); }

/* 结果行：来源 / 内容 / 时间三段，全部 nowrap + 省略号 */
.cmd-hit {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
}

.cmd-hit:hover,
.cmd-hit.active { background: #f1f5f9; }

/* 第一行：来源 + 时间 */
.cmd-hit .hit-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-bottom: 3px;
}

.cmd-hit .hit-src {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-hit time {
  flex: 0 0 auto;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* 第二行：正文，最多两行，超出省略 */
.cmd-hit .hit-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
}

.cmd-hit .hit-text b {
  font-weight: 600;
  color: var(--text-dim);
}

.cmd-hit mark { background: #fff3bf; color: #8a6d00; padding: 0 1px; border-radius: 2px; }

.cmd-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-dim);
}

.cmd-foot .dot { margin: 0 3px; }

.cmd-foot kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #f8fafc;
  font-family: inherit;
  font-size: 10.5px;
  text-align: center;
}

/* ---------------- 编辑提示条 ---------------- */

.edit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 6px;
  padding: 7px 12px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--accent);
}

.edit-bar .edit-label { flex: 1; }
.edit-bar .mini { background: #fff; }

/* ---------------- 输入区：一个 ＋ 号 ---------------- */

.composer-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.plus-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-dim);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: .15s;
}

.plus-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.attach-list { display: flex; flex-wrap: wrap; gap: 6px; }

.attach-item {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 4px 6px 4px 4px;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 12.5px;
}

.attach-item img { width: 30px; height: 30px; object-fit: cover; border-radius: 6px; }
.attach-kind { width: 30px; text-align: center; font-size: 16px; }
.attach-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attach-remove {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 5px;
}

.attach-remove:hover { background: #e2e8f0; color: #dc2626; }

/* ---------------- 拖拽遮罩 ---------------- */

.drop-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(37, 99, 235, .12);
  border: 3px dashed rgba(37, 99, 235, .55);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.drop-inner {
  background: var(--accent);
  color: #fff;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
}

/* ---------------- 消息操作 ---------------- */

.msg { position: relative; }

.act-more {
  position: absolute;
  top: 2px;
  right: 2px;
  opacity: 0;
  border: 0;
  background: #eef2f8;
  color: var(--text-dim);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: .14s;
}

.msg.self .act-more { right: auto; left: 2px; }

.msg:hover .act-more { opacity: 1; }
.act-more:hover { background: #dbe4f0; color: var(--text); }

.bubble.deleted {
  background: transparent !important;
  border: 1px dashed var(--line) !important;
  color: var(--text-dim) !important;
  font-size: 12.5px;
  font-style: italic;
  padding: 5px 12px;
}

.msg.is-deleted .avatar { opacity: .5; }

.edited-tag {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.bubble.media { position: relative; }

.media-dl {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, .62);
  color: #fff;
  border-radius: 7px;
  font-size: 13px;
  text-decoration: none;
  opacity: 0;
  transition: .15s;
}

.bubble.media:hover .media-dl { opacity: 1; }
.media-dl:hover { background: rgba(15, 23, 42, .85); }

/* 搜索跳转后的闪烁高亮 */
.msg.highlight .bubble {
  animation: hit-flash 2.2s ease;
}

@keyframes hit-flash {
  0%, 100% { box-shadow: none; }
  15%, 55% { box-shadow: 0 0 0 3px rgba(37, 99, 235, .35); }
}

/* ============================================================
   搜索命令面板 · 响应式
   窄屏按「时间 → 来源」的顺序依次隐藏，正文始终保留可读宽度
   ============================================================ */

@media (max-width: 640px) {
  .cmd-modal { padding: 7vh 10px 10px; }
  .cmd-box { max-height: 80vh; border-radius: 12px; }

  .cmd-head {
    height: 46px;
    padding: 0 6px 0 12px;
    gap: 8px;
  }

  .cmd-head input { font-size: 14px; }

  .cmd-hit { padding: 9px 10px; }
  /* 窄屏：来源独占一行已够用，时间让位给正文 */
  .cmd-hit time { display: none; }
  .cmd-hit .hit-text { -webkit-line-clamp: 3; }
  .cmd-foot { display: none; }
}

/* 视口过矮时（横屏手机）收紧上下留白，保证列表可用高度 */
@media (max-height: 520px) {
  .cmd-modal { padding-top: 3vh; }
  .cmd-box { max-height: 90vh; }
}
