/* ---------- 基础 ---------- */
:root {
  /* 浅色（默认，像 QQ） */
  --bg: #f4f4f7;
  --bg-rail: #ffffff;
  --bg-side: #ffffff;
  --bg-chat: #f7f7fa;
  --bg-input: #f0f0f4;
  --bg-hover: #eeeef3;
  --bg-active: #e4e4ec;
  --line: #e6e6ec;
  --text: #17171c;
  --text-dim: #565667;
  --text-mute: #9292a1;
  --accent: #4f7cff;
  --accent-dim: #3a5fd0;
  --danger: #e5484d;
  --ok: #26a17b;
  --bubble-me: #4f7cff;
  --bubble-other: #ffffff;
  --bg-panel: #ffffff;
  --bg-modal: #ffffff;
  --bg-toast: #ffffff;
  --shadow: 0 10px 30px rgba(20, 20, 40, .12);
  --shadow-strong: 0 20px 50px rgba(20, 20, 40, .18);
  --radius: 10px;
  /* 底部悬浮导航 */
  --tabbar-bg: rgba(255, 255, 255, .78);
  --tabbar-line: rgba(228, 228, 238, .9);
  --tabbar-shadow: 0 12px 34px rgba(24, 24, 48, .14), 0 2px 8px rgba(24, 24, 48, .06);
  --tab-fg: #4a4a58;
  --tab-accent: #7a5cff;
  --tab-bubble: rgba(122, 92, 255, .13);
}

[data-theme="dark"] {
  --bg: #10101a;
  --bg-rail: #0b0b12;
  --bg-side: #16161f;
  --bg-chat: #1a1a24;
  --bg-input: #22222e;
  --bg-hover: #23232f;
  --bg-active: #2b2b3a;
  --line: #262633;
  --text: #e8e8ef;
  --text-dim: #9a9aad;
  --text-mute: #6c6c80;
  --accent: #4f7cff;
  --accent-dim: #3a5fd0;
  --danger: #ef5350;
  --ok: #3ecf8e;
  --bubble-me: #4f7cff;
  --bubble-other: #262633;
  --bg-panel: #22222f;
  --bg-modal: #1c1c27;
  --bg-toast: #2a2a3a;
  --shadow: 0 10px 28px rgba(0, 0, 0, .55);
  --shadow-strong: 0 24px 60px rgba(0, 0, 0, .6);
  --tabbar-bg: rgba(26, 26, 38, .82);
  --tabbar-line: rgba(255, 255, 255, .07);
  --tabbar-shadow: 0 12px 34px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .3);
  --tab-fg: #b9b9c9;
  --tab-accent: #9a86ff;
  --tab-bubble: rgba(154, 134, 255, .16);
}

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

/*
 * 必须放在最前面且带 !important。
 * HTML 的 hidden 属性只靠浏览器默认样式 display:none 生效，
 * 优先级比 .modal-mask { display:grid } 这类类选择器低，会被压掉。
 * 不写这条，弹窗会永远盖在最上层，整个页面点不动。
 */
[hidden] { display: none !important; }

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; fill: currentColor; display: block; }

/* ---------- 登录 ---------- */
.auth-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(79, 124, 255, .18) 0%, transparent 60%),
    radial-gradient(700px 500px at 90% 100%, rgba(138, 92, 255, .16) 0%, transparent 55%),
    var(--bg);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(24, 24, 34, .82);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 32px 28px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
}

.auth-logo { font-size: 40px; text-align: center; line-height: 1; }
.auth-title { font-size: 24px; text-align: center; margin-top: 10px; letter-spacing: .5px; }
.auth-sub { text-align: center; color: var(--text-mute); font-size: 12.5px; margin-top: 6px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: 10px;
  padding: 4px;
  margin: 22px 0 18px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 13.5px;
  transition: .15s;
}
.auth-tab.active { background: var(--accent); color: #fff; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--text-mute); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 9px;
  outline: none;
  transition: .15s;
}
.field input:focus { border-color: var(--accent); background: var(--bg-hover); }

.btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  background: var(--accent);
  border-radius: 9px;
  font-weight: 600;
  transition: .15s;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:disabled { opacity: .55; cursor: default; }

