:root {
  /* ── 人间仙境（默认）：雾山、青玉、软金 ── */
  --bg: #0b1210;
  --surface: #14221c;
  --surface2: #1b2c24;
  --surface3: #243830;
  --border: rgba(180, 210, 190, 0.10);
  --border-hover: rgba(200, 220, 200, 0.22);
  --text: #e7f2ea;
  --muted: #7f9a8c;
  --text-secondary: #9bb0a4;
  --blue: #5db89a;
  --blue-dim: rgba(93, 184, 154, 0.14);
  --accent: #5db89a;
  --purple: #c9a86c;
  --purple-dim: rgba(201, 168, 108, 0.14);
  --green: #6ec4a0;
  --green-dim: rgba(110, 196, 160, 0.14);
  --red: #d47a6a;
  --grad: linear-gradient(135deg, #3d8f72 0%, #5db89a 48%, #c9a86c 100%);
  --grad-subtle: linear-gradient(135deg, rgba(93,184,154,0.12), rgba(201,168,108,0.08));
  --bubble-out: linear-gradient(135deg, #3f9a7a 0%, #5db89a 100%);
  --bubble-in: #1f322a;
  --input-bg: #243830;
  --on-accent: #07140f;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 18px color-mix(in srgb, var(--text) 32%, transparent);
  /* Links must NOT match bubble/accent — otherwise invisible in chat. */
  --link: #7ec8ff;
  --link-bg: rgba(126, 200, 255, 0.18);
  --link-on-out: #ffffff;
  --link-on-out-bg: rgba(7, 20, 15, 0.32);
  --atmosphere:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(93, 184, 154, 0.16), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(201, 168, 108, 0.10), transparent 50%);

  /* ── 间距阶梯 ── */
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;

  /* ── 圆角规范 ── */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 50%;

  /* ── 字体：宋意标题 + 人文黑体 ── */
  /* 系统字体栈：避免 Google Fonts 在国内 20–30s 级延迟 */
  --font-display: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-xs: 0.7rem;
  --font-sm: 0.8rem;
  --font-md: 0.9rem;
  --font-lg: 1.1rem;
  --font-xl: 1.4rem;
  --font-2xl: 1.8rem;

  /* ── 阴影层级 ── */
  --shadow-sm: 0 2px 8px color-mix(in srgb, var(--text) 20%, transparent);
  --shadow-md: 0 8px 24px color-mix(in srgb, var(--text) 26%, transparent);
  --shadow-lg: 0 18px 44px color-mix(in srgb, var(--text) 36%, transparent);
  --shadow-glow: 0 0 0 1px rgba(93, 184, 154, 0.28);

  /* ── 过渡变量 ── */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 红尘闹市：暖金灯火、烟火气（刻意避开血红）── */
[data-theme="hongchen"] {
  --bg: #1a120a;
  --surface: #2a1e12;
  --surface2: #362818;
  --surface3: #443420;
  --border: rgba(232, 196, 120, 0.14);
  --border-hover: rgba(232, 196, 120, 0.28);
  --text: #f7ecd8;
  --muted: #b89a72;
  --text-secondary: #c9ae86;
  --blue: #e8b84a;
  --blue-dim: rgba(232, 184, 74, 0.16);
  --accent: #e8b84a;
  --purple: #f0a060;
  --purple-dim: rgba(240, 160, 96, 0.14);
  --green: #d4a017;
  --green-dim: rgba(212, 160, 23, 0.12);
  --red: #e07a4a;
  --grad: linear-gradient(135deg, #c4892a 0%, #e8b84a 48%, #f0c878 100%);
  --grad-subtle: linear-gradient(135deg, rgba(232,184,74,0.14), rgba(240,160,96,0.08));
  --bubble-out: linear-gradient(135deg, #c4892a 0%, #e8b84a 100%);
  --bubble-in: #3a2a18;
  --input-bg: #443420;
  --on-accent: #1a1006;
  --shadow: 0 2px 16px rgba(60, 35, 8, 0.35);
  --shadow-glow: 0 0 0 1px rgba(232, 184, 74, 0.30);
  --link: #8fd0ff;
  --link-bg: rgba(143, 208, 255, 0.16);
  --link-on-out: #1a1006;
  --link-on-out-bg: rgba(255, 255, 255, 0.55);
  --atmosphere:
    radial-gradient(ellipse 70% 45% at 20% 0%, rgba(232, 184, 74, 0.18), transparent 55%),
    radial-gradient(ellipse 55% 40% at 95% 20%, rgba(240, 160, 96, 0.10), transparent 50%);
}

/* ── 修罗地狱：焦炭黑、熔岩橙、铁壁（刻意避开血红洪水）── */
[data-theme="xiuluo"] {
  --bg: #070608;
  --surface: #121014;
  --surface2: #1a161c;
  --surface3: #262028;
  --border: rgba(255, 140, 60, 0.14);
  --border-hover: rgba(255, 140, 60, 0.28);
  --text: #efe6e2;
  --muted: #8a7a78;
  --text-secondary: #a0908c;
  --blue: #ff7a3a;
  --blue-dim: rgba(255, 122, 58, 0.16);
  --accent: #ff7a3a;
  --purple: #ffb060;
  --purple-dim: rgba(255, 176, 96, 0.12);
  --green: #e07040;
  --green-dim: rgba(224, 112, 64, 0.12);
  --red: #ff5a3a;
  --grad: linear-gradient(135deg, #3a2018 0%, #ff7a3a 55%, #ffb060 100%);
  --grad-subtle: linear-gradient(135deg, rgba(255,122,58,0.14), rgba(255,176,96,0.06));
  --bubble-out: linear-gradient(135deg, #c45a28 0%, #ff7a3a 100%);
  --bubble-in: #1e181c;
  --input-bg: #262028;
  --on-accent: #120806;
  --shadow: 0 2px 18px color-mix(in srgb, var(--text) 55%, transparent);
  --shadow-glow: 0 0 0 1px rgba(255, 122, 58, 0.32);
  --link: #7ec8ff;
  --link-bg: rgba(126, 200, 255, 0.16);
  --link-on-out: #120806;
  --link-on-out-bg: rgba(255, 255, 255, 0.55);
  --atmosphere:
    radial-gradient(ellipse 70% 45% at 50% -5%, rgba(255, 122, 58, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 90%, rgba(255, 176, 96, 0.08), transparent 50%);
}

/* ── 素雪白昼：自然白、纸感、清爽打字 ── */
[data-theme="suyue"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface2: #f7f8fa;
  --surface3: #eef1f4;
  --border: rgba(30, 45, 60, 0.10);
  --border-hover: rgba(30, 45, 60, 0.18);
  --text: #1f2a33;
  --muted: #7a8794;
  --text-secondary: #5f6d7a;
  --blue: #3d8f72;
  --blue-dim: rgba(61, 143, 114, 0.10);
  --accent: #3d8f72;
  --purple: #c9a86c;
  --purple-dim: rgba(201, 168, 108, 0.12);
  --green: #2f9d6a;
  --green-dim: rgba(47, 157, 106, 0.10);
  --red: #d45b4a;
  --grad: linear-gradient(135deg, #3d8f72 0%, #5db89a 55%, #7ec9ad 100%);
  --grad-subtle: linear-gradient(135deg, rgba(61,143,114,0.08), rgba(201,168,108,0.06));
  --bubble-out: linear-gradient(135deg, #3d8f72 0%, #5db89a 100%);
  --bubble-in: #ffffff;
  --input-bg: #f0f3f6;
  --on-accent: #ffffff;
  --shadow: 0 2px 12px rgba(20, 35, 50, 0.08);
  --shadow-sm: 0 1px 4px rgba(20, 35, 50, 0.06);
  --shadow-md: 0 6px 18px rgba(20, 35, 50, 0.10);
  --shadow-lg: 0 14px 36px rgba(20, 35, 50, 0.12);
  --shadow-glow: 0 0 0 1px rgba(61, 143, 114, 0.18);
  --link: #1565c0;
  --link-bg: rgba(21, 101, 192, 0.10);
  --link-on-out: #ffffff;
  --link-on-out-bg: rgba(7, 40, 28, 0.28);
  --atmosphere:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(61, 143, 114, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 8%, rgba(201, 168, 108, 0.06), transparent 50%);
}

/* 素雪白昼：打字区与气泡更干净 */
[data-theme="suyue"] .send-bar {
  background: #ffffff;
  box-shadow: 0 2px 14px rgba(20, 35, 50, 0.07);
}
[data-theme="suyue"] .send-bar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 2px rgba(61, 143, 114, 0.12), 0 4px 18px rgba(20, 35, 50, 0.08);
}
[data-theme="suyue"] .send-bar:has(#msg-input:focus) {
  background: #ffffff;
}
[data-theme="suyue"] .msg.in {
  background: #ffffff;
  border-color: rgba(30, 45, 60, 0.08);
}
[data-theme="suyue"] .msg.in .msg-mention { color: #2f9d6a; }
[data-theme="suyue"] .login-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(30, 45, 60, 0.10);
  box-shadow: 0 12px 40px rgba(20, 35, 50, 0.10);
}
[data-theme="suyue"] .sidebar {
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}
[data-theme="suyue"] .emoji-picker {
  background: #ffffff;
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}
[data-theme="suyue"] .msg-load-older {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  color: var(--muted);
}
[data-theme="suyue"] .emoji-btn:hover,
[data-theme="suyue"] .btn-attach:hover,
[data-theme="suyue"] .btn-emoji:hover {
  background: var(--surface3);
}
[data-theme="suyue"] .upload-bar {
  background: var(--surface2);
}



* { box-sizing: border-box; margin: 0; padding: 0; }

/* Shared line icons (mask so currentColor follows theme) */
.ui-icon {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: var(--ui-icon) center / contain no-repeat;
  mask: var(--ui-icon) center / contain no-repeat;
  vertical-align: -0.12em;
}
.ui-icon[data-icon="search"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2211%22%20cy%3D%2211%22%20r%3D%226.5%22%2F%3E%3Cpath%20d%3D%22M16.5%2016.5L21%2021%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="send"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4.5%2011.5L19.5%204.5%2012.5%2019.5%2010.5%2013.5%204.5%2011.5z%22%2F%3E%3Cpath%20d%3D%22M10.5%2013.5L19.5%204.5%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="attach"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M15.5%207.5l-6.8%206.8a2.5%202.5%200%201%200%203.5%203.5l7.2-7.2a4%204%200%200%200-5.7-5.7L6.2%2012.4a5.5%205.5%200%200%200%207.8%207.8l5.5-5.5%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="emoji"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%228.5%22%2F%3E%3Cpath%20d%3D%22M8.5%2014.5c1.2%201.4%202.7%202%203.5%202s2.3-.6%203.5-2%22%2F%3E%3Ccircle%20cx%3D%229%22%20cy%3D%2210%22%20r%3D%221%22%20fill%3D%22%23000%22%20stroke%3D%22none%22%2F%3E%3Ccircle%20cx%3D%2215%22%20cy%3D%2210%22%20r%3D%221%22%20fill%3D%22%23000%22%20stroke%3D%22none%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="mention"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%223.25%22%2F%3E%3Cpath%20d%3D%22M16.5%2012v1.4a2.1%202.1%200%200%200%204.2%200V12a8.5%208.5%200%201%200-3.4%206.8%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="members"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%229%22%20cy%3D%228%22%20r%3D%223%22%2F%3E%3Cpath%20d%3D%22M3.5%2018.5c.8-2.8%202.9-4.2%205.5-4.2s4.7%201.4%205.5%204.2%22%2F%3E%3Ccircle%20cx%3D%2217%22%20cy%3D%229%22%20r%3D%222.4%22%2F%3E%3Cpath%20d%3D%22M14.8%2018.5c.5-1.8%201.8-2.9%203.6-2.9%201.2%200%202.2.5%202.9%201.4%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="share"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2218%22%20cy%3D%225.5%22%20r%3D%222.5%22%2F%3E%3Ccircle%20cx%3D%226%22%20cy%3D%2212%22%20r%3D%222.5%22%2F%3E%3Ccircle%20cx%3D%2218%22%20cy%3D%2218.5%22%20r%3D%222.5%22%2F%3E%3Cpath%20d%3D%22M8.3%2010.9l7.4-4.1M8.3%2013.1l7.4%204.1%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="call"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M8.2%203.8l2.4%202.4a1.2%201.2%200%200%201%200%201.7L9.2%209.3c1%201.8%202.5%203.3%204.3%204.3l1.4-1.4a1.2%201.2%200%200%201%201.7%200l2.4%202.4a1.2%201.2%200%200%201%200%201.7l-1.1%201.1c-.7.7-1.7%201-2.7.8-2.9-.6-5.7-2.5-7.9-4.7S4.1%209.1%203.5%206.2c-.2-.9.1-1.9.8-2.6l1.1-1.1a1.2%201.2%200%200%201%201.7%200l1.1%201.3z%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="more"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%226%22%20cy%3D%2212%22%20r%3D%221.4%22%20fill%3D%22%23000%22%20stroke%3D%22none%22%2F%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%221.4%22%20fill%3D%22%23000%22%20stroke%3D%22none%22%2F%3E%3Ccircle%20cx%3D%2218%22%20cy%3D%2212%22%20r%3D%221.4%22%20fill%3D%22%23000%22%20stroke%3D%22none%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="profile"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%228%22%20r%3D%223.5%22%2F%3E%3Cpath%20d%3D%22M5%2019.5c1.2-3.4%203.7-5%207-5s5.8%201.6%207%205%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="logout"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M10%205H7a2%202%200%200%200-2%202v10a2%202%200%200%200%202%202h3%22%2F%3E%3Cpath%20d%3D%22M14%2016l4-4-4-4%22%2F%3E%3Cpath%20d%3D%22M18%2012H9%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="channels"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M9%204l-2%2016M17%204l-2%2016M5%209h15M4%2015h15%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="settings"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%223%22%2F%3E%3Cpath%20d%3D%22M12%203.5v2.2M12%2018.3v2.2M4.9%206.5l1.6%201.6M17.5%2015.9l1.6%201.6M3.5%2012h2.2M18.3%2012h2.2M4.9%2017.5l1.6-1.6M17.5%208.1l1.6-1.6%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="edit"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%2020h4l11-11-4-4L4%2016v4z%22%2F%3E%3Cpath%20d%3D%22M13%207l4%204%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="voice"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M8%2010v2a4%204%200%200%200%208%200v-2%22%2F%3E%3Cpath%20d%3D%22M12%2016v3M9%2019h6%22%2F%3E%3Crect%20x%3D%229.5%22%20y%3D%224%22%20width%3D%225%22%20height%3D%229%22%20rx%3D%222.5%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="screenshot"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%209V6a2%202%200%200%201%202-2h3M20%209V6a2%202%200%200%200-2-2h-3M4%2015v3a2%202%200%200%200%202%202h3M20%2015v3a2%202%200%200%201-2%202h-3%22%2F%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%223%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="friends"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%228.5%22%20cy%3D%228%22%20r%3D%223%22%2F%3E%3Cpath%20d%3D%22M2.8%2018.5c.8-2.6%202.7-4%205.7-4s4.9%201.4%205.7%204%22%2F%3E%3Ccircle%20cx%3D%2216.5%22%20cy%3D%228.5%22%20r%3D%222.4%22%2F%3E%3Cpath%20d%3D%22M14.2%2018.5c.4-1.7%201.6-2.8%203.3-2.8%201.1%200%202%20.4%202.7%201.2%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="groups"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%208.5A3.5%203.5%200%200%201%207.5%205H14a3%203%200%200%201%203%203v8.5a2.5%202.5%200%200%201-2.5%202.5H7.5A3.5%203.5%200%200%201%204%2015.5v-7z%22%2F%3E%3Cpath%20d%3D%22M17%208h1.5A2.5%202.5%200%200%201%2021%2010.5v6A2.5%202.5%200%200%201%2018.5%2019H16%22%2F%3E%3Cpath%20d%3D%22M8%2010h5M8%2013h3.5%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="hall"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%2020h16M6%2020V10l6-5%206%205v10%22%2F%3E%3Cpath%20d%3D%22M10%2020v-5h4v5%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="pin"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M9.5%204.5l10%2010-2.2%201.1-3.3-3.3-3.8%203.8v3.4L8%2017.3l-3.8%203.8-1.3-1.3%203.8-3.8-2.2-2.2%203.4-3.8-3.3-3.3L9.5%204.5z%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="theme"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%223%22%2F%3E%3Cpath%20d%3D%22M12%203.5a8.5%208.5%200%201%200%208.5%208.5h-5.5a3%203%200%200%201-3-3V3.5z%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="mic"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%229%22%20y%3D%223.5%22%20width%3D%226%22%20height%3D%2210%22%20rx%3D%223%22%2F%3E%3Cpath%20d%3D%22M6.5%2011a5.5%205.5%200%200%200%2011%200M12%2016.5V20.5M9.5%2020.5h5%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="back"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M15%205l-7%207%207%207%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="menu"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%207h16M4%2012h16M4%2017h16%22%2F%3E%3C%2Fsvg%3E"); }
.ui-icon[data-icon="plus"] { --ui-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%23000%22%20stroke-width%3D%221.75%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%205v14M5%2012h14%22%2F%3E%3C%2Fsvg%3E"); }
.tb-icon .ui-icon { width: 14px; height: 14px; }
.send-bar .ui-icon { width: 18px; height: 18px; }
.search-icon .ui-icon { width: 14px; height: 14px; }
.sidebar-tab-icon .ui-icon { width: 12px; height: 12px; color: var(--muted); }
.sidebar-tab.active .sidebar-tab-icon .ui-icon { color: var(--on-accent, #fff); }
.btn-hall-prominent { display: inline-flex; align-items: center; gap: 8px; }
.btn-hall-prominent .ui-icon { width: 16px; height: 16px; }
.notification-icon .ui-icon { width: 14px; height: 14px; }
.mobile-only-theme { display: none; }
#btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow var(--transition-fast), background var(--transition-fast);
}
#btn-send:active { transform: scale(0.96); }

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

#app {
  height: 100%;
  height: 100dvh;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image: var(--atmosphere);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}
h1, h2, h3, .login-card h1, .brand-title {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-weight: 700;
}

.hidden { display: none !important; }
.view {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.view.active {
  display: flex;
  flex-direction: column;
}

/* Skip login flash when resuming saved session */
html.session-resume #view-login { display: none !important; }
html.session-resume #view-main {
  display: flex !important;
  flex-direction: column;
}

/* ── Login ── */
#view-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.login-bg {
  position: fixed;
  inset: 0;
  --scene: url("assets/theme-xianjing.jpg");
  background:
    radial-gradient(ellipse 80% 55% at 50% -8%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 42%, transparent) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 72%, var(--bg) 100%),
    var(--scene) center / cover no-repeat;
  z-index: 0;
  animation: ambientDrift 22s ease-in-out infinite alternate;
}
[data-theme="hongchen"] .login-bg { --scene: url("assets/theme-hongchen.jpg"); }
[data-theme="xiuluo"] .login-bg { --scene: url("assets/theme-xiuluo.jpg"); }
[data-theme="suyue"] .login-bg {
  --scene: none;
  background:
    radial-gradient(ellipse 80% 55% at 50% -8%, rgba(61, 143, 114, 0.10), transparent 58%),
    linear-gradient(180deg, #f7f9fb 0%, #eef3f0 55%, #e8eee9 100%);
  animation: none;
}
@supports (background-image: image-set(url("a.webp") type("image/webp"))) {
  .login-bg {
    --scene: image-set(
      url("assets/theme-xianjing.webp") type("image/webp"),
      url("assets/theme-xianjing.jpg") type("image/jpeg")
    );
  }
  [data-theme="hongchen"] .login-bg {
    --scene: image-set(
      url("assets/theme-hongchen.webp") type("image/webp"),
      url("assets/theme-hongchen.jpg") type("image/jpeg")
    );
  }
  [data-theme="xiuluo"] .login-bg {
    --scene: image-set(
      url("assets/theme-xiuluo.webp") type("image/webp"),
      url("assets/theme-xiuluo.jpg") type("image/jpeg")
    );
  }
  [data-theme="suyue"] .login-bg { --scene: none; }
}
.login-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.10;
  background-image:
    radial-gradient(ellipse 50% 30% at 20% 80%, color-mix(in srgb, var(--purple) 18%, transparent), transparent 70%),
    radial-gradient(ellipse 40% 25% at 85% 70%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
  pointer-events: none;
  animation: mistDrift 18s ease-in-out infinite alternate;
}
@keyframes mistDrift {
  from { transform: translateY(0); opacity: 0.08; }
  to { transform: translateY(-10px); opacity: 0.14; }
}
@keyframes ambientDrift {
  0% { opacity: 0.94; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.025); }
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 40px 32px 32px;
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 80%, color-mix(in srgb, var(--green) 20%, transparent));
  backdrop-filter: blur(28px) saturate(1.1);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: loginCardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.login-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.login-shell.has-invite {
  max-width: min(1040px, 96vw);
  flex-direction: row;
  align-items: stretch;
  gap: 24px;
}
.login-shell.has-invite .invite-landing:not(.hidden) {
  flex: 1 1 62%;
  min-width: 280px;
}
.login-shell.has-invite .login-card {
  flex: 0 0 min(340px, 34%);
  max-width: 360px;
  width: 100%;
  align-self: center;
  padding: 28px 24px 22px;
}
.login-shell.has-invite .login-logo {
  width: 44px;
  height: 44px;
  font-size: 1.25rem;
  margin: 0 auto 12px;
  border-radius: 12px;
}
.login-shell.has-invite .login-card h1 {
  font-size: 1.15rem;
  margin-bottom: 2px;
}
.login-shell.has-invite .login-card-brand .login-sub {
  margin-bottom: 12px;
  font-size: 0.74rem;
}
.login-shell.has-invite .login-lang { margin-bottom: 2px; }
.login-shell.has-invite .tabs { margin-bottom: 14px; }
.login-shell.has-invite .form-panel { gap: 12px; }
.login-shell.has-invite .btn-primary { padding: 11px 16px; font-size: 0.9rem; }

.login-card-brand {
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--green) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 22%, transparent);
  overflow: hidden;
}
.login-logo img { display: block; width: 100%; height: 100%; }

.login-card h1 {
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}
.login-sub { text-align: center; color: var(--muted); font-size: 0.84rem; margin-bottom: 24px; line-height: 1.45; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface2);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--grad);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}

.form-panel { display: none; flex-direction: column; gap: 14px; }
.form-panel.active { display: flex; }

.reg-captcha { display: flex; flex-direction: column; gap: 8px; }
.reg-captcha-label { font-size: 12px; color: var(--text-muted, #888); }
.reg-captcha-track {
  position: relative;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--blue-dim), color-mix(in srgb, var(--accent) 16%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  user-select: none;
  touch-action: none;
}
.reg-captcha-slot {
  position: absolute;
  top: 6px;
  width: 40px;
  height: 30px;
  border-radius: 8px;
  border: 2px dashed rgba(52,185,122,0.85);
  background: rgba(52,185,122,0.12);
  pointer-events: none;
  transform: translateX(0);
}
.reg-captcha-knob {
  position: absolute;
  top: 4px;
  width: 40px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #6BB5FF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: grab;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent);
  transform: translateX(0);
}
.reg-captcha-knob:active { cursor: grabbing; }
.reg-captcha-hint { font-size: 12px; color: #888; margin: 0; }
.reg-captcha-hint.ok { color: #34B97A; font-weight: 600; }

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg, var(--surface2));
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-dim); }

.btn-primary {
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--grad);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 6px 22px color-mix(in srgb, var(--green) 32%, transparent); }
.btn-primary:active { transform: translateY(0); }

.error-msg { color: var(--red); font-size: 0.82rem; margin-top: 8px; text-align: center; }
.back-link { display: block; text-align: center; margin-top: 18px; color: var(--muted); font-size: 0.82rem; text-decoration: none; transition: color 0.2s; }
.back-link:hover { color: var(--blue); }

/* ── Topbar ── */
#view-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.app-ambient-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  --scene: none;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 78%, transparent) 0%, color-mix(in srgb, var(--bg) 92%, transparent) 55%, var(--bg) 100%),
    var(--atmosphere);
  /* Scene image is lazy-applied via .scene-ready to avoid blocking first paint / hall redirect */
}
.app-ambient-bg.scene-ready {
  --scene: url("assets/theme-xianjing.jpg");
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 78%, transparent) 0%, color-mix(in srgb, var(--bg) 92%, transparent) 55%, var(--bg) 100%),
    var(--atmosphere),
    var(--scene) center / cover no-repeat;
  animation: ambientDrift 26s ease-in-out infinite alternate;
}
[data-theme="hongchen"] .app-ambient-bg.scene-ready { --scene: url("assets/theme-hongchen.jpg"); }
[data-theme="xiuluo"] .app-ambient-bg.scene-ready { --scene: url("assets/theme-xiuluo.jpg"); }
[data-theme="suyue"] .app-ambient-bg,
[data-theme="suyue"] .app-ambient-bg.scene-ready {
  --scene: none;
  background:
    linear-gradient(180deg, #f7f9fb 0%, #f2f5f7 50%, #eef2f4 100%),
    var(--atmosphere);
  animation: none;
  opacity: 1;
}
@supports (background-image: image-set(url("a.webp") type("image/webp"))) {
  .app-ambient-bg.scene-ready {
    --scene: image-set(
      url("assets/theme-xianjing.webp") type("image/webp"),
      url("assets/theme-xianjing.jpg") type("image/jpeg")
    );
  }
  [data-theme="hongchen"] .app-ambient-bg.scene-ready {
    --scene: image-set(
      url("assets/theme-hongchen.webp") type("image/webp"),
      url("assets/theme-hongchen.jpg") type("image/jpeg")
    );
  }
  [data-theme="xiuluo"] .app-ambient-bg.scene-ready {
    --scene: image-set(
      url("assets/theme-xiuluo.webp") type("image/webp"),
      url("assets/theme-xiuluo.jpg") type("image/jpeg")
    );
  }
  [data-theme="suyue"] .app-ambient-bg.scene-ready { --scene: none; }
}
#view-main > .topbar {
  position: relative;
  z-index: 100;
  overflow: visible;
}
#view-main > .main-layout { position: relative; z-index: 1; }

.text-gradient {
  background: linear-gradient(90deg, var(--text) 0%, #a8e063 55%, var(--green) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
  align-items: center;
  gap: var(--sp-sm);
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0 var(--sp-lg);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px color-mix(in srgb, var(--text) 8%, transparent);
  flex-shrink: 0;
  overflow: visible;
}

.topbar-left { display: flex; align-items: center; justify-content: flex-start; }
.topbar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: min(360px, 42vw);
  text-align: center;
}
.topbar-center.hidden { display: none; }
.topbar-chat-title {
  font-weight: 700;
  font-size: var(--font-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar-chat-sub {
  font-size: var(--font-xs);
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.topbar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.topbar-status-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px rgba(52, 185, 122, 0.5);
}
.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 0.78rem; color: var(--muted); flex-wrap: nowrap; min-width: 0; overflow: visible; }
.topbar-chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  overflow: visible;
}
.topbar-chat-actions.hidden { display: none; }
.topbar-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}
.topbar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 1;
  min-width: 0;
  overflow: visible;
}
.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.topbar-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grad-subtle);
  opacity: 0;
  transition: opacity var(--transition-fast);
  pointer-events: none;
}
.topbar-btn:hover {
  background: var(--surface2);
  border-color: color-mix(in srgb, var(--blue) 35%, var(--border));
  box-shadow: 0 2px 10px color-mix(in srgb, var(--blue) 12%, transparent);
}
.topbar-btn:hover::before { opacity: 1; }
.topbar-btn .tb-icon {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  line-height: 1;
  flex-shrink: 0;
  background: var(--grad-subtle);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent);
}
.topbar-btn:hover .tb-icon {
  border-color: color-mix(in srgb, var(--blue) 40%, var(--border));
  background: color-mix(in srgb, var(--blue-dim) 80%, var(--grad-subtle));
}
.topbar-btn .tb-text {
  position: relative;
  z-index: 1;
  font-size: 0.76rem;
}
.topbar-btn-muted { color: var(--muted); }
.topbar-btn-muted:hover { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.topbar-btn-muted .tb-icon { background: color-mix(in srgb, var(--surface2) 90%, transparent); }
.topbar-btn-muted:hover .tb-icon {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  border-color: color-mix(in srgb, var(--red) 30%, var(--border));
}

.topbar-more { position: relative; }
.topbar-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg, 0 8px 24px color-mix(in srgb, var(--text) 18%, transparent));
  z-index: 1000;
}
.topbar-more-menu.hidden { display: none; }
.topbar-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}
.topbar-menu-item:hover { background: var(--surface2); }
.topbar-menu-item .tb-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-subtle);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
.topbar-menu-item:hover .tb-icon {
  border-color: color-mix(in srgb, var(--blue) 35%, var(--border));
  background: var(--blue-dim);
}
.topbar-menu-item.topbar-menu-danger { color: #f87171; }
.topbar-menu-item.topbar-menu-danger:hover { background: rgba(239, 68, 68, 0.1); }

.topbar-chat-actions.hidden + .topbar-divider { display: none; }

/* legacy icon-only buttons (fallback) */
.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.topbar-icon-btn:hover {
  background: var(--surface2);
  color: var(--text);
  transform: scale(1.08);
}

.conn-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffb74d;
  flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px rgba(52, 185, 122, 0.5); }
