:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-soft: #dbeafe;
  --bg: #f5f7fb;
  --card: #ffffff;
  --border: #e6eaf2;
  --text: #1e293b;
  --muted: #6b7a90;
  --danger: #ef4444;
  --success: #10b981;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(37, 99, 235, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  transition: background .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--primary-light); color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #eff6ff 0%, #f5f7fb 45%, #e0ecff 100%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
}
.auth-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800;
  margin: 0 auto 16px;
}
.auth-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-switch a { font-weight: 600; cursor: pointer; }
.auth-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }

.oauth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0; color: var(--muted); font-size: 12px;
}
.oauth-divider::before, .oauth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.oauth-btns { display: flex; flex-direction: column; gap: 10px; }
.btn-qq { background: #e8f2ff; color: #1e6fd9; }
.btn-qq:hover { background: #d7e9ff; }
.btn-wechat { background: #eafaf1; color: #0e9f6e; }
.btn-wechat:hover { background: #d7f5e6; }

/* ---------- 聊天页 ---------- */
.chat-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-head {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-head .dot {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
}
.sidebar-head .name { font-weight: 700; }
.sidebar-head .who { font-size: 12px; color: var(--muted); }
.online-list { flex: 1; overflow-y: auto; padding: 10px; }
.online-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; font-size: 14px;
}
.online-item:hover { background: var(--primary-light); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.online-item .me-tag { font-size: 11px; color: var(--muted); }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.sidebar-foot .btn { flex: 1; padding: 9px; font-size: 13px; }

.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-head {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.chat-head .title { font-weight: 700; font-size: 16px; }
.chat-head .count { font-size: 13px; color: var(--muted); }
.chat-head .count b { color: var(--primary); }

.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 78%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { flex-shrink: 0; }
.msg-body { display: flex; flex-direction: column; gap: 4px; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.msg.mine .msg-meta { flex-direction: row-reverse; }
.msg-nick { font-weight: 600; color: var(--text); }
.msg-bubble {
  padding: 10px 14px; border-radius: 14px; background: #fff;
  border: 1px solid var(--border); font-size: 14px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
}
.msg.mine .msg-bubble {
  background: var(--primary); color: #fff; border-color: var(--primary);
  border-top-right-radius: 4px;
}
.msg:not(.mine) .msg-bubble { border-top-left-radius: 4px; }
.sys-tip { text-align: center; color: var(--muted); font-size: 12px; }

.composer {
  padding: 14px 20px; background: #fff; border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-end;
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; font-family: inherit; outline: none;
  max-height: 120px; line-height: 1.5; color: var(--text);
}
.composer textarea:focus { border-color: var(--primary); }
.composer .btn { height: 44px; padding: 0 22px; }

/* ---------- 后台 ---------- */
.admin-wrap { min-height: 100vh; padding: 24px; max-width: 1100px; margin: 0 auto; }
.admin-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.admin-top h1 { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.admin-top h1 .dot { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-grid .card { padding: 22px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card-title .badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge-on { background: #d1fae5; color: #059669; }
.badge-off { background: #f1f5f9; color: var(--muted); }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; width: 44px; height: 24px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #cbd5e1; border-radius: 20px; transition: .2s; }
.switch .track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(20px); }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table td .btn { padding: 5px 12px; font-size: 12px; border-radius: 7px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.tag-admin { background: #e0ecff; color: var(--primary); }
.tag-user { background: #f1f5f9; color: var(--muted); }
.tag-banned { background: #fee2e2; color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.saved-tip { color: var(--success); font-size: 13px; font-weight: 600; }

@media (max-width: 860px) {
  .sidebar { width: 200px; }
  .admin-grid { grid-template-columns: 1fr; }
  .msg { max-width: 90%; }
}