.auth-error {
  background: rgba(239, 83, 80, .12);
  border: 1px solid rgba(239, 83, 80, .35);
  color: #ff8b88;
  font-size: 12.5px;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

/* 长按消息时别弹系统自带的「保存图片」菜单 */
.bubble, .bubble img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.bubble img {
  cursor: pointer;
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* 聊天设置：从左往右滑出 */
.modal-mask.slide-right {
  padding: 0;
  /* 竖向拉满，横向贴右边 */
  place-items: stretch end;
  background: rgba(0, 0, 0, .28);
}
.modal-mask.slide-right .modal {
  width: 90%;
  max-width: 420px;
  height: 100%;
  max-height: none;
  border-radius: 16px 0 0 16px;
  border: none;
  border-left: none;
  animation: slide-in-right .22s ease;
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.modal-mask.slide-right .modal-head { padding: 16px 14px; }
.modal-mask.slide-right .modal-body { padding: 0 0 20px; }

.set-group {
  background: var(--bg-side);
  margin: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.set-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.set-row:last-child { border-bottom: none; }
.set-row-label { flex: 1; min-width: 0; }
.set-row-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }
.set-person { display: flex; align-items: center; gap: 12px; padding: 16px; }
.set-person-avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 600; overflow: hidden;
}
.set-person-avatar img { width: 100%; height: 100%; object-fit: cover; }
.set-person-name { font-size: 17px; font-weight: 600; }
.set-person-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.search-hit {
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.search-hit:active { background: var(--bg-hover); }
.search-hit-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.search-hit-name { font-size: 13px; font-weight: 600; }
.search-hit-time { font-size: 11px; color: var(--text-mute); }
.search-hit-text { font-size: 13px; color: var(--text-dim); word-break: break-word; }

/* 跳转到的消息闪一下 */
.msg-flash .bubble {
  animation: msg-flash 1.8s ease;
}
@keyframes msg-flash {
  0% { box-shadow: 0 0 0 3px rgba(79, 124, 255, .55); }
  100% { box-shadow: 0 0 0 3px rgba(79, 124, 255, 0); }
}

/* 开关 */
.switch {
  width: 46px; height: 26px; border-radius: 13px; flex: none;
  background: var(--bg-active); position: relative; transition: background .18s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .18s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

/* 全屏弹窗：手机上动态、个人空间铺满整屏，不像个小窗 */
.modal-mask.fullscreen {
  padding: 0;
  background: var(--bg);
  backdrop-filter: none;
  place-items: stretch;
}
.modal-mask.fullscreen .modal {
  max-width: none;
  max-height: 100%;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  background: var(--bg-chat);
  box-shadow: none;
}
.modal-mask.fullscreen .modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 761px) {
  /* 电脑上还是留点边距，别糊满屏 */
  .modal-mask.fullscreen { padding: 24px; place-items: center; }
  .modal-mask.fullscreen .modal { max-width: 720px; height: 86vh; border-radius: 16px; border: 1px solid var(--line); }
}

/* 手机顶部用户栏 + 底部导航（桌面不显示） */
.mobile-userbar, .mobile-tabbar { display: none; }

.mobile-userbar {
  align-items: center;
  gap: 10px;
  padding: 10px 12px 2px;
}
.mobile-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}
.mobile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mobile-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 悬浮胶囊底部导航：浅色半透明容器，选中项浮起大气泡 */
.mobile-tabbar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  align-items: stretch;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--tabbar-line);
  border-radius: 30px;
  background: var(--tabbar-bg);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: var(--tabbar-shadow);
  overflow: visible;
  /* 不设这条，横向拖动会被当成滚动手势，浏览器发 pointercancel 把按压中断 */
  touch-action: none;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 2px 8px;
  border-radius: 26px;
  font-size: 10.5px;
  line-height: 1.2;
  color: var(--tab-fg);
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: color .2s ease, transform .2s cubic-bezier(.2, .8, .3, 1);
  -webkit-tap-highlight-color: transparent;
}
.tab-item > svg,
.tab-item > span,
.tab-item > .tab-badge { position: relative; z-index: 1; }
.tab-item svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .24s cubic-bezier(.2, .8, .3, 1);
}
/* 选中气泡改成一块会滑动的板子，位置由 JS 算 */
.tab-slider {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 0;
  border-radius: 26px;
  background: var(--tab-bubble);
  z-index: 0;
  pointer-events: none;
  /* 弹簧手感：冲过头一点再回来 */
  transition: left .34s cubic-bezier(.34, 1.4, .5, 1),
              width .34s cubic-bezier(.34, 1.4, .5, 1),
              transform .18s ease;
}
/* 按下去的时候板子自己先胖一点 */
/* 板子必须跟按钮同步放大 —— 只放大按钮的话，看到的是字变大、灰底不动 */
.tab-slider.press {
  transform: translateY(-2px) scale(1.16);
  transition: transform .16s cubic-bezier(.34, 1.5, .5, 1);
}
.tab-slider.drag { transition: none; }

.tab-item.active {
  color: var(--tab-accent);
}
.tab-item.active svg { transform: scale(1.08); }
.tab-item.active span { font-weight: 600; }

/* 按住时整个按钮弹起来 */
.tab-item.press {
  transform: translateY(-2px) scale(1.16);
  transition: transform .16s cubic-bezier(.34, 1.5, .5, 1);
}
.tab-item.press svg { transform: scale(1.1); }
/* 松手回弹，带一点过冲 */
.tab-item.release {
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}
.tab-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  line-height: 15px;
  text-align: center;
  z-index: 2;
}

/* 用户资料详情页 */
.detail-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 30px 20px 26px;
  background: linear-gradient(135deg, #efe6ff 0%, #f7f2ff 55%, #eef4ff 100%);
}
.detail-av {
  width: 68px !important;
  height: 68px !important;
  font-size: 26px !important;
}
.detail-name-row { display: flex; align-items: center; gap: 8px; }
.detail-name { font-size: 20px; font-weight: 600; }
.detail-id { font-size: 12.5px; color: var(--text-mute); margin-top: 4px; }