.status-dot.connecting {
  animation: breathe 1.5s ease-in-out infinite;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: all var(--transition-fast);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); background: var(--surface2); transform: scale(1.08); }

/* Topbar icon buttons */
.topbar .btn-ghost {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-md);
  border: none;
  background: transparent;
}
.topbar .btn-ghost:hover { background: var(--surface2); color: var(--text); transform: scale(1.08); }

.btn-hall-prominent {
  border: none;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--font-sm);
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--blue) 35%, transparent);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.btn-hall-prominent::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), transparent 55%);
  pointer-events: none;
}
.btn-hall-prominent:hover {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.06);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--blue) 45%, transparent);
}

.btn-hall {
  border: none;
  background: var(--purple-dim);
  color: var(--purple);
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.15s;
}
.btn-hall:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* ── Main Layout ── */
.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 280px;
  transition: width 0.26s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-layout.sidebar-collapsed .sidebar-wrap {
  width: 32px;
}
.sidebar {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 88%, var(--bg)) 100%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.main-layout.sidebar-collapsed .sidebar {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  border-right: none;
}
.sidebar-toggle {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
  width: 28px;
  height: 52px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--surface2) 92%, transparent);
  backdrop-filter: blur(8px);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 0 18px color-mix(in srgb, var(--text) 14%, transparent);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, right 0.26s ease;
}
.main-layout.sidebar-collapsed .sidebar-toggle {
  right: 0;
  border-left: 1px solid var(--border);
}
.sidebar-toggle:hover {
  background: var(--surface3);
  color: var(--green);
  box-shadow: 4px 0 22px color-mix(in srgb, var(--green) 18%, transparent);
}

