/* ========== 全局 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --qq-blue: #2A9CF5;
  --qq-blue-dark: #1E7FD9;
  --qq-green: #95EC69;
  --bg-chat: #F5F6F7;
  --border: #E4E6EB;
  --text: #1F2329;
  --text-dim: #8A919F;
  --nav-w: 64px;
  --list-w: 260px;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: #EFF2F7;
  overflow: hidden;
}
button { cursor: pointer; font-family: inherit; }
.hidden { display: none !important; }

/* ========== 登录页 ========== */
.auth-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #D8ECFF 0%, #F0F7FF 40%, #E3F5E8 100%);
  position: relative;
}
.auth-card {
  width: 380px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(42, 156, 245, 0.18);
  padding: 34px 36px 26px;
  text-align: center;
  position: relative;
  z-index: 2;
}
.auth-logo .logo-badge {
  width: 62px; height: 62px;
  margin: 0 auto 10px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2A9CF5, #55B8FF);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  box-shadow: 0 6px 16px rgba(42,156,245,.35);
}
.auth-logo h1 { font-size: 22px; color: var(--qq-blue-dark); letter-spacing: 2px; }
.auth-logo p { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.auth-tabs { display: flex; margin: 24px 0 18px; border-bottom: 2px solid var(--border); }
.tab-btn {
  flex: 1; background: none; border: none;
  padding: 10px 0; font-size: 15px; color: var(--text-dim);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab-btn.active { color: var(--qq-blue); border-bottom-color: var(--qq-blue); font-weight: 600; }
.auth-form { text-align: left; }
.input-group {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  background: #FBFBFD;
  transition: border-color .2s, box-shadow .2s;
}
.input-group:focus-within { border-color: var(--qq-blue); box-shadow: 0 0 0 3px rgba(42,156,245,.12); background: #fff; }
.input-icon { width: 38px; text-align: center; font-size: 15px; opacity: .7; }
.input-group input {
  flex: 1; border: none; outline: none; background: none;
  padding: 11px 10px 11px 0; font-size: 14px;
}
.auth-btn {
  width: 100%; padding: 11px;
  border: none; border-radius: 8px;
  background: linear-gradient(135deg, var(--qq-blue), var(--qq-blue-dark));
  color: #fff; font-size: 15px; letter-spacing: 6px; font-weight: 600;
  margin-top: 6px;
  transition: transform .1s, box-shadow .2s;
  box-shadow: 0 4px 12px rgba(42,156,245,.3);
}
.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(42,156,245,.4); }
.auth-btn:active { transform: translateY(0); }
.auth-tip { min-height: 20px; margin-top: 14px; font-size: 13px; color: #E5484D; }
.auth-footer {
  position: absolute; bottom: 24px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: #9AA6B5;
}

/* ========== 主界面布局 ========== */
.main-screen {
  height: 100vh;
  display: flex;
  background: #fff;
}

/* 左侧导航栏 */
.nav-bar {
  width: var(--nav-w);
  background: linear-gradient(180deg, #2A9CF5, #1E7FD9);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0;
  gap: 10px;
  flex-shrink: 0;
}
.nav-logout-top {
  width: 42px; height: 42px; border-radius: 10px;
  border: none; background: rgba(255,255,255,.12);
  font-size: 17px; color: #D8E8FF;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
  margin-bottom: 2px; flex-shrink: 0;
}
.nav-logout-top:hover { background: rgba(255,255,255,.25); }
.nav-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.6);
  margin-bottom: 6px;
}
.nav-btns { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nav-btn {
  width: 42px; height: 42px; border-radius: 10px;
  border: none; background: rgba(255,255,255,.12);
  font-size: 19px; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
}
.nav-btn:hover { background: rgba(255,255,255,.25); }
.nav-btn.active { background: rgba(255,255,255,.32); }
.nav-bottom { display: flex; flex-direction: column; }
.nav-btn#nav-logout { font-size: 17px; color: #D8E8FF; }

/* 会话列表 */
.list-panel {
  width: var(--list-w);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: #FBFCFE;
  flex-shrink: 0;
}
.list-header { padding: 14px 12px 8px; border-bottom: 1px solid var(--border); }
.me-box { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.me-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 19px; font-weight: 700;
}
.me-info .me-nick { font-size: 15px; font-weight: 600; }
.me-status { font-size: 12px; color: #52C41A; }
.search-box input {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 16px;
  outline: none; font-size: 13px; background: #F0F2F5;
}
.search-box input:focus { border-color: var(--qq-blue); background: #fff; }
.list-tabs { display: flex; padding: 0 12px; border-bottom: 1px solid var(--border); }
.lt {
  flex: 1; text-align: center; padding: 10px 0;
  font-size: 14px; color: var(--text-dim); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.lt.active { color: var(--qq-blue); border-bottom-color: var(--qq-blue); font-weight: 600; }
.list-body { flex: 1; overflow-y: auto; padding: 6px 0; }
.list-body::-webkit-scrollbar, .chat-messages::-webkit-scrollbar { width: 6px; }
.list-body::-webkit-scrollbar-thumb, .chat-messages::-webkit-scrollbar-thumb { background: #D3D9E0; border-radius: 3px; }

/* 会话项 */
.conv-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; cursor: pointer;
  position: relative;
  transition: background .12s;
}
.conv-item:hover { background: #F0F4F9; }
.conv-item.active { background: #E4F1FE; }
.conv-item .c-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; font-weight: 600;
  position: relative;
}
.c-avatar .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #fff;
}
.c-avatar .dot.on { background: #52C41A; }
.c-avatar .dot.off { background: #C4C9D0; }
.conv-item .c-body { flex: 1; min-width: 0; }
.conv-item .c-top { display: flex; justify-content: space-between; align-items: center; }
.conv-item .c-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .c-time { font-size: 11px; color: var(--text-dim); }
.conv-item .c-preview { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-item .c-badge {
  position: absolute; right: 10px; bottom: 12px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #F5484D; color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
}
.section-title {
  padding: 10px 14px 4px; font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}

/* 聊天区 */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-chat); }
.chat-header {
  height: 58px; padding: 0 20px;
  display: flex; flex-direction: column; justify-content: center;
  background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
  z-index: 3;
}
.chat-title { font-size: 16px; font-weight: 600; }
.chat-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg-row { display: flex; gap: 10px; align-items: flex-start; max-width: 78%; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 600;
}
.msg-main { display: flex; flex-direction: column; gap: 3px; }
.msg-meta { font-size: 11px; color: var(--text-dim); padding: 0 2px; }
.msg-row.mine .msg-meta { text-align: right; }
.msg-bubble {
  padding: 9px 13px; border-radius: 8px;
  font-size: 14px; line-height: 1.55;
  word-break: break-word; white-space: pre-wrap;
  position: relative;
}
.msg-row:not(.mine) .msg-bubble {
  background: #fff; border: 1px solid var(--border);
  border-top-left-radius: 2px;
}
.msg-row.mine .msg-bubble {
  background: var(--qq-green);
  border-top-right-radius: 2px;
}
.msg-time {
  text-align: center; font-size: 11px; color: #B8C0CC;
  padding: 4px 0 2px;
}
.sys-msg {
  align-self: center; font-size: 12px; color: #9AA6B5;
  background: rgba(0,0,0,.04); padding: 4px 12px; border-radius: 10px;
}

/* 输入区 */
.chat-input-area {
  background: #fff; border-top: 1px solid var(--border);
  padding: 8px 16px 12px;
}
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tool-btn {
  width: 30px; height: 30px; border: none; background: none;
  font-size: 17px; border-radius: 6px;
}
.tool-btn:hover { background: #F0F2F5; }
.tool-hint { font-size: 11px; color: #B8C0CC; margin-left: auto; }
#chat-input {
  width: 100%; border: none; outline: none; resize: none;
  font-size: 14px; font-family: inherit; line-height: 1.5;
}
.send-row { display: flex; justify-content: flex-end; margin-top: 4px; }
.send-btn {
  padding: 7px 22px; border: none; border-radius: 6px;
  background: var(--qq-blue); color: #fff; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.send-btn:hover { background: var(--qq-blue-dark); }

/* 表情面板 */
.emoji-panel {
  position: fixed; bottom: 210px; right: 40px;
  width: 300px; background: #fff; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  border: 1px solid var(--border);
  padding: 10px; z-index: 99;
}
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-grid span {
  font-size: 20px; text-align: center; padding: 5px 0;
  border-radius: 6px; cursor: pointer;
}
.emoji-grid span:hover { background: #F0F2F5; }

/* 小屏适配 */
@media (max-width: 720px) {
  .list-panel { width: 220px; }
}

/* ========== 我的资料弹窗 ========== */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 30, 50, 0.45);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-card {
  width: 440px; max-height: 88vh; overflow-y: auto;
  background: #fff; border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  animation: modalIn .18s ease-out;
}
@keyframes modalIn {
  from { transform: translateY(14px) scale(.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  width: 28px; height: 28px; border: none; border-radius: 50%;
  background: #F0F2F5; color: #5A6472; font-size: 13px;
}
.modal-close:hover { background: #E4E7EC; }
.modal-body { padding: 18px 20px; }
.modal-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px 18px;
}

/* 对方资料弹窗状态 */
.user-status { font-size: 12px; margin-top: 2px; }
.user-status.on { color: #3BB36B; }
.user-status.off { color: #B8C0CC; }

/* 资料头部 */
.profile-top { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-avatar-lg {
  width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
}
.profile-top-info .pt-name { font-size: 18px; font-weight: 700; }
.profile-top-info .pt-id { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.profile-top-info .pt-time { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.section-label {
  font-size: 13px; font-weight: 600; color: var(--text-dim);
  margin: 14px 0 8px;
}
.profile-tip { min-height: 18px; padding: 0 20px 8px; font-size: 13px; color: #E5484D; text-align: center; }

/* 头像选择网格 */
.avatar-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px;
  max-height: 150px; overflow-y: auto; padding: 2px;
}
.avatar-item {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; color: #fff; cursor: pointer;
  border: 3px solid transparent; box-sizing: border-box;
  transition: transform .1s, border-color .15s;
}
.avatar-item:hover { transform: scale(1.1); }
.avatar-item.selected { border-color: var(--qq-blue); box-shadow: 0 0 0 2px rgba(42,156,245,.25); }

/* 设置开关 */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 2px;
}
.setting-name { font-size: 14px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #D3D9E0; border-radius: 12px;
  transition: background .2s;
}
.slider::before {
  content: ""; position: absolute; width: 20px; height: 20px;
  left: 2px; top: 2px; border-radius: 50%;
  background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--qq-blue); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* 按钮 */
.btn-primary {
  padding: 9px 22px; border: none; border-radius: 7px;
  background: var(--qq-blue); color: #fff; font-size: 14px; font-weight: 600;
}
.btn-primary:hover { background: var(--qq-blue-dark); }
.btn-danger {
  padding: 9px 18px; border: 1px solid #F0D2D4; border-radius: 7px;
  background: #fff; color: #E5484D; font-size: 13px;
}
.btn-danger:hover { background: #FEF1F1; }
/* ========== 手机端适配（仿手机QQ） ========== */
.mobile-tabs { display: none; }

@media (max-width: 720px) {
  /* --- 登录页 --- */
  .auth-card { width: 92vw; max-width: 400px; padding: 28px 22px 20px; }
  .auth-logo .logo-badge { width: 56px; height: 56px; font-size: 30px; }
  .auth-logo h1 { font-size: 20px; }
  .input-group input { padding: 12px 10px 12px 0; font-size: 15px; }
  .auth-btn { padding: 13px; font-size: 16px; }

  /* --- 主界面：隐藏桌面左导航，改为底部 tab --- */
  .nav-bar { display: none; }
  .main-screen { flex-direction: column; }

  /* 列表面板全屏（底部留出 tab 栏高度） */
  .list-panel {
    width: 100%; height: 100vh; flex: 1;
    border-right: none;
    padding-bottom: 56px; /* tab 栏高度 */
  }
  .list-header { padding: 12px 12px 8px; }
  .me-box { margin-bottom: 10px; }

  /* 底部 tab 栏 */
  .mobile-tabs {
    display: flex; position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 56px; z-index: 60;
    background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mtab {
    flex: 1; border: none; background: none;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; color: var(--text-dim);
    font-size: 11px; padding: 4px 0;
  }
  .mtab .mtab-icon { font-size: 21px; line-height: 1; }
  .mtab.active { color: var(--qq-blue); }
  .mtab:active { background: #F5F7FA; }

  /* 聊天面板：全屏覆盖，进入聊天时显示 */
  .chat-panel {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    z-index: 70; display: none;
  }
  body.mobile-chat .chat-panel { display: flex; }
  body.mobile-chat .mobile-tabs { display: none; }

  /* 聊天头部：返回按钮 + 标题 */
  .chat-header {
    flex-direction: row; align-items: center; gap: 4px;
    padding: 0 12px 0 2px; height: 54px;
  }
  .back-btn {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    border: none; background: #F0F2F5; border-radius: 50%;
    font-size: 22px; color: #5A6472; line-height: 1;
  }
  .back-btn:active { background: #E4E7EC; }
  .chat-header-text { min-width: 0; }
  .chat-title { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* 消息区 */
  .chat-messages { padding: 14px 12px; gap: 12px; padding-bottom: 90px; }
  .msg-row { max-width: 85%; }
  .msg-avatar { width: 34px; height: 34px; font-size: 14px; }
  .msg-bubble { padding: 8px 11px; font-size: 14px; }

  /* 输入区固定在聊天面板底部 */
  .chat-input-area { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .send-btn { padding: 8px 24px; }

  /* 表情面板 */
  .emoji-panel { right: 8px; left: 8px; width: auto; bottom: 100px; }
  .emoji-grid { grid-template-columns: repeat(6, 1fr); }
  .emoji-grid span { font-size: 24px; padding: 7px 0; }

  /* 我的资料弹窗 */
  .modal-card { width: 94vw; max-height: 92vh; }
  .modal-body { padding: 14px 16px; }
  .avatar-grid { grid-template-columns: repeat(6, 1fr); }
  .avatar-item { width: 40px; height: 40px; font-size: 19px; }
}

/* 桌面端：隐藏返回按钮 */
@media (min-width: 721px) {
  .back-btn { display: none; }
}

/* 自定义图片头像 */
.c-avatar, .msg-avatar, .me-avatar, .nav-avatar, .profile-avatar-lg {
  overflow: hidden;
}
.c-avatar img, .msg-avatar img, .me-avatar img, .nav-avatar img, .profile-avatar-lg img {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; display: block;
}