.detail-rows { padding: 8px 20px; }
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  width: 82px;
  flex: none;
  font-size: 15px;
  color: var(--text-dim);
}
.detail-value {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-actions {
  position: sticky;
  bottom: 0;
  margin-top: 10px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  background: linear-gradient(to top, var(--bg-modal) 72%, transparent);
}
.detail-btn {
  min-width: 190px;
  padding: 13px 26px;
  border-radius: 26px;
  background: linear-gradient(135deg, #8a6cff, #6b52f0);
  color: #fff;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(107, 82, 240, .35);
}

/* 通用资料卡：别人的空间 / 聊天设置顶部 */
.profile-card {
  display: flex;
  gap: 14px;
  align-items: center;
}
.profile-card-av {
  width: 62px; height: 62px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 24px; font-weight: 600; overflow: hidden;
}
.profile-card-av img { width: 100%; height: 100%; object-fit: cover; }
.profile-card-info { flex: 1; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 8px; }
.profile-name { font-size: 18px; font-weight: 600; }
.profile-id { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.profile-stats {
  display: flex;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.profile-stats .stat { flex: 1; text-align: center; }
.profile-stats .stat-num { font-size: 20px; font-weight: 600; color: var(--text); }
.profile-stats .stat-label { font-size: 12px; color: var(--text-mute); margin-top: 4px; }

/* 我的资料：顶部横幅 + 资料/动态 标签 */
.profile-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px 12px;
}
.profile-banner {
  margin: 16px 16px 0;
  padding: 18px 18px 14px;
  background: var(--bg-modal);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.profile-card-top {
  display: flex;
  align-items: center;
  gap: 16px;
}
.profile-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-card-main .profile-name { font-size: 20px; }
.profile-sig-pill {
  align-self: flex-start;
  max-width: 100%;
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(229, 72, 77, .12);
  color: #e5484d;
  font-size: 12.5px;
  line-height: 1.35;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .profile-sig-pill {
  background: rgba(239, 83, 80, .16);
  color: #ff8b88;
}

/* 编辑资料的卡片列表（昵称/简介/外观/背景） */
.edit-card {
  background: var(--bg-modal);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.edit-row:last-child { border-bottom: none; }
.edit-label {
  width: 72px;
  flex: none;
  font-size: 14px;
  color: var(--text);
}
.edit-value { flex: 1; min-width: 0; display: flex; align-items: center; }
.edit-input {
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  font: inherit;
  font-size: 14px;
  color: var(--text-dim);
  padding: 0;
}
.edit-input::placeholder { color: var(--text-mute); }
.edit-muted { font-size: 13px; color: var(--text-mute); }
.edit-arrow { color: var(--text-mute); font-size: 17px; line-height: 1; }
.edit-seg {
  display: flex;
  gap: 6px;
  background: var(--bg-input);
  border-radius: 9px;
  padding: 3px;
}
.edit-seg-btn {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--text-dim);
  transition: .18s;
}
.edit-seg-btn.active {
  background: var(--bg-modal);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(20, 20, 40, .1);
}
.edit-swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.edit-swatch {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: var(--bg-chat);
  cursor: pointer;
  padding: 0;
}
.edit-swatch.active { border-color: var(--accent); }
.edit-link-btn { font-size: 13px; color: var(--accent); padding: 2px 4px; }
.edit-save { width: 100%; margin-top: 16px; padding: 13px; border-radius: 12px; }
/* 头像：可点，右下角带相机角标 */
.profile-av {
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 50%;
  cursor: pointer;
  transition: transform .18s ease;
}
.profile-av:active { transform: scale(.94); }
.profile-av.uploading { opacity: .5; pointer-events: none; }
.profile-av-cam {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-modal);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.profile-av-cam::after {
  content: '';
  width: 9px;
  height: 7px;
  border-radius: 2px;
  border: 1.4px solid #fff;
  box-sizing: border-box;
}
.profile-av-cam::before {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  border: 1px solid #fff;
  box-sizing: border-box;
}
.profile-head-name { display: flex; align-items: center; gap: 8px; }
.profile-head-sig {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pill-tabs {
  display: flex;
  gap: 6px;
  margin: 0 20px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg-input);
}
.pill-tab {
  flex: 1;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 13px;
  color: var(--tab-fg);
  text-align: center;
  position: relative;
  transition: color .2s ease, background .24s cubic-bezier(.2,.8,.3,1), transform .24s cubic-bezier(.2,.8,.3,1);
}
.pill-tab.active {
  color: var(--tab-accent);
  background: var(--tab-bubble);
  font-weight: 600;
}
.pill-pane { padding: 14px 20px 6px; }
.pill-pane .field { margin-bottom: 13px; }

/* 底部动作面板（像 QQ 点昵称弹的那种） */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: flex-end;
}
.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .38);
  opacity: 0;
  transition: opacity .22s ease;
}
.sheet-wrap.open .sheet-mask { opacity: 1; }
.action-sheet {
  position: relative;
  width: 100%;
  background: var(--bg-modal);
  border-radius: 16px 16px 0 0;
  padding: 0 0 calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.2, .8, .3, 1);
  box-shadow: 0 -8px 30px rgba(20, 20, 40, .2);
}
.action-sheet.open { transform: translateY(0); }
.sheet-grip {
  width: 34px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 8px auto 2px;
}
.sheet-title {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-mute);
  padding: 8px 20px 10px;
}
.sheet-item {
  display: block;
  width: 100%;
  padding: 15px 20px;
  font-size: 15px;
  text-align: center;
  color: var(--text);
  border-top: 1px solid var(--line);
  transition: background .12s;
}
.sheet-item:active { background: var(--bg-hover); }
.sheet-item.danger { color: var(--danger); }
.sheet-cancel {
  margin-top: 8px;
  border-top: none;
  color: var(--text-dim);
  background: var(--bg-input);
}