.sidebar-tabs {
  display: flex;
  gap: var(--sp-xs);
  padding: var(--sp-xs);
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-bottom: none;
  margin: var(--sp-sm);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: var(--sp-sm) var(--sp-md);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-sm);
  border-radius: var(--radius-xs);
  transition: background var(--transition-normal), color var(--transition-fast), transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  overflow: hidden;
}
.sidebar-tab-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-subtle);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 6%, transparent);
}
.sidebar-tab-icon-friends,
.sidebar-tab-icon-groups {
  background-image: none;
}
.sidebar-tab-label { position: relative; z-index: 1; }
.sidebar-tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface2) 80%, transparent);
  transform: scale(1.02);
}
.sidebar-tab:hover .sidebar-tab-icon {
  border-color: color-mix(in srgb, var(--blue) 30%, var(--border));
}
.sidebar-tab.active {
  background: var(--grad);
  color: var(--on-accent, #fff);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.sidebar-tab.active .sidebar-tab-icon {
  background-color: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.22);
  color: inherit;
}
.sidebar-tab.active[data-stab="friends"] .sidebar-tab-icon-friends,
.sidebar-tab.active[data-stab="groups"] .sidebar-tab-icon-groups {
  filter: brightness(1.15);
}
.sidebar-tab.active[data-stab="friends"],
.sidebar-tab.active[data-stab="groups"] {
  /* keep unified active styles above */
}
.sidebar-tab .tab-badge {
  position: relative;
  top: -1px;
}

.sidebar-panel { display: none; flex: 1; flex-direction: column; overflow: hidden; padding: var(--sp-sm); }
.sidebar-panel.active { display: flex; }

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.muted { color: var(--muted); font-size: 0.78rem; }

.icon-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: var(--blue-dim);
  color: var(--blue);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.15s;
}
.icon-btn:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }

.search-box { display: flex; align-items: center; gap: var(--sp-xs); margin-bottom: var(--sp-sm); }
.search-box .search-icon {
  color: var(--muted);
  font-size: var(--font-sm);
  flex-shrink: 0;
}
.search-box input {
  flex: 1;
  height: 38px;
  padding: 0 var(--sp-sm);
  font-size: var(--font-sm);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid transparent;
  color: var(--text);
  outline: none;
  transition: all var(--transition-fast);
}
.search-box input::placeholder { color: var(--muted); }
.search-box input:focus {
  border-color: var(--blue);
  box-shadow: var(--shadow-glow);
}
.search-box button {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  font-size: var(--font-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.search-box button:hover { background: var(--surface3); }

.conv-list { list-style: none; overflow-y: auto; overflow-x: hidden; }
.conv-list.grow { flex: 1; }

.conv-item {
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: var(--sp-xs);
  transition: background var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  background: rgba(255, 255, 255, 0.02);
}
@media (hover: hover) and (pointer: fine) {
  .conv-item {
    transition: background var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  }
  .conv-item:hover {
    background: color-mix(in srgb, var(--surface3) 80%, transparent);
    box-shadow: 0 2px 12px color-mix(in srgb, var(--text) 8%, transparent);
  }
}
.conv-item.active {
  background: linear-gradient(90deg, var(--blue-dim), transparent);
  border-left: 3px solid var(--green);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--green) 10%, transparent), 0 2px 14px var(--green-dim);
}
.conv-item.group-conv-item .conv-item-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-sm);
}
.conv-item.group-conv-item .conv-item-main { flex: 1; min-width: 0; }
.conv-item.group-conv-item .conv-item-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.group-avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--text) 25%, transparent);
  border: 2px solid rgba(255,255,255,0.12);
  text-shadow: 0 1px 2px color-mix(in srgb, var(--text) 20%, transparent);
}
.conv-item .name { font-weight: 600; font-size: 0.88rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .preview { font-size: 0.72rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.conv-item-row-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.conv-item-row-main .conv-peer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  font-size: 0.88rem;
}
.conv-item-row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.conv-item .conv-desc { font-size: 0.7rem; color: var(--text-secondary, var(--muted)); margin-top: 2px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conv-item .conv-loc { font-size: 0.68rem; color: var(--muted); margin-top: 2px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Chat Panel ── */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 55%),
    var(--bg);
  overflow: hidden;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-lg);
}
.chat-empty-illus {
  position: relative;
  overflow: hidden;
  width: 120px;
  height: 120px;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent), color-mix(in srgb, var(--bg) 70%, transparent)),
    url("assets/chat-empty.jpg") center / cover no-repeat;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--blue);
}
@supports (background-image: image-set(url("a.webp") type("image/webp"))) {
  .chat-empty-illus {
    background:
      linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent), color-mix(in srgb, var(--bg) 70%, transparent)),
      image-set(
        url("assets/chat-empty.webp") type("image/webp"),
        url("assets/chat-empty.jpg") type("image/jpeg")
      ) center / cover no-repeat;
  }
}
.chat-empty-illus::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--grad-subtle);
  opacity: 0.35;
  pointer-events: none;
}
.chat-empty-svg {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  opacity: 0.92;
  filter: drop-shadow(0 2px 8px color-mix(in srgb, var(--text) 35%, transparent));
}
.chat-empty p {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px dashed var(--border);
}
.chat-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}
.sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.sidebar-empty.hidden { display: none; }
.btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
  border-radius: 10px;
}

