/* ============================================================
   Starlit · QQ 式清晰骨架，角色主题负责氛围
   浅色 = 云白与 QQ 蓝；深色 = 静谧夜蓝
   ============================================================ */

:root {
  color-scheme: light;
  --font: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
          "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Songti SC", "STSong", "SimSun", Georgia, serif;

  --brand: #1687d9;
  --brand-2: #55afe8;
  --brand-deep: #0874bd;
  --brand-soft: rgba(22, 135, 217, .09);
  --brand-ring: rgba(22, 135, 217, .20);

  --bg: #eef1f5;
  --rail: rgba(248, 250, 252, .98);
  --pane: #ffffff;
  --chat: #f5f7fa;
  --chat-bg-overlay: linear-gradient(rgba(245, 247, 250, .42), rgba(245, 247, 250, .42));
  --chat-custom-image: none;
  --text: #20242c;
  --text-1: var(--text);
  --text-2: #606875;
  --text-3: #7a8390;
  --line: rgba(35, 52, 72, .09);
  --line-strong: rgba(35, 52, 72, .16);
  --hover: rgba(40, 76, 110, .055);
  --active: rgba(22, 135, 217, .11);
  --active-line: rgba(22, 135, 217, .22);

  --bubble-in: #ffffff;
  --bubble-in-text: #20242c;
  --bubble-out: #087dcc;
  --bubble-out-text: #ffffff;

  --shadow-sm: 0 2px 8px rgba(32, 48, 64, .045);
  --shadow-md: 0 14px 34px -16px rgba(32, 48, 64, .20);
  --shadow-lg: 0 30px 80px -28px rgba(22, 34, 48, .32);

  --glass: rgba(255, 255, 255, .94);
  --glass-border: rgba(255, 255, 255, .82);
  --panel: rgba(255, 255, 255, .98);

  --danger: #df5367;
  --ok: #249c70;
  --warning: #c98b32;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --ease: cubic-bezier(.22, .75, .25, 1);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --brand: #69bfff;
  --brand-2: #91d0ff;
  --brand-deep: #8bcaff;
  --brand-soft: rgba(82, 174, 239, .14);
  --brand-ring: rgba(105, 191, 255, .25);

  --bg: #10141b;
  --rail: rgba(24, 29, 38, .98);
  --pane: #1a2029;
  --chat: #141a22;
  --chat-bg-overlay: linear-gradient(rgba(20, 26, 34, .66), rgba(20, 26, 34, .66));
  --text: #edf1f6;
  --text-1: var(--text);
  --text-2: #acb6c2;
  --text-3: #8e9aa8;
  --line: rgba(255, 255, 255, .075);
  --line-strong: rgba(255, 255, 255, .14);
  --hover: rgba(255, 255, 255, .055);
  --active: rgba(82, 174, 239, .16);
  --active-line: rgba(105, 191, 255, .28);

  --bubble-in: #252d38;
  --bubble-in-text: #edf1f6;
  --bubble-out: #126a9f;
  --bubble-out-text: #ffffff;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .18);
  --shadow-md: 0 16px 38px -16px rgba(0, 0, 0, .56);
  --shadow-lg: 0 34px 90px -28px rgba(0, 0, 0, .78);

  --glass: rgba(26, 32, 41, .94);
  --glass-border: rgba(255, 255, 255, .09);
  --panel: rgba(28, 35, 45, .98);

  --danger: #ff8192;
  --ok: #4dcc9b;
  --warning: #e6b565;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

input, textarea { outline: none; }

::selection { background: var(--brand-ring); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*:hover::-webkit-scrollbar-thumb { background: rgba(120, 140, 168, .28); background-clip: padding-box; }
*:hover::-webkit-scrollbar-thumb:hover { background: rgba(120, 140, 168, .45); background-clip: padding-box; }

.hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

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

/* ------------------------------------------------ 连接页 */

.connect {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 18% 12%, rgba(102, 190, 255, .28), transparent 70%),
    radial-gradient(55% 50% at 82% 88%, rgba(255, 150, 205, .20), transparent 70%),
    linear-gradient(150deg, #eef5ff 0%, #f7f3ff 52%, #eef9ff 100%);
  overflow: hidden;
}

html[data-theme="dark"] .connect {
  background:
    radial-gradient(60% 50% at 18% 12%, rgba(70, 120, 255, .22), transparent 70%),
    radial-gradient(55% 50% at 82% 88%, rgba(190, 90, 255, .16), transparent 70%),
    linear-gradient(150deg, #080b12 0%, #0b0e18 100%);
}

.connect-sky { position: absolute; inset: 0; pointer-events: none; }

/* 登录页背景图（默认 23.png，用户可以自己换；换的图存在本机 localStorage）
   —— 上面再压一层半透明蒙层，保证卡片上的文字永远看得清 */
.connect-bg {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
.connect-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(150deg,
    rgba(238, 245, 255, .55) 0%,
    rgba(247, 243, 255, .42) 52%,
    rgba(238, 249, 255, .55) 100%);
}
html[data-theme="dark"] .connect-bg::after {
  background: linear-gradient(150deg,
    rgba(8, 11, 18, .62) 0%, rgba(11, 14, 24, .5) 100%);
}
.connect-bg-btn {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-3);
  background: rgba(255, 255, 255, .5);
  transition: color .14s ease, background .14s ease;
}
.connect-bg-btn svg { width: 13px; height: 13px; }
.connect-bg-btn:hover { color: var(--brand); background: var(--brand-soft); }
html[data-theme="dark"] .connect-bg-btn { background: rgba(255, 255, 255, .07); }

/* 登录页上的「我」的头像（QQ 头像 / 自定义头像都吃） */
.brand-avatar.has-img span { display: none; }
.brand-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.connect-sky i {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
  animation: float 14s ease-in-out infinite;
}
.connect-sky i:nth-child(1) { background: #8cc8ff; left: -80px; top: -90px; }
.connect-sky i:nth-child(2) { background: #ffc2e2; right: -60px; bottom: -120px; animation-delay: -5s; }
.connect-sky i:nth-child(3) { background: #b8ffef; left: 44%; top: 58%; width: 240px; height: 240px; animation-delay: -9s; opacity: .35; }
html[data-theme="dark"] .connect-sky i { opacity: .22; }

@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(18px, -24px, 0) scale(1.08); }
}

.connect-card {
  position: relative;
  width: min(392px, 100%);
  padding: 40px 34px 28px;
  border-radius: 24px;
  text-align: center;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
}

html[data-theme="dark"] .connect-card {
  background: rgba(22, 26, 36, .74);
  border-color: rgba(255, 255, 255, .08);
}

.brand-avatar {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #7fd0ff 0%, #5b8cff 46%, #a06bff 100%);
  box-shadow: 0 14px 34px -10px rgba(86, 128, 255, .55),
              inset 0 1px 0 rgba(255, 255, 255, .45);
}
.brand-avatar span {
  font-family: var(--serif);
  font-size: 40px;
  font-weight: 700;
  transform: translateY(-1px);
}
.brand-avatar .brand-dot {
  position: absolute;
  right: 4px;
  bottom: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ok);
  border: 3px solid #fff;
}
html[data-theme="dark"] .brand-avatar .brand-dot { border-color: #171b25; }

.connect-card h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: .06em;
  font-weight: 700;
}
.brand-sub {
  margin: 8px 0 24px;
  color: var(--text-3);
  font-size: 12.5px;
  letter-spacing: .1em;
}

.connect-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  margin-bottom: 20px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--brand-soft);
  border-radius: 999px;
}
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 var(--brand-ring);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(10, 157, 255, .35); }
  70% { box-shadow: 0 0 0 8px rgba(10, 157, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(10, 157, 255, 0); }
}
.connect-state.bad { color: var(--danger); background: rgba(240, 74, 74, .09); }
.connect-state.bad .pulse { background: var(--danger); animation: none; box-shadow: none; }

.primary {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
  letter-spacing: .08em;
  background: linear-gradient(135deg, #21adff, #0b7bff);
  box-shadow: 0 12px 24px -12px rgba(11, 123, 255, .75);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.primary:hover { filter: brightness(1.04); box-shadow: 0 14px 28px -12px rgba(11, 123, 255, .85); }
.primary:active { transform: translateY(1px) scale(.995); }

.token-row { margin-top: 18px; text-align: left; }
.token-row label { display: block; margin-bottom: 7px; font-size: 12px; color: var(--text-3); }
.token-input { display: flex; gap: 8px; }
.token-input input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, .6);
}
html[data-theme="dark"] .token-input input { background: rgba(255, 255, 255, .04); }
.token-input input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.token-input button {
  padding: 0 16px;
  border-radius: 10px;
  color: #fff;
  background: var(--brand);
  font-weight: 600;
}

.connect-tip {
  margin: 22px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-3);
}

/* ------------------------------------------------ 主框架 */

.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: 64px 292px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
}

.rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0 14px;
  background: var(--rail);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

html[data-theme="dark"] .rail { border-right-color: rgba(255, 255, 255, .06); }

.rail-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  margin-bottom: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(140deg, #6fc9ff, #5b8cff 55%, #9a6bff);
  box-shadow: 0 8px 18px -8px rgba(86, 128, 255, .6);
  user-select: none;
}

/* 头像右下角的在线状态点（和 QQ 一样） */
.presence-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 2;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--rail);
  background: #21c07a;
  transition: background .2s ease;
}
.presence-dot[data-p="qme"]       { background: #ff8a3d; }
.presence-dot[data-p="away"]      { background: #f5a623; }
.presence-dot[data-p="busy"]      { background: #f04a4a; }
.presence-dot[data-p="dnd"]       { background: #c0392b; }
.presence-dot[data-p="invisible"] { background: #98a3b4; }
.presence-dot[data-p="offline"]   { background: #6c7788; }

.rail-nav, .rail-foot { display: flex; flex-direction: column; gap: 6px; }
.rail-foot { margin-top: auto; }

.rail-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background .15s ease, color .15s ease;
}
.rail-btn svg { width: 21px; height: 21px; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.active { color: var(--brand); background: var(--brand-soft); }
.rail-btn.active::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 11px;
  bottom: 11px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}

/* 悬停提示 */
.rail-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 52px;
  top: 50%;
  transform: translateY(-50%) translateX(-4px);
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
  color: #fff;
  background: rgba(24, 30, 42, .9);
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
  z-index: 40;
}
.rail-btn[data-tip]:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }

html[data-theme="light"] .ic-sun { display: none; }
html[data-theme="dark"] .ic-moon { display: none; }

/* ------------------------------------------------ 会话列表 */

.list-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--pane);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
html[data-theme="dark"] .list-pane { border-right-color: rgba(255, 255, 255, .06); }

.list-head { padding: 16px 14px 12px; }

.me-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 12px;
}
.me-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 名字右侧的一小簇：在线状态胶囊 + 连接胶囊（顺序：状态在「已连接」左边）*/
.me-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  min-width: 0;
}
.me-meta .conn-chip { margin-left: 0; }

/* 在线状态胶囊（点它切换状态）*/
.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--text-2);
  background: var(--hover);
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.presence-chip:hover { background: var(--active); color: var(--text); }
.presence-chip svg { width: 13px; height: 13px; color: var(--text-2); }
.presence-chip span { overflow: hidden; text-overflow: ellipsis; }
/* 状态色（和头像状态点同一套配色）*/
.presence-chip[data-p="online"] svg    { color: #21c07a; }
.presence-chip[data-p="qme"] svg       { color: #ff8a3d; }
.presence-chip[data-p="away"] svg      { color: #f5a623; }
.presence-chip[data-p="busy"] svg      { color: #f04a4a; }
.presence-chip[data-p="dnd"] svg       { color: #c0392b; }
.presence-chip[data-p="invisible"] svg { color: #98a3b4; }
.presence-chip[data-p="offline"] svg   { color: #6c7788; }
.presence-chip[data-p="qme"] { color: var(--text); }
.conn-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--text-3);
  background: var(--hover);
  white-space: nowrap;
}
.conn-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.conn-chip.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(33, 192, 122, .12); }
.conn-chip.warn i { background: #f5a623; }
.conn-chip.bad i { background: var(--danger); }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  background: var(--hover);
  border: 1px solid transparent;
  transition: border-color .15s ease, background .15s ease;
}
.search-box:focus-within { border-color: var(--brand-ring); background: var(--pane); }
.search-box svg { width: 15px; height: 15px; color: var(--text-3); }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 12.5px;
}
.search-box input::placeholder { color: var(--text-3); }

.conv-list { flex: 1; overflow-y: auto; padding: 2px 8px 10px; }

.conv {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  text-align: left;
  transition: background .13s ease;
}
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); }
.conv.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}

.avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  user-select: none;
}
.rail-avatar { position: relative; overflow: hidden; }
.avatar > span, .rail-avatar > span { pointer-events: none; }
.avatar > img, .rail-avatar > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.avatar.has-img > span, .rail-avatar.has-img > span { visibility: hidden; }
.bot-avatar {
  background:
    radial-gradient(120% 120% at 22% 18%, rgba(255, 255, 255, .5), transparent 52%),
    linear-gradient(140deg, #ffb3d9 0%, #a48bff 54%, #6fa8ff 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}
.avatar.me-avatar {
  background: linear-gradient(140deg, #6fc9ff, #5b8cff 58%, #9a6bff);
}
/* 一眼情绪：头像右下角的晴/阴/雨。悬停才显示她本人那句心里话。 */
.mood-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  z-index: 2;
  pointer-events: auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}
.mood-dot.sun { background: #f5b73d; }
.mood-dot.cloud { background: #98a6b5; }
.mood-dot.rain { background: #6d8fd8; }

/* 情侣 / 专属关系 */
.bond-mark {
  position: absolute;
  top: 0;
  right: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #ff5f8f;
  color: #fff;
  font-style: normal;
  font-size: 9px;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--panel);
  z-index: 3;
  pointer-events: none;
}
.bond-chip {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  line-height: 16px;
  color: #b3184f;
  background: rgba(255, 95, 143, .14);
  border: 1px solid rgba(255, 95, 143, .3);
  white-space: nowrap;
}
body.dark .bond-chip, html[data-theme="dark"] .bond-chip {
  color: #ff9dba;
  background: rgba(255, 95, 143, .18);
}
/* 角色资料卡 */
.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.profile-avatar { width: 56px; height: 56px; font-size: 20px; }
.profile-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.profile-meta strong { font-size: 15px; }
.profile-meta span { font-size: 12px; opacity: .7; }
.profile-stats {
  font-size: 12px;
  opacity: .75;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(127, 127, 127, .07);
  margin-bottom: 12px;
}
.profile-bond { border-top: 1px solid rgba(127, 127, 127, .16); padding-top: 10px; }
.profile-bond-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.profile-bond-actions { margin: 8px 0; }
.btn-primary.danger { background: #e5484d; border-color: #e5484d; }

.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time { margin-left: auto; font-size: 10.5px; color: var(--text-3); flex: none; }
.conv-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.conv-preview {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-draft-label { color: var(--danger); font-weight: 500; }

.badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  background: #ff5b5b;
  box-shadow: 0 2px 6px -2px rgba(255, 70, 70, .6);
}
.badge.small {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  font-size: 9.5px;
}

.list-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 10.5px;
  color: var(--text-3);
  border-top: 1px solid var(--line);
}
html[data-theme="dark"] .list-foot { border-top-color: rgba(255, 255, 255, .06); }

/* ------------------------------------------------ 聊天区 */

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: row;
  min-width: 0;
  min-height: 0;
  background: var(--chat);
  overflow: hidden;
}
/* 聊天主区（群聊时会和右侧群面板并排） */
.chat-main {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
html[data-theme="dark"] .chat-pane {
  background:
    radial-gradient(80% 60% at 100% 0%, rgba(90, 100, 255, .12), transparent 60%),
    radial-gradient(70% 50% at 0% 100%, rgba(190, 80, 255, .08), transparent 65%),
    var(--chat);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 16px 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  z-index: 6;
}
html[data-theme="dark"] .chat-head { border-bottom-color: rgba(255, 255, 255, .06); }

.chat-title { min-width: 0; }
.name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 700;
}
.name-row #chatName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
}
.online-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(33, 192, 122, .12); }
.sub-row { margin-top: 2px; font-size: 11px; color: var(--text-3); }

.chat-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background .14s ease, color .14s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }

.back-btn { display: none; color: var(--text); }

.chat-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--pane);
  z-index: 5;
}
.chat-search svg { width: 15px; height: 15px; color: var(--text-3); }
.chat-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 13px;
}
.search-count { font-size: 11px; color: var(--text-3); white-space: nowrap; }

/* 消息区 */
.msg-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
  padding: 20px 24px 12px;
}
.msg-list { display: flex; flex-direction: column; }

.empty-state {
  margin: 12vh auto 0;
  max-width: 320px;
  text-align: center;
  color: var(--text-3);
  animation: fade-up .4s ease both;
}
.empty-state .empty-avatar {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 28px;
  color: #fff;
  background: linear-gradient(140deg, #ffb3d9, #a48bff 55%, #6fa8ff);
  box-shadow: 0 14px 30px -14px rgba(120, 110, 255, .6);
  overflow: hidden;
}
.empty-state .empty-avatar > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.empty-state .empty-avatar.has-img > span { visibility: hidden; }
.empty-state p { margin: 0 0 6px; font-size: 14px; color: var(--text-2); font-weight: 600; }
.empty-state > span { font-size: 11.5px; line-height: 1.7; }

.day-sep {
  align-self: center;
  margin: 14px 0 16px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--text-3);
  background: rgba(130, 147, 170, .09);
  user-select: none;
}

/* 「加载更早」提示条：渲染窗口只画最近一屏，更早的折叠在这里 */
.earlier-bar {
  align-self: center;
  margin: 6px 0 10px;
  padding: 4px 14px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 11px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  cursor: default;
  user-select: none;
  transition: background .15s ease;
}
button.earlier-bar { cursor: pointer; }
button.earlier-bar:hover { background: var(--brand-ring); }
button.earlier-bar:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
  margin-bottom: 8px;
  animation: msg-in .18s ease both;
}
.msg-row.out { flex-direction: row-reverse; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row .avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
  margin-top: 2px;
  cursor: default;
}

.msg-body {
  display: flex;
  flex-direction: column;
  max-width: min(66%, 620px);
  min-width: 0;
}
.msg-row.out .msg-body { align-items: flex-end; }

.bubble {
  position: relative;
  padding: 9px 13px;
  border-radius: var(--bubble-radius, 4px 12px 12px 12px);
  background: var(--bubble-bg, var(--bubble-in));
  color: var(--bubble-fg, var(--bubble-in-text));
  border: var(--bubble-border, 0);
  box-shadow: var(--bubble-shadow, var(--shadow-sm), inset 0 0 0 1px var(--line));
  backdrop-filter: var(--bubble-blur, none);
  -webkit-backdrop-filter: var(--bubble-blur, none);
  font-size: 14px;
  line-height: 1.68;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  transition: box-shadow .15s ease, background .15s ease;
}
.msg-row.out .bubble {
  border-radius: var(--bubble-radius-out, 12px 4px 12px 12px);
  background: var(--bubble-bg-out, var(--bubble-out));
  color: var(--bubble-fg-out, var(--bubble-out-text));
  border: var(--bubble-border-out, 0);
  box-shadow: var(--bubble-shadow-out, 0 6px 16px -8px rgba(11, 123, 255, .55));
  backdrop-filter: var(--bubble-blur-out, none);
  -webkit-backdrop-filter: var(--bubble-blur-out, none);
}