/* 手机侧滑抽屉 */
.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 264px;
  max-width: 82vw;
  z-index: 700;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  transform: translateX(-102%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  padding: 22px 12px 18px;
  will-change: transform;
}
.side-drawer.open { transform: translateX(0); }

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 690;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  transition: opacity .22s ease;
}
.drawer-mask.open { opacity: 1; }

.drawer-user {
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.drawer-row { display: flex; align-items: center; gap: 12px; }
.drawer-name-row { display: flex; align-items: center; gap: 8px; }
.lv-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ffb340, #ff7a45);
  color: #fff;
  font-weight: 600;
  line-height: 17px;
}
.drawer-stats {
  display: flex;
  margin-top: 16px;
  text-align: center;
}
.drawer-stats .stat { flex: 1; cursor: pointer; }
.drawer-stats .stat:active { opacity: .6; }
.drawer-stats .stat + .stat { border-left: 1px solid var(--line); }
.stat-num { font-size: 17px; font-weight: 600; }
.stat-label { font-size: 11px; color: var(--text-mute); margin-top: 3px; }
.drawer-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}
.drawer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.drawer-info { min-width: 0; }
.drawer-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.drawer-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
}
/* 设置 / 退出登录：并排贴底 */
.drawer-bottom {
  margin-top: auto;
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.drawer-bottom-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-dim);
  transition: background .15s;
}
.drawer-bottom-btn:active { background: var(--bg-active); }
.drawer-bottom-btn svg { width: 21px; height: 21px; fill: currentColor; }
/* 一个靠左、一个靠右，往两边再推开一点 */
#drawer-settings { align-items: flex-start; padding-left: 10px; }
#drawer-logout { align-items: flex-end; padding-right: 10px; }
.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
}
.drawer-item:active { background: var(--bg-active); }
.drawer-item svg { width: 20px; height: 20px; fill: var(--text-dim); flex: none; }
.drawer-item.danger { color: var(--danger); }
.drawer-item.danger svg { fill: var(--danger); margin-left: -2px; }

/* 抽屉只在手机上出现 */
@media (min-width: 761px) {
  .side-drawer, .drawer-mask { display: none !important; }
}

/* 兜底返回键：头上的返回键看不见时才出现 */
.float-back {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 500;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(18, 18, 28, .9);
  border: 1px solid var(--line);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}

/* 消息操作菜单 */
.msg-menu {
  position: fixed;
  z-index: 400;
  min-width: 112px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.msg-menu::backdrop { background: transparent; }
.msg-menu button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  text-align: left;
  border-radius: 7px;
  font-size: 14px;
}
.msg-menu button:hover { background: var(--bg-hover); }

/* 安装到桌面提示条 */
.install-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(79, 124, 255, .14);
  border: 1px solid rgba(79, 124, 255, .35);
}
.install-bar-text { flex: 1; font-size: 12px; line-height: 1.4; color: var(--text-dim); }
.install-bar-btn {
  flex: none; padding: 5px 14px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 12px;
}
.install-bar-close { flex: none; color: var(--text-mute); font-size: 16px; padding: 0 2px; }

/* ---------- 主布局 ---------- */
.app {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 62px 300px 1fr;
  /* 关键：行高必须被容器限死，否则图片一高就把整行撑出去，头被顶到屏幕外 */
  grid-template-rows: minmax(0, 1fr);
}

/* 左侧导航 */
.rail {
  background: var(--bg-rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 10px;
  gap: 6px;
  border-right: 1px solid var(--line);
}
.rail-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f7cff, #8a5cff);
  display: grid; place-items: center;
  font-weight: 600; font-size: 15px;
  margin-bottom: 10px;
  cursor: pointer;
  overflow: hidden;
  flex: none;
}
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }

.rail-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  color: var(--text-mute);
  transition: .15s;
}
.rail-btn:hover { background: var(--bg-hover); color: var(--text-dim); }
.rail-btn.active { background: var(--bg-active); color: var(--accent); }
.rail-spacer { flex: 1; }

.rail-badge {
  position: absolute;
  top: 3px; right: 3px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
}

