/* ==========================================================================
   轻聊 chateasy · 样式表
   参考截图：深色 QQ 风格 —— 顶栏搜索、会话卡片流、底部标签栏、气泡聊天页
   ========================================================================== */

:root {
  --brand: #12b7f5;
  --brand-d: #0aa5e0;
  --grad: linear-gradient(135deg, #12b7f5 0%, #3b6bff 100%);
  --bg: #0e1116;
  --bg-2: #141920;
  --card: #1b2027;
  --card-2: #21262e;
  --line: #262c35;
  --line-2: #333a45;
  --text: #cfd4db;
  --text-2: #98a0ab;
  --text-3: #6d7580;
  --red: #ff6b6b;
  --green: #3ec98a;
  --bubble-me: linear-gradient(135deg, #12b7f5, #2f7ff0);
  --bubble-them: #262c36;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .28);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* 浅色主题 */
html[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-2: #eceff3;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --line: #e6e9ef;
  --line-2: #d9dde3;
  --text: #1a1a1a;
  --text-2: #8a909c;
  --text-3: #b3b8c2;
  --red: #fa5151;
  --green: #1fa463;
  --bubble-me: linear-gradient(135deg, #12b7f5, #2f7ff0);
  --bubble-them: #ffffff;
  --shadow-sm: 0 2px 8px rgba(56, 130, 255, .07);
  --shadow-lg: 0 20px 60px rgba(40, 90, 190, .18);
  color-scheme: light;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
button { font-family: inherit; }
svg { display: block; }

/* ---------- 启动错误 ---------- */
.boot-error {
  background: #3a1f22;
  color: #ff9d9d;
  border-bottom: 1px solid #5a2b30;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

/* ==========================================================================
   登录 / 注册
   ========================================================================== */
.auth-view {
  position: relative;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(120% 65% at 10% -6%, rgba(18, 183, 245, .2) 0%, rgba(18, 183, 245, 0) 60%),
    linear-gradient(160deg, #16202e, #101722 55%, #16202e);
}
.lg-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.lg-glow { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; }
.lg-glow.g1 { width: 280px; height: 280px; left: -90px; top: 6%; background: #7fd8ff; animation: lgFloat 9s ease-in-out infinite; }
.lg-glow.g2 { width: 300px; height: 300px; right: -110px; top: 40%; background: #8f7fff; animation: lgFloat 11s ease-in-out infinite reverse; }
.lg-glow.g3 { width: 240px; height: 240px; right: 22%; bottom: -80px; background: #3ad3b0; animation: lgFloat 13s ease-in-out infinite; }
@keyframes lgFloat {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(0, -22px, 0); }
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 390px;
  padding: 34px 30px 30px;
  background: rgba(24, 30, 40, .86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(120, 160, 220, .16);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}
.login-brand { text-align: center; padding-bottom: 22px; }
.login-title {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: 8px;
  text-indent: 8px;
  background: linear-gradient(120deg, #12b7f5 0%, #3b6bff 50%, #7a5cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 16px rgba(58, 140, 255, .38));
}
.login-sub { margin-top: 10px; font-size: 11px; letter-spacing: 3px; color: #7f8b9c; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(120, 160, 220, .14);
}
.tabs button {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #8b97a8;
  font-size: 15px;
  cursor: pointer;
  transition: .22s;
}
.tabs button.active {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, rgba(18, 183, 245, .24), rgba(122, 92, 255, .18));
  box-shadow: 0 0 0 1px rgba(18, 183, 245, .3);
}

.auth-card input {
  width: 100%;
  height: 48px;
  margin-top: 12px;
  padding: 0 15px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, .05);
  color: var(--text);
  font-size: 15px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.auth-card input::placeholder { color: var(--text-3); }
.auth-card input:focus {
  outline: none;
  background: rgba(255, 255, 255, .08);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(18, 183, 245, .14);
}

.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-row button {
  flex: none;
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(18, 183, 245, .32);
  border-radius: 12px;
  background: rgba(18, 183, 245, .12);
  color: #6fd0ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}
.code-row button:hover { background: rgba(18, 183, 245, .2); }
.code-row button:disabled { opacity: .55; cursor: default; }

#auth-submit {
  width: 100%;
  height: 48px;
  margin-top: 20px;
  border: none;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(18, 140, 240, .32);
  transition: transform .15s, filter .2s;
}
#auth-submit:hover { filter: brightness(1.06); }
#auth-submit:active { transform: translateY(1px); }

.msg {
  margin-top: 12px;
  font-size: 13px;
  min-height: 16px;
  text-align: center;
  line-height: 1.5;
}
.msg:empty { display: none; }
.msg.is-err { color: var(--red); }
.msg.is-ok { color: var(--green); }
.msg.is-info { color: var(--brand); }

.auth-detail {
  margin-top: 10px;
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
  white-space: pre-wrap;
  color: #ffb4b4;
  background: rgba(150, 50, 50, .16);
  border: 1px solid rgba(200, 90, 90, .3);
  border-radius: 12px;
  word-break: break-word;
}
.auth-detail.hidden { display: none; }

/* ==========================================================================
   主界面框架
   ========================================================================== */
.app-view { display: flex; height: 100vh; }

.left-col {
  width: 344px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}

/* ---------- 顶栏 ---------- */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  background: var(--bg-2);
}
.avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  font-weight: 600;
  user-select: none;
  overflow: hidden;
}
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.xs { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 60px; height: 60px; font-size: 24px; }
.avatar.md { width: 46px; height: 46px; font-size: 18px; }
.avatar.v1 { background: linear-gradient(135deg, #12b7f5, #3b6bff); }
.avatar.v2 { background: linear-gradient(135deg, #7a5cff, #b36bff); }
.avatar.v3 { background: linear-gradient(135deg, #12a870, #6bd6a8); }
.avatar.v4 { background: linear-gradient(135deg, #ff6a9a, #ff9a6a); }
.avatar.v5 { background: linear-gradient(135deg, #c98a12, #f0c04a); }
.avatar.v6 { background: linear-gradient(135deg, #2f7ff0, #12b7f5); }

.search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .07);
  color: var(--text-3);
  transition: background .2s, box-shadow .2s;
}
.search:focus-within { background: rgba(255, 255, 255, .1); box-shadow: 0 0 0 1px rgba(18, 183, 245, .3); }
.search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search input::placeholder { color: var(--text-3); }

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  color: var(--text-2);
  cursor: pointer;
  transition: background .18s, color .18s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .13); color: var(--text); }
.icon-btn.ghost { background: transparent; }
.icon-btn.ghost:hover { background: rgba(255, 255, 255, .1); }

/* ---------- 视图容器 ---------- */
.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px 16px;
}
.view::-webkit-scrollbar { width: 6px; }
.view::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

/* ---------- 会话卡片流 ---------- */
.conv-list { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }

.conv-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 14px;
  background: var(--card);
  cursor: pointer;
  transition: background .16s, transform .12s;
  border: 1px solid transparent;
}
.conv-card:hover { background: var(--card-2); }
.conv-card:active { transform: scale(.99); }
.conv-card.active { background: var(--card-2); border-color: rgba(18, 183, 245, .35); }

.conv-avatar { position: relative; flex: none; }
.conv-avatar .unread {
  position: absolute;
  right: -2px;
  bottom: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card);
}

.conv-main { flex: 1; min-width: 0; }
.conv-row1 { display: flex; align-items: center; gap: 6px; }
.conv-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60%;
}
.conv-time { margin-left: auto; flex: none; font-size: 11px; color: var(--text-3); }
.conv-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.conv-preview {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-preview .at { color: var(--brand); }

/* 标签 */
.tag {
  flex: none;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(18, 183, 245, .16);
  color: #6fd0ff;
  letter-spacing: .02em;
}
.tag.official { background: rgba(18, 183, 245, .16); color: #6fd0ff; }
.tag.friend { background: rgba(18, 183, 245, .16); color: #6fd0ff; }
.tag.vip { background: linear-gradient(135deg, #ffb648, #ff7a2e); color: #fff; }
.tag.check {
  width: 14px;
  height: 14px;
  padding: 0;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

/* ---------- 联系人 / 我的 ---------- */
.panel { margin-bottom: 10px; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 8px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 700;
}
.plus {
  margin-left: auto;
  border: none;
  background: rgba(255, 255, 255, .09);
  color: var(--brand);
  width: 24px;
  height: 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: background .18s;
}
.plus:hover { background: rgba(18, 183, 245, .2); }

.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: none; }
.row-item > span:first-child { flex: 1; }
.row-val { color: var(--text-3); font-size: 13px; }
.row-btn {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.row-btn.danger { color: var(--red); }

.contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  cursor: pointer;
  transition: background .16s;
}
.contact-row:hover { background: var(--card-2); }
.contact-name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  background: var(--red);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}

.req-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: var(--card);
  font-size: 14px;
}
.req-item .contact-name { flex: 1; }
.req-item button {
  flex: none;
  border: none;
  background: var(--grad);
  color: #fff;
  padding: 5px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}

.empty { padding: 14px 6px; font-size: 13px; color: var(--text-3); }

.me-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 14px;
  margin-bottom: 10px;
  background: var(--card);
  border-radius: 14px;
}
.me-nick { font-size: 17px; font-weight: 700; }
.me-mail { margin-top: 4px; font-size: 12px; color: var(--text-3); }

/* 开关 */
.switch {
  position: relative;
  width: 44px;
  height: 25px;
  border-radius: 13px;
  border: none;
  background: var(--line-2);
  cursor: pointer;
  transition: background .2s;
}
.switch i {
  position: absolute;
  top: 3px; left: 3px;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch.on { background: var(--brand); }
.switch.on i { transform: translateX(19px); }

/* ---------- 底部标签栏 ---------- */
.tabbar {
  flex: none;
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  position: relative;
  border: none;
  background: transparent;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 0 8px;
  font-size: 11px;
  cursor: pointer;
  transition: color .18s;
}
.tab.on { color: var(--brand); }
.tab .dot {
  position: absolute;
  top: 6px;
  left: 50%;
  margin-left: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--bg-2);
}

/* ==========================================================================
   聊天页
   ========================================================================== */
.chat-page {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.chat-page::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 80% 0%, rgba(18, 183, 245, .05) 0%, rgba(18, 183, 245, 0) 70%);
}

.chat-top {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.chat-info { flex: 1; min-width: 0; }
.chat-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.chat-desc {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.chat-empty { margin: auto; text-align: center; color: var(--text-2); padding: 40px 20px; }
.chat-empty-icon { font-size: 42px; opacity: .5; }
.chat-empty-title { margin-top: 12px; font-size: 15px; font-weight: 600; color: var(--text); }
.chat-empty-sub { margin-top: 6px; font-size: 12px; color: var(--text-3); }

/* 消息行 */
.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: min(78%, 660px);
}
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.theirs { align-self: flex-start; }

.msg-col { min-width: 0; display: flex; flex-direction: column; }
.msg.mine .msg-col { align-items: flex-end; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px 5px;
  font-size: 11px;
  color: var(--text-3);
}
.msg-meta .mname { color: var(--text-2); }
.msg-meta .mtime { font-variant-numeric: tabular-nums; }

.bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  animation: msgIn .2s ease-out;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
.msg.theirs .bubble {
  background: var(--bubble-them);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.mine .bubble {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(18, 140, 240, .26);
}
.bubble .at { color: #7fd8ff; font-weight: 500; }
.msg.mine .bubble .at { color: #d8f4ff; }

/* 输入区 */
.composer {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, .08);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: background .2s, box-shadow .2s;
}
.composer input:focus { background: rgba(255, 255, 255, .12); box-shadow: 0 0 0 1px rgba(18, 183, 245, .28); }
.composer input::placeholder { color: var(--text-3); }
.composer input:disabled { background: rgba(255, 255, 255, .04); }
.send-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(18, 140, 240, .3);
  transition: transform .15s, filter .2s, opacity .2s;
}
.send-btn:hover:not(:disabled) { filter: brightness(1.08); }
.send-btn:active:not(:disabled) { transform: scale(.94); }
.send-btn:disabled { background: var(--line-2); color: var(--text-3); box-shadow: none; cursor: not-allowed; }

/* ==========================================================================
   弹窗 / 轻提示
   ========================================================================== */
.dlg-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(3px);
  animation: fadeIn .16s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dlg {
  width: min(340px, calc(100vw - 48px));
  padding: 22px 22px 18px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: dlgIn .2s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes dlgIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.dlg-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; color: var(--text); }
.dlg-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.dlg-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(18, 183, 245, .14); }
.dlg-actions { display: flex; gap: 10px; margin-top: 18px; }
.dlg-actions button {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 11px;
  font-size: 14px;
  cursor: pointer;
  transition: filter .18s, background .18s;
}
.dlg-cancel { background: rgba(255, 255, 255, .08); color: var(--text-2); }
.dlg-cancel:hover { background: rgba(255, 255, 255, .14); }
.dlg-ok { background: var(--grad); color: #fff; font-weight: 600; }
.dlg-ok:hover { filter: brightness(1.06); }

.toast {
  position: fixed;
  left: 50%;
  top: 28px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: 80vw;
  padding: 10px 18px;
  border-radius: 21px;
  font-size: 13px;
  color: #fff;
  background: rgba(45, 52, 62, .95);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  transition: opacity .26s, transform .26s;
}
.toast.ok { background: rgba(28, 160, 110, .95); }
.toast.err { background: rgba(226, 74, 74, .95); }

/* ==========================================================================
   响应式：窄屏切换为「列表 / 聊天」单页
   ========================================================================== */
@media (max-width: 820px) {
  .left-col { width: 100%; }
  .app-view { position: relative; }
  .chat-page {
    position: absolute;
    inset: 0;
    z-index: 20;
    transform: translateX(100%);
    transition: transform .24s cubic-bezier(.3, .8, .4, 1);
  }
  .app-view.chat-open .chat-page { transform: none; }
}
@media (min-width: 821px) {
  #btn-back { display: none; }
}

/* ==========================================================================
   顶栏加号菜单
   ========================================================================== */
.plus-wrap { position: relative; flex: none; }
.plus-menu {
  position: absolute;
  right: 0;
  top: 44px;
  z-index: 40;
  min-width: 176px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: dlgIn .16s cubic-bezier(.2, .9, .3, 1.1);
}
.pm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background .16s;
}
.pm-item:hover { background: var(--card-2); }
.pm-item svg { color: var(--text-2); flex: none; }

/* ==========================================================================
   联系人页：功能宫格
   ========================================================================== */
.grid-menu {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 4px;
  padding: 18px 12px 22px;
}
.gm-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: transform .12s;
}
.gm-item:active { transform: scale(.94); }
.gm-ico {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  color: #fff;
}
.gm-ico.v1 { background: linear-gradient(135deg, #2a3550, #1b2233); }
.gm-ico.v2 { background: linear-gradient(135deg, #2a3550, #1b2233); }
.gm-ico.v3 { background: linear-gradient(135deg, #2a3550, #1b2233); }
.gm-ico.v4 { background: linear-gradient(135deg, #2a3550, #1b2233); }
.gm-ico.v5 { background: linear-gradient(135deg, #2a3550, #1b2233); }
.gm-ico.v6 { background: linear-gradient(135deg, #2a3550, #1b2233); }
html[data-theme="light"] .gm-ico { background: linear-gradient(135deg, #f0f3f8, #e3e8f0); color: #4a5568; }

/* ==========================================================================
   联系人：字母分组
   ========================================================================== */
.contact-list { padding-bottom: 20px; }
.cl-letter {
  padding: 12px 8px 6px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 700;
  letter-spacing: .06em;
}
.cl-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .16s;
}
.cl-row:hover { background: var(--card); }
.cl-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cl-sign {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter-index {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px 5px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .25);
}
html[data-theme="light"] .letter-index { background: rgba(255, 255, 255, .7); }
.letter-index span {
  font-size: 9px;
  line-height: 1.5;
  color: var(--text-3);
  text-align: center;
  cursor: pointer;
}
.letter-index span:hover { color: var(--brand); }
#view-contact { position: relative; }

/* ==========================================================================
   抽屉：我的
   ========================================================================== */
.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(2px);
  animation: fadeIn .18s ease-out;
}
.me-drawer {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 46;
  width: 300px;
  max-width: 84vw;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 40px rgba(0, 0, 0, .45);
  transform: translateX(-100%);
  transition: transform .26s cubic-bezier(.3, .8, .4, 1);
  overflow-y: auto;
}
.me-drawer.open { transform: none; }

.md-cover { position: relative; flex: none; }
.md-cover-bg {
  height: 132px;
  background:
    radial-gradient(90% 90% at 20% 0%, rgba(18, 183, 245, .3) 0%, rgba(18, 183, 245, 0) 65%),
    radial-gradient(80% 80% at 90% 20%, rgba(122, 92, 255, .32) 0%, rgba(122, 92, 255, 0) 65%),
    linear-gradient(160deg, #1c2434, #141a26);
}
.md-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  margin-top: -26px;
  position: relative;
}
.md-profile .avatar { border: 3px solid var(--bg-2); }
.md-info { min-width: 0; }
.md-nick { font-size: 17px; font-weight: 700; color: var(--text); }
.md-mail { margin-top: 3px; font-size: 12px; color: var(--text-3); }

.md-stats {
  display: flex;
  margin: 16px 12px 14px;
  padding: 12px 0;
  background: var(--card);
  border-radius: 12px;
}
.md-stat { flex: 1; text-align: center; }
.md-stat b { display: block; font-size: 18px; color: var(--text); }
.md-stat span { display: block; margin-top: 3px; font-size: 12px; color: var(--text-3); }

.md-list { flex: 1; }
.md-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .16s;
}
.md-item:hover { background: var(--card); }
.md-ico {
  width: 30px;
  height: 30px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  color: #fff;
}
.md-ico.v3 { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.md-ico.v5 { background: linear-gradient(135deg, #00b894, #55efc4); }
.md-ico.v6 { background: linear-gradient(135deg, #0984e3, #74b9ff); }
.md-label { flex: 1; font-size: 15px; color: var(--text); }

.md-logout {
  flex: none;
  margin: 18px 16px 26px;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--red);
  font-size: 15px;
  cursor: pointer;
  transition: background .16s;
}
.md-logout:hover { background: rgba(250, 81, 81, .1); }

/* 头像按钮 */
.avatar-btn {
  flex: none;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  line-height: 0;
  transition: transform .15s;
}
.avatar-btn:active { transform: scale(.92); }

/* ==========================================================================
   联系人页：好友请求块 / 宫格配色
   ========================================================================== */
.fr-block {
  margin: 12px 12px 4px;
  padding: 10px 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.fr-title {
  padding: 4px 12px 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.fr-btn {
  flex: none;
  padding: 5px 14px;
  border: none;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .16s;
}
.fr-btn:hover { filter: brightness(1.08); }

.gm-ico.v1 { background: linear-gradient(135deg, #12b7f5, #3b6bff); }
.gm-ico.v2 { background: linear-gradient(135deg, #00b894, #55efc4); }
.gm-ico.v3 { background: linear-gradient(135deg, #fd79a8, #e84393); }
.gm-ico.v4 { background: linear-gradient(135deg, #fdcb6e, #f39c12); }
.gm-ico.v5 { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }
.gm-ico.v6 { background: linear-gradient(135deg, #74b9ff, #0984e3); }
html[data-theme="light"] .gm-ico { color: #fff; }
