/* ================= ChatHub 样式 ================= */
:root {
  --pri: #6366f1;
  --pri2: #8b5cf6;
  --pri-soft: #eef2ff;
  --bg: #f5f6fa;
  --panel: #ffffff;
  --line: #e8eaf0;
  --txt: #1e293b;
  --txt2: #64748b;
  --txt3: #94a3b8;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(15, 23, 42, .06);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  overflow: hidden;
}

button, input, textarea { font-family: inherit; font-size: 14px; outline: none; border: none; }
button { cursor: pointer; background: none; color: inherit; }
.hidden { display: none !important; }

/* ---------------- 登录 / 注册 ---------------- */
.auth-wrap { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(1000px 500px at 12% 8%, #e0e7ff 0%, transparent 60%),
    radial-gradient(900px 500px at 88% 92%, #f3e8ff 0%, transparent 60%),
    linear-gradient(135deg, #eef2ff, #faf5ff);
}
.auth-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(99,102,241,.14) 1px, transparent 1px);
  background-size: 26px 26px;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px; margin: 20px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-radius: 22px; padding: 34px 30px 26px;
  box-shadow: 0 24px 70px rgba(99,102,241,.18);
  animation: rise .5s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.97); } to { opacity: 1; transform: none; } }

.auth-head { text-align: center; margin-bottom: 22px; }
.auth-logo {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 18px;
  background: linear-gradient(135deg, var(--pri), var(--pri2));
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  box-shadow: 0 10px 26px rgba(99,102,241,.35);
}
.auth-head h1 { font-size: 22px; letter-spacing: .5px; }
.auth-head p { color: var(--txt2); font-size: 13px; margin-top: 6px; }