.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
}
.chat-active-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
}
.group-channel-sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.group-channel-sidebar.hidden { display: none !important; }
.gch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #888);
}
.gch-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.gch-head-hint {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.3;
}
.gch-manage-foot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 12px);
  margin: 8px 6px 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--blue-dim);
  color: var(--accent, var(--accent));
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.gch-manage-foot-btn:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-style: solid;
}
.group-channel-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 6px;
}
.gch-category {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted, #888);
  padding: 8px 8px 4px;
  letter-spacing: 0.02em;
}
.gch-channel {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text, #ccc);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  min-width: 0;
}
.gch-channel-label {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
}
.gch-channel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gch-channel-unread {
  flex-shrink: 0;
  margin-left: 6px;
  min-width: 18px;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  border-radius: 9px;
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent, #5db89a);
  background: color-mix(in srgb, var(--accent, #5db89a) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent, #5db89a) 28%, transparent);
}
.gch-channel.active .gch-channel-unread {
  opacity: 0.45;
  font-weight: 600;
}
.gch-channel:hover { background: var(--blue-dim); }
.gch-channel.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent, var(--accent));
  font-weight: 600;
  border-left-color: var(--accent, var(--green));
}
.gch-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--text) 45%, transparent);
}
.gch-backdrop.visible { display: block; }
.gch-manage-dialog {
  width: min(420px, 92vw);
  max-width: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0;
  background: var(--surface);
  color: var(--text);
}
.gch-manage-dialog[open] {
  display: flex;
  flex-direction: column;
}
.gch-manage-dialog::backdrop { background: color-mix(in srgb, var(--text) 35%, transparent); }
.gch-manage-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.gch-manage-body {
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gch-manage-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
}
.gch-manage-alert {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.45;
}
.gch-manage-alert.hidden { display: none; }
.gch-manage-alert.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.gch-manage-alert.is-warning {
  background: rgba(234, 179, 8, 0.14);
  color: #ca8a04;
  border: 1px solid rgba(234, 179, 8, 0.4);
}
.gch-manage-alert.is-success {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.35);
}
.gch-manage-foot + .gch-manage-alert,
.gch-manage-alert {
  margin: 0 16px 10px;
}
.gch-mode-tabs {
  display: flex;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
}
.gch-mode-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.gch-mode-tab:active { transform: scale(0.98); }
.gch-mode-tab-create {
  border: 2px solid rgba(22, 163, 74, 0.35);
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}
.gch-mode-tab-create:hover:not(.active) {
  background: rgba(22, 163, 74, 0.18);
  border-color: rgba(22, 163, 74, 0.5);
}
.gch-mode-tab-create.active {
  border-color: #16a34a;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  box-shadow: 0 3px 12px rgba(22, 163, 74, 0.4);
}
.gch-mode-tab-edit {
  border: 2px solid rgba(234, 88, 12, 0.35);
  background: rgba(234, 88, 12, 0.1);
  color: #c2410c;
}
.gch-mode-tab-edit:hover:not(.active) {
  background: rgba(234, 88, 12, 0.18);
  border-color: rgba(234, 88, 12, 0.5);
}
.gch-mode-tab-edit.active {
  border-color: #ea580c;
  background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
  color: #fff;
  box-shadow: 0 3px 12px rgba(234, 88, 12, 0.4);
}
.gch-mode-tab-edit.active .gch-rename-tag {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.gch-mode-tab-categories {
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--blue-dim);
  color: #4f46e5;
}
.gch-mode-tab-categories:hover:not(.active) {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}
.gch-mode-tab-categories.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 40%, transparent);
}
.gch-category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gch-category-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface, color-mix(in srgb, var(--text) 2%, transparent));
}
.gch-cat-rename {
  flex: 1 1 120px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  font-size: 0.85rem;
}
.gch-cat-rename:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.gch-cat-default-tag { font-size: 0.75rem; white-space: nowrap; }
.gch-sidebar-tip {
  margin: 10px 8px 6px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--text-muted, #888);
  background: var(--blue-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.gch-sidebar-status {
  margin: 8px 8px 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.45;
  font-weight: 600;
}
.gch-sidebar-status.is-success {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  border: 1px solid rgba(22, 163, 74, 0.35);
}
.gch-sidebar-status.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}
.gch-sidebar-status.is-warning {
  background: rgba(234, 179, 8, 0.14);
  color: #ca8a04;
  border: 1px solid rgba(234, 179, 8, 0.4);
}
.gch-empty-mark { font-weight: 400; opacity: 0.75; }
.gch-category-create-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}
.gch-category-create-inline input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  font-size: 0.85rem;
}
.gch-category-create-inline .btn-primary {
  flex-shrink: 0;
  padding: 9px 14px;
  font-size: 0.82rem;
}
.gch-category-item-default {
  justify-content: space-between;
}
.gch-cat-name { font-weight: 600; font-size: 0.85rem; }
.gch-manage-row select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  font-size: 0.85rem;
}
.gch-manage-row select:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.gch-category-tip {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--blue-dim);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  font-size: 0.78rem;
  line-height: 1.5;
}
.gch-category-tip strong { color: var(--text); font-size: 0.82rem; }
.gch-category-tip p { margin: 6px 0 0; }
.gch-category-tip p:first-of-type { margin-top: 4px; }
.gch-save-create {
  background: linear-gradient(135deg, #22c55e, #16a34a) !important;
  border-color: #16a34a !important;
}
.gch-save-edit {
  background: linear-gradient(135deg, #fb923c, #ea580c) !important;
  border-color: #ea580c !important;
}
.gch-mode-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gch-mode-panel.hidden { display: none; }
.gch-manage-row label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.gch-manage-row label .muted { font-weight: 400; font-size: 0.75rem; }
.gch-rename-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--blue-dim);
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 600;
}
.gch-manage-row input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
}
.gch-manage-row input:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.gch-manage-row textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 72px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
}
.gch-manage-row textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px var(--blue-dim);
}
.gch-clear-notif {
  align-self: flex-start;
  margin-top: 4px;
  padding: 4px 10px;
  font-size: 0.75rem;
}
.gch-manage-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.gch-permission-row { gap: 6px; }
.gch-permission-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}
.gch-permission-label input { width: auto; margin: 0; }
.gch-permission-hint { margin: 0; font-size: 0.75rem; line-height: 1.4; }
.gch-delete-row { gap: 6px; margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--border); }
.gch-delete-hint { margin: 0; font-size: 0.75rem; line-height: 1.4; }
.btn-danger-outline {
  align-self: flex-start;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger-outline:hover { background: rgba(239, 68, 68, 0.16); }
.gch-lock { font-size: 0.75rem; opacity: 0.85; flex-shrink: 0; }
.channel-readonly-banner { background: rgba(255, 193, 7, 0.12); border-color: rgba(255, 193, 7, 0.35); }
@media (max-width: 1100px) {
  .chat-active-body { position: relative; }
  .group-channel-sidebar:not(.hidden) {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(260px, 78vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px color-mix(in srgb, var(--text) 28%, transparent);
  }
  .group-channel-sidebar.channel-drawer-open {
    transform: translateX(0);
  }
  .group-member-panel { display: none !important; }
}
@media (min-width: 1101px) {
  #btn-toggle-channels { display: none !important; }
  .gch-backdrop { display: none !important; }
  /* Keep member sidebar visible on wide screens; do not let other rules hide it. */
  .group-member-panel:not(.hidden) {
    display: flex !important;
  }
}
@media (max-width: 900px) {
  .group-channel-sidebar:not(.hidden) {
    width: min(240px, 85vw);
  }
}
.chat-main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.group-member-panel {
  width: 220px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.group-member-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px;
  flex-shrink: 0;
}
.group-member-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}
.group-member-view-all {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 8px 4px;
  min-height: 36px;
  white-space: nowrap;
  border-radius: 8px;
  transition: background var(--transition-fast);
}
.group-member-view-all:hover { background: var(--surface2); text-decoration: none; }
.group-member-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 6px;
  align-content: start;
}
.group-member-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 28px 8px;
  font-size: 0.78rem;
}
.group-member-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px 2px;
  border-radius: 10px;
  color: inherit;
  min-width: 0;
}
.group-member-item:hover { background: var(--surface2); }
.group-member-item .name {
  font-size: 0.62rem;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.avatar-with-status {
  position: relative;
  display: inline-flex;
  line-height: 0;
}
.avatar-with-status.online::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 10px;
  height: 10px;
  background: #34b97a;
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-sizing: border-box;
}
/* ── Right side drawer dialogs (members / share / edit) ── */
.side-drawer-dialog {
  width: min(400px, 92vw);
  height: 100%;
  max-height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0;
  border: none;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  box-shadow: -10px 0 36px color-mix(in srgb, var(--text) 18%, transparent);
  overflow: hidden;
  animation: none;
}
.side-drawer-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: sideDrawerIn 0.24s ease;
}
@keyframes sideDrawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.side-drawer-dialog::backdrop {
  background: color-mix(in srgb, var(--text) 35%, transparent);
  backdrop-filter: none;
}
.side-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.side-drawer-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.side-drawer-head-text { min-width: 0; flex: 1; }
.side-drawer-head .muted { margin: 4px 0 0; font-size: 0.82rem; }
.side-drawer-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.side-drawer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
}
.side-drawer-foot {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.group-members-dialog {
  width: min(360px, 90vw);
  overflow: visible;
}
.group-members-dialog[open] {
  display: flex;
  flex-direction: column;
}
.group-members-dialog::backdrop { background: color-mix(in srgb, var(--text) 35%, transparent); }
.group-members-dialog-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.group-members-dialog-head h3 { margin: 0; font-size: 1rem; flex-shrink: 0; }
.group-members-danger-foot {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px dashed rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.04);
}
.group-members-danger-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
}
.group-members-danger-foot .btn-members-action {
  width: 100%;
  justify-content: center;
  padding: 8px 12px;
}
.btn-members-action {
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-members-action:hover { background: var(--surface); }
.btn-members-leave { color: #f87171; border-color: rgba(239, 68, 68, 0.35); background: rgba(239, 68, 68, 0.08); }
.btn-members-leave:hover { background: rgba(239, 68, 68, 0.14); }
.btn-members-disband { color: #fb923c; border-color: rgba(251, 146, 60, 0.35); background: rgba(251, 146, 60, 0.08); }
.btn-members-disband:hover { background: rgba(251, 146, 60, 0.14); }
.group-members-dialog-head .btn-ghost { flex-shrink: 0; margin-left: 2px; }
.group-members-full-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.group-members-full-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}
.group-members-full-list li:hover { background: var(--surface2); }
.group-members-full-list .meta { flex: 1; min-width: 0; }
.group-members-full-list .uname {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-members-full-list .status {
  font-size: 0.72rem;
  color: var(--muted);
}
.group-members-full-list .status.online { color: var(--green); }
.group-members-full-list .status.muted-ban { color: #e67e22; }
.group-members-full-list .role-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 500;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent, var(--accent));
  vertical-align: middle;
}
.group-members-full-list li[data-role="owner"] .role-tag {
  background: rgba(255, 193, 7, 0.2);
  color: #d4a017;
}
.group-member-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 6px !important;
  pointer-events: none;
}
.group-member-divider::before,
.group-member-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.group-member-divider span {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.member-action-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.member-action-btn:hover { background: var(--surface2); color: var(--text); }
#group-member-action-menu.member-action-menu {
  position: fixed;
  z-index: 100000;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--text) 18%, transparent);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
#group-member-action-menu.member-action-menu.hidden { display: none !important; }
.member-action-item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}
.member-action-item:hover { background: var(--surface2); }
.member-action-item.danger { color: #e74c3c; }
.group-mute-dialog {
  width: min(320px, 90vw);
  border: none;
  border-radius: 16px;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
}
.group-mute-dialog::backdrop { background: color-mix(in srgb, var(--text) 35%, transparent); }
.group-mute-dialog h3 { margin: 0 0 6px; font-size: 1rem; }
.mute-duration-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}
.mute-duration-grid .btn-ghost {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.msg-date-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--sp-md) 0;
  flex-shrink: 0;
}
.msg-date-divider span {
  padding: 4px 14px;
  border-radius: var(--radius-full);
  background: var(--surface2);
  color: var(--muted);
  font-size: var(--font-xs);
  font-weight: 500;
  border: 1px solid var(--border);
}

/* Notification bar */
.notification-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: var(--sp-sm) var(--sp-md);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border-left: 3px solid #f59e0b;
  font-size: var(--font-sm);
  flex-shrink: 0;
}
.notification-icon { font-size: 1rem; flex-shrink: 0; }
.notification-label {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}
.notification-text {
  flex: 1;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}
.notification-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  flex-shrink: 0;
}
.notification-close:hover { color: var(--text); }

