﻿/* ============================================================
   鍐呴儴鑱婂ぉ瀹?路 鏍峰紡
   ============================================================ */

:root {
  --bg:          #0d0f15;
  --panel:       #141822;
  --panel-2:     #1a1f2b;
  --panel-3:     #222836;
  --border:      #262d3d;
  --border-soft: #1f2532;
  --text:        #e7eaf2;
  --text-dim:    #a2aabd;
  --muted:       #7b839a;
  --accent:      #6366f1;
  --accent-soft: rgba(99, 102, 241, .16);
  --accent-2:    #8b5cf6;
  --green:       #22c55e;
  --red:         #ef4444;
  --radius:      14px;
  --shadow:      0 12px 40px rgba(0, 0, 0, .45);
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

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

.sprite { display: none; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

input, textarea {
  font: inherit;
  color: var(--text);
  background: none;
  border: 0;
  outline: none;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb {
  background: #2c3446;
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: #3a4459; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------- 閫氱敤缁勪欢 */

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  flex: none;
  user-select: none;
  letter-spacing: .5px;
}

.avatar.big {
  width: 84px;
  height: 84px;
  font-size: 32px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.icon-btn:hover {
  background: var(--panel-3);
  color: var(--text);
}
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small svg { width: 15px; height: 15px; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
  transition: filter .15s, transform .05s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.btn-ghost {
  padding: 10px 16px;
  border-radius: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--panel-3); color: var(--text); }

.link-btn {
  color: var(--accent);
  font-size: 13px;
  padding: 4px;
}
.link-btn:hover { text-decoration: underline; }

/* ---------------------------------------------------------- 鐧诲綍椤?*/

.auth-screen {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  overflow: auto;
}

.auth-bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(99, 102, 241, .22), transparent 70%),
    radial-gradient(700px 500px at 85% 90%, rgba(139, 92, 246, .18), transparent 70%),
    var(--bg);
}

.auth-card {
  position: relative;
  width: min(420px, 100%);
  background: rgba(20, 24, 34, .88);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
  color: #fff;
}
.brand-mark svg { width: 25px; height: 25px; stroke-width: 2.1; }
.brand h1 { font-size: 19px; margin: 0 0 4px; letter-spacing: .5px; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--panel-2);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1;
  padding: 9px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13.5px;
  transition: .15s;
}
.auth-tab.active {
  background: var(--panel-3);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

.field {
  display: block;
  margin-bottom: 16px;
}
.field span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-error {
  min-height: 18px;
  color: var(--red);
  font-size: 12.5px;
  margin: 0 0 12px;
}

#auth-submit { width: 100%; padding: 12px; font-size: 15px; }

.auth-hint {
  margin: 18px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ---------------------------------------------------------- 涓绘鏋?*/

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  box-sizing: border-box;
}

.tab-pages {
  flex: 1;
  min-height: 0;
  display: flex;
}

.page {
  display: none;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}
.page.active { display: flex; }

.page-chat { flex-direction: row; }
.page-chat.active {
  display: grid;
  grid-template-columns: 292px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 20;
}

.me {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 16px 12px;
}
.me-info { flex: 1; min-width: 0; }
.me-info strong {
  display: block;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.online-text {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--green);
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.sidebar-search {
  position: relative;
  padding: 0 16px 12px;
}
.sidebar-search input, .search-box input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 8px 10px 8px 32px;
  font-size: 13px;
  transition: border-color .15s;
}
.sidebar-search input:focus, .search-box input:focus { border-color: #3b4256; }

.search-icon {
  position: absolute;
  left: 26px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.search-box .search-icon { left: 10px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 6px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}
.count {
  background: var(--panel-3);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 11px;
  letter-spacing: 0;
}

.room-list, .member-list {
  overflow-y: auto;
  padding: 0 8px;
}
.room-list { flex: 1 1 auto; min-height: 90px; }
.member-list { flex: 0 1 34%; min-height: 70px; padding-bottom: 10px; }

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 11px;
  cursor: pointer;
  transition: background .13s;
  margin-bottom: 2px;
}
.room-item:hover { background: var(--panel-2); }
.room-item.active { background: var(--accent-soft); }
.room-item .avatar { width: 34px; height: 34px; font-size: 13px; }

.room-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  color: var(--text-dim);
  flex: none;
}
.room-icon svg { width: 16px; height: 16px; }

.room-main { flex: 1; min-width: 0; }
.room-name {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-preview {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.room-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex: none;
}
.room-time { font-size: 10.5px; color: #6b7385; }
.badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.member {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .13s;
}
.member:hover { background: var(--panel-2); }
.member .avatar { width: 27px; height: 27px; font-size: 11.5px; }
.member-name {
  font-size: 13px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.member-state {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #475063;
  flex: none;
}
.member-state.online {
  background: var(--green);
  box-shadow: 0 0 6px rgba(34, 197, 94, .7);
}

/* ---------------------------------------------------------- 鑱婂ぉ鍖?*/

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 70% -10%, rgba(99, 102, 241, .07), transparent 70%);
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(13, 15, 21, .75);
  backdrop-filter: blur(12px);
  min-height: 62px;
}
.menu-btn { display: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-sub { font-size: 11.5px; color: var(--muted); }

.chat-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.search-box { position: relative; margin-right: 6px; }
.search-box input { width: 190px; font-size: 12.5px; padding: 7px 10px 7px 30px; }

.search-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 20px;
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(99, 102, 241, .1);
  border-bottom: 1px solid var(--border-soft);
}

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

/* 娑堟伅涓嶈冻涓€灞忔椂璐村簳鏄剧ず锛涘唴瀹硅秴鍑哄悗鑷姩澶辨晥 */
.messages::before {
  content: "";
  margin-top: auto;
}

.load-more {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--panel-2);
  margin-bottom: 10px;
}

.day-divider {
  align-self: center;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 20px;
  padding: 3px 12px;
  margin: 14px 0 10px;
}

.msg {
  display: flex;
  gap: 11px;
  padding: 3px 0;
  animation: msg-in .18s ease-out;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.msg.grouped { margin-top: 0; }
.msg .avatar { width: 36px; height: 36px; font-size: 14px; margin-top: 2px; }
.msg-spacer { width: 36px; flex: none; }

.msg-content { min-width: 0; flex: 1; max-width: 780px; }
.msg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.msg-author { font-size: 13px; font-weight: 600; }
.msg-time { font-size: 10.5px; color: #6b7385; }

.msg-text {
  font-size: 14px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-image {
  display: block;
  margin-top: 4px;
  border-radius: 12px;
  max-width: min(340px, 60vw);
  max-height: 340px;
  cursor: zoom-in;
  border: 1px solid var(--border-soft);
  object-fit: cover;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  max-width: 380px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, background .15s;
}
.msg-file:hover { border-color: #3a4459; background: var(--panel-3); }
.file-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.file-meta { min-width: 0; flex: 1; }
.file-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.file-dl { color: var(--muted); }

.msg-system {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 20px;
  padding: 4px 14px;
  margin: 8px 0;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 2;
}
.empty-state .big-emoji { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------------------------------------------------------- 杈撳叆鍖?*/

.composer-wrap {
  padding: 0 20px 16px;
  flex: none;
}

.typing {
  height: 20px;
  font-size: 11.5px;
  color: var(--muted);
  padding: 0 4px 4px;
}

.drop-hint {
  border: 2px dashed var(--accent);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
  background: var(--accent-soft);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 7px 8px 7px 6px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within {
  border-color: #3d4560;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .09);
}

.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  line-height: 1.55;
  padding: 7px 4px;
  font-size: 14px;
  background: transparent;
}
.composer textarea::placeholder { color: #5f677b; }

.attach { color: var(--muted); }
.attach:hover { color: var(--text); }

.btn-send {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  transition: filter .15s, opacity .15s;
}
.btn-send:hover { filter: brightness(1.1); }
.btn-send:disabled { opacity: .35; filter: none; cursor: default; }

/* ---------------------------------------------------------- 閫氳瘽 */

.call-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(6, 8, 12, .93);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 80;
  animation: fade-in .2s;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.call-box {
  position: relative;
  width: min(720px, 94vw);
  height: min(560px, 82vh);
  border-radius: 22px;
  overflow: hidden;
  background: #12151d;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0c11;
}

.call-placeholder {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: radial-gradient(500px 400px at 50% 30%, rgba(99, 102, 241, .2), transparent 70%), #12151d;
}
.call-peer-name { font-size: 19px; font-weight: 600; }
.call-status { font-size: 13px; color: var(--muted); }

.local-video {
  position: absolute;
  right: 16px;
  bottom: 92px;
  width: 150px;
  height: 104px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0a0c11;
  transform: scaleX(-1);
}

.call-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20px;
  display: flex;
  justify-content: center;
  gap: 14px;
}
.call-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  backdrop-filter: blur(8px);
  transition: background .15s, transform .1s;
}
.call-btn:hover { background: rgba(255, 255, 255, .2); }
.call-btn:active { transform: scale(.94); }
.call-btn svg { width: 21px; height: 21px; }
.call-btn.danger { background: var(--red); }
.call-btn.danger:hover { background: #dc2626; }
.call-btn.off { background: rgba(255, 255, 255, .9); color: #111; }

/* ---------------------------------------------------------- 寮圭獥 */

.modal-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(6, 8, 12, .7);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 20px;
}

.modal {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.modal h3 { margin: 12px 0 6px; font-size: 17px; }
.modal-desc { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; }
.modal input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 18px;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.incoming .avatar { margin: 0 auto; }
.incoming-actions {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin-top: 22px;
}
.btn-round {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  transition: transform .1s, filter .15s;
}
.btn-round:hover { filter: brightness(1.1); }
.btn-round:active { transform: scale(.94); }
.btn-round svg { width: 24px; height: 24px; }
.btn-round.accept { background: var(--green); }
.btn-round.reject { background: var(--red); }

/* ---------------------------------------------------------- 鎻愮ず鏉?*/

.toasts {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease-out;
  max-width: 80vw;
}
.toast.error { border-color: rgba(239, 68, 68, .5); color: #fecaca; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.lightbox {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(0, 0, 0, .9);
  display: grid;
  place-items: center;
  z-index: 150;
  cursor: zoom-out;
  padding: 30px;
}
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
}

/* 灏婇噸绯荤粺鐨勩€屽噺寮卞姩鎬佹晥鏋溿€嶈缃?*/
@media (prefers-reduced-motion: reduce) {
  .msg, .toast, .call-layer { animation: none !important; }
  * { transition: none !important; }
}

/* ---------------------------------------------------------- 鍝嶅簲寮?*/

@media (max-width: 820px) {
  .page-chat.active { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
  right: auto;
  bottom: 0;
  left: 0;
    width: 84vw;
    max-width: 320px;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .search-box { display: none; }
  .messages { padding: 14px 14px 6px; }
  .composer-wrap { padding: 0 12px 12px; }
  .chat-header { padding: 10px 12px; }
  .msg .avatar { width: 32px; height: 32px; font-size: 12px; }
  .msg-spacer { width: 32px; }
  .local-video { width: 100px; height: 72px; bottom: 86px; right: 12px; }
}

/* ============================================================
   v2 鏂板缁勪欢
   ============================================================ */

.msg { position: relative; }
.msg.editing { background: rgba(99, 102, 241, .08); border-radius: 10px; }

.msg-actions {
  position: absolute;
  right: 6px;
  top: 0;
  opacity: 0;
  transition: opacity .12s;
}
.msg:hover .msg-actions { opacity: 1; }
.msg-actions button {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.msg-actions button:hover { color: var(--text); }
.msg-actions svg { width: 15px; height: 15px; }

/* 鎮诞鎿嶄綔鑿滃崟 */
.msg-menu {
  position: fixed;
  z-index: 130;
  min-width: 132px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: left;
}
.msg-menu button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.msg-menu button.danger { color: #fca5a5; }
.msg-menu button.danger:hover { background: rgba(239, 68, 68, .12); }
.msg-menu svg { width: 15px; height: 15px; }

/* 寮曠敤鍧?*/
.msg-reply {
  display: flex;
  gap: 6px;
  align-items: baseline;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, .045);
  padding: 4px 9px;
  border-radius: 0 6px 6px 0;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.msg-reply b { color: var(--accent); font-weight: 600; flex: none; }
.msg-reply span { overflow: hidden; text-overflow: ellipsis; }

.msg-deleted {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

/* 璇煶娑堟伅 */
.msg-voice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px 7px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  max-width: 240px;
  min-width: 132px;
}
.voice-play {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}
.voice-play svg { width: 13px; height: 13px; }
.voice-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 18px;
  flex: 1;
  overflow: hidden;
}
.voice-bars i {
  display: block;
  width: 2px;
  border-radius: 1px;
  background: #4b5368;
  transition: background .15s;
}
.voice-bars.playing i { background: var(--accent); }
.voice-dur { font-size: 11.5px; color: var(--muted); flex: none; }

/* 閫氳瘽璁板綍 */
.msg-call {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  max-width: 300px;
  cursor: default;
}
.msg-call .call-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(34, 197, 94, .14);
  color: var(--green);
  flex: none;
}
.msg-call.missed .call-icon { background: rgba(239, 68, 68, .14); color: #f87171; }
.msg-call .call-text { font-size: 13px; }
.msg-call .call-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.msg-call .call-back {
  margin-left: auto;
  color: var(--accent);
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 6px;
}
.msg-call .call-back:hover { background: var(--accent-soft); }

/* 宸茶鍥炴墽 */
.read-state {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.read-state.read { color: var(--accent); }
.read-state svg { width: 12px; height: 12px; }

/* 缂栬緫鏉?/ 褰曢煶鏉?*/
.edit-bar,
.recorder {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.edit-bar {
  justify-content: space-between;
  background: rgba(99, 102, 241, .12);
  border: 1px solid rgba(99, 102, 241, .3);
}
.edit-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.edit-info strong { color: var(--accent); font-size: 12px; }
.edit-info span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.recorder {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .3);
}
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  animation: rec-pulse 1s infinite;
  flex: none;
}
@keyframes rec-pulse { 50% { opacity: .25; } }
.rec-hint { color: var(--muted); font-size: 12px; flex: 1; }

/* 寮圭獥鍙樹綋 */
.modal.profile, .modal.picker, .modal.multi, .modal.members {
  text-align: left;
  width: min(430px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.modal.profile { text-align: center; }
.modal.profile .avatar { margin: 0 auto 4px; }
.modal.profile .field { text-align: left; }
.profile-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.profile-actions .btn-ghost { flex: 1 1 40%; padding: 9px 10px; font-size: 13px; }
.profile-actions .btn-primary { flex: 1 1 100%; }

.picker-search { position: relative; margin-bottom: 8px; flex: none; }
.picker-search input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px 8px 32px;
  font-size: 13px;
}
.picker-search .search-icon { left: 10px; }

.picker-list, .multi-list, .member-manage {
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 6px;
  background: rgba(0, 0, 0, .16);
  max-height: 250px;
  min-height: 60px;
}
.member-manage { max-height: 320px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
}
.check-row:hover { background: rgba(255, 255, 255, .05); }
.check-row input { width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.check-row .avatar { width: 26px; height: 26px; font-size: 11px; }
.check-row .who {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.check-row .sub { font-size: 11px; color: var(--muted); }
.check-row .tag {
  font-size: 10.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  flex: none;
}

.multi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0;
}
.multi-head .check-row { padding: 4px 2px; }
.multi-count { font-size: 12px; color: var(--muted); }

.modal.multi textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  resize: vertical;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 66px;
}
.modal.multi textarea:focus { border-color: var(--accent); }

.multi-preview {
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  border-radius: 0 8px 8px 0;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
  max-height: 84px;
  overflow: auto;
  white-space: pre-wrap;
}

.manage-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13.5px;
}
.manage-row:hover { background: rgba(255, 255, 255, .04); }
.manage-row .who { flex: 1; min-width: 0; }
.manage-row .tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }

.icon-btn.enabled { color: var(--accent); }

/* ============================================================
   鍝佺墝涓?PWA
   ============================================================ */

.brand-mark {
  background: #ffffff;
  padding: 3px;
  overflow: hidden;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 11px;
}

.icon-btn.muted {
  color: #5b6478;
  opacity: .65;
}

.install-hint {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 160;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-width: 92vw;
}
.install-text { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.install-text strong { font-size: 13px; }
.install-text span { color: var(--muted); line-height: 1.5; }

@media (max-width: 820px) {
  .install-hint { bottom: 14px; padding: 10px 14px; gap: 10px; }
  .install-text span { font-size: 11.5px; }
}

/* 璁?iOS 鍔犲埌涓诲睆骞曞悗瀹夊叏鍖轰笉鎸″唴瀹?*/
@supports (padding: env(safe-area-inset-bottom)) {
  .composer-wrap { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ============================================================
   v3锛氫笁椤电 / 鏈嬪弸鍦?/ 璁剧疆 / 鍦ｈ癁涓婚
   ============================================================ */

/* ---------- 鍏ㄥ憳澶у巺锛堝彧璇诲叕鍛婂尯锛?---------- */
.hall-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(47, 111, 224, .1);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-dim);
}
.hall-banner svg { width: 15px; height: 15px; color: var(--accent); flex: none; }

.msg-announce {
  align-self: stretch;
  margin: 10px 0;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(47, 111, 224, .16), rgba(47, 111, 224, .05));
  border: 1px solid rgba(47, 111, 224, .35);
  border-radius: 14px;
}
.announce-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #7aa7ff;
  margin-bottom: 7px;
}
.announce-head svg { width: 15px; height: 15px; }
.announce-body {
  font-size: 14px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}
.announce-time { font-size: 11px; color: var(--muted); margin-top: 8px; }
.composer.is-readonly { opacity: .55; }

/* ---------- 搴曢儴椤电 ---------- */
.tabbar {
  flex: none;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border-soft);
  padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 0 7px;
  color: var(--muted);
  font-size: 11px;
  transition: color .15s;
}
.tab.active { color: var(--accent); }
.tab svg { width: 21px; height: 21px; }
.tab-badge {
  position: absolute;
  top: 4px;
  right: 50%;
  margin-right: -24px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* ---------- 閫氱敤椤甸潰 ---------- */
.page-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(13, 15, 21, .75);
  backdrop-filter: blur(12px);
}
.page-header h2 { margin: 0; font-size: 17px; }
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 28px;
}

/* ---------- 鏂扮殑鏈嬪弸鍏ュ彛 ---------- */
.requests-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: calc(100% - 16px);
  margin: 0 8px 4px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 13px;
}
.requests-row:hover { filter: brightness(1.1); }
.requests-row svg { width: 16px; height: 16px; color: var(--accent); }
.requests-row span { flex: 1; text-align: left; }

/* ---------- 璁剧疆椤?---------- */
.settings-scroll { max-width: 640px; margin: 0 auto; width: 100%; }

.settings-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  margin-bottom: 18px;
}
.settings-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.settings-who strong { font-size: 17px; }
.settings-who span { font-size: 12.5px; color: var(--muted); }

.settings-group {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  margin-bottom: 16px;
  overflow: hidden;
}
.settings-title {
  padding: 10px 16px 6px;
  font-size: 11.5px;
  letter-spacing: .5px;
  color: var(--muted);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 12px;
  padding: 13px 16px;
  font-size: 14px;
  text-align: left;
  border-top: 1px solid var(--border-soft);
}
.settings-title + .settings-row { border-top: 0; }
.settings-row:hover { background: rgba(255, 255, 255, .03); }
.settings-row.danger { color: #f87171; }
.settings-row.column { flex-direction: column; align-items: stretch; }
.row-head { display: flex; align-items: center; justify-content: space-between; }
.chev { color: var(--muted); font-size: 18px; }
.settings-footer {
  text-align: center;
  font-size: 11.5px;
  color: #5b6478;
  margin: 8px 0 0;
}

/* 寮€鍏?*/
input.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background .18s, border-color .18s;
}
input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #8b93a7;
  transition: transform .18s, background .18s;
}
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { transform: translateX(18px); background: #fff; }

/* 閾冨０鍒楄〃 */
.ringtone-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 14px;
}
.ringtone-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12.5px;
}
.ringtone-item.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.ringtone-item svg { width: 13px; height: 13px; }

/* ---------- 鏈嬪弸鍦?---------- */
.moments-scroll { max-width: 640px; margin: 0 auto; width: 100%; }

.moment-composer {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  margin-bottom: 18px;
}
.moment-compose-main { flex: 1; min-width: 0; }
.moment-compose-main textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  min-height: 54px;
}
.moment-compose-main textarea:focus { border-color: var(--accent); }
.moment-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.moment-tools .btn-primary { padding: 8px 18px; font-size: 13.5px; }
.moment-preview {
  position: relative;
  margin-top: 10px;
  width: fit-content;
}
.moment-preview img {
  max-width: 220px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}
