/* ==========================================================================
   汐语 · 白蓝极简聊天室
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f5f8ff;
  --bg-deep: #eaf1ff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #f1f6ff;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e8eef7;
  --line-strong: #d5dfee;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-deep: #1e3a8a;
  --blue-soft: #eff6ff;
  --blue-softer: #f6f9ff;
  --sky: #0ea5e9;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(37, 99, 235, 0.08);
  --shadow-lg: 0 30px 80px rgba(15, 23, 42, 0.14);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;
  --font: "Inter", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", monospace;
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 48% 45% at 8% 0%, rgba(191, 219, 254, 0.46), transparent 68%),
    radial-gradient(ellipse 42% 44% at 100% 100%, rgba(224, 242, 254, 0.7), transparent 72%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
a { color: var(--blue); }

::selection { background: #dbeafe; color: var(--blue-deep); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon .fill, .icon.fill { fill: currentColor; stroke: none; }

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   通用
   -------------------------------------------------------------------------- */

.eyebrow {
  margin: 0 0 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--blue);
  text-transform: uppercase;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: none;
  background: linear-gradient(145deg, var(--blue) 0%, var(--sky) 100%);
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.22);
}
.logo-mark span { transform: translateY(-1px); }
.logo-mark.large { width: 68px; height: 68px; border-radius: 21px; font-size: 31px; }
.logo-mark.small { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-copy { display: flex; flex-direction: column; gap: 3px; line-height: 1; }
.brand-copy strong { font-size: 19px; font-weight: 700; letter-spacing: 0.04em; }
.brand-copy small { font-size: 8px; color: var(--muted-light); letter-spacing: 0.22em; font-weight: 600; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  transition: background 0.16s, color 0.16s, border-color 0.16s;
}
.icon-btn:hover { background: var(--surface-blue); color: var(--ink); }
.icon-btn:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.primary-btn {
  border: none;
  border-radius: 11px;
  padding: 11px 18px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.18);
  transition: background 0.16s, transform 0.16s, box-shadow 0.16s;
}
.primary-btn:hover { background: var(--blue-dark); transform: translateY(-1px); box-shadow: 0 8px 22px rgba(37, 99, 235, 0.24); }
.primary-btn:active { transform: translateY(0); }
.primary-btn:disabled { opacity: 0.55; transform: none; box-shadow: none; }
.primary-btn.full { width: 100%; }

.secondary-btn {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.16s, border-color 0.16s;
}
.secondary-btn:hover { background: var(--surface-blue); border-color: #bfdbfe; }
.secondary-btn .icon { width: 15px; height: 15px; }

.danger-btn {
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 9px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.16s;
}
.danger-btn:hover { background: #fee2e2; }

.text-btn {
  border: none;
  background: transparent;
  padding: 7px 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.text-btn:hover { color: var(--ink); }
.danger-text { color: var(--danger); }
.danger-text:hover { color: var(--danger); }

.text-link {
  border: none;
  background: transparent;
  color: var(--blue);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
}
.text-link:hover { color: var(--blue-dark); text-decoration: underline; text-underline-offset: 3px; }
.text-link .icon { width: 13px; height: 13px; }

.avatar {
  --avatar: #3b82f6;
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 11px;
  font-size: 18px;
  line-height: 1;
  background: #f0f7ff;
  background: color-mix(in srgb, var(--avatar) 12%, #ffffff);
  border: 1px solid #dbeafe;
  border-color: color-mix(in srgb, var(--avatar) 24%, #dbeafe);
  color: var(--ink);
  user-select: none;
}
.avatar.large { width: 58px; height: 58px; border-radius: 17px; font-size: 28px; }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 14px; }

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

/* --------------------------------------------------------------------------
   Boot / Auth
   -------------------------------------------------------------------------- */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}
.boot-screen .logo-mark { animation: float 2.4s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-shell {
  width: min(1120px, 100%);
  min-height: min(720px, calc(100dvh - 48px));
  max-height: calc(100dvh - 48px);
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  background: var(--surface);
  border: 1px solid rgba(219, 234, 254, 0.9);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 42px 48px 36px;
  overflow: hidden;
  background:
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.85), transparent 36%),
    radial-gradient(circle at 12% 92%, rgba(186, 230, 253, 0.8), transparent 40%),
    linear-gradient(155deg, #eff6ff 0%, #dbeafe 52%, #e0f2fe 100%);
  color: var(--blue-deep);
}

.auth-brand::before {
  content: "";
  position: absolute;
  width: 430px;
  height: 430px;
  border-radius: 50%;
  border: 1px solid rgba(37, 99, 235, 0.13);
  right: -190px;
  top: -160px;
}
.auth-brand::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  border: 1px solid rgba(14, 165, 233, 0.16);
  right: -100px;
  top: -65px;
}

.brand-on-light { position: relative; z-index: 1; }
.brand-on-light .brand-copy small { color: #64748b; }

.auth-copy { position: relative; z-index: 1; margin-top: auto; padding-top: 54px; }
.auth-copy .eyebrow { color: var(--blue); }
.auth-copy h1 {
  margin: 0 0 16px;
  font-size: clamp(31px, 4vw, 46px);
  line-height: 1.22;
  letter-spacing: -0.045em;
  font-weight: 720;
  color: #172554;
}
.auth-copy > p:last-child {
  margin: 0;
  max-width: 390px;
  font-size: 13px;
  line-height: 1.85;
  color: #475569;
}

.auth-mock {
  position: relative;
  z-index: 1;
  margin: 28px 0 26px;
  min-height: 122px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.mock-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 14px 14px 14px 4px;
  color: #334155;
  font-size: 12px;
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.08);
}
.mock-bubble.mock-b { margin-left: 36px; border-radius: 14px 14px 4px 14px; background: #2563eb; color: #fff; border-color: #2563eb; }
.mock-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sky);
}
.mock-b .mock-dot { background: #bfdbfe; }
.mock-typing {
  display: inline-flex;
  gap: 3px;
  margin-left: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}
.mock-typing i { width: 4px; height: 4px; border-radius: 50%; background: #93c5fd; animation: blink 1.2s infinite; }
.mock-typing i:nth-child(2) { animation-delay: 0.15s; }
.mock-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 70%, 100% { opacity: 0.35; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-3px); } }

.auth-points {
  position: relative;
  z-index: 1;
  margin: auto 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 10.5px;
  color: #64748b;
}
.auth-points li { display: inline-flex; align-items: center; gap: 6px; }
.auth-points li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--blue); opacity: 0.7; }

