:root {
  --bg-black: #141618;   /* 根容器 / 全应用贯通背景色（沉浸式，杜绝断层） */
  --bg-panel: #111111;
  --bg-hover: #1a1a1a;
  --neon-green: #bdfe30;
  --text-white: #ffffff;
  --text-gray: #888888;
  --red: #ff453a;
  --border-color: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  background-color: #141618;
  height: 100dvh;
  overscroll-behavior: none;
}
body {
  background-color: #141618;
  color: var(--text-white);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ==================== 1. 伪装层：AI 文字游戏 ==================== */
#disguise-game-layer {
  position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100%); z-index: 100;
  display: flex; flex-direction: column; background: var(--bg-black);
}
.game-header {
  padding: max(16px, env(safe-area-inset-top)) 20px 14px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border-color); background: var(--bg-panel);
}
.game-title {
  font-size: 16px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--neon-green); font-family: monospace;
}
.game-logo {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover;
  background: #222; border: 1px solid var(--border-color);
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
}
.game-log-container {
  flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
  font-size: 15px; line-height: 1.6;
}
.game-bubble {
  padding: 12px 16px; border-radius: 12px; max-width: 88%; word-break: break-word;
  white-space: pre-wrap; animation: fadeIn 0.25s ease;
}
.game-bubble.assistant {
  align-self: flex-start; background: #161616; border: 1px solid var(--border-color);
  color: #dedede; border-left: 3px solid var(--neon-green);
}
.game-bubble.user { align-self: flex-end; background: #262626; color: #fff; }

.game-input-area {
  /* 底色面板锚定屏幕最底边（0 距离），与顶部 header 对称；上下内边距相同，不使用安全区 */
  padding: 8px 16px 6px;
  background: var(--bg-black); border-top: 1px solid var(--border-color);
}
.game-input-wrap { position: relative; }
#game-input {
  width: 100%; background: #1f1f1f; border: 1px solid var(--border-color);
  border-radius: 22px; padding: 12px 84px 12px 16px; color: #fff; outline: none; font-size: 15px;
}
#game-input:focus { border-color: rgba(189, 254, 48, 0.4); }
#game-send-btn {
  position: absolute; right: 5px; top: 5px; bottom: 5px;
  background: var(--neon-green); color: #000; border: none; font-weight: 700;
  padding: 0 16px; border-radius: 18px; cursor: pointer; font-size: 14px; transition: transform 0.1s;
}
#game-send-btn:active { transform: scale(0.92); }

/* ==================== 2. 通讯主面板 ==================== */
#dashboard {
  position: fixed; inset: 0; z-index: 50;
  display: none; flex-direction: column; background: var(--bg-black);
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s;
}
#dashboard.dash-enter { animation: dashIn 0.32s cubic-bezier(0.25, 1, 0.5, 1); }
@keyframes dashIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
.view-container {
  flex: 1; display: none; flex-direction: column;
  overflow-y: auto; padding-bottom: 100px; animation: fadeIn 0.3s ease;
}
.view-container.active { display: flex; }

.dash-header {
  padding: max(20px, env(safe-area-inset-top)) 20px 10px 20px; font-size: 24px; font-weight: bold;
  letter-spacing: 1px; position: sticky; top: 0; background: var(--bg-black); z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
}
.header-plus {
  width: 36px; height: 36px; border-radius: 50%; background: #181818; border: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--neon-green);
}
.header-plus:active { transform: scale(0.92); }
.header-plus svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }

.empty-hint { text-align: center; color: var(--text-gray); font-size: 13px; padding: 60px 20px; }

.list-item-wrapper { border-bottom: 1px solid var(--border-color); }
.list-item {
  display: flex; align-items: center; padding: 14px 20px;
  background: var(--bg-black); cursor: pointer;
}
.list-item:active { background: var(--bg-hover); }

.avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--bg-panel); object-fit: cover; flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}
.group-avatar {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; overflow: hidden;
  background: #1c1c1c; border: 1px solid rgba(255,255,255,0.1);
  display: grid; gap: 1px;
}
.group-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; background: #222; }
.group-avatar.g1 { grid-template-columns: 1fr; }
.group-avatar.g2, .group-avatar.g4 { grid-template-columns: 1fr 1fr; }
.group-avatar.g3 { grid-template-columns: 1fr 1fr; }
.group-avatar.g3 img:first-child { grid-column: 1 / 3; }
.group-avatar.g9 { grid-template-columns: 1fr 1fr 1fr; }