.moment-preview .icon-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  width: 24px;
  height: 24px;
}

.moment-feed { display: flex; flex-direction: column; gap: 14px; }
.moment-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
}
.moment-body { flex: 1; min-width: 0; }
.moment-head { display: flex; align-items: baseline; gap: 8px; }
.moment-author { font-size: 14px; font-weight: 600; }
.moment-time { font-size: 11px; color: var(--muted); }
.moment-text {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
}
.moment-image {
  display: block;
  margin-top: 8px;
  max-width: min(320px, 100%);
  max-height: 320px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  cursor: zoom-in;
}
.moment-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 12.5px;
}
.like-btn.liked { color: #f472b6; background: rgba(244, 114, 182, .12); }
.like-btn svg { width: 14px; height: 14px; }
.moment-likers { font-size: 12px; color: var(--muted); }
.empty-line {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- 娣诲姞濂藉弸 ---------- */
.modal.friend-modal { width: min(460px, 100%); }
.friend-search { display: flex; gap: 8px; margin-bottom: 12px; }
.friend-search input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
}
.friend-search .btn-primary { padding: 10px 16px; font-size: 13.5px; }
.friend-result:empty { display: none; }
.friend-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 12px;
}
.friend-card .who { flex: 1; min-width: 0; }
.friend-card .who strong { display: block; font-size: 14px; }
.friend-card .who span { font-size: 11.5px; color: var(--muted); }
.friend-card .btn-primary { padding: 7px 14px; font-size: 12.5px; }
.friend-section-title {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 8px;
}
.friend-invite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}
.friend-invite strong { color: var(--text); }
.friend-request-list { max-height: 220px; overflow-y: auto; }
.friend-request {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  margin-bottom: 8px;
}
.friend-request .who { flex: 1; min-width: 0; }
.friend-request .who strong { font-size: 13.5px; display: block; }
.friend-request .who span { font-size: 11.5px; color: var(--muted); }
.friend-request button {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}
.friend-request .ok { background: var(--accent); color: #fff; }
.friend-request .no { border: 1px solid var(--border); color: var(--muted); }

/* ---------- 淇敼瀵嗙爜寮圭獥 ---------- */
.modal.prompt-modal { width: min(400px, 100%); }

/* ---------- 鑺傛棩涓婚 ---------- */
body.fest-christmas  { --accent:#e0524f; --accent-2:#2f9e63; --accent-soft:rgba(224,82,79,.16); }
body.fest-midautumn  { --accent:#e0a83c; --accent-2:#5b7bd5; --accent-soft:rgba(224,168,60,.16); }
body.fest-newyear    { --accent:#e0451f; --accent-2:#f0b429; --accent-soft:rgba(224,69,31,.16); }
body.fest-thingyan   { --accent:#2ea8e0; --accent-2:#22d3ee; --accent-soft:rgba(46,168,224,.16); }
body.fest-thadingyut { --accent:#d4a017; --accent-2:#b45309; --accent-soft:rgba(212,160,23,.16); }

body.fest-christmas .auth-bg {
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(224, 82, 79, .22), transparent 70%),
    radial-gradient(700px 500px at 85% 90%, rgba(47, 158, 99, .20), transparent 70%),
    var(--bg);
}
body.fest-midautumn .auth-bg {
  background:
    radial-gradient(420px 420px at 78% 16%, rgba(255, 236, 179, .28), transparent 62%),
    radial-gradient(700px 500px at 15% 85%, rgba(91, 123, 213, .22), transparent 70%),
    #0b0f1c;
}
body.fest-newyear .auth-bg {
  background:
    radial-gradient(520px 380px at 20% 12%, rgba(240, 180, 41, .25), transparent 68%),
    radial-gradient(600px 420px at 85% 88%, rgba(224, 69, 31, .24), transparent 70%),
    #150a08;
}
body.fest-thingyan .auth-bg {
  background:
    radial-gradient(600px 400px at 20% 10%, rgba(56, 189, 248, .30), transparent 68%),
    radial-gradient(700px 500px at 85% 90%, rgba(34, 211, 238, .22), transparent 70%),
    #071620;
}
body.fest-thadingyut .auth-bg {
  background:
    radial-gradient(520px 380px at 25% 12%, rgba(240, 190, 60, .28), transparent 66%),
    radial-gradient(600px 420px at 80% 85%, rgba(180, 83, 9, .25), transparent 70%),
    #100c04;
}

.brand-mark { position: relative; }
/* 瑁呴グ灞?*/
.snow {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
  display: none;
}
body[class*="fest-"] .snow { display: block; }
.snow i {
  position: absolute;
  top: -40px;
  font-style: normal;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
@keyframes fest-fall {
  to { transform: translateY(112vh) rotate(320deg); }
}
@keyframes fest-rise {
  from { transform: translateY(105vh) rotate(-8deg); }
  to   { transform: translateY(-15vh) rotate(8deg); }
}
@keyframes fest-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-16px); }
}

.festival-corner {
  position: fixed;
  right: 16px;
  bottom: 84px;
  font-size: 68px;
  opacity: .14;
  pointer-events: none;
  z-index: 3;
  filter: grayscale(.1);
}
@media (max-width: 820px) {
  .festival-corner { font-size: 46px; bottom: 76px; right: 10px; }
}


@media (max-width: 820px) {
  .sidebar-backdrop {
    position: fixed;
    top: 0;
  right: 0;
  bottom: 0;
  left: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 19;
  }
  .msg-actions { display: none; }
  .modal.profile, .modal.picker, .modal.multi, .modal.members { max-height: 92vh; }
  .picker-list, .multi-list { max-height: 210px; }
  .page-header { padding: 12px 14px; }
  .page-scroll { padding: 12px 12px 22px; }
  .settings-card { padding: 14px; }
  .moment-composer { padding: 12px; }
  .moment-item { padding: 12px; }
  .tab { padding: 7px 0 6px; }
}




/* ============================================================
   v5锛氭皵娉″榻?/ 澶村儚 / 寰呭彂閫侀瑙?/ 璇勮 / 閰嶈壊
   ============================================================ */

.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-wrap { position: relative; display: inline-block; flex: none; }
.avatar-edit {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-dim);
}
.avatar-edit svg { width: 13px; height: 13px; }

/* 鑷繁鐨勬秷鎭潬鍙?*/
.msg { align-items: flex-start; }
.msg.mine { flex-direction: row-reverse; }
.msg-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.msg.mine .msg-content { align-items: flex-end; }
.msg.mine .msg-head { justify-content: flex-end; }
.msg.mine .msg-reply {
  border-left: 0;
  border-right: 3px solid var(--accent);
  border-radius: 6px 0 0 6px;
}
.msg-text {
  display: inline-block;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
}
.msg.mine .msg-text {
  background: var(--accent-soft);
  border-color: transparent;
}

/* 寰呭彂閫侀瑙?*/
.pending-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.pending-bar img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  flex: none;
}
.pending-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.pending-name { flex: 1; font-size: 12.5px; color: var(--text-dim); }
.pending-actions { display: flex; gap: 6px; }

/* 鏈嬪弸鍦堣瘎璁?*/
.moment-comments {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.moment-comment { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.moment-comment b { color: var(--accent); font-weight: 600; }
.moment-comment-input { display: flex; gap: 8px; margin-top: 8px; }
.moment-comment-input input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  outline: none;
}
.moment-comment-input input:focus { border-color: var(--accent); }
.moment-comment-input button {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
}

/* 閰嶈壊閫夋嫨 */
.palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 16px 14px;
}
.palette-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  transition: transform .12s;
}
.palette-dot:hover { transform: scale(1.08); }
.palette-dot.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .5); }
.palette-dot[data-color="auto"] {
  background: conic-gradient(#e0524f, #eab308, #22c55e, #3b82f6, #8b5cf6, #e0524f);
}

/* ---- v6锛氳瘎璁烘搷浣?/ 鑷畾涔夎儗鏅?---- */
.comment-actions { margin-left: 8px; display: inline-flex; gap: 8px; }
.comment-actions button { font-size: 11.5px; color: var(--muted); }
.comment-actions button:hover { color: var(--accent); }

.auth-bg { background-size: cover; background-position: center; }

.main { position: relative; }
.main::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: var(--app-bg, none);
  background-size: cover;
  background-position: center;
  opacity: .3;
  pointer-events: none;
  z-index: 0;
}
.main > * { position: relative; z-index: 1; }