/* Description bar */
.description-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: var(--sp-sm) var(--sp-md);
  padding: var(--sp-sm) var(--sp-lg);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border-left: 3px solid var(--blue);
  font-size: var(--font-sm);
  flex-shrink: 0;
  opacity: 0.9;
}
.description-icon { font-size: 0.95rem; flex-shrink: 0; margin-top: 1px; }
.description-label {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--blue-dim);
  color: var(--blue);
}
.description-text {
  flex: 1;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

/* Group online badge */
.group-online-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--green);
  background: var(--green-dim);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-call {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--green-dim);
  color: var(--green);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-call:hover { background: rgba(52, 185, 122, 0.22); transform: scale(1.05); }

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  min-height: 0;
}
.msg-load-older {
  flex-shrink: 0;
  text-align: center;
  padding: 6px 12px;
  font-size: var(--font-xs);
  color: var(--muted);
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-bottom: 1px solid var(--border);
}
.msg-load-older.hidden { display: none; }

.typing-indicator {
  flex-shrink: 0;
  padding: 2px 16px 6px;
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1.2em;
}
.typing-indicator.hidden { display: none !important; }

.msg.msg-sending { opacity: 0.72; }
.msg.msg-failed { outline: 1px solid rgba(239, 68, 68, 0.45); }
.msg-retry-btn {
  margin-top: 6px;
  border: none;
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}
.msg-retry-btn:hover { background: rgba(239, 68, 68, 0.2); }
.msg-send-hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin-left: 4px;
}
.msg-send-hint.failed { color: #f87171; }

.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
  transition: box-shadow 0.15s ease;
}
.msg.msg-new {
  animation: msgSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@media (hover: hover) and (pointer: fine) {
  .msg {
    transition: box-shadow 0.15s ease;
  }
  .msg-avatar {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  .msg-avatar:hover {
    transform: scale(1.06);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--accent) 30%, transparent);
  }
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: flex-end;
  border: 2px solid var(--border-hover);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 15%, transparent);
  transition: box-shadow 0.2s ease;
}
.msg-wrap {
  display: grid;
  column-gap: 8px;
  row-gap: 4px;
  max-width: 80%;
}
.msg-wrap.in {
  grid-template-columns: 36px minmax(0, max-content);
  grid-template-areas:
    "meta ."
    "avatar bubble"
    ". time";
  align-self: flex-start;
}
.msg-wrap.out {
  grid-template-columns: minmax(0, max-content) 36px;
  grid-template-areas:
    "bubble avatar"
    "time .";
  align-self: flex-end;
  justify-self: end;
}
.msg-wrap.msg-new {
  animation: msgSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.msg-wrap .msg-meta {
  grid-area: meta;
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  max-width: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-wrap .msg-avatar-slot {
  grid-area: avatar;
  align-self: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-wrap .msg-bubble-col {
  grid-area: bubble;
  min-width: 0;
}
.msg-wrap .time-row {
  grid-area: time;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
}
.msg-wrap.in .time-row { padding-left: 44px; }
.msg-wrap.out .time-row {
  justify-content: flex-end;
  padding-right: 44px;
}
.msg-wrap .msg {
  max-width: 100%;
}
.msg-wrap .time { font-size: 0.62rem; color: var(--muted); }
.msg-wrap .read-status { font-size: 0.62rem; color: var(--green); }
.msg.in {
  align-self: flex-start;
  background: var(--bubble-in, var(--surface2));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.msg.out {
  align-self: flex-end;
  background: var(--bubble-out, var(--grad));
  color: var(--on-accent);
  box-shadow: var(--shadow-md);
}
.msg.out:hover {
  box-shadow: var(--shadow-lg);
}

.share-friend-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.share-friend-scroll {
  max-height: none;
  min-height: 120px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface2);
}
.share-friend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  flex-wrap: nowrap;
}
.share-friend-item:hover { background: rgba(255, 255, 255, 0.04); }
.share-friend-item input {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--green);
}
.share-friend-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.share-friend-avatar .avatar,
.share-friend-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.share-friend-name {
  font-weight: 600;
  font-size: 0.88rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
  max-width: 38%;
}
.share-friend-id {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.share-friend-id-only {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: none;
}
.share-friend-status {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}
.share-friend-status.online {
  color: var(--green);
  background: var(--green-dim);
}
.share-empty { padding: 24px 12px; text-align: center; }

dialog.share-dialog {
  overflow: hidden;
}
.share-dialog-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--grad-subtle);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.share-dialog-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grad);
  opacity: 0.22;
  pointer-events: none;
}
.share-dialog-hero-icon {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.share-dialog-hero-text {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}
.share-invite-section {
  margin: 0 0 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--grad-subtle);
  border: 1px solid color-mix(in srgb, var(--blue) 22%, var(--border));
}
.share-invite-label { font-size: 0.9rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.share-invite-hint { margin: 0 0 12px; font-size: 0.78rem; line-height: 1.45; }
.share-invite-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.78rem;
}
.btn-copy-invite-large {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 13px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--blue) 35%, transparent);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease, filter 0.12s ease;
}
.btn-copy-invite-large:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--blue) 45%, transparent);
}
.btn-copy-invite-large:active:not(:disabled) { transform: translateY(0); }
.btn-copy-invite-large:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-copy-invite-large.copied {
  background: linear-gradient(135deg, var(--green), color-mix(in srgb, var(--green) 80%, #000));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--green) 35%, transparent);
}
.share-regen-btn { margin-top: 10px; font-size: 0.78rem; padding: 8px 10px; width: 100%; }
.share-section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.72rem;
}
.share-section-divider::before,
.share-section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.invite-landing {
  display: none;
  flex: 1;
  min-width: 0;
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(24px);
  text-align: left;
  overflow: hidden;
  box-shadow: 0 32px 80px color-mix(in srgb, var(--text) 45%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  flex-direction: column;
}
.login-shell.has-invite .invite-landing:not(.hidden) {
  display: flex;
}
.invite-landing.hidden { display: none !important; }
.invite-landing-cover {
  height: 156px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  padding: 0 28px 16px;
  background: var(--grad-subtle) center/cover no-repeat;
  border-bottom: none;
  position: relative;
}
.invite-landing-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--text) 8%, transparent) 0%,
    color-mix(in srgb, var(--text) 42%, transparent) 100%
  );
  pointer-events: none;
}
.invite-landing-cover .invite-landing-label {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 10px color-mix(in srgb, var(--text) 45%, transparent);
}
.invite-landing-cover.has-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grad);
  opacity: 0.12;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.invite-landing-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 28px 28px;
  position: relative;
  z-index: 1;
  min-height: 0;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.invite-landing-head {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-top: -42px;
  margin-bottom: 14px;
  position: relative;
  z-index: 2;
}
.invite-landing-info {
  min-width: 0;
  flex: 1;
  padding-bottom: 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 42px;
}
.invite-landing-avatar {
  width: 84px;
  height: 84px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  background: var(--surface2);
  border: 4px solid color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--text) 22%, transparent);
  overflow: hidden;
}
.invite-landing-avatar .group-avatar,
.invite-landing-avatar .group-avatar-img {
  width: 100% !important;
  height: 100% !important;
  border-radius: 14px !important;
  object-fit: cover;
}
.invite-landing h2 {
  margin: 0 0 6px;
  padding-top: 0;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.3;
  word-break: break-word;
}
.invite-landing-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  min-height: 2.4em;
}
.invite-landing.is-loading .invite-landing-avatar {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: inviteShimmer 1.2s ease-in-out infinite;
  color: transparent;
}
.invite-landing.is-loading .invite-landing-cover {
  background: var(--surface2);
}
@keyframes inviteShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.invite-landing-desc-wrap {
  flex: 1;
  margin: 18px 0 16px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  min-height: 96px;
}
.invite-landing-desc {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.invite-landing-desc.is-empty {
  color: var(--muted);
  font-style: italic;
}
.invite-landing-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--blue);
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--blue-dim);
  border: 1px dashed color-mix(in srgb, var(--blue) 30%, var(--border));
  flex-shrink: 0;
}

.group-share-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface2) 90%, transparent);
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.group-share-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--grad-subtle);
  opacity: 0;
  transition: opacity 0.15s;
}
.group-share-card:hover {
  border-color: color-mix(in srgb, var(--blue) 35%, var(--border));
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.group-share-card:hover::before { opacity: 1; }
.group-share-icon {
  position: relative;
  z-index: 1;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--grad-subtle);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.group-share-body,
.group-share-arrow { position: relative; z-index: 1; }
.group-share-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.group-share-title { font-weight: 700; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-share-sub { font-size: 0.72rem; color: var(--muted); }
.group-share-arrow { color: var(--muted); font-size: 1.2rem; }

.conv-online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
  vertical-align: middle;
}

.hall-lock { margin-left: 6px; opacity: 0.8; }

.msg-recall-link {
  border: none;
  background: transparent;
  color: rgba(248, 113, 113, 0.8);
  font-size: 0.62rem;
  cursor: pointer;
  padding: 0 2px;
}
.msg.out .msg-recall-link { color: rgba(255, 200, 200, 0.85); }
.msg-recall-link:hover { text-decoration: underline; }
.msg.recalled { opacity: 0.45; font-style: italic; }
.msg.can-recall { cursor: context-menu; }

.msg-context-menu {
  position: fixed;
  z-index: 1000;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.msg-recall-btn {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--red);
  padding: 10px 18px;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.msg-recall-btn:hover { background: rgba(248, 113, 113, 0.08); }

/* ── Send Bar ── */
.send-bar {
  display: flex;
  gap: 8px;
  margin: var(--sp-sm) var(--sp-md) var(--sp-md);
  padding: var(--sp-sm) var(--sp-md);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface2) 90%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px color-mix(in srgb, var(--text) 12%, transparent);
  align-items: flex-end;
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.send-bar:focus-within {
  border-color: color-mix(in srgb, var(--green) 55%, var(--border));
  box-shadow: 0 0 0 2px var(--green-dim), 0 6px 28px color-mix(in srgb, var(--text) 14%, transparent);
}

.send-bar:has(#msg-input:focus) {
  background: var(--surface3);
}
.hidden-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

.send-bar button, .send-bar label {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: var(--transition-fast);
}
.send-bar button:hover, .send-bar label:hover {
  background: var(--surface3);
}

#msg-input {
  flex: 1;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.92rem;
  outline: none;
  min-height: 38px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
  font-family: inherit;
}
#msg-input::placeholder { color: var(--muted); opacity: 0.85; }

.emoji-picker {
  position: absolute;
  bottom: 60px;
  left: 16px;
  right: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 -4px 20px color-mix(in srgb, var(--text) 30%, transparent);
  z-index: 100;
}
.emoji-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 1.3rem;
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.emoji-btn:hover { background: rgba(255,255,255,0.08); }

.mention-picker {
  position: absolute;
  bottom: 60px;
  left: 16px;
  width: min(280px, calc(100% - 32px));
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 -4px 24px color-mix(in srgb, var(--text) 35%, transparent);
  z-index: 101;
  overflow: hidden;
}
.mention-picker-head {
  padding: 8px 12px;
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--green);
  border-bottom: 1px solid var(--border);
  background: var(--blue-dim);
}
.mention-picker-list {
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0;
  padding: 4px;
}
.mention-picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: var(--font-sm);
  transition: background var(--transition-fast);
}
.mention-picker-item:hover,
.mention-picker-item.active {
  background: var(--blue-dim);
}
.mention-all-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}
.msg-mention {
  color: var(--green);
  font-weight: 600;
  background: var(--green-dim);
  padding: 0 3px;
  border-radius: 4px;
}
.msg.in .msg-mention { color: #8ed629; }
#btn-mention {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--green);
}

#btn-send {
  background: var(--grad);
  color: #fff;
  width: auto;
  min-width: 52px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--green) 28%, transparent);
}
#btn-send:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--green) 38%, transparent);
}
#btn-send:active {
  transform: scale(0.95);
}