/* ------------------------------------------------ 气泡皮肤
   每套皮肤只设置 CSS 变量，媒体/表情气泡的样式由下方规则覆盖。 */

/* 尖角 */
html[data-bubble-in="tail"] { --bubble-radius: 14px; }
html[data-bubble-out="tail"] { --bubble-radius-out: 14px; }
html[data-bubble-in="tail"] .msg-row.in .bubble:not(.sticker):not(.media)::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 11px;
  width: 10px;
  height: 14px;
  background: var(--bubble-in);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
}
html[data-bubble-out="tail"] .msg-row.out .bubble:not(.sticker):not(.media)::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 11px;
  width: 10px;
  height: 14px;
  background: #0b82ff;
  clip-path: polygon(0 0, 0 100%, 100% 50%);
}

/* 玻璃 */
html[data-bubble-in="glass"] {
  --bubble-bg: rgba(255, 255, 255, .55);
  --bubble-fg: var(--text);
  --bubble-border: 1px solid rgba(255, 255, 255, .8);
  --bubble-shadow: 0 10px 26px -16px rgba(20, 50, 100, .5);
  --bubble-blur: blur(14px) saturate(160%);
  --bubble-radius: 16px;
}
html[data-theme="dark"][data-bubble-in="glass"] {
  --bubble-bg: rgba(255, 255, 255, .075);
  --bubble-border: 1px solid rgba(255, 255, 255, .14);
  --bubble-shadow: 0 12px 30px -18px rgba(0, 0, 0, .8);
}
html[data-bubble-out="glass"] {
  --bubble-bg-out: linear-gradient(135deg, rgba(26, 168, 255, .86), rgba(96, 110, 255, .82));
  --bubble-fg-out: #fff;
  --bubble-border-out: 1px solid rgba(255, 255, 255, .3);
  --bubble-shadow-out: 0 10px 28px -14px rgba(40, 90, 255, .65);
  --bubble-blur-out: blur(14px) saturate(160%);
  --bubble-radius-out: 16px;
}

/* 奶油手账 */
html[data-bubble-in="cream"] {
  --bubble-bg: #fffaf0;
  --bubble-fg: #5a4632;
  --bubble-border: 1px dashed rgba(206, 160, 104, .55);
  --bubble-shadow: 0 3px 10px -6px rgba(160, 120, 70, .4);
  --bubble-radius: 4px 16px 16px 16px;
}
html[data-theme="dark"][data-bubble-in="cream"] {
  --bubble-bg: rgba(255, 244, 226, .07);
  --bubble-fg: #f0e4d4;
  --bubble-border: 1px dashed rgba(255, 210, 160, .25);
  --bubble-shadow: 0 4px 12px -8px rgba(0, 0, 0, .7);
}
html[data-bubble-out="cream"] {
  --bubble-bg-out: linear-gradient(135deg, #ffd9e7, #ffc0d6);
  --bubble-fg-out: #5b2b3d;
  --bubble-border-out: 1px solid rgba(255, 150, 185, .55);
  --bubble-shadow-out: 0 6px 16px -10px rgba(230, 110, 160, .55);
  --bubble-radius-out: 16px 4px 16px 16px;
}
html[data-theme="dark"][data-bubble-out="cream"] {
  --bubble-bg-out: linear-gradient(135deg, #6f3550, #9a4568);
  --bubble-fg-out: #ffe9f0;
  --bubble-border-out: 1px solid rgba(255, 160, 200, .25);
  --bubble-shadow-out: 0 8px 20px -12px rgba(0, 0, 0, .7);
}

/* 线框 */
html[data-bubble-in="line"] {
  --bubble-bg: transparent;
  --bubble-fg: var(--text);
  --bubble-border: 1.5px solid var(--line-strong);
  --bubble-shadow: none;
  --bubble-radius: 12px;
}
html[data-bubble-out="line"] {
  --bubble-bg-out: var(--brand-soft);
  --bubble-fg-out: #0b6fd6;
  --bubble-border-out: 1.5px solid rgba(10, 157, 255, .6);
  --bubble-shadow-out: none;
  --bubble-radius-out: 12px;
}
html[data-theme="dark"][data-bubble-out="line"] {
  --bubble-fg-out: #cfe2ff;
  --bubble-bg-out: rgba(91, 147, 255, .14);
  --bubble-border-out: 1.5px solid rgba(91, 147, 255, .55);
}

/* 霓虹 */
html[data-bubble-in="neon"] {
  --bubble-bg: linear-gradient(135deg, rgba(120, 200, 255, .16), rgba(170, 120, 255, .16));
  --bubble-fg: var(--text);
  --bubble-border: 1px solid rgba(120, 160, 255, .35);
  --bubble-shadow: 0 0 22px -8px rgba(100, 150, 255, .5);
  --bubble-radius: 14px;
}
html[data-theme="dark"][data-bubble-in="neon"] {
  --bubble-bg: linear-gradient(135deg, rgba(70, 150, 255, .18), rgba(150, 80, 255, .18));
  --bubble-border: 1px solid rgba(130, 170, 255, .3);
  --bubble-shadow: 0 0 26px -10px rgba(100, 150, 255, .55);
}
html[data-bubble-out="neon"] {
  --bubble-bg-out: linear-gradient(135deg, #ff5fa8, #8a5cff);
  --bubble-fg-out: #fff;
  --bubble-border-out: 1px solid rgba(255, 255, 255, .22);
  --bubble-shadow-out: 0 0 26px -8px rgba(180, 90, 255, .7);
  --bubble-radius-out: 14px;
}

/* 花边 */
html[data-bubble-in="lace"] {
  --bubble-bg: #fffafc;
  --bubble-fg: #4a3b52;
  --bubble-border: 2px dotted rgba(255, 160, 200, .8);
  --bubble-shadow: 0 0 0 3px rgba(255, 255, 255, .9),
                   0 0 0 4px rgba(255, 205, 225, .55),
                   0 6px 16px -12px rgba(220, 120, 170, .6);
  --bubble-radius: 18px;
}
html[data-theme="dark"][data-bubble-in="lace"] {
  --bubble-bg: rgba(255, 220, 240, .06);
  --bubble-fg: #f6e6ef;
  --bubble-border: 2px dotted rgba(255, 150, 200, .5);
  --bubble-shadow: 0 0 0 3px rgba(255, 255, 255, .02),
                   0 0 0 4px rgba(255, 150, 200, .18);
}
html[data-bubble-out="lace"] {
  --bubble-bg-out: linear-gradient(135deg, #ffd6e8, #ffc0dd);
  --bubble-fg-out: #6b2b47;
  --bubble-border-out: 2px dotted rgba(255, 255, 255, .9);
  --bubble-shadow-out: 0 0 0 3px rgba(255, 190, 220, .35),
                       0 8px 18px -12px rgba(230, 100, 160, .6);
  --bubble-radius-out: 18px;
}
html[data-theme="dark"][data-bubble-out="lace"] {
  --bubble-bg-out: linear-gradient(135deg, #6d3550, #944866);
  --bubble-fg-out: #ffeaf3;
  --bubble-border-out: 2px dotted rgba(255, 210, 230, .35);
}

/* 云朵 */
html[data-bubble-in="cloud"] {
  --bubble-bg: linear-gradient(135deg, #eef7ff, #f6f0ff);
  --bubble-fg: #35405a;
  --bubble-border: 1px solid rgba(160, 190, 255, .35);
  --bubble-shadow: 0 8px 20px -14px rgba(90, 130, 220, .5);
  --bubble-radius: 22px 22px 22px 6px;
}
html[data-theme="dark"][data-bubble-in="cloud"] {
  --bubble-bg: linear-gradient(135deg, rgba(70, 130, 220, .13), rgba(150, 110, 240, .12));
  --bubble-fg: #e8edf6;
  --bubble-border: 1px solid rgba(150, 180, 255, .22);
  --bubble-shadow: 0 8px 22px -16px rgba(0, 0, 0, .8);
}
html[data-bubble-out="cloud"] {
  --bubble-bg-out: linear-gradient(135deg, #b8e3ff, #c9c0ff);
  --bubble-fg-out: #2b3350;
  --bubble-border-out: 1px solid rgba(255, 255, 255, .7);
  --bubble-shadow-out: 0 8px 22px -14px rgba(110, 140, 255, .6);
  --bubble-radius-out: 22px 22px 6px 22px;
}
html[data-theme="dark"][data-bubble-out="cloud"] {
  --bubble-bg-out: linear-gradient(135deg, #3e5f9e, #5b4b9c);
  --bubble-fg-out: #f2f5ff;
  --bubble-border-out: 1px solid rgba(255, 255, 255, .18);
}

/* 自定义颜色（放在所有预设之后，覆盖预设色） */
html[data-custom-in="1"] {
  --bubble-bg: linear-gradient(135deg, var(--custom-in-bg1), var(--custom-in-bg2));
  --bubble-fg: var(--custom-in-fg);
}
html[data-custom-out="1"] {
  --bubble-bg-out: linear-gradient(135deg, var(--custom-out-bg1), var(--custom-out-bg2));
  --bubble-fg-out: var(--custom-out-fg);
}

/* 气泡角标 / 颜文字装饰 */
.bubble-tag {
  position: absolute;
  right: 8px;
  bottom: -8px;
  padding: 0 5px;
  border-radius: 5px;
  font-size: 8.5px;
  line-height: 14px;
  letter-spacing: .3px;
  white-space: nowrap;
  color: #fff;
  background: #35c58f;
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}
.msg-row.in .bubble-tag {
  right: 8px;
  left: auto;
  color: #1f9c72;
  background: var(--pane);
  border: 1px solid rgba(53, 197, 143, .35);
}
.bubble-deco {
  position: absolute;
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(20, 40, 80, .15));
  white-space: nowrap;
}
.msg-row.in .bubble-deco { left: -7px; top: -11px; transform: rotate(-12deg); }
.msg-row.out .bubble-deco { right: -7px; top: -11px; transform: rotate(10deg); }
.msg-row.has-tag { margin-bottom: 18px; }
.msg-row.has-tag .msg-meta { margin-top: 9px; }

.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; opacity: .92; }
.bubble a:hover { opacity: 1; }

.bubble.media {
  padding: 4px;
  background: var(--bubble-in);
  border: 0;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 10px;
}
.msg-row.out .bubble.media {
  background: rgba(255, 255, 255, .14);
  box-shadow: none;
}
.bubble.media img {
  display: block;
  max-width: 240px;
  max-height: 280px;
  border-radius: 8px;
  cursor: zoom-in;
}

.bubble.sticker {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 8px;
}
.bubble.sticker img {
  display: block;
  max-width: 168px;
  max-height: 168px;
  min-width: 64px;
  border-radius: 8px;
  cursor: zoom-in;
  filter: drop-shadow(0 3px 8px rgba(20, 40, 80, .12));
}

.bubble .face-chip {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin: 0 1px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 11px;
  vertical-align: -4px;
  background: rgba(120, 145, 180, .13);
}

.bubble .voice-message {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: min(210px, 58vw);
  min-width: 132px;
  min-height: 30px;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.voice-message > svg { flex: none; width: 16px; height: 16px; }
.voice-wave { display: inline-flex; align-items: center; gap: 3px; height: 19px; }
.voice-wave i { display: block; width: 2px; border-radius: 2px; background: currentColor; opacity: .68; }
.voice-wave i:nth-child(1) { height: 6px; }
.voice-wave i:nth-child(2) { height: 13px; }
.voice-wave i:nth-child(3) { height: 18px; }
.voice-wave i:nth-child(4) { height: 10px; }
.voice-duration { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.voice-message.is-playing .voice-wave i { animation: voice-wave-play .8s ease-in-out infinite alternate; }
.voice-message.is-playing .voice-wave i:nth-child(2) { animation-delay: -.35s; }
.voice-message.is-playing .voice-wave i:nth-child(3) { animation-delay: -.55s; }
.voice-message.is-playing .voice-wave i:nth-child(4) { animation-delay: -.2s; }
.voice-message.is-error { color: var(--danger); }
.voice-message:disabled { cursor: default; opacity: .72; }
@keyframes voice-wave-play { from { transform: scaleY(.45); } to { transform: scaleY(1); } }

/* 「甩分享」卡片（vol 把搜到的内容用真人的方式甩出来） */
.bubble .share-card {
  display: block;
  max-width: 260px;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(120, 145, 180, .22);
  border-left: 3px solid var(--brand);
  background: rgba(120, 145, 180, .08);
  text-decoration: none;
  color: inherit;
}
.bubble .share-card strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bubble .share-card p {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bubble .share-card .share-src {
  display: block;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--text-3);
}
.bubble .share-card:hover { background: rgba(120, 145, 180, .14); }

/* 合并转发（聊天记录）：展开成一个列表，别只给个「[聊天记录]」提示 */
.bubble .fwd-box {
  max-width: 280px;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(120, 145, 180, .22);
  background: rgba(120, 145, 180, .07);
}
.bubble .fwd-head {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(120, 145, 180, .18);
}
.bubble .fwd-line {
  display: flex;
  gap: 6px;
  font-size: 11.5px;
  line-height: 1.5;
  margin-top: 3px;
}
.bubble .fwd-who {
  flex: 0 0 auto;
  color: var(--text-3);
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble .fwd-text { color: var(--text-1); }

/* 只有 id、内容在服务端时的「聊天记录」卡片：可点，点开取回内容展开 */
.bubble .fwd-chip {
  border: 1px solid rgba(120, 145, 180, .28);
  background: rgba(120, 145, 180, .12);
  cursor: pointer;
  height: auto;
  min-height: 24px;
  padding: 3px 8px;
  vertical-align: middle;
  color: var(--text-1);
}
.bubble .fwd-chip:hover { background: rgba(120, 145, 180, .2); }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 0 2px;
  font-size: 10.5px;
  color: var(--text-3);
  opacity: 0;
  transition: opacity .15s ease;
}
.msg-row:hover .msg-meta, .msg-row.pending .msg-meta, .msg-row.failed .msg-meta { opacity: 1; }
.msg-row.out .msg-meta { flex-direction: row-reverse; }
.msg-meta .retry {
  color: var(--brand);
  font-weight: 600;
}
.msg-row.failed .msg-meta { color: var(--danger); }

/* ------------------------------------------------ 多选消息 */
.msg-list.selecting .msg-row {
  position: relative;
  padding-left: 32px;
  cursor: pointer;
}
.msg-list.selecting { padding-bottom: 110px; }
.msg-check {
  display: none;
  position: absolute;
  left: 0;
  top: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--pane);
  align-items: center;
  justify-content: center;
  color: #fff;
  z-index: 2;
  transition: background .12s ease, border-color .12s ease;
}
.msg-list.selecting .msg-check { display: flex; }
.msg-check svg { width: 13px; height: 13px; opacity: 0; }
.msg-row.selected { background: rgba(10, 157, 255, .10); border-radius: 10px; }
.msg-row.selected .msg-check {
  background: var(--brand);
  border-color: var(--brand);
}
.msg-row.selected .msg-check svg { opacity: 1; }
html[data-theme="dark"] .msg-row.selected { background: rgba(10, 157, 255, .16); }

/* 鼠标框选 */
.marquee-box {
  position: absolute;
  z-index: 5;
  border: 1px solid var(--brand);
  background: rgba(10, 157, 255, .12);
  border-radius: 4px;
  pointer-events: none;
}
body.marquee-dragging,
body.marquee-dragging * { user-select: none !important; }

/* 撤回提示 */
.msg-row.recalled {
  justify-content: center;
  flex-direction: row;
  padding: 5px 0;
}
.msg-row.recalled .recalled-tip {
  font-size: 11.5px;
  color: var(--text-3);
  background: rgba(130, 147, 170, .12);
  padding: 4px 10px;
  border-radius: 10px;
}

/* 多选操作栏 */
.multi-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--glass);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.multi-count { font-size: 12px; color: var(--text-2); }
.multi-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.multi-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 58px;
  padding: 6px 8px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 11px;
  transition: background .12s ease, color .12s ease;
}
.multi-btn svg { width: 20px; height: 20px; }
.multi-btn:hover { background: var(--hover); color: var(--text); }
.multi-btn.danger { color: var(--danger); }
.multi-btn:disabled { opacity: .32; pointer-events: none; }

/* 转发目标 */
.forward-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.forward-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
  color: var(--text);
  font-size: 13.5px;
}
.forward-item:hover { background: var(--hover); }
.forward-item .avatar { width: 34px; height: 34px; font-size: 13px; }

.msg-row.hit .bubble {
  box-shadow: 0 0 0 2px #ffb020, 0 8px 18px -10px rgba(255, 176, 32, .5);
}

.to-bottom {
  position: sticky;
  bottom: 8px;
  margin-left: auto;
  margin-right: 2px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: var(--pane);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  transition: transform .15s ease, color .15s ease;
  z-index: 3;
}
.to-bottom:hover { color: var(--brand); transform: translateY(-2px); }
.to-bottom svg { transform: rotate(-90deg); }

/* ------------------------------------------------ 输入区 */

.composer { position: relative; padding: 8px 20px 16px; z-index: 4; }

.composer-box {
  border-radius: 12px;
  background: var(--pane);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-sm);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-row textarea { flex: 1; min-width: 0; }
.mobile-send { display: none; flex: none; }
.mobile-only { display: none; }
.mobile-head { display: none; }
.composer-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring), var(--shadow-sm);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 148px;
  padding: 11px 13px 2px;
  border: 0;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.65;
}
.composer textarea::placeholder { color: var(--text-3); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 6px 8px;
}
.tools { display: flex; align-items: center; gap: 2px; }
.tool-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: background .14s ease, color .14s ease;
}
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn:hover, .tool-btn.active { color: var(--brand); background: var(--brand-soft); }

.send-wrap { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.send-hint { font-size: 10.5px; color: var(--text-3); }
.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, #21adff, #0b7bff);
  box-shadow: 0 8px 16px -10px rgba(11, 123, 255, .8);
  transition: filter .15s ease, transform .12s ease, opacity .15s ease;
}
.send-btn svg { width: 15px; height: 15px; }
.send-btn:hover:not(:disabled) { filter: brightness(1.06); }
.send-btn:active:not(:disabled) { transform: scale(.97); }
.send-btn:disabled {
  cursor: default;
  color: var(--text-3);
  background: var(--hover);
  box-shadow: none;
}

.voice-recorder {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--pane);
  box-shadow: var(--shadow-sm);
}
.voice-cancel { flex: none; width: 30px; height: 30px; }
.voice-cancel svg { width: 16px; height: 16px; }
.voice-recorder-main { flex: 1; min-width: 0; }
.voice-recording-line { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.voice-recording-line strong { font-size: 13px; font-weight: 600; }
.voice-record-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-3);
}
.voice-recorder.is-recording .voice-record-dot {
  background: #f25f6b;
  box-shadow: 0 0 0 5px rgba(242, 95, 107, .12);
  animation: voice-record-pulse 1.2s ease-in-out infinite;
}
.voice-time { margin-left: auto; color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.voice-preview { display: block; width: 100%; height: 38px; margin-top: 7px; }
.voice-action, .voice-send { flex: none; margin: 0; }
.voice-action:disabled { opacity: .5; cursor: default; }

/* 按住说话的麦克风按钮：别让长按触发滚动/缩放/系统菜单 */
#voiceBtn {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 移动端「按住说话」提示条：悬浮在输入框上方，不挤动麦克风按钮。
   按住时按钮位置固定，手指不会因为布局变化「跟丢」。 */
.composer { position: relative; }
.composer .voice-hold-bar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 4;
  transform: translateX(-50%);
  width: min(92%, 620px);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--pane);
  box-shadow: var(--shadow-sm);
  color: var(--text-2);
  font-size: 12px;
  touch-action: none;
}
.voice-hold-bar.is-canceling {
  border-color: #e9657a;
  color: #d94a63;
}
.vh-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f25f6b;
  box-shadow: 0 0 0 5px rgba(242, 95, 107, .12);
  animation: voice-record-pulse 1.2s ease-in-out infinite;
}
.vh-text { font-weight: 600; }
.vh-time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
@keyframes voice-record-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.82); }
}

