/* ===================================================================
   暗号 · CIPHER  —  多主题设计系统
   4 套色系分明的主题：午夜 / 昼白 / 翡翠 / 绯霞
   颜色全部走 CSS 变量，[data-theme] 切换；字体 Inter + cv01/ss03
=================================================================== */

/* ---------- 午夜 Midnight：近黑 + 靛紫（冷）---------- */
:root,
[data-theme="midnight"] {
  --bg: #0a0b12;
  --bg-2: #12131f;
  --ink: #f4f5fb;
  --ink-dim: #8b90a6;
  --ink-faint: #5b607a;

  --accent: #7c6cff;
  --accent-2: #a78bfa;
  --accent-ink: #ffffff;
  --status: #4cc38a;

  --border: rgba(255, 255, 255, 0.09);
  --border-subtle: rgba(255, 255, 255, 0.055);
  --field-bg: rgba(255, 255, 255, 0.045);
  --field-bg-hover: rgba(255, 255, 255, 0.075);
  --chip-bg: rgba(255, 255, 255, 0.045);
  --icon-bg: rgba(255, 255, 255, 0.055);
  --icon-bg-hover: rgba(255, 255, 255, 0.1);

  --card-bg: rgba(255, 255, 255, 0.032);
  --card-blur: 20px;
  --card-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.05) inset, 0 24px 70px rgba(0, 0, 0, 0.5);

  --grad: linear-gradient(135deg, #7c6cff, #a78bfa);
  --bubble-me: linear-gradient(135deg, #7161ff, #9b7bf5);
  --bubble-me-ink: #ffffff;
  --bubble-other-bg: rgba(255, 255, 255, 0.06);
  --bubble-other-ink: var(--ink);

  --grid-color: rgba(255, 255, 255, 0.025);
  --blob-opacity: 0.26;
  --blob-blend: screen;
  --blob-1: #5b4fff;
  --blob-2: #a855f7;
  --blob-3: #4f6bff;
  --btn-shadow: 0 14px 34px rgba(124, 108, 255, 0.4);
}

/* ---------- 昼白 Daylight：纯白 + 蓝（亮）---------- */
[data-theme="daylight"] {
  --bg: #ffffff;
  --bg-2: #f7f8fa;
  --ink: #16181d;
  --ink-dim: #5b6270;
  --ink-faint: #9aa0ad;

  --accent: #2f6bff;
  --accent-2: #6366f1;
  --accent-ink: #ffffff;
  --status: #0a8f57;

  --border: rgba(16, 24, 40, 0.1);
  --border-subtle: rgba(16, 24, 40, 0.07);
  --field-bg: #ffffff;
  --field-bg-hover: #fafbfc;
  --chip-bg: #f4f6f9;
  --icon-bg: #f2f4f7;
  --icon-bg-hover: #e8ebf0;

  --card-bg: #ffffff;
  --card-blur: 0px;
  --card-shadow: rgba(16, 24, 40, 0.08) 0 0 0 1px, rgba(16, 24, 40, 0.05) 0 2px 4px, rgba(16, 24, 40, 0.07) 0 14px 32px -14px;

  --grad: linear-gradient(135deg, #2f6bff, #6366f1);
  --bubble-me: linear-gradient(135deg, #2f6bff, #6366f1);
  --bubble-me-ink: #ffffff;
  --bubble-other-bg: #f0f2f6;
  --bubble-other-ink: #16181d;

  --grid-color: rgba(16, 24, 40, 0.04);
  --blob-opacity: 0.14;
  --blob-blend: normal;
  --blob-1: #a5c4fc;
  --blob-2: #c4b5fd;
  --blob-3: #bae6fd;
  --btn-shadow: 0 12px 28px rgba(47, 107, 255, 0.28);
}

/* ---------- 翡翠 Emerald：墨绿黑 + 翡翠绿 ---------- */
[data-theme="emerald"] {
  --bg: #06120e;
  --bg-2: #0b1d17;
  --ink: #e8f6ef;
  --ink-dim: #7ba694;
  --ink-faint: #4f7264;

  --accent: #10d99a;
  --accent-2: #2dd4bf;
  --accent-ink: #04160f;
  --status: #34d399;

  --border: rgba(120, 255, 214, 0.12);
  --border-subtle: rgba(120, 255, 214, 0.07);
  --field-bg: rgba(120, 255, 214, 0.05);
  --field-bg-hover: rgba(120, 255, 214, 0.09);
  --chip-bg: rgba(120, 255, 214, 0.05);
  --icon-bg: rgba(120, 255, 214, 0.06);
  --icon-bg-hover: rgba(120, 255, 214, 0.12);

  --card-bg: rgba(16, 40, 32, 0.5);
  --card-blur: 20px;
  --card-shadow: 0 1px 0 0 rgba(120, 255, 214, 0.08) inset, 0 24px 70px rgba(0, 20, 12, 0.6);

  --grad: linear-gradient(135deg, #10d99a, #2dd4bf);
  --bubble-me: linear-gradient(135deg, #0fc98f, #22c9b4);
  --bubble-me-ink: #04160f;
  --bubble-other-bg: rgba(120, 255, 214, 0.08);
  --bubble-other-ink: var(--ink);

  --grid-color: rgba(120, 255, 214, 0.03);
  --blob-opacity: 0.3;
  --blob-blend: screen;
  --blob-1: #10b981;
  --blob-2: #14b8a6;
  --blob-3: #06b6d4;
  --btn-shadow: 0 14px 34px rgba(16, 217, 154, 0.35);
}

/* ---------- 绯霞 Sunset：暖紫黑 + 珊瑚粉/琥珀 ---------- */
[data-theme="sunset"] {
  --bg: #140a11;
  --bg-2: #20101a;
  --ink: #fbeaf0;
  --ink-dim: #c090a3;
  --ink-faint: #8c6070;

  --accent: #ff5d8f;
  --accent-2: #ff9d5c;
  --accent-ink: #ffffff;
  --status: #ffb454;

  --border: rgba(255, 180, 210, 0.13);
  --border-subtle: rgba(255, 180, 210, 0.08);
  --field-bg: rgba(255, 180, 210, 0.055);
  --field-bg-hover: rgba(255, 180, 210, 0.09);
  --chip-bg: rgba(255, 180, 210, 0.055);
  --icon-bg: rgba(255, 180, 210, 0.06);
  --icon-bg-hover: rgba(255, 180, 210, 0.12);

  --card-bg: rgba(46, 22, 36, 0.52);
  --card-blur: 20px;
  --card-shadow: 0 1px 0 0 rgba(255, 180, 210, 0.09) inset, 0 24px 70px rgba(20, 0, 10, 0.6);

  --grad: linear-gradient(135deg, #ff5d8f, #ff9d5c);
  --bubble-me: linear-gradient(135deg, #ff5d8f, #ff8a6b);
  --bubble-me-ink: #ffffff;
  --bubble-other-bg: rgba(255, 180, 210, 0.09);
  --bubble-other-ink: var(--ink);

  --grid-color: rgba(255, 180, 210, 0.03);
  --blob-opacity: 0.32;
  --blob-blend: screen;
  --blob-1: #ff5d8f;
  --blob-2: #ff9d5c;
  --blob-3: #c026d3;
  --btn-shadow: 0 14px 34px rgba(255, 93, 143, 0.36);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root { --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-feature-settings: "cv01", "ss03";
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  transition: background 0.4s ease, color 0.4s ease;
}
body { position: relative; overflow: hidden; }

/* ---------- 动态背景 ---------- */
.aurora { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg); transition: background 0.4s ease; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(70px);
  opacity: var(--blob-opacity); mix-blend-mode: var(--blob-blend);
  animation: drift 26s ease-in-out infinite; transition: opacity 0.4s ease;
}
.blob.b1 { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: radial-gradient(circle, var(--blob-1), transparent 65%); }
.blob.b2 { width: 40vmax; height: 40vmax; right: -12vmax; top: 8vmax; background: radial-gradient(circle, var(--blob-2), transparent 65%); animation-delay: -9s; }
.blob.b3 { width: 38vmax; height: 38vmax; left: 20vmax; bottom: -16vmax; background: radial-gradient(circle, var(--blob-3), transparent 65%); animation-delay: -16s; }
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(7vmax, 5vmax) scale(1.1); }
  66% { transform: translate(-6vmax, 3vmax) scale(0.95); }
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(130% 90% at 50% 0%, #000 30%, transparent 82%);
  -webkit-mask-image: radial-gradient(130% 90% at 50% 0%, #000 30%, transparent 82%);
}

/* ---------- 顶部控制 ---------- */
.top-controls { position: fixed; top: calc(14px + var(--safe-t)); right: 16px; z-index: 60; display: flex; gap: 8px; }
.chip-btn {
  background: var(--card-bg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); color: var(--ink-dim); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.chip-btn:hover { color: var(--ink); background: var(--icon-bg-hover); }
.chip-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grad); }
.lang-toggle #langLabel { color: var(--accent); }
.lang-toggle.en #langLabel { color: var(--ink-dim); }
.lang-toggle .lang-slash { opacity: 0.4; }
.lang-toggle.en .lang-en { color: var(--accent); }

/* ---------- 屏幕 ---------- */
.screen { position: relative; z-index: 1; display: none; height: 100dvh; }
.screen.active { display: flex; }
.glass {
  background: var(--card-bg);
  backdrop-filter: blur(var(--card-blur)) saturate(140%);
  -webkit-backdrop-filter: blur(var(--card-blur)) saturate(140%);
  border: 1px solid var(--border);
}

/* ---------- 进入页 ---------- */
#lobby { flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.lobby-inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

.brand { text-align: center; margin-bottom: 20px; }
.brand-mark { width: 76px; height: 76px; margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; border-radius: 22px; background: var(--card-bg); border: 1px solid var(--border); box-shadow: var(--card-shadow); animation: floaty 5.5s ease-in-out infinite; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.brand-name { margin: 0; font-size: 40px; font-weight: 700; letter-spacing: -1.2px; color: var(--ink); }
.brand-tagline { margin: 10px 0 0; color: var(--ink-dim); font-size: 15px; letter-spacing: -0.16px; line-height: 1.5; }

.stat-badge { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: center; background: var(--chip-bg); border: 1px solid var(--border-subtle); color: var(--ink-dim); padding: 8px 15px; border-radius: 999px; font-size: 13px; margin-bottom: 24px; }
.stat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status); box-shadow: 0 0 10px var(--status); animation: blink 2s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.stat-num { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sep { opacity: 0.3; margin: 0 3px; }

.glass-card { width: 100%; padding: 26px 24px; border-radius: 24px; background: var(--card-bg); backdrop-filter: blur(var(--card-blur)) saturate(140%); -webkit-backdrop-filter: blur(var(--card-blur)) saturate(140%); border: 1px solid var(--border); box-shadow: var(--card-shadow); }

.profile-row { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.avatar-btn { position: relative; width: 60px; height: 60px; border-radius: 50%; border: none; padding: 0; cursor: pointer; flex-shrink: 0; background: none; }
.avatar-btn img { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; display: block; background: var(--bg-2); border: 1px solid var(--border); }
.avatar-edit { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.nick-wrap { flex: 1; position: relative; display: flex; }
.roll-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: var(--icon-bg); border: none; border-radius: 9px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; color: var(--ink-dim); transition: transform 0.3s, background 0.2s, color 0.2s; }
.roll-btn:hover { background: var(--icon-bg-hover); color: var(--ink); }
.roll-btn:active { transform: translateY(-50%) rotate(180deg); }

.field { width: 100%; background: var(--field-bg); border: 1px solid var(--border); color: var(--ink); border-radius: 13px; padding: 14px 16px; font-size: 15px; outline: none; transition: border-color 0.18s, box-shadow 0.18s, background 0.18s; font-family: inherit; }
.nick-input { padding-right: 48px; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); background: var(--field-bg-hover); }
.field::placeholder { color: var(--ink-faint); }

.field-label { display: block; font-size: 12px; color: var(--ink-dim); margin: 0 0 9px 3px; letter-spacing: 0.4px; text-transform: uppercase; }
.code-wrap { margin-bottom: 20px; }

.primary-btn { position: relative; width: 100%; border: none; border-radius: 14px; padding: 16px; font-size: 16px; font-weight: 600; color: var(--accent-ink); background: var(--grad); cursor: pointer; overflow: hidden; box-shadow: var(--btn-shadow); transition: transform 0.12s, filter 0.2s, opacity 0.2s; }
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: scale(0.985); }
.primary-btn:disabled { opacity: 0.55; cursor: default; }
.btn-label { position: relative; z-index: 1; }
.btn-glow { position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent); transform: skewX(-20deg); animation: sheen 3.6s ease-in-out infinite; }
@keyframes sheen { 0%, 62% { left: -60%; } 100% { left: 135%; } }

.hint { margin: 16px 2px 0; font-size: 12.5px; color: var(--ink-faint); line-height: 1.65; }

.feat-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.feat-chip { font-size: 12px; color: var(--ink-dim); background: var(--chip-bg); border: 1px solid var(--border-subtle); padding: 6px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.feat-chip em { font-style: normal; }

/* ---------- 聊天页 ---------- */
#chat { flex-direction: column; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 12px 14px; padding-top: calc(12px + var(--safe-t)); border-bottom: 1px solid var(--border-subtle); z-index: 6; position: relative; }
.room-meta { flex: 1; min-width: 0; }
.room-title { font-weight: 600; font-size: 16px; letter-spacing: -0.2px; }
.room-status { font-size: 12px; color: var(--ink-dim); margin-top: 1px; }
.room-status.online { color: var(--status); }

.icon-btn { background: var(--icon-bg); border: 1px solid var(--border-subtle); color: var(--ink); width: 40px; height: 40px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.18s; }
.icon-btn:hover { background: var(--icon-bg-hover); }
.members-btn { width: auto; padding: 0 12px; gap: 6px; font-size: 14px; font-weight: 600; }

.countdown { position: relative; width: 40px; height: 40px; flex-shrink: 0; }
.countdown svg { transform: rotate(-90deg); }
.cd-track { fill: none; stroke: var(--border); stroke-width: 3; }
.cd-arc { fill: none; stroke: var(--status); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 106.8; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke 0.4s; }
.cd-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-dim); }
.countdown.warn .cd-arc { stroke: #ff5f7e; }
.countdown.warn .cd-text { color: #ff5f7e; }

.members-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 280px; max-width: 82%; transform: translateX(100%); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); z-index: 30; padding: calc(18px + var(--safe-t)) 18px 18px; overflow-y: auto; border-left: 1px solid var(--border); background: var(--bg-2); }
.members-panel.open { transform: translateX(0); box-shadow: -20px 0 60px rgba(0, 0, 0, 0.3); }
.members-head { font-weight: 600; margin-bottom: 14px; font-size: 15px; }
.members-list { list-style: none; margin: 0; padding: 0; }
.members-list li { display: flex; align-items: center; gap: 11px; padding: 9px 0; font-size: 14px; }
.members-list img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.panel-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 25; }

.messages { flex: 1; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 14px; }
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg-row { display: flex; gap: 9px; max-width: 84%; animation: pop 0.25s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.msg-body { display: flex; flex-direction: column; min-width: 0; }
.msg-row.me .msg-body { align-items: flex-end; }
.msg-nick { font-size: 11px; color: var(--ink-dim); margin: 0 4px 4px; }

.bubble { padding: 11px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; background: var(--bubble-other-bg); border: 1px solid var(--border-subtle); color: var(--bubble-other-ink); border-top-left-radius: 6px; }
.msg-row.me .bubble { background: var(--bubble-me); border: none; color: var(--bubble-me-ink); border-radius: 16px; border-top-right-radius: 6px; }
.bubble.img-bubble { padding: 5px; }
.bubble.img-bubble img { max-width: 240px; max-height: 320px; border-radius: 12px; display: block; cursor: pointer; }

.voice-bubble { display: flex; align-items: center; gap: 11px; cursor: pointer; min-width: 130px; user-select: none; }
.voice-bubble .vplay { font-size: 15px; }
.voice-bubble .vwave { flex: 1; height: 22px; display: flex; align-items: center; gap: 2px; }
.voice-bubble .vwave i { flex: 1; background: currentColor; opacity: 0.5; border-radius: 2px; height: 40%; }
.voice-bubble .vwave i:nth-child(3n) { height: 90%; }
.voice-bubble .vwave i:nth-child(3n + 1) { height: 60%; }
.voice-bubble .vdur { font-size: 12px; opacity: 0.85; font-variant-numeric: tabular-nums; }

.msg-foot { display: flex; align-items: center; gap: 6px; margin: 4px 4px 0; }
.msg-time { font-size: 10px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.msg-read { font-size: 10px; color: var(--status); display: flex; align-items: center; gap: 2px; }
.msg-read.pending { color: var(--ink-faint); }

.sys-msg { align-self: center; font-size: 12px; color: var(--ink-dim); background: var(--chip-bg); padding: 5px 14px; border-radius: 999px; border: 1px solid var(--border-subtle); max-width: 90%; text-align: center; }

.call-bar { display: flex; align-items: center; gap: 11px; padding: 11px 16px; background: color-mix(in srgb, var(--status) 12%, transparent); border-top: 1px solid color-mix(in srgb, var(--status) 30%, transparent); font-size: 14px; }
.call-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--status); box-shadow: 0 0 10px var(--status); animation: blink 1.3s infinite; }
.call-hangup { margin-left: auto; background: #ff5f7e; color: #fff; border: none; padding: 8px 18px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; }

.composer { display: flex; align-items: center; gap: 8px; padding: 11px 12px; padding-bottom: calc(11px + var(--safe-b)); border-top: 1px solid var(--border-subtle); }
.composer-icon { background: var(--icon-bg); border: 1px solid var(--border-subtle); color: var(--ink-dim); width: 42px; height: 42px; border-radius: 12px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: background 0.18s, color 0.18s; }
.composer-icon:hover { background: var(--icon-bg-hover); color: var(--ink); }
.composer-icon.recording { background: #ff5f7e; color: #fff; border-color: transparent; animation: blink 1s infinite; }
.composer .field { flex: 1; border-radius: 13px; padding: 11px 14px; }
.send-btn { background: var(--grad); border: none; color: var(--accent-ink); padding: 0 18px; height: 42px; border-radius: 12px; font-size: 15px; font-weight: 600; cursor: pointer; flex-shrink: 0; box-shadow: var(--btn-shadow); }
.send-btn:active { transform: scale(0.97); }

.expired-overlay { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 24px; background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.expired-card { width: 100%; max-width: 380px; border-radius: 24px; padding: 34px 28px; text-align: center; box-shadow: var(--card-shadow); }
.expired-icon { font-size: 42px; }
.expired-card h2 { margin: 12px 0 8px; font-size: 22px; letter-spacing: -0.4px; }
.expired-card p { margin: 0 0 22px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }

.img-viewer { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.94); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.img-viewer img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }

.hidden { display: none !important; }

@media (min-width: 780px) {
  #chat { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); }
}


/* ===================================================================
   私聊 / 移动端适配 / 可点击成员
=================================================================== */

/* 聊天/私聊页时隐藏全局顶部控件，避免与头部按钮重叠 */
.in-chat .top-controls { display: none; }

/* 可点击的成员（发起私聊） */
.members-list li.clickable { cursor: pointer; border-radius: 12px; padding: 9px 8px; margin: 0 -8px; transition: background 0.15s; position: relative; }
.members-list li.clickable:hover { background: var(--icon-bg-hover); }
.members-list li .pm-ico { margin-left: auto; color: var(--ink-faint); display: flex; }
.members-list li.clickable:hover .pm-ico { color: var(--accent); }
.members-list li .pm-unread { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* 私聊覆盖层 */
.pm-screen { position: fixed; inset: 0; z-index: 40; flex-direction: column; background: var(--bg); transform: translateX(100%); visibility: hidden; transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.28s; display: flex; }
.pm-screen.open { transform: translateX(0); visibility: visible; transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s; }
.pm-head-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
@media (min-width: 780px) { .pm-screen { max-width: 760px; margin: 0 auto; border-left: 1px solid var(--border-subtle); border-right: 1px solid var(--border-subtle); } }

/* 私聊请求弹窗 */
.pm-request { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; padding: 24px; background: color-mix(in srgb, var(--bg) 68%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.pm-request-card { width: 100%; max-width: 340px; border-radius: 22px; padding: 26px 22px; text-align: center; box-shadow: var(--card-shadow); }
.pm-req-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); margin-bottom: 14px; }
.pm-req-text { font-size: 16px; font-weight: 600; margin-bottom: 22px; line-height: 1.4; }
.pm-req-actions { display: flex; gap: 10px; }
.pm-btn { flex: 1; border: none; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 600; cursor: pointer; transition: filter 0.15s, background 0.15s; }
.pm-btn-decline { background: var(--icon-bg); color: var(--ink-dim); border: 1px solid var(--border); }
.pm-btn-decline:hover { background: var(--icon-bg-hover); }
.pm-btn-accept { background: var(--grad); color: var(--accent-ink); box-shadow: var(--btn-shadow); }
.pm-btn-accept:hover { filter: brightness(1.06); }

/* ---------- 移动端适配 ---------- */
@media (max-width: 480px) {
  .top-controls { top: calc(10px + var(--safe-t)); right: 12px; gap: 6px; }
  .chip-btn { padding: 6px 11px; font-size: 12px; }

  #lobby { padding: 18px 16px; }
  .brand-mark { width: 66px; height: 66px; }
  .brand-name { font-size: 34px; }
  .brand-tagline { font-size: 14px; }
  .stat-badge { font-size: 12px; padding: 7px 13px; }
  .glass-card { padding: 22px 18px; border-radius: 20px; }

  .chat-header { gap: 8px; padding: 10px 12px; padding-top: calc(10px + var(--safe-t)); }
  .room-title { font-size: 15px; }
  .icon-btn { width: 38px; height: 38px; }
  .members-btn { padding: 0 10px; }
  .countdown { width: 36px; height: 36px; }
  .countdown svg { width: 36px; height: 36px; }

  .messages { padding: 14px 10px; gap: 12px; }
  .msg-row { max-width: 88%; }
  .bubble { font-size: 14.5px; }
  .bubble.img-bubble img { max-width: min(66vw, 240px); }

  /* 输入栏：图标略缩，输入框优先 */
  .composer { gap: 6px; padding: 9px 10px; padding-bottom: calc(9px + var(--safe-b)); }
  .composer-icon { width: 38px; height: 38px; border-radius: 11px; }
  .composer .field { padding: 10px 12px; font-size: 15px; min-width: 0; }
  .send-btn { padding: 0 14px; height: 40px; }
}

/* 超窄屏（<360px）进一步收紧：语音通话按钮让位 */
@media (max-width: 340px) {
  #callBtn { display: none; }
  .composer-icon { width: 36px; height: 36px; }
}


/* ===================================================================
   文件消息气泡
=================================================================== */
.bubble.file-bubble { padding: 0; overflow: hidden; }
.file-link { display: flex; align-items: center; gap: 11px; padding: 11px 13px; text-decoration: none; color: inherit; min-width: 190px; max-width: 260px; }
.file-ico { width: 38px; height: 38px; border-radius: 10px; background: color-mix(in srgb, currentColor 14%, transparent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 18px; }
.msg-row.me .file-ico { background: rgba(255, 255, 255, 0.2); }
.file-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 11px; opacity: 0.7; margin-top: 2px; }
.file-dl { flex-shrink: 0; opacity: 0.7; font-size: 16px; }
.file-link:hover .file-dl { opacity: 1; }

/* 让文件按钮在窄屏有空间：≤420px 隐藏语音通话按钮 */
@media (max-width: 420px) {
  #callBtn { display: none; }
}


/* ===================================================================
   私聊：未读角标 / 会话列表 / 通知开关 / Toast
=================================================================== */

/* 头部按钮上的未读角标 */
.pm-list-btn { position: relative; }
.head-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px; background: #ff5f7e; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* 会话列表面板头部 + 通知开关 */
.pm-list-head { display: flex; align-items: center; justify-content: space-between; }
.notify-toggle {
  background: var(--icon-bg); border: 1px solid var(--border-subtle);
  border-radius: 9px; width: 32px; height: 32px; cursor: pointer;
  font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, opacity 0.15s;
}
.notify-toggle:hover { background: var(--icon-bg-hover); }
.notify-toggle.off { opacity: 0.5; }

/* 会话条目 */
.pm-conv { gap: 11px; }
.pm-conv-mid { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pm-conv-nick { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-conv-preview { font-size: 12px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.pm-conv.active { background: var(--icon-bg-hover); }
.pm-dot { margin-left: auto; width: 9px; height: 9px; border-radius: 50%; background: #ff5f7e; flex-shrink: 0; }
.pm-empty { color: var(--ink-faint); font-size: 13px; text-align: center; margin-top: 34px; }

/* Toast 顶部通知条（可点击跳转） */
.toast {
  position: fixed; top: calc(14px + var(--safe-t)); left: 50%;
  transform: translate(-50%, -18px); z-index: 98; max-width: 88%;
  background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--border); box-shadow: var(--card-shadow);
  padding: 11px 16px; border-radius: 14px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; opacity: 0; transition: opacity 0.28s ease, transform 0.28s ease;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }


/* 文件图标显示类型后缀（如 PDF / ZIP） */
.file-ico.has-ext { font-size: 11px; font-weight: 800; letter-spacing: 0.3px; text-transform: uppercase; }
.file-size { text-transform: uppercase; }
.file-name { text-transform: none; }


/* ===================================================================
   成员面板：成员 / 进出动态 标签
=================================================================== */
.panel-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.panel-tab {
  flex: 1; background: var(--icon-bg); border: 1px solid var(--border-subtle);
  color: var(--ink-dim); border-radius: 10px; padding: 8px 6px;
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.panel-tab.active { background: var(--grad); color: var(--accent-ink); border-color: transparent; }

.activity-list .activity-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 14px; }
.act-badge { width: 26px; height: 26px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.act-badge.join { background: color-mix(in srgb, var(--status) 18%, transparent); color: var(--status); }
.act-badge.leave { background: color-mix(in srgb, #ff5f7e 16%, transparent); color: #ff5f7e; }
.act-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-time { font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; flex-shrink: 0; }


/* ===================================================================
   多语言：国旗下拉菜单 + RTL（阿拉伯语）
=================================================================== */
.lang-wrap { position: relative; }
.lang-toggle { gap: 5px; }
.lang-flag { font-size: 15px; line-height: 1; }
.lang-name { font-weight: 600; }
.lang-caret { opacity: 0.5; font-size: 10px; }

.lang-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--card-shadow); padding: 6px; min-width: 176px;
  display: flex; flex-direction: column; gap: 2px;
  max-height: 66vh; overflow-y: auto;
}
.lang-opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: var(--ink); cursor: pointer;
  padding: 9px 11px; border-radius: 10px; font-size: 14px; font-family: inherit; text-align: start;
  transition: background 0.15s;
}
.lang-opt:hover { background: var(--icon-bg-hover); }
.lang-opt.active { background: var(--icon-bg); font-weight: 600; }
.lang-opt .of { font-size: 18px; line-height: 1; flex-shrink: 0; }
.lang-opt .on { flex: 1; white-space: nowrap; }
.lang-opt .ok { color: var(--accent); font-weight: 700; }

/* RTL（阿拉伯语）微调 */
[dir="rtl"] .lang-menu { right: auto; left: 0; }
[dir="rtl"] .lang-opt { text-align: end; }
[dir="rtl"] .msg-nick, [dir="rtl"] .msg-foot { direction: rtl; }
[dir="rtl"] .bubble { text-align: right; }


/* ===================================================================
   内置浏览器（微信/抖音等）引导提示条
=================================================================== */
.inapp-banner {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--accent) 12%, var(--card-bg));
  border: 1px solid var(--border); border-radius: 14px;
  padding: 11px 13px; margin-bottom: 18px; font-size: 13px; color: var(--ink);
  box-shadow: var(--card-shadow);
}
.inapp-ico { font-size: 18px; flex-shrink: 0; }
.inapp-text { flex: 1; line-height: 1.45; }
.inapp-copy {
  flex-shrink: 0; background: var(--grad); color: var(--accent-ink); border: none;
  border-radius: 9px; padding: 8px 12px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}


/* ===================================================================
   群主 / 群资料 / 公告 / 私聊开关 / 拉黑
=================================================================== */

/* 群头像 + 可编辑标题 */
.group-avatar { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
#groupInfo { cursor: pointer; }
/* 群设置按钮：与其它头部图标统一为单色，简洁协调 */
#groupSettingsBtn:hover { background: var(--icon-bg-hover); }

/* 成员列表：姓名/群主标签/私聊开关 */
.members-list .m-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-me { display: flex; align-items: center; gap: 11px; padding: 9px 0; font-size: 14px; }
.member-me img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.owner-tag { flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); padding: 2px 7px; border-radius: 999px; margin-inline-start: 6px; }
.pm-accept-pill { flex-shrink: 0; margin-inline-start: 8px; border: 1px solid var(--border); background: color-mix(in srgb, var(--status) 14%, transparent); color: var(--status); border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 600; cursor: pointer; font-family: inherit; }
.pm-accept-pill.off { background: var(--icon-bg); color: var(--ink-dim); }

/* 群主公告 */
.announce { align-self: stretch; margin: 4px 0; background: color-mix(in srgb, var(--accent) 12%, var(--card-bg)); border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent); border-radius: 14px; padding: 11px 14px; }
.announce-head { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.announce-body { font-size: 14.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.announce-time { font-size: 10px; color: var(--ink-faint); margin-top: 4px; }

/* 通用弹窗（群资料）*/
.modal-overlay { position: fixed; inset: 0; z-index: 96; display: flex; align-items: center; justify-content: center; padding: 24px; background: color-mix(in srgb, var(--bg) 68%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-card { width: 100%; max-width: 360px; border-radius: 22px; padding: 24px; box-shadow: var(--card-shadow); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; text-align: center; }
.group-edit-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.group-edit-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .pm-btn { flex: 1; }

/* 私聊拉黑复选框 */
.pm-block-check { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 16px; cursor: pointer; }
.pm-block-check input { width: 15px; height: 15px; accent-color: var(--accent); }


/* 群主密钥导出/导入 */
.modal-wide { width: 100%; margin-bottom: 10px; }
.owner-key-box { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.4; resize: none; word-break: break-all; margin-bottom: 10px; }
.owner-key-hint { font-size: 12px; color: var(--ink-dim); line-height: 1.5; margin-bottom: 14px; }


/* 成员搜索 + 群分享 */
.member-search { width: 100%; margin-bottom: 12px; padding: 9px 12px; font-size: 13px; }
.group-share-btn { width: 100%; margin-bottom: 12px; background: var(--icon-bg); color: var(--ink); border: 1px solid var(--border); }
.group-share-btn:hover { background: var(--icon-bg-hover); }
.members-empty { color: var(--ink-faint); font-size: 13px; text-align: center; margin-top: 20px; }


/* ===================================================================
   性能优化：动效降载 / 移动端
=================================================================== */
/* 提升光晕到独立合成层，避免重绘 */
.blob { will-change: transform; transform: translateZ(0); }

/* 移动端：光晕更省、减少混合与模糊、放慢动画、少画一团 */
@media (max-width: 640px) {
  .blob { filter: blur(46px); mix-blend-mode: normal; animation-duration: 46s; }
  .blob.b3 { display: none; }
}

/* 尊重系统"减少动态效果"：关掉所有循环动画，最省电最流畅 */
@media (prefers-reduced-motion: reduce) {
  .blob, .btn-glow, .brand-mark, .stat-dot, .call-dot, .composer-icon.recording { animation: none !important; }
  * { scroll-behavior: auto !important; }
}


/* ===================================================================
   @提及 成员 / 提及高亮
=================================================================== */
.mention-box {
  position: absolute; left: 10px; right: 10px; bottom: calc(62px + var(--safe-b));
  max-height: 220px; overflow-y: auto; z-index: 8;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--card-shadow); padding: 5px;
}
.mention-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; color: var(--ink); cursor: pointer;
  padding: 9px 10px; border-radius: 10px; font-size: 14px; font-family: inherit; text-align: start;
}
.mention-item:hover { background: var(--icon-bg-hover); }
.mention-item img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.mention-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 消息里 @昵称 的高亮 */
.bubble .mention { color: var(--accent); font-weight: 600; }
.msg-row.me .bubble .mention { color: #fff; text-decoration: underline; }
/* @到我的消息整条高亮 */
.msg-row.mention-me .bubble { box-shadow: 0 0 0 2px var(--accent); }

@media (min-width: 780px) { .mention-box { max-width: 760px; margin: 0 auto; } }
