/* 内部通讯（类QQ）深色风格 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b1220;
  --side: #101a2e;
  --card: #16203a;
  --card2: #1b2747;
  --line: rgba(255,255,255,.07);
  --txt: #e8edf7;
  --dim: #8b98b8;
  --pri: #4f7cff;
  --pri2: #6a5cff;
  --green: #2eb872;
  --red: #e0568c;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--txt); overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ---------- 登录页 ---------- */
.login-page {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(79,124,255,.25), transparent),
              radial-gradient(900px 500px at 90% 110%, rgba(106,92,255,.2), transparent), var(--bg);
}
.login-card {
  width: min(380px, 92vw); padding: 40px 34px; border-radius: 20px;
  background: rgba(22,32,58,.85); backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.45);
  text-align: center;
}
.login-logo { font-size: 46px; margin-bottom: 6px; }
.login-card h1 { font-size: 26px; letter-spacing: 2px; }
.grad { background: linear-gradient(90deg, #6ea8ff, #9b8cff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { color: var(--dim); font-size: 13px; margin: 8px 0 24px; }
.login-form input {
  width: 100%; padding: 13px 16px; margin-bottom: 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(11,18,32,.7); color: var(--txt); font-size: 15px; outline: none;
}
.login-form input:focus { border-color: var(--pri); }
.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px; font-size: 16px; font-weight: 600;
  background: linear-gradient(90deg, var(--pri), var(--pri2)); color: #fff;
  transition: opacity .2s;
}
.btn-primary:hover { opacity: .9; }
.btn-ghost {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: transparent; color: var(--txt); font-size: 14px;
}
.btn-ghost:hover { background: rgba(255,255,255,.06); }
.w100 { width: 100%; }
.login-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.login-links a { color: #6ea8ff; text-decoration: none; }

/* ---------- 主布局 ---------- */
.main-page { display: flex; height: 100vh; }

/* 侧栏 */
.sidebar {
  width: 280px; min-width: 280px; background: var(--side);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.side-top { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.side-me { flex: 1; min-width: 0; }
.side-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-status { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.icon-btn {
  border: none; background: transparent; font-size: 17px; color: var(--dim);
  width: 34px; height: 34px; border-radius: 9px; line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: var(--txt); }
.icon-btn.big { font-size: 21px; width: 40px; height: 40px; }
.side-search { padding: 0 12px 10px; }
.side-search input {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(11,18,32,.6); color: var(--txt); font-size: 13px; outline: none;
}
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px; }
.conv-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 10px;
  border-radius: 12px; cursor: pointer; margin-bottom: 2px;
}
.conv-item:hover { background: rgba(255,255,255,.05); }
.conv-item.active { background: linear-gradient(90deg, rgba(79,124,255,.22), rgba(106,92,255,.14)); }
.conv-info { flex: 1; min-width: 0; }
.conv-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--dim); flex-shrink: 0; }
.conv-last { font-size: 12.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--red); color: #fff; font-size: 11px; min-width: 18px; height: 18px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px; flex-shrink: 0;
}
.conv-empty { text-align: center; color: var(--dim); padding: 30px 0; font-size: 13px; }
.side-bottom { padding: 10px 12px; border-top: 1px solid var(--line); }

/* 头像 */
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 16px; position: relative;
  background: var(--pri);
}
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 14px; }
.avatar.xs { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
.dot {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px;
  border-radius: 50%; border: 2px solid var(--side);
}
.dot.on { background: var(--green); }

/* 聊天区 */
.chat-area { flex: 1; display: flex; min-width: 0; background: var(--bg); }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--dim); }
.empty-icon { font-size: 56px; opacity: .5; margin-bottom: 12px; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  display: flex; align-items: center; gap: 10px; padding: 13px 18px;
  border-bottom: 1px solid var(--line); background: rgba(16,26,46,.6);
}
.back-btn { display: none; border: none; background: transparent; color: var(--txt); font-size: 26px; line-height: 1; }
.chat-title { font-weight: 600; font-size: 16px; }
.chat-sub { font-size: 12px; color: var(--dim); display: flex; align-items: center; gap: 5px; }
.chat-sub .dot { position: static; border: none; width: 8px; height: 8px; }