/* 中间列表 */
.sidebar {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 10px;
}
.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 9px;
  width: 15px; height: 15px;
  color: var(--text-mute);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 8px 10px 8px 30px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-mute);
  transition: .15s;
  flex: none;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.list { flex: 1; overflow-y: auto; padding: 2px 6px 12px; }

.empty-hint {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--text-mute);
  font-size: 13px;
}

.btn-ghost {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
  transition: .15s;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

/* 列表项 */
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .12s;
  min-width: 0;
}
.item:hover { background: var(--bg-hover); }
.item.active { background: var(--bg-active); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  flex: none;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #4f7cff, #8a5cff);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.avatar.lg { width: 52px; height: 52px; font-size: 19px; }
.avatar.square { border-radius: 11px; }

.item-body { flex: 1; min-width: 0; }
.item-top { display: flex; align-items: baseline; gap: 6px; }
.item-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-time { font-size: 11px; color: var(--text-mute); flex: none; }
.item-preview {
  font-size: 12.5px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.badge {
  min-width: 17px; height: 17px;
  padding: 0 5px;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 17px;
  text-align: center;
  border-radius: 9px;
  flex: none;
}
.badge.mute { background: var(--text-mute); }

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--danger);
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: middle;
}

.online-dot {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--bg-side);
}

/* 分段控件 */
.seg {
  display: flex;
  gap: 3px;
  padding: 0 12px 10px;
  position: relative;
  /* 不加会被当成滚动手势，拖动时浏览器直接发 pointercancel */
  touch-action: none;
}
/* 跟底部 tab 同一套：一块会滑的板子 */
.seg-slider {
  position: absolute;
  left: 12px;
  top: 0;
  width: 0;
  height: 0;
  border-radius: 999px;
  background: var(--bg-active);
  z-index: 0;
  pointer-events: none;
  transition: left .34s cubic-bezier(.34, 1.4, .5, 1),
              width .34s cubic-bezier(.34, 1.4, .5, 1);
}
/* 板子跟着按钮一起放大，边缘才会一起动 */
.seg-slider.press {
  transform: translateY(-1px) scale(1.14);
  transition: transform .16s cubic-bezier(.34, 1.5, .5, 1);
}
.seg-slider.drag { transition: none; }
.seg-btn {
  flex: 1;
  padding: 9px 7px;
  font-size: 13px;
  color: var(--text-mute);
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  z-index: 1;
  background: transparent;
  touch-action: none;
  transition: color .2s ease, transform .2s cubic-bezier(.2, .8, .3, 1);
}
.seg-btn:hover { background: transparent; color: var(--text-dim); }
.seg-btn.active { background: transparent; color: var(--text); font-weight: 600; }
/* 按住弹起来，跟底部 tab 一个手感 */
.seg-btn:focus { outline: none; }
.seg-btn.press {
  transform: translateY(-1px) scale(1.14);
  transition: transform .16s cubic-bezier(.34, 1.5, .5, 1);
}
.seg-btn.release {
  transition: transform .38s cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- 聊天区 ---------- */
.chat {
  background: var(--bg-chat);
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.chat-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  /* 用 vh 不用 dvh：键盘弹出时这一层高度不变，背景不跳 */
  height: 100vh;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
}
.chat > :not(.chat-bg) { position: relative; z-index: 1; }

.chat-placeholder {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--text-mute);
}
.placeholder-logo { font-size: 52px; opacity: .35; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  min-height: 46px;
  box-sizing: border-box;
  background: var(--bg-chat);
  position: relative;
  z-index: 20;
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-head-sub { font-size: 11.5px; color: var(--text-mute); margin-top: 1px; }
.chat-head-sub.online { color: var(--ok); }
.chat-head-sub.offline { color: var(--text-mute); }
.chat-head-actions { display: flex; gap: 4px; }

/* 消息流 */
.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
  padding: 16px 18px 8px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}
.msg-flow { display: flex; flex-direction: column; gap: 3px; }

.load-more { text-align: center; padding-bottom: 14px; }

.msg {
  display: flex;
  gap: 9px;
  padding: 5px 0;
  max-width: 100%;
}
.msg.mine { flex-direction: row-reverse; }