.item-content { flex: 1; margin-left: 14px; min-width: 0; }
.item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; gap: 8px; }
.item-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-time { font-size: 12px; color: var(--text-gray); flex-shrink: 0; }
.item-bottom { display: flex; align-items: center; gap: 10px; }
.item-preview { flex: 1; min-width: 0; font-size: 13px; color: var(--text-gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 17px; }
.badge {
  flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.profile-header {
  display: flex; flex-direction: column; align-items: center;
  padding: max(30px, env(safe-area-inset-top)) 20px 26px; border-bottom: 1px solid var(--border-color);
}
.profile-header .avatar { width: 80px; height: 80px; margin-bottom: 14px; cursor: pointer; transition: transform 0.2s; }
.profile-header .avatar:active { transform: scale(0.95); }
.profile-name { font-size: 20px; font-weight: bold; }
.profile-name.unset { color: var(--text-gray); font-weight: 500; font-size: 16px; }

.settings-list { padding: 6px 20px; }
.setting-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 0; border-bottom: 1px solid var(--border-color);
  font-size: 15px; cursor: pointer; transition: opacity 0.2s;
}
.setting-item:active { opacity: 0.7; }
.setting-item svg { width: 18px; height: 18px; }
.setting-item .chev { fill: none; stroke: var(--text-gray); stroke-width: 2; stroke-linecap: round; }

.switch { position: relative; width: 46px; height: 28px; border-radius: 14px; background: #333; transition: background 0.2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch.on { background: var(--neon-green); }
.switch.on::after { transform: translateX(18px); background: #000; }

/* 底部悬浮液态导航：4 个入口 */
.floating-nav-wrapper {
  position: fixed; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 90%; max-width: 400px; z-index: 100;
}
.floating-nav {
  background: var(--bg-panel); border: 1px solid var(--border-color);
  border-radius: 40px; padding: 6px; display: flex; position: relative;
}
.nav-indicator {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 4);
  background: #222; border-radius: 30px; z-index: 1;
  transition: transform 0.35s cubic-bezier(0.5, -0.4, 0.2, 1.4); pointer-events: none;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 0; position: relative; z-index: 2;
  color: var(--text-gray); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: color 0.3s ease;
}
.nav-item svg { width: 22px; height: 22px; margin-bottom: 4px; fill: currentColor; }
.nav-item.active { color: var(--neon-green); }
.nav-dot {
  position: absolute; top: 4px; left: calc(50% + 8px); min-width: 8px; height: 8px; border-radius: 4px;
  background: var(--red); display: none;
}
.nav-dot.show { display: block; }

/* ==================== 3. 独立聊天窗口 ==================== */
#chat-room {
  position: fixed; top: var(--vvt, 0px); left: 0; width: 100%; height: var(--vvh, 100%);
  background: var(--bg-black); z-index: 200; display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  touch-action: pan-y; will-change: transform;
}
#chat-room.open { transform: translateX(0); }

.chat-header {
  position: relative; z-index: 30;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: max(15px, env(safe-area-inset-top)) 15px 15px 15px;
  background: var(--bg-black); border-bottom: 1px solid var(--border-color);
}
.chat-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-header-right { display: flex; justify-content: flex-end; position: relative; }
.chat-header-center { font-size: 16px; font-weight: bold; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
#chat-room.mode-c2c .chat-header-center { display: none; }
#chat-room.mode-c2c .chat-header { grid-template-columns: 1fr auto; }
#chat-room.mode-group .c2c-only { display: none; }

.btn-header-circle {
  width: 40px; height: 40px; border-radius: 50%; background: #181818; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.05); transition: background 0.2s;
}
.btn-header-circle:active { background: #252525; transform: scale(0.95); }
.btn-header-circle svg { width: 20px; height: 20px; fill: none; stroke: var(--text-white); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-header-circle.plus svg { transition: transform 0.28s cubic-bezier(0.25, 1, 0.5, 1); }
.btn-header-circle.plus.open { background: #252525; }
.btn-header-circle.plus.open svg { transform: rotate(45deg); }

/* + 号下拉抽屉：贴着 + 号正下方向下展开，纯文字 */
.tool-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 150px; padding: 6px;
  background: #1c1e20; border: 1px solid rgba(255,255,255,0.10); border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
  transform-origin: top right; transform: scale(0.85, 0.4); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.18s ease, visibility 0s linear 0.22s;
}
.tool-menu.open { transform: none; opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.tool-item {
  padding: 13px 16px; border-radius: 11px; font-size: 15px; color: var(--text-white);
  cursor: pointer; white-space: nowrap; text-align: center; letter-spacing: 1px; user-select: none; -webkit-user-select: none;
}
.tool-item:active { background: rgba(255,255,255,0.08); }
.tool-item.danger { color: #ff7a70; }
.tool-sep { height: 1px; margin: 4px 8px; background: rgba(255,255,255,0.08); }

.chat-header-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-panel); }
.chat-header-name {
  font-size: 16px; font-weight: bold; cursor: pointer; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px dashed rgba(255,255,255,0.18); padding-bottom: 1px;
}

.chat-messages {
  flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
}
.chat-messages::before { content: ''; flex: 1 1 auto; }

.msg-row { display: flex; gap: 8px; align-items: flex-start; }
.msg-row.self { flex-direction: row-reverse; }
.msg-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--bg-panel); }
#chat-room.mode-c2c .msg-avatar, #chat-room.mode-c2c .msg-name { display: none; }
.msg-col { display: flex; flex-direction: column; max-width: 76%; min-width: 0; }
.msg-row.self .msg-col { align-items: flex-end; }
.msg-name { font-size: 12px; color: var(--text-gray); margin: 0 4px 3px; }

.msg-bubble {
  background: var(--bg-panel); padding: 8px 12px; border-radius: 18px;
  font-size: 15px; display: inline-block; position: relative; max-width: 100%;
}
.msg-bubble.self { background: var(--neon-green); color: #000; border-bottom-right-radius: 4px; }
.msg-bubble.other { border-bottom-left-radius: 4px; }
.msg-text { line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; display: inline; }
.msg-meta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.65em; margin-left: 8px; vertical-align: bottom; position: relative; top: 2px;
}
.msg-bubble.self .msg-meta { color: rgba(0, 0, 0, 0.55); }
.msg-bubble.other .msg-meta { color: rgba(255, 255, 255, 0.45); }
.msg-bubble.has-img { padding: 4px; }
.msg-bubble.has-img .msg-meta { display: flex; justify-content: flex-end; margin: 3px 6px 2px 0; top: 0; }
.msg-img { max-width: 200px; max-height: 260px; border-radius: 14px; display: block; cursor: zoom-in; }
.tick { width: 1.5em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tick.read { stroke: #0b57d0; }
.tick.fail { stroke: var(--red); }
.msg-bubble.self.sending { opacity: 0.7; }

/* ===== 互动小游戏：无气泡背景、独立展示、伪 3D ===== */
.msg-bubble.has-game, .msg-bubble.has-game.self, .msg-bubble.has-game.other {
  background: transparent; padding: 0; border-radius: 0; color: #fff;
}
.msg-bubble.has-game .msg-meta { display: flex; justify-content: center; margin: 2px 0 0; top: 0; }
.msg-bubble.has-game.self .msg-meta, .msg-bubble.has-game.other .msg-meta { color: rgba(255,255,255,0.4); }
.game-box { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 120px; transition: opacity 0.2s; }
.game-box.pending { opacity: 0.45; }
.game-box.failed { opacity: 0.4; filter: grayscale(1); }
.game-cap { font-size: 14px; font-weight: 700; min-height: 20px; text-align: center; color: #fff; max-width: 220px; word-break: break-word; }

/* 骰子：真 3D 立方体 */
.d3-wrap { position: relative; width: 120px; height: 112px; perspective: 560px; display: flex; align-items: center; justify-content: center; }
.d3-tilt { transform-style: preserve-3d; transform: rotateX(-24deg) rotateY(-30deg); }
.d3-cube { position: relative; width: 64px; height: 64px; transform-style: preserve-3d; }
.d3-face {
  position: absolute; inset: 0; border-radius: 12px; padding: 9px;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center;
  background: linear-gradient(145deg, #ffffff, #cfd4da); box-shadow: inset 0 0 12px rgba(0,0,0,0.22);
}
.d3-face i { width: 11px; height: 11px; border-radius: 50%; }
.d3-face i.p { background: radial-gradient(circle at 35% 30%, #555, #0d0d0d); box-shadow: inset 0 1px 2px rgba(0,0,0,0.6); }
.d3-face.f1 i.p { background: radial-gradient(circle at 35% 30%, #ff7a70, #b3150b); width: 15px; height: 15px; }
.d3-face.f1 { transform: translateZ(32px); }
.d3-face.f6 { transform: rotateY(180deg) translateZ(32px); }
.d3-face.f3 { transform: rotateY(90deg) translateZ(32px); }
.d3-face.f4 { transform: rotateY(-90deg) translateZ(32px); }
.d3-face.f2 { transform: rotateX(90deg) translateZ(32px); }
.d3-face.f5 { transform: rotateX(-90deg) translateZ(32px); }
.d3-shadow, .p3-shadow {
  position: absolute; left: 50%; bottom: 4px; width: 70px; height: 14px; margin-left: -35px; border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55), rgba(0,0,0,0) 70%);
}
.d3-wrap.go .d3-tilt { animation: d3Hop 3s linear 1; }
.d3-wrap.go .d3-shadow { animation: d3Sh 3s linear 1; }
@keyframes d3Hop { 0% { transform: rotateX(-24deg) rotateY(-30deg) translateY(0); } 12% { transform: rotateX(-24deg) rotateY(-30deg) translateY(-38px); } 28% { transform: rotateX(-24deg) rotateY(-30deg) translateY(0); } 40% { transform: rotateX(-24deg) rotateY(-30deg) translateY(-18px); } 52% { transform: rotateX(-24deg) rotateY(-30deg) translateY(0); } 62% { transform: rotateX(-24deg) rotateY(-30deg) translateY(-7px); } 70%, 100% { transform: rotateX(-24deg) rotateY(-30deg) translateY(0); } }
@keyframes d3Sh { 0%, 28%, 52%, 70%, 100% { transform: scale(1); opacity: 1; } 12% { transform: scale(0.6); opacity: 0.5; } 40% { transform: scale(0.8); opacity: 0.75; } 62% { transform: scale(0.92); opacity: 0.9; } }

/* 石剪刀布：三棱柱滚筒 */
.p3-wrap { position: relative; width: 120px; height: 112px; perspective: 560px; display: flex; align-items: center; justify-content: center; }
.p3-tilt { transform-style: preserve-3d; transform: rotateX(-14deg); }
.p3-prism { position: relative; width: 90px; height: 90px; transform-style: preserve-3d; }
.p3-face {
  position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 46px;
  box-shadow: inset 0 0 14px rgba(0,0,0,0.25), inset 0 2px 0 rgba(255,255,255,0.5);
}
.p3-wrap.go .p3-tilt { animation: p3Bob 3s ease-in-out 1; }
@keyframes p3Bob { 0%, 100% { transform: rotateX(-14deg) translateY(0); } 30% { transform: rotateX(-14deg) translateY(-14px); } 60% { transform: rotateX(-14deg) translateY(-6px); } }

/* 幸运转盘：倾斜圆盘 + 厚度 + 指针 */
.w3-wrap { position: relative; width: 170px; height: 112px; perspective: 700px; }
.w3-pointer {
  position: absolute; left: 50%; top: -6px; margin-left: -9px; z-index: 5;
  border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 18px solid #fff;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.6));
}
.w3-stage {
  position: absolute; left: 50%; top: 50%; width: 150px; height: 150px; margin: -75px 0 0 -75px;
  transform: rotateX(58deg); transform-style: preserve-3d;
}
.w3-edge { position: absolute; inset: 0; border-radius: 50%; background: #23262a; }
.w3-disc { position: absolute; inset: 0; border-radius: 50%; }
.w3-disc svg { width: 100%; height: 100%; display: block; }
.wheel-chips { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; max-width: 210px; margin-top: 2px; }
.wheel-chip { font-size: 11px; padding: 2px 7px; border-radius: 9px; color: #111; opacity: 0.5; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: opacity 0.2s, transform 0.2s; }
.wheel-chip.hit { opacity: 1; transform: scale(1.12); font-weight: 700; }

/* 输入区：+ 按钮嵌入输入框左侧弧形，上下贴满 */
.chat-input-area { margin: 8px 15px 4px 15px; }
html.kb-open .chat-input-area { margin-bottom: 0; }
.input-field-container {
  position: relative; background: #181818; min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 24px;
  display: flex; align-items: flex-end;
}
.btn-plus {
  width: 46px; height: 46px; border-radius: 50%; background: #262626; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-white);
  margin: -1px 0 -1px -1px;
}
.btn-plus:active { background: #333; }
.btn-plus svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; }
#msg-input {
  flex: 1; min-width: 0; background: transparent; border: none; padding: 13px 132px 12px 10px;
  color: var(--text-white); resize: none; outline: none; font-size: 15px; line-height: 20px;
  max-height: 130px; font-family: inherit;
}
#send-btn {
  background: var(--neon-green);
  color: #000; border: none; padding: 0 14px; height: 36px; border-radius: 18px;
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform; touch-action: manipulation;
}
#send-btn:active { transform: scale(0.82); transition-duration: 0.1s; }
#send-btn.boing { animation: sendBoing 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes sendBoing {
  0%   { transform: scale(1, 1); }
  28%  { transform: scale(0.8, 0.86); }
  62%  { transform: scale(1.1, 1.06); }
  100% { transform: scale(1, 1); }
}

/* ==================== 4. 模态框 ==================== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 10000;
  display: none; align-items: center; justify-content: center; backdrop-filter: blur(6px);
}
.overlay.show { display: flex; }
.custom-modal {
  background: var(--bg-panel); width: 88%; max-width: 340px; padding: 24px; max-height: 90dvh; overflow-y: auto;
  border-radius: 20px; border: 1px solid var(--border-color);
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
.custom-modal.wide { max-width: 560px; width: 94%; }
.custom-modal h3 { margin-bottom: 16px; text-align: center; font-size: 18px; }
.modal-msg { font-size: 14px; color: #ccc; text-align: center; line-height: 1.6; padding: 4px 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-btn { flex: 1; padding: 12px; font-size: 14px; border-radius: 12px; border: none; font-weight: bold; cursor: pointer; }
.modal-btn.cancel { background: rgba(255,255,255,0.1); color: var(--text-white); }
.modal-btn.confirm { background: var(--neon-green); color: #000; }
.modal-btn.danger { background: rgba(255,69,58,0.15); color: var(--red); }
.modal-btn:active { transform: scale(0.97); }
.modal-btn.block { width: 100%; flex: none; margin-top: 10px; }

.input-style {
  width: 100%; padding: 12px; background: #222; border: 1px solid rgba(255,255,255,0.1);
  color: #fff; border-radius: 12px; outline: none; font-size: 14px; margin-bottom: 10px; font-family: inherit;
}
.input-style:focus { border-color: rgba(189,254,48,0.4); }
textarea.input-style.big { min-height: 42dvh; resize: vertical; line-height: 1.5; }
.field-label { font-size: 12px; color: var(--text-gray); margin: 2px 2px 6px; }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 6px 0 4px; }
.qr-box canvas { width: 230px; height: 230px; border-radius: 12px; background: #fff; image-rendering: pixelated; }
.qr-fail { font-size: 12px; color: var(--text-gray); text-align: center; padding: 14px 0; }
.row-btns { display: flex; gap: 10px; width: 100%; }
.row-btns .modal-btn { margin-top: 0; padding: 10px; }

.friend-name { font-size: 18px; font-weight: 700; cursor: pointer; border-bottom: 1px dashed rgba(255,255,255,0.25); padding-bottom: 1px; }

.pick-list { max-height: 34dvh; overflow-y: auto; margin: 4px 0; }
.pick-item { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border-color); cursor: pointer; }
.pick-item .avatar { width: 38px; height: 38px; }
.pick-item .pick-name { flex: 1; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-box { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #444; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pick-item.on .pick-box { background: var(--neon-green); border-color: var(--neon-green); }
.pick-item.on .pick-box::after { content: ''; width: 6px; height: 11px; border: solid #000; border-width: 0 2.4px 2.4px 0; transform: rotate(45deg) translate(-1px, -1px); }

#avatar-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 11000;
  display: none; align-items: flex-end; justify-content: center; backdrop-filter: blur(5px);
}
#avatar-modal.show { display: flex; }
.avatar-sheet {
  background: #181818; width: 100%; max-height: 80dvh; overflow-y: auto; border-radius: 24px 24px 0 0;
  padding: 25px 20px max(25px, env(safe-area-inset-bottom)); animation: slideUp 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.avatar-sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.avatar-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; justify-items: center; }
.preset-avatar-item {
  width: 62px; height: 62px; border-radius: 50%; object-fit: cover;
  cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s, transform 0.1s; background: #222;
}
.preset-avatar-item:active { transform: scale(0.92); border-color: var(--neon-green); }

#image-viewer {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.95);
  z-index: 12000; justify-content: center; align-items: center; cursor: zoom-out;
}
#viewer-img { max-width: 92%; max-height: 92%; object-fit: contain; border-radius: 12px; }

#toast {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.92);
  background: #222; color: #fff; padding: 14px 28px; border-radius: 20px; font-size: 15px; font-weight: 600;
  z-index: 20000; opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s;
  border: 1px solid var(--border-color); max-width: 86vw; text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* 微信内打开指引 */
#wechat-guide {
  position: fixed; inset: 0; z-index: 30000; background: rgba(0,0,0,0.94); display: none;
  flex-direction: column; align-items: flex-end; padding: max(16px, env(safe-area-inset-top)) 22px 0 22px;
}
#wechat-guide.show { display: flex; }
#wechat-guide svg { width: 84px; height: 110px; stroke: var(--neon-green); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; margin-right: 6px; }
#wechat-guide .guide-text { margin-top: 10px; align-self: stretch; text-align: right; font-size: 18px; line-height: 1.8; color: #fff; }
#wechat-guide .guide-text b { color: var(--neon-green); }
#wechat-guide .guide-sub { margin-top: 10px; align-self: stretch; text-align: right; font-size: 13px; color: var(--text-gray); }


/* ==================== 5. 语音 / 视频消息 ==================== */
.input-actions { position: absolute; right: 5px; bottom: 5px; display: flex; align-items: center; gap: 6px; }
.btn-mic {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: #262626; color: var(--text-white);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.btn-mic:active { background: #333; transform: scale(0.92); }
.btn-mic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.rec-bar {
  position: absolute; inset: 0; z-index: 3; display: none; align-items: center; gap: 12px;
  padding: 0 5px; background: #181818; border-radius: 24px;
}
.input-field-container.recording .rec-bar { display: flex; }
.rec-cancel {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: #262626; color: var(--text-white);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.rec-cancel svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex-shrink: 0; animation: recPulse 1s ease-in-out infinite; }
@keyframes recPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
.rec-time { flex: 1; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--text-white); }
.rec-send {
  height: 36px; padding: 0 16px; border-radius: 18px; border: none; background: var(--neon-green);
  color: #000; font-weight: 700; font-size: 14px; cursor: pointer;
}
.rec-send:active { transform: scale(0.92); }

.msg-bubble.has-voice { padding: 8px 12px; }
.voice-msg { display: inline-flex; align-items: center; gap: 10px; min-width: 96px; cursor: pointer; vertical-align: middle; user-select: none; -webkit-user-select: none; }
.voice-play {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.msg-bubble.self .voice-play { background: rgba(0, 0, 0, 0.14); }
.msg-bubble.other .voice-play { background: rgba(255, 255, 255, 0.12); }
.voice-play svg { width: 14px; height: 14px; fill: currentColor; }
.voice-play .ic-pause { display: none; }
.voice-msg.playing .ic-play { display: none; }
.voice-msg.playing .ic-pause { display: block; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 22px; }
.voice-wave i { display: block; width: 3px; border-radius: 2px; background: currentColor; opacity: 0.5; }
.voice-msg.playing .voice-wave i { opacity: 1; animation: voiceBar 0.9s ease-in-out infinite; }
.voice-msg.playing .voice-wave i:nth-child(3n) { animation-delay: 0.15s; }
.voice-msg.playing .voice-wave i:nth-child(3n+1) { animation-delay: 0.3s; }
@keyframes voiceBar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.45); } }
.voice-sec { font-size: 13px; font-variant-numeric: tabular-nums; }

.msg-video { max-width: 220px; max-height: 300px; border-radius: 14px; display: block; background: #000; }

/* ==================== 6. 左滑删除（群组列表） ==================== */
.list-item-wrapper { position: relative; overflow: hidden; }
.list-item { position: relative; z-index: 1; touch-action: pan-y; will-change: transform; transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1); }
.list-item.dragging { transition: none; }
.swipe-del {
  position: absolute; right: 0; top: 0; bottom: 0; width: 84px; z-index: 0;
  border: none; background: var(--red); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ==================== 7. 好友资料卡 ==================== */
.custom-modal.profile {
  width: 92%; max-width: 430px; padding: 22px 20px 20px; border-radius: 28px; background: #0c0d0f;
}
.fp-head {
  position: relative; display: flex; align-items: center; gap: 18px;
  padding: 2px 40px 18px 4px; border-bottom: 1px solid var(--border-color);
}
.fp-head .avatar { width: 88px; height: 88px; }
.fp-head .friend-name {
  flex: 0 1 auto; min-width: 0; font-size: 26px; font-weight: 800; letter-spacing: 0.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom-color: rgba(255,255,255,0.14);
}
.fp-close {
  position: absolute; top: -4px; right: -6px; width: 38px; height: 38px; border: none; background: none;
  color: var(--text-white); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.fp-close svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.qr-tip { font-size: 11px; color: var(--text-gray); text-align: center; line-height: 1.7; }

.fp-pwd {
  display: flex; align-items: center; gap: 8px;
  background: #101215; border: 1px solid rgba(255, 255, 255, 0.07); border-radius: 20px;
  padding: 6px 6px 6px 18px; margin-top: 22px; height: 64px;
}
.fp-pwd .input-style {
  flex: 1; min-width: 0; margin: 0; height: 100%; background: transparent; border: none;
  font-size: 17px; font-weight: 600; color: #fff; border-radius: 0;
}
.fp-pwd .input-style::placeholder { color: #ececec; font-weight: 700; }
.fp-chev {
  width: 52px; height: 52px; flex-shrink: 0; border: none; border-radius: 16px; background: transparent;
  color: #d6d6d6; display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.fp-chev:active { background: #1b1f24; color: var(--neon-green); transform: scale(0.94); }
.fp-chev svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.fp-primary {
  display: block; width: 100%; height: 58px; margin-top: 24px; border: none; border-radius: 999px;
  background: var(--neon-green); color: #000; font-size: 18px; font-weight: 800; cursor: pointer;
  letter-spacing: 1px;
}
.fp-danger {
  display: block; width: 100%; height: 54px; margin-top: 16px; border-radius: 999px; cursor: pointer;
  background: rgba(255, 69, 58, 0.10); border: 1px solid rgba(255, 69, 58, 0.55); color: var(--red);
  font-size: 17px; font-weight: 700; letter-spacing: 1px;
}
.fp-primary:active, .fp-danger:active { transform: scale(0.97); }

/* ==================== 8. 全屏沉浸式认证首屏 ==================== */
#auth-layer {
  position: fixed; inset: 0; z-index: 8000; background: #141618;
  display: none; opacity: 1; transition: opacity 0.3s ease;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
#auth-layer.show { display: block; }
#auth-layer.leaving { opacity: 0; }
.auth-view {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 28px max(28px, env(safe-area-inset-bottom));
  opacity: 0; transform: translateY(16px) scale(0.985); pointer-events: none;
  transition: opacity 0.26s ease, transform 0.26s cubic-bezier(0.25, 1, 0.5, 1);
}
.auth-view.active { opacity: 1; transform: none; pointer-events: auto; }
.auth-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; }
.auth-subtitle { text-align: center; color: #84888c; font-size: 13px; letter-spacing: 2px; margin-bottom: 4px; }
.auth-input {
  width: 100%; height: 54px; padding: 0 18px;
  background: #000; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 14px;
  color: #fff; font-size: 16px; outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input:focus { border-color: rgba(189, 254, 48, 0.45); box-shadow: 0 0 0 3px rgba(189, 254, 48, 0.10); }
.auth-primary {
  height: 54px; margin-top: 6px; border: none; border-radius: 16px;
  background: var(--neon-green); color: #000; font-size: 17px; font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 26px rgba(189, 254, 48, 0.22);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.auth-primary:active { transform: scale(0.96); }
.auth-switch {
  margin-top: 26px; color: #6b6f73; font-size: 13px; letter-spacing: 4px; text-indent: 4px;
  cursor: pointer; user-select: none; -webkit-user-select: none; transition: color 0.2s;
}
.auth-switch:active { color: #a9adb1; }
.totp-boxes { display: flex; gap: 10px; justify-content: center; }
.totp-cell {
  width: 46px; height: 56px; text-align: center; font-size: 24px; font-weight: 700;
  background: #000; border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 12px;
  color: #fff; outline: none; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.totp-cell:focus { border-color: rgba(189, 254, 48, 0.55); box-shadow: 0 0 0 3px rgba(189, 254, 48, 0.12); }
