/* ═══════════════════════════ Telegram Clone — 深色主题 ═══════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #17212b;
  --bg2:       #0e1621;
  --surface:   #1f2b38;
  --surface2:  #242f3d;
  --surface3:  #2b3c50;
  --line:      #0e1621;
  --blue:      #3390ec;
  --blue-dark: #2b7cd1;
  --sent:      #2b5278;
  --recv:      #182533;
  --text:      #e8f4ff;
  --text2:     #adb5be;
  --text3:     #677b90;
  --online:    #4dcd5e;
  --unread:    #3390ec;
  --tabbar-h:  56px;
  --statusbar-h: 0px;
  --header-h:  54px;
}

html, body {
  height: 100%;
  height: 100dvh;
  width: 100%;
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* 只在 Telegram 克隆页锁定 overflow */
body:has(.tg-app) {
  background: #000;
  color: var(--text);
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 0; }

/* ─────────────────────────────── 登录界面 ─────────────────────────────── */
.tg-login-overlay {
  position: fixed; inset: 0;
  background: #17212b;
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  overflow-y: auto;
}
.tg-login-wrap {
  width: min(380px, 100%);
  padding: 36px 24px 32px;
  display: flex; flex-direction: column; gap: 18px;
  align-items: stretch;
}
.tg-login-logo {
  width: 80px; height: 80px;
  border-radius: 50%;
  margin: 0 auto 4px;
  overflow: hidden;
}
.tg-login-logo svg { width: 100%; height: 100%; }
.tg-login-title {
  text-align: center;
  font-size: 26px; font-weight: 700; color: var(--text);
  letter-spacing: -.3px;
}
.tg-login-sub {
  text-align: center; color: #8a9bb0;
  font-size: 15px; line-height: 1.55;
}
.tg-login-field-label { color: #5aade8; font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.tg-login-country {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  font-size: 17px; color: var(--text); cursor: pointer;
  background: var(--surface);
  transition: background .12s;
}
.tg-login-country:active { background: #263444; }
.tg-login-flag { font-size: 22px; }
.tg-login-country-name { flex: 1; }
.tg-login-arrow { width: 18px; height: 18px; }
.tg-login-phone-row {
  position: relative;
  display: grid; grid-template-columns: 68px 1px 1fr;
  align-items: center; gap: 12px;
  border: 2px solid var(--blue); border-radius: 14px;
  padding: 13px 70px 13px 14px;
  background: var(--surface);
}
.tg-login-code, .tg-login-number {
  border: 0; background: transparent;
  font-size: 17px; color: var(--text); outline: none;
}
.tg-login-number::placeholder { color: var(--text3); }
.tg-login-divider {
  width: 1px; height: 24px; background: rgba(255,255,255,.12);
}
.tg-login-go {
  position: absolute; right: -1px; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: var(--blue); cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 20px rgba(51,144,236,.35);
}
.tg-login-go svg { width: 22px; height: 22px; }
.tg-login-input-field {
  width: 100%; padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  font-size: 17px; color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .2s;
}
.tg-login-input-field:focus { border-color: var(--blue); }
.tg-login-code-block { display: flex; flex-direction: column; gap: 16px; }
.tg-login-submit {
  width: 100%; padding: 15px;
  border: 0; border-radius: 14px;
  background: var(--blue); color: #fff;
  font-size: 17px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 18px rgba(51,144,236,.4);
  transition: all .15s;
}
.tg-login-submit:active { background: #2b7cd1; transform: scale(.97); }
.tg-status-box {
  padding: 12px 14px; border-radius: 12px;
  font-size: 14px; line-height: 1.5;
  display: none;
  background: rgba(255,255,255,.05);
  color: #adb5be;
}
.tg-status-box.show { display: block; }
.tg-status-box.error { background: #fff0f0; color: #d33; border: 1px solid #fcc; }
.tg-status-box.success { background: #f0fff4; color: #1a8735; border: 1px solid #b7efc5; }

/* ─────────────────────────────── 主 App ─────────────────────────────── */
.tg-app {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* ── 状态栏 ── */
.tg-statusbar {
  height: var(--statusbar-h);
  background: var(--bg);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px; font-weight: 600; color: #ffffff;
  flex-shrink: 0;
  z-index: 100;
}
.tg-statusbar-right {
  display: flex; align-items: center; gap: 6px;
}
.tg-statusbar-right svg { width: 16px; height: 16px; }
.tg-battery { display: flex; align-items: center; gap: 1px; }
.tg-battery-body {
  width: 22px; height: 11px;
  border: 1.5px solid rgba(255,255,255,.8);
  border-radius: 3px; padding: 1px;
}
.tg-battery-fill {
  height: 100%; width: 72%;
  background: rgba(255,255,255,.9); border-radius: 1px;
}
.tg-battery-tip {
  width: 3px; height: 5px;
  background: rgba(255,255,255,.7);
  border-radius: 0 1px 1px 0;
}

/* ── 页面容器 ── */
.tg-page {
  display: none; flex: 1; overflow: hidden;
  flex-direction: column;
}
.tg-page-active { display: flex; }

/* ── 通用头部 ── */
.tg-list-header {
  height: var(--header-h);
  background: var(--surface);
  display: flex; align-items: center;
  padding: 0 6px 0 8px;
  gap: 0;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.tg-list-title {
  font-size: 20px; font-weight: 700; color: var(--text);
  padding: 0 4px; letter-spacing: -.4px;
}
.tg-hdr-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--blue);
  display: grid; place-items: center; cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.tg-hdr-btn:active { background: rgba(51,144,236,.15); }
.tg-hdr-btn svg { width: 22px; height: 22px; }
.tg-back-btn { color: var(--blue); }

/* ── 三段式头部：左按钮 / 居中标题 / 右按钮组 ── */
.tg-list-header-3col { padding: 0 8px; }
.tg-list-header-3col .tg-list-header-center {
  position: absolute; left: 50%; top: 0; height: var(--header-h);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}
.tg-list-header-3col { position: relative; justify-content: space-between; }
.tg-list-header-right { display: flex; align-items: center; gap: 0; margin-left: auto; }
.tg-hdr-text-btn {
  border: 0; background: transparent; color: var(--blue);
  font-size: 17px; padding: 0 6px; height: 40px; cursor: pointer;
  flex-shrink: 0;
}
.tg-hdr-text-btn:active { opacity: .6; }

/* ── 编辑模式：多选/清空聊天记录条 ── */
.tg-select-bar {
  height: 44px; background: var(--surface); flex-shrink: 0;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  font-size: 14px; color: var(--text2);
}
.tg-select-cancel { border:0; background:transparent; color:var(--blue); font-size:15px; cursor:pointer; padding:4px 0; }
#selectCountLabel { flex: 1; }
.tg-select-clear { border:0; background:transparent; color:#e05a4e; font-size:15px; cursor:pointer; padding:4px 0; }
.tg-select-clear:disabled { color: var(--text3); cursor: default; }
.tg-chat-checkbox {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text3);
  flex-shrink: 0; display: none; align-items: center; justify-content: center;
  margin-right: 2px; box-sizing: border-box;
}
.tg-select-active .tg-chat-checkbox { display: flex; }
.tg-chat-checkbox.checked { background: var(--blue); border-color: var(--blue); }
.tg-chat-checkbox.checked::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }

/* ── 搜索栏 ── */
.tg-search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  margin: 6px 12px 2px;
  padding: 8px 12px;
  border-radius: 10px;
  flex-shrink: 0;
}
.tg-search-bar svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .6; }
.tg-search-input {
  flex: 1; border: 0; background: transparent;
  font-size: 16px; color: var(--text);
  outline: none;
}
.tg-search-input::placeholder { color: var(--text3); font-size: 15px; }

/* ── 聊天列表 ── */
.tg-chat-list {
  flex: 1; overflow-y: auto; overflow-x: hidden;
}
.tg-chat-items { padding: 0 0 80px; }

/* ── 聊天列表项 ── */
.tg-chat-item {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 14px 9px 16px;
  cursor: pointer; border: 0; background: transparent;
  width: 100%; text-align: left;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.tg-chat-item::after {
  content: "";
  position: absolute;
  bottom: 0; left: 80px; right: 0;
  height: 0.5px;
  background: rgba(255,255,255,.05);
}
.tg-chat-item:active, .tg-chat-item.active {
  background: var(--surface2);
}
.tg-chat-item-body { min-width: 0; }
.tg-chat-item-row1 {
  display: flex; align-items: center;
  justify-content: space-between; gap: 6px;
  margin-bottom: 3px;
}
.tg-chat-name {
  font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -0.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 3px;
}
.tg-chat-time { font-size: 13px; color: var(--text3); white-space: nowrap; flex-shrink: 0; }
.tg-chat-item-row2 { display: flex; align-items: center; gap: 6px; }
.tg-chat-last {
  font-size: 14px; color: var(--text3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0; line-height: 1.4;
}
.tg-unread-badge {
  min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 999px;
  background: var(--unread); color: #fff;
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.tg-muted-badge { background: var(--text3); }

/* ── 头像 ── */
.tg-avatar {
  width: 54px; height: 54px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: #fff;
  flex-shrink: 0; letter-spacing: -.5px;
  user-select: none;
}
.tg-avatar-sm { width: 40px; height: 40px; font-size: 15px; }
.tg-avatar-lg { width: 66px; height: 66px; font-size: 26px; }
.tg-online-dot {
  position: relative;
}
.tg-online-dot::after {
  content: ""; position: absolute; bottom: 2px; right: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}

/* ── 会话视图：浅色壁纸 + 紫白气泡主题（参考真实 Telegram 聊天截图） ── */
.tg-conv-wrap {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
  --conv-sent: #dcf5c8;
  --conv-sent-text: #223616;
  --conv-recv: #ffffff;
  --conv-recv-text: #223616;
  --conv-header-bg: rgba(160,120,210,.42);
  --conv-composer-bg: rgba(255,255,255,.9);
}
.tg-conv-header {
  height: var(--header-h); background: var(--conv-header-bg);
  display: flex; align-items: center;
  padding: 0 4px 0 2px; gap: 2px;
  flex-shrink: 0;
  backdrop-filter: blur(10px) saturate(1.4);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,.15);
  position: relative; z-index: 2;
}
.tg-conv-header .tg-hdr-btn,
.tg-conv-header .tg-back-btn { color: #fff; }
.tg-conv-name { color: #fff !important; }
.tg-conv-status { color: rgba(255,255,255,.85) !important; }
.tg-conv-status.tg-status-typing { color: #fff !important; }
.tg-back-badge {
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: #fff; color: #8b6fd6; font-size: 11px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
  position: relative; left: -6px; top: 8px;
}
.tg-back-badge.show { display: flex; }
.tg-conv-meta {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 8px; border-radius: 10px;
  transition: background .12s;
}
.tg-conv-meta:active { background: var(--surface2); }
.tg-conv-info { min-width: 0; }
.tg-conv-name {
  font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -0.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 180px;
}
.tg-conv-status { font-size: 12px; color: var(--text3); }
.tg-conv-status.tg-status-online { color: var(--online); }
.tg-conv-status.tg-status-typing { color: var(--blue); font-style: normal; }

/* ── 消息区域：浅绿色壁纸背景（渐变 + 平铺花草小图案，贴近真实截图效果） ── */
.tg-messages {
  flex: 1; overflow-y: auto;
  padding: 6px 8px 8px;
  display: flex; flex-direction: column;
  scroll-behavior: smooth;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1.6' opacity='0.4'%3E%3Cpath d='M24 30c-3-7 4-11 7-6 3-5 10-2 7 6-2 4-7 7-7 7s-5-3-7-7z'/%3E%3Cpath d='M31 37v14'/%3E%3Ccircle cx='104' cy='26' r='9'/%3E%3Cpath d='M104 17v18M95 26h18'/%3E%3Cpath d='M60 78l4 8 8 1-6 5.5 1.5 8-7.5-4-7.5 4 1.5-8-6-5.5 8-1z'/%3E%3Crect x='14' y='96' width='20' height='16' rx='3'/%3E%3Cpath d='M14 102h20M24 96v16'/%3E%3Cpath d='M118 92c-3-6 3-10 6-5 3-5 9-1 6 5-2 3-6 6-6 6s-4-3-6-6z'/%3E%3Cpath d='M124 98v12'/%3E%3Cpath d='M46 8c6 0 10 5 10 11-6 0-10-5-10-11z'/%3E%3Cpath d='M46 19v10'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(165deg, #d7ecd2 0%, #bfe0c4 35%, #a9d6c9 65%, #8fc6c4 100%);
  background-size: 140px 140px, cover;
}
.tg-empty-conv {
  margin: auto; text-align: center; opacity: .5;
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
}
.tg-empty-conv svg { width: 64px; height: 64px; }
.tg-empty-conv .tg-empty-text { font-size: 15px; color: var(--text2); }

/* 日期chip */
.tg-date-chip {
  text-align: center; margin: 10px 0 6px;
  font-size: 12px; color: rgba(255,255,255,.65);
}
.tg-date-chip span {
  background: rgba(0,0,0,.28); padding: 4px 10px;
  border-radius: 999px; display: inline-block;
  backdrop-filter: blur(4px);
  letter-spacing: .2px;
}

/* 消息行 */
.tg-msg-row {
  display: flex; margin-bottom: 3px;
}
.tg-msg-row.tg-out { justify-content: flex-end; }
.tg-msg-row.tg-in  { justify-content: flex-start; }
.tg-msg-row + .tg-msg-row.tg-in.tg-first-in { margin-top: 6px; }
.tg-msg-row + .tg-msg-row.tg-out.tg-first-out { margin-top: 6px; }

/* 气泡 */
.tg-bubble {
  max-width: 78%;
  padding: 6px 10px 4px;
  border-radius: 18px;
  font-size: 15px; line-height: 1.45;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.tg-out .tg-bubble {
  background: var(--conv-sent); color: var(--conv-sent-text);
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 1px 3px rgba(90,60,140,.25);
}
.tg-in .tg-bubble {
  background: var(--conv-recv); color: var(--conv-recv-text);
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 3px rgba(60,40,90,.15);
}
/* 气泡尾巴 / 气泡底部(foot) / 已读勾(check) 的完整定义统一放在下方
   "气泡尾巴 - 更真实的形状" 与 "消息区精修" 部分，避免同一选择器重复覆盖 */
.tg-bubble-time { font-size: 11px; color: rgba(34,54,22,.55); white-space: nowrap; }
.tg-in .tg-bubble-time { color: rgba(43,37,64,.45); }

/* ── 机器人消息内联按钮（真实 replyMarkup） ──
   还原真实 Telegram 的样式：整块按钮附着在消息气泡正下方，同一整体背景、
   用 1px 分隔线区分每个按钮，而不是一个个独立带间距的圆角小按钮 */
.tg-msg-col { display: flex; flex-direction: column; max-width: 78%; }
.tg-msg-buttons {
  display: flex; flex-direction: column;
  margin-top: 2px; border-radius: 0 0 18px 18px; overflow: hidden;
  /* 玻璃质感：半透明白 + 毛玻璃模糊，替代之前的纯白实色背景 */
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255,255,255,.6);
  border-top: none;
  box-shadow: 0 4px 14px rgba(60,40,90,.12);
}
.tg-msg-btn-row { display: flex; }
.tg-msg-btn-row + .tg-msg-btn-row { border-top: 1px solid rgba(255,255,255,.5); }
.tg-msg-btn {
  flex: 1; min-width: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--blue);
  font-size: 15px; font-weight: 500; line-height: 1.45; padding: 9px 8px;
  cursor: pointer; text-align: center; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  font-family: inherit;
  transition: background .12s;
}
.tg-msg-btn-row .tg-msg-btn + .tg-msg-btn { border-left: 1px solid rgba(255,255,255,.5); }
.tg-msg-btn:active { background: rgba(255,255,255,.35); }
.tg-msg-btn:disabled { opacity: .6; cursor: default; }
.tg-msg-btn-icon { opacity: .7; font-size: 13px; }

/* ── 输入框：浅色药丸样式 ── */
.tg-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 6px 10px 10px;
  background: var(--conv-composer-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(60,40,90,.08);
  flex-shrink: 0;
}
.tg-composer-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: #6b5a95; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  transition: color .15s;
}
.tg-composer-btn:active { color: var(--conv-sent); }
.tg-composer-btn svg { width: 22px; height: 22px; }
.tg-composer-input {
  flex: 1; min-height: 36px; max-height: 120px;
  padding: 9px 14px; border: 0; border-radius: 20px;
  background: #fff; color: #2b2540;
  font-size: 16px; outline: none; resize: none;
  line-height: 1.45; transition: background .15s;
  box-shadow: inset 0 0 0 1px rgba(60,40,90,.08);
}
.tg-composer-input::placeholder { color: #9a8fb5; }
.tg-send-btn {
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--blue); color: #fff; cursor: pointer;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(51,144,236,.35);
  transition: all .15s;
  flex-shrink: 0;
}
.tg-send-btn:active { background: var(--blue-dark); transform: scale(.92); }
.tg-send-btn svg { width: 18px; height: 18px; }

/* ── 联系人页 ── */
.tg-contacts-section {
  background: var(--surface2); margin: 8px 12px;
  border-radius: 14px; overflow: hidden;
}
.tg-section-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px 11px 16px; cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.tg-section-row:active { background: rgba(255,255,255,.05); }
.tg-section-action { cursor: pointer; }
.tg-row-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; flex-shrink: 0;
}
.tg-row-icon svg { width: 17px; height: 17px; }
.tg-row-label { font-size: 16px; color: var(--text); letter-spacing: -.1px; }
.tg-row-texts { flex: 1; min-width: 0; }
.tg-row-sub { font-size: 13px; color: var(--text3); margin-top: 2px; }
.tg-row-arrow { width: 16px; height: 16px; color: #6b7f94; flex-shrink: 0; opacity: .6; }
.tg-section-divider { height: 0.5px; background: rgba(255,255,255,.07); margin-left: 60px; }
.tg-section-divider-inset { margin-left: 60px; }
.tg-section-header-label {
  font-size: 13px; color: var(--text3);
  padding: 12px 14px 4px;
}

/* ── 设置页 ── */
.tg-settings-profile {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px 12px 16px;
  background: var(--surface2); margin: 6px 12px 4px;
  border-radius: 14px; cursor: pointer;
  transition: background .12s;
  flex-shrink: 0;
}
.tg-settings-profile:active { background: var(--surface3); }
.tg-settings-profile-info { flex: 1; min-width: 0; }
.tg-settings-name { font-size: 19px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; }
.tg-settings-handle { font-size: 13px; color: var(--text3); margin-top: 2px; }
.tg-settings-actions {
  display: flex; gap: 8px;
  padding: 4px 12px 6px;
  flex-shrink: 0;
}
.tg-settings-action {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  padding: 12px 8px;
  background: var(--surface2); border-radius: 12px;
  cursor: pointer; color: var(--blue);
  transition: background .12s;
  -webkit-tap-highlight-color: transparent;
}
.tg-settings-action:active { background: var(--surface3); }
.tg-settings-action svg { width: 20px; height: 20px; }
.tg-settings-action span { font-size: 12px; font-weight: 500; }
.tg-settings-list {
  background: var(--surface2); margin: 0 12px;
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  flex-shrink: 0;
}
.tg-settings-version {
  text-align: center; color: var(--text3);
  font-size: 12px; padding: 16px 0 calc(var(--tabbar-h) + 20px);
  letter-spacing: .2px; line-height: 1.6;
  flex-shrink: 0;
}

/* ── 空状态 ── */
.tg-empty-page {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; opacity: .5;
}
.tg-empty-icon-large svg { width: 80px; height: 80px; }
.tg-empty-title { font-size: 18px; color: var(--text2); font-weight: 600; }
.tg-empty-sub { font-size: 14px; color: var(--text3); }

/* ── 底部导航栏 ── */
.tg-tabbar {
  height: var(--tabbar-h);
  background: var(--surface);
  display: flex; align-items: stretch;
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
  z-index: 10;
  /* Safe area for iPhone home bar */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tg-tab {
  flex: 1; border: 0; background: transparent;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; cursor: pointer;
  color: var(--text3); font-size: 10px; font-weight: 400;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0);
  min-height: 49px;
}
.tg-tab.tg-tab-active { color: var(--blue); }
.tg-tab.tg-tab-active span { font-weight: 500; }
.tg-tab-icon { width: 25px; height: 25px; }
.tg-tab-icon-wrap { position: relative; display: inline-flex; }
.tg-tab-badge {
  position: absolute; top: -4px; right: -10px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--unread); color: #fff; font-size: 10.5px; font-weight: 700;
  display: none; align-items: center; justify-content: center; line-height: 1;
}
.tg-tab-badge.show { display: flex; }

/* ── 底部导航容器 + 悬浮搜索按钮 ── */
.tg-tabbar-wrap { position: relative; flex-shrink: 0; }
.tg-float-search-btn {
  position: absolute; right: 14px; bottom: calc(100% + 10px);
  width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--blue); box-shadow: 0 3px 10px rgba(0,0,0,.25);
  display: grid; place-items: center; cursor: pointer; z-index: 5;
}
.tg-float-search-btn:active { opacity: .85; }

/* ── 工具类 ── */
.hidden { display: none !important; }
/* 进入会话页时隐藏聊天列表顶部标题栏/搜索栏/文件夹栏 + 底部导航栏，避免与会话头部/输入框重叠 */
.tg-hidden-in-conv { display: none !important; }

/* ─────────────────── 桌面端：手机外框 ─────────────────── */
@media (min-width: 600px) {
  body { background: #0a0f16; display: flex; align-items: center; justify-content: center; }
  .tg-login-overlay {
    position: fixed;
    background: #eee;
    inset: 0;
  }
  .tg-app {
    position: relative;
    width: 393px;
    height: 852px;
    border-radius: 50px;
    box-shadow: 0 0 0 12px #1a1a1a, 0 30px 80px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.05);
    overflow: hidden;
    animation: tg-appear .25s ease-out;
  }
  .tg-login-overlay {
    border-radius: 50px;
    width: 393px; height: 852px;
    position: absolute;
    inset: unset;
    transform: none;
    margin: 0;
  }
}

@keyframes tg-appear {
  from { transform: scale(.97); opacity: .7; }
  to   { transform: scale(1); opacity: 1; }
}


/* ══════════════════════ 联系人资料页 (iOS 风格) ══════════════════════ */
.tg-profile-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: #f2f2f7;
  transform: translateX(100%);
  transition: transform .32s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
.tg-profile-overlay.open { transform: translateX(0); }

/* ── 导航栏 ── */
.tg-profile-nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
  height: 44px;
  flex-shrink: 0;
}
.tg-profile-nav-back {
  display: flex; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-size: 17px; padding: 8px 8px;
  -webkit-tap-highlight-color: transparent;
}
.tg-profile-nav-back svg { width: 24px; height: 24px; }
.tg-profile-nav-edit {
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-size: 17px; padding: 8px 10px;
  -webkit-tap-highlight-color: transparent;
}

/* ── Hero 渐变头像区 ── */
.tg-profile-hero {
  display: flex; flex-direction: column; align-items: center;
  padding: 0 16px 20px;
  gap: 6px; flex-shrink: 0;
  margin-top: -44px; /* overlap under nav */
  padding-top: 54px;
}
.tg-profile-hero-avatar {
  width: 90px; height: 90px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 600; color: #fff;
  letter-spacing: -1px;
  flex-shrink: 0;
  margin-bottom: 4px;
}
.tg-profile-hero-name-row {
  display: flex; align-items: center; gap: 6px;
}
.tg-profile-hero-name {
  font-size: 22px; font-weight: 700; color: #fff;
  letter-spacing: -.3px;
}
.tg-profile-hero-shield {
  width: 20px; height: 20px; opacity: .9;
}
.tg-profile-hero-status {
  font-size: 14px; color: rgba(255,255,255,.72);
}

/* ── 操作按钮行 ── */
.tg-profile-actions {
  display: flex; align-items: flex-start; justify-content: center;
  gap: 12px; padding: 12px 16px 8px;
  background: #f2f2f7; flex-shrink: 0;
}
.tg-profile-action {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  flex: 1; max-width: 80px;
}
.tg-profile-action-icon {
  width: 54px; height: 54px; border-radius: 14px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.tg-profile-action-icon svg { width: 22px; height: 22px; color: var(--blue); }
.tg-profile-action-label {
  font-size: 12px; color: var(--blue); text-align: center;
  font-weight: 400;
}

/* ── 信息卡片 ── */
.tg-profile-card {
  background: #fff; border-radius: 12px;
  margin: 8px 16px; overflow: hidden;
  flex-shrink: 0;
}
.tg-profile-field {
  display: flex; align-items: center; padding: 12px 16px; gap: 12px;
  min-height: 58px;
}
.tg-profile-field-texts { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tg-profile-field-label {
  font-size: 13px; color: #8e8e93; line-height: 1.3; margin-bottom: 2px;
}
.tg-profile-field-value {
  font-size: 17px; color: #000; font-weight: 400; line-height: 1.35;
}
.tg-profile-field-value.tg-link { color: var(--blue); }
.tg-profile-field-qr {
  width: 32px; height: 32px; opacity: .45; flex-shrink: 0;
}
.tg-profile-divider {
  height: 1px; background: #e5e5ea; margin-left: 16px;
}

/* ── 切换开关卡片 ── */
.tg-profile-toggle-row {
  display: flex; align-items: center; padding: 12px 16px; gap: 12px;
  min-height: 58px;
}
.tg-profile-toggle-texts { flex: 1; }
.tg-profile-toggle-label {
  font-size: 17px; color: #000; line-height: 1.35;
}
.tg-profile-toggle-sub {
  font-size: 13px; color: #8e8e93; line-height: 1.4; margin-top: 2px;
}
/* iOS toggle */
.tg-ios-toggle {
  width: 51px; height: 31px; border-radius: 16px;
  background: #e5e5ea; flex-shrink: 0;
  position: relative; cursor: pointer;
  transition: background .2s;
}
.tg-ios-toggle::after {
  content: ''; position: absolute;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px;
  transition: transform .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.tg-ios-toggle.on { background: #30d158; }
.tg-ios-toggle.on::after { transform: translateX(20px); }

/* ── 媒体 Tab 栏 ── */
.tg-profile-tabs {
  display: flex; background: #fff;
  margin: 8px 16px 0; border-radius: 12px 12px 0 0;
  border-bottom: 1px solid #e5e5ea;
  flex-shrink: 0;
  overflow-x: auto; scrollbar-width: none;
}
.tg-profile-tabs::-webkit-scrollbar { display: none; }
.tg-profile-tab {
  flex-shrink: 0; padding: 12px 14px; text-align: center;
  font-size: 13px; font-weight: 500; color: #8e8e93;
  background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.tg-profile-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tg-profile-media-empty {
  background: #fff; margin: 0 16px;
  padding: 48px 0; text-align: center;
  color: #8e8e93; font-size: 15px;
  border-radius: 0 0 12px 12px;
}
.tg-profile-spacer { height: 40px; flex-shrink: 0; }

.tg-avatar-tap { display: contents; cursor: pointer; }
.tg-avatar-tap .tg-avatar { flex-shrink: 0; }

/* ══ 头像真实图片层 ══ */
.tg-avatar { position: relative; overflow: hidden; flex-shrink: 0; }
.tg-avatar-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
}

/* ══ 设置子页面 overlay ══ */
.tg-settings-sub {
  position: fixed; inset: 0; z-index: 210;
  background: var(--bg);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.25,.46,.45,.94);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
.tg-settings-sub.open { transform: translateX(0); }

/* 子页面 header */
.tg-sub-nav {
  display: flex; align-items: center;
  height: 48px; padding: 0 4px;
  background: #1f2d3a;
  flex-shrink: 0; position: sticky; top: 0; z-index: 5;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.tg-sub-nav-back {
  display: flex; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  color: var(--blue); font-size: 17px; padding: 8px 10px;
  -webkit-tap-highlight-color: transparent;
}
.tg-sub-nav-back svg { width: 22px; height: 22px; }
.tg-sub-nav-title {
  flex: 1; text-align: center;
  font-size: 17px; font-weight: 600; color: var(--text);
  margin-right: 42px;
}

/* 子页面内容区 */
.tg-sub-body { padding: 12px 0 60px; }
.tg-sub-section {
  margin: 8px 0;
  background: #1f2d3a;
  border-top: 1px solid rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.tg-sub-row {
  display: flex; align-items: center;
  padding: 13px 16px; gap: 14px;
  min-height: 50px;
}
.tg-sub-row-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tg-sub-row-icon svg { width: 18px; height: 18px; }
.tg-sub-row-texts { flex: 1; }
.tg-sub-row-label { font-size: 17px; color: var(--text); }
.tg-sub-row-sub { font-size: 13px; color: var(--text3); margin-top: 2px; }
.tg-sub-row-value { font-size: 15px; color: var(--text3); }
.tg-sub-divider { height: 1px; background: rgba(255,255,255,.06); margin-left: 16px; }
.tg-sub-section-label {
  font-size: 13px; color: var(--text3);
  padding: 10px 16px 6px;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 500;
}
.tg-sub-section-foot {
  font-size: 13px; color: var(--text3);
  padding: 6px 16px 10px; line-height: 1.5;
}
/* toggle in sub-page (dark theme) */
.tg-sub-toggle {
  width: 48px; height: 28px; border-radius: 14px;
  background: var(--surface3); flex-shrink: 0;
  position: relative; cursor: pointer; transition: background .2s;
}
.tg-sub-toggle::after {
  content: ''; position: absolute;
  width: 24px; height: 24px; border-radius: 50%;
  background: #8899aa; top: 2px; left: 2px;
  transition: transform .2s, background .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.tg-sub-toggle.on { background: var(--blue); }
.tg-sub-toggle.on::after { transform: translateX(20px); background: #fff; }
/* radio */
.tg-sub-radio {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--text3); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.tg-sub-radio.checked { border-color: var(--blue); background: var(--blue); }
.tg-sub-radio.checked::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff;
}
/* Premium gradient */
.tg-premium-hero {
  background: linear-gradient(135deg, #6c6ef7 0%, #c160c0 100%);
  padding: 32px 16px 24px; text-align: center;
}
.tg-premium-hero-title { font-size: 24px; font-weight: 700; color: #fff; margin-bottom: 6px; }
.tg-premium-hero-sub { font-size: 14px; color: rgba(255,255,255,.8); }
.tg-premium-btn {
  margin: 16px; padding: 14px;
  background: linear-gradient(135deg, #6c6ef7, #c160c0);
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 16px; font-weight: 600; color: #fff; width: calc(100% - 32px);
}
/* device card */
.tg-device-card {
  background: #1f2d3a; margin: 8px 0;
  border-top: 1px solid rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.tg-device-row {
  display: flex; align-items: center; padding: 12px 16px; gap: 12px;
}
.tg-device-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.tg-device-icon svg { width: 22px; height: 22px; color: var(--blue); }
.tg-device-name { font-size: 15px; color: var(--text); font-weight: 500; }
.tg-device-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }
.tg-device-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  color: var(--blue); background: rgba(51,144,236,.15);
  padding: 3px 8px; border-radius: 10px;
}


/* ── 头像图片淡入 ── */
.tg-avatar-img {
  animation: tg-fade-in .2s ease;
}
@keyframes tg-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── 聊天列表项更真实的 active 态 ── */
.tg-chat-item:active {
  background: var(--surface3);
  transform: scale(.99);
  transition: transform .08s;
}

/* ── 频道名称图标对齐 ── */
.tg-chat-name { display: flex; align-items: center; gap: 0; }

/* ── 状态栏载体名 ── */
.tg-statusbar-carrier {
  font-size: 12px; font-weight: 500;
  opacity: .85; letter-spacing: .2px;
}



/* ── 输入框焦点高亮 ── */
.tg-composer-input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1.5px rgba(139,111,214,.4);
  transition: background .15s;
}

/* ── 底栏安全区增强 ── */
.tg-tabbar {
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
}

/* ── 轻提示 toast ── */
.tg-toast {
  position: absolute; left: 50%; bottom: calc(var(--tabbar-h) + 20px);
  transform: translateX(-50%) translateY(10px);
  background: rgba(40,50,64,.96); color: var(--text);
  font-size: 13.5px; padding: 10px 16px; border-radius: 10px;
  max-width: 82%; text-align: center; z-index: 500;
  opacity: 0; transition: opacity .18s, transform .18s;
  pointer-events: none; box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.tg-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 设置页可滚动 ── */
#pageSettings { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── 设置页版本号样式 ── */
.tg-settings-version {
  color: var(--text3); font-size: 13px;
  padding: 20px 0 calc(var(--tabbar-h) + 24px);
  text-align: center; letter-spacing: .3px;
  flex-shrink: 0;
}


/* ── 未读角标动画 ── */
.tg-unread-badge {
  animation: tg-badge-pop .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes tg-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}


/* ══ bubble-text & media ══ */
.tg-bubble-text { display: block; }
.tg-bubble-media .tg-bubble-text { color: rgba(255,255,255,.7); font-size: 14px; font-style: italic; }
.tg-bubble-foot {
  display: flex; justify-content: flex-end;
  align-items: center; gap: 3px;
  margin-top: 3px; float: right;
  margin-left: 8px; margin-bottom: -2px;
}

/* ══ 消息行间距更精确 ══ */
.tg-msg-row { display: flex; margin-bottom: 2px; align-items: flex-end; }
.tg-msg-row.tg-first { margin-top: 8px; }

/* ── 群组消息：发送人头像 + 名称 ── */
.tg-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  margin: 0 6px 2px 0; font-size: 12px; font-weight: 600;
  color: #fff; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; align-self: flex-end;
}
.tg-msg-avatar-spacer { width: 28px; flex-shrink: 0; margin-right: 6px; }
.tg-bubble-sender {
  font-size: 13px; font-weight: 600; margin-bottom: 2px;
  display: block; line-height: 1.3;
}
.tg-out { justify-content: flex-end; }
.tg-in  { justify-content: flex-start; }

/* ══ 气泡尾巴 - 更真实的形状 ══
   注意：必须用 --conv-sent/--conv-recv（当前聊天气泡真正用的颜色变量），
   不能用 --sent/--recv（那是旧的深色主题变量，颜色对不上会显示成突兀的黑色三角） */
.tg-out .tg-bubble::after {
  content: ""; position: absolute;
  bottom: 0; right: -6px;
  width: 9px; height: 15px;
  background: var(--conv-sent);
  clip-path: polygon(0 0, 0 100%, 100% 100%);
  border-bottom-right-radius: 2px;
}
.tg-in .tg-bubble::after {
  content: ""; position: absolute;
  bottom: 0; left: -6px;
  width: 9px; height: 15px;
  background: var(--conv-recv);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
  border-bottom-left-radius: 2px;
}
.tg-msg-row:not(.tg-first) .tg-bubble::after { display: none; }

/* ══ 页面加载骨架 ══ */
.tg-skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: tg-shimmer 1.2s infinite;
  border-radius: 8px;
}
@keyframes tg-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══ 头像 - 更好的布局 ══ */
.tg-avatar { position: relative; overflow: hidden; flex-shrink: 0; }
.tg-avatar-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
  animation: tg-fade-in .18s ease;
}

/* ══ 聊天时间精确颜色 ══ */
.tg-chat-time {
  font-size: 12px; color: var(--text3); white-space: nowrap; flex-shrink: 0;
  font-weight: 400; letter-spacing: .1px;
}

/* ══ 未读角标精确样式 ══ */
.tg-unread-badge {
  min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px;
  background: var(--blue); color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: -.3px;
}

/* ══ 已发送双勾更好看 ══ */
.tg-bubble-check {
  display: inline-flex; align-items: center;
  font-size: 14px; letter-spacing: -3px; line-height: 1;
  color: rgba(34,54,22,.6); margin-left: 1px;
}

/* ══ 消息输入区 ══ */
.tg-composer {
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px)) 10px;
}

/* ══ 资料页操作按钮 ══ */
.tg-profile-action-btn {
  transition: opacity .12s, transform .12s;
}
.tg-profile-action-btn:active { opacity: .7; transform: scale(.95); }

/* ══ 滚动条完全隐藏 ══ */
* { scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }

/* ══ 聊天文件夹 Tab 筛选条 ══ */
.tg-folder-bar {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 12px 0;
  gap: 6px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 0.5px solid rgba(255,255,255,.05);
}
.tg-folder-bar::-webkit-scrollbar { display: none; }

.tg-folder-tab {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text3);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px 9px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  letter-spacing: -.1px;
}
.tg-folder-tab.tg-folder-active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}
.tg-folder-tab:active { opacity: .7; }

/* ══ 文件夹 Tab 未读角标 ══ */
.tg-folder-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: -.2px;
}
.tg-folder-tab.tg-folder-active .tg-folder-badge {
  background: var(--blue);
}
.tg-folder-tab:not(.tg-folder-active) .tg-folder-badge {
  background: var(--text3);
}

/* ══ 置顶图标 ══ */
.tg-pin-icon {
  flex-shrink: 0;
  opacity: .4;
  color: var(--text3);
}

/* ══ Story / 联系人头像条 ══ */
.tg-story-row {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 10px 12px 8px;
  gap: 14px;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 0.5px solid rgba(255,255,255,.04);
}
.tg-story-row::-webkit-scrollbar { display: none; }

.tg-story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tg-story-ring {
  width: 56px; height: 56px;
  border-radius: 50%;
  padding: 2.5px;
  background: conic-gradient(var(--blue) 0deg 270deg, #5ad7f0 270deg 360deg);
  flex-shrink: 0;
}
.tg-story-ring.seen {
  background: var(--surface3);
}
.tg-story-ring.own {
  background: var(--surface3);
}
.tg-story-inner {
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
  font-size: 20px; font-weight: 700; color: #fff;
}
.tg-story-add-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  position: absolute; bottom: 14px; right: -2px;
  font-size: 14px; font-weight: 700; color: #fff;
  line-height: 1;
}
.tg-story-avatar-wrap {
  position: relative;
  width: 56px; height: 56px;
}
.tg-story-name {
  font-size: 11px; color: var(--text2);
  max-width: 60px;
  text-align: center;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -.1px;
}
.tg-story-name.own { color: var(--blue); }

/* ══ 纯表情气泡 ══ */
.tg-bubble-emoji {
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 4px !important;
}
.tg-bubble-emoji .tg-bubble-text {
  font-size: 40px !important;
  line-height: 1.15;
}
.tg-bubble-emoji .tg-bubble-foot {
  margin-top: -4px;
}

/* ══ 超链接 ══ */
.tg-bubble-link {
  color: #7ec9f5;
  text-decoration: underline;
  text-decoration-color: rgba(126,201,245,.4);
  word-break: break-all;
}

/* ══ 链接预览卡 ══ */
.tg-link-preview {
  display: flex;
  gap: 8px;
  margin: 0 -10px 6px;
  padding: 6px 10px;
  border-top: 0.5px solid rgba(255,255,255,.08);
  max-width: 260px;
}
.tg-link-preview-bar {
  width: 3px; flex-shrink: 0;
  border-radius: 2px;
  background: var(--blue);
  align-self: stretch;
}
.tg-link-preview-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tg-link-preview-site { font-size: 12px; color: var(--blue); font-weight: 600; }
.tg-link-preview-title { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ══ 消息右键菜单 ══ */
.tg-msg-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--surface2);
  border-radius: 14px;
  padding: 6px;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
  border: 0.5px solid rgba(255,255,255,.08);
  transform-origin: top left;
  transform: scale(.85);
  opacity: 0;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), opacity .12s;
}
.tg-msg-ctx-menu.open {
  transform: scale(1);
  opacity: 1;
}
.tg-ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  border: none; background: transparent;
  color: var(--text); font-size: 15px;
  cursor: pointer; border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.tg-ctx-item:active { background: rgba(255,255,255,.07); }
.tg-ctx-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

/* ══ 复制提示 Toast ══ */
.tg-copy-toast {
  position: fixed;
  bottom: 90px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: rgba(36,47,61,.96);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  padding: 9px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 9997;
}
.tg-copy-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ══ 消息行长按反馈 ══ */
.tg-msg-row:active .tg-bubble { opacity: .75; }

/* ══ 表情选择器 ══ */
.tg-emoji-picker {
  position: absolute;
  bottom: 100%; left: 0; right: 0;
  background: var(--surface);
  border-top: 0.5px solid rgba(255,255,255,.08);
  padding: 10px 8px 6px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px,1fr));
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 200;
  scrollbar-width: none;
}
.tg-emoji-picker::-webkit-scrollbar { display: none; }
.tg-emoji-picker.hidden { display: none; }
.tg-emoji-btn-cell {
  font-size: 26px;
  line-height: 1;
  padding: 6px;
  text-align: center;
  border: none; background: transparent;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s;
}
.tg-emoji-btn-cell:active { background: rgba(255,255,255,.1); }