/* 浮层面板（表情 / 表情包） */
.panel {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 96px;
  height: 258px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  overflow: hidden;
  z-index: 20;
  animation: panel-in .18s ease both;
}
.panel.tall { height: 340px; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--line);
}
.panel-close { margin-left: auto; }

.tabs { display: flex; gap: 2px; overflow: hidden; }
.tabs.scroll-x { overflow-x: auto; scrollbar-width: none; }
.tabs.scroll-x::-webkit-scrollbar { display: none; }
.tab {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  transition: background .13s ease, color .13s ease;
}
.tab:hover { background: var(--hover); }
.tab.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }

.emoji-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px;
  align-content: start;
}
.emoji-grid button {
  height: 38px;
  border-radius: 8px;
  font-size: 22px;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
  line-height: 1;
  transition: background .12s ease, transform .12s ease;
}
.emoji-grid button:hover { background: var(--hover); transform: scale(1.12); }

.sticker-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.sticker-tools input {
  width: 132px;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--hover);
  font-size: 12px;
}
.sticker-tools input:focus { border-color: var(--brand-ring); background: var(--pane); }
.mini-btn { padding: 5px 9px; font-size: 11.5px; flex: none; }
.mini-btn.danger { color: var(--danger); border-color: rgba(240, 74, 74, .35); }
.mini-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.sticker-manage-bar .ghost { margin-left: 0; }
.sticker-manage-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-3);
}
.sticker-manage-bar span { flex: 1; }
.sticker-item.add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--text-3);
  font-size: 10.5px;
}
.sticker-item.add svg { width: 20px; height: 20px; }
.sticker-item.add:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.sticker-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(240, 74, 74, .94);
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  z-index: 3;
  cursor: pointer;
}

.sticker-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 12px 12px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  grid-auto-rows: 88px;
  gap: 8px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 140, 168, .45) transparent;
}
/* 面板里的滚动条要一直看得见，不然会误以为内容卡住了 */
.sticker-grid::-webkit-scrollbar { width: 10px; }
.sticker-grid::-webkit-scrollbar-track { background: transparent; }
.sticker-grid::-webkit-scrollbar-thumb {
  background: rgba(120, 140, 168, .38);
  border: 2px solid transparent;
  border-radius: 10px;
  background-clip: padding-box;
}
.sticker-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 140, 168, .6);
  background-clip: padding-box;
}
.sticker-item {
  position: relative;
  height: 88px;
  border-radius: 10px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--hover);
  border: 1px solid transparent;
  transition: transform .13s ease, border-color .13s ease, background .13s ease;
  overflow: hidden;
  contain: layout paint;
}
.sticker-item:hover { transform: translateY(-2px); border-color: var(--brand-ring); background: var(--brand-soft); }
.sticker-item img {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  object-fit: contain;
  border-radius: 6px;
  /* 面板入场动画 + 大量图片时，Chromium 偶发按错误的光栅偏移绘制
     （表现成横条切片）。独立图层可以稳定绘制。 */
  transform: translateZ(0);
}
.sticker-item.loading::after {
  content: "";
  width: 56%;
  height: 56%;
  border-radius: 8px;
  background: linear-gradient(100deg, transparent 30%, rgba(150, 170, 200, .18) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.panel-empty {
  padding: 26px 0 40px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
}

.drop-mask {
  position: absolute;
  inset: 60px 0 0;
  display: grid;
  place-items: center;
  background: rgba(10, 157, 255, .08);
  backdrop-filter: blur(2px);
  border: 2px dashed var(--brand);
  border-radius: 12px;
  margin: 8px;
  color: var(--brand);
  font-size: 14px;
  font-weight: 600;
  z-index: 30;
  pointer-events: none;
}

/* ------------------------------------------------ 右键菜单 / 弹层 */

.ctx-menu {
  position: fixed;
  min-width: 148px;
  padding: 5px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 90;
  animation: menu-in .12s ease both;
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(.97); }
  to { opacity: 1; transform: scale(1); }
}
.ctx-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  text-align: left;
  color: var(--text);
}
.ctx-menu button svg { width: 15px; height: 15px; color: var(--text-2); }
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button.danger svg { color: var(--danger); }

/* ---- 在线状态菜单（QQ 式） ---- */

.presence-menu { min-width: 216px; padding: 6px; }

.presence-menu .pm-head {
  padding: 6px 10px 8px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.presence-menu button.pm-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-align: left;
}

.presence-menu button.pm-item:hover { background: var(--hover); }
.presence-menu button.pm-item.active { background: var(--brand-soft); }