/* ============================================================
   v7锛氭墜鏈虹鍥哄畾缂╂斁锛岀姝㈣嚜鍔ㄦ斁澶?/ 鍙屽嚮缂╂斁
   ============================================================ */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  touch-action: manipulation;   /* 绂佹鍙屽嚮缂╂斁 */
  overscroll-behavior: none;    /* 绂佹涓嬫媺鍒锋柊鎶婇〉闈㈡媺鍔?*/
}

button, a, label, .tab, .room-item, .member {
  touch-action: manipulation;
}

@media (max-width: 820px) {
  /* iOS 涓婅緭鍏ユ瀛楀彿 < 16px 浼氳嚜鍔ㄦ斁澶ч〉闈紝缁熶竴鏀规垚 16px */
  input, textarea, select {
    font-size: 16px !important;
  }
  .composer textarea { font-size: 16px; }
  /* 杞敭鐩樺脊鍑烘椂涓嶈鏁撮〉璺冲姩 */
  .app { height: 100dvh; }
}

/* ============================================================
   v8锛氭祬鑹叉ā寮忥紙body.mode-light锛?   ============================================================ */

body.mode-light {
  --bg:          #f4f6fb;
  --panel:       #ffffff;
  --panel-2:     #f1f4f9;
  --panel-3:     #e6ebf3;
  --border:      #d7dee9;
  --border-soft: #e5eaf2;
  --text:        #1a2233;
  --text-dim:    #4b5568;
  --muted:       #7b8598;
  --shadow:      0 12px 40px rgba(20, 30, 50, .12);
}

body.mode-light .auth-bg {
  background:
    radial-gradient(600px 400px at 15% 10%, rgba(99, 102, 241, .16), transparent 70%),
    radial-gradient(700px 500px at 85% 90%, rgba(139, 92, 246, .12), transparent 70%),
    var(--bg);
}
body.mode-light .auth-card {
  background: rgba(255, 255, 255, .94);
  border-color: var(--border);
}
body.mode-light .auth-tab.active {
  background: #fff;
  box-shadow: 0 2px 8px rgba(20, 30, 50, .12);
}

body.mode-light .main {
  background-image:
    radial-gradient(900px 500px at 70% -10%, rgba(99, 102, 241, .06), transparent 70%);
}
body.mode-light .chat-header,
body.mode-light .page-header {
  background: rgba(255, 255, 255, .82);
}
body.mode-light .sidebar { background: var(--panel); }

body.mode-light .room-item:hover,
body.mode-light .member:hover,
body.mode-light .check-row:hover,
body.mode-light .settings-row:hover,
body.mode-light .manage-row:hover,
body.mode-light .ringtone-item:hover { background: rgba(20, 35, 60, .05); }

body.mode-light .msg-menu button:hover { background: rgba(20, 35, 60, .06); }
body.mode-light .msg-actions button { background: #fff; }
body.mode-light .msg.mine .msg-text { border-color: rgba(20, 35, 60, .06); }

body.mode-light .modal-layer { background: rgba(20, 30, 50, .35); }
body.mode-light .call-layer { background: rgba(20, 30, 50, .82); }
body.mode-light .lightbox { background: rgba(255, 255, 255, .92); }

body.mode-light .msg-reply { background: rgba(20, 35, 60, .05); }
body.mode-light .file-icon { background: rgba(99, 102, 241, .12); }
body.mode-light .voice-bars i { background: #c2cbd9; }

body.mode-light ::-webkit-scrollbar-thumb { background: #c3ccda; }
body.mode-light ::-webkit-scrollbar-thumb:hover { background: #aeb9ca; }

body.mode-light .snow i { color: rgba(110, 130, 165, .45); }
body.mode-light .festival-corner { opacity: .18; }

body.mode-light .search-banner { background: rgba(99, 102, 241, .08); }
body.mode-light .hall-banner { background: rgba(47, 111, 224, .08); }
body.mode-light .msg-announce { background: rgba(47, 111, 224, .08); border-color: rgba(47, 111, 224, .25); }
body.mode-light .announce-head { color: #2f6fe0; }

.mode-switch {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.mode-switch button {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--muted);
}
.mode-switch button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(10, 20, 40, .15);
}

/* ---- 缁存姢妯″紡娴眰 ---- */
.maintenance-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.maintenance-card { text-align: center; max-width: 360px; }
.maintenance-icon { font-size: 54px; margin-bottom: 12px; }
.maintenance-card h2 { margin: 0 0 10px; font-size: 20px; color: var(--text); }
.maintenance-card p { margin: 0; color: var(--text-dim); font-size: 13.5px; line-height: 1.7; white-space: pre-wrap; }
.maintenance-hint { margin-top: 14px !important; color: var(--muted) !important; font-size: 11.5px !important; }

/* ---- 鐧诲綍椤?App 涓嬭浇 ---- */
.auth-download {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.download-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid transparent;
  transition: border-color .15s, transform .12s;
}
.download-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.download-icon { font-size: 22px; line-height: 1; }
.download-text { display: flex; flex-direction: column; gap: 2px; }
.download-text b { font-size: 13.5px; color: var(--text); font-weight: 600; }
.download-text em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-dim);
}
.download-tip {
  margin: 10px 2px 0;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
  text-align: center;
}
@media (max-width: 520px) {
  .download-tip { font-size: 11px; }
}

/* 鎵嬫満绔槻姝㈢櫥褰曞崱鐗囨í鍚戞孩鍑?*/
.auth-screen { width: 100%; max-width: 100vw; }
.auth-card { max-width: calc(100vw - 32px); }
.auth-download { max-width: 100%; }
.download-btn { min-width: 0; }
.download-text { min-width: 0; }
.download-text b, .download-text em { overflow: hidden; text-overflow: ellipsis; }
html, body { overflow-x: hidden; }

/* 鐧诲綍椤靛竷灞€鏀逛负 flex锛岄伩鍏嶅崱鐗囧湪绐勫睆琚鍒?*/
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  min-width: 0;
  margin: 0 auto;
}

/* ============================================================
   v9锛氭墜鏈虹寮圭獥鏀逛负搴曢儴鎶藉眽锛岄伩鍏嶈瑁佸垏
   ============================================================ */
@media (max-width: 560px) {
  .modal-layer {
    align-items: flex-end;
    padding: 10px;
  }
  .modal,
  .modal.profile,
  .modal.picker,
  .modal.multi,
  .modal.members {
    width: 100%;
    max-width: 100%;
    max-height: 86vh;
    border-radius: 18px;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  }
  .modal.picker .modal-actions,
  .modal.multi .modal-actions,
  .modal.members .modal-actions {
    flex-direction: column-reverse;
  }
  .modal.picker .modal-actions button,
  .modal.multi .modal-actions button,
  .modal.members .modal-actions button {
    width: 100%;
  }
  .picker-list { max-height: 46vh; }
  .modal h3 { font-size: 16px; }
}

/* ============================================================
   v10锛歩OS 鐙珛妯″紡锛堟坊鍔犲埌涓诲睆骞曪級瀹夊叏鍖轰慨姝?   ============================================================ */

/* 鎵嬫満绔晶杈规爮鏄?fixed 鎶藉眽锛屽繀椤昏嚜宸辫寮€鐘舵€佹爮 */
@media (max-width: 820px) {
  .sidebar {
    padding-top: env(safe-area-inset-top, 0px);
  }
  .sidebar .sidebar-head {
    padding-top: 14px;
  }
}

/* 鐙珛妯″紡鍏滃簳锛氬嵆浣?env() 鎷夸笉鍒板€硷紝涔熺暀鍑虹姸鎬佹爮楂樺害 */
@media (display-mode: standalone) {
  .app {
    padding-top: max(env(safe-area-inset-top, 0px), 24px);
  }
  .sidebar {
    padding-top: max(env(safe-area-inset-top, 0px), 24px);
  }
  .tabbar {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 10px);
  }
  .modal-layer {
    padding-top: max(env(safe-area-inset-top, 0px), 16px);
  }
}