.msg-col { display: flex; flex-direction: column; min-width: 0; max-width: min(560px, 76%); }
.msg.mine .msg-col { align-items: flex-end; }

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 3px;
  padding: 0 2px;
}
.msg.mine .msg-meta { flex-direction: row-reverse; }
.msg-sender { font-size: 12px; color: var(--text-dim); font-weight: 500; }
/* 群主 / 管理员在消息头的小标 */
.msg-role {
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  line-height: 1.5;
  flex: none;
}
.msg-role.owner { background: rgba(245, 166, 35, .18); color: #e0a125; }
.msg-role.admin { background: rgba(79, 124, 255, .16); color: #5b86ff; }
.msg-time { font-size: 10.5px; color: var(--text-mute); }
.msg-bot-tag {
  font-size: 9.5px;
  padding: 1px 5px;
  background: rgba(79, 124, 255, .18);
  color: #8aa6ff;
  border-radius: 4px;
  font-weight: 600;
}

.bubble {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bubble-other);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
  position: relative;
}
.msg.mine .bubble { background: var(--bubble-me); color: #fff; }

.bubble.at-me { box-shadow: inset 0 0 0 1.5px rgba(79, 124, 255, .55); }
.bubble.revoked { background: transparent !important; color: var(--text-mute); font-style: italic; font-size: 12px; }

.bubble .mention {
  color: #8aa6ff;
  font-weight: 500;
}
.msg.mine .bubble .mention { color: #dbe6ff; }
.bubble .mention.all { color: #ffb84d; font-weight: 600; }

.bubble img {
  max-width: 260px;
  max-height: 260px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}

.msg-time-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-mute);
  margin: 14px 0 6px;
}

/* 输入区 */
.composer {
  flex: none;
  border-top: 1px solid var(--line);
  padding: 10px 18px 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  position: relative;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
}
.composer-spacer { flex: 1; }
.composer-hint { font-size: 11px; color: var(--text-mute); }

.composer-input-wrap { position: relative; }

.emoji-popup {
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: 2px;
  padding: 8px;
  max-height: 200px;
}
.emoji-popup button {
  width: 34px; height: 34px;
  border: none; border-radius: 7px;
  background: transparent;
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.emoji-popup button:hover { background: var(--bg-hover); }
#composer-input {
  width: 100%;
  max-height: 160px;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color .15s;
}
#composer-input:focus { border-color: var(--accent); }

.composer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.btn-send {
  padding: 8px 22px;
  background: var(--accent);
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: .15s;
}
.btn-send:hover { background: var(--accent-dim); }
.btn-send:disabled { opacity: .45; cursor: default; }

.typing-hint {
  position: absolute;
  left: 18px;
  bottom: 3px;
  font-size: 11px;
  color: var(--text-mute);
  height: 14px;
}

/* @ 弹层 */
.at-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 5px;
  z-index: 20;
}
.at-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}
.at-item:hover, .at-item.sel { background: var(--bg-active); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  background: var(--bg-modal);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-strong);
}
.modal-head {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14.5px;
}
.modal-head > span { flex: 1; }
.modal-body { padding: 18px 20px 20px; overflow-y: auto; }

.modal-body .field:last-of-type { margin-bottom: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.btn-danger {
  padding: 8px 18px;
  background: rgba(239, 83, 80, .15);
  color: #ff8b88;
  border-radius: 8px;
  font-size: 13px;
}
.btn-danger:hover { background: rgba(239, 83, 80, .25); }
.btn-plain {
  padding: 8px 18px;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 13px;
}
.btn-plain:hover { background: var(--bg-active); }

/* Toast */
.toast-wrap {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  padding: 9px 18px;
  background: var(--bg-toast);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}
.toast.err { border-color: rgba(239, 83, 80, .45); color: #ff9b98; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* 图片查看器 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  display: grid;
  place-items: center;
  z-index: 300;
  cursor: zoom-out;
}
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 6px; }

/* 返回按钮：只在窄屏出现 */
#btn-chat-back { display: none; }

/* ---------- 窄屏 ---------- */
@media (max-width: 760px) {
  /* QQ 式布局：上面用户栏，中间内容，下面三个 tab */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }
  .rail { display: none; }
  .sidebar { grid-column: 1; grid-row: 1; min-height: 0; }
  .chat { display: none; grid-column: 1; grid-row: 1; min-height: 0; }
  .mobile-userbar { display: flex; }
  .mobile-tabbar { display: flex; }
  /* 悬浮在内容上方，列表底部留出空间不被盖住 */
  .list { padding-bottom: 96px; }
  /* 手机上这几个入口收进抽屉 */
  #btn-admin-users, #btn-settings, #btn-logout { display: none; }
  /* 加号挪到顶部用户栏，搜索行里那个就不用了 */
  .sidebar-head #btn-new { display: none; }
  /* 进了聊天就整屏，左栏和列表都让位 */
  .app.chat-open { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr); }
  .app.chat-open .rail { display: none; }
  .app.chat-open .sidebar { display: none; }
  .app.chat-open .mobile-tabbar { display: none; }
  .app.chat-open .chat { display: flex; grid-column: 1; }
  #btn-chat-back { display: inline-flex; align-items: center; justify-content: center; }
  .app.chat-open #btn-chat-back { display: inline-flex; align-items: center; justify-content: center; }
  .msg-col { max-width: 82%; }
  .chat-head { padding: 11px 12px; }
  .messages { padding: 12px 12px 6px; }
  .composer { padding: 8px 12px 12px; }
}

/* ---------------- 设置页 ---------------- */
.set-group-title {
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 4px 4px 8px;
}
.set-group-title:not(:first-child) { margin-top: 6px; }
.set-card {
  background: var(--bg-modal);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}