/* ── Upload Bar ── */
.upload-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  background: var(--blue-dim);
  border-top: 1px solid var(--border);
}
.upload-bar-track { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.upload-bar-fill { height: 100%; width: 0%; background: var(--blue); border-radius: 2px; transition: width 0.15s; }
.upload-label { font-size: 0.72rem; color: var(--muted); white-space: nowrap; }

/* ── File Messages ── */
.msg.file-msg-wrap { max-width: 100%; }
.file-msg { display: flex; gap: 10px; align-items: flex-start; }
.file-icon { font-size: 1.3rem; line-height: 1; }
.file-name { font-weight: 600; font-size: 0.82rem; word-break: break-all; }
.file-size { font-size: 0.7rem; color: var(--muted); margin: 2px 0 6px; }
.file-dl {
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  background: var(--blue-dim);
  color: var(--blue);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.15s;
}
.file-dl:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.msg.out .file-dl { background: rgba(255, 255, 255, 0.18); color: #fff; }
.file-preview { display: block; max-width: 200px; max-height: 160px; margin-top: 6px; border-radius: 8px; cursor: pointer; }

/* ── Dialogs ── */
dialog {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-xl);
  color: var(--text);
  max-width: 360px;
  width: 90%;
  margin: 0;
}

/* Viewport-centered modals (not right drawers / not command palette / not hall drawers) */
dialog:not(.side-drawer-dialog):not(.global-search-dialog):not(.hall-drawer):not(.hall-modal) {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
dialog:not(.side-drawer-dialog):not(.global-search-dialog):not(.hall-drawer):not(.hall-modal)[open] {
  animation: modalCenterIn 0.24s cubic-bezier(0.34, 1.1, 0.64, 1);
}
@keyframes modalCenterIn {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 14px)) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

dialog::backdrop {
  background: color-mix(in srgb, var(--text) 50%, transparent);
  backdrop-filter: blur(8px);
}

@keyframes dialogSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
/* legacy alias kept for any non-dialog overlays */

dialog h3 {
  font-size: var(--font-lg);
  font-weight: 700;
  margin-bottom: var(--sp-lg);
  color: var(--text);
}

dialog input[type="text"],
dialog input[type="password"],
dialog input[type="number"],
dialog textarea,
dialog select {
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 0 var(--sp-lg);
  font-size: var(--font-md);
  transition: var(--transition-fast);
  width: 100%;
  box-sizing: border-box;
  margin: 10px 0;
}
dialog textarea {
  height: auto;
  min-height: 80px;
  padding: var(--sp-md) var(--sp-lg);
}
dialog input:focus,
dialog textarea:focus,
dialog select:focus {
  border-color: var(--blue);
  box-shadow: var(--shadow-glow);
  outline: none;
}

dialog button[type="submit"],
dialog .btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  border: none;
  height: 44px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  font-size: var(--font-md);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
dialog button[type="submit"]:hover,
dialog .btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ── Group Hall Dialog (only visible when [open]) ── */
dialog.hall-dialog {
  max-width: 720px;
  width: 90vw;
  max-height: 80vh;
  padding: 0;
}
dialog.hall-dialog[open] {
  display: flex;
  flex-direction: column;
}

.hall-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.hall-header .hall-title { margin: 0; font-size: var(--font-xl); font-weight: 700; }

.hall-search {
  position: relative;
  margin: 10px 16px;
  flex-shrink: 0;
}
.hall-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.6;
  pointer-events: none;
}
.hall-search input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: var(--font-md);
  transition: var(--transition-fast);
  outline: none;
}
.hall-search input:focus {
  border-color: var(--blue);
  box-shadow: var(--shadow-glow);
}

.hall-cats {
  display: flex;
  gap: var(--sp-sm);
  padding: 0 16px;
  margin-bottom: var(--sp-lg);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.hall-cat-btn {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: var(--font-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.hall-cat-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.hall-cat-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

#hall-count { padding: 0 20px 6px; font-size: 0.78rem; flex-shrink: 0; }

/* 核心：三列网格卡片（参考 KOOK 发现页） */
.hall-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-lg);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 55vh;
  /* top padding keeps hall cards clear of the scroll edge */
  padding: 10px 16px 16px;
  flex: 1;
}

/* 单个群聊卡片 */
.hall-card {
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-fast);
  animation: cardFadeUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  position: relative;
}
.hall-card:nth-child(1) { animation-delay: 0s; }
.hall-card:nth-child(2) { animation-delay: 0.05s; }
.hall-card:nth-child(3) { animation-delay: 0.1s; }
.hall-card:nth-child(4) { animation-delay: 0.15s; }
.hall-card:nth-child(5) { animation-delay: 0.2s; }
.hall-card:nth-child(6) { animation-delay: 0.25s; }
.hall-card:nth-child(7) { animation-delay: 0.3s; }
.hall-card:nth-child(8) { animation-delay: 0.35s; }
.hall-card:hover {
  box-shadow: 0 12px 32px color-mix(in srgb, var(--text) 28%, transparent), var(--shadow-glow);
  border-color: color-mix(in srgb, var(--green) 25%, transparent);
}
.hall-card:hover .hall-card-hover { opacity: 1; }

.hall-card-banner {
  aspect-ratio: 272 / 100;
  position: relative;
  overflow: hidden;
}
.hall-card-banner-pattern {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--text) 35%, transparent) 100%),
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.04) 0, rgba(255,255,255,0.04) 1px, transparent 1px, transparent 8px);
  pointer-events: none;
}

.hall-card-body {
  padding: 0 var(--sp-lg) var(--sp-md);
  margin-top: -18px;
  position: relative;
  display: flex;
  gap: var(--sp-sm);
  align-items: flex-start;
}
.hall-card-icon { flex-shrink: 0; }
.hall-card-info { flex: 1; min-width: 0; }

.hall-card-name {
  font-size: var(--font-md);
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  line-height: 1.3;
}
.hall-card-name .text-gradient {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hall-card-tag {
  font-size: var(--font-xs);
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
  font-weight: 500;
  display: inline-block;
  margin-bottom: var(--sp-xs);
}

.hall-card-desc {
  font-size: var(--font-sm);
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: var(--sp-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}

.hall-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-xs);
  color: var(--muted);
  gap: var(--sp-sm);
}
.hall-card-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-wrap: wrap;
}
.hall-online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px color-mix(in srgb, var(--green) 60%, transparent);
  flex-shrink: 0;
}
.hall-card-lock {
  opacity: 0.85;
  font-size: var(--font-sm);
}
.hall-card-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 20%;
  background: linear-gradient(180deg, transparent 30%, color-mix(in srgb, var(--text) 55%, transparent) 100%);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}
.hall-card-hover span {
  padding: 8px 20px;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-size: var(--font-sm);
  font-weight: 600;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--green) 40%, transparent);
}
.hall-card-join { display: none; }

@media (max-width: 1100px) {
  .sidebar-wrap { width: min(260px, 32vw); }
}
@media (max-width: 900px) {
  /* 手机竖屏：列表与聊天全屏切换（不依赖 JS 的 mobile-mode 类） */
  .sidebar-wrap {
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
  }
  .main-layout {
    flex-direction: column;
  }
  .main-layout:not(.mobile-chat-active) .chat-panel {
    display: none !important;
  }
  .main-layout:not(.mobile-chat-active) .sidebar {
    flex: 1;
    width: 100%;
    max-height: none;
    min-height: 0;
    border-right: none;
    border-bottom: none;
  }
  .main-layout.mobile-chat-active .sidebar-wrap {
    display: none;
  }
  .main-layout.mobile-chat-active .chat-panel {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    min-height: 0;
    width: 100%;
  }
}