/* 瑕嗙洊锛氫晶杈规爮鏀圭敤鍙橀噺锛屼究浜?JS 鍏滃簳 */
@media (max-width: 820px) {
  .sidebar { padding-top: var(--safe-top); }
}

/* ============================================================
   v11锛歷iewport 鍏滃簳 鈥斺€?鎵嬫満浣嗛〉闈㈠搴﹀紓甯告椂寮哄埗鍗曟爮
   ============================================================ */
body.force-narrow .page-chat.active { grid-template-columns: 1fr; }
body.force-narrow .sidebar {
  position: fixed;
  top: 0;
  right: auto;
  bottom: 0;
  left: 0;
  width: 84vw;
  max-width: 320px;
  transform: translateX(-102%);
  transition: transform .22s ease;
  box-shadow: var(--shadow);
  padding-top: var(--safe-top);
}
body.force-narrow .sidebar.open { transform: none; }
body.force-narrow .menu-btn { display: grid; }
body.force-narrow .search-box { display: none; }
body.force-narrow .messages { padding: 14px 14px 6px; }
body.force-narrow .composer-wrap { padding: 0 12px 12px; }
body.force-narrow .chat-header { padding: 10px 12px; }
body.force-narrow .msg .avatar { width: 32px; height: 32px; font-size: 12px; }
body.force-narrow .msg-spacer { width: 32px; }

/* ============================================================
   v12锛氭坊鍔犲ソ鍙嬪脊绐楋紙鎵嬫満绔弸濂斤紝閿洏寮瑰嚭涔熶笉琚《鎺夛級
   ============================================================ */
.modal.friend-modal {
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  text-align: left;
}
.modal.friend-modal .friend-search,
.modal.friend-modal .friend-invite,
.modal.friend-modal .friend-section-title {
  flex: none;
}
.friend-request-list { overflow-y: auto; max-height: 30vh; }
.friend-result { overflow-y: auto; max-height: 26vh; }

@media (max-width: 560px) {
  .modal-layer { overflow-y: auto; }
  .modal.friend-modal {
    max-height: calc(100% - 12px);
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .modal.friend-modal .friend-search { flex-direction: column; }
  .modal.friend-modal .friend-search .btn-primary { width: 100%; }
  .friend-request-list { max-height: 26vh; }
  .friend-result { max-height: 22vh; }
}

/* 鎵嬫満绔斁澶?+"鎸夐挳鐐瑰嚮鍖哄煙锛岄伩鍏嶇偣涓嶄腑 */
@media (max-width: 820px) {
  .section-head .icon-btn.small,
  .section-head .icon-btn {
    width: 40px;
    height: 40px;
  }
  .section-head { min-height: 44px; }
}

/* ============================================================
   v13锛氬洓椤电锛堣亰澶?/ 鑱旂郴浜?/ 鏈嬪弸鍦?/ 璁剧疆锛? 鎵竴鎵?   ============================================================ */

.back-btn { display: none; }

.header-actions { display: flex; gap: 6px; }

/* 鑱旂郴浜洪〉 */
.contacts-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
}
.contacts-action:active { background: var(--panel-2); }
.ca-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 19px;
  flex: none;
}
.ca-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ca-text b { font-size: 14px; color: var(--text); font-weight: 600; }
.ca-text em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.contacts-list { display: flex; flex-direction: column; gap: 6px; }
.contact-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
}
.contact-name { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text); }
.contact-name em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }
.contact-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* 浜岀淮鐮佸脊绐?*/
.qr-modal { text-align: center; }
.qr-image {
  width: 220px;
  height: 220px;
  margin: 6px auto 10px;
  display: block;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
  box-sizing: border-box;
}
.qr-link {
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 14px;
}

/* 鎵竴鎵?*/
.scan-layer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  background: #000;
  display: grid;
  place-items: center;
}
.scan-layer video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute;
  width: min(62vw, 260px);
  height: min(62vw, 260px);
  border: 3px solid #fff;
  border-radius: 18px;
  box-shadow: 0 0 0 2000px rgba(0, 0, 0, .45);
}
.scan-tip {
  position: absolute;
  bottom: 96px;
  color: #fff;
  font-size: 13px;
  text-align: center;
  width: 100%;
}
.scan-close {
  position: absolute;
  top: calc(18px + env(safe-area-inset-top, 0px));
  right: 16px;
  color: #fff;
  background: rgba(255, 255, 255, .18);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
}

/* 鎵嬫満锛氳亰澶╅〉鍏堝垪琛紝鐐硅繘鍘绘墠鑱婂ぉ锛堣鐩栨棫鐨勬娊灞夎鍒欙級 */
@media (max-width: 820px) {
  .page-chat.active { display: block; }
  .sidebar {
    position: static;
    transform: none;
    width: 100%;
    max-width: none;
    height: 100%;
    border-right: 0;
    box-shadow: none;
    padding-top: var(--safe-top);
  }
  .main { display: none; }
  body.chat-open .sidebar { display: none; }
  body.chat-open .main { display: flex; }
  body.chat-open .tabbar { display: none; }
  .back-btn { display: grid; }
  .menu-btn { display: none; }
  body.chat-open .back-btn { display: grid; }
}

/* 娣诲姞濂藉弸鐙珛椤甸潰 */
.addfriend-page .page-scroll { padding: 12px 14px calc(24px + env(safe-area-inset-bottom)); }
.addfriend-page .friend-search { margin-top: 4px; }
.addfriend-page .friend-invite { margin-top: 12px; }
.addfriend-page .friend-request-list { max-height: none; overflow: visible; }

/* ============================================================
   v14锛氫慨姝ｆ墜鏈虹鑱婂ぉ椤甸珮搴︼紙杈撳叆妗嗕笉鍐嶆诞鍦ㄤ腑闂达級
   ============================================================ */
@media (max-width: 820px) {
  .page-chat.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
  }
  .page-chat .sidebar {
    flex: 1;
    min-height: 0;
    height: auto;
  }
  .page-chat .main {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: none;
  }
  body.chat-open .page-chat .main { display: flex; }
  .main .messages { flex: 1; min-height: 0; }
  .main .composer-wrap { flex: none; margin-top: auto; }
}

/* 閫氳瘽/鎵爜娴眰灞傜骇鎻愰珮锛岄伩鍏嶈鍏跺畠灞傞伄浣?*/
.call-layer { z-index: 300; }
#incoming-layer { z-index: 310; }
.scan-layer {
  z-index: 320;
  width: 100vw;
  height: 100vh;
  background: #000;
}
.scan-layer video { background: #000; }

/* ============================================================
   v15锛氭墍鏈夊脊绐楁敼涓烘暣椤垫ā寮忥紙涓嶅啀鏈夋诞灞?灞呬腑绐楋級
   ============================================================ */
.modal-layer {
  position: fixed !important;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 0 !important;
  background: var(--bg);
  display: block !important;
  place-items: unset !important;
  z-index: 250;
  overflow: hidden;
}
.modal-layer[hidden] { display: none !important; }

.modal-layer .modal,
.modal-layer .modal.profile,
.modal-layer .modal.picker,
.modal-layer .modal.multi,
.modal-layer .modal.members,
.modal-layer .modal.friend-modal,
.modal-layer .modal.qr-modal {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: var(--bg) !important;
  padding: calc(14px + var(--safe-top)) 16px calc(18px + var(--safe-bottom)) !important;
  overflow-y: auto !important;
  display: block !important;
  text-align: left;
  backdrop-filter: none;
}
.modal-layer .modal h3 {
  font-size: 18px;
  margin: 6px 0 10px;
}
.modal-layer .modal-actions {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 12px 0 calc(6px + var(--safe-bottom));
  margin-top: 12px;
}
.modal-layer .modal-actions button { width: 100%; }
.modal-layer .profile-actions { display: flex; flex-direction: column; gap: 8px; }

/* 鍥剧墖鏌ョ湅浠嶆槸鍏ㄥ睆锛屼絾鍘绘帀灞呬腑闃村奖 */
.lightbox { z-index: 260; }

/* ============================================================
   v16锛氭潵鐢甸〉鏁撮〉鍖?+ 澶ф寜閽?   ============================================================ */
#incoming-layer .modal.incoming {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100% !important;
  padding-top: calc(70px + var(--safe-top)) !important;
  text-align: center;
}
#incoming-layer .avatar.big {
  width: 110px;
  height: 110px;
  font-size: 40px;
  margin-bottom: 18px;
}
#incoming-layer .incoming-actions {
  margin-top: auto;
  display: flex;
  gap: 56px;
  justify-content: center;
  align-items: center;
  padding: 30px 0 calc(40px + var(--safe-bottom));
}
#incoming-layer .btn-round {
  width: 74px;
  height: 74px;
}
#incoming-layer .btn-round svg { width: 30px; height: 30px; }
#incoming-layer h3 { font-size: 22px; margin: 0 0 8px; }
#incoming-layer p { font-size: 14px; color: var(--muted); }

/* 鎵嬫満绔彁绀烘潯绉诲埌椤堕儴锛岄伩鍏嶈搴曢儴瀵艰埅/閿洏鎸′綇 */
@media (max-width: 820px) {
  .toasts {
    top: calc(12px + env(safe-area-inset-top, 0px));
    bottom: auto;
    z-index: 500;
    width: 92vw;
  }
  .toast {
    font-size: 14px;
    padding: 12px 16px;
    max-width: 92vw;
    line-height: 1.5;
  }
}

/* ============================================================
   v17锛氱Щ闄ゆ墍鏈?backdrop-filter锛堜綆绔畨鍗?WebView 浼氱櫧灞忥級
   ============================================================ */
