/* 鑫聊 · 样式 —— 紫韵主题 */

:root {
  --ink: #2b2b47;
  --ink-2: #6f7191;
  --pine: #7b6cf0;
  --pine-hover: #6a5be6;
  --pine-deep: #2d2a52;
  --pine-side: #332f5e;
  --side-text: #d6d4f5;
  --paper: #eef0f6;
  --card: #ffffff;
  --mine-bg: #e9e5fd;
  --other-bg: #ffffff;
  --line: #e1e3f0;
  --danger: #b3402f;
  --ok: #2f9e6e;
  --warn: #c07f1f;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(45, 42, 82, .12);
  --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; font-size: 15px; color: var(--ink); }
.hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9cbe8; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 登录页 ============ */

.auth-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 85% -10%, #e3e0fb 0%, transparent 60%),
    radial-gradient(900px 480px at -10% 110%, #e7e9f8 0%, transparent 55%),
    var(--paper);
}

.auth-card {
  width: min(860px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--line);
}

.auth-brand {
  background:
    radial-gradient(420px 260px at 80% 0%, rgba(255, 255, 255, .07), transparent 70%),
    var(--pine-deep);
  color: #e9e8fc;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-logo { height: 120px; margin-bottom: 10px; display: flex; align-items: center; }
.brand-logo svg { width: 78px; height: 78px; border-radius: 22px; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .28)); }