.auth-panel {
  display: flex;
  flex-direction: column;
  padding: 38px 46px 30px;
  min-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
}

.auth-mobile-brand { display: none; }
.auth-tabs {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  margin-bottom: 30px;
}
.auth-tabs button {
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 7px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.16s, color 0.16s, box-shadow 0.16s;
}
.auth-tabs button.active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow-sm); }

.auth-form { width: 100%; max-width: 420px; margin: 0 auto; }
.auth-form h2 { margin: 0 0 8px; font-size: 29px; line-height: 1.2; letter-spacing: -0.035em; font-weight: 700; }
.auth-lead { margin: 0 0 24px; color: var(--muted); font-size: 12px; line-height: 1.75; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span, .field > label { font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.field > span small { color: var(--muted-light); font-weight: 400; margin-left: 4px; }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--ink);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted-light); }
.field input:disabled { background: var(--surface-soft); color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 48px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 10px;
  color: var(--muted);
  padding: 5px;
}
.password-toggle:hover { color: var(--blue); }

.auth-submit { width: 100%; padding: 12px; margin-top: 6px; }
.auth-note { margin: 14px 0 0; font-size: 9.5px; line-height: 1.6; color: var(--muted-light); text-align: center; }

.form-error {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.5;
}

.avatar-picker { display: flex; flex-wrap: wrap; gap: 4px; }
.avatar-picker button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
  font-size: 16px;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.avatar-picker button:hover { background: var(--surface-blue); transform: translateY(-1px); }
.avatar-picker button.selected { background: var(--blue-soft); border-color: #bfdbfe; }
.avatar-picker.compact button { width: 31px; height: 31px; font-size: 15px; }

.color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-picker button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch);
  transition: transform 0.15s, box-shadow 0.15s;
}
.color-picker button:hover { transform: scale(1.12); }
.color-picker button.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--swatch); }

/* --------------------------------------------------------------------------
   应用外壳
   -------------------------------------------------------------------------- */

.app-shell {
  position: relative;
  height: calc(100dvh - 24px);
  max-width: 1600px;
  margin: 12px auto;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(30, 64, 175, 0.09);
  isolation: isolate;
}

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

.sidebar-head {
  height: 76px;
  flex: none;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.sidebar-close { display: none; }

.quick-actions {
  display: flex;
  gap: 6px;
  padding: 14px 14px 8px;
}
.quick-btn {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 8px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}
.quick-btn .icon { width: 14px; height: 14px; color: var(--blue); }
.quick-btn:hover { background: var(--blue-soft); border-color: #bfdbfe; color: var(--blue-dark); }

.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 12px; scrollbar-width: thin; }
.sidebar-scroll::-webkit-scrollbar { width: 5px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.conv-section { padding-top: 9px; }
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 5px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted-light);
  text-transform: uppercase;
}
.section-count {
  min-width: 17px;
  height: 16px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--surface-blue);
  color: var(--blue);
  display: inline-grid;
  place-items: center;
  font-size: 9px;
  letter-spacing: 0;
}
.conv-list { display: flex; flex-direction: column; gap: 1px; }