.auth-card,
.sidebar,
.chat-header,
.page-header,
.modal,
.modal-layer,
.call-layer,
.tabbar,
.composer,
.msg-menu {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* 閫氳瘽灞傛敼鎴愮函鑹茶儗鏅紝閬垮厤 GPU 鍚堟垚澶辫触 */
.call-layer {
  background: #0b0e14 !important;
  animation: none !important;
}

/* 鎵嬫満绔叧闂ぇ鑼冨洿姣涚幓鐠?鍔ㄧ敾锛屾彁鍗囩ǔ瀹氭€?*/
@media (max-width: 820px) {
  * {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
  .call-layer,
  .modal-layer,
  .incoming-layer {
    animation: none !important;
  }
}

/* ============================================================
   v18锛氬吋瀹硅€佹棫 WebView锛圕hrome 83锛?   ============================================================ */
@supports not (height: 100dvh) {
  .app { height: 100% !important; }
}

/* Chrome 83 涓嶆敮鎸?flex gap锛岀敤 margin 鍏滃簳 */
@supports not (gap: 1px) {
  .toasts .toast + .toast { margin-top: 8px; }
  .contacts-list .contact-row + .contact-row { margin-top: 6px; }
  .profile-actions button + button { margin-top: 8px; }
  .modal-actions button + button { margin-top: 8px; }
  .toolbar > * + * { margin-left: 8px; }
  .friend-search button { margin-left: 8px; }
  .settings-row > * + * { margin-left: 8px; }
}

/* 鑰?WebView 閲?fixed 鍏冪礌蹇呴』鏈夋槑纭昂瀵?*/
.modal-layer,
.call-layer,
.scan-layer,
.lightbox {
  width: 100%;
  height: 100%;
}

/* ============================================================
   v19锛氳〃鎯呴潰鏉?/ 缇ょ鐞?   ============================================================ */
.emoji-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% - 4px);
  max-height: 240px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
  z-index: 60;
}
.emoji-item {
  height: 38px;
  font-size: 22px;
  line-height: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
}
.emoji-item:hover { background: var(--panel-2); }
.emoji-item:active { background: var(--panel-3); }
.composer-wrap { position: relative; }

.manage-row .kick-btn {
  color: #f87171;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, .35);
}