.auth-brand h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 6px;
}
.auth-brand .sub { color: #a5a1e8; margin-top: 4px; font-size: 14px; letter-spacing: 1px; }
.auth-brand ul { margin-top: auto; padding-top: 26px; list-style: none; display: grid; gap: 9px; font-size: 13px; color: #c9c6f0; }
.auth-brand li::before { content: "—"; margin-right: 8px; color: #8b81f0; }

.auth-form { padding: 44px 42px; display: flex; flex-direction: column; }
.auth-tabs { display: flex; gap: 4px; background: var(--paper); border-radius: 12px; padding: 4px; margin-bottom: 26px; }
.auth-tabs button {
  flex: 1; padding: 9px 0; border-radius: 9px; font-size: 15px; color: var(--ink-2); transition: all .15s;
}
.auth-tabs button.active { background: #fff; color: var(--pine); font-weight: 600; box-shadow: 0 2px 8px rgba(45,42,82,.10); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; letter-spacing: .5px; }
.field input {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px;
  outline: none; background: #fbfcfb; transition: border-color .15s;
}
.field input:focus { border-color: var(--pine); background: #fff; }

.primary-btn {
  width: 100%; padding: 12px 0; margin-top: 6px; border-radius: 10px;
  background: var(--pine); color: #fff; font-size: 15px; font-weight: 600; letter-spacing: 2px;
  transition: background .15s;
}
.primary-btn:hover { background: var(--pine-hover); }
.primary-btn:disabled { opacity: .6; cursor: not-allowed; }

.auth-msg { min-height: 20px; margin-top: 14px; font-size: 13px; color: var(--danger); }
.auth-msg.ok { color: var(--ok); }
.auth-hint { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }

/* ============ 主界面 ============ */

.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: 54px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.logo-mini { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 2px; color: var(--pine); }
.logo-mini svg.x-logo { width: 24px; height: 24px; border-radius: 7px; }
.room-title { font-weight: 600; font-size: 15px; }
.topbar .spacer { flex: 1; }

.conn-state { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.conn-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.conn-state.off::before { background: var(--warn); }
.conn-state.bad::before { background: var(--danger); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; color: var(--ink-2); transition: all .15s;
}
.icon-btn:hover { background: var(--paper); color: var(--pine); }
.icon-btn svg { width: 19px; height: 19px; }
.text-btn { padding: 7px 10px; border-radius: 9px; color: var(--ink-2); font-size: 13px; }
.text-btn:hover { background: var(--paper); color: var(--pine); }

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

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

.sidebar {
  width: 264px; flex: none; display: flex; flex-direction: column;
  background: var(--pine-side); color: var(--side-text); overflow-y: auto;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 6px; font-size: 12px; letter-spacing: 2px; color: #8f8cc0;
}
.side-head button {
  width: 24px; height: 24px; border-radius: 7px; color: #b5b2e8; font-size: 16px; line-height: 1;
}
.side-head button:hover { background: rgba(255, 255, 255, .12); color: #fff; }

.room-list, .user-list { list-style: none; padding: 2px 8px 10px; }
.room-list li {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; margin: 1px 0;
  border-radius: 10px; cursor: pointer; font-size: 14px; transition: background .12s;
}
.room-list li:hover { background: rgba(255, 255, 255, .07); }
.room-list li.active { background: rgba(255, 255, 255, .13); color: #fff; }
.room-ico {
  width: 30px; height: 30px; flex: none; border-radius: 9px 9px 9px 2px;
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600;
  background: rgba(255, 255, 255, .12); color: #dcdbf8;
}
.room-list li.active .room-ico { background: var(--pine); color: #fff; }
.room-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-sub { font-size: 11px; color: #7fa89e; }
.unread {
  flex: none; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #e0b25a; color: #3d2e08; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.user-list li {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; margin: 1px 0;
  border-radius: 10px; cursor: pointer; font-size: 13.5px;
}
.user-list li:hover { background: rgba(255, 255, 255, .07); }
.user-list li.me { cursor: default; }
.user-list li .u-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-admin { font-size: 10.5px; color: #e0b25a; border: 1px solid rgba(224, 178, 90, .5); border-radius: 4px; padding: 0 4px; }
.badge-off { font-size: 10.5px; color: #6f8b84; }

/* ---- 消息区 ---- */

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

.msg-scroll { flex: 1; overflow-y: auto; padding: 18px 22px 8px; scroll-behavior: smooth; }
.msg-more { text-align: center; padding: 4px 0 14px; }
.msg-more button {
  font-size: 12.5px; color: var(--pine); background: #fff; border: 1px solid var(--line);
  padding: 6px 16px; border-radius: 999px;
}
.msg-more button:hover { background: var(--mine-bg); }

.msg-list { list-style: none; }
.msg { display: flex; gap: 10px; margin-top: 14px; animation: rise .18s ease-out; }
.msg.compact { margin-top: 3px; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.avatar {
  width: 36px; height: 36px; flex: none; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 15px; user-select: none;
}
.msg-body { max-width: min(64%, 560px); display: flex; flex-direction: column; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; padding-left: 2px; }
.msg-head .m-name { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.msg-head .m-time { font-size: 11px; color: #9a9eb8; font-variant-numeric: tabular-nums; }

.bubble {
  padding: 9px 13px; border-radius: var(--radius); background: var(--other-bg);
  border: 1px solid var(--line); width: fit-content; max-width: 100%;
  overflow-wrap: break-word; white-space: pre-wrap;
}
.msg.mine { flex-direction: row-reverse; }
.msg.mine .msg-body { align-items: flex-end; }
.msg.mine .bubble { background: var(--mine-bg); border-color: #d3cdfa; }
.msg.compact .msg-head { display: none; }
.msg.compact .bubble { border-top-left-radius: 4px; }
.msg.mine.compact .bubble { border-radius: 4px var(--radius) var(--radius) var(--radius); }

.msg img.pic {
  display: block; max-width: min(320px, 100%); max-height: 260px;
  border-radius: 9px; cursor: zoom-in; background: #e3e5f3;
}
.bubble.media { padding: 5px; }

.file-card {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  min-width: 220px; text-decoration: none; color: inherit;
}
.file-ico {
  width: 38px; height: 38px; flex: none; border-radius: 10px; background: #ecebfc;
  display: flex; align-items: center; justify-content: center; color: var(--pine);
}
.file-ico svg { width: 20px; height: 20px; }
.file-meta { min-width: 0; }
.file-meta .f-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.file-meta .f-size { font-size: 12px; color: var(--ink-2); }
.file-dl { color: var(--pine); font-size: 12.5px; flex: none; }

.msg.system { justify-content: center; margin-top: 18px; }
.msg.system .sys {
  font-size: 12px; color: var(--ink-2); background: #e8eaf5; border-radius: 999px; padding: 4px 14px;
}

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

.composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 14px 12px; background: var(--card); border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 9px 12px; max-height: 140px; outline: none; background: #fbfcfb;
  line-height: 1.5; transition: border-color .15s;
}
.composer textarea:focus { border-color: var(--pine); background: #fff; }
.send-btn {
  flex: none; padding: 10px 20px; border-radius: 12px; background: var(--pine); color: #fff;
  font-weight: 600; letter-spacing: 2px;
}
.send-btn:hover { background: var(--pine-hover); }
.send-btn:disabled { opacity: .55; cursor: not-allowed; }

.upload-bar { padding: 0 14px 10px; background: var(--card); }
.upload-item { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.upload-item .bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.upload-item .bar i { display: block; height: 100%; background: var(--pine); width: 0; transition: width .15s; }

.drop-mask {
  position: absolute; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(45, 42, 82, .55); color: #fff; font-size: 17px; letter-spacing: 3px;
  border-radius: 4px;
}

.typing-hint { flex: none; min-height: 22px; padding: 0 22px 2px; font-size: 12px; color: var(--pine); }
.typing-hint .dots i { animation: blink 1.2s infinite; }
.typing-hint .dots i:nth-child(2) { animation-delay: .2s; }
.typing-hint .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---- 灯箱 ---- */

.lightbox {
  position: fixed; inset: 0; z-index: 90; background: rgba(23, 20, 44, .82);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 30px;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 6px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }

/* ---- 模态 ---- */

.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(23, 20, 44, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: min(560px, 100%); max-height: 84vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 22px 24px;
}
.modal-card h3 { font-size: 16px; margin-bottom: 16px; display: flex; align-items: center; }
.modal-card h3 .close { margin-left: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.mini-btn {
  padding: 8px 16px; border-radius: 9px; font-size: 13.5px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.mini-btn:hover { border-color: var(--pine); color: var(--pine); }
.mini-btn.solid { background: var(--pine); border-color: var(--pine); color: #fff; }
.mini-btn.solid:hover { background: var(--pine-hover); }
.mini-btn.danger { color: var(--danger); border-color: #e3c0c8; }
.mini-btn.danger:hover { background: #fdf0f0; }

.admin-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.admin-tabs button { padding: 8px 2px; font-size: 14px; color: var(--ink-2); border-bottom: 2px solid transparent; }
.admin-tabs button.active { color: var(--pine); border-bottom-color: var(--pine); font-weight: 600; }

.invite-row, .admin-user-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 2px; font-size: 13.5px;
  border-bottom: 1px dashed var(--line);
}
.invite-row code { font-weight: 700; letter-spacing: 1.5px; color: var(--pine); font-size: 15px; }
.admin-user-row .u-info { flex: 1; min-width: 0; }
.admin-user-row .u-info small { color: var(--ink-2); margin-left: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px; }
.stat-cell { background: var(--paper); border-radius: 12px; padding: 14px 16px; }
.stat-cell b { display: block; font-size: 22px; color: var(--pine); font-variant-numeric: tabular-nums; }
.stat-cell span { font-size: 12px; color: var(--ink-2); }
.invite-new { margin: 10px 0 4px; padding: 10px 12px; background: #f1eefd; border-radius: 10px; display: flex; align-items: center; gap: 10px; }

/* ---- 手机 ---- */

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

@media (max-width: 900px) {
  .only-mobile { display: inline-flex !important; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-brand { padding: 30px 30px 24px; }
  .auth-brand ul { display: none; }
  .brand-logo { height: 74px; margin-bottom: 2px; }
  .brand-logo svg { width: 60px; height: 60px; }
  .auth-form { padding: 30px 26px; }

  .app-body { position: relative; }
  .sidebar {
    position: absolute; z-index: 40; inset: 0 auto 0 0; width: min(78vw, 300px);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: none;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
  .msg-scroll { padding: 14px 12px 6px; }
  .msg-body { max-width: 78%; }
  .composer { padding: 8px 8px 10px; gap: 5px; }
  .send-btn { padding: 10px 14px; }
  .room-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .conn-state span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- 大厅全体禁言 ---- */
.mute-badge {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 10px; padding: 2px 10px; border-radius: 999px;
  background: #fdf0f0; color: #c0564a; border: 1px solid #edd0cf;
  font-size: 12px; font-weight: 600; letter-spacing: 1px; vertical-align: middle;
}
.composer textarea:disabled { background: #f1f0f7; color: #9a9eb8; cursor: not-allowed; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn:disabled:hover { background: none; color: var(--ink-2); }