.conv-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  color: var(--ink-soft);
  transition: background 0.15s, border-color 0.15s;
}
.conv-item:hover { background: var(--surface-soft); }
.conv-item.active { background: #edf5ff; border-color: #d6e9ff; color: var(--blue-dark); box-shadow: inset 3px 0 0 var(--blue); }
.conv-item.active .conv-name { color: var(--blue-dark); }
.conv-item.active .conv-preview { color: #7ca7dd; }
.conv-item .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 14px; background: var(--surface-blue); border-color: var(--line); }
.conv-item .conv-symbol {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface-soft);
}
.conv-item.active .conv-symbol { background: #dbeafe; color: var(--blue); }
.conv-symbol .icon { width: 14px; height: 14px; }
.conv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 9.5px; color: var(--muted-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.conv-time { font-size: 8.5px; color: var(--muted-light); }
.unread-badge {
  min-width: 17px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-size: 8.5px;
  font-weight: 700;
}
.conv-empty { padding: 6px 10px 8px; font-size: 10px; color: var(--muted-light); line-height: 1.5; }

.sidebar-foot { flex: none; border-top: 1px solid var(--line); padding: 10px; }
.account-card {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: transparent;
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
}
.account-card:hover { background: var(--surface-soft); }
.account-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.account-copy strong { font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-copy small { font-size: 9px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.account-card > .icon { width: 15px; height: 15px; color: var(--muted-light); }

.admin-entry {
  width: 100%;
  margin-top: 4px;
  border: 1px solid #dbeafe;
  border-radius: 9px;
  background: var(--blue-soft);
  padding: 8px 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 600;
}
.admin-entry:hover { background: #dbeafe; }
.admin-entry .icon { width: 14px; height: 14px; }
.admin-entry-tag { margin-left: auto; font-size: 7.5px; letter-spacing: 0.08em; color: var(--blue); opacity: 0.75; }

.sidebar-mini-actions { display: flex; align-items: center; gap: 3px; padding: 5px 4px 0; }
.mini-btn {
  width: 27px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted-light);
  display: grid;
  place-items: center;
}
.mini-btn:hover { background: var(--surface-blue); color: var(--blue); }
.mini-btn .icon { width: 15px; height: 15px; }
.sound-off { display: none; }
body.muted .sound-on { display: none; }
body.muted .sound-off { display: block; }

.connection-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted-light);
  font-size: 8.5px;
  white-space: nowrap;
}
.connection-pill i { width: 5px; height: 5px; border-radius: 50%; background: var(--amber); }
.connection-pill[data-state="online"] i { background: var(--green); }
.connection-pill[data-state="offline"] i { background: var(--danger); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(2px);
}

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

.chat-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.8), rgba(255, 255, 255, 0.58)),
    var(--surface);
}

.chat-header {
  height: 76px;
  flex: none;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  z-index: 6;
}
.menu-btn { display: none; }
.conv-identity { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.conv-title-row { display: flex; align-items: center; gap: 7px; min-width: 0; }
.conv-emoji { font-size: 18px; flex: none; }
.conv-title-row h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-title-row h1::before { content: ""; }
.type-badge {
  flex: none;
  font-size: 8px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #dbeafe;
  border-radius: 5px;
  padding: 2px 5px;
}
#convTopic {
  margin: 0;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.header-chip {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
}
.header-chip:hover { background: var(--surface-blue); color: var(--blue); }
.header-chip .icon { width: 15px; height: 15px; }

.offline-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 24px;
  background: var(--amber-soft);
  color: #92400e;
  font-size: 10.5px;
  border-bottom: 1px solid #fde68a;
}
.offline-banner button { margin-left: auto; border: none; background: transparent; color: inherit; font-size: 10px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.readonly-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 10.5px;
  border-bottom: 1px solid #dbeafe;
}
.readonly-banner .icon { width: 14px; height: 14px; }

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