.auth-tabs {
  display: flex; background: #f1f3f9; border-radius: 11px; padding: 4px; margin-bottom: 20px;
}
.tab-btn {
  flex: 1; padding: 9px; border-radius: 8px; font-size: 14px; font-weight: 600;
  color: var(--txt2); transition: .22s;
}
.tab-btn.active { background: #fff; color: var(--pri); box-shadow: 0 2px 8px rgba(15,23,42,.08); }

.field {
  display: flex; align-items: center; gap: 10px;
  background: #f7f8fc; border: 1.5px solid var(--line);
  border-radius: 11px; padding: 0 13px; margin-bottom: 12px; transition: .2s;
}
.field:focus-within { border-color: var(--pri); background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.field .fi { font-size: 15px; opacity: .65; flex-shrink: 0; }
.field input { flex: 1; padding: 12px 0; background: transparent; color: var(--txt); }
.field input::placeholder { color: var(--txt3); }

.btn-primary {
  width: 100%; padding: 13px; border-radius: 11px; color: #fff; font-weight: 600; font-size: 15px;
  background: linear-gradient(135deg, var(--pri), var(--pri2));
  box-shadow: 0 8px 22px rgba(99,102,241,.32); transition: .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(99,102,241,.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-primary.sm { width: auto; padding: 10px 22px; }

.auth-msg { min-height: 20px; text-align: center; font-size: 13px; margin-top: 14px; color: var(--danger); }
.auth-msg.ok { color: var(--ok); }
.auth-foot { text-align: center; font-size: 12px; color: var(--txt3); margin-top: 18px; }

/* ---------------- 应用布局 ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 268px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.side-head {
  height: 58px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand-ico {
  width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--pri), var(--pri2)); font-size: 15px;
}

.icon-btn {
  width: 32px; height: 32px; border-radius: 9px; color: var(--txt2);
  display: flex; align-items: center; justify-content: center; font-size: 15px; transition: .18s;
}
.icon-btn:hover { background: #f1f3f9; color: var(--txt); }
.icon-btn.sm { width: 24px; height: 24px; font-size: 16px; border-radius: 7px; }

.me-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; margin: 10px;
  background: linear-gradient(135deg, #f8faff, #faf5ff); border-radius: 12px; border: 1px solid var(--line);
}
.avatar {
  width: 38px; height: 38px; border-radius: 11px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
  text-transform: uppercase;
}
.me-info { flex: 1; min-width: 0; }
.me-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-sub { font-size: 12px; color: var(--txt3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-sec { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 6px 18px; }
.side-sec-title { font-size: 12px; font-weight: 600; color: var(--txt3); letter-spacing: 1px; }

.room-list { flex: 1; overflow-y: auto; padding: 4px 10px 10px; }
.room-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px;
  cursor: pointer; transition: .18s; margin-bottom: 2px;
}
.room-item:hover { background: #f5f6fb; }
.room-item.active { background: linear-gradient(135deg, var(--pri-soft), #faf5ff); box-shadow: inset 0 0 0 1px rgba(99,102,241,.18); }
.room-ico { font-size: 16px; flex-shrink: 0; }
.room-meta { flex: 1; min-width: 0; }
.room-nm { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item.active .room-nm { color: var(--pri); font-weight: 600; }
.room-tp { font-size: 11.5px; color: var(--txt3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-cnt { font-size: 11px; color: var(--txt3); background: #f1f3f9; padding: 2px 7px; border-radius: 20px; flex-shrink: 0; }

.side-foot { padding: 12px 14px; border-top: 1px solid var(--line); }
.btn-ghost {
  width: 100%; padding: 10px; border-radius: 10px; background: #f7f8fc; color: var(--txt2);
  font-size: 13.5px; font-weight: 500; transition: .18s;
}
.btn-ghost:hover { background: #fef2f2; color: var(--danger); }

/* 主区 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.chat-head {
  height: 58px; flex-shrink: 0; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
}
.chat-title { flex: 1; min-width: 0; }
.ct-name { font-size: 15.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sub { font-size: 12px; color: var(--txt3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-right { display: flex; align-items: center; gap: 8px; }
.online-badge {
  font-size: 12px; color: var(--ok); background: #f0fdf4; border: 1px solid #bbf7d0;
  padding: 4px 11px; border-radius: 20px; white-space: nowrap;
}

.msg-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 18px; scroll-behavior: smooth; }
.msg-list { display: flex; flex-direction: column; gap: 12px; max-width: 920px; margin: 0 auto; }

.loading-tip { text-align: center; color: var(--txt3); font-size: 13px; padding: 26px 0; }

.msg { display: flex; gap: 10px; animation: pop .28s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.mine { flex-direction: row-reverse; }
.msg-av {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
  text-transform: uppercase;
}
.msg-body { max-width: min(74%, 560px); min-width: 0; }
.msg-top { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.msg.mine .msg-top { flex-direction: row-reverse; }
.msg-nick { font-size: 12.5px; font-weight: 600; color: var(--txt2); }
.msg-time { font-size: 11px; color: var(--txt3); }
.msg-bubble {
  background: #fff; padding: 9px 13px; border-radius: 4px 14px 14px 14px;
  box-shadow: var(--shadow); line-height: 1.62; word-break: break-word; white-space: pre-wrap;
  font-size: 14.2px;
}
.msg.mine .msg-bubble {
  background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff;
  border-radius: 14px 4px 14px 14px; box-shadow: 0 3px 14px rgba(99,102,241,.28);
}
.msg.mine .msg-nick { color: var(--pri); }

.msg-sys { text-align: center; margin: 2px 0; }
.msg-sys span {
  display: inline-block; font-size: 12px; color: var(--txt2);
  background: rgba(148,163,184,.14); padding: 4px 13px; border-radius: 20px;
}

.day-sep { text-align: center; margin: 8px 0 2px; }
.day-sep span {
  font-size: 11.5px; color: var(--txt3); background: #ecedf3;
  padding: 3px 12px; border-radius: 20px;
}

.typing-hint { height: 18px; padding: 0 20px; font-size: 12px; color: var(--txt3); flex-shrink: 0; }

/* 输入区 */
.composer { flex-shrink: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 8px 14px 12px; }
.emoji-bar { display: flex; gap: 2px; overflow-x: auto; padding: 2px 0 7px; scrollbar-width: none; }
.emoji-bar::-webkit-scrollbar { display: none; }
.emoji { font-size: 19px; padding: 3px 5px; border-radius: 8px; transition: .15s; flex-shrink: 0; }
.emoji:hover { background: #f1f3f9; transform: scale(1.16); }

.composer-row { display: flex; align-items: flex-end; gap: 9px; }
#input {
  flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 13px;
  padding: 11px 14px; max-height: 118px; line-height: 1.55; background: #f7f8fc;
  transition: .2s; font-size: 14.2px;
}
#input:focus { border-color: var(--pri); background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
.btn-send {
  width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0; color: #fff; font-size: 17px;
  background: linear-gradient(135deg, var(--pri), var(--pri2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 16px rgba(99,102,241,.32); transition: .18s;
}
.btn-send:hover { transform: translateY(-1px); }
.btn-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* 成员栏 */
.members {
  width: 214px; flex-shrink: 0; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.members.hidden { display: none; }
.mem-head {
  height: 58px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--txt2);
}
.mem-list { flex: 1; overflow-y: auto; padding: 10px; }
.mem-item { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 10px; }
.mem-item:hover { background: #f5f6fb; }
.mem-av {
  width: 28px; height: 28px; border-radius: 9px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
}
.mem-nm { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mem-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-left: auto; flex-shrink: 0; }

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.42); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 360px;
  box-shadow: 0 24px 60px rgba(15,23,42,.24); animation: rise .28s cubic-bezier(.2,.9,.3,1.2) both;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 16px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-btns .btn-ghost { width: auto; padding: 10px 20px; }
.modal-btns .btn-ghost:hover { background: #f1f5f9; color: var(--txt2); }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 22px; transform: translate(-50%, -20px);
  background: rgba(15,23,42,.92); color: #fff; padding: 10px 20px; border-radius: 11px;
  font-size: 13.5px; z-index: 200; opacity: 0; pointer-events: none; transition: .28s;
  box-shadow: 0 10px 30px rgba(15,23,42,.28); max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 管理员 ---------------- */
.badge-admin {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px;
  font-size: 10.5px; font-weight: 600; vertical-align: 1px;
  background: linear-gradient(135deg, #fee2e2, #fecaca); color: #b91c1c;
  border: 1px solid #fca5a5; letter-spacing: .5px;
}
.btn-admin-entry {
  width: 100%; padding: 10px; border-radius: 10px; margin-bottom: 8px;
  background: linear-gradient(135deg, #fef2f2, #fff7ed); color: #b91c1c;
  border: 1px solid #fecaca; font-size: 13.5px; font-weight: 600; transition: .18s;
}
.btn-admin-entry:hover { background: #fee2e2; }

.admin-box { max-width: 560px; max-height: 86vh; display: flex; flex-direction: column; overflow: hidden; }
.admin-title { display: flex; align-items: center; justify-content: space-between; }
.admin-tabs {
  display: flex; background: #f1f3f9; border-radius: 11px; padding: 4px; margin-bottom: 14px;
}
.ad-tab {
  flex: 1; padding: 8px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--txt2); transition: .2s;
}
.ad-tab.active { background: #fff; color: #b91c1c; box-shadow: 0 2px 8px rgba(15,23,42,.08); }
.ad-panel { overflow-y: auto; min-height: 220px; }
.ad-user-list { display: flex; flex-direction: column; gap: 6px; }
.ad-user {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border-radius: 11px; border: 1px solid var(--line); background: #fafbfe;
}
.ad-user.banned { background: #fef7f7; border-color: #fecaca; }
.ad-av {
  width: 34px; height: 34px; border-radius: 10px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.ad-umeta { flex: 1; min-width: 0; }
.ad-uname { font-size: 13.5px; font-weight: 600; }
.ad-user.banned .ad-uname { color: #b91c1c; }
.ad-usub { font-size: 11.5px; color: var(--txt3); margin-top: 2px; }
.ad-uops { display: flex; gap: 6px; flex-shrink: 0; }
.ad-op {
  padding: 6px 11px; border-radius: 8px; font-size: 12px; font-weight: 600; transition: .16s;
}
.ad-op.mute { background: #fef9c3; color: #a16207; }
.ad-op.mute:hover { background: #fde047; }
.ad-op.ban { background: #fee2e2; color: #b91c1c; }
.ad-op.ban:hover { background: #fca5a5; }
.ad-op.del { background: #f1f3f9; color: var(--txt2); }
.ad-op.del:hover { background: #e2e8f0; }
.ad-self-tag { font-size: 12px; color: var(--txt3); }

.ad-clean-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ad-label { width: 72px; flex-shrink: 0; font-size: 13px; color: var(--txt2); font-weight: 500; }
.ad-clean-row select {
  flex: 1; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #f7f8fc; color: var(--txt); font-size: 13.5px;
}
.btn-danger-block {
  width: 100%; padding: 12px; border-radius: 11px; margin-top: 6px;
  background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 18px rgba(239,68,68,.3); transition: .18s;
}
.btn-danger-block:hover { transform: translateY(-1px); }
.ad-tip { font-size: 12px; color: var(--txt3); margin-top: 10px; line-height: 1.6; }

.ad-sum-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.ad-sum-item {
  background: #f8f9fd; border: 1px solid var(--line); border-radius: 11px;
  padding: 11px 6px; text-align: center;
}
.ad-sum-val { font-size: 19px; font-weight: 700; color: var(--pri); }
.ad-sum-key { font-size: 11.5px; color: var(--txt3); margin-top: 2px; }
.ad-tbl-title { font-size: 12.5px; font-weight: 600; color: var(--txt2); margin-bottom: 8px; }
.ad-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ad-tbl th, .ad-tbl td { padding: 7px 9px; text-align: left; border-bottom: 1px solid var(--line); }
.ad-tbl th { color: var(--txt3); font-weight: 600; font-size: 11.5px; }

/* 遮罩 */
.mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 30;
  display: none;
}
.mask.show { display: block; }

.only-mobile { display: none !important; }

/* 滚动条 */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #d5d8e2; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #bcc0cd; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .members {
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 40; width: 230px;
    box-shadow: -8px 0 30px rgba(15,23,42,.14); transform: translateX(100%); transition: .28s;
  }
  .members.show { transform: none; }
  .members.hidden { display: flex; }
}
@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: 272px;
    box-shadow: 8px 0 30px rgba(15,23,42,.16); transform: translateX(-100%); transition: .28s;
  }
  .sidebar.show { transform: none; }
  .only-mobile { display: flex !important; }
  .msg-scroll { padding: 12px; }
  .msg-body { max-width: 80%; }
  .online-badge { display: none; }
  .chat-head { padding: 0 10px; }
}