@media (max-width: 900px) {
  .hall-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Language Switch ── */
.lang-switch select {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.72rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.lang-switch select:focus { border-color: var(--blue); }
.login-lang { text-align: center; margin-bottom: 16px; }
.login-lang select { padding: 6px 12px; font-size: 0.82rem; color: var(--text); }

/* ── Toast ── */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 999;
  font-size: 0.85rem;
  overflow: hidden;
}

/* ── Voice Call Overlay ── */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  backdrop-filter: blur(24px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: callFadeIn 0.3s ease;
}
@keyframes callFadeIn { from { opacity: 0; } to { opacity: 1; } }

.call-card { text-align: center; padding: 40px; max-width: 300px; width: 90%; }
.call-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 18px;
  box-shadow: 0 0 40px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: callPulse 2s ease-in-out infinite;
}
@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 15%, transparent); }
  50% { box-shadow: 0 0 50px color-mix(in srgb, var(--accent) 40%, transparent); }
}
.call-name { font-size: 1.3rem; font-weight: 700; color: #fff; margin-bottom: 6px; }
.call-status { font-size: 0.85rem; color: var(--muted); }
.call-timer { font-size: 1rem; color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; justify-content: center; gap: 20px; margin-top: 28px; }
.call-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-btn:hover { transform: scale(1.08); }
.call-btn-accept { background: var(--green); color: #fff; box-shadow: 0 4px 16px rgba(52, 185, 122, 0.35); }
.call-btn-reject, .call-btn-hangup { background: var(--red); color: #fff; box-shadow: 0 4px 16px rgba(248, 113, 113, 0.35); }
.call-btn-mute { background: rgba(255,255,255,0.12); color: #fff; }
.call-btn-mute.muted { background: var(--red); }

/* ── Sidebar Badges ── */
.conv-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--blue);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  flex-shrink: 0;
}
.conv-badge-placeholder {
  visibility: hidden;
  min-width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
}

/* ── Mobile ── */
.btn-mobile-back {
  display: none;
  width: 40px;
  height: 40px;
  margin-right: 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.btn-mobile-back:hover { background: var(--surface2); }

.btn-mobile-channels {
  display: none;
  width: auto;
  min-width: 40px;
  height: 36px;
  margin-right: 4px;
  padding: 0 10px;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface2) 90%, transparent);
  color: var(--accent, var(--accent));
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.btn-mobile-channels-icon {
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.85;
}
.btn-mobile-channels-label {
  letter-spacing: 0.02em;
}
.btn-mobile-channels:not(.hidden) { display: inline-flex; }
.btn-mobile-channels.channel-drawer-open {
  background: var(--blue-dim);
  border-color: color-mix(in srgb, var(--blue) 45%, var(--border));
  color: var(--green);
}
.topbar-title-tappable {
  cursor: pointer;
}
.topbar-title-tappable::after {
  content: ' ▾';
  font-size: 0.75em;
  opacity: 0.55;
  font-weight: 400;
}
.topbar-title-tappable:active { opacity: 0.85; }

@media (max-width: 900px) {
  .topbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    height: auto;
    min-height: 48px;
    max-height: none;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
    gap: 6px;
    backdrop-filter: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
    gap: 2px;
  }
  .topbar-center { display: none; }
  .btn-hall-prominent {
    font-size: 0.72rem;
    padding: 6px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(42vw, 160px);
  }
  .topbar-right {
    gap: 4px;
    font-size: 0.68rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
    max-width: 58vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar-right::-webkit-scrollbar { display: none; }
  .topbar:not(.mobile-chat-topbar) .lang-switch:has(#theme-select) {
    display: inline-flex;
  }
  .topbar:not(.mobile-chat-topbar) #theme-select { max-width: 92px; font-size: 0.62rem; }
  .mobile-only-theme { display: flex !important; }
  .topbar:not(.mobile-chat-topbar) #btn-global-search { display: none; }
  .topbar-btn { height: 36px; min-width: 36px; padding: 0 8px; flex-shrink: 0; }
  .topbar-btn .tb-text { display: none; }
  .topbar-more-trigger .tb-text { display: inline; }
  .topbar-divider { display: none; }
  .topbar-lang select { font-size: 0.62rem; padding: 2px 4px; max-width: 64px; }
  .conn-status { display: none; }
  .topbar .btn-ghost { width: 32px; height: 32px; font-size: 0.9rem; }
  .topbar-icon-btn { width: 30px; height: 30px; font-size: 0.9rem; }

  .sidebar-global-search {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* 进入聊天后的顶栏：左返回+子频道 / 中标题 / 右操作 */
  .topbar.mobile-chat-topbar {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .topbar.mobile-chat-topbar .topbar-left {
    flex: 0 0 auto;
    max-width: none;
  }
  .topbar.mobile-chat-topbar .topbar-center {
    display: flex !important;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    text-align: left;
    align-items: flex-start;
    padding: 0 2px;
  }
  .topbar.mobile-chat-topbar .topbar-chat-title {
    font-size: 0.92rem;
    text-align: left;
    width: 100%;
  }
  .topbar.mobile-chat-topbar .topbar-chat-sub {
    font-size: 0.68rem;
    text-align: left;
    width: 100%;
  }
  .topbar.mobile-chat-topbar .topbar-right {
    flex: 0 0 auto;
    max-width: none;
    overflow: visible;
    gap: 2px;
  }
  .topbar.mobile-chat-topbar .topbar-tools { display: none; }
  .topbar.mobile-chat-topbar .topbar-divider { display: none; }
  .topbar.mobile-chat-topbar .topbar-chat-actions .tb-text { display: none !important; }
  .topbar.mobile-chat-topbar #btn-share-group,
  .topbar.mobile-chat-topbar #btn-voice-call { display: none !important; }
  .topbar.mobile-chat-topbar .topbar-btn {
    min-width: 36px;
    width: 36px;
    height: 36px;
    padding: 0;
  }
  .topbar.mobile-chat-topbar .btn-mobile-back {
    display: inline-flex;
  }
  .topbar.mobile-chat-topbar .btn-hall-prominent {
    display: none;
  }
  .topbar.mobile-chat-topbar .topbar-lang,
  .topbar.mobile-chat-topbar .conn-status {
    display: none;
  }

  .group-channel-sidebar:not(.hidden) {
    width: min(280px, 86vw);
    z-index: 120;
  }
  .gch-backdrop.visible {
    z-index: 110;
  }
  .chat-main-column {
    min-width: 0;
    width: 100%;
  }

  .sidebar-tab { padding: 12px 8px; font-size: 0.86rem; }
  .conv-item { padding: 11px 12px; }
  .chat-active {
    flex: 1;
    min-height: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .send-bar {
    margin: 6px 8px;
    margin-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    padding: 6px 8px;
    gap: 4px;
    flex-shrink: 0;
  }
  .send-bar button, .send-bar label {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }
  #msg-input { padding: 8px 6px; font-size: 16px; min-width: 0; }
  #btn-send {
    padding: 0 10px;
    font-size: 0.78rem;
    min-width: 46px;
    height: 34px;
    flex-shrink: 0;
  }
  .messages { padding: 10px 12px; }
  .msg-wrap { max-width: 86%; }
  .msg { max-width: 86%; }
  .emoji-picker, .mention-picker {
    left: 8px;
    right: 8px;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
  dialog.hall-dialog { max-height: 88vh; width: 96%; }
  dialog.hall-dialog[open] { display: flex; }
  .hall-search { margin: 8px 12px; }
  .hall-cats { padding: 0 12px; margin-bottom: var(--sp-md); }
  .hall-grid { grid-template-columns: 1fr; padding: var(--sp-xs) 12px 12px; }
  .call-card { padding: 24px; }
  .call-avatar { width: 60px; height: 60px; font-size: 1.5rem; }
  .call-name { font-size: 1.1rem; }
  .call-btn { width: 46px; height: 46px; font-size: 1.2rem; }
}

/* Pending screenshot/image before send */
.pending-image-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.pending-image-bar.hidden { display: none; }
.pending-image-bar img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.pending-image-meta {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Image lightbox */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: color-mix(in srgb, var(--text) 88%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.image-lightbox.hidden { display: none; }
.image-lightbox img {
  max-width: min(96vw, 1200px);
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}
.lightbox-actions { margin-top: 16px; }

/* Screenshot — WeChat/QQ style region picker */
.screenshot-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  background: #000;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}
.screenshot-overlay.hidden { display: none; }
#screenshot-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.screenshot-selection {
  position: absolute;
  border: 2px solid #07c160;
  background: transparent;
  box-shadow: 0 0 0 9999px color-mix(in srgb, var(--text) 55%, transparent);
  pointer-events: none;
  z-index: 1;
}
.screenshot-selection.hidden { display: none; }
.screenshot-size {
  position: absolute;
  left: 0;
  top: -26px;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 72%, transparent);
  color: #fff;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  white-space: nowrap;
}
.screenshot-float-bar {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 168px;
  box-sizing: border-box;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(30, 30, 30, 0.94);
  box-shadow: 0 4px 20px color-mix(in srgb, var(--text) 45%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.screenshot-float-bar.hidden { display: none; }
.ss-btn {
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.ss-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ss-btn:not(:disabled):hover { transform: translateY(-1px); }
.ss-btn-ok {
  background: #07c160;
  color: #fff;
}
.ss-btn-cancel {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.screenshot-tip {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 2;
  padding: 8px 16px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--text) 65%, transparent);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  pointer-events: none;
}
.file-preview { cursor: zoom-in; }

/* ── Friend System ── */
.friend-request-item {
  background: var(--blue-dim) !important;
  border-left: 2px solid var(--blue);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  flex-direction: column !important;
  gap: 6px;
  padding: var(--sp-sm) var(--sp-md) !important;
}
.friend-req-label {
  font-size: 10px;
  color: var(--blue);
  background: var(--blue-dim);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}
.friend-req-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.friend-req-actions button {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.btn-friend-accept {
  background: var(--green);
  color: #fff;
}
.btn-friend-accept:hover {
  background: #2ea06a;
}
.btn-friend-reject {
  background: var(--surface3);
  color: var(--muted);
}
.btn-friend-reject:hover {
  background: var(--red);
  color: #fff;
}
.non-friend-banner {
  padding: 8px 16px;
  background: rgba(232, 121, 58, 0.08);
  border-top: 1px solid rgba(232, 121, 58, 0.2);
  border-bottom: 1px solid rgba(232, 121, 58, 0.2);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #e65100;
}
.non-friend-banner .add-friend-btn {
  margin-left: auto;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ── Add Friend Bar ── */
.add-friend-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-sm);
  border-bottom: none;
}
.add-friend-bar .search-icon {
  color: var(--muted);
  font-size: var(--font-sm);
  flex-shrink: 0;
}
.add-friend-bar input {
  flex: 1;
  height: 38px;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 var(--sp-sm);
  color: var(--text);
  font-size: var(--font-sm);
  outline: none;
  transition: all var(--transition-fast);
}
.add-friend-bar input::placeholder {
  color: var(--muted);
}
.add-friend-bar input:focus {
  border-color: var(--blue);
  box-shadow: var(--shadow-glow);
}
.add-friend-btn-sm {
  width: 38px;
  height: 38px;
  background: var(--blue-dim);
  color: var(--blue);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0;
  font-size: var(--font-md);
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.add-friend-btn-sm:hover {
  background: var(--blue);
  color: #fff;
}

/* ── User Search Result Card ── */
#add-friend-result {
  padding: 0 8px;
}
.search-result-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 4px 0;
  background: var(--surface2);
  border: 1px solid var(--blue-dim);
  border-radius: 12px;
}
.search-result-card.error {
  border-color: rgba(226, 91, 91, 0.3);
  background: rgba(226, 91, 91, 0.06);
}
.search-result-card .search-icon {
  font-size: 16px;
  color: var(--red);
}
.search-result-card .search-text {
  color: var(--red);
  font-size: 13px;
}
.search-user-info {
  flex: 1;
  min-width: 0;
}
.search-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-user-status {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--muted); }
.btn-add-result {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-add-result:hover { background: #2a7ae8; }
.btn-add-result:disabled {
  background: var(--surface3);
  color: var(--muted);
  cursor: default;
}

/* ── Tab Badge ── */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  border-radius: 10px;
  line-height: 1;
}
.tab-badge-alert { background: #e25b5b; }
.tab-badge-unread { background: var(--blue); }
.tab-badge.hidden { display: none; }

/* ── Delete Friend Button ── */
.btn-friend-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.45;
  transition: opacity 0.15s, color 0.15s;
}
.conv-item:hover .btn-friend-delete,
.btn-friend-delete:focus-visible { opacity: 1; }
.btn-friend-delete:hover,
.btn-friend-delete:focus-visible { color: var(--red); }

/* ── Message Links (high contrast vs bubble/accent) ── */
.msg-link {
  color: var(--link);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
  text-underline-offset: 3px;
  cursor: pointer;
  word-break: break-all;
  background: var(--link-bg);
  border-radius: 4px;
  padding: 1px 5px;
  margin: 0 1px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: filter 0.15s ease, background 0.15s ease;
}
.msg-link:hover {
  filter: brightness(1.12);
  background: color-mix(in srgb, var(--link) 28%, transparent);
}
/* Outgoing green/gold/orange bubbles: force light-on-dark / dark-on-gold contrast */
.msg.out .msg-link {
  color: var(--link-on-out);
  background: var(--link-on-out-bg);
  text-decoration-color: currentColor;
  text-shadow: none;
}
.msg.out .msg-link:hover {
  filter: brightness(1.05);
  background: color-mix(in srgb, var(--link-on-out-bg) 70%, var(--text));
}

/* ── Link Warning Dialog ── */
.link-warning-dialog {
  border: none;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 420px;
  width: 92%;
  box-shadow: 0 20px 60px color-mix(in srgb, var(--text) 50%, transparent);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.link-warning-dialog[open] {
  animation: dialogZoomIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dialogZoomIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.link-warning-dialog::backdrop {
  background: color-mix(in srgb, var(--text) 50%, transparent);
}
.link-warning-content {
  padding: 24px;
}
.link-warning-icon {
  font-size: 36px;
  text-align: center;
  margin-bottom: 8px;
}
.link-warning-content h3 {
  margin: 0 0 12px;
  font-size: 18px;
  text-align: center;
}
.link-warning-content p {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
}
.link-warning-content ul {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--muted);
}
.link-warning-content ul li {
  margin-bottom: 4px;
}
.link-url-display {
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--blue);
  word-break: break-all;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.link-warning-actions {
  display: flex;
  gap: 10px;
}
.link-warning-actions button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-link-cancel {
  background: var(--surface3);
  color: var(--muted);
}
.btn-link-cancel:hover {
  background: var(--border-hover);
}
.btn-link-confirm {
  background: var(--blue);
  color: #fff;
}
.btn-link-confirm:hover {
  background: #2a7ae8;
}

/* ── Enhanced Scrollbar ── */
.messages::-webkit-scrollbar {
  width: 6px;
}
.messages::-webkit-scrollbar-track {
  background: transparent;
}
.messages::-webkit-scrollbar-thumb {
  background: rgba(122, 133, 153, 0.25);
  border-radius: 3px;
}
.messages::-webkit-scrollbar-thumb:hover {
  background: rgba(122, 133, 153, 0.45);
}

/* ── Message Body Enhancement ── */
.msg .body {
  position: relative;
  z-index: 1;
  white-space: pre-wrap;
}
.msg.out .body {
  text-shadow: 0 1px 2px color-mix(in srgb, var(--text) 10%, transparent);
}



/* ── Sidebar Conv Items Hover ── */
/* .conv-item rules consolidated above */

/* ── Online Dot Pulse Animation ── */
.conv-online-dot {
  animation: onlinePulse 2s infinite;
}
@keyframes onlinePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(52, 185, 122, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(52, 185, 122, 0); }
}

/* ── Toast Slide Animation ── */
#toast {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#toast:not(.hidden) {
  animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-100%); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Chat Active Entrance ── */
.chat-active.chat-enter {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Message Link hover polish (merged into base .msg-link) ── */

/* ── Profile Dialog ── */
.profile-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.profile-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.profile-tab:hover { background: var(--blue-dim); color: var(--text); }
.profile-tab.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--blue);
}
.profile-panel.hidden { display: none; }
.device-panel-hint { margin: 0 0 12px; font-size: 0.82rem; }
.device-session-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.device-session-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.device-session-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.device-session-main { flex: 1; min-width: 0; }
.device-session-name {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.device-session-meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.device-badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
}
.device-badge.online { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.device-badge.current { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--blue); }
.device-session-revoke {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: transparent;
  color: #f87171;
  cursor: pointer;
}
.device-session-revoke:hover { background: rgba(248, 113, 113, 0.1); }
.device-session-loading { font-size: 0.85rem; color: var(--muted); padding: 8px 0; }

/* Login password visibility */
.password-field .password-input-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}
.password-field .password-input-wrap input {
  flex: 1;
  padding-right: 40px;
}
.btn-pw-toggle {
  position: absolute;
  right: 4px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.55;
  border-radius: 8px;
}
.btn-pw-toggle:hover { opacity: 1; background: color-mix(in srgb, var(--text) 5%, transparent); }

.conn-status .status-dot.connecting {
  background: #fbbf24;
  animation: pulse-dot 1.2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.profile-dialog.side-drawer-dialog .side-drawer-body label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}

.notification-dialog-hint {
  margin: 0 0 12px;
  font-size: 0.82rem;
  line-height: 1.45;
}
#notification-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  resize: vertical;
  min-height: 120px;
  outline: none;
  font-family: inherit;
}
#notification-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent);
}
.notification-dialog-actions {
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.profile-data-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.profile-data-hint {
  font-size: 0.75rem;
  line-height: 1.45;
  margin: 0 0 10px;
  color: var(--muted);
}
.btn-clear-local {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.08);
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-clear-local:hover {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.55);
}

.msg-highlight {
  animation: msgFlash 2.2s ease-in-out;
  border-radius: 16px;
}
@keyframes msgFlash {
  0%, 100% {
    box-shadow: 0 0 0 0 transparent;
  }
  12%, 38%, 64% {
    box-shadow: 0 0 0 3px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 50%, transparent);
  }
  25%, 51% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
  }
}
mark.search-hit {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}