.messages-scroll {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.messages-scroll::-webkit-scrollbar { width: 6px; }
.messages-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

.messages-stage {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 32px) 32px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-illustration {
  font-size: 36px;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(145deg, #eff6ff, #e0f2fe);
  margin-bottom: 16px;
}
.empty-chat h2 { margin: 0 0 6px; font-size: 16px; color: var(--ink-soft); }
.empty-chat p { margin: 0; font-size: 11.5px; line-height: 1.7; max-width: 300px; }

.message-list { display: flex; flex-direction: column; gap: 1px; }

.date-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 12px;
  color: var(--muted-light);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.date-divider::before, .date-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.date-divider:first-child { margin-top: 4px; }

.message {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 7px 9px;
  border-radius: 11px;
  transition: background 0.14s;
}
.message:hover { background: rgba(239, 246, 255, 0.56); }
.message.is-mine { background: rgba(239, 246, 255, 0.52); }
.message.is-mine:hover { background: rgba(219, 234, 254, 0.52); }
.message.continuation { padding-top: 2px; padding-bottom: 4px; }
.message.continuation .msg-avatar { visibility: hidden; height: 0; }
.message.continuation .msg-head { display: none; }
.message.continuation .msg-main { padding-top: 0; }
.message.pending { opacity: 0.72; }

.msg-avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; margin-top: 2px; background: var(--surface-blue); border-color: #e0efff; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; min-height: 15px; margin-bottom: 3px; }
.msg-author { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); }
.msg-username { font-size: 8.5px; color: var(--muted-light); }
.msg-time { font-size: 8.5px; color: var(--muted-light); }
.msg-edited { font-size: 8.5px; color: var(--muted-light); font-style: italic; }
.msg-role { font-size: 7.5px; font-weight: 700; color: var(--blue); background: var(--blue-soft); border-radius: 4px; padding: 1px 4px; }
.msg-pending-tag { font-size: 8px; color: var(--muted-light); }
.msg-body { font-size: 13.5px; line-height: 1.7; color: var(--ink); overflow-wrap: anywhere; }
.msg-body code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
}
.msg-body a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.msg-body .mention { color: var(--blue-dark); background: var(--blue-soft); border-radius: 4px; padding: 0 3px; font-weight: 600; }
.msg-body strong { font-weight: 700; }

.reply-quote {
  border: none;
  border-left: 2px solid #bfdbfe;
  background: transparent;
  padding: 1px 0 1px 8px;
  margin: 0 0 4px;
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  cursor: pointer;
}
.reply-quote strong { color: var(--blue); font-weight: 600; flex: none; }
.reply-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-quote .icon { width: 11px; height: 11px; }

.msg-image-btn {
  border: none;
  padding: 0;
  margin-top: 5px;
  display: block;
  max-width: min(320px, 100%);
  border-radius: 11px;
  overflow: hidden;
  background: var(--surface-soft);
  cursor: zoom-in;
}
.msg-image-btn img {
  display: block;
  max-width: 100%;
  max-height: 280px;
  object-fit: cover;
  transition: filter 0.18s;
}
.msg-image-btn:hover img { filter: brightness(0.96); }
.img-fallback { display: grid; place-items: center; width: 210px; height: 100px; color: var(--muted); font-size: 10px; }