/* ============================================================
   v20锛氬叏璁惧鍏煎鎬у姞鍥?   ============================================================ */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, .tab, .room-item, .contact-row {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
input, textarea {
  font-size: 16px;           /* 浣庝簬 16px 鏃?iOS 浼氳嚜鍔ㄦ斁澶ч〉闈?*/
}
@media (max-width: 820px) {
  input, textarea { font-size: 16px; }
}

/* 鍔ㄦ€佽鍙ｉ珮搴︼細iOS 閿洏寮瑰嚭鏃惰嚜鍔ㄦ敹缂╋紝涓嶄細鎸′綇杈撳叆妗?*/
.app {
  height: var(--app-height, 100%);
}
@supports (height: 100dvh) {
  .app { height: 100dvh; }
}

/* 鎵爜灞傜敤鐧惧垎姣旈珮搴︼紝閬垮厤 iOS 鍦板潃鏍忓鑷存孩鍑?*/
.scan-layer {
  width: 100%;
  height: 100%;
}

/* 闀挎寜閫変腑鏂囧瓧锛堣亰澶╁唴瀹瑰彲澶嶅埗锛?*/
.msg-text, .msg-body {
  -webkit-user-select: text;
  user-select: text;
}

/* ============================================================
   鍦ｈ癁涓婚锛氳儗鏅浘 + 姘旀场閰嶈壊 + 涓嬮洩
   ============================================================ */
body.fest-christmas {
  --xmas-bg: url("/static/img/christmas-bg.jpg");
}

body.fest-christmas .app {
  background-color: #0b1220;
  background-image:
    linear-gradient(180deg, rgba(8, 14, 26, .55), rgba(8, 14, 26, .78)),
    var(--xmas-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* 闈㈡澘鍗婇€忔槑锛岃鑳屾櫙閫忓嚭鏉?*/
body.fest-christmas .sidebar,
body.fest-christmas .room-list,
body.fest-christmas .page-header,
body.fest-christmas .chat-header,
body.fest-christmas .chat-body,
body.fest-christmas .messages,
body.fest-christmas .page-contacts,
body.fest-christmas .page-moments,
body.fest-christmas .page-settings {
  background-color: rgba(10, 16, 28, .72);
  backdrop-filter: none;
}

body.fest-christmas .composer-wrap,
body.fest-christmas .tabbar {
  background-color: rgba(10, 16, 28, .86);
}

/* 姘旀场閰嶈壊锛氬鏂规殫缁裤€佹垜鏂圭孩鑹?*/
body.fest-christmas .msg:not(.mine) .msg-text {
  background: #1e4a3a;
  color: #eaf6ef;
  border-color: rgba(120, 200, 160, .25);
}
body.fest-christmas .msg.mine .msg-text {
  background: #a8322f;
  color: #fff5f4;
  border-color: rgba(255, 255, 255, .12);
}
body.fest-christmas .msg:not(.mine) .msg-voice,
body.fest-christmas .msg:not(.mine) .msg-file {
  background: #1e4a3a;
  color: #eaf6ef;
  border-color: rgba(120, 200, 160, .25);
}
body.fest-christmas .msg.mine .msg-voice,
body.fest-christmas .msg.mine .msg-file {
  background: #a8322f;
  color: #fff5f4;
  border-color: rgba(255, 255, 255, .12);
}
body.fest-christmas .msg.mine .msg-author,
body.fest-christmas .msg.mine .msg-time { color: rgba(255, 220, 215, .75); }

/* 涓嬮洩鐢诲竷 */
.snow-canvas {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 45;
}
@media (prefers-reduced-motion: reduce) {
  .snow-canvas { display: none; }
}

/* 鍦ｈ癁涓婚锛氳鑳屾櫙鍥剧湡姝ｉ€忓嚭鏉ワ紝骞跺叧闂棫鐨勯洩鑺卞瓧绗﹀眰锛堟敼鐢?canvas 涓嬮洩锛?*/
body.fest-christmas #snow { display: none; }

body.fest-christmas .app {
  background-image:
    linear-gradient(180deg, rgba(6, 12, 24, .35), rgba(6, 12, 24, .62)),
    var(--xmas-bg);
}

body.fest-christmas .sidebar,
body.fest-christmas .room-list,
body.fest-christmas .page-header,
body.fest-christmas .chat-header,
body.fest-christmas .chat-body,
body.fest-christmas .messages,
body.fest-christmas .page-contacts,
body.fest-christmas .page-moments,
body.fest-christmas .page-settings,
body.fest-christmas .settings-group {
  background-color: rgba(8, 14, 26, .42);
}

body.fest-christmas .messages { background-color: transparent; }

body.fest-christmas .composer-wrap,
body.fest-christmas .tabbar {
  background-color: rgba(8, 14, 26, .66);
}

body.fest-christmas .composer {
  background: rgba(14, 22, 36, .72);
  border-color: rgba(160, 200, 255, .18);
}

/* 鍦ｈ癁涓婚锛氫富鍖哄煙閫忓嚭鑳屾櫙鍥?*/
body.fest-christmas .main,
body.fest-christmas .page-chat .main {
  background: transparent !important;
}
body.fest-christmas .sidebar { background-color: rgba(8, 14, 26, .55); }

/* 圣诞主题：作者名/时间颜色适配 */
body.fest-christmas .msg.mine .msg-author { color: #ffb9ad; }
body.fest-christmas .msg:not(.mine) .msg-author { color: #9fe0c0; }
body.fest-christmas .msg-time { color: rgba(220, 235, 255, .62); }

/* ============================================================
   中秋主题：月亮背景 + 月饼兔子特效 + 月饼气泡
   ============================================================ */
body.fest-midautumn {
  --moon-bg: url("/static/img/midautumn-bg.jpg");
}

body.fest-midautumn #snow { display: none; }

body.fest-midautumn .app {
  background-color: #1b1630;
  background-image:
    linear-gradient(180deg, rgba(18, 12, 30, .38), rgba(18, 12, 30, .62)),
    var(--moon-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.fest-midautumn .main,
body.fest-midautumn .page-chat .main {
  background: transparent !important;
}

body.fest-midautumn .sidebar,
body.fest-midautumn .room-list,
body.fest-midautumn .page-header,
body.fest-midautumn .chat-header,
body.fest-midautumn .chat-body,
body.fest-midautumn .messages,
body.fest-midautumn .page-contacts,
body.fest-midautumn .page-moments,
body.fest-midautumn .page-settings,
body.fest-midautumn .settings-group {
  background-color: rgba(24, 18, 38, .45);
}

body.fest-midautumn .messages { background-color: transparent; }

body.fest-midautumn .composer-wrap,
body.fest-midautumn .tabbar {
  background-color: rgba(24, 18, 38, .68);
}

body.fest-midautumn .composer {
  background: rgba(42, 30, 58, .74);
  border-color: rgba(255, 220, 150, .22);
}

/* ---- 月饼气泡 ---- */
body.fest-midautumn .msg .msg-text {
  border-radius: 16px;
  position: relative;
}

/* 对方：烤金饼皮 */
body.fest-midautumn .msg:not(.mine) .msg-text {
  background:
    radial-gradient(circle at 28% 26%, rgba(255, 226, 170, .30), transparent 58%),
    repeating-linear-gradient(45deg,
      rgba(90, 52, 16, .14) 0 5px,
      rgba(255, 255, 255, 0) 5px 10px),
    linear-gradient(160deg, #b06a2c 0%, #96521f 100%);
  color: #fff6e6;
  border-color: rgba(255, 214, 150, .35);
}

/* 我方：奶黄月饼 */
body.fest-midautumn .msg.mine .msg-text {
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 255, 255, .45), transparent 58%),
    repeating-linear-gradient(-45deg,
      rgba(150, 96, 20, .12) 0 5px,
      rgba(255, 255, 255, 0) 5px 10px),
    linear-gradient(160deg, #f0c762 0%, #e2a93c 100%);
  color: #3a2410;
  border-color: rgba(255, 236, 180, .55);
}

body.fest-midautumn .msg:not(.mine) .msg-voice,
body.fest-midautumn .msg:not(.mine) .msg-file {
  background: linear-gradient(160deg, #b06a2c 0%, #96521f 100%);
  color: #fff6e6;
  border-color: rgba(255, 214, 150, .35);
}
body.fest-midautumn .msg.mine .msg-voice,
body.fest-midautumn .msg.mine .msg-file {
  background: linear-gradient(160deg, #f0c762 0%, #e2a93c 100%);
  color: #3a2410;
  border-color: rgba(255, 236, 180, .55);
}

body.fest-midautumn .msg.mine .msg-author { color: #ffd98a; }
body.fest-midautumn .msg:not(.mine) .msg-author { color: #ffc98a; }
body.fest-midautumn .msg-time { color: rgba(255, 236, 200, .64); }

/* 中秋粒子层 */
.moon-canvas {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 45;
}
@media (prefers-reduced-motion: reduce) {
  .moon-canvas { display: none; }
}

/* ============================================================
   新年主题：烟花背景 + 鞭炮红包特效 + 金红气泡
   ============================================================ */
body.fest-newyear {
  --ny-bg: url("/static/img/newyear-bg.jpg");
}

body.fest-newyear #snow { display: none; }

body.fest-newyear .app {
  background-color: #101a33;
  background-image:
    linear-gradient(180deg, rgba(10, 16, 34, .34), rgba(10, 16, 34, .60)),
    var(--ny-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.fest-newyear .main,
body.fest-newyear .page-chat .main {
  background: transparent !important;
}

body.fest-newyear .sidebar,
body.fest-newyear .room-list,
body.fest-newyear .page-header,
body.fest-newyear .chat-header,
body.fest-newyear .chat-body,
body.fest-newyear .messages,
body.fest-newyear .page-contacts,
body.fest-newyear .page-moments,
body.fest-newyear .page-settings,
body.fest-newyear .settings-group {
  background-color: rgba(14, 20, 40, .48);
}

body.fest-newyear .messages { background-color: transparent; }

body.fest-newyear .composer-wrap,
body.fest-newyear .tabbar {
  background-color: rgba(14, 20, 40, .70);
}

body.fest-newyear .composer {
  background: rgba(28, 34, 58, .74);
  border-color: rgba(255, 210, 120, .22);
}

/* ---- 气泡：对方金色、我方红色 ---- */
body.fest-newyear .msg .msg-text { border-radius: 14px; }

body.fest-newyear .msg:not(.mine) .msg-text {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .35), transparent 58%),
    linear-gradient(160deg, #f2c14e 0%, #d4a017 100%);
  color: #3b2600;
  border-color: rgba(255, 232, 160, .55);
}

body.fest-newyear .msg.mine .msg-text {
  background:
    radial-gradient(circle at 70% 24%, rgba(255, 190, 180, .32), transparent 58%),
    linear-gradient(160deg, #d32f2f 0%, #9b1c1c 100%);
  color: #fff4f0;
  border-color: rgba(255, 170, 150, .35);
}

body.fest-newyear .msg:not(.mine) .msg-voice,
body.fest-newyear .msg:not(.mine) .msg-file {
  background: linear-gradient(160deg, #f2c14e 0%, #d4a017 100%);
  color: #3b2600;
  border-color: rgba(255, 232, 160, .55);
}
body.fest-newyear .msg.mine .msg-voice,
body.fest-newyear .msg.mine .msg-file {
  background: linear-gradient(160deg, #d32f2f 0%, #9b1c1c 100%);
  color: #fff4f0;
  border-color: rgba(255, 170, 150, .35);
}

body.fest-newyear .msg.mine .msg-author { color: #ffb3a0; }
body.fest-newyear .msg:not(.mine) .msg-author { color: #ffd77a; }
body.fest-newyear .msg-time { color: rgba(255, 236, 200, .64); }

/* ============================================================
   泼水节主题：水花背景 + 水滴特效 + 金蓝气泡
   ============================================================ */
body.fest-thingyan {
  --ty-bg: url("/static/img/thingyan-bg.jpg");
}

body.fest-thingyan #snow { display: none; }

body.fest-thingyan .app {
  background-color: #0f2233;
  background-image:
    linear-gradient(180deg, rgba(8, 26, 40, .30), rgba(8, 26, 40, .58)),
    var(--ty-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.fest-thingyan .main,
body.fest-thingyan .page-chat .main {
  background: transparent !important;
}

body.fest-thingyan .sidebar,
body.fest-thingyan .room-list,
body.fest-thingyan .page-header,
body.fest-thingyan .chat-header,
body.fest-thingyan .chat-body,
body.fest-thingyan .messages,
body.fest-thingyan .page-contacts,
body.fest-thingyan .page-moments,
body.fest-thingyan .page-settings,
body.fest-thingyan .settings-group {
  background-color: rgba(10, 30, 44, .48);
}

body.fest-thingyan .messages { background-color: transparent; }

body.fest-thingyan .composer-wrap,
body.fest-thingyan .tabbar {
  background-color: rgba(10, 30, 44, .70);
}

body.fest-thingyan .composer {
  background: rgba(18, 46, 64, .74);
  border-color: rgba(140, 220, 255, .22);
}

/* ---- 气泡：对方金色、我方蓝色 ---- */
body.fest-thingyan .msg .msg-text { border-radius: 14px; }

body.fest-thingyan .msg:not(.mine) .msg-text {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .35), transparent 58%),
    linear-gradient(160deg, #f2c14e 0%, #d4a017 100%);
  color: #3b2600;
  border-color: rgba(255, 232, 160, .55);
}

body.fest-thingyan .msg.mine .msg-text {
  background:
    radial-gradient(circle at 70% 24%, rgba(180, 225, 255, .35), transparent 58%),
    linear-gradient(160deg, #2f7fd8 0%, #1b4b9b 100%);
  color: #f2f9ff;
  border-color: rgba(160, 210, 255, .35);
}

body.fest-thingyan .msg:not(.mine) .msg-voice,
body.fest-thingyan .msg:not(.mine) .msg-file {
  background: linear-gradient(160deg, #f2c14e 0%, #d4a017 100%);
  color: #3b2600;
  border-color: rgba(255, 232, 160, .55);
}
body.fest-thingyan .msg.mine .msg-voice,
body.fest-thingyan .msg.mine .msg-file {
  background: linear-gradient(160deg, #2f7fd8 0%, #1b4b9b 100%);
  color: #f2f9ff;
  border-color: rgba(160, 210, 255, .35);
}

body.fest-thingyan .msg.mine .msg-author { color: #a8d4ff; }
body.fest-thingyan .msg:not(.mine) .msg-author { color: #ffd77a; }
body.fest-thingyan .msg-time { color: rgba(220, 240, 255, .66); }

/* ============================================================
   点灯节主题：金塔灯海背景 + 孔明灯水灯特效 + 双金气泡
   ============================================================ */
body.fest-thadingyut {
  --td-bg: url("/static/img/thadingyut-bg.jpg");
}

body.fest-thadingyut #snow { display: none; }

body.fest-thadingyut .app {
  background-color: #12100c;
  background-image:
    linear-gradient(180deg, rgba(24, 16, 6, .34), rgba(24, 16, 6, .60)),
    var(--td-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.fest-thadingyut .main,
body.fest-thadingyut .page-chat .main {
  background: transparent !important;
}

body.fest-thadingyut .sidebar,
body.fest-thadingyut .room-list,
body.fest-thadingyut .page-header,
body.fest-thadingyut .chat-header,
body.fest-thadingyut .chat-body,
body.fest-thadingyut .messages,
body.fest-thadingyut .page-contacts,
body.fest-thadingyut .page-moments,
body.fest-thadingyut .page-settings,
body.fest-thadingyut .settings-group {
  background-color: rgba(26, 18, 8, .46);
}

body.fest-thadingyut .messages { background-color: transparent; }

body.fest-thadingyut .composer-wrap,
body.fest-thadingyut .tabbar {
  background-color: rgba(26, 18, 8, .70);
}

body.fest-thadingyut .composer {
  background: rgba(44, 32, 14, .74);
  border-color: rgba(255, 210, 120, .22);
}

/* ---- 双金气泡：靠亮度和描边区分 ---- */
body.fest-thadingyut .msg .msg-text { border-radius: 14px; }

/* 对方：亮金（浅底深字） */
body.fest-thadingyut .msg:not(.mine) .msg-text {
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, .45), transparent 58%),
    linear-gradient(160deg, #f7d36b 0%, #e0aa2a 100%);
  color: #3a2700;
  border: 1px solid rgba(255, 244, 200, .75);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}

/* 我方：深金 / 琥珀（深底浅字 + 金色描边） */
body.fest-thadingyut .msg.mine .msg-text {
  background:
    radial-gradient(circle at 72% 22%, rgba(255, 220, 150, .55), transparent 58%),
    linear-gradient(160deg, #c98f1f 0%, #8f5f0c 100%);
  color: #fff6dd;
  border: 1px solid rgba(255, 214, 120, .55);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .24);
}

body.fest-thadingyut .msg:not(.mine) .msg-voice,
body.fest-thadingyut .msg:not(.mine) .msg-file {
  background: linear-gradient(160deg, #f7d36b 0%, #e0aa2a 100%);
  color: #3a2700;
  border-color: rgba(255, 244, 200, .75);
}
body.fest-thadingyut .msg.mine .msg-voice,
body.fest-thadingyut .msg.mine .msg-file {
  background: linear-gradient(160deg, #c98f1f 0%, #8f5f0c 100%);
  color: #fff6dd;
  border-color: rgba(255, 214, 120, .55);
}

body.fest-thadingyut .msg.mine .msg-author { color: #ffd98b; }
body.fest-thadingyut .msg:not(.mine) .msg-author { color: #ffe6a8; }
body.fest-thadingyut .msg-time { color: rgba(255, 236, 190, .66); }

/* ============================================================
   启动页（3 秒）
   ============================================================ */
.splash {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 42%, #2a2340 0%, #141322 46%, #0a0a12 100%);
  transition: opacity .45s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  transform: translateY(-2vh);
}
.splash-logo {
  width: 132px;
  height: 132px;
  border-radius: 26px;
  box-shadow: 0 18px 50px rgba(120, 80, 220, .35), 0 0 0 1px rgba(255, 255, 255, .06);
  animation: splash-pop .8s cubic-bezier(.22, 1.2, .36, 1) both;
}
.splash-title {
  font-size: 20px;
  letter-spacing: .32em;
  color: #f2eeff;
  font-weight: 600;
  animation: splash-fade .9s .15s both;
}
.splash-sub {
  font-size: 11px;
  letter-spacing: .28em;
  color: rgba(210, 200, 255, .55);
  text-transform: uppercase;
  animation: splash-fade .9s .3s both;
}
.splash-bar {
  width: 132px;
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
  margin-top: 4px;
}
.splash-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #8b5cf6, #c4a0ff);
  animation: splash-load 2.7s cubic-bezier(.5, .05, .2, 1) forwards;
}
@keyframes splash-pop {
  from { opacity: 0; transform: scale(.82); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes splash-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes splash-load {
  0% { width: 0; }
  55% { width: 62%; }
  100% { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-title, .splash-sub { animation: none; }
  .splash-bar i { animation-duration: 1.2s; }
}

/* ============================================================
   情人节主题：樱花背景 + 爱心特效 + 红粉气泡
   ============================================================ */
body.fest-valentine {
  --val-bg: url("/static/img/valentine-bg.jpg");
}

body.fest-valentine #snow { display: none; }

body.fest-valentine .app {
  background-color: #2a1620;
  background-image:
    linear-gradient(180deg, rgba(40, 16, 26, .30), rgba(40, 16, 26, .58)),
    var(--val-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

body.fest-valentine .main,
body.fest-valentine .page-chat .main {
  background: transparent !important;
}

body.fest-valentine .sidebar,
body.fest-valentine .room-list,
body.fest-valentine .page-header,
body.fest-valentine .chat-header,
body.fest-valentine .chat-body,
body.fest-valentine .messages,
body.fest-valentine .page-contacts,
body.fest-valentine .page-moments,
body.fest-valentine .page-settings,
body.fest-valentine .settings-group {
  background-color: rgba(48, 20, 32, .44);
}

body.fest-valentine .messages { background-color: transparent; }

body.fest-valentine .composer-wrap,
body.fest-valentine .tabbar {
  background-color: rgba(48, 20, 32, .68);
}

body.fest-valentine .composer {
  background: rgba(66, 28, 44, .74);
  border-color: rgba(255, 170, 200, .22);
}

/* ---- 气泡：对方红色、我方粉色 ---- */
body.fest-valentine .msg .msg-text { border-radius: 16px; }

body.fest-valentine .msg:not(.mine) .msg-text {
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, .30), transparent 58%),
    linear-gradient(160deg, #e04a5f 0%, #a8192f 100%);
  color: #fff2f4;
  border-color: rgba(255, 180, 190, .35);
}

body.fest-valentine .msg.mine .msg-text {
  background:
    radial-gradient(circle at 72% 22%, rgba(255, 255, 255, .45), transparent 58%),
    linear-gradient(160deg, #ffc2d6 0%, #f28fb4 100%);
  color: #5c1730;
  border-color: rgba(255, 230, 240, .60);
}

body.fest-valentine .msg:not(.mine) .msg-voice,
body.fest-valentine .msg:not(.mine) .msg-file {
  background: linear-gradient(160deg, #e04a5f 0%, #a8192f 100%);
  color: #fff2f4;
  border-color: rgba(255, 180, 190, .35);
}
body.fest-valentine .msg.mine .msg-voice,
body.fest-valentine .msg.mine .msg-file {
  background: linear-gradient(160deg, #ffc2d6 0%, #f28fb4 100%);
  color: #5c1730;
  border-color: rgba(255, 230, 240, .60);
}

body.fest-valentine .msg.mine .msg-author { color: #ffb3cc; }
body.fest-valentine .msg:not(.mine) .msg-author { color: #ff8fa3; }
body.fest-valentine .msg-time { color: rgba(255, 220, 230, .66); }

/* ============================================================
   朋友圈：多图九宫格 / 视频 / 评论表情
   ============================================================ */
.moment-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 8px 0 4px;
}
.moment-preview-grid.video-mode { grid-template-columns: 1fr; }
.moment-preview-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel-2);
}
.moment-preview-grid.video-mode .moment-preview-cell { aspect-ratio: 16 / 9; }
.moment-preview-cell img,
.moment-preview-cell video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.preview-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 14px;
  line-height: 18px;
  text-align: center;
  padding: 0;
}
.preview-kind {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
}
.preview-tip {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* 动态里的媒体网格 */
.moment-media-grid {
  display: grid;
  gap: 5px;
  margin: 8px 0;
  max-width: 360px;
}
.moment-media-grid.count-1 { grid-template-columns: 1fr; max-width: 240px; }
.moment-media-grid.count-2 { grid-template-columns: repeat(2, 1fr); }
.moment-media-grid.count-3 { grid-template-columns: repeat(3, 1fr); }
.moment-media-grid.count-4 { grid-template-columns: repeat(2, 1fr); }
.moment-media-grid.count-5,
.moment-media-grid.count-6 { grid-template-columns: repeat(3, 1fr); }
.moment-media-grid.count-7,
.moment-media-grid.count-8,
.moment-media-grid.count-9 { grid-template-columns: repeat(3, 1fr); }
.moment-media-grid.is-video { grid-template-columns: 1fr; max-width: 100%; }

.moment-media-grid .moment-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: zoom-in;
  display: block;
}
.moment-media-grid.count-1 .moment-image { aspect-ratio: auto; max-height: 320px; }
.moment-video {
  width: 100%;
  max-height: 360px;
  border-radius: 10px;
  background: #000;
  display: block;
}

/* 评论表情 */
.moment-comment-input { position: relative; }
.comment-emoji-btn {
  font-size: 18px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
}
.comment-emoji-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  max-height: 180px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 3px;
  z-index: 30;
}
.comment-emoji-sheet button {
  height: 34px;
  font-size: 19px;
  border-radius: 8px;
}
.comment-emoji-sheet .sheet-close {
  grid-column: 1 / -1;
  font-size: 12px;
  height: 26px;
  color: var(--muted);
}

/* 评论表情面板修正：改为底部弹出 + 统一配色 */
.comment-emoji-sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  max-height: 38vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
  z-index: 400;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
.comment-emoji-sheet button {
  height: 36px;
  font-size: 20px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 0;
}
.comment-emoji-sheet button:hover { background: var(--panel-3); }
.comment-emoji-sheet .sheet-close {
  grid-column: 1 / -1;
  height: 30px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
}

/* ============================================================
   朋友圈互动通知：徽标 / 横幅 / 互动列表 / 详情
   ============================================================ */
.tab-badge {
  position: absolute;
  top: 4px;
  left: 50%;
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ff3b30;
  color: #fff;
  font-size: 10px;
  font-style: normal;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 1.5px var(--panel);
}

.moment-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 8px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  text-align: left;
}
.moment-notice:active { background: var(--panel-2); }
.moment-notice .notice-icon { font-size: 16px; }

.mument-list { display: flex; flex-direction: column; gap: 2px; }
.mument-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-radius: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
}
.mument-row:active { background: var(--panel-2); }
.mument-main { flex: 1; min-width: 0; }
.mument-name { font-size: 14px; font-weight: 600; color: var(--accent); }
.mument-text {
  font-size: 13px;
  color: var(--text);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mument-time { font-size: 11px; color: var(--muted); margin-top: 3px; }
.mument-thumb {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
  background: var(--panel-2);
}

.mdetail-body .moment-item { padding: 0; }

/* 互动/详情页：按钮固定底部 */
.mument-page,
.mdetail-page {
  display: flex !important;
  flex-direction: column;
}
.mument-page #mument-list,
.mdetail-page #mdetail-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.mument-page .modal-actions,
.mdetail-page .modal-actions {
  margin-top: auto;
}

/* ============================================================
   图片 / 视频查看器：自适应屏幕 + 缩放 + 保存
   ============================================================ */
.lightbox {
  display: flex !important;
  flex-direction: column;
  padding: 0 !important;
  background: rgba(0, 0, 0, .94);
  cursor: default;
}
.lb-toolbar {
  flex: none;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,.75), transparent);
  z-index: 2;
}
.lb-btn {
  padding: 7px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 14px;
  border: 0;
}
.lb-btn:active { background: rgba(255, 255, 255, .3); }

.lb-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.lb-stage img,
.lb-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  transition: transform .18s ease;
  will-change: transform;
  touch-action: none;
  cursor: zoom-in;
}
.lb-stage img.zoomed { cursor: grab; }
.lb-stage img.dragging { cursor: grabbing; transition: none; }
.lb-stage video { width: 100%; max-height: 100%; background: #000; cursor: default; }

.lb-tip {
  flex: none;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, .55);
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px));
}
@media (max-width: 820px) {
  .lb-tip { display: none; }
}

/* 查看器视频强制铺满（覆盖浏览器默认 300x150） */
.lb-stage video {
  width: 100% !important;
  height: auto !important;
  max-height: 100% !important;
  object-fit: contain !important;
  background: #000;
}

/* 修复：旧的 place-items:center 让子元素收缩成 300px */
.lightbox { align-items: stretch !important; }
.lb-toolbar,
.lb-stage,
.lb-tip { width: 100%; }


/* 防复发：所有用 display 覆盖过的组件，隐藏时必须优先 */
.lightbox[hidden],
.moment-preview-grid[hidden],
.comment-emoji-sheet[hidden],
.moment-notice[hidden],
.mument-page[hidden],
.mdetail-page[hidden] {
  display: none !important;
}

/* ============================================================
   聊天内视频消息 / 朋友圈转发卡片 / 转发面板
   ============================================================ */
.msg-video {
  max-width: 260px;
  max-height: 320px;
  border-radius: 12px;
  background: #000;
  display: block;
}

.msg-moment-card {
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: 280px;
  padding: 8px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  text-align: left;
  color: var(--text);
}
.msg-moment-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
  background: var(--panel-3);
}
.msg-moment-main { min-width: 0; }
.msg-moment-from { font-size: 12px; color: var(--accent); }
.msg-moment-text {
  font-size: 13px;
  color: var(--text);
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.share-page { display: flex !important; flex-direction: column; }
.share-search { padding: 4px 0 8px; }
.share-search input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.share-list { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.share-row:active { background: var(--panel-2); }
.share-main { min-width: 0; }
.share-name { font-size: 14px; font-weight: 600; }
.share-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.share-page .modal-actions { margin-top: 8px; }

/* ============================================================
   账号注销 / 协议 / 黑名单 / 举报
   ============================================================ */
.auth-agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.auth-agree input { margin-top: 2px; accent-color: var(--accent); }
.auth-agree a { color: var(--accent); }

.settings-row.danger-row span:first-child { color: #f87171; }

.delacc-page { display: flex !important; flex-direction: column; }
.delacc-warn {
  font-size: 13px;
  color: #f0b429;
  background: rgba(240, 180, 41, .08);
  border: 1px solid rgba(240, 180, 41, .25);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.7;
  margin: 6px 0 14px;
}
.delacc-page .field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 6px;
}
.delacc-page input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.delacc-error { color: #f87171; font-size: 13px; margin: 10px 0 0; }
.btn-danger {
  background: #dc2626;
  color: #fff;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
}
.btn-danger:disabled { opacity: .6; }

.blocked-page { display: flex !important; flex-direction: column; }
.blocked-list { flex: 1; overflow-y: auto; min-height: 120px; }
.blocked-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.btn-ghost.small { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.blocked-page .modal-actions { margin-top: 8px; }

/* ============================================================
   多语言：语言选择列表
   ============================================================ */
.lang-page { display: flex !important; flex-direction: column; }
.lang-list { display: flex; flex-direction: column; gap: 4px; padding: 4px 0 10px; }
.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  border: 1px solid transparent;
}
.lang-row.active {
  border-color: var(--accent);
  background: rgba(124, 108, 255, .12);
}
.lang-check { color: var(--accent); font-size: 15px; }

/* 多语言：协议里的链接样式统一 */
.auth-agree a { color: var(--accent); text-decoration: none; }
.auth-agree a:active { opacity: .7; }

/* ============================================================
   移动端适配：防止朋友圈/评论行横向溢出（360px 等窄屏）
   ============================================================ */
html, body { overflow-x: hidden; }
.moments-scroll { overflow-x: hidden; }

.moment-actions { flex-wrap: wrap; row-gap: 6px; }
.moment-actions .like-btn { flex: 0 0 auto; }

.moment-comment-input { align-items: center; flex-wrap: nowrap; }
.moment-comment-input input {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
}
.moment-comment-input > button { flex: 0 0 auto; }

@media (max-width: 400px) {
  .moment-actions { gap: 8px; }
  .like-btn { padding: 5px 8px; font-size: 12px; }
}

/* ============================================================
   首次权限引导（安卓）
   ============================================================ */
.perm-page { display: flex !important; flex-direction: column; }
.perm-desc { font-size: 13px; color: var(--muted); margin: 4px 0 14px; line-height: 1.6; }
.perm-list { display: flex; flex-direction: column; gap: 8px; }
.perm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  border: 1px solid transparent;
}
.perm-row:active { border-color: var(--accent); }
.perm-icon { font-size: 20px; flex: none; }
.perm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.perm-main b { font-size: 14px; font-weight: 600; }
.perm-main em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.perm-status { font-size: 12px; color: #f0b429; flex: none; }
.perm-status.ok { color: var(--green); }
.perm-page .modal-actions { margin-top: 16px; }

/* 下载区版本与校验 */
.download-verify {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}
.download-verify a { color: var(--accent); text-decoration: none; }

/* ============================================================
   链接 / @提及 / 表情回应 / 置顶 / 右键菜单
   ============================================================ */
.msg-link {
  color: #6aa8ff;
  text-decoration: underline;
  word-break: break-all;
}
.msg-mention {
  color: #6aa8ff;
  background: rgba(106, 168, 255, .14);
  border-radius: 4px;
  padding: 0 3px;
}
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.reaction-chip.mine {
  background: rgba(124, 108, 255, .22);
  border-color: rgba(124, 108, 255, .5);
}
.reaction-chip:active { transform: scale(.94); }

.msg-menu-emoji {
  display: flex;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 4px;
}
.msg-menu-emoji button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  background: transparent;
  color: var(--text);
}
.msg-menu-emoji button:active { background: rgba(255, 255, 255, .12); }

#msg-menu {
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pinned-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px 6px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(124, 108, 255, .14);
  border-left: 3px solid var(--accent);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.pinned-banner .pin-icon { font-size: 13px; }
.pinned-banner .pin-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
}
.pinned-banner .pin-close {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}
.msg.flash .msg-content {
  animation: msgFlash 1.1s ease;
}
@keyframes msgFlash {
  0% { box-shadow: 0 0 0 2px rgba(124, 108, 255, .9); }
  100% { box-shadow: 0 0 0 2px rgba(124, 108, 255, 0); }
}

/* ============================================================
   丝滑动效系统（iOS 风格）
   ============================================================ */
:root {
  --ease-out: cubic-bezier(.22, .61, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
}

* { -webkit-tap-highlight-color: transparent; }
button, a, .tab, .room-item, .settings-row, .download-btn, .perm-row, .lang-row, .share-row {
  touch-action: manipulation;
}
button { transition: transform .12s var(--ease-out), background-color .16s, opacity .16s; }
button:active { transform: scale(.965); }
.tab:active svg { transform: scale(.92); }
.tab svg { transition: transform .15s var(--ease-spring); }

/* 页面切换：轻微上浮淡入 */
.page.active {
  animation: pageIn .22s var(--ease-out);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* 弹层 */
.modal-layer:not([hidden]) {
  animation: layerFade .16s var(--ease-out);
}
.modal-layer:not([hidden]) .modal {
  animation: modalPop .24s var(--ease-spring);
}
@keyframes layerFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* 消息入场 */
.msg-enter { animation: msgIn .2s var(--ease-out); }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* 菜单 */
.msg-menu:not([hidden]) { animation: menuPop .14s var(--ease-out); }
@keyframes menuPop {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: none; }
}

/* 侧边栏更顺 */
.sidebar { transition: transform .26s var(--ease-out), box-shadow .26s; }
.chat { transition: transform .24s var(--ease-out), opacity .2s; }

/* 滚动更跟手 */
.messages, .page-scroll, .msg-list, .share-list, .blocked-list {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* 长按反馈 */
.msg { transition: background-color .15s; }
.msg:active { background-color: rgba(255, 255, 255, .035); }

/* 尊重系统「减少动态效果」 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   手机端：会话从右侧滑入（WeChat 手感）
   ============================================================ */
@media (max-width: 820px) {
  .page-chat { position: relative; overflow: hidden; }
  .main {
    display: flex !important;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    background: var(--bg);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .3s var(--ease-out), visibility 0s linear .3s;
  }
  body.chat-open .main {
    transform: none;
    visibility: visible;
    transition: transform .3s var(--ease-out), visibility 0s;
  }
  /* 列表轻微后退，形成层次 */
  .sidebar {
    transition: transform .3s var(--ease-out), opacity .3s;
  }
  body.chat-open .sidebar {
    transform: translateX(-16%);
    opacity: .85;
  }
  /* 打开会话时不再显示底部标签栏 */
  body.chat-open .tabbar { display: none; }
}

/* ============================================================
   图片编辑 / 视频剪辑
   ============================================================ */
.imgedit-page {
  display: flex !important;
  flex-direction: column;
  max-height: 92vh;
}
.imgedit-toolbar,
.imgedit-colors {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 2px;
}
.tool-btn {
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  border: 1px solid var(--border);
}
.tool-btn.active {
  background: rgba(124, 108, 255, .22);
  border-color: var(--accent);
  color: #cfc8ff;
}
.imgedit-stage {
  position: relative;
  flex: 1;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0a0c12;
  border-radius: 10px;
  margin: 8px 0;
}
.imgedit-stage canvas {
  max-width: 100%;
  max-height: 52vh;
  touch-action: none;
  display: block;
}
.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  display: inline-block;
}
.color-dot.active { border-color: var(--accent); }
#imgedit-size { flex: 1; min-width: 80px; accent-color: var(--accent); }

.videotrim-page { display: flex !important; flex-direction: column; }
#videotrim-video {
  width: 100%;
  max-height: 42vh;
  background: #000;
  border-radius: 10px;
}
.trim-info {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 4px;
}
.trim-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 4px 0;
}
.trim-label input { flex: 1; accent-color: var(--accent); }
.crop-box {
  position: absolute;
  border: 2px dashed #7c6cff;
  background: rgba(124, 108, 255, .12);
  pointer-events: none;
  z-index: 3;
}
.imgedit-stage { position: relative; }
.crop-actions {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 4;
}
.crop-ok,
.crop-redo {
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  border: 0;
}
.crop-ok { background: #34c759; color: #fff; font-weight: 600; }
.crop-redo { background: rgba(255, 255, 255, .16); color: #fff; }
.room-icon.official {
  background: linear-gradient(135deg, #f0b429, #ef7d3a);
  display: grid;
  place-items: center;
  color: #fff;
}
.room-icon.official svg { width: 18px; height: 18px; }
.phone-page { display: flex !important; flex-direction: column; gap: 10px; }
.phone-code-row { display: flex; gap: 8px; }
.phone-code-row input { flex: 1; min-width: 0; }
#phone-input, #phone-code {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
}
#phone-send { white-space: nowrap; }
#phone-send:disabled { opacity: .5; }
.btn-ghost.danger { color: #ff6b6b; }
.auth-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}
.auth-links button {
  background: none;
  border: 0;
  color: #9d92ff;
  font-size: 12.5px;
  padding: 4px 2px;
}
.sms-auth-page { display: flex !important; flex-direction: column; gap: 9px; }
.devices-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.device-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.device-item .meta { flex: 1; min-width: 0; }
.device-item b { font-size: 13.5px; display: block; }
.device-item small { color: var(--muted); font-size: 11.5px; }
.device-item .now {
  font-size: 11px;
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, .4);
  border-radius: 6px;
  padding: 1px 6px;
}
.login-alert-actions { display: flex; gap: 8px; margin-top: 10px; }
.login-alert-actions button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0;
  font-size: 13px;
}
.login-alert-actions .ok { background: rgba(34, 197, 94, .18); color: #4ade80; }
.login-alert-actions .no { background: rgba(239, 68, 68, .18); color: #f87171; }
.login-alert-actions button:disabled { opacity: .45; }
/* 通话悬浮小窗 */
.call-float {
  position: fixed;
  right: 14px;
  bottom: 90px;
  width: 132px;
  height: 200px;
  z-index: 300;
  border-radius: 14px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  touch-action: none;
}
.call-float .cf-remote,
.call-float .cf-local {
  position: absolute;
  overflow: hidden;
  background: #000;
}
.call-float .cf-remote { inset: 0; }
.call-float .cf-local {
  right: 6px;
  top: 6px;
  width: 34%;
  height: 30%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .25);
}
.call-float video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.call-float .cf-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  opacity: 0;
  transition: opacity .2s;
}
.call-float:hover .cf-bar,
.call-float.show-bar .cf-bar { opacity: 1; }
.call-float .cf-bar button {
  flex: 1;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-size: 14px;
  padding: 5px 0;
}
.call-float .cf-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, .45) 50%);
}

/* 系统画中画模式：只留远端画面 */
body.pip-mode .tab-pages,
body.pip-mode .tabbar,
body.pip-mode .sidebar,
body.pip-mode .call-actions,
body.pip-mode .call-placeholder,
body.pip-mode .local-video,
body.pip-mode .cf-bar,
body.pip-mode .cf-local {
  display: none !important;
}
body.pip-mode #call-layer { background: #000; }
body.pip-mode .call-box { border-radius: 0; }
body.pip-mode .remote-video { object-fit: cover; }

/* ============================================================
   通话界面（微信风格）
   ============================================================ */
.call-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  overflow: hidden;
  color: #fff;
}
.call-layer[hidden] { display: none !important; }
.call-layer .remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.call-layer .local-video {
  position: absolute;
  top: calc(60px + env(safe-area-inset-top));
  right: 12px;
  width: 104px;
  height: 150px;
  border-radius: 10px;
  object-fit: cover;
  background: #111;
  z-index: 6;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
  touch-action: none;
}
.call-layer .call-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: radial-gradient(120% 80% at 50% 20%, #2a2f3a 0%, #0b0d12 70%);
  z-index: 3;
}
.call-layer .call-peer-name { font-size: 19px; font-weight: 600; }
.call-layer .call-status { font-size: 13px; color: rgba(255, 255, 255, .7); }
.call-layer .call-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 0;
}
.call-top-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  display: grid;
  place-items: center;
}
.call-top-btn svg { width: 20px; height: 20px; }
.call-duration {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
.call-layer .call-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 8px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .35));
}
.call-row {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
}
.call-big {
  background: none;
  border: 0;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  min-width: 88px;
}
.call-ico {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}
.call-ico svg { width: 26px; height: 26px; }
.call-big em { font-style: normal; color: rgba(255, 255, 255, .88); font-size: 12px; }
.call-big.off .call-ico { background: #fff; color: #111; }
.call-big.small .call-ico { width: 52px; height: 52px; background: rgba(255, 255, 255, .12); }
.call-big.small .call-ico svg { width: 22px; height: 22px; }
.call-hangup {
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 50%;
  background: #f0433f;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(240, 67, 63, .35);
}
.call-hangup svg { width: 30px; height: 30px; transform: rotate(135deg); }
.call-more-menu {
  position: absolute;
  right: 14px;
  bottom: calc(160px + env(safe-area-inset-bottom));
  z-index: 20;
  background: rgba(32, 34, 40, .96);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 132px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.call-more-menu[hidden] { display: none !important; }
.call-more-menu button {
  background: none;
  border: 0;
  color: #fff;
  text-align: left;
  padding: 10px 14px;
  font-size: 13.5px;
  border-radius: 8px;
}
.call-more-menu button:active { background: rgba(255, 255, 255, .12); }

/* 画中画模式：只保留远端画面 */
body.pip-mode .tab-pages,
body.pip-mode .tabbar,
body.pip-mode .sidebar,
body.pip-mode .call-top,
body.pip-mode .call-bottom,
body.pip-mode .call-placeholder,
body.pip-mode .local-video,
body.pip-mode .call-more-menu {
  display: none !important;
}

/* 全屏来电 */
.incoming-screen {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: #14161b;
  color: #fff;
  overflow: hidden;
}
.incoming-screen[hidden] { display: none !important; }
.incoming-bg {
  position: absolute;
  inset: -10%;
  background-size: cover;
  background-position: center;
  filter: blur(28px) brightness(.45);
  transform: scale(1.1);
}
.incoming-info {
  position: relative;
  z-index: 2;
  height: 72%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.incoming-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #2b2f39 center/cover no-repeat;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
}
.incoming-info h3 { font-size: 21px; font-weight: 600; margin: 4px 0 0; }
.incoming-info p { font-size: 13.5px; color: rgba(255, 255, 255, .65); margin: 0; }
.incoming-buttons {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  justify-content: space-evenly;
  align-items: flex-start;
}
.incoming-btn {
  background: none;
  border: 0;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.incoming-btn em { font-style: normal; color: rgba(255, 255, 255, .85); }
.ib-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
}
.ib-circle svg { width: 30px; height: 30px; transform: rotate(135deg); }
.incoming-btn.accept .ib-circle svg { transform: none; }
.incoming-btn.reject .ib-circle { background: #fa5151; }
.incoming-btn.accept .ib-circle { background: #07c160; }

/* 语音通话：突出头像 */
.call-layer.audio .call-placeholder { background: radial-gradient(120% 80% at 50% 25%, #2c3140 0%, #0b0d12 72%); }
.call-layer.audio .call-placeholder .avatar { width: 96px; height: 96px; font-size: 34px; }
.call-layer.audio .call-peer-name { font-size: 21px; margin-top: 6px; }
.call-layer.audio .local-video { display: none; }

/* 通话底部第二排：更多 / 挂断居中 / 翻转 */
.call-bottom .call-row:nth-child(2) {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
}
.call-bottom .call-row:nth-child(2) > :first-child { justify-self: end; margin-right: 26px; }
.call-bottom .call-row:nth-child(2) > :last-child { justify-self: start; margin-left: 26px; }
.verify-list { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow: auto; }
.verify-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-2);
}
.verify-item b { font-size: 13.5px; }
.verify-item code {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.5;
}
.verify-item .verify-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.verify-item small { color: var(--muted); font-size: 11.5px; }
.verify-cmd {
  background: #0a0c12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  color: #9fe6b8;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.verify-item button { font-size: 12px; }
.bind-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 108, 255, .16), rgba(124, 108, 255, .06));
  border: 1px solid rgba(124, 108, 255, .35);
}
.bind-banner[hidden] { display: none !important; }
.bind-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bind-text b { font-size: 13.5px; }
.bind-text span { font-size: 11.5px; color: var(--muted); }
.bind-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-primary.small { padding: 7px 14px; font-size: 12.5px; border-radius: 8px; }
.tab.has-dot { position: relative; }
.tab.has-dot::after {
  content: "";
  position: absolute;
  top: 6px;
  right: calc(50% - 16px);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff4d4f;
  box-shadow: 0 0 0 2px var(--bg);
}
.tg-page { display: flex !important; flex-direction: column; gap: 12px; text-align: center; }
.tg-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 30px;
  letter-spacing: 6px;
  font-weight: 700;
  padding: 14px 10px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  color: #cfc8ff;
}
.tg-open { display: block; text-align: center; padding: 11px 14px; border-radius: 10px; }
.tg-status { margin: 2px 0 0; }
.tg-status.ok { color: var(--green); }
#btn-telegram[hidden] { display: none !important; }