.sidebar-global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 10px 12px 4px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface2) 85%, transparent);
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.sidebar-global-search .search-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: var(--grad-subtle);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-global-search:hover .search-icon {
  border-color: color-mix(in srgb, var(--blue) 35%, var(--border));
  background: var(--blue-dim);
}
.sidebar-global-search:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.main-layout.mobile-chat-active .sidebar-global-search {
  display: none;
}

.global-search-dialog {
  border: none;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: min(72vh, 640px);
  box-shadow: 0 20px 60px color-mix(in srgb, var(--text) 22%, transparent);
  position: fixed;
  top: clamp(76px, 11vh, 168px);
  left: 50%;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
  margin: 0;
}
.global-search-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: searchModalIn 0.2s ease;
}
@keyframes searchModalIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.global-search-dialog::backdrop {
  background: color-mix(in srgb, var(--text) 45%, transparent);
  backdrop-filter: blur(6px);
}
.global-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.global-search-header input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.global-search-hint {
  margin: 8px 16px 0;
  font-size: 0.75rem;
}
.global-search-results {
  padding: 8px 8px 12px;
  max-height: min(58vh, 480px);
  overflow-y: auto;
  overflow-x: hidden;
}
.global-search-empty,
.global-search-loading {
  text-align: center;
  padding: 28px 16px;
  font-size: 0.9rem;
}
.global-search-item {
  display: flex;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.global-search-item:hover,
.global-search-item.active {
  background: var(--surface2);
}
.global-search-item.active {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -2px;
}
.global-search-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.global-search-item-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.global-search-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.global-search-item-meta {
  font-size: 0.72rem;
  color: var(--muted);
}
.global-search-item-preview {
  font-size: 0.82rem;
  color: var(--text);
  opacity: 0.88;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hall-card-banner.has-cover .hall-card-banner-pattern {
  background: linear-gradient(to top, color-mix(in srgb, var(--text) 35%, transparent) 0%, transparent 50%);
}

.group-cover-pick {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  margin: 8px 0 4px;
}
.group-cover-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  border: 2px dashed var(--border);
  background: var(--surface) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
}
.group-cover-pick:hover .group-cover-preview { border-color: var(--accent); }
.group-cover-placeholder {
  font-size: 0.85rem;
  color: var(--muted);
}
.group-cover-preview.has-image .group-cover-placeholder { display: none; }
.group-cover-tip {
  font-size: 0.72rem;
  margin: 0 0 8px;
}
.group-cover-edit-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  background: var(--surface-variant, var(--surface)) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}
.profile-avatar-pick {
  position: relative;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}
.profile-avatar-pick:hover .profile-avatar-preview {
  box-shadow: 0 0 0 2px var(--accent);
}
.profile-avatar-camera {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--text) 20%, transparent);
}
.profile-avatar-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}
.profile-emoji-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}
.btn-link {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
}
.group-avatar-img {
  border-radius: 50%;
  object-fit: cover;
}
.profile-avatar-preview {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}


@keyframes cardFadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Toast Progress Bar ── */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--blue);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  animation: toastProgress 3.2s linear forwards;
}
@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ── Accessibility: Reduced Motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Edit Group Dialog ── */
.edit-group-dialog.side-drawer-dialog .side-drawer-body label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}
.edit-group-dialog .muted { color: var(--muted); font-weight: normal; }
.edit-group-admin-hint {
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--blue-dim);
}
.btn-clear-group-password {
  width: 100%;
  margin: 4px 0 10px;
  justify-content: center;
}
.edit-group-dialog input:disabled,
.edit-group-dialog select:disabled,
.edit-group-dialog textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Global Responsive (all pages & dialogs) ── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

@media (max-width: 1200px) {
  .hall-grid { grid-template-columns: repeat(2, 1fr); }
  .msg-wrap, .msg { max-width: min(78%, 520px); }
}

@media (max-width: 1100px) {
  .topbar-tools .topbar-btn .tb-text { display: none; }
  .topbar-chat-actions .topbar-btn .tb-text { display: inline; }
  .topbar {
    grid-template-columns: minmax(72px, 1fr) auto minmax(72px, 1fr);
    padding: 0 12px;
    gap: 6px;
  }
  .topbar-center { max-width: min(300px, 36vw); }
  .topbar-right {
    overflow-x: auto;
    overflow-y: visible;
    max-width: min(54vw, 440px);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .topbar-right::-webkit-scrollbar { display: none; }
  .topbar-lang select { max-width: 96px; }
  #theme-select { max-width: 108px; }
  .btn-hall-prominent { padding: 7px 12px; font-size: 0.76rem; }
  .side-drawer-dialog { width: min(400px, 96vw); }
  dialog.hall-dialog { width: 96vw; max-height: 88vh; }
  .global-search-dialog { width: min(520px, 96vw); max-height: 88vh; }
  .messages { padding: 12px 14px; }
  .send-bar { margin: 8px 12px; }
}

@media (max-width: 900px) {
  .sidebar-toggle { display: none !important; }
  .main-layout.sidebar-collapsed .sidebar-wrap { width: 100%; }
  .main-layout.sidebar-collapsed .sidebar {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  #view-login {
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }
  .login-shell.has-invite {
    flex-direction: column;
    max-width: 100%;
    gap: 16px;
  }
  .login-shell.has-invite .login-card {
    flex: none;
    max-width: 100%;
    width: 100%;
  }
  .login-card {
    padding: 28px 20px 24px;
    border-radius: 16px;
    max-width: 100%;
  }
  .login-card h1 { font-size: 1.25rem; }
  .login-sub { font-size: 0.78rem; margin-bottom: 18px; }
  .invite-landing { border-radius: 16px; }
  .invite-landing-body { padding: 0 18px 18px; }
  .invite-landing-cover { height: 120px; padding: 0 18px 12px; }
  .invite-landing-head { margin-top: -34px; gap: 12px; margin-bottom: 12px; }
  .invite-landing-avatar { width: 68px; height: 68px; font-size: 1.6rem; border-radius: 16px; border-width: 3px; }
  .invite-landing-info { min-height: 34px; padding-bottom: 2px; }
  .invite-landing h2 { font-size: 1.2rem; margin-bottom: 4px; }
  .invite-landing-desc-wrap { min-height: 56px; padding: 12px; margin-top: 14px; }
  input[type="text"],
  input[type="password"],
  input[type="search"],
  #msg-input,
  .add-friend-bar input,
  .search-box input {
    font-size: max(16px, 0.9rem);
  }
  .side-drawer-dialog,
  dialog.share-dialog.side-drawer-dialog,
  dialog.profile-dialog.side-drawer-dialog,
  dialog.edit-group-dialog.side-drawer-dialog,
  dialog.notification-dialog.side-drawer-dialog,
  .group-members-dialog.side-drawer-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
  }
  dialog:not(.side-drawer-dialog):not(.hall-dialog):not(.global-search-dialog):not(.link-warning-dialog) {
    width: min(360px, 94vw);
    padding: 20px 16px;
    max-width: calc(100vw - 24px);
  }
  .global-search-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
    display: flex;
    flex-direction: column;
    animation: none;
  }
  .global-search-dialog[open] {
    display: flex;
    animation: none;
  }
  .global-search-results {
    max-height: none;
    flex: 1;
    min-height: 0;
  }
  dialog.hall-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .hall-header { padding: 12px 14px; }
  .hall-header .hall-title { font-size: 1.05rem; }
  .hall-grid { max-height: none; flex: 1; grid-template-columns: 1fr; }
  .gch-manage-dialog { width: min(420px, 94vw); max-width: calc(100vw - 20px); }
  .link-warning-dialog { width: min(360px, 92vw); max-width: calc(100vw - 24px); }
  .link-warning-content { padding: 18px 16px; }
  .link-warning-actions { flex-direction: column; gap: 8px; }
  .link-warning-actions button { width: 100%; }
  .notification-bar,
  .description-bar {
    margin: 6px 8px;
    padding: 8px 10px;
    font-size: 0.78rem;
  }
  .non-friend-banner {
    flex-wrap: wrap;
    padding: 8px 10px;
    font-size: 11px;
    gap: 6px;
  }
  .non-friend-banner .add-friend-btn { margin-left: 0; }
  .pending-image-bar { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .pending-image-bar img { width: 56px; height: 56px; }
  .pending-image-meta { flex-wrap: wrap; }
  .upload-bar { padding: 8px 10px; }
  .msg-load-older { padding: 6px 10px; font-size: 0.78rem; }
  .group-share-card { padding: 10px 12px; }
  .group-share-title { white-space: normal; }
  .file-preview { max-width: min(200px, 72vw); max-height: 140px; }
  .image-lightbox { padding: 12px; padding-top: max(12px, env(safe-area-inset-top)); }
  .image-lightbox img { max-height: 72vh; }
  .lightbox-close { top: max(12px, env(safe-area-inset-top)); right: 12px; }
  .screenshot-float-bar {
    width: auto;
    max-width: calc(100vw - 24px);
    flex-wrap: wrap;
    justify-content: center;
  }
  .screenshot-tip {
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    font-size: 12px;
    max-width: calc(100vw - 32px);
    text-align: center;
  }
  .toast,
  #toast {
    top: max(12px, env(safe-area-inset-top, 0px));
    left: 12px;
    right: 12px;
    transform: none;
    max-width: none;
    text-align: center;
  }
  #toast:not(.hidden) {
    animation: toastSlideInMobile 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  @keyframes toastSlideInMobile {
    from { opacity: 0; transform: translateY(-100%); }
    to { opacity: 1; transform: translateY(0); }
  }
  .sidebar-head { padding: 8px 10px; }
  .search-box { margin-bottom: 6px; }
  .search-box input { min-width: 0; }
  .conv-item .conv-name { font-size: 0.88rem; }
  .profile-avatar-section { flex-direction: column; align-items: center; text-align: center; }
  .profile-avatar-meta { align-items: center; }
  .side-drawer-foot.dialog-actions,
  .notification-dialog-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .mute-duration-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .share-invite-section { padding: 12px; }
  .global-search-header { padding: 12px; }
  .global-search-hint { margin: 6px 12px 0; }
}

@media (max-width: 480px) {
  .topbar { padding-left: 8px; padding-right: 8px; }
  .topbar-btn { min-height: 44px; min-width: 44px; height: auto; padding: 0 10px; }
  .topbar-icon-btn { width: 44px; height: 44px; font-size: 0.95rem; }
  .tabs { margin-bottom: 14px; }
  .tab { padding: 8px; font-size: 0.8rem; }
  .hall-cat-btn { padding: 5px 10px; font-size: 0.72rem; }
  .hall-search { margin: 8px 10px; }
  .dialog-actions { flex-direction: column-reverse; align-items: stretch; }
  .dialog-actions button,
  .dialog-actions .btn-primary,
  .dialog-actions .btn-ghost { width: 100%; }
  .side-drawer-foot { flex-direction: column-reverse; align-items: stretch; }
  .side-drawer-foot button { width: 100%; }
  .gch-manage-foot { flex-direction: column-reverse; align-items: stretch; }
  .gch-manage-foot button { width: 100%; }
  .msg-wrap, .msg { max-width: 92%; }
  .emoji-picker { max-height: 40vh; }
  .mention-picker { max-height: 40vh; width: calc(100% - 16px); left: 8px; right: 8px; }
  .global-search-item { padding: 8px 10px; gap: 8px; }
  .global-search-item-icon { width: 32px; height: 32px; font-size: 1rem; }
  #btn-send { min-width: 44px; min-height: 44px; padding: 0 12px; }
  .send-bar button { min-width: 44px; min-height: 44px; }
}