.reactions { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 5px; }
.reaction-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 1px 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.5;
}
.reaction-chip:hover { background: var(--surface-blue); border-color: #dbeafe; }
.reaction-chip.mine { background: var(--blue-soft); border-color: #bfdbfe; color: var(--blue-dark); }
.reaction-chip .count { font-size: 8.5px; font-weight: 700; }

.msg-actions {
  position: absolute;
  right: 8px;
  top: -10px;
  display: flex;
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 2px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(2px);
  pointer-events: none;
  transition: opacity 0.14s, transform 0.14s;
  z-index: 3;
}
.message:hover .msg-actions, .message:focus-within .msg-actions { opacity: 1; transform: translateY(0); pointer-events: auto; }
.action-btn {
  width: 25px;
  height: 25px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.action-btn:hover { background: var(--surface-blue); color: var(--blue); }
.action-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.action-btn .icon { width: 13px; height: 13px; }
.action-btn.quick { font-size: 12px; }

.flash { animation: flash 1.1s var(--ease); }
@keyframes flash { 0%, 100% { background: transparent; } 20%, 65% { background: #dbeafe; } }

.load-more {
  order: -1;
  align-self: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 9.5px;
  margin: 0 auto 12px;
}
.load-more:hover { color: var(--blue); border-color: #bfdbfe; }
.load-more.loading { opacity: 0.6; }

.scroll-bottom {
  position: sticky;
  bottom: 16px;
  margin: 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  z-index: 4;
}
.scroll-bottom .icon { width: 15px; height: 15px; }
.scroll-bottom span {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 7.5px;
  display: grid;
  place-items: center;
  border: 1.5px solid #fff;
}

/* --------------------------------------------------------------------------
   成员面板
   -------------------------------------------------------------------------- */

.members-panel {
  width: 258px;
  flex: none;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}
.members-head {
  padding: 21px 18px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.members-head h2 { margin: 0; font-size: 13px; font-weight: 700; }
.members-head h2 span { color: var(--muted); font-weight: 500; margin-left: 2px; font-size: 10px; }
.members-close { display: none; width: 28px; height: 28px; }
.member-list { padding: 0 9px 8px; }
.member-item {
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.member-item:hover { background: var(--surface-blue); }
.member-item .avatar { width: 27px; height: 27px; border-radius: 8px; font-size: 13px; }
.member-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.member-copy strong { font-size: 10.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-copy small { font-size: 8.5px; color: var(--muted-light); }
.member-status { width: 5px; height: 5px; border-radius: 50%; background: var(--green); flex: none; }
.member-me { font-size: 7.5px; color: var(--blue); background: var(--blue-soft); padding: 1px 4px; border-radius: 4px; flex: none; }
.member-empty { padding: 10px 9px; font-size: 10px; color: var(--muted-light); line-height: 1.6; }

.space-card {
  margin: 8px 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  background: var(--surface);
}
.space-card h3 { margin: 0 0 6px; font-size: 11.5px; }
.space-card > p { margin: 0 0 11px; font-size: 10px; line-height: 1.65; color: var(--muted); }
.space-card dl { margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.space-card .text-link + .text-link { margin-top: 8px; }
.space-card dl div { display: flex; justify-content: space-between; font-size: 9px; gap: 8px; }
.space-card dt { color: var(--muted-light); }
.space-card dd { margin: 0; color: var(--ink-soft); max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.members-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.25); backdrop-filter: blur(2px); }

/* --------------------------------------------------------------------------
   Composer
   -------------------------------------------------------------------------- */

.composer-area {
  flex: none;
  padding: 6px clamp(14px, 4vw, 30px) max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(248, 251, 255, 0.92) 35%);
}
.composer-area > * { max-width: 860px; margin-left: auto; margin-right: auto; }

.typing-bar { display: flex; align-items: center; gap: 6px; height: 20px; padding: 0 5px; font-size: 9.5px; color: var(--muted); }
.typing-dots { display: inline-flex; gap: 2px; }
.typing-dots i { width: 3px; height: 3px; border-radius: 50%; background: var(--blue); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

.reply-banner, .edit-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 11px 11px 3px 3px;
}
.banner-accent { width: 3px; align-self: stretch; border-radius: 3px; background: var(--blue); }
.edit-banner .banner-accent { background: var(--amber); }
.banner-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.banner-copy span { font-size: 9px; color: var(--muted); }
.banner-copy span strong { color: var(--blue); }
.banner-copy p { margin: 0; font-size: 10px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-copy + .icon-btn { width: 26px; height: 26px; }
.banner-copy + .icon-btn .icon { width: 13px; height: 13px; }

.attachment-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 11px 11px 3px 3px;
  background: var(--surface);
}
.attachment-preview img { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; background: var(--surface-soft); }
.attachment-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.attachment-copy strong { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-copy span { font-size: 8.5px; color: var(--muted); }
.upload-dot { width: 14px; height: 14px; border: 2px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }

.composer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  padding: 6px;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.composer:focus-within { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.07); }
.composer-btn {
  width: 33px;
  height: 33px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
}
.composer-btn:hover { background: var(--surface-blue); color: var(--blue); }
.composer-btn .icon { width: 18px; height: 18px; }
#messageInput {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  padding: 7px 4px;
  max-height: 145px;
  font-size: 13px;
  line-height: 1.55;
  scrollbar-width: thin;
}
#messageInput::placeholder { color: var(--muted-light); }
.composer-tail { display: flex; align-items: flex-end; gap: 2px; padding-bottom: 1px; flex: none; }
.char-count { font-size: 8px; color: var(--muted-light); align-self: center; padding-right: 3px; }
.char-count.warning { color: var(--danger); }
.send-btn {
  width: 35px;
  height: 35px;
  border: none;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  position: relative;
  transition: background 0.16s, opacity 0.16s;
}
.send-btn:hover:not(:disabled) { background: var(--blue-dark); }
.send-btn:disabled { opacity: 0.28; }
.send-btn .icon { width: 17px; height: 17px; }
.send-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.composer-hint { display: flex; justify-content: space-between; gap: 10px; padding: 6px 5px 0; font-size: 8.5px; color: var(--muted-light); }
.composer-hint span:last-child { text-align: right; }

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   通用弹窗 / 用户搜索
   -------------------------------------------------------------------------- */

.modal {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  width: min(460px, calc(100vw - 28px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
}
.modal.wide-modal { width: min(600px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(15, 23, 42, 0.35); backdrop-filter: blur(4px); }
.modal[open] { animation: modalIn 0.2s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-body { position: relative; padding: 28px; }
.modal-body h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.03em; }
.modal-lead { margin: 0 0 18px; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 29px;
  height: 29px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.modal-close:hover { background: var(--surface-soft); color: var(--ink); }
.modal-close .icon { width: 16px; height: 16px; }

.search-field { position: relative; display: block; }
.search-field > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-light); z-index: 1; }
.search-field input { padding-left: 34px; }
.search-field.inner { margin-top: 8px; }

.user-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  margin-top: 10px;
  scrollbar-width: thin;
}
.result-hint { margin: 0; padding: 14px 5px; font-size: 10.5px; color: var(--muted-light); text-align: center; }
.user-result {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  padding: 7px 8px;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
}
.user-result:hover { background: var(--surface-blue); border-color: #e0efff; }
.user-result .avatar { width: 30px; height: 30px; border-radius: 8px; font-size: 14px; }
.user-result-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-result-copy strong { font-size: 11px; font-weight: 600; }
.user-result-copy small { font-size: 8.5px; color: var(--muted-light); }
.user-result-action { font-size: 9px; color: var(--blue); font-weight: 600; flex: none; }
.online-label { color: var(--green); }
.compact-results { max-height: 180px; }

.selected-users { display: flex; flex-wrap: wrap; gap: 5px; }
.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: var(--blue-soft);
  padding: 4px 6px;
  font-size: 9.5px;
  color: var(--blue-dark);
}
.selected-chip button { border: none; background: transparent; color: var(--blue); padding: 0; line-height: 1; font-size: 12px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.confirm-modal { width: min(390px, calc(100vw - 28px)); }
.confirm-modal .modal-body { padding: 26px; }

/* 个人资料 / 群设置 */
.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  margin-bottom: 20px;
}
.profile-head > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.profile-head strong { font-size: 13px; }
.profile-head span { font-size: 9.5px; color: var(--muted); }
.role-badge {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #dbeafe;
  flex: none;
}
.role-badge.admin { color: var(--amber); background: var(--amber-soft); border-color: #fde68a; }

.settings-divider { height: 1px; background: var(--line); margin: 20px 0; }
.settings-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.settings-section-head h3 { margin: 0; font-size: 13px; }
.settings-section-head span { font-size: 9.5px; color: var(--muted-light); }
.small-title { margin: 0 0 10px; font-size: 13px; }
.settings-members { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.settings-member { display: flex; align-items: center; gap: 7px; padding: 5px 6px; border-radius: 7px; }
.settings-member:hover { background: var(--surface-soft); }
.settings-member .avatar { width: 26px; height: 26px; border-radius: 7px; font-size: 13px; }
.settings-member-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.settings-member-copy strong { font-size: 10.5px; font-weight: 600; }
.settings-member-copy small { font-size: 8.5px; color: var(--muted-light); }
.remove-member { border: none; background: transparent; color: var(--muted-light); font-size: 9px; padding: 4px 6px; border-radius: 5px; }
.remove-member:hover { color: var(--danger); background: var(--danger-soft); }
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #fee2e2;
  background: #fffafa;
}
.danger-zone strong { font-size: 11px; color: var(--danger); }
.danger-zone p { margin: 3px 0 0; font-size: 9px; color: var(--muted); line-height: 1.5; }

/* --------------------------------------------------------------------------
   表情 / 灯箱 / Toast
   -------------------------------------------------------------------------- */

.emoji-popover {
  position: fixed;
  z-index: 80;
  width: 310px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.emoji-popover-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 8px 6px 12px; font-size: 11px; }
.emoji-popover-head .icon-btn { width: 26px; height: 26px; }
.emoji-popover-head .icon { width: 14px; height: 14px; }
.emoji-tabs { display: flex; gap: 1px; padding: 0 8px 7px; border-bottom: 1px solid var(--line); }
.emoji-tabs button { border: none; background: transparent; border-radius: 6px; padding: 4px 7px; font-size: 9.5px; color: var(--muted); }
.emoji-tabs button:hover { background: var(--surface-soft); }
.emoji-tabs button.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 1px; padding: 7px; max-height: 235px; overflow-y: auto; scrollbar-width: thin; }
.emoji-grid button { aspect-ratio: 1; border: none; background: transparent; border-radius: 7px; display: grid; place-items: center; font-size: 17px; }
.emoji-grid button:hover { background: var(--surface-soft); transform: scale(1.08); }

.lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(15, 23, 42, 0.84); display: flex; align-items: center; justify-content: center; padding: 36px; backdrop-filter: blur(6px); }
.lightbox img { max-width: 92vw; max-height: 86vh; object-fit: contain; border-radius: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); }
.lightbox-close { position: absolute; top: 20px; right: 20px; width: 38px; height: 38px; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 50%; background: rgba(255, 255, 255, 0.08); color: #fff; display: grid; place-items: center; }
.lightbox-close:hover { background: rgba(255, 255, 255, 0.16); }

.toast-stack {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  width: min(380px, calc(100vw - 28px));
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.2s var(--ease);
  pointer-events: auto;
}
.toast .icon { width: 13px; height: 13px; }
.toast.success { color: var(--green); border-color: #a7f3d0; background: #f0fdf9; }
.toast.error { color: var(--danger); border-color: #fecaca; background: #fff8f8; }
.toast.leaving { opacity: 0; transform: translateY(4px); transition: opacity 0.18s, transform 0.18s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

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

.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
}
.admin-header {
  height: 66px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.admin-brand { display: flex; align-items: center; gap: 9px; }
.admin-brand > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.admin-brand strong { font-size: 13px; }
.admin-brand small { font-size: 7.5px; letter-spacing: 0.16em; color: var(--muted-light); }
.admin-header-right { display: flex; align-items: center; gap: 12px; }
.admin-user { font-size: 10px; color: var(--muted); }

.admin-layout { flex: 1; min-height: 0; display: flex; }
.admin-nav {
  width: 205px;
  flex: none;
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-nav button {
  border: none;
  border-radius: 8px;
  background: transparent;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.admin-nav button:hover { background: var(--surface-soft); color: var(--ink); }
.admin-nav button.active { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.admin-nav .icon { width: 15px; height: 15px; }

.admin-content { flex: 1; min-width: 0; overflow-y: auto; padding: 26px clamp(18px, 3.5vw, 40px) 60px; }
.admin-loading { color: var(--muted); font-size: 12px; padding: 40px; text-align: center; }
.admin-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin-page-head h1 { margin: 0 0 4px; font-size: 23px; letter-spacing: -0.03em; }
.admin-page-head p { margin: 0; color: var(--muted); font-size: 10.5px; }
.admin-page-head .admin-actions { display: flex; gap: 6px; align-items: center; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  padding: 15px 16px;
  min-height: 94px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat-card .stat-label { font-size: 9.5px; color: var(--muted); letter-spacing: 0.03em; }
.stat-card strong { font-size: 25px; line-height: 1; letter-spacing: -0.03em; font-weight: 700; }
.stat-card small { font-size: 8.5px; color: var(--muted-light); }
.stat-card.accent { background: linear-gradient(145deg, #eff6ff, #f8fbff); border-color: #dbeafe; }
.stat-card.accent strong { color: var(--blue-dark); }

.admin-grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.admin-card { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); overflow: hidden; }
.admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.admin-card-head h2 { margin: 0; font-size: 12.5px; }
.admin-card-body { padding: 13px 15px; }
.audit-list { display: flex; flex-direction: column; gap: 10px; }
.audit-item { display: flex; gap: 8px; font-size: 9.5px; line-height: 1.55; }
.audit-item .audit-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); margin-top: 5px; flex: none; }
.audit-item p { margin: 0; color: var(--ink-soft); }
.audit-item small { color: var(--muted-light); font-size: 8.5px; }

.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 12px; }
.admin-search { position: relative; flex: 1; max-width: 300px; min-width: 180px; }
.admin-search .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted-light); }
.admin-search input { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 9px 7px 29px; font-size: 11px; background: var(--surface); }
.admin-search input:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.06); }
.admin-filter { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 7px 9px; font-size: 10px; color: var(--ink-soft); }
.admin-toolbar .secondary-btn { padding: 7px 10px; font-size: 10px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 9.5px;
  padding: 5px 7px;
}
.filter-chip button { border: none; background: transparent; color: var(--blue); font-size: 12px; line-height: 1; padding: 0; }

.admin-table-wrap { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted-light);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  white-space: nowrap;
}
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 10.5px; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #fbfdff; }
.table-user { display: flex; align-items: center; gap: 7px; min-width: 130px; }
.table-user .avatar { width: 26px; height: 26px; border-radius: 7px; font-size: 13px; }
.table-user > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.table-user strong { font-size: 10.5px; font-weight: 600; }
.table-user small { font-size: 8.5px; color: var(--muted-light); }
.table-content { max-width: 380px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.table-muted { color: var(--muted-light); font-size: 9px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.table-btn {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 8.5px;
  padding: 4px 6px;
  white-space: nowrap;
}
.table-btn:hover { background: var(--surface-blue); border-color: #dbeafe; color: var(--blue); }
.table-btn.danger { color: var(--danger); }
.table-btn.danger:hover { background: var(--danger-soft); border-color: #fecaca; }
.table-btn.primary { color: var(--blue); background: var(--blue-soft); border-color: #dbeafe; }
.table-btn:disabled { opacity: 0.4; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 8px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.admin { color: var(--amber); background: var(--amber-soft); border: 1px solid #fde68a; }
.badge.member { color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); }
.badge.active { color: var(--green); background: var(--green-soft); border: 1px solid #a7f3d0; }
.badge.banned { color: var(--danger); background: var(--danger-soft); border: 1px solid #fecaca; }
.badge.public { color: var(--blue); background: var(--blue-soft); border: 1px solid #dbeafe; }
.badge.announcement { color: var(--amber); background: var(--amber-soft); border: 1px solid #fde68a; }
.badge.group { color: #7c3aed; background: #f5f3ff; border: 1px solid #ddd6fe; }
.badge.dm { color: #0e7490; background: #ecfeff; border: 1px solid #a5f3fc; }
.badge.deleted { color: var(--danger); background: var(--danger-soft); border: 1px solid #fecaca; }

.admin-pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; font-size: 9.5px; color: var(--muted); }
.admin-pager .pager-btns { display: flex; gap: 5px; }
.pager-btns button { width: 27px; height: 25px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; color: var(--muted); display: grid; place-items: center; }
.pager-btns button:hover:not(:disabled) { border-color: #bfdbfe; color: var(--blue); }
.pager-btns button:disabled { opacity: 0.35; }
.pager-btns .icon { width: 13px; height: 13px; }

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

@media (max-width: 1160px) {
  .members-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: min(300px, 86vw);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform 0.24s var(--ease);
  }
  .members-panel.open { transform: translateX(0); }
  .members-close { display: grid; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar-head { padding: 0 16px; }
  .chat-header { padding: 0 17px; }
  .composer-area { padding-left: 16px; padding-right: 16px; }
  .messages-stage { padding-left: 14px; padding-right: 14px; }
  .auth-brand { padding: 34px; }
  .auth-panel { padding: 34px 32px 26px; }
}

@media (max-width: 800px) {
  .app-shell {
    height: 100dvh;
    margin: 0;
    border: none;
    border-radius: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(290px, 86vw);
    z-index: 60;
    transform: translateX(-102%);
    transition: transform 0.24s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-grid; }
  .menu-btn { display: inline-grid; }
  .chat-header { height: 66px; padding: 0 11px; gap: 6px; }
  .conv-title-row h1 { font-size: 15px; }
  #convTopic { font-size: 9.5px; }
  .header-chip { height: 29px; }
  .header-actions { gap: 2px; }
  .messages-stage { padding: 14px 10px 24px; }
  .composer-area { padding: 4px 8px max(7px, env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .composer { border-radius: 12px; min-height: 48px; }
  .composer-btn { width: 31px; height: 31px; }
  .send-btn { width: 33px; height: 33px; border-radius: 9px; }
  #messageInput { font-size: 13px; }
  .msg-actions { opacity: 0.68; transform: none; pointer-events: auto; top: -11px; right: 2px; }
  .message { padding: 7px 4px; }
  .msg-body { font-size: 13px; }
  .msg-image-btn img { max-height: 230px; }
  .typing-bar { height: 17px; }
  .auth-screen { height: 100dvh; min-height: 0; overflow-y: auto; display: block; padding: 0; }
  .auth-shell { grid-template-columns: 1fr; min-height: 100dvh; max-height: none; border: none; border-radius: 0; box-shadow: none; }
  .auth-brand { display: none; }
  .auth-panel { padding: 26px 22px 22px; min-height: 100dvh; }
  .auth-mobile-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 28px; font-size: 17px; }
  .auth-mobile-brand .logo-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
  .auth-tabs { margin-bottom: 24px; }
  .auth-form { max-width: none; }
  .admin-header { padding: 0 14px; height: 60px; }
  .admin-user { display: none; }
  .admin-layout { flex-direction: column; }
  .admin-nav {
    width: 100%;
    flex: none;
    flex-direction: row;
    overflow-x: auto;
    padding: 8px 10px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    gap: 2px;
  }
  .admin-nav button { white-space: nowrap; padding: 7px 9px; font-size: 10px; }
  .admin-content { padding: 16px 12px 40px; }
  .admin-page-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .admin-page-head h1 { font-size: 20px; }
  .stats-grid { gap: 7px; }
  .stat-card { padding: 12px; min-height: 84px; }
  .stat-card strong { font-size: 22px; }
  .toast-stack { bottom: max(14px, env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .modal-body { padding: 22px 18px; }
  .modal-body h2 { font-size: 20px; }
  .btn, .auth-submit { padding: 11px; }
  .chat-header .conv-emoji { display: none; }
  .header-chip span { font-size: 9px; }
  .message .msg-avatar { width: 31px; height: 31px; font-size: 15px; border-radius: 9px; }
  .msg-actions { gap: 0; }
  .action-btn { width: 24px; height: 24px; }
  .emoji-popover {
    width: calc(100vw - 16px);
    left: 8px !important;
    top: auto !important;
    bottom: 8px !important;
  }
  .emoji-grid { max-height: 34dvh; }
  .admin-header-right .secondary-btn { padding: 7px 10px; font-size: 10px; }
  .admin-table { min-width: 580px; }
  .auth-panel { padding-left: 18px; padding-right: 18px; }
  .auth-form h2 { font-size: 25px; }
  .auth-tabs button { padding: 7px 16px; }
  .lightbox { padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