.msg-list { flex: 1; overflow-y: auto; padding: 18px 18px 8px; }
.msg-row { display: flex; gap: 10px; margin-bottom: 14px; }
.msg-row.mine-row { flex-direction: row-reverse; }
.msg-col { max-width: min(64%, 560px); display: flex; flex-direction: column; }
.mine-row .msg-col { align-items: flex-end; }
.msg-name { font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.bubble {
  padding: 10px 14px; border-radius: 4px 14px 14px 14px;
  background: var(--card2); font-size: 14.5px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
}
.bubble.mine { border-radius: 14px 4px 14px 14px; background: linear-gradient(135deg, var(--pri), var(--pri2)); color: #fff; }
.bubble.img { padding: 4px; background: var(--card2); }
.bubble.img img { max-width: min(300px, 60vw); max-height: 320px; border-radius: 10px; display: block; cursor: zoom-in; }
.bubble.file {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px; min-width: 220px;
  cursor: pointer; border-radius: 4px 14px 14px 14px;
}
.bubble.file.mine { border-radius: 14px 4px 14px 14px; }
.bubble.file:hover { filter: brightness(1.12); }
.file-ic { font-size: 30px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { font-size: 13.5px; font-weight: 500; word-break: break-all; }
.file-size { font-size: 11.5px; color: var(--dim); margin-top: 3px; }
.bubble.file.mine .file-size { color: rgba(255,255,255,.75); }
.file-dl { font-size: 18px; opacity: .8; }

.typing-bar { padding: 0 18px 6px; font-size: 12px; color: var(--dim); font-style: italic; }

.chat-input {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--line); background: rgba(16,26,46,.6);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.chat-input input[type=text] {
  flex: 1; padding: 11px 15px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(11,18,32,.7); color: var(--txt); font-size: 14.5px; outline: none;
}
.chat-input input[type=text]:focus { border-color: var(--pri); }
.send-btn { width: auto; padding: 11px 22px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(5,10,20,.66); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  width: min(420px, 92vw); max-height: 82vh; overflow-y: auto; padding: 22px;
  border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h3 { margin-bottom: 16px; font-size: 17px; }
.form-grid { display: grid; grid-template-columns: 72px 1fr; gap: 11px 10px; align-items: center; }
.form-grid label { color: var(--dim); font-size: 13.5px; }
.form-grid input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(11,18,32,.7); color: var(--txt); font-size: 14px; outline: none;
}
.form-grid input:focus { border-color: var(--pri); }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.gp-members { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.gp-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  cursor: pointer; font-size: 14px;
}
.gp-item:hover { background: rgba(255,255,255,.05); }
.dim { color: var(--dim); font-size: 13px; }

/* 图片查看器 */
.img-viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 200;
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.img-viewer img { max-width: 94vw; max-height: 92vh; border-radius: 8px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 12%; transform: translateX(-50%) translateY(20px);
  background: rgba(22,32,58,.95); border: 1px solid var(--line); color: var(--txt);
  padding: 10px 22px; border-radius: 24px; font-size: 14px; z-index: 300;
  opacity: 0; pointer-events: none; transition: all .25s; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(224,86,140,.5); }

/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 手机适配 ---------- */
@media (max-width: 700px) {
  .main-page { position: relative; }
  .sidebar { width: 100%; min-width: 0; border-right: none; }
  .chat-area {
    position: fixed; inset: 0; z-index: 50; display: none;
  }
  body.mobile-chat .chat-area { display: flex; }
  .back-btn { display: block; }
  .msg-col { max-width: 78%; }
  .bubble.img img { max-width: min(260px, 66vw); }
  .login-card { padding: 32px 24px; }
}