.set-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.set-row:last-child { border-bottom: none; }
.set-row:active { background: var(--bg-active); }
.set-main { flex: 1; min-width: 0; }
.set-name { font-size: 15px; color: var(--text); }
.set-sub {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.4;
}
.set-value { flex: none; font-size: 13.5px; color: var(--text-dim); }
.set-chev {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-dim);
  opacity: .55;
}
.set-row-danger {
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-modal);
  color: var(--danger);
  font-size: 15px;
  margin: 4px 0 6px;
}
.set-row-danger .set-main {
  flex: none;
  text-align: center;
  color: var(--danger);
}
.item-tag {
  flex: none;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-active);
  color: var(--text-dim);
}

/* 未读徽标上的 @ 提示 */
.badge.at { background: var(--accent); }
.badge-at {
  font-size: 9.5px;
  font-weight: 700;
  margin-right: 1px;
  opacity: .95;
}
/* 会话预览前的「有人@我」 */
.at-flag {
  color: var(--danger);
  font-weight: 600;
  margin-right: 4px;
}

/* 底部 Tab 徽标：有人@我 时变成 @ */
.tab-badge.at {
  background: var(--accent);
  font-weight: 700;
  min-width: 16px;
}

/* 未读数挂在头像右上角（QQ 那种） */
.avatar-box {
  position: relative;
  flex: none;
}
.badge-corner {
  position: absolute;
  top: -5px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-side);
  z-index: 2;
}
.badge-corner.mute { background: var(--text-mute); }
.badge-corner.at {
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--bg-side), 0 0 0 4px rgba(229, 72, 77, .18);
}

/* 提示音选择行的副标题 */
.item-sub {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: right;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 安装条淡出 */
.install-bar {
  transition: opacity .24s ease, transform .24s ease;
}
.install-bar.leaving {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

/* 关于里的更新提示 */
.update-tag {
  flex: none;
  font-size: 12px;
  color: var(--text-mute);
}
.update-tag.hot {
  color: var(--danger);
  font-weight: 600;
}

/* 会话长按菜单（像 QQ 那个小黑条） */
.conv-menu {
  position: fixed;
  z-index: 900;
  display: flex;
  background: #3b3b46;
  border-radius: 10px;
  /* 不能 hidden，否则箭头被裁掉 */
  overflow: visible;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}
.conv-menu button:first-of-type { border-radius: 10px 0 0 10px; }
.conv-menu button:last-of-type { border-radius: 0 10px 10px 0; }
.conv-menu button {
  padding: 11px 16px;
  font-size: 14px;
  color: #fff;
  background: transparent;
  white-space: nowrap;
}
.conv-menu button + button { border-left: 1px solid rgba(255, 255, 255, .14); }
.conv-menu button:active { background: rgba(255, 255, 255, .12); }

/* 会话菜单的小箭头：指向被长按的那一行 */
.conv-menu-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #3b3b46;
  bottom: -7px;
  pointer-events: none;
}
.conv-menu-arrow.up {
  border-top: none;
  border-bottom: 7px solid #3b3b46;
  bottom: auto;
  top: -7px;
}

/* 会话刚打开、消息还在路上 */
.msg-loading {
  padding: 24px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
}

/* 弹窗内容绝不能把弹窗撑出屏幕 */
.modal { min-width: 0; }
.modal-body { min-width: 0; overflow-x: hidden; }

/* 语音条气泡 */
.voice-bubble {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 84px;
  max-width: 190px;
  cursor: pointer;
}
.vb-bars {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2.5px;
  height: 22px;
}
.vb-bars i {
  display: block;
  width: 2.5px;
  border-radius: 2px;
  background: currentColor;
  opacity: .75;
}
/* 播放时波形上下跳，跟微信一样有「在放」的感觉 */
.voice-bubble.playing .vb-bars i {
  animation: vbJump .9s ease-in-out infinite;
}
.voice-bubble.playing .vb-bars i:nth-child(2n) { animation-delay: .12s }
.voice-bubble.playing .vb-bars i:nth-child(3n) { animation-delay: .24s }
.voice-bubble.playing .vb-bars i:nth-child(4n) { animation-delay: .36s }
@keyframes vbJump {
  0%, 100% { transform: scaleY(1) }
  50% { transform: scaleY(1.7) }
}
.vb-len {
  font-size: 12px;
  opacity: .85;
  flex: none;
  font-variant-numeric: tabular-nums;
}
.bubble audio { display: none; }

/* 语音模式：左边切换键 + 中间「按住 说话」 */
.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.composer-input-row .composer-input-wrap { flex: 1; min-width: 0; }
.voice-toggle { flex: none; width: 34px; height: 34px; align-self: flex-end; }
.voice-toggle svg { width: 20px; height: 20px; fill: var(--text-dim); }

.hold-talk {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.hold-talk.holding {
  background: var(--bg-active);
  color: var(--text);
}
.hold-talk.cancel {
  background: rgba(239, 83, 80, .16);
  color: var(--danger);
}

/* ---------- 输入栏：微信那种一条的布局 ---------- */
.composer {
  padding: 8px 10px 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.composer-bar {
  display: flex;
  align-items: center;   /* 三个圆钮和输入框同一条中线 */
  gap: 8px;
}
.composer-bar .composer-input-wrap { flex: 1; min-width: 0; }

/* 圆形按钮 */
.wx-btn {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.6px solid var(--text-dim);
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  transition: background .15s, opacity .15s;
}
.wx-btn:active { background: var(--bg-active); }
.wx-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* 输入框：微信那种大圆角 */
#composer-input {
  padding: 8px 14px;
  height: 36px;
  min-height: 36px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 18px;
  overflow-y: auto;
  scrollbar-width: none;   /* 那条灰竖条是它的滚动条 */
}
#composer-input::-webkit-scrollbar { width: 0; height: 0; }
#composer-input::placeholder { color: transparent; }

/* 按住说话：跟输入框同高同圆角 */
.hold-talk {
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 18px;
  font-size: 15px;
  font-weight: 500;
}

/* 发送键：有字才出现，绿色系换成本站主色 */
.wx-send {
  flex: none;
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
}
.wx-send:active { background: var(--accent-dim); }

/* ＋ 展开的面板 */
.composer-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 6px 4px;
}
.panel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: 12px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 12px;
}
.panel-btn:active { background: var(--bg-active); }
.panel-btn svg { width: 24px; height: 24px; fill: currentColor; }

