:root {
  --bg: #ffffff;
  --card: #fff;
  --text: #000;
  --muted: #8e8e93;
  --line: rgba(60, 60, 67, 0.12);
  --blue: #007aff;
  --green: #34c759;
  --green-soft: #ecfdf3;
  --tg: #229ed9;
  --nav-h: 54px;
}
html[data-theme="dark"] {
  --bg: #000;
  --card: #1c1c1e;
  --text: #fff;
  --muted: #98989d;
  --line: rgba(84, 84, 88, 0.65);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}
.app-root {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  overflow: hidden;
  min-height: 0;
}
.screen-wrap {
  overflow: hidden;
  min-height: 0;
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.screen.active { display: flex; }

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 8px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar h1 { font-size: 17px; font-weight: 700; text-align: center; margin: 0; }
.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}
.thread-title-wrap { min-width: 0; text-align: left; }
.thread-title-wrap h1 {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-avatar-btn {
  border: 0;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.thread-avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thread-avatar-btn.has-photo #thread-avatar-fallback { display: none; }
.room-edit-avatar {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  border: 0;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 32px;
  font-weight: 700;
  cursor: pointer;
}
.room-edit-avatar img { width: 100%; height: 100%; object-fit: cover; }
.room-edit-avatar.has-photo span { display: none; }
.room-qr-block {
  margin-top: 8px;
  padding-top: 8px;
  text-align: center;
}
.room-qr-block > label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
  text-align: left;
}
.room-qr-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: left;
}
.room-qr-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}
.room-qr-card img {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 8px;
  background: #fff;
}
.room-qr-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-qr-save {
  margin-top: 12px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
}
.room-qr-save:active { opacity: 0.85; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-field input, .form-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  background: #fff;
}
.thread-title-wrap .sub { text-align: left; margin-top: 0; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; }
.pill-btn, .icon-btn {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 17px;
  cursor: pointer;
  padding: 6px 8px;
}
.pill-btn.compose-plus-btn {
  min-width: 36px;
  padding: 0 12px;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  position: relative;
}
.compose-plus-btn .compose-plus-glyph {
  position: relative;
  z-index: 1;
  display: block;
  line-height: 1;
}
.compose-plus-ring {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  pointer-events: none;
  color: var(--text, #111);
  opacity: .55;
  animation: composePlusSpin 2.4s linear infinite;
}
.compose-plus-btn.is-uploading .compose-plus-ring,
.moments-story-create.is-uploading .moments-story-plus-ring {
  opacity: 1;
  color: var(--blue, #007aff);
  animation-duration: .85s;
}
@keyframes composePlusSpin {
  to { transform: rotate(360deg); }
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: rgba(120,120,128,.12);
  display: grid; place-items: center;
  font-size: 18px;
}
.search-wrap {
  padding: 8px 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.chat-folder-bar {
  background: var(--bg);
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.chat-folder-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 12px 10px;
}
.chat-folder-scroll::-webkit-scrollbar { display: none; }
.chat-folder-tab {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.chat-folder-tab.on {
  color: var(--blue);
  font-weight: 700;
  background: rgba(0,122,255,.1);
}
.chat-folder-tab .folder-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.chat-folder-tab:not(.on) .folder-badge {
  background: rgba(120,120,128,.35);
  color: var(--text);
}
.chat-row-folder-tag {
  display: inline-block;
  font-size: 11px;
  color: var(--blue);
  margin-right: 4px;
  font-weight: 600;
}
.search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(120,120,128,.12);
  border-radius: 10px;
  padding: 8px 10px;
}
.search input {
  border: 0; background: transparent; flex: 1;
  font-size: 17px; outline: none; color: var(--text);
}
.scroll-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

/* 五 Tab 统一可上下滑动区域 */
.tab-scroll,
.scroll-body,
.rooms-scroll,
.messages,
.moments-scroll,
.overlay-body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

/* 底栏样式见 jw-bottom-nav.css（锁定，勿在此改） */

/* List rows */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: inherit;
  border-bottom: 1px solid var(--line);
}
.list-row:active { opacity: .7; }
.avatar {
  width: 48px; height: 48px;
  border-radius: 999px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }
.avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
}
.avatar-wrap .avatar { width: 100%; height: 100%; }
.avatar-unread {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  z-index: 2;
  box-shadow: 0 0 0 2px var(--card, #fff);
  pointer-events: none;
}
.row-unread-tag {
  color: #22c55e;
  font-weight: 700;
}
.row-moment-tag {
  color: #f59e0b;
  font-weight: 600;
}
.nav-moment-badge {
  /* legacy alias — use .nav-badge on bottom nav */
}
.row-sub .row-tg-link,
.row-sub .copy-link,
.thread-sub .copy-link,
.thread-sub-link.copy-link {
  display: inline;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--tg);
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  vertical-align: baseline;
}
.row-title { font-size: 17px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main { flex: 1; min-width: 0; }
.chat-row-meta {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding-left: 8px;
  font-size: 13px;
  color: var(--muted);
}
.chat-row-pin, .chat-row-mute { font-size: 12px; opacity: .85; pointer-events: none; }
.chat-ctx-menu {
  position: fixed;
  z-index: 10050;
  min-width: 220px;
  max-width: min(280px, calc(100vw - 16px));
  padding: 6px 0;
  background: var(--card, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .18), 0 0 0 1px rgba(0, 0, 0, .06);
  user-select: none;
}
.chat-ctx-submenu { min-width: 200px; }
.chat-ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 16px;
  font-size: 15px;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.chat-ctx-item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text, #111);
}
.chat-ctx-item span { flex: 1; }
.chat-ctx-item:hover, .chat-ctx-item:focus-visible { background: rgba(0, 0, 0, .05); }
.chat-ctx-item.chat-ctx-danger { color: #ff3b30; }
.chat-ctx-item.chat-ctx-danger svg { color: #ff3b30; }
.chat-ctx-chev {
  font-style: normal;
  color: var(--muted);
  font-size: 18px;
  margin-left: auto;
}
.chat-ctx-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--line, rgba(0, 0, 0, .08));
}
.chat-ctx-folder-item .folder-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.row-sub { font-size: 14px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.row-sub .copy-link { margin-right: 0; word-break: break-all; white-space: normal; text-align: left; }
.row-link-pill {
  display: inline;
  border: 0;
  background: none;
  padding: 0;
  color: var(--tg);
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}
.thread-sub .copy-link { word-break: break-all; white-space: normal; }
.row-meta { font-size: 13px; color: var(--muted); flex-shrink: 0; text-align: right; }
.row-meta .missed { color: #ff3b30; }

/* Chat thread */
.chat-list-view, .chat-thread-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}
.chat-thread-view { display: none; }
.chat-thread-view.open { display: flex; }
.chat-list-view.hidden { display: none; }
.rooms-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}
.room-row .badge-tg {
  font-size: 10px; padding: 1px 5px; border-radius: 4px;
  background: var(--tg); color: #fff; margin-left: 4px;
}
.tg-banner { display: none !important; }
.msg .msg-body .msg-link,
.msg .bubble .msg-link,
.row-user-link.user-mention {
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  color: var(--tg);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  word-break: break-all;
  text-align: left;
}
.row-user-link.user-mention { font-size: 13px; }
.copy-toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  background: rgba(0,0,0,.82);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.thread-sub { line-height: 1.2; font-size: 12px; color: var(--muted); }

/* 会话顶栏：单行紧凑，给消息区留高度 */
.chat-thread-view.open .topbar {
  padding: 6px 10px 5px;
  gap: 6px;
  min-height: 0;
}
.chat-thread-view.open .topbar-left .pill-btn {
  font-size: 15px;
  padding: 2px 0;
}
.chat-thread-view.open .thread-avatar-btn {
  width: 32px;
  height: 32px;
  font-size: 13px;
}
.chat-thread-view.open .topbar-center { gap: 8px; }
.chat-thread-view.open .thread-title-wrap h1 { font-size: 15px; line-height: 1.2; }
.chat-thread-view.open .thread-title-wrap .sub {
  margin-top: 1px;
  font-size: 11px;
  line-height: 1.1;
}
.thread-link-btn {
  border: 0;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tg);
  background: rgba(34, 158, 217, 0.12);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.thread-link-btn:active { opacity: 0.75; }

.chat-thread-view.open .composer-bar {
  flex-shrink: 0;
  z-index: 100;
}
.composer-bar {
  position: relative;
  flex-shrink: 0;
}

.form-copy-link {
  display: block;
  width: 100%;
  word-break: break-all;
  cursor: pointer;
}
.tg-banner.show { display: none !important; }
.tg-banner .tg-link,
.tg-banner .tg-open-btn,
.thread-sub-link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--tg);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.tg-banner .tg-open-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--tg);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
}
.tg-banner a {
  display: inline-block; margin-top: 8px; padding: 8px 14px;
  border-radius: 999px; background: var(--tg); color: #fff;
  text-decoration: none; font-weight: 700; font-size: 13px;
}
.messages {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg { max-width: 100%; width: 100%; align-self: stretch; }
.msg.mine { align-self: stretch; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; padding: 0; }
.msg.mine .meta { text-align: left; }
.msg .msg-body,
.msg .bubble {
  padding: 0 0 12px;
  background: none;
  border: 0;
  border-radius: 0;
  font-size: 16px;
  line-height: 1.45;
  word-break: break-word;
  color: var(--text);
}
.msg.mine .msg-body,
.msg.mine .bubble {
  background: none;
  border: 0;
  color: var(--text);
}
.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
  background: linear-gradient(180deg, rgba(214, 234, 206, 0.95) 0%, rgba(198, 228, 191, 0.98) 100%);
  border-top: 0;
  position: relative;
}
.composer-icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  color: #1c1c1e;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: none;
}
.composer-icon-btn:active { opacity: .75; transform: scale(.96); }
.composer-attach { background: rgba(255, 236, 179, 0.95); }
.composer-voice { background: rgba(187, 240, 200, 0.95); }
.composer-voice.recording { background: #ff3b30; color: #fff; }
.composer-send {
  background: #007aff;
  color: #fff;
}
.composer-action {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}
.composer-action .composer-icon-btn {
  position: absolute;
  inset: 0;
}
.composer-action .composer-icon-btn[hidden] {
  display: none !important;
}
.composer-svg {
  width: 22px;
  height: 22px;
  display: block;
}
.composer-input-wrap {
  position: relative;
  min-width: 0;
}
.composer-input-wrap input {
  width: 100%;
  border: 0;
  border-radius: 22px;
  padding: 11px 40px 11px 16px;
  font-size: 16px;
  outline: none;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
.composer-input-wrap.composer-channel input {
  padding-right: 72px;
}
.composer-input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(60, 60, 67, 0.55);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.composer-input-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}
.composer-sticker { right: 8px; }
.composer-bell { right: 38px; }
.composer-input-icon:active { opacity: .65; }
.composer-input-icon[hidden] { display: none !important; }
.composer-emoji-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: #eceff1;
  border-top: 1px solid var(--line);
  height: min(42vh, 300px);
  max-height: 300px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.composer-emoji-panel[hidden] { display: none !important; }
.composer-emoji-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 4px;
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.composer-emoji-tab {
  border: 0;
  background: transparent;
  width: 40px;
  height: 36px;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.composer-emoji-tab.on {
  background: rgba(255,255,255,.85);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.composer-emoji-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 6px 8px 8px;
  align-content: start;
}
.composer-emoji-btn {
  border: 0;
  background: transparent;
  font-size: 30px;
  line-height: 1;
  padding: 0;
  width: 100%;
  aspect-ratio: 1;
  cursor: pointer;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  -webkit-text-size-adjust: none;
}
.composer-emoji-btn:active { background: rgba(120,120,128,.15); }
.composer-emoji-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0));
  background: rgba(255,255,255,.55);
  border-top: 1px solid rgba(0,0,0,.06);
  flex-shrink: 0;
}
.composer-emoji-del {
  width: 44px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: rgba(255,255,255,.9);
  font-size: 20px;
  color: #3a3a3c;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.composer-emoji-del:active { opacity: .7; }
.composer-emoji-send {
  min-width: 72px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: #007aff;
  cursor: pointer;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}
.composer-emoji-send:disabled {
  background: #c7c7cc;
  color: #fff;
  cursor: default;
}
.composer-emoji-send:not(:disabled):active { opacity: .85; }
.msg-audio {
  display: block;
  width: min(100%, 260px);
  height: 36px;
  margin: 2px 0 6px;
}
.composer.disabled input { opacity: .5; pointer-events: none; }
.composer.disabled button { display: none; }
.msg.pending .msg-body,
.msg.pending .bubble { opacity: 0.72; }
.msg-media {
  display: block;
  max-width: min(100%, 320px);
  max-height: 280px;
  border-radius: 8px;
  margin: 2px 0 6px;
  object-fit: contain;
  background: rgba(0,0,0,.04);
}
img.msg-media {
  width: 100%;
  object-fit: cover;
}
.msg-video-wrap {
  display: inline-block;
  max-width: min(100%, 320px);
  max-height: 280px;
  border-radius: 8px;
  overflow: hidden;
  margin: 2px 0 6px;
  line-height: 0;
  background: #000;
}
.msg-video-wrap .msg-media {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  object-fit: contain;
  background: #000;
}
.msg-text { margin-top: 4px; }
.empty {
  padding: 40px 24px; text-align: center;
  color: var(--muted); font-size: 15px; line-height: 1.6;
}

/* Settings */
.settings-scroll {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
}
.settings-hero {
  padding: 10px 16px 22px;
  text-align: center;
  background: var(--bg);
}
.settings-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.settings-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qr-icon-btn .qr-glyph {
  color: var(--text);
}
.round-btn-spacer {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.round-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text);
  padding: 0;
}
.round-btn-text {
  width: auto;
  min-width: 40px;
  padding: 0 14px;
  font-size: 16px;
  font-weight: 500;
}
.grid-dots {
  display: inline-grid;
  grid-template-columns: repeat(2, 5px);
  gap: 3px;
}
.grid-dots i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: currentColor;
}
.settings-hero-avatar {
  width: 104px;
  height: 104px;
  margin: 0 auto 14px;
  cursor: pointer;
}
.settings-hero-avatar .avatar-ring-inner {
  font-size: 36px;
  font-weight: 600;
  position: relative;
}
.settings-hero-avatar .avatar-ring-inner img {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.settings-hero-avatar .avatar-ring-inner #settings-avatar-fallback {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}
.settings-hero-avatar.has-photo .avatar-ring-inner #settings-avatar-fallback { display: none !important; }
.settings-hero-avatar.has-photo .avatar-ring-inner img { display: block !important; }
.settings-hero-avatar:not(.has-photo) .avatar-ring-inner img { display: none !important; }

/* 头像外圈：登录=蓝绿渐变，退出=白圈 */
.avatar-ring {
  border-radius: 999px;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  flex-shrink: 0;
  display: block;
  line-height: 0;
  overflow: visible;
}
.avatar-ring.avatar-ring-active {
  padding: 3px;
  background: linear-gradient(145deg, #2aabee 0%, #27d366 100%);
}
.avatar-ring.avatar-ring-off {
  padding: 0;
  background: transparent;
  box-shadow: none;
}
.avatar-ring .avatar-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-sizing: border-box;
}
.avatar-ring.avatar-ring-active .avatar-ring-inner {
  border: 3px solid #fff;
  background: linear-gradient(145deg, #6b7fd7, #8b5cf6);
  color: #fff;
}
.avatar-ring.avatar-ring-active.has-photo .avatar-ring-inner {
  background: #000;
}
.avatar-ring.avatar-ring-off .avatar-ring-inner {
  border: 3px solid #e5e5ea;
  background: #fff;
  color: #c7c7cc;
}
.avatar-ring .avatar-ring-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.settings-hero-name {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.settings-hero-user {
  font-size: 16px;
  color: var(--muted);
  margin-top: 6px;
}
.settings-hero-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.settings-hero-link:active { opacity: 0.65; }
.settings-cell-static {
  cursor: default;
  border-bottom: 0;
}
.settings-cell-static .cell-body {
  color: var(--blue);
  font-size: 15px;
}

.settings-profile {
  text-align: center;
  padding: 20px 14px 16px;
  background: var(--card);
  margin-bottom: 8px;
}
.settings-profile .avatar { width: 88px; height: 88px; font-size: 32px; margin: 0 auto 10px; }
.settings-profile h2 { font-size: 22px; font-weight: 600; }
.settings-profile p { font-size: 15px; color: var(--muted); margin-top: 4px; }
.settings-group {
  background: var(--card);
  border-radius: 12px;
  margin: 0 14px 12px;
  overflow: hidden;
}
.settings-cell {
  display: flex; align-items: center; gap: 12px;
  width: 100%; border: 0; background: transparent;
  padding: 11px 14px; text-align: left; cursor: pointer;
  color: inherit; font-size: 17px;
  border-bottom: 1px solid var(--line);
}
.settings-cell:last-child { border-bottom: 0; }
.settings-cell:active { background: rgba(120,120,128,.08); }
.cell-ico {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center; font-size: 16px; flex-shrink: 0;
}
.cell-ico.blue { background: #007aff; color: #fff; }
.cell-ico.red { background: #ff3b30; color: #fff; }
.cell-ico.green { background: #34c759; color: #fff; }
.cell-ico.orange { background: #ff9500; color: #fff; }
.cell-ico.purple { background: #af52de; color: #fff; }
.cell-ico.gray { background: #8e8e93; color: #fff; }
.cell-ico.teal { background: #5ac8fa; color: #fff; }
.cell-ico.pink { background: #ff2d55; color: #fff; }
.cell-ico.yellow { background: #ffcc00; color: #fff; }
.cell-body { flex: 1; min-width: 0; }
.cell-value { font-size: 17px; color: var(--muted); margin-right: 4px; }
.cell-chevron { color: var(--muted); font-size: 14px; }
.settings-logout { justify-content: center; }
.settings-logout .cell-body {
  flex: none;
  color: #ff3b30;
  font-weight: 600;
  text-align: center;
}
.settings-login-btn {
  display: inline-block;
  width: auto;
  margin: 10px auto 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}
.settings-login-btn[hidden] { display: none !important; }

/* Overlay pages */
.overlay {
  display: none;
  position: absolute; inset: 0;
  background: var(--bg);
  z-index: 80;
  flex-direction: column;
  overflow: hidden;
}
.overlay.open { display: flex; }
.overlay-nav {
  display: grid; grid-template-columns: 80px 1fr 80px;
  align-items: center; padding: 10px 14px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.overlay-nav h2 { text-align: center; font-size: 17px; font-weight: 600; }
.overlay-nav button { border: 0; background: transparent; color: var(--blue); font-size: 17px; cursor: pointer; }
.overlay-body { padding: 12px 14px 24px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 16px; background: var(--card); color: var(--text);
}
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--card);
  border-bottom: 1px solid var(--line); font-size: 17px;
}
.toggle-row input { width: 51px; height: 31px; accent-color: var(--green); }

.sheet-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 200;
}
.sheet-backdrop.show { display: block; }
.action-sheet {
  position: fixed; left: 0; right: 0; bottom: var(--jw-ios-bottom, 0px); z-index: 201;
  background: var(--card);
  border-radius: 14px 14px 0 0;
  padding: 8px 0 calc(12px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform .25s ease;
}
.action-sheet.show { transform: translateY(0); }
.sheet-item {
  display: block;
  width: 100%; border: 0; background: transparent;
  padding: 14px 20px; font-size: 17px; color: var(--blue);
  cursor: pointer; text-align: center;
}
.sheet-cancel {
  display: block; width: calc(100% - 24px); margin: 8px auto 0;
  border: 0; background: rgba(120,120,128,.12);
  border-radius: 12px; padding: 14px; font-size: 17px; font-weight: 600; cursor: pointer;
}
.call-actions { display: flex; gap: 12px; margin-top: 8px; }
.call-actions button {
  flex: 1; border: 0; border-radius: 12px; padding: 12px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-call { background: var(--green); color: #fff; }
.btn-tg { background: var(--tg); color: #fff; }

/* Calls tab (Telegram-style) */
.calls-toolbar {
  padding: 8px 14px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.calls-segment {
  display: flex;
  gap: 0;
  padding: 2px;
  border-radius: 10px;
  background: rgba(120, 120, 128, 0.16);
}
.calls-seg-btn {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.calls-seg-btn.on {
  background: var(--card, #fff);
  color: var(--text, #1a1a1a);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.calls-scroll { padding-bottom: 8px; }
.calls-new-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: var(--blue, #007aff);
  font-size: 17px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.calls-new-row:active { opacity: 0.7; }
.calls-new-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.12);
  color: var(--blue, #007aff);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.call-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.call-item:active { opacity: 0.72; }
.call-item.editing { grid-template-columns: auto auto 1fr auto; }
.call-item-main {
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.call-item .avatar-wrap { width: 48px; height: 48px; }
.call-item-main { min-width: 0; }
.call-item-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.call-item-name {
  font-size: 17px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-item-name.missed { color: #ff3b30; }
.call-item-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-item-sub.missed { color: #ff3b30; }
.call-dir {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--muted);
}
.call-dir.missed { color: #ff3b30; }
.call-item-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.call-item-time {
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}
.call-info-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--blue, #007aff);
  font-size: 17px;
  font-weight: 600;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.call-info-btn:active { opacity: 0.6; }
.call-delete-btn {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.calls-empty-inline {
  padding: 28px 20px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}
.calls-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  color: inherit;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.calls-picker-row:active { opacity: 0.7; }

/* Voice call overlay */
.voice-call {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: linear-gradient(180deg, #1c1c1e 0%, #000 100%);
  color: #fff;
}
.voice-call.open { display: grid; place-items: center; }
.voice-call-inner {
  width: 100%;
  padding: calc(48px + env(safe-area-inset-top, 0)) 24px calc(48px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.voice-call-avatar { margin-bottom: 20px; }
.voice-call-avatar .avatar {
  width: 120px;
  height: 120px;
  font-size: 42px;
}
.voice-call-name {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 600;
}
.voice-call-status,
.voice-call-timer {
  margin: 0 0 48px;
  font-size: 17px;
  color: rgba(255, 255, 255, 0.72);
}
.voice-call-hangup {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  margin-top: auto;
  transform: rotate(135deg);
}
.voice-call-hangup:active { opacity: 0.85; }

.section-label {
  padding: 8px 14px 4px; font-size: 13px; color: var(--muted);
  text-transform: uppercase;
}

/* In-app link browser (开元式：点链接在 App 内打开) */
.link-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  background: var(--bg, #fff);
}
.link-viewer.open { display: flex; }
.link-viewer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--bg, #fff);
  flex-shrink: 0;
}
.link-viewer-bar button {
  border: 0;
  background: rgba(120,120,128,.12);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: inherit;
}
.link-viewer-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-viewer-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}
.link-viewer-fallback {
  display: block;
  text-align: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  font-size: 15px;
  font-weight: 600;
  color: var(--tg, #229ed9);
  text-decoration: none;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ---- 朋友圈 ---- */
.moments-scroll {
  background: var(--bg);
}
.moments-gallery-btn {
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
}
.moments-compose {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 12px 14px;
  border: 0;
  border-bottom: 8px solid var(--line);
  background: var(--card);
  text-align: left;
  cursor: pointer;
}
.moments-compose-avatar {
  width: 46px;
  height: 46px;
  font-size: 16px;
  font-weight: 600;
}
.moments-compose-avatar .avatar-ring-inner {
  font-size: 16px;
}
.moments-compose-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.moments-compose-text {
  flex: 1;
  font-size: 16px;
  color: var(--muted);
}
.moments-compose-icon {
  font-size: 13px;
  color: var(--blue);
  font-weight: 600;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.moments-stories-wrap {
  background: var(--card);
  border-bottom: 8px solid var(--line);
  padding: 12px 0 14px;
}
.moments-stories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 12px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
}
.moments-story-card {
  position: relative;
  flex: 0 0 108px;
  width: 108px;
  height: 168px;
  border-radius: 10px;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: #e8eaed;
}
.moments-story-create { cursor: pointer; }
.moments-story-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}
.moments-story-ring {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--blue);
  z-index: 2;
  pointer-events: none;
}
.moments-story-plus-wrap {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 38px;
  height: 38px;
  z-index: 3;
}
.moments-story-plus-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #fff;
  opacity: .95;
  animation: composePlusSpin 2.4s linear infinite;
  pointer-events: none;
}
.moments-story-plus {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  line-height: 22px;
  text-align: center;
  z-index: 1;
}
.moments-story-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24px 8px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
  z-index: 2;
}
.moments-feed { padding-bottom: 12px; }
.moments-empty { padding: 48px 20px; }
.moments-post {
  background: var(--card);
  margin-bottom: 8px;
  padding: 12px 14px 14px;
}
.moments-post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.moments-post-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
}
.moments-post-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.moments-post-name {
  font-size: 15px;
  font-weight: 600;
}
.moments-post-time {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.moments-post-caption {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.moments-post-media {
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.moments-post-media img,
.moments-post-media video {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #111;
}


/* snow-white unify */
html, body, .app-root, .screen-wrap, .screen, .scroll-body, .rooms-scroll, .calls-scroll, .chat-list-view, .chat-thread-view, .settings-scroll, #contacts-list, #chat-rooms-list, #calls-list, .moments-scroll {
  background: #ffffff !important;
  background-color: #ffffff !important;
}
.topbar, .search-wrap, .chat-folder-bar, .bottom-nav, #jw-bottom-nav.bottom-nav {
  background: #ffffff !important;
  background-color: #ffffff !important;
}
.search, .search input { background: #ffffff !important; background-color: #ffffff !important; }


/* settings-login-btn text-only */
.settings-login-btn {
  display: inline-block !important;
  width: auto !important;
  margin: 10px auto 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  color: #007aff !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  box-shadow: none !important;
}