.presence-menu .pm-ico {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--text-2);
}
/* 菜单里每一项的图标也带状态色（和胶囊、头像点一致）*/
.presence-menu .pm-item[data-p="online"] .pm-ico    { color: #21c07a; }
.presence-menu .pm-item[data-p="qme"] .pm-ico       { color: #ff8a3d; }
.presence-menu .pm-item[data-p="away"] .pm-ico      { color: #f5a623; }
.presence-menu .pm-item[data-p="busy"] .pm-ico      { color: #f04a4a; }
.presence-menu .pm-item[data-p="dnd"] .pm-ico       { color: #c0392b; }
.presence-menu .pm-item[data-p="invisible"] .pm-ico { color: #98a3b4; }
.presence-menu .pm-item[data-p="offline"] .pm-ico   { color: #6c7788; }

.presence-menu .pm-text { min-width: 0; flex: 1; }
.presence-menu .pm-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.presence-menu .pm-item.active .pm-label { color: var(--brand); }
.presence-menu .pm-desc {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.presence-menu .pm-freq {
  flex: none;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--text-3);
  background: var(--hover);
}
.presence-menu button.pm-item.active .pm-freq {
  color: var(--brand);
  background: var(--brand-soft);
}

.lightbox {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px;
  background: rgba(9, 12, 18, .82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  animation: fade .16s ease both;
  cursor: zoom-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.lightbox img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7);
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, .12);
}
.lightbox-close:hover { background: rgba(255, 255, 255, .22); }

.modal-mask {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 17, 26, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 95;
  animation: fade .16s ease both;
}
.modal {
  width: min(460px, 100%);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: menu-in .2s ease both;
}
.modal-head {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 6px 20px 20px; overflow-y: auto; }
.mini-modal { width: min(390px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions .ghost { margin-left: 0; }
.btn-primary {
  padding: 8px 20px;
  border-radius: 9px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(135deg, #21adff, #0b7bff);
  box-shadow: 0 8px 16px -10px rgba(11, 123, 255, .8);
}
.btn-primary:hover { filter: brightness(1.05); }

/* 角色资料 → 回忆中心 */
.profile-memory-row { margin-top: 2px; }
.profile-memory-row .ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.profile-memory-row .ghost svg { width: 15px; height: 15px; }

.memory-modal { width: min(680px, 100%); max-height: 90vh; }
.memory-modal-head { align-items: flex-start; gap: 16px; }
.memory-modal-head .icon-btn { flex: none; }
.memory-heading { min-width: 0; }
.memory-heading p {
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text-3);
}
.memory-heading p > span { display: block; }
.memory-peer-name { margin-bottom: 2px; color: var(--brand-deep); font-weight: 600; }
.memory-body { padding-top: 14px; }
.memory-toolbar { display: flex; align-items: center; gap: 10px; }
.memory-search { position: relative; flex: 1; min-width: 180px; }
.memory-search > svg {
  position: absolute;
  left: 11px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
  transform: translateY(-50%);
}
.memory-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--hover);
  font-size: 12.5px;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
.memory-search:focus-within input {
  border-color: var(--brand);
  background: var(--pane);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.memory-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 0;
  padding-top: 7px;
  padding-bottom: 7px;
}
.memory-add-btn svg, .memory-empty .ghost svg { width: 14px; height: 14px; }
.memory-filters { margin: 12px 0; gap: 6px; }
.memory-filter { min-height: 29px; }

.memory-editor {
  margin: 12px 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--active-line);
  border-radius: 12px;
  background: var(--brand-soft);
}
.memory-editor-head { display: flex; align-items: center; gap: 10px; }
.memory-editor-head h3 { margin: 0; font-size: 13px; }
.memory-editor-head .icon-btn { width: 28px; height: 28px; margin-left: auto; }
.memory-field { display: block; margin-top: 8px; }
.memory-field > span, .memory-category-field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.memory-text.cs-input {
  height: auto;
  min-height: 88px;
  max-height: 180px;
  margin-top: 6px;
  padding: 9px 10px;
  background: var(--pane);
  line-height: 1.6;
  resize: vertical;
}
.memory-editor-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 12px;
}
.memory-category-field { min-width: 0; }
.memory-category {
  margin-top: 6px;
  padding-right: 8px;
  background: var(--pane);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.memory-pin-option {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--pane);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}
.memory-form-error { margin: 9px 0 0; font-size: 12px; line-height: 1.6; color: var(--danger); }
.memory-editor .modal-actions { margin-top: 12px; }

.memory-summary { min-height: 30px; display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; }
.memory-summary > span { font-size: 11.5px; line-height: 1.5; color: var(--text-3); overflow-wrap: anywhere; }
.memory-summary .icon-btn { width: 28px; height: 28px; margin-left: auto; flex: none; }
.memory-summary .icon-btn svg { width: 15px; height: 15px; }

.memory-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 30px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
  color: var(--text-3);
}
.memory-state strong { font-size: 13px; color: var(--text-2); }
.memory-state > span { max-width: 100%; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.memory-state .ghost { display: inline-flex; align-items: center; gap: 5px; margin: 4px 0 0; }
.memory-loading { min-height: 52px; flex-direction: row; justify-content: center; padding: 16px; border: 0; }
.memory-spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--brand-ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: memory-spin .75s linear infinite;
}
@keyframes memory-spin { to { transform: rotate(360deg); } }
.memory-error { border-color: rgba(228, 92, 112, .3); background: rgba(228, 92, 112, .05); }
.memory-error strong { color: var(--danger); }

.memory-list { display: flex; flex-direction: column; gap: 10px; border-radius: 12px; }
.memory-list:focus-visible { box-shadow: 0 0 0 2px var(--brand-ring); }
.memory-card {
  padding: 13px 14px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--pane);
  transition: border-color .14s ease, background .14s ease;
}
.memory-card:hover { border-color: var(--active-line); }
.memory-card.pinned { border-color: rgba(217, 154, 62, .42); box-shadow: inset 3px 0 var(--warning); }
.memory-card-head { display: flex; align-items: flex-start; gap: 8px; }
.memory-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.memory-badge, .memory-flag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
}
.memory-badge { color: var(--brand-deep); background: var(--brand-soft); }
.memory-badge.source { color: var(--text-3); background: var(--hover); border: 1px solid var(--line); }
.memory-flag.pinned { color: #a56808; background: rgba(217, 154, 62, .13); }
.memory-flag.corrected { color: var(--ok); background: rgba(44, 171, 124, .1); }
.memory-flag.version { color: var(--text-3); background: var(--hover); }
.memory-text-content {
  margin: 11px 0 12px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.memory-evidence {
  margin: -3px 0 12px;
  padding: 7px 9px;
  border-left: 2px solid var(--line);
  border-radius: 0 8px 8px 0;
  color: var(--text-3);
  background: var(--hover);
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  user-select: text;
}
.memory-evidence.missing { border-left-style: dashed; }
.memory-card-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.memory-time { font-size: 10.5px; color: var(--text-3); }
.memory-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.memory-action {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 11px;
  transition: color .14s ease, background .14s ease;
}
.memory-action svg { width: 14px; height: 14px; }
.memory-action:hover { color: var(--brand); background: var(--brand-soft); }
.memory-action.danger { color: var(--danger); }
.memory-action.danger:hover { background: rgba(228, 92, 112, .09); }
.memory-more { width: 100%; margin: 12px 0 0; padding: 9px 12px; }
.memory-modal button:disabled { opacity: .45; cursor: not-allowed; }
#profileMemoriesBtn:focus-visible,
.memory-modal button:focus-visible,
.memory-modal textarea:focus-visible,
.memory-modal select:focus-visible,
.memory-search input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.memory-modal .switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--brand-ring); }
html[data-theme="dark"] .memory-card { background: rgba(255, 255, 255, .025); }
html[data-theme="dark"] .memory-card:hover { background: rgba(255, 255, 255, .04); }
html[data-theme="dark"] .memory-flag.pinned { color: #f0c477; }

.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row > div:first-child { min-width: 0; }
.setting-row strong { display: block; font-size: 13px; font-weight: 600; }
.setting-row > div:first-child span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--text-3); word-break: break-all; }
.setting-row.column { flex-direction: column; align-items: stretch; gap: 10px; }
.setting-row.about { border-bottom: 0; }
.setting-stack { display: flex; flex-direction: column; gap: 8px; }
.setting-stack .cs-input { margin-top: 0; }
.setting-inline { display: flex; align-items: center; gap: 10px; }
.setting-inline .cs-hint { flex: 1; margin: 0; }

/* 添加角色 */
.char-add-row { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; }
.char-preview { width: 64px; height: 64px; font-size: 22px; flex: none; }
.char-add-info { min-width: 0; }
.char-add-info .ghost { margin-left: 0; }
#characterStatus.busy { color: var(--brand); }

/* 气泡皮肤选择 */
.bubble-setting { display: flex; flex-direction: column; gap: 10px; }
.bubble-line { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.bubble-who {
  width: 38px;
  flex: none;
  padding-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.bubble-opts { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.bubble-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-2);
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.bubble-opt:hover { border-color: var(--brand-ring); color: var(--text); }
.bubble-opt.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.mini { width: 24px; height: 14px; border-radius: 4px; flex: none; }
.mini-classic { background: linear-gradient(135deg, #1aa8ff, #0b82ff); }
.mini-tail { background: #0b82ff; border-radius: 8px 8px 8px 2px; }
.mini-glass {
  background: linear-gradient(135deg, rgba(80, 180, 255, .7), rgba(120, 110, 255, .65));
  border: 1px solid rgba(255, 255, 255, .8);
  backdrop-filter: blur(4px);
}
.mini-cream {
  background: linear-gradient(135deg, #ffd9e7, #ffc0d6);
  border: 1px dashed rgba(200, 120, 160, .65);
}
.mini-line { background: transparent; border: 1.5px solid var(--brand); border-radius: 6px; }
.mini-neon {
  background: linear-gradient(135deg, #ff5fa8, #8a5cff);
  box-shadow: 0 0 8px rgba(180, 90, 255, .6);
}
.mini-lace {
  background: #fffafc;
  border: 2px dotted #ffb6d5;
  box-shadow: 0 0 0 2px rgba(255, 205, 225, .6);
}
.mini-cloud {
  background: linear-gradient(135deg, #dff1ff, #e9e0ff);
  border: 1px solid rgba(160, 190, 255, .5);
  border-radius: 8px 8px 8px 2px;
}

.bubble-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  margin-top: 2px;
  border-radius: 12px;
  background: var(--chat);
  border: 1px solid var(--line);
}
.bubble-preview .msg-row { margin: 0; padding: 2px 0; animation: none; }
.bubble-preview .msg-row .avatar { width: 28px; height: 28px; font-size: 11px; }
.bubble-preview .msg-body { max-width: 80%; }
.bubble-preview .bubble { font-size: 12.5px; padding: 6px 10px; line-height: 1.5; }
html[data-theme="dark"] .bubble-preview { background: rgba(255, 255, 255, .03); }

/* 聊天设置（按对话） */
.chat-modal { width: min(540px, 100%); }
.cs-head { gap: 12px; }
.cs-head .avatar { width: 38px; height: 38px; font-size: 14px; flex: none; }
.cs-head-info { min-width: 0; }
.cs-head-info h2 { margin: 0; font-size: 15px; font-weight: 700; }
.cs-head-info span { display: block; margin-top: 2px; font-size: 11px; color: var(--text-3); }
.cs-head .icon-btn { margin-left: auto; }
.cs-side { margin: 4px 0 6px; }
.cs-side button { flex: 1; padding: 7px 12px; }
.cs-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.cs-section:last-of-type { border-bottom: 0; }
.cs-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.cs-label > span:first-child { flex: 1; }
.cs-colors { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cs-colors label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-3);
}
.cs-colors input[type="color"] {
  width: 26px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.cs-colors.disabled { opacity: .45; pointer-events: none; }
.cs-input {
  width: 100%;
  height: 34px;
  margin-top: 8px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--hover);
  font-size: 12px;
}
.cs-input:focus { border-color: var(--brand); background: var(--pane); }

.switch { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch i {
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .16s ease;
  position: relative;
  display: block;
}
.switch i::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .16s ease;
}
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(14px); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--pane);
  font-size: 11.5px;
  color: var(--text-2);
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.chip:hover { border-color: var(--brand-ring); color: var(--text); }
.chip.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.chip-check:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
.chip-check input {
  width: 13px;
  height: 13px;
  accent-color: var(--brand);
  margin: 0;
}
.cs-hint { margin: 8px 0 0; font-size: 10.5px; line-height: 1.6; color: var(--text-3); }
.cs-loading { font-size: 11.5px; color: var(--text-3); }
.cs-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  margin-top: 4px;
  border-radius: 12px;
  background: var(--chat);
  border: 1px solid var(--line);
}
.cs-preview .msg-row { margin: 0; padding: 2px 0; animation: none; }
.cs-preview .msg-row .avatar { width: 30px; height: 30px; font-size: 12px; }
.cs-preview .msg-body { max-width: 82%; }
.cs-preview .bubble { font-size: 12.5px; padding: 7px 11px; line-height: 1.55; }
html[data-theme="dark"] .cs-preview { background: rgba(255, 255, 255, .03); }

.chat-bg-opts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.chat-bg-opt {
  min-width: 0;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--pane);
  color: var(--text-2);
  font-size: 11px;
  transition: border-color .14s ease, box-shadow .14s ease, color .14s ease;
}
.chat-bg-opt:hover { border-color: var(--brand-ring); color: var(--text); }
.chat-bg-opt.active {
  border-color: var(--brand);
  color: var(--brand-deep);
  box-shadow: 0 0 0 2px var(--brand-soft);
}
.chat-bg-opt > span:last-child {
  display: block;
  padding: 5px 2px 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-bg-swatch {
  display: block;
  height: 44px;
  border-radius: 8px;
  background: var(--chat);
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(90, 80, 120, .06);
}
.chat-bg-swatch[data-bg-preview="mist"] {
  background-image: radial-gradient(circle at 80% 12%, rgba(255,255,255,.8), transparent 42%), linear-gradient(135deg, #ddd7f1, #f2e8f1 58%, #d7e2f1);
}
.chat-bg-swatch[data-bg-preview="starlight"] {
  background-image: radial-gradient(circle at 76% 22%, rgba(255,255,255,.85) 0 1px, transparent 1.8px), radial-gradient(circle at 25% 68%, rgba(255,255,255,.55) 0 1px, transparent 1.8px), linear-gradient(135deg, #62618e, #252b49);
}
.chat-bg-swatch[data-bg-preview="sakura"] {
  background-image: radial-gradient(circle at 18% 22%, rgba(255,255,255,.7), transparent 36%), linear-gradient(135deg, #f5dce5, #f7eee9 55%, #dfd9ee);
}
.chat-bg-swatch[data-bg-preview="seaside"] {
  background-image: linear-gradient(155deg, #d8ecf1 0%, #e9f3ee 52%, #cbdce9 100%);
}
.chat-bg-swatch[data-bg-preview="forest"] {
  background-image: radial-gradient(circle at 82% 18%, rgba(255,255,255,.55), transparent 40%), linear-gradient(135deg, #d9e6dc, #edf0df 58%, #c7d8d0);
}
.chat-bg-swatch[data-bg-preview="custom"] {
  background-image: linear-gradient(135deg, #d9d2f2, #b9c7e8);
}
.cs-bg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cs-bg-actions .ghost { margin: 0; }
.cs-bg-picker { cursor: pointer; }
.cs-bg-picker.disabled { opacity: .55; cursor: not-allowed; }
.cs-bg-actions:focus-within .cs-bg-picker {
  outline: 2px solid var(--brand-ring);
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 聊天对象头像 */
.cs-avatar-section { padding-top: 4px; }
.cs-avatar-row { display: flex; align-items: center; gap: 14px; }
.cs-avatar-preview {
  width: 58px;
  height: 58px;
  font-size: 20px;
  flex: none;
  cursor: pointer;
  transition: transform .14s ease;
}
.cs-avatar-preview:hover { transform: scale(1.04); }
.cs-avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cs-avatar-actions .ghost { margin-left: 0; }

/* 关系参数：热情 / 好感 */
.trait-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-2);
}
.trait-name { flex: none; width: 2.4em; color: var(--text); }
.trait-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--brand);
  margin: 0;
}
.trait-val {
  flex: none;
  width: 2.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}
.trait-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.trait-actions .mini-btn { margin: 0; }
.initiative-row .trait-name { width: 4.8em; }
.initiative-row .trait-val { width: 3.6em; }
.cs-quiet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text);
}
.cs-quiet-row > span { flex: 1; min-width: 0; }
.cs-quiet-row .cs-input { width: min(210px, 62%); margin: 0; }
.cs-pressure-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 15px;
  cursor: pointer;
}
.cs-pressure-row > span:first-child { flex: 1; min-width: 0; }
.cs-pressure-row strong { display: block; font-size: 12.5px; font-weight: 600; }
.cs-pressure-row small {
  display: block;
  margin-top: 4px;
  color: var(--text-3);
  font-size: 10.5px;
  line-height: 1.6;
}

/* 更换头像：QQ 式圆形裁剪 */
.avatar-modal { width: min(400px, 100%); }
.avatar-crop-stage {
  position: relative;
  width: min(280px, 72vw);
  aspect-ratio: 1 / 1;
  margin: 12px auto 0;
  border-radius: 50%;
  overflow: hidden;
  background: #0d1117;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.avatar-crop-stage.dragging { cursor: grabbing; }
.avatar-crop-stage > img {
  position: absolute;
  max-width: none;
  max-height: none;
  pointer-events: none;
  will-change: left, top, width, height;
}
.avatar-crop-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45),
              inset 0 0 24px rgba(0, 0, 0, .22);
  pointer-events: none;
}
.avatar-crop-zoom {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(280px, 72vw);
  margin: 14px auto 0;
  font-size: 13px;
  color: var(--text-3);
}
.avatar-crop-zoom input[type="range"] {
  flex: 1;
  height: 4px;
  accent-color: var(--brand);
  cursor: pointer;
}
.avatar-crop-hint { text-align: center; }

.seg {
  margin-left: auto;
  display: flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--hover);
  flex: none;
}
.seg button {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--text-2);
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.seg button.active {
  color: var(--text);
  background: var(--pane);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.cs-side { width: 100%; margin-left: 0; }

.ghost {
  margin-left: auto;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  white-space: nowrap;
  transition: border-color .14s ease, color .14s ease;
}
.ghost:hover { color: var(--brand); border-color: var(--brand); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(8px);
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 12.5px;
  color: #fff;
  background: rgba(26, 33, 46, .92);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 120;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------ 响应式 */

.mobile-tools { display: none; }
.mobile-nav { display: none; }

/* 手机联系人页 */
.mobile-page {
  display: flex;
  flex-direction: column;
  position: absolute;
  inset: 0;
  z-index: 7;
  background: var(--pane);
}
.mp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(12px + env(safe-area-inset-top)) 10px 10px;
  border-bottom: 1px solid var(--line);
}
.mp-head h2 { flex: 1; margin: 0; text-align: center; font-size: 16px; font-weight: 700; }
.mp-body { flex: 1; overflow-y: auto; padding: 8px 12px 90px; }
.mp-section { padding: 14px 6px 8px; font-size: 11px; color: var(--text-3); }
.mp-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  border-radius: 12px;
  text-align: left;
}
.mp-contact:not(.static):hover { background: var(--hover); }
.mp-contact .avatar { width: 46px; height: 46px; font-size: 17px; }
.mp-contact-main { flex: 1; min-width: 0; }
.mp-contact-main strong { display: block; font-size: 14.5px; font-weight: 600; }
.mp-contact-main span { display: block; margin-top: 3px; font-size: 11px; color: var(--text-3); }
.mp-contact .chev { width: 16px; height: 16px; color: var(--text-3); transform: rotate(180deg); flex: none; }
.mp-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
}

/* 手机操作面板 */
.action-sheet {
  position: fixed;
  inset: 0;
  z-index: 96;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 15, 25, .4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sheet {
  width: 100%;
  max-width: 520px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  border-radius: 18px 18px 0 0;
  background: var(--pane);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: sheet-up .22s cubic-bezier(.32, .72, .3, 1) both;
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  font-size: 14px;
  text-align: left;
  color: var(--text);
}
.sheet button:hover { background: var(--hover); }
.sheet button svg { width: 19px; height: 19px; color: var(--text-2); }
.sheet button.cancel {
  justify-content: center;
  margin-top: 4px;
  color: var(--text-3);
  border-top: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
}

@media (max-width: 520px) {
  #memoriesMask { padding: 12px; }
  .memory-modal {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 14px;
  }
  .memory-modal-head { padding: 14px 12px 12px 16px; gap: 10px; }
  .memory-body { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
  .memory-toolbar { gap: 8px; }
  .memory-search { min-width: 0; }
  .memory-search input, .memory-text, .memory-category { font-size: 16px; }
  .memory-add-btn { padding: 7px 9px; }
  .memory-filters { gap: 5px; margin: 10px 0; }
  .memory-filter { padding: 6px 8px; }
  .memory-editor { padding: 11px 12px 13px; }
  .memory-editor-options { grid-template-columns: 1fr; gap: 10px; }
  .memory-pin-option { min-height: 42px; justify-content: space-between; }
  .memory-card { padding: 12px; }
  .memory-actions {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
    padding-top: 7px;
    border-top: 1px solid var(--line);
  }
  .memory-action { min-height: 34px; padding: 5px 8px; }
}

@media (max-width: 1120px) {
  .app { grid-template-columns: 60px 260px minmax(0, 1fr); }
  .msg-body { max-width: 72%; }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }

  .rail { display: none; }
  .list-pane {
    position: absolute;
    inset: 0;
    z-index: 6;
    width: 100%;
    border-right: 0;
  }
  .mobile-tools { display: flex; gap: 2px; margin-left: 4px; }

  /* 手机端顶部：头像 + 昵称 + 状态 + 加号 */
  .me-line { display: none; }
  .mobile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px 12px;
  }
  .mh-avatar { width: 42px; height: 42px; font-size: 16px; }
  .mh-info { flex: 1; min-width: 0; }
  .mh-name {
    font-size: 17px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mh-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    margin-left: -6px;
    padding: 2px 7px;
    border-radius: 7px;
    font-size: 11px;
    color: var(--text-3);
    transition: background .14s ease;
  }
  .mh-status:active { background: var(--hover); }
  .mh-status i { width: 6px; height: 6px; border-radius: 50%; background: #f5a623; }
  .mh-status.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(33, 192, 122, .12); }
  .mh-status i[data-p="qme"]       { background: #ff8a3d; box-shadow: none; }
  .mh-status i[data-p="away"]      { background: #f5a623; box-shadow: none; }
  .mh-status i[data-p="busy"]      { background: #f04a4a; box-shadow: none; }
  .mh-status i[data-p="dnd"]       { background: #c0392b; box-shadow: none; }
  .mh-status i[data-p="invisible"] { background: #98a3b4; box-shadow: none; }
  .mh-status i[data-p="offline"]   { background: #6c7788; box-shadow: none; }
  .mh-plus {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: var(--text);
    transition: background .14s ease;
  }
  .mh-plus:hover { background: var(--hover); }
  .mh-plus svg { width: 22px; height: 22px; }

  .list-head { padding: calc(14px + env(safe-area-inset-top)) 14px 10px; }
  .search-box { height: 38px; border-radius: 10px; }
  .search-box input { font-size: 16px; }

  .conv-list { padding: 2px 8px 96px; }
  .conv { padding: 12px 10px; gap: 12px; border-radius: 12px; }
  .conv .avatar { width: 48px; height: 48px; font-size: 18px; }
  .conv-name { font-size: 15px; }
  .conv-preview { font-size: 12.5px; }
  .conv-time { font-size: 10.5px; }
  .conv.active { background: var(--hover); }
  .conv.active::before { display: none; }
  .list-foot { display: none; }

  /* 底部导航 */
  .mobile-nav {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(62px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    align-items: stretch;
    background: var(--pane);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 8;
  }
  .mn-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10.5px;
    color: var(--text-3);
    transition: color .14s ease;
  }
  .mn-icon { position: relative; display: grid; place-items: center; }
  .mn-icon svg { width: 23px; height: 23px; }
  .mn-item.active { color: var(--brand); font-weight: 600; }
  .mn-item .badge.small { top: -5px; right: -9px; }
  .app.mobile-chat .mobile-nav { display: none; }

  .chat-pane {
    position: absolute;
    inset: 0;
    z-index: 10;
    transform: translateX(100%);
    transition: transform .26s cubic-bezier(.32, .72, .3, 1);
    box-shadow: -18px 0 40px -24px rgba(0, 0, 0, .35);
  }
  .app.mobile-chat .chat-pane {
    transform: translateX(0);
    touch-action: pan-y pinch-zoom;
  }
  /* 边缘滑动跟随手指时不要被 CSS 过渡拖慢 */
  .chat-pane.swiping { transition: none; }
  .back-btn { display: grid; }

  .chat-head {
    height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 8px 0 4px;
  }
  .msg-scroll { padding: 14px 12px 8px; }
  .msg-body { max-width: 78%; }

  /* QQ 手机端输入栏：输入框 + 发送按钮一行，工具图标一行 */
  .composer { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer-box {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .composer-box:focus-within { border-color: transparent; box-shadow: none; }
  .composer-row { align-items: flex-end; gap: 8px; }
  .composer textarea {
    min-height: 40px;
    max-height: 108px;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--pane);
    font-size: 16px;
  }
  .composer-bar { padding: 8px 4px 2px; gap: 6px; }
  .tools { width: auto; flex: 1; justify-content: space-around; gap: 4px; }
  .tool-btn { width: 36px; height: 36px; }
  .tool-btn svg { width: 22px; height: 22px; }
  .send-wrap { display: flex; margin-left: 0; }
  .send-hint { display: none; }
  .mobile-only { display: grid; }

  .panel { left: 10px; right: 10px; bottom: calc(104px + env(safe-area-inset-bottom)); height: 47vh; }
  .panel.tall { height: 54vh; }
  #stickerPanel .panel-head { flex-wrap: wrap; }
  #stickerPanel .tabs { order: 1; width: 100%; }
  #stickerPanel .sticker-tools { order: 2; width: 100%; margin-left: 0; }
  #stickerPanel .sticker-tools input { flex: 1; width: auto; }
  .sticker-manage-bar span { display: none; }
  .sticker-manage-bar { justify-content: flex-end; }
  .send-hint { display: none; }
  .bubble { font-size: 14px; }
  /* iOS 聚焦小于 16px 的输入框会自动放大页面 */
  .composer textarea, .sticker-tools input, .search-box input, .chat-search input { font-size: 16px; }
  .bubble.media img { max-width: 210px; max-height: 260px; }
}

@media (max-width: 420px) {
  .msg-row .avatar { width: 32px; height: 32px; font-size: 12.5px; }
  .msg-body { max-width: 80%; }
  .chat-actions #btnSearchMsg { display: none; }
}

/* 角色资料 → 共同生活 */
#sharedLifeMask .shared-life-modal { width: min(760px, 100%); max-height: 90vh; max-height: 90dvh; }
.shared-life-modal-head { align-items: flex-start; gap: 16px; }
.shared-life-modal-head .icon-btn { flex: none; }
.shared-life-heading { min-width: 0; }
.shared-life-body { min-width: 0; padding-top: 14px; overflow-x: hidden; }
.shared-life-panel { min-width: 0; max-width: 100%; outline: none; }
.shared-life-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--hover);
}
.shared-life-tabs button {
  min-width: 0;
  min-height: 37px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  color: var(--text-3);
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.shared-life-tabs button.active {
  color: var(--brand-deep);
  background: var(--panel);
  box-shadow: 0 2px 9px rgba(36, 28, 65, .08);
}
.shared-life-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  margin-bottom: 12px;
}
.shared-life-section-head > div { min-width: 0; }
.shared-life-section-head h3 { margin: 0; font-size: 14px; }
.shared-life-section-head p { margin: 4px 0 0; color: var(--text-3); font-size: 11.5px; line-height: 1.55; }
.shared-life-add { display: inline-flex; align-items: center; gap: 5px; margin-left: 0; }
.shared-life-add svg { width: 14px; height: 14px; }
.shared-life-editor {
  min-width: 0;
  margin: 12px 0 14px;
  padding: 14px;
  border: 1px solid var(--active-line);
  border-radius: 14px;
  background: var(--brand-soft);
}
.shared-life-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.shared-life-editor-head h3 { margin: 0; font-size: 13px; }
.shared-life-editor-head .icon-btn { width: 28px; height: 28px; margin-left: auto; }
.shared-life-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.shared-life-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-top: 10px; }
.shared-life-form-grid .shared-life-field { margin-top: 0; }
.shared-life-field > span { color: var(--text-2); font-size: 12px; font-weight: 600; }
.shared-life-field .cs-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  color: var(--text);
  background: var(--pane);
  font: inherit;
}
.shared-life-field textarea.cs-input { min-height: 82px; max-height: 240px; line-height: 1.65; resize: vertical; }
.shared-life-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--pane);
  cursor: pointer;
}
.shared-life-switch > span:first-child { min-width: 0; }
.shared-life-switch strong { display: block; color: var(--text-2); font-size: 12px; }
.shared-life-switch small { display: block; margin-top: 3px; color: var(--text-3); font-size: 10.5px; }
.shared-life-switch .switch { flex: none; }
.shared-life-form-error { margin: 10px 0 0; color: var(--danger); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.shared-life-agreement-rule, .shared-life-diary-policy {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--hover);
  line-height: 1.65;
}
.shared-life-list-meta { display: flex; align-items: center; gap: 8px; min-height: 31px; margin: 4px 0 7px; }
.shared-life-list-meta > span { color: var(--text-3); font-size: 11.5px; line-height: 1.5; }
.shared-life-list-meta .icon-btn { width: 28px; height: 28px; margin-left: auto; flex: none; }
.shared-life-list-meta .icon-btn svg { width: 15px; height: 15px; }
.shared-life-state { margin-top: 8px; }
.shared-life-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; border-radius: 13px; }
.shared-life-list:focus-visible { box-shadow: 0 0 0 2px var(--brand-ring); }
.shared-life-card {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--pane);
  transition: border-color .14s ease, background .14s ease;
}
.shared-life-card:hover { border-color: var(--active-line); }
.shared-life-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; }
.shared-life-card-head h4 { min-width: 0; margin: 2px 0 0; font-size: 13.5px; line-height: 1.55; overflow-wrap: anywhere; }
.shared-life-badges { display: flex; flex: none; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.shared-life-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.shared-life-badge.once, .shared-life-badge.followed-up { color: var(--text-3); background: var(--hover); border: 1px solid var(--line); }
.shared-life-badge.pending { color: var(--warning); background: rgba(217, 154, 62, .12); }
.shared-life-badge.confirmed { color: var(--ok); background: rgba(44, 171, 124, .1); }
.shared-life-date-lines { margin-top: 10px; }
.shared-life-date-lines p, .shared-life-due-time { margin: 3px 0; color: var(--text-2); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.shared-life-date-lines p.today { color: var(--brand-deep); font-weight: 600; }
.shared-life-date-lines p.past { color: var(--text-3); }
.shared-life-due-time { margin-top: 10px; }
.shared-life-card-content {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.shared-life-status-text {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text-2);
  background: var(--hover);
  font-size: 11.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.shared-life-card-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.shared-life-card-footer > span { color: var(--text-3); font-size: 10.5px; line-height: 1.5; overflow-wrap: anywhere; }
.shared-life-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-left: auto; }
.shared-life-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 4px 7px;
  border: 0;
  border-radius: 7px;
  color: var(--text-3);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  transition: color .14s ease, background .14s ease;
}
.shared-life-action svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shared-life-action:hover { color: var(--brand-deep); background: var(--brand-soft); }
.shared-life-action[data-shared-life-action="confirm"] { color: var(--brand-deep); background: var(--brand-soft); }
.shared-life-action.danger { color: var(--danger); }
.shared-life-action.danger:hover { background: rgba(228, 92, 112, .09); }
.shared-life-diary-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; margin-bottom: 10px; }
.shared-life-diary-form .shared-life-field { margin-top: 0; }
.shared-life-diary-form .btn-primary { min-width: 104px; margin: 0; }
.shared-life-diary-card { padding: 0; }
.shared-life-diary-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 13px 14px;
  cursor: pointer;
  list-style: none;
}
.shared-life-diary-card > summary::-webkit-details-marker { display: none; }
.shared-life-diary-card[open] > summary { border-bottom: 1px solid var(--line); }
.shared-life-diary-summary-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.shared-life-diary-summary-main > strong { font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.shared-life-diary-toggle { color: var(--brand-deep); font-size: 10.5px; }
.shared-life-diary-body { min-width: 0; padding: 12px 14px 13px; }
.shared-life-diary-meta { margin: 0 0 9px; color: var(--text-3); font-size: 10.5px; line-height: 1.55; }
.shared-life-diary-content {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  max-height: 310px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--hover);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}
.shared-life-modal button:disabled { opacity: .45; cursor: not-allowed; }
#profileSharedLifeBtn:focus-visible,
.shared-life-modal button:focus-visible,
.shared-life-modal input:focus-visible,
.shared-life-modal textarea:focus-visible,
.shared-life-modal summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.shared-life-modal .switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--brand-ring); }
html[data-theme="dark"] .shared-life-card { background: rgba(255, 255, 255, .025); }
html[data-theme="dark"] .shared-life-card:hover { background: rgba(255, 255, 255, .04); }
html[data-theme="dark"] .shared-life-tabs button.active { box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }

@media (max-width: 560px) {
  #sharedLifeMask { align-items: end; padding: 0; }
  #sharedLifeMask .shared-life-modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    animation: sheet-up .24s var(--ease) both;
  }
  .shared-life-modal-head { padding: 17px 13px 13px 17px; gap: 10px; }
  .shared-life-body { padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); }
  .shared-life-tabs { margin-bottom: 14px; }
  .shared-life-tabs button { min-height: 40px; padding-inline: 5px; font-size: 12px; }
  .shared-life-section-head { align-items: flex-start; gap: 10px; }
  .shared-life-section-head p { font-size: 11px; }
  .shared-life-add { padding-inline: 9px; }
  .shared-life-form-grid, .shared-life-diary-form { grid-template-columns: minmax(0, 1fr); }
  .shared-life-diary-form .btn-primary { width: 100%; }
  .shared-life-editor { padding: 12px; }
  .shared-life-card { padding: 12px; }
  .shared-life-diary-card { padding: 0; }
  .shared-life-card-head { flex-direction: column; gap: 7px; }
  .shared-life-badges { justify-content: flex-start; }
  .shared-life-card-footer { align-items: flex-start; }
  .shared-life-card-actions { width: 100%; justify-content: flex-end; margin-left: 0; }
  .shared-life-action { min-height: 36px; padding: 6px 8px; }
  .shared-life-diary-card > summary { align-items: flex-start; padding: 12px; }
  .shared-life-diary-card > summary .shared-life-badge { flex: none; }
  .shared-life-diary-body { padding: 11px 12px 12px; }
  .shared-life-diary-content { max-height: 38vh; max-height: 38dvh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------ 群聊 */

/* 群头像：和好友头像同一尺寸，只是底色换成品牌渐变 */
.group-avatar {
  background: linear-gradient(135deg, #7cc4ff, #6f7bff);
  color: #fff;
}
html[data-theme="dark"] .group-avatar {
  background: linear-gradient(135deg, #3b5bb5, #5f4bd0);
}

.chat-head .chat-avatar {
  width: 34px;
  height: 34px;
  font-size: 13px;
  flex: none;
  cursor: pointer;
  transition: transform .16s var(--ease), box-shadow .16s ease;
}
.chat-head .chat-avatar:hover { transform: translateY(-1px); box-shadow: 0 5px 14px -8px var(--brand); }
.chat-head .chat-avatar:active { transform: scale(.96); }
.chat-head .chat-avatar:focus-visible,
.name-row #chatName:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 8px;
}
.name-row #chatName[role="button"]:hover { color: var(--brand-deep); }

/* 会话列表里的「群」角标 / 待审申请红点 */
.conv-tag {
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 5px;
  font-size: 9.5px;
  line-height: 15px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  vertical-align: middle;
}
.conv-pending {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 10.5px;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: var(--danger);
  box-shadow: 0 2px 6px -2px rgba(240, 74, 74, .6);
}

/* 群消息：昵称 + 等级 / 角色标签（QQ 群的味道） */
.msg-sender {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 3px 2px;
  max-width: 100%;
  font-size: 11.5px;
  color: var(--text-3);
}
.msg-row.out .msg-sender { justify-content: flex-end; margin: 0 2px 3px 0; }
.ms-name {
  font-weight: 600;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ms-badges { display: inline-flex; align-items: center; gap: 4px; }
.ms-role {
  font-style: normal;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 9.5px;
  line-height: 14px;
  font-weight: 700;
  color: #fff;
}
.ms-role.owner { background: linear-gradient(135deg, #ffb347, #ff8a3d); }
.ms-role.admin { background: linear-gradient(135deg, #56c1ff, #4a7dff); }
.ms-lv {
  font-style: normal;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 9.5px;
  line-height: 14px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
}

/* 系统消息（入群 / 改名 / 公告 / 踢人…）居中提示 */
.msg-row.system { justify-content: center; }
.system-tip {
  align-self: center;
  margin: 2px 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-3);
  background: rgba(130, 147, 170, .1);
}

/* @ 芯片：QQ 里 @ 就是一段高亮文字，**不带底色块**。
   原来的 brand-soft 底 + padding 在我的蓝色气泡里会变成一块深色补丁，
   看起来像气泡左边多了一段空白（用户实测截图）。
   ⚠️ 必须用 `.bubble .at-chip` 提高特异性 —— `.bubble .face-chip` 的底色
   会把它压过去（不加选择器前缀的话这里根本生效不了）。 */
.bubble .at-chip,
.bubble .face-chip.at-chip {
  display: inline;
  color: var(--brand);
  background: transparent;
  padding: 0;
  min-width: 0;
  margin: 0;
  height: auto;
  font-weight: 600;
  vertical-align: baseline;
}
.bubble .at-chip:hover { background: transparent; }
.msg-row.out .bubble .at-chip { color: inherit; }

/* 关系参数：滑杆下方的「真实生效值」明细 */
.trait-detail {
  margin: 6px 0 2px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(120, 145, 180, .08);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-2);
  white-space: pre-line;
}

/* ---------- 群右侧面板（群公告 + 群聊成员） ---------- */
.group-side {
  flex: 0 0 268px;
  width: 268px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--pane);
}
html[data-theme="dark"] .group-side { background: rgba(18, 22, 31, .6); }

.gs-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line);
}
.gs-avatar { width: 40px; height: 40px; font-size: 15px; flex: none; }
.gs-set-avatar {
  width: 40px;
  height: 40px;
  font-size: 15px;
  flex: none;
  cursor: pointer;
}

/* 群设置里的「群聊节奏」滑杆（和私聊的关系参数同一套排版） */
.setting-row.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.setting-row.compact strong { font-size: 12.5px; font-weight: 600; }
#gsLimits .trait-row { margin-top: 8px; }
#gsLimits .trait-name { width: auto; flex: 1; min-width: 0; }
.gs-head-info { flex: 1; min-width: 0; }
.gs-head-info strong {
  display: block;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gs-head-info span { font-size: 11px; color: var(--text-3); }

.gs-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gs-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: var(--chat);
}
html[data-theme="dark"] .gs-card { background: rgba(255, 255, 255, .03); }
.gs-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.gs-card-head em { font-style: normal; font-weight: 500; color: var(--text-3); }
.gs-ic {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  vertical-align: -2px;
  color: var(--brand);
}
.gs-announce {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.gs-members-card { display: flex; flex-direction: column; min-height: 0; }
.gs-search { margin: 8px 0; }
.gs-members {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 340px;
  overflow-y: auto;
}

.gs-member {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 9px;
  text-align: left;
  transition: background .12s ease;
}
.gs-member:hover { background: var(--hover); }
.gs-member .avatar { width: 30px; height: 30px; font-size: 12px; flex: none; }
.gs-member-info { flex: 1; min-width: 0; }
.gs-member-info strong {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gs-member-info span { font-size: 10.5px; color: var(--text-3); }
.gs-member-more { flex: none; color: var(--text-3); opacity: 0; transition: opacity .12s ease; }
.gs-member:hover .gs-member-more { opacity: 1; }
.gs-member-more svg { width: 15px; height: 15px; }

.gs-req { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.gs-req .avatar { width: 30px; height: 30px; font-size: 12px; flex: none; }
.gs-req-info { flex: 1; min-width: 0; }
.gs-req-info strong { display: block; font-size: 12.5px; }
.gs-req-info span { font-size: 10.5px; color: var(--text-3); }
.gs-req-acts { display: flex; gap: 4px; flex: none; }

/* ---------- 建群 / 邀请：好友多选 ---------- */
.cg-members {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 6px;
}
.cg-member {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
  transition: background .12s ease;
}
.cg-member:hover { background: var(--hover); }
.cg-member.on { background: var(--brand-soft); }
.cg-member[disabled] { opacity: .55; cursor: default; }
.cg-member .avatar { width: 34px; height: 34px; font-size: 13px; flex: none; }
.cg-member > span {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cg-tick {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  color: transparent;
}
.cg-member.on .cg-tick { border-color: var(--brand); background: var(--brand); color: #fff; }
.cg-tick svg { width: 13px; height: 13px; }
.cg-tag { flex: none; font-style: normal; font-size: 10px; color: var(--text-3); }

.forward-tag {
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 5px;
  font-size: 10px;
  font-style: normal;
  line-height: 15px;
  color: var(--brand);
  background: var(--brand-soft);
}

.announce-input {
  min-height: 96px;
  resize: vertical;
  line-height: 1.7;
  font-family: var(--font);
}

/* ---------- 引用回复 ---------- */

.quote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 7px 10px;
  border-radius: 10px;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
}
.qb-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.qb-name { font-size: 11.5px; font-weight: 600; color: var(--brand); }
.qb-text {
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qb-close { flex: none; width: 24px; height: 24px; }
.qb-close svg { width: 14px; height: 14px; }

.quote-ref {
  max-width: 100%;
  margin: 0 0 4px;
  padding: 4px 8px;
  border-radius: 7px;
  border-left: 3px solid var(--brand);
  background: rgba(130, 147, 170, .12);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quote-ref:hover { background: rgba(130, 147, 170, .2); }
.quote-ref[role="button"]:focus-visible,
.bubble img[role="button"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.qr-name { font-weight: 600; color: var(--text-2); margin-right: 4px; }
.msg-row.out .quote-ref { border-left-color: rgba(255, 255, 255, .7); }
.msg-row.out .quote-ref .qr-name { color: inherit; }

@keyframes row-flash {
  0%, 100% { background: transparent; }
  30% { background: var(--brand-soft); }
}
.msg-row.flash { animation: row-flash 1.1s ease; border-radius: 8px; }

/* ---------- 群文件 / 群相册 ---------- */

.gs-tabs {
  display: flex;
  gap: 4px;
  margin: 8px 0 6px;
}
.gs-tabs button {
  flex: 1;
  padding: 4px 0;
  border-radius: 7px;
  font-size: 11.5px;
  color: var(--text-3);
  transition: background .12s ease, color .12s ease;
}
.gs-tabs button:hover { background: var(--hover); }
.gs-tabs button.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }

.gs-files { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.gs-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
}
.gs-file:hover { background: var(--hover); }
.gs-file-ico { flex: none; color: var(--brand); display: grid; place-items: center; }
.gs-file-ico svg { width: 16px; height: 16px; }
.gs-file-info { flex: 1; min-width: 0; }
.gs-file-info strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gs-file-info span { font-size: 10px; color: var(--text-3); }
.gs-file-dl, .gs-file-del {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-3);
  transition: background .12s ease, color .12s ease;
}
.gs-file-dl:hover { color: var(--brand); background: var(--brand-soft); }
.gs-file-del:hover { color: var(--danger); background: rgba(240, 74, 74, .12); }
.gs-file-dl svg, .gs-file-del svg { width: 15px; height: 15px; }

.gs-album {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.gs-album img {
  width: 100%;
  height: 68px;
  object-fit: cover;
  border-radius: 7px;
  cursor: zoom-in;
  background: var(--hover);
}

@media (max-width: 1120px) {
  .group-side { flex-basis: 232px; width: 232px; }
}

@media (max-width: 880px) {
  /* 手机上群面板默认收起，点群头像把它当浮层展开 */
  .group-side { display: none; }
  .group-side.mobile-open {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 12;
    width: 100%;
    flex-basis: auto;
    border-left: 0;
    background: var(--chat);
  }
  .gs-members { max-height: none; }
  .cg-members { max-height: 46vh; }
  .msg-sender { font-size: 12px; }
}

/* ============================================================
   整体视觉整合
   只覆盖表现层；动态 DOM、气泡皮肤变量和 JS 几何契约保持不变。
   ============================================================ */

/* ---------- 基础控件与可访问性 ---------- */
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
:where(button, a, [tabindex]):focus-visible {
  outline: 3px solid var(--brand-ring);
  outline-offset: 2px;
}
:where(.icon-btn, .rail-btn, .tool-btn, .tab, .chip, .ghost,
       .btn-primary, .send-btn, .conv, .ctx-menu button) {
  transition-timing-function: var(--ease);
}
::placeholder { color: var(--text-3); opacity: .82; }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--brand-ring); }

/* ---------- 连接页 ---------- */
.connect { padding: 32px; isolation: isolate; }
.connect-bg::after {
  background:
    radial-gradient(70% 65% at 50% 45%, rgba(244, 241, 255, .14), transparent 72%),
    linear-gradient(145deg, rgba(238, 238, 250, .64), rgba(247, 241, 250, .46) 52%, rgba(234, 241, 252, .62));
}
html[data-theme="dark"] .connect-bg::after {
  background:
    radial-gradient(70% 65% at 50% 45%, rgba(102, 86, 170, .10), transparent 72%),
    linear-gradient(145deg, rgba(9, 11, 20, .72), rgba(17, 15, 29, .58));
}
.connect-sky i:nth-child(1) { background: #a9a2f2; }
.connect-sky i:nth-child(2) { background: #edb7d7; }
.connect-sky i:nth-child(3) { background: #b6d9ee; }
.connect-card {
  width: min(414px, 100%);
  padding: 44px 38px 30px;
  border-radius: 28px;
  background: rgba(255, 255, 255, .74);
  border: 1px solid rgba(255, 255, 255, .82);
  box-shadow: 0 34px 90px -32px rgba(48, 35, 88, .42),
              inset 0 1px 0 rgba(255, 255, 255, .74);
  backdrop-filter: blur(30px) saturate(135%);
  -webkit-backdrop-filter: blur(30px) saturate(135%);
}
html[data-theme="dark"] .connect-card {
  background: rgba(24, 24, 38, .74);
  border-color: rgba(255, 255, 255, .10);
  box-shadow: 0 36px 100px -34px rgba(0, 0, 0, .76),
              inset 0 1px 0 rgba(255, 255, 255, .05);
}
.brand-avatar {
  width: 90px;
  height: 90px;
  margin-bottom: 22px;
  background: linear-gradient(145deg, #c4baf9 0%, #8c7ee9 52%, #b68bc6 100%);
  box-shadow: 0 18px 38px -16px rgba(105, 83, 181, .64),
              inset 0 1px 0 rgba(255, 255, 255, .5);
}
.brand-avatar::before {
  content: "";
  position: absolute;
  inset: -7px;
  border: 1px solid rgba(116, 105, 232, .18);
  border-radius: 50%;
  pointer-events: none;
}
.connect-card h1 {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: .12em;
  font-weight: 720;
}
.brand-sub { margin: 9px 0 26px; color: var(--text-2); letter-spacing: .08em; }
.connect-state {
  min-height: 32px;
  padding: 7px 13px;
  border: 1px solid var(--brand-ring);
  background: var(--brand-soft);
}
.connect-state.bad { border-color: rgba(228, 92, 112, .18); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--brand-ring); }
  70% { box-shadow: 0 0 0 8px rgba(116, 105, 232, 0); }
  100% { box-shadow: 0 0 0 0 rgba(116, 105, 232, 0); }
}
.primary, .btn-primary, .send-btn {
  background: var(--bubble-out);
  box-shadow: none;
}
.primary:hover, .btn-primary:hover, .send-btn:hover { filter: brightness(.96); }
.primary {
  height: 46px;
  border-radius: 14px;
  letter-spacing: .06em;
}
.primary:hover, .btn-primary:hover { filter: brightness(1.045); }
.primary:active, .btn-primary:active { transform: translateY(1px); }
.connect-tip { max-width: 310px; margin: 22px auto 0; line-height: 1.75; }
.connect-bg-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 3;
  min-height: 32px;
  padding: 7px 12px;
  color: var(--text-2);
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.connect-bg-btn:hover { color: var(--brand-deep); background: rgba(255, 255, 255, .9); }
html[data-theme="dark"] .connect-bg-btn {
  color: var(--text-2);
  background: rgba(24, 26, 40, .76);
  border-color: var(--line-strong);
}
.token-row label { color: var(--text-2); }
.token-input input {
  height: 42px;
  border-radius: 11px;
  background: var(--hover);
}
.token-input input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.token-input button {
  border-radius: 11px;
  background: #786be0;
  transition: filter .15s ease;
}
.token-input button:hover { filter: brightness(1.06); }

/* ---------- 桌面工作区 ---------- */
.app {
  grid-template-columns: 68px 296px minmax(0, 1fr);
  padding: 8px;
  background: var(--bg);
}
.rail {
  position: relative;
  z-index: 3;
  padding: 16px 0 14px;
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 12px 0 0 12px;
  box-shadow: none;
}
.rail-avatar {
  width: 42px;
  height: 42px;
  margin-bottom: 22px;
  background: linear-gradient(145deg, #8acdf3, #3699d5);
  box-shadow: 0 8px 20px -12px rgba(22, 135, 217, .55);
}
.rail-nav, .rail-foot { gap: 6px; }
.rail-btn { width: 42px; height: 42px; border-radius: 10px; }
.rail-btn svg { width: 21px; height: 21px; stroke-width: 1.8; }
.rail-btn.active { color: var(--brand-deep); background: var(--brand-soft); }
.rail-btn.active::before {
  left: -13px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  box-shadow: none;
}
.rail-btn[data-tip]::after {
  left: 52px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(25, 32, 42, .94);
  box-shadow: var(--shadow-md);
}
.list-pane {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--pane);
}
.list-head { padding: 17px 15px 12px; }
.me-line { gap: 8px; padding: 0 2px 13px; }
.me-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.me-meta { flex: none; gap: 5px; }
.presence-chip, .conn-chip { min-height: 23px; padding: 3px 8px; }
.presence-chip { border: 1px solid transparent; }
.presence-chip:hover { border-color: var(--active-line); }
.conn-chip.ok { display: none; }
.search-box {
  height: 36px;
  gap: 8px;
  padding: 0 11px;
  border-radius: 8px;
  background: var(--hover);
  border-color: transparent;
}
.search-box:focus-within {
  border-color: var(--brand);
  background: var(--pane);
  box-shadow: 0 0 0 2px var(--brand-ring);
}
.search-box input { font-size: 13px; }
.conv-list { padding: 2px 7px 10px; }
.conv {
  gap: 11px;
  margin: 1px 0;
  padding: 10px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
}
.conv:hover { background: var(--hover); }
.conv.active {
  background: var(--active);
  border-color: transparent;
  box-shadow: none;
}
.conv.active::before { display: none; }
.conv .avatar { width: 44px; height: 44px; }
.conv-name { font-size: 14px; font-weight: 500; letter-spacing: 0; }
.conv.active .conv-name { color: var(--brand-deep); }
.conv-bottom { margin-top: 4px; }
.conv-preview { font-size: 12px; line-height: 1.45; }
.conv-time { font-size: 11px; font-variant-numeric: tabular-nums; }
.avatar { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.bot-avatar {
  background:
    radial-gradient(120% 120% at 22% 18%, rgba(255, 255, 255, .52), transparent 52%),
    linear-gradient(145deg, #e2b5d5 0%, #aa9ae9 54%, #829fdc 100%);
}
.avatar.me-avatar { background: linear-gradient(145deg, #8acdf3, #459fd2); }
.badge { background: #ed5b70; box-shadow: none; }
.list-foot { padding: 10px 16px; letter-spacing: 0; }

/* ---------- 聊天顶栏与消息 ---------- */
.chat-pane {
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 12px 12px 0;
  background: var(--chat);
  box-shadow: none;
}
html[data-theme="dark"] .chat-pane { background: var(--chat); }
html[data-chat-bg="mist"] {
  --chat-bg-image: radial-gradient(circle at 80% 12%, rgba(255,255,255,.8), transparent 42%), linear-gradient(135deg, #ddd7f1, #f2e8f1 58%, #d7e2f1);
}
html[data-chat-bg="starlight"] {
  --chat-bg-image: radial-gradient(circle at 76% 22%, rgba(255,255,255,.85) 0 1px, transparent 1.8px), radial-gradient(circle at 25% 68%, rgba(255,255,255,.55) 0 1px, transparent 1.8px), linear-gradient(135deg, #62618e, #252b49);
}
html[data-chat-bg="sakura"] {
  --chat-bg-image: radial-gradient(circle at 18% 22%, rgba(255,255,255,.7), transparent 36%), linear-gradient(135deg, #f5dce5, #f7eee9 55%, #dfd9ee);
}
html[data-chat-bg="seaside"] {
  --chat-bg-image: linear-gradient(155deg, #d8ecf1 0%, #e9f3ee 52%, #cbdce9 100%);
}
html[data-chat-bg="forest"] {
  --chat-bg-image: radial-gradient(circle at 82% 18%, rgba(255,255,255,.55), transparent 40%), linear-gradient(135deg, #d9e6dc, #edf0df 58%, #c7d8d0);
}
html[data-chat-bg="custom"] { --chat-bg-image: var(--chat-custom-image); }
html[data-chat-bg]:not([data-chat-bg="default"]) .chat-main,
html[data-chat-bg]:not([data-chat-bg="default"]) .cs-preview {
  background-color: var(--chat);
  background-image: var(--chat-bg-overlay), var(--chat-bg-image);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}
.chat-head {
  height: 62px;
  gap: 12px;
  padding: 0 16px 0 22px;
  background: var(--glass);
  border-bottom-color: var(--line);
}
.chat-title { flex: 1; min-width: 0; }
.name-row { min-width: 0; gap: 8px; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.name-row #chatName { min-width: 0; }
.sub-row { margin-top: 3px; font-size: 12px; }
.online-dot { width: 7px; height: 7px; flex: none; }
.chat-head .chat-avatar { width: 38px; height: 38px; font-size: 14px; }
.chat-actions { gap: 4px; }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.icon-btn:active, .tool-btn:active, .rail-btn:active { transform: scale(.96); }
.chat-search { height: 48px; padding: 0 18px; background: var(--glass); }
.chat-search input { font-size: 13px; }
.msg-scroll {
  padding: 20px 26px 12px;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}
.msg-list { width: min(100%, 920px); margin-inline: auto; }
.empty-state {
  max-width: 340px;
  margin-top: 12vh;
  padding: 26px 26px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--glass);
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.empty-state .empty-avatar {
  width: 66px;
  height: 66px;
  margin-bottom: 16px;
  background: linear-gradient(145deg, #dfb5d2, #aa99e5 55%, #879ed7);
  box-shadow: 0 12px 26px -16px rgba(70, 105, 145, .45);
}
.empty-state p { margin-bottom: 8px; font-size: 15px; color: var(--text); }
.empty-state > span { font-size: 12px; }
.day-sep {
  margin: 14px 0 16px;
  padding: 4px 10px;
  border: 0;
  background: var(--hover);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.earlier-bar {
  margin: 4px 0 14px;
  padding: 6px 14px;
  border: 0;
  color: var(--brand-deep);
  background: var(--brand-soft);
}
.earlier-bar.error {
  color: var(--danger);
  border-color: var(--danger);
}
.msg-row { gap: 10px; padding: 2px 0; margin-bottom: 10px; }
.msg-row .avatar { width: 36px; height: 36px; margin-top: 3px; }
.msg-body { max-width: min(72%, 660px); }
.msg-row.grouped { margin-top: -6px; }
.msg-row.grouped > .avatar { visibility: hidden; }
.msg-row.grouped .msg-sender { display: none; }
.msg-row.grouped .msg-meta { margin-top: 1px; }
.msg-row.grouped .msg-meta > span:first-child { display: none; }
.typing-row { margin-top: 3px; margin-bottom: 4px; }
.typing-row .avatar { width: 32px; height: 32px; opacity: .82; }
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 52px;
  min-height: 36px;
  padding: 10px 14px;
}
.typing-bubble i {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--text-3);
  animation: typing-dot 1.2s ease-in-out infinite;
}
.typing-bubble i:nth-child(2) { animation-delay: .16s; }
.typing-bubble i:nth-child(3) { animation-delay: .32s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: .36; transform: translateY(0); }
  30% { opacity: .95; transform: translateY(-3px); }
}
.bubble {
  padding: 9px 13px;
  border-radius: var(--bubble-radius, 5px 14px 14px 14px);
  font-size: 14px;
  line-height: 1.65;
}
.msg-row.out .bubble {
  border-radius: var(--bubble-radius-out, 14px 5px 14px 14px);
  box-shadow: var(--bubble-shadow-out, none);
}
.msg-row.pending .bubble { opacity: .72; }
.msg-row.failed .bubble { outline: 1px solid rgba(223, 83, 103, .38); }
.msg-row:focus-within .msg-meta { opacity: 1; }
.msg-meta { margin-top: 4px; font-size: 11px; letter-spacing: 0; }
.msg-row.reply-failed .msg-meta { opacity: 1; color: var(--danger); }
.msg-meta .retry { min-height: 24px; }
html[data-bubble-in="tail"] .msg-row.in .bubble:not(.sticker):not(.media)::before {
  background: var(--bubble-bg, var(--bubble-in));
}
html[data-bubble-out="tail"] .msg-row.out .bubble:not(.sticker):not(.media)::after {
  background: var(--bubble-bg-out, var(--bubble-out));
}
html[data-bubble-out="line"] { --bubble-fg-out: var(--brand-deep); --bubble-border-out: 1.5px solid var(--brand-ring); }
.msg-row.selected { background: var(--brand-soft); border-radius: 10px; }
html[data-theme="dark"] .msg-row.selected { background: var(--active); }
.msg-check { border-color: var(--line-strong); }
.marquee-box { background: var(--brand-soft); }
.bubble .share-card, .bubble .fwd-box { border-radius: 10px; }
.bubble .share-card strong, .bubble .fwd-text, .bubble .fwd-chip { color: var(--text-1); }
.msg-row.out .bubble .share-card strong,
.msg-row.out .bubble .fwd-text,
.msg-row.out .bubble .fwd-chip { color: inherit; }
.msg-row.hit .bubble { box-shadow: 0 0 0 2px #e7ad4c, 0 8px 20px -12px rgba(231, 173, 76, .42); }
.system-tip, .msg-row.recalled .recalled-tip {
  padding: 5px 12px;
  border: 0;
  background: var(--hover);
}
.quote-ref { border-radius: 8px; background: var(--brand-soft); }
.quote-ref:hover { background: var(--active); }
.to-bottom {
  bottom: 10px;
  width: 38px;
  height: 38px;
  color: var(--brand-deep);
  background: var(--panel);
  border-color: var(--line-strong);
}
.to-bottom .badge.small { top: -5px; right: -5px; }

/* ---------- 输入区与表情浮层 ---------- */
.composer { padding: 9px 24px 16px; }
.composer-box, .quote-bar, .voice-recorder { width: min(100%, 900px); margin-inline: auto; }
.composer-box {
  border-radius: 12px;
  border-color: var(--line-strong);
  background: var(--panel);
  box-shadow: none;
}
.composer-box:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-ring);
}
.composer textarea { min-height: 46px; padding: 12px 14px 3px; line-height: 1.6; }
.composer-bar { padding: 4px 8px 7px; gap: 10px; }
.tools { gap: 3px; }
.tool-btn { width: 34px; height: 34px; border-radius: 8px; }
.tool-btn svg { width: 19px; height: 19px; }
.send-wrap { gap: 12px; }
.send-btn { height: 34px; padding: 0 17px; border-radius: 8px; }
.send-btn:disabled { color: var(--text-3); background: var(--hover); box-shadow: none; }
.send-hint { font-size: 11px; }
.quote-bar {
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid var(--brand-ring);
  border-left: 3px solid var(--brand);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.panel {
  left: 24px;
  right: 24px;
  bottom: 110px;
  max-width: 900px;
  height: 286px;
  margin-inline: auto;
  border-radius: 20px;
  border-color: var(--line-strong);
  box-shadow: 0 28px 70px -26px rgba(37, 29, 68, .38);
}
.panel.tall { height: 380px; }
.panel-head { padding: 10px 12px 10px 14px; }
.tab { min-height: 30px; padding: 6px 11px; border-radius: 9px; }
.tab.active { color: var(--brand-deep); }
.emoji-grid { padding: 12px 14px 16px; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.emoji-grid button { height: 40px; border-radius: 10px; }
.sticker-tools input { height: 32px; border-radius: 10px; }
.sticker-tools input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.sticker-grid { padding: 14px 14px 18px; gap: 10px; }
.sticker-item { border-radius: 12px; }
.sticker-item:hover { border-color: var(--brand-ring); }
.drop-mask {
  inset: 68px 0 0;
  margin: 12px;
  border-radius: 18px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}
.drop-mask > div {
  padding: 16px 24px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--brand-ring);
  box-shadow: var(--shadow-md);
}
.multi-bar {
  padding: 12px max(20px, calc((100% - 900px) / 2)) calc(12px + env(safe-area-inset-bottom));
  background: var(--glass);
}
.multi-count { font-weight: 600; color: var(--text); }
.multi-actions { gap: 8px; }
.multi-btn { border-radius: 11px; }
.multi-btn:hover { background: var(--brand-soft); color: var(--brand-deep); }
.multi-btn.danger:hover { color: var(--danger); background: rgba(228, 92, 112, .09); }

/* ---------- 菜单、模态框与表单 ---------- */
.ctx-menu {
  min-width: 176px;
  padding: 6px;
  border-radius: 14px;
  border-color: var(--line-strong);
  box-shadow: 0 20px 54px -20px rgba(29, 23, 51, .4);
}
.ctx-menu button { min-height: 38px; padding: 9px 11px; border-radius: 9px; }
.ctx-menu button:hover { background: var(--brand-soft); }
.ctx-menu button.danger:hover { background: rgba(228, 92, 112, .09); }
.presence-menu { min-width: 232px; }
.presence-menu .pm-head { padding: 8px 10px 10px; }
.presence-menu button.pm-item { border-radius: 10px; }
.lightbox { background: rgba(10, 10, 18, .86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); }
.lightbox img { border-radius: 14px; }
.lightbox-close { border: 1px solid rgba(255, 255, 255, .14); }
.modal-mask {
  padding: 24px;
  background: rgba(24, 20, 39, .44);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal {
  width: min(480px, 100%);
  max-height: 84vh;
  max-height: 84dvh;
  border-radius: 22px;
  border-color: var(--glass-border);
  background: var(--panel);
  box-shadow: 0 34px 100px -30px rgba(25, 19, 48, .52);
  animation: modal-in .22s var(--ease) both;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head { padding: 19px 18px 15px 24px; }
.modal-head h2, .cs-head-info h2 { font-size: 17px; letter-spacing: .01em; }
.modal-body { padding: 8px 24px 24px; overscroll-behavior: contain; }
.mini-modal { width: min(410px, 100%); }
.chat-modal { width: min(560px, 100%); }
.modal-actions { gap: 10px; margin-top: 20px; }
.btn-primary { min-height: 38px; padding: 9px 20px; border-radius: 11px; }
.btn-primary.danger { background: var(--danger); border-color: var(--danger); }
.ghost {
  min-height: 34px;
  padding: 7px 13px;
  border-radius: 10px;
  border-color: var(--line-strong);
  background: transparent;
}
.ghost:hover { color: var(--brand-deep); border-color: var(--brand-ring); background: var(--brand-soft); }
.setting-row { gap: 16px; padding: 16px 1px; }
.setting-row strong { font-size: 13.5px; }
.setting-row > div:first-child span { margin-top: 5px; line-height: 1.55; word-break: break-word; }
.setting-row.compact { padding: 12px 0; }
.cs-section { padding: 16px 0; }
.cs-label { margin-bottom: 11px; font-size: 13px; }
.cs-input {
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border-color: var(--line-strong);
  background: var(--hover);
  font-size: 13px;
}
.cs-input:focus { border-color: var(--brand); background: var(--panel); box-shadow: 0 0 0 3px var(--brand-ring); }
.password-field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.password-field .cs-input { flex: 1; min-width: 0; }
.password-toggle { flex: none; min-width: 52px; min-height: 38px; cursor: pointer; }
.token-input .password-toggle {
  padding: 0 11px;
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  background: var(--hover);
}
.password-field .password-toggle {
  padding: 0 12px;
  color: var(--text-2);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--hover);
}
.password-toggle:hover { color: var(--brand-deep); border-color: var(--brand); }
.setting-inline .cs-input { margin-top: 0; }
.announce-input { height: auto; min-height: 120px; padding: 11px 12px; }
.cs-hint { line-height: 1.7; }
.seg { padding: 4px; border: 1px solid var(--line); border-radius: 12px; }
.seg button { min-height: 30px; border-radius: 9px; }
.seg button.active { color: var(--brand-deep); background: var(--panel); }
.switch i { width: 40px; height: 22px; background: var(--line-strong); }
.switch i::after { width: 18px; height: 18px; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(18px); }
.chip, .chip-check, .bubble-opt, .cs-colors label {
  min-height: 34px;
  border-radius: 10px;
  border-color: var(--line-strong);
}
.chip.active, .chip-check:has(input:checked), .bubble-opt.active {
  color: var(--brand-deep);
  border-color: var(--brand-ring);
}
.cs-colors label { background: var(--pane); }
.bubble-preview, .cs-preview { border-radius: 16px; }
.profile-stats, .trait-detail {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--hover);
  opacity: 1;
  color: var(--text-2);
}
.profile-bond { border-top-color: var(--line); }
.profile-bond-title { font-size: 14px; }
.profile-head { margin-bottom: 16px; }
.profile-avatar { width: 60px; height: 60px; }
.avatar-crop-stage { box-shadow: 0 0 0 5px var(--brand-soft), var(--shadow-md); }
.avatar-crop-ring { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55), inset 0 0 24px rgba(0, 0, 0, .2); }
.forward-item, .cg-member { border: 1px solid transparent; }
.forward-item:hover, .cg-member:hover { background: var(--hover); border-color: var(--line); }
.cg-member.on { background: var(--brand-soft); border-color: var(--brand-ring); }
.toast {
  bottom: 30px;
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 12px;
  background: rgba(35, 31, 48, .92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .42);
}

/* ---------- 群资料与移动端页面 ---------- */
.group-side { flex-basis: 280px; width: 280px; background: var(--pane); }
html[data-theme="dark"] .group-side { background: var(--pane); }
.gs-head { min-height: 68px; padding: 13px 14px; }
.gs-avatar { width: 42px; height: 42px; }
.gs-body { padding: 12px; gap: 12px; }
.gs-card { padding: 12px; border-radius: 14px; border-color: var(--line); background: var(--chat); }
html[data-theme="dark"] .gs-card { background: rgba(255, 255, 255, .025); }
.gs-card-head { font-size: 12.5px; }
.gs-announce { line-height: 1.75; }
.gs-members { gap: 3px; }
.gs-member { min-height: 44px; padding: 7px 8px; border-radius: 10px; }
.gs-member .avatar { width: 32px; height: 32px; }
.gs-member-more { opacity: .4; }
.gs-member:hover .gs-member-more { opacity: 1; }
.gs-search { height: 36px; margin: 10px 0; }
.gs-tabs button { min-height: 28px; }
.gs-file { min-height: 38px; }
.gs-album { gap: 6px; }
.gs-album img { border-radius: 9px; }
.group-avatar { background: linear-gradient(145deg, #a9a0ed, #7d70d5); }
.mobile-page { background: var(--pane); }
.mp-head { min-height: 60px; padding-inline: 12px; background: var(--glass); }
.mp-head h2 { font-size: 17px; }
.mp-body { padding-inline: 14px; }
.mp-section { font-weight: 600; letter-spacing: .04em; }
.mp-contact { padding: 11px 10px; border-radius: 14px; }
.mp-contact:not(.static):hover { background: var(--brand-soft); }
.sheet {
  width: calc(100% - 16px);
  margin: 0 8px calc(8px + env(safe-area-inset-bottom));
  padding: 8px;
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  background: var(--panel);
}
.sheet button { min-height: 48px; border-radius: 13px; }
.sheet button.cancel { margin-top: 6px; border-top: 0; border-radius: 13px; background: var(--hover); }

/* 沉浸模式只收起技术噪声；断线错误、未读、重试和设置入口不受影响。 */
html[data-immersive="1"] .list-foot,
html[data-immersive="1"] #onlineDot,
html[data-immersive="1"] .send-hint,
html[data-immersive="1"] #connChip.ok,
html[data-immersive="1"] .pm-freq,
html[data-immersive="1"] .ms-lv,
html[data-immersive="1"] #profileStats,
html[data-immersive="1"] #profileBondMeta {
  display: none !important;
}

/* ---------- 首次启动与分层诊断 ---------- */
.setup-panel {
  margin: 10px 0 6px;
  padding: 18px;
  border: 1px solid var(--brand-ring);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--brand-soft), transparent 82%);
}
.setup-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-deep);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
}
.setup-panel h3 { margin: 0; font-size: 17px; line-height: 1.45; }
.setup-panel > p { margin: 8px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.7; }
.setup-steps {
  margin: 12px 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.75;
}
.setup-steps li + li { margin-top: 3px; }
.setup-panel .setup-state { color: var(--brand-deep); }
.setup-panel .setup-state:empty { display: none; }
.setup-panel .btn-primary { width: 100%; margin-top: 14px; }
.service-settings-state {
  margin: 10px 0 2px;
  padding: 10px 12px;
  border: 1px solid rgba(228, 92, 112, .24);
  border-radius: 11px;
  background: rgba(228, 92, 112, .07);
  color: var(--danger);
  font-size: 11.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.service-settings-state.warning {
  border-color: rgba(217, 154, 62, .28);
  background: rgba(217, 154, 62, .08);
  color: var(--warning);
}
.diagnostic-test-result { margin-top: 0; overflow-wrap: anywhere; }
.diagnostic-test-result.success, .diagnostic-last-test.success { color: var(--ok); }
.diagnostic-test-result.error, .diagnostic-last-test.error { color: var(--danger); }
.diagnostics-block { gap: 12px; }
.diagnostics-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.diagnostics-head > div { min-width: 0; }
.diagnostics-head .mini-btn { flex: none; }
.diagnostics-list { display: grid; gap: 8px; }
.diagnostics-empty { margin: 0; padding: 4px 0; }
.diagnostics-empty.warning { color: var(--warning); }
.diagnostic-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--hover);
}
.diagnostic-card.error { border-color: rgba(228, 92, 112, .25); }
.diagnostic-card.warning { border-color: rgba(217, 154, 62, .25); }
.diagnostic-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.diagnostic-card-head strong { min-width: 0; font-size: 12.5px; }
.diagnostic-badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--hover);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
}
.diagnostic-badge.ok { color: var(--ok); background: rgba(44, 171, 124, .10); }
.diagnostic-badge.warning { color: var(--warning); background: rgba(217, 154, 62, .11); }
.diagnostic-badge.error { color: var(--danger); background: rgba(228, 92, 112, .10); }
.diagnostic-summary { margin: 7px 0 0; color: var(--text-2); font-size: 11.5px; line-height: 1.6; }
.diagnostic-details { margin: 6px 0 0; padding-left: 16px; color: var(--text-3); font-size: 10.5px; line-height: 1.7; }
.diagnostic-last-test {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
#settings .setting-inline button:disabled, .diagnostics-head button:disabled, .setup-panel button:disabled {
  cursor: wait;
  opacity: .55;
}

@media (max-width: 560px) {
  .setup-panel { padding: 15px; border-radius: 14px; }
  #settings .setting-inline { flex-wrap: wrap; }
  #settings .setting-inline .cs-hint { flex-basis: 100%; }
  #settings .setting-inline .mini-btn { flex: 1; }
  .diagnostics-head { align-items: flex-start; }
  .diagnostics-head .mini-btn { flex: none; }
}

/* ---------- 响应式收尾 ---------- */
@media (min-width: 1600px) {
  .app { grid-template-columns: 76px 320px minmax(0, 1fr); padding: 16px; }
  .msg-list, .composer-box, .quote-bar, .voice-recorder { max-width: 980px; }
  .msg-scroll { padding-inline: 38px; }
}

@media (max-width: 1120px) {
  .app { grid-template-columns: 64px 264px minmax(0, 1fr); padding: 10px; }
  .rail-btn.active::before { left: -10px; }
  .list-head { padding-inline: 14px; }
  .presence-chip, .conn-chip { padding-inline: 7px; }
  .chat-head { padding-inline: 18px 14px; }
  .msg-scroll { padding: 22px 20px 12px; }
  .msg-body { max-width: 74%; }
  .composer { padding: 9px 18px 16px; }
  .panel { left: 18px; right: 18px; }
  .group-side { flex-basis: 244px; width: 244px; }
}

@media (min-width: 881px) and (max-width: 1050px) {
  .group-side {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: 12;
    flex: none;
    width: min(310px, 88%);
    border-radius: 0 22px 22px 0;
    box-shadow: -24px 0 52px -26px rgba(26, 22, 44, .48);
  }
  .send-hint { display: none; }
}

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; padding: 0; }
  .rail { display: none; }
  .list-pane, .chat-pane { border: 0; border-radius: 0; box-shadow: none; }
  .list-head { padding: calc(16px + env(safe-area-inset-top)) 15px 12px; }
  .mobile-head { gap: 12px; padding: 4px 3px 16px; }
  .mh-avatar { width: 46px; height: 46px; }
  .mh-name { font-size: 19px; letter-spacing: .01em; }
  .mh-status { min-height: 24px; }
  .mh-plus { width: 40px; height: 40px; border-radius: 13px; }
  .search-box { height: 42px; border-radius: 13px; }
  .conv-list { padding: 3px 9px 100px; }
  .conv { padding: 12px 11px; border-radius: 15px; }
  .conv .avatar { width: 50px; height: 50px; }
  .conv.active { background: var(--active); border-color: transparent; }
  .conv-name { font-size: 15px; }
  .conv-preview { font-size: 12.5px; }
  .mobile-nav {
    height: calc(66px + env(safe-area-inset-bottom));
    background: var(--glass);
    border-top-color: var(--line);
  }
  .mn-item { gap: 3px; font-size: 10.5px; }
  .mn-icon { min-width: 44px; height: 29px; border-radius: 11px; transition: background .16s ease; }
  .mn-item.active .mn-icon { background: var(--brand-soft); }
  .chat-head {
    height: calc(60px + env(safe-area-inset-top));
    gap: 8px;
    padding: env(safe-area-inset-top) 8px 0 5px;
  }
  .chat-head .chat-avatar { width: 36px; height: 36px; }
  .chat-actions { gap: 2px; }
  .chat-actions .icon-btn, .back-btn { width: 44px; height: 44px; }
  .name-row { gap: 6px; font-size: 15px; }
  .sub-row { margin-top: 3px; font-size: 10.5px; }
  .bond-chip { margin-left: 2px; padding-inline: 6px; }
  .msg-scroll { padding: 17px 12px 10px; scrollbar-gutter: auto; }
  .msg-list { width: 100%; }
  .msg-row { gap: 8px; margin-bottom: 10px; }
  .msg-row .avatar { width: 35px; height: 35px; }
  .msg-body { max-width: 79%; }
  .bubble { padding: 9px 12px; font-size: 14px; line-height: 1.68; }
  .msg-meta { opacity: .68; }
  .empty-state { margin-top: 10vh; padding: 26px 22px 23px; }
  .day-sep { margin: 12px 0 16px; }
  .composer { padding: 7px 9px calc(9px + env(safe-area-inset-bottom)); }
  .composer-box {
    border: 1px solid var(--line-strong);
    border-radius: 19px;
    background: var(--panel);
    box-shadow: var(--shadow-sm);
  }
  .composer-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
  .composer textarea {
    min-height: 43px;
    max-height: 108px;
    padding: 11px 13px 2px;
    border: 0;
    border-radius: 16px;
    background: transparent;
  }
  .composer-bar { padding: 4px 7px 6px; gap: 6px; }
  .voice-recorder { gap: 8px; padding: 8px 9px; border-radius: 16px; }
  .voice-cancel { width: 44px; height: 44px; }
  .voice-action, .voice-send { min-height: 44px; padding-inline: 11px; }
  .tools { justify-content: flex-start; gap: 4px; }
  .tool-btn { width: 44px; height: 44px; border-radius: 11px; }
  .tool-btn svg { width: 21px; height: 21px; }
  .send-btn.desktop-send { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 12px; }
  .send-btn.desktop-send span { display: none; }
  .send-btn.desktop-send svg { width: 18px; height: 18px; }
  .quote-bar { margin-bottom: 7px; }
  .panel {
    left: 8px;
    right: 8px;
    bottom: calc(108px + env(safe-area-inset-bottom));
    height: min(47vh, 390px);
    border-radius: 20px;
  }
  .panel.tall { height: min(56vh, 480px); }
  .multi-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .multi-actions { justify-content: space-between; gap: 2px; }
  .multi-btn { flex: 1; min-width: 0; padding-inline: 5px; }
  .ctx-menu button { min-height: 43px; }
  .gs-member-more { opacity: 1; }
  .group-side.mobile-open { background: var(--pane); }
  .group-side.mobile-open .gs-head { padding-top: calc(13px + env(safe-area-inset-top)); }
  .group-side.mobile-open .gs-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .lightbox { padding: 20px; }
  .lightbox-close { top: calc(14px + env(safe-area-inset-top)); right: 14px; }
}

@media (max-width: 560px) {
  .chat-actions #btnChatStyle, .chat-actions #btnSearchMsg { display: none; }
  .modal-mask { align-items: end; padding: 0; }
  .modal, .mini-modal, .chat-modal, .avatar-modal {
    width: 100%;
    max-height: 89vh;
    max-height: 89dvh;
    border-radius: 24px 24px 0 0;
    border-bottom: 0;
    animation: sheet-up .24s var(--ease) both;
  }
  .modal-head { padding: 18px 15px 14px 20px; }
  .modal-body { padding: 8px 20px calc(22px + env(safe-area-inset-bottom)); }
  .modal-actions { position: sticky; bottom: 0; padding-top: 6px; background: var(--panel); }
  .setting-row { gap: 12px; }
  .setting-row:not(.column) { align-items: center; }
  .setting-row > div:first-child span { font-size: 11px; }
  .cs-colors { gap: 7px; }
  .cs-colors label { padding-inline: 7px; }
  .connect { padding: 20px; }
  .connect-card { padding: 38px 25px 27px; border-radius: 26px; }
  .brand-avatar { width: 82px; height: 82px; }
  .connect-card h1 { font-size: 28px; }
  .connect-bg-btn { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .chat-head { gap: 5px; }
  .msg-row .avatar { width: 32px; height: 32px; }
  .msg-body { max-width: 80%; }
  .msg-scroll { padding-inline: 10px; }
  .composer { padding-inline: 7px; }
  .panel { left: 6px; right: 6px; }
  .empty-state { max-width: 300px; }
  .modal-head h2, .cs-head-info h2 { font-size: 16px; }
}

@media (hover: none) {
  .rail-btn[data-tip]::after { display: none; }
  .msg-meta { opacity: .68; }
  .emoji-grid button:hover, .sticker-item:hover, .to-bottom:hover { transform: none; }
}

/* 角色卡草稿、独立试聊与人设版本 */
.character-modal, .persona-modal { width: min(760px, 100%); max-height: 90vh; max-height: 90dvh; }
.character-body, .persona-body { display: flex; flex-direction: column; gap: 14px; }
.character-heading { min-width: 0; }
.character-heading h2 { margin-bottom: 4px; }
.character-heading p { margin: 0; color: var(--text-3); font-size: 12px; line-height: 1.55; }
.char-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.character-field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.character-field > span { color: var(--text-2); font-size: 12px; font-weight: 600; }
.character-field .cs-input { width: 100%; margin: 0; box-sizing: border-box; }
.character-field textarea.cs-input { resize: vertical; line-height: 1.65; min-height: 64px; }
.character-source-actions { display: flex; gap: 9px; }
.character-source-actions > button { flex: 1; margin: 0; }
#characterStatus { margin: -3px 0 0; line-height: 1.6; }
.character-editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
.character-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.character-persona-input { min-height: 236px !important; font-family: inherit; }
.character-edit-meta, .persona-editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -5px;
  color: var(--text-3);
  font-size: 11px;
}
.character-edit-meta .mini-btn { flex: none; }
.character-trial {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.character-trial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.character-trial-head > div { display: flex; flex-direction: column; gap: 3px; }
.character-trial-head strong { font-size: 13px; }
.character-trial-head span { color: var(--text-3); font-size: 10.5px; }
.character-trial-badge {
  flex: none;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--brand-deep) !important;
  background: var(--brand-soft);
  font-weight: 600;
}
.character-trial-log {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 142px;
  max-height: 238px;
  overflow-y: auto;
  padding: 14px;
}
.character-trial-empty { margin: auto; padding: 24px 10px; color: var(--text-3); font-size: 12px; text-align: center; }
.character-trial-row { display: flex; }
.character-trial-row.from-user { justify-content: flex-end; }
.character-trial-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 6px 15px 15px 15px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(30, 25, 55, .06);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.character-trial-row.from-user .character-trial-bubble {
  border-radius: 15px 6px 15px 15px;
  color: #fff;
  background: var(--brand);
}
.character-trial-composer { display: flex; align-items: flex-end; gap: 9px; padding: 11px; border-top: 1px solid var(--line); }
.character-trial-composer .cs-input { flex: 1; min-width: 0; margin: 0; resize: none; }
.character-trial-composer .btn-primary { flex: none; min-height: 38px; }
.persona-editor-input { min-height: 300px !important; font-family: inherit; }
.persona-history { padding-top: 13px; border-top: 1px solid var(--line); }
.persona-history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.persona-history-head strong { font-size: 13px; }
.persona-history-head span { color: var(--text-3); font-size: 11px; }
.persona-versions { display: flex; flex-direction: column; gap: 9px; max-height: 224px; overflow-y: auto; }
.persona-version-empty { padding: 18px 12px; border: 1px dashed var(--line); border-radius: 12px; color: var(--text-3); font-size: 12px; text-align: center; }
.persona-version-card { padding: 11px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.persona-version-head, .persona-version-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.persona-version-head strong { font-size: 12px; }
.persona-version-head time, .persona-version-footer > span { color: var(--text-3); font-size: 10.5px; }
.persona-version-card p {
  display: -webkit-box;
  overflow: hidden;
  margin: 8px 0;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.persona-version-footer .mini-btn { min-height: 28px; }

@media (max-width: 560px) {
  .character-form-grid { grid-template-columns: 1fr; }
  .character-source-actions { flex-direction: column; }
  .character-trial-head, .persona-history-head { align-items: flex-start; }
  .character-trial-head { flex-direction: column; gap: 8px; }
  .character-trial-log { max-height: 210px; }
  .character-trial-bubble { max-width: 90%; }
  .character-trial-composer { align-items: stretch; }
  .character-trial-composer .btn-primary { align-self: flex-end; }
  .persona-editor-input { min-height: 240px !important; }
  .persona-history-head { flex-direction: column; gap: 4px; }
  .character-edit-meta, .persona-editor-meta { align-items: flex-start; }
}

/* 角色语音：消息内轻量朗读入口 + 设置面板 */
.msg-meta .speech-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  margin: -3px 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.msg-meta .speech-btn svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.msg-meta .speech-btn:hover,
.msg-meta .speech-btn.is-loading,
.msg-meta .speech-btn.is-playing {
  color: var(--brand-deep);
  background: var(--brand-soft);
}
.msg-meta .speech-btn.is-error { color: var(--danger); }
.msg-meta .speech-btn.is-loading svg { animation: speech-pulse 1.1s ease-in-out infinite; }
.msg-meta .speech-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.msg-row.speech-active .msg-meta { opacity: 1; }
@keyframes speech-pulse { 50% { opacity: .35; } }

.setting-stack .setting-inline { flex-wrap: wrap; }
#settingsTtsPrivacy, #csVoiceHint { margin: 0; }
#settingsTtsState { min-width: 140px; }
.cs-voice-id-row { margin-top: 16px; }
.cs-voice-id-row .cs-input { width: min(240px, 68%); margin: 0; }
.cs-voice-speed-row { margin-top: 14px; }
.cs-voice-speed-row .trait-name { width: 4.8em; }
.cs-voice-speed-row .trait-val { width: 3.6em; }
#csVoiceAuto:disabled + i { opacity: .45; cursor: not-allowed; }

@media (max-width: 560px) {
  .cs-voice-id-row { align-items: stretch; flex-direction: column; gap: 7px; }
  .cs-voice-id-row .cs-input { width: 100%; }
  #settingsTtsSave { margin-left: auto; }
}

/* 会话管理：保留原会话按钮，在兄弟入口承载右键以外的显式操作。 */
.conv-wrap { position: relative; }
.conv-wrap .conv { padding-right: 42px; }
.conv-wrap .conv.pinned:not(.active) { background: var(--hover); }
.conv-wrap .conv.pinned:not(.active):hover { background: var(--active); }
.conv-more {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  color: var(--text-3);
  background: var(--panel);
  box-shadow: 0 2px 9px rgba(37, 29, 65, .1);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.conv-wrap:hover .conv-more,
.conv-wrap:focus-within .conv-more,
.conv-more:focus-visible { opacity: 1; pointer-events: auto; }
.conv-more:hover { color: var(--brand-deep); background: var(--brand-soft); }
.conv-more svg { width: 17px; height: 17px; }
.conv-mute { display: inline-flex; flex: none; color: var(--text-3); opacity: .72; }
.conv-mute svg { width: 13px; height: 13px; }
.conv-unread-dot {
  flex: none;
  width: 9px;
  height: 9px;
  margin: 0 4px;
  border-radius: 50%;
  background: #ed647c;
  box-shadow: 0 2px 7px -2px rgba(219, 71, 99, .58);
}
.ctx-menu button:focus-visible,
.sheet button:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

@media (max-width: 880px) {
  .conv-wrap .conv { padding-right: 56px; }
  .conv-more {
    right: 5px;
    width: 44px;
    height: 44px;
    background: transparent;
    box-shadow: none;
    opacity: .62;
    pointer-events: auto;
  }
  .conv-more svg { width: 20px; height: 20px; }
}
@media (hover: none) {
  .conv-more { opacity: .68; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .msg-row, .empty-state, .panel, .modal, .sheet { animation: none !important; }
  .msg-meta .speech-btn.is-loading svg { animation: none; }
  .voice-record-dot, .voice-message .voice-wave i { animation: none !important; }
  .typing-bubble i { animation: none !important; opacity: .65; transform: none; }
  .conv-more { transition: none; }
}

/* 桌面联系人：只替换左栏内容，右侧当前聊天保持不动。 */
.desktop-contacts {
  display: none;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
.desktop-contacts-head { flex: none; padding: 20px 17px 14px; }
.desktop-contacts-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 3px 14px;
}
.desktop-contacts-title strong { font-size: 16px; }
.desktop-contacts-title span {
  color: var(--text-3);
  font-size: 10.5px;
  white-space: nowrap;
}
.desktop-contact-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 3px 10px 14px;
}
.desktop-contact-section + .desktop-contact-section { margin-top: 9px; }
.desktop-contact-heading {
  margin: 0;
  padding: 10px 11px 7px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
}
.desktop-contact {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 2px 0;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  text-align: left;
}
.desktop-contact:hover { background: var(--hover); }
.desktop-contact.active {
  border-color: var(--active-line);
  background: var(--active);
}
.desktop-contact.active::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}
.desktop-contact .avatar { width: 44px; height: 44px; }
.desktop-contact-main { flex: 1; min-width: 0; }
.desktop-contact-main strong,
.desktop-contact-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.desktop-contact-main strong { font-size: 14px; font-weight: 600; }
.desktop-contact-main span { margin-top: 4px; color: var(--text-3); font-size: 11.5px; }
.desktop-contact-empty {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 190px;
  padding: 28px 22px;
  color: var(--text-3);
  text-align: center;
}
.desktop-contact-empty strong { color: var(--text-2); font-size: 13px; }
.desktop-contact-empty span { font-size: 11.5px; line-height: 1.7; }

@media (min-width: 881px) {
  .list-pane[data-desktop-view="contacts"] > .list-head,
  .list-pane[data-desktop-view="contacts"] > .conv-list,
  .list-pane[data-desktop-view="contacts"] > .list-foot { display: none; }
  .list-pane[data-desktop-view="contacts"] > .desktop-contacts { display: flex; }
}
@media (max-width: 1120px) and (min-width: 881px) {
  .desktop-contacts-head { padding-inline: 14px; }
  .desktop-contacts-title { align-items: flex-start; flex-direction: column; gap: 4px; }
}

/* 完整历史搜索：输入条固定在上，结果体独立滚动，不改写消息列表。 */
.chat-search {
  flex: 0 1 auto;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  height: auto;
  min-height: 48px;
  max-height: min(46vh, 440px);
  max-height: min(46dvh, 440px);
  padding: 0;
  overflow: hidden;
}
.chat-search-bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
}
.chat-search-bar > svg { width: 16px; height: 16px; }
.chat-search-bar .search-count { flex: none; }
.chat-search-bar .icon-btn { flex: none; }
.chat-search-body {
  display: flex;
  flex: 0 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
}
.chat-search-status {
  flex: none;
  margin: 2px 8px 8px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.6;
}
.chat-search-status.error { color: var(--danger); }
.chat-search-error {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 8px;
  padding: 9px 11px;
  border: 1px solid rgba(228, 92, 112, .24);
  border-radius: 11px;
  color: var(--danger);
  background: rgba(228, 92, 112, .07);
  font-size: 11.5px;
  line-height: 1.55;
}
.chat-search-error button {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 8px;
  color: var(--danger);
  background: var(--panel);
}
.chat-search-error button:hover { background: var(--hover); }
.chat-search-error button svg { width: 14px; height: 14px; color: currentColor; }
.chat-search-results { display: flex; flex: none; flex-direction: column; gap: 4px; }
.chat-search-result {
  display: block;
  flex: none;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: left;
}
.chat-search-result:hover { background: var(--hover); }
.chat-search-result.is-locating {
  border-color: var(--brand-ring);
  background: var(--brand-soft);
}
.chat-search-result-head { display: flex; align-items: baseline; gap: 10px; }
.chat-search-result-head strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.chat-search-result-head time {
  flex: none;
  color: var(--text-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.search-hit {
  padding: 0 1px;
  border-radius: 3px;
  background: var(--brand-ring);
  color: var(--brand-deep);
  font-weight: 600;
}
.chat-search-result-text {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 5px;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.chat-search-result-locating {
  display: block;
  margin-top: 5px;
  color: var(--brand-deep);
  font-size: 10.5px;
}
.chat-search-more {
  align-self: center;
  flex: none;
  min-height: 34px;
  margin-top: 7px;
  padding: 6px 18px;
  border-radius: 10px;
  color: var(--brand-deep);
  background: var(--brand-soft);
  font-size: 12px;
}
.chat-search-more:hover { background: var(--active); }
.chat-search-more:disabled { opacity: .6; cursor: wait; }

@media (max-width: 880px) {
  .chat-search {
    max-height: 58vh;
    max-height: 58dvh;
  }
  .chat-search-bar { min-height: 52px; padding-inline: 10px; }
  .chat-search-bar .icon-btn { width: 38px; height: 38px; }
  .chat-search-body { padding: 8px; }
  .chat-search-result { padding: 11px 12px; }
}

/* ---------- 左侧全局搜索：联系人即时筛选 + 各会话完整历史 ---------- */
.global-search-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 8px 14px;
}
.list-pane.global-searching > .conv-list { display: none; }
.global-search-status {
  padding: 8px 10px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.6;
}
.global-search-status:empty { display: none; }
.global-search-status.error { color: var(--danger); }
.global-search-section + .global-search-section { margin-top: 12px; }
.global-search-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
}
.global-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  text-align: left;
}
.global-search-item:hover, .global-search-item:focus-visible { background: var(--hover); }
.global-search-item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.global-search-item .avatar { width: 36px; height: 36px; flex: none; font-size: 13px; }
.global-search-item-main { flex: 1; min-width: 0; }
.global-search-item-top { display: flex; align-items: baseline; gap: 8px; }
.global-search-item-top strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.global-search-item-top time { flex: none; color: var(--text-3); font-size: 10px; }
.global-search-item-text {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.global-search-item.message { align-items: flex-start; }
.global-search-item.message .avatar { width: 28px; height: 28px; margin-top: 2px; font-size: 11px; }
.global-search-source { color: var(--brand-deep); }
.global-search-empty { padding: 32px 16px; text-align: center; color: var(--text-3); font-size: 12px; }
@media (min-width: 881px) {
  .list-pane[data-desktop-view="contacts"] > .global-search-panel { display: none; }
}
@media (max-width: 880px) {
  .global-search-panel { padding-inline: 10px; }
  .global-search-item { min-height: 58px; padding: 10px; }
}

/* ---------- 角色陪伴主页 ---------- */
.profile-modal { width: min(540px, 100%); }
.profile-body { padding-top: 2px; }
.profile-hero {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, var(--brand-soft), transparent 72%), var(--chat);
}
.profile-hero .profile-head { gap: 15px; margin-bottom: 0; }
.profile-hero .profile-avatar { width: 72px; height: 72px; font-size: 25px; }
.profile-hero .profile-meta { gap: 7px; }
.profile-hero .profile-meta strong { font-size: 22px; font-weight: 600; }
.profile-hero .profile-meta span { font-size: 13px; line-height: 1.55; opacity: 1; color: var(--text-2); }
.profile-hero .profile-stats {
  margin: 13px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  line-height: 1.6;
}
.profile-continue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 16px;
}
.profile-continue svg { width: 17px; height: 17px; }
.profile-life-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  background: var(--pane);
  transition: border-color .16s ease, background .16s ease;
}
.profile-life-entry:hover { border-color: var(--brand-ring); background: var(--brand-soft); }
.profile-life-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--brand-deep);
  background: var(--brand-soft);
}
.profile-life-copy { display: flex; flex: 1; flex-direction: column; gap: 5px; min-width: 0; }
.profile-life-copy strong { font-size: 14px; }
.profile-life-copy > span { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.profile-life-arrow { width: 17px; height: 17px; color: var(--text-3); transform: rotate(180deg); }
.profile-management { margin-top: 14px; border-top: 1px solid var(--line); }
.profile-management > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 4px 2px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.profile-management > summary::-webkit-details-marker { display: none; }
.profile-management > summary svg { width: 17px; height: 17px; transition: transform .16s ease; }
.profile-management[open] > summary svg { transform: rotate(90deg); }
.profile-management-body { padding-bottom: 2px; }
.profile-management .profile-memory-row { padding: 12px 1px; }
.profile-management .profile-bond { margin-top: 4px; padding-top: 14px; }
.profile-management .profile-bond-actions { margin-top: 12px; }

@media (max-width: 560px) {
  .profile-hero { padding: 16px; border-radius: 14px; }
  .profile-hero .profile-avatar { width: 64px; height: 64px; }
  .profile-hero .profile-meta strong { font-size: 20px; }
  .profile-life-entry { padding: 13px; }
}

/* ---------- 日常设置与高级配置分层 ---------- */
.settings-advanced {
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.settings-advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  padding: 12px 2px;
  cursor: pointer;
  list-style: none;
}
.settings-advanced > summary::-webkit-details-marker { display: none; }
.settings-advanced > summary > span { display: flex; flex-direction: column; gap: 5px; }
.settings-advanced > summary strong { font-size: 13.5px; }
.settings-advanced > summary small { color: var(--text-3); font-size: 11.5px; }
.settings-advanced > summary svg {
  width: 17px;
  height: 17px;
  color: var(--text-3);
  transform: rotate(180deg);
  transition: transform .16s ease;
}
.settings-advanced[open] > summary svg { transform: rotate(270deg); }
.settings-advanced-body {
  margin: 0 -8px;
  padding: 0 8px 8px;
  border-radius: 10px;
  background: var(--hover);
}
.settings-advanced-body > .setting-row:first-child { padding-top: 18px; }

@media (max-width: 880px) {
  .mobile-nav .mn-item { min-width: 0; }
  .sheet button { min-height: 46px; }
}

/* ---------- 本机聊天显示偏好：只影响消息流，不缩放整个应用 ---------- */
html[data-density="comfortable"] {
  --msg-gap: 12px;
  --msg-group-gap: -5px;
  --msg-avatar-size: 38px;
  --msg-bubble-padding-y: 10px;
  --msg-bubble-padding-x: 14px;
}
html[data-density="compact"] {
  --msg-gap: 5px;
  --msg-group-gap: -3px;
  --msg-avatar-size: 32px;
  --msg-bubble-padding-y: 6px;
  --msg-bubble-padding-x: 11px;
}
html[data-font-size="standard"] { --msg-font-size: 14px; }
html[data-font-size="large"] { --msg-font-size: 16px; }
html[data-font-size="xlarge"] { --msg-font-size: 18px; }
#msgList .msg-row { margin-bottom: var(--msg-gap, 10px); }
#msgList .msg-row.grouped { margin-top: var(--msg-group-gap, -6px); }
#msgList .msg-row > .avatar {
  width: var(--msg-avatar-size, 36px);
  height: var(--msg-avatar-size, 36px);
  font-size: calc(var(--msg-avatar-size, 36px) * .36);
}
#msgList .bubble {
  padding: var(--msg-bubble-padding-y, 9px) var(--msg-bubble-padding-x, 13px);
  font-size: var(--msg-font-size, 14px);
}
#msgList .bubble.sticker, #msgList .bubble.media { padding: 0; }
.settings-choice { flex: none; width: 150px; margin: 0; }
@media (max-width: 880px) {
  .composer textarea { font-size: 16px; }
}
@media (max-width: 560px) {
  .setting-row:has(.settings-choice) { align-items: flex-start; }
  .settings-choice { width: 118px; min-height: 40px; padding-inline: 8px; font-size: 16px; }
}

/* 角色主页与共同生活：真实状态摘要，快捷入口保持安静轻量。 */
.profile-today-kicker {
  color: var(--text-3) !important;
  font-size: 10.5px !important;
  letter-spacing: .08em;
}
#profileMood { overflow-wrap: anywhere; }
.profile-stats { color: var(--text-2); }
.profile-life-copy #profileLifeSummary { color: var(--text-2); }
.profile-life-copy .profile-life-next {
  color: var(--brand-deep);
  font-size: 11.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.profile-life-entry[aria-busy="true"] .profile-life-icon { opacity: .65; }
.shared-life-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-soft), transparent 85%), var(--chat);
}
.shared-life-overview-item {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  min-height: 56px;
  padding: 7px 5px;
  border-radius: 10px;
  color: var(--text-2);
  background: transparent;
}
.shared-life-overview-item:hover { color: var(--brand-deep); background: var(--brand-soft); }
.shared-life-overview-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.shared-life-overview-item strong { color: var(--text); font-size: 19px; line-height: 1.25; }
.shared-life-overview-item span { font-size: 11px; }
.shared-life-next {
  grid-column: 1 / -1;
  margin: 1px 3px 0;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.shared-life-next strong { color: var(--brand-deep); font-weight: 600; }
.shared-life-next.error { color: var(--danger); }
@media (max-width: 560px) {
  .shared-life-overview { gap: 4px; padding: 8px; }
  .shared-life-overview-item { padding-inline: 3px; }
}

/* ---------- Windows 桌面粉饰：QQ 式一体化标题栏，不进入 Android ---------- */
.desktop-titlebar { display: none; }
html.desktop-window .desktop-titlebar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 900;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
  background: var(--rail);
  border-bottom: 1px solid var(--line);
  user-select: none;
  -webkit-app-region: drag;
}
.desktop-window-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-left: 14px;
  font-size: 12px;
}
.desktop-window-brand strong { font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.desktop-window-brand > span:last-child { color: var(--text-3); font-size: 11px; }
.desktop-window-logo {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  color: #fff;
  background: var(--brand-soft);
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 7px rgba(22, 135, 217, .2);
}
.desktop-window-logo img { width: 100%; height: 100%; display: block; object-fit: cover; }
.desktop-window-controls { align-self: stretch; display: flex; -webkit-app-region: no-drag; }
.desktop-window-controls button {
  width: 46px;
  height: 100%;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  color: var(--text-2);
  background: transparent;
  transition: background .12s ease, color .12s ease;
}
.desktop-window-controls button:hover { color: var(--text); background: var(--hover); }
.desktop-window-controls button:focus-visible { outline: 2px solid var(--brand); outline-offset: -3px; }
.desktop-window-controls .window-close:hover { color: #fff; background: #e81123; }
.desktop-window-controls svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.15; }
#windowMaximize.is-maximized svg rect { x: 6.5px; y: 4.5px; width: 8px; height: 8px; }
#windowMaximize.is-maximized svg { transform: rotate(180deg); }
html.desktop-window .app { inset: 38px 0 0; padding: 0; }
html.desktop-window .connect { inset: 38px 0 0; }
html.desktop-window .rail { border: 0; border-right: 1px solid var(--line); border-radius: 0; }
html.desktop-window .list-pane { border: 0; border-right: 1px solid var(--line); }
html.desktop-window .chat-pane { border: 0; border-radius: 0; }
html.desktop-window .chat-head { background: var(--pane); }
html.desktop-window .list-foot { padding-block: 8px; }
html.desktop-window .rail-btn.active { border-radius: 8px; }
html.desktop-window .conv.active { background: var(--brand-soft); }
@media (min-width: 1600px) {
  html.desktop-window .app { padding: 0; }
}
@media (max-width: 1120px) {
  html.desktop-window .app { padding: 0; }
}

/* ---------- 双端更新：安静设置入口 + 用户确认的安装卡片 ---------- */
.update-settings { border-block: 1px solid var(--line); }
.update-kicker { display: block; margin-bottom: 5px; color: var(--brand); font-size: 10px; font-weight: 700; letter-spacing: .13em; }
.update-summary { margin: 0 0 16px; color: var(--text-2); font-size: 13px; }
.update-notes { max-height: 230px; margin: 0; padding: 16px 16px 16px 34px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--chat); color: var(--text-2); font-size: 13px; line-height: 1.85; }
.update-progress { width: 100%; height: 7px; margin-top: 20px; overflow: hidden; border: 0; border-radius: 9px; accent-color: var(--brand); }
.update-progress::-webkit-progress-bar { background: var(--brand-soft); }
.update-progress::-webkit-progress-value { border-radius: 9px; background: var(--brand); }
.update-state { min-height: 24px; margin: 12px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.update-actions { flex-wrap: wrap; }
@media (max-width: 560px) {
  .update-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .update-actions .btn-primary { grid-column: 1 / -1; grid-row: 1; }
  .update-actions button { width: 100%; }
}

/* ---------- Android / 手机：QQ 式高密度会话与单行输入栏 ---------- */
@media (max-width: 880px) {
  .list-head { padding: calc(12px + env(safe-area-inset-top)) 12px 9px; }
  .mobile-head { padding: 3px 3px 13px; }
  .search-box { height: 38px; border-radius: 10px; }
  .conv-list { padding: 2px 7px calc(84px + env(safe-area-inset-bottom)); }
  .conv { min-height: 70px; padding: 10px 9px; border-radius: 10px; }
  .conv .avatar { width: 48px; height: 48px; }
  .conv.active { background: var(--brand-soft); }
  .conv-name { font-size: 15px; line-height: 1.4; }
  .conv-preview { margin-top: 4px; color: var(--text-3); font-size: 12px; }
  .conv-time { align-self: flex-start; margin-top: 3px; font-size: 10.5px; }
  .conv-more { width: 30px; height: 36px; opacity: .5; }
  .mobile-nav { height: calc(62px + env(safe-area-inset-bottom)); }
  .mn-item.active .mn-icon { background: transparent; }
  .mn-icon svg { width: 24px; height: 24px; }

  .empty-state {
    max-width: 290px;
    margin: 14vh auto 0;
    padding: 22px 18px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .empty-state .empty-avatar { width: 68px; height: 68px; margin-bottom: 17px; box-shadow: none; }
  .empty-state p { margin-bottom: 7px; font-size: 15px; font-weight: 600; }
  .empty-state > span { color: var(--text-3); font-size: 12px; }

  .composer {
    padding: 6px 7px calc(7px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: var(--pane);
  }
  .composer-box {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  .composer-box:focus-within { border: 0; box-shadow: none; }
  .composer-row { flex: 1; min-width: 0; order: 2; display: flex; align-items: flex-end; }
  .composer textarea {
    flex: 1;
    width: 100%;
    min-height: 42px;
    max-height: 108px;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: 21px;
    background: var(--chat);
    line-height: 20px;
  }
  .composer textarea:focus { border-color: var(--brand-ring); }
  .composer-bar, .tools, .send-wrap { display: contents; }
  .tool-btn { flex: none; width: 40px; height: 42px; border-radius: 50%; }
  .tool-btn:active { background: var(--brand-soft); }
  #voiceBtn { order: 1; }
  #emojiBtn { order: 3; }
  #stickerBtn, #imageBtn { display: none; }
  #mobileMoreBtn { order: 4; }
  .send-btn.desktop-send {
    order: 5;
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
  }
  .composer:not(.has-text) .send-wrap { display: none; }
  .composer.has-text #mobileMoreBtn { display: none; }
  .panel { bottom: calc(61px + env(safe-area-inset-bottom)); }
  .composer-action-sheet { padding-top: 10px; }
}

@media (max-width: 370px) {
  .tool-btn { width: 36px; }
  .composer textarea { padding-inline: 11px; }
  .conv { padding-inline: 7px; }
}

@media (max-width: 880px) and (hover: none) {
  .conv-more { display: none; }
}

/* ==== 自定义：桌面 rail 的"+"弹出菜单（添加角色/创建群聊/手机同步） ==== */
.rail-menu {
  position: fixed;
  z-index: 400;
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--pane);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: rail-menu-in .14s ease both;
}
@keyframes rail-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.rail-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: none;
  color: var(--text);
  text-align: left;
  transition: background .14s ease;
}
.rail-menu button:hover { background: var(--hover); }
.rail-menu button svg { width: 18px; height: 18px; flex: none; color: var(--text-2); }