.composer-hint { display: block; font-size: 11px; color: var(--text-mute); padding-left: 4px; }


/* ---------- 录音浮层：微信那种全屏深色 + 波形 ---------- */
.voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 32px;
  user-select: none;
  -webkit-user-select: none;
}
.vo-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 190px;
  padding: 22px 26px;
  border-radius: 18px;
  background: #07c160;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
  transition: background .15s;
}
.vo-card.cancel { background: #e64340; }
.vo-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 34px;
}
.vo-wave i {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: #fff;
  transition: height .09s linear;
}
.vo-time {
  font-size: 13px;
  color: rgba(255, 255, 255, .92);
  font-variant-numeric: tabular-nums;
}
.vo-hint {
  font-size: 14px;
  color: #fff;
  font-weight: 500;
}
.vo-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, .65);
  margin-top: -8px;
}
.vo-cancel {
  margin-top: 10px;
  padding: 9px 30px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, .45);
  background: transparent;
  color: #fff;
  font-size: 13px;
}
.vo-cancel:active { background: rgba(255, 255, 255, .16); }

/* ---------- 下拉刷新 ---------- */
.ptr {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mute);
  transition: height .18s ease, color .15s;
  flex: none;
}
.ptr.ready { color: var(--accent); }
.ptr-spin {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  opacity: .35;
  transition: transform .18s;
}
.ptr.ready .ptr-spin { opacity: 1; transform: rotate(180deg); }
.ptr.spin .ptr-spin {
  opacity: 1;
  animation: ptrSpin .7s linear infinite;
}
@keyframes ptrSpin { to { transform: rotate(360deg) } }

/* ---------- 引用条（输入框上方） ---------- */
/* ---------- 引用条（输入框内，单独一行） ---------- */
/* 有引用时，输入区整个变成一个浅色卡片，上面一条引用胶囊，下面才是输入框 */
.composer-input-wrap.has-quote {
  background: var(--bg-input);
  border-radius: 16px;
  padding: 6px 8px 2px;
}
.composer-input-wrap.has-quote #composer-input {
  background: transparent;
  padding-top: 4px;
}

.quote-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .05);
  min-width: 0;
}
.quote-who {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  max-width: 30%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quote-text {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quote-close {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .12);
  display: grid;
  place-items: center;
  padding: 0;
}
.quote-close svg {
  width: 12px;
  height: 12px;
  fill: var(--text-mute);
}

.bubble.has-quote {
  max-width: min(84%, 420px);
}

/* 气泡里的引用块：QQ 那种「上面一行来源，下面一段原文」 */
.bubble-quote {
  display: block;
  padding: 8px 10px;
  margin-bottom: 7px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .055);
  overflow: hidden;
  cursor: pointer;
}
.bubble.mine .bubble-quote { background: rgba(255, 255, 255, .18); }

.bq-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.4;
  opacity: .92;
  margin-bottom: 4px;
}
.bq-who {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
}
.bq-time {
  flex: 1;
  opacity: .7;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* 右上角那个小箭头，表示「引自上面」 */
.bq-arrow {
  flex: none;
  width: 12px;
  height: 12px;
  position: relative;
  opacity: .55;
}
.bq-arrow::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 3px;
  width: 1.5px;
  height: 8px;
  margin-left: -0.75px;
  background: currentColor;
}
.bq-arrow::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 6px;
  height: 6px;
  margin-left: -3px;
  border-left: 1.5px solid currentColor;
  border-top: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.bq-body {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  /* 最多三行，多了省略 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


/* ---------- 全局禁掉长按选中 ---------- */
/* 长按本该弹我们自己的菜单，不能跳系统的「复制/分享/全选」 */
body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* 输入框和可编辑区域除外，不然打不了字 */
input, textarea, [contenteditable="true"], [contenteditable=""] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
/* 系统通知类的文案留着能选，方便复制错误信息 */
.selectable, .selectable * {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 可长按复制的 ID */
.id-copy {
  -webkit-touch-callout: none;
  cursor: default;
}
.id-copy:active { color: var(--accent); }