/* ══ 滚动到底部按钮 ══ */
.tg-scroll-down {
  position: absolute;
  bottom: 72px; right: 14px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 0.5px solid rgba(255,255,255,.12);
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  z-index: 100;
  transition: opacity .2s, transform .2s;
  -webkit-tap-highlight-color: transparent;
}
.tg-scroll-down.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
.tg-scroll-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--blue);
  color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 999px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
}
.tg-scroll-badge.hidden { display: none; }

/* ══ 图片/视频气泡 ══ */
.tg-bubble-photo-img {
  display: block;
  max-width: 220px; max-height: 280px;
  border-radius: 10px;
  object-fit: cover;
  cursor: zoom-in;
  margin-bottom: 4px;
}

/* ══ 图片灯箱 ══ */
.tg-lightbox {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
  backdrop-filter: blur(8px);
}
.tg-lightbox.open { opacity: 1; }
.tg-lightbox img {
  max-width: 96vw; max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 8px 48px rgba(0,0,0,.6);
  transform: scale(.92);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.tg-lightbox.open img { transform: scale(1); }
.tg-lightbox-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px;
  background: rgba(255,255,255,.12);
  border: none; border-radius: 50%;
  color: #fff; font-size: 20px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ══ 资料页链接按钮（添加/屏蔽）══ */
.tg-profile-action-card { padding: 0; }
.tg-profile-link-btn {
  display: block; width: 100%;
  padding: 14px 16px;
  background: none; border: none;
  font-size: 17px; font-weight: 400;
  text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tg-profile-link-btn:active { opacity: .6; }
.tg-profile-link-blue { color: var(--blue); }
.tg-profile-link-red  { color: #ff3b30; }
.tg-profile-hint { font-size: 13px; color: var(--text3); padding: 8px 20px 4px; }

/* ══ 验证徽章 ══ */
.tg-profile-verify {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 20px 16px;
  font-size: 13px; color: #8e8e93;
}

/* ══ 字段间距加大 ══ */
#profileInfoCard .tg-profile-field { padding: 14px 16px; min-height: 64px; }

/* reply bar */
.tg-reply-bar{display:flex;align-items:center;gap:8px;padding:8px 12px 6px;background:var(--surface);border-top:.5px solid rgba(255,255,255,.06);flex-shrink:0;animation:slideUp .15s ease}
.tg-reply-bar.hidden{display:none}
.tg-reply-bar-line{width:3px;align-self:stretch;flex-shrink:0;background:var(--blue);border-radius:2px}
.tg-reply-bar-body{flex:1;min-width:0}
.tg-reply-bar-label{font-size:12px;color:var(--blue);font-weight:600;margin-bottom:1px}
.tg-reply-bar-text{font-size:13px;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-reply-bar-close{border:none;background:none;color:var(--text3);font-size:17px;cursor:pointer;padding:4px;flex-shrink:0;line-height:1}
@keyframes slideUp{from{transform:translateY(6px);opacity:0}to{transform:none;opacity:1}}

/* bubble quote */
.tg-bubble-quote{display:flex;gap:6px;margin:-2px -10px 6px;padding:6px 10px 6px 8px;background:rgba(0,0,0,.15);border-radius:8px 8px 0 0;cursor:pointer}
.tg-bubble-quote-bar{width:3px;flex-shrink:0;border-radius:2px;background:var(--blue);align-self:stretch;min-height:28px}
.tg-bubble-quote-body{min-width:0}
.tg-bubble-quote-name{font-size:12px;color:var(--blue);font-weight:600;margin-bottom:1px}
.tg-bubble-quote-text{font-size:13px;color:rgba(255,255,255,.65);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* conv search bar */
.tg-conv-search-bar{display:flex;align-items:center;gap:6px;padding:6px 10px;background:var(--surface);border-bottom:.5px solid rgba(255,255,255,.06);flex-shrink:0}
.tg-conv-search-bar.hidden{display:none}
.tg-conv-search-input{flex:1;background:rgba(255,255,255,.07);border:none;border-radius:8px;padding:6px 10px;color:#fff;font-size:14px;outline:none}
.tg-conv-search-input::placeholder{color:var(--text3)}
.tg-conv-search-nav{display:flex;align-items:center;gap:2px;flex-shrink:0}
.tg-conv-search-nav button{background:none;border:none;color:var(--blue);font-size:18px;cursor:pointer;padding:2px 4px;line-height:1}
#convSearchCount{font-size:12px;color:var(--text3);min-width:36px;text-align:center}
.tg-conv-search-close{background:none;border:none;color:var(--text3);font-size:16px;cursor:pointer;padding:2px 4px;flex-shrink:0}

/* pull to refresh spin */
@keyframes spin{to{transform:rotate(360deg)}}

/* forward modal */
.tg-forward-overlay{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:9000;display:flex;align-items:flex-end;justify-content:center}
.tg-forward-overlay.hidden{display:none}
.tg-forward-modal{background:var(--surface);border-radius:18px 18px 0 0;width:100%;max-height:70vh;display:flex;flex-direction:column;overflow:hidden;padding-bottom:env(safe-area-inset-bottom,0)}
.tg-forward-title{font-size:17px;font-weight:600;color:#fff;text-align:center;padding:16px 0 8px}
.tg-forward-list{flex:1;overflow-y:auto;padding:4px 0 12px}
.tg-forward-item{display:flex;align-items:center;gap:12px;padding:9px 16px;cursor:pointer}
.tg-forward-item:active{background:rgba(255,255,255,.06)}
.tg-forward-item-name{font-size:15px;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* 应用内网页/小程序 Webview：机器人按钮、链接按钮统一在这里打开，不再弹出新标签页 */
.tg-webview-overlay{position:fixed;inset:0;background:var(--surface);z-index:9500;display:flex;flex-direction:column}
.tg-webview-overlay.hidden{display:none}
.tg-webview-header{display:flex;align-items:center;gap:10px;padding:calc(env(safe-area-inset-top,0) + 8px) 12px 8px;background:var(--header-bg,#182533);flex-shrink:0}
.tg-webview-close,.tg-webview-external{background:none;border:0;color:#fff;font-size:18px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;flex-shrink:0;cursor:pointer;text-decoration:none;border-radius:50%}
.tg-webview-close:active,.tg-webview-external:active{background:rgba(255,255,255,.12)}
.tg-webview-titlewrap{flex:1;min-width:0;text-align:center}
.tg-webview-title{color:#fff;font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-webview-subtitle{color:rgba(255,255,255,.6);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.tg-webview-frame{flex:1;width:100%;border:0;background:#fff}

/* sticker bubble */
.tg-sticker-bubble{font-size:72px;line-height:1;text-align:center;padding:4px 0}
/* GIF bubble */
.tg-gif-bubble{position:relative;width:180px;height:120px;border-radius:10px;overflow:hidden;background:#182533;display:flex;align-items:center;justify-content:center;margin-bottom:4px;cursor:pointer}
.tg-gif-label{position:absolute;bottom:6px;left:6px;background:rgba(0,0,0,.6);color:#fff;font-size:11px;font-weight:700;padding:2px 5px;border-radius:4px;letter-spacing:.5px}
.tg-video-bubble{position:relative;width:180px;height:120px;border-radius:10px;overflow:hidden;background:#0d1b2a;display:flex;align-items:center;justify-content:center;margin-bottom:4px;cursor:pointer}
/* voice bubble */
.tg-voice-bubble{display:flex;align-items:center;gap:8px;min-width:180px;padding:2px 0}
.tg-voice-wave{display:flex;align-items:center;gap:2px;flex:1;height:28px}
.tg-voice-wave span{display:inline-block;width:3px;border-radius:2px;background:rgba(255,255,255,.4);flex-shrink:0}
.tg-voice-dur{font-size:12px;color:rgba(255,255,255,.5);flex-shrink:0}
/* doc bubble */
.tg-doc-bubble{display:flex;align-items:center;gap:10px;min-width:180px}
.tg-doc-icon{font-size:32px;flex-shrink:0}
.tg-doc-info{min-width:0}
.tg-doc-name{font-size:13px;color:#fff;font-weight:500;word-break:break-all;line-height:1.3}
.tg-doc-size{font-size:11px;color:rgba(255,255,255,.45);margin-top:2px}

/* ── 浅色气泡（收到的消息）内媒体/引用文字改用深色，保证可读性 ── */
.tg-in .tg-doc-name { color: #2b2540; }
.tg-in .tg-doc-size, .tg-in .tg-voice-dur { color: rgba(43,37,64,.5); }
.tg-in .tg-voice-wave span { background: rgba(43,37,64,.35); }
.tg-in .tg-bubble-quote { background: rgba(60,40,90,.07); }
.tg-in .tg-bubble-quote-text { color: rgba(43,37,64,.65); }
.tg-in .tg-link-preview-title { color: #2b2540; }
.tg-in.tg-bubble-media .tg-bubble-text,
.tg-in .tg-bubble-media .tg-bubble-text { color: rgba(43,37,64,.65); }
/* members grid */
.tg-profile-section-label{font-size:13px;color:var(--text3);padding:14px 16px 6px;text-transform:uppercase;letter-spacing:.5px}
.tg-profile-section-card{background:#fff;border-radius:12px;margin:8px 12px;overflow:hidden}
.tg-members-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:4px;padding:8px 12px 16px;background:#fff;border-radius:12px;margin:0 12px 8px}
.tg-member-item{display:flex;flex-direction:column;align-items:center;gap:5px;cursor:pointer;padding:6px 4px;border-radius:8px}
.tg-member-item:active{background:rgba(0,0,0,.05)}

/* ── 群组/频道真实成员列表 ── */
.tg-members-list{background:#fff;border-radius:12px;margin:0 12px 16px;overflow:hidden}
.tg-member-row{display:flex;align-items:center;gap:10px;padding:9px 14px;border-bottom:1px solid rgba(0,0,0,.05)}
.tg-member-row:last-child{border-bottom:none}
.tg-member-row-body{flex:1;min-width:0}
.tg-member-row-name{font-size:15px;color:#000;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tg-member-role{font-size:12.5px;color:var(--blue);font-weight:500;flex-shrink:0}
.tg-member-status{font-size:12.5px;color:var(--text3);flex-shrink:0}
.tg-member-name{font-size:11px;color:#333;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:60px}
