/* 密聊 · 样式。浅色 / 深色通过 html[data-theme] 切换，所有颜色走变量。 */
:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --surface-3: #ecedf0;
  --border: #e5e6ea;
  --border-soft: #f0f1f3;
  --text: #141516;
  --text-2: #6e7278;
  --text-3: #9a9ea5;
  --accent: #0e8a74;
  --accent-ink: #ffffff;
  --accent-soft: #e3f4f0;
  --accent-soft-ink: #0b6e5d;
  --bubble-self: #0e8a74;
  --bubble-self-ink: #ffffff;
  --bubble-peer: #ffffff;
  --bubble-peer-ink: #141516;
  --danger: #d9463e;
  --link: #0b6fcf;
  --warn-bg: #fff4e5;
  --warn-ink: #7a4800;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.18);
  --overlay: rgba(20, 21, 22, 0.45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tap: 44px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e0f12;
  --surface: #1c1f24;
  --surface-2: #23262c;
  --surface-3: #2b2f36;
  --border: #2b2f36;
  --border-soft: #22252b;
  --text: #eceef1;
  --text-2: #a0a5ad;
  --text-3: #6e737b;
  --accent: #35b99f;
  --accent-ink: #0e0f12;
  --accent-soft: #163a33;
  --accent-soft-ink: #5ccbb5;
  --bubble-self: #2a8f78;
  --bubble-self-ink: #ffffff;
  --bubble-peer: #23262c;
  --bubble-peer-ink: #eceef1;
  --danger: #f07a74;
  --link: #5b9bf0;
  --warn-bg: #3a2c12;
  --warn-ink: #f0c070;
  --shadow: none;
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
b { font-weight: 600; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; pointer-events: none; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; align-items: center; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.col.gap { gap: 12px; }
.col.gap-s { gap: 8px; }
.spacer { flex: 1; }
.pad { padding: 12px 16px; }
.h2 { font-size: 20px; font-weight: 700; }
.blue { color: var(--link); }
.section-label { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 14px 4px 6px; }

/* ---------- 基础组件 ---------- */
.btn {
  height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.block { width: 100%; display: flex; }
.btn.small { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn.small .ic { width: 18px; height: 18px; }
.btn.icon { width: 36px; padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); font-weight: 500; }
.btn.danger-text { color: var(--danger); }
.icon-btn {
  width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text);
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.accent { color: var(--accent); }
.icon-btn.accent-fill { background: var(--accent); color: var(--accent-ink); width: 40px; height: 40px; margin: 2px; }
.icon-btn.outline { border: 1px solid var(--border); background: var(--surface); width: 40px; height: 40px; }
.icon-btn.sm { width: 36px; height: 36px; color: var(--text-2); }
.icon-btn.light { color: #fff; background: rgba(255, 255, 255, 0.15); }
.link-btn { border: 0; background: transparent; color: var(--accent); font-weight: 500; padding: 8px 6px; min-height: var(--tap); }
.link-btn.strong { font-weight: 700; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; font-style: normal; display: inline-flex; align-items: center; justify-content: center;
}
.badge.accent { background: var(--accent); color: var(--accent-ink); }

.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; overflow: hidden; border: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 19px;
  color: var(--text); background: var(--surface-3); user-select: none; -webkit-user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .ic { width: 50%; height: 50%; }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.md { width: 36px; height: 36px; font-size: 15px; }
.avatar.lg { width: 44px; height: 44px; font-size: 17px; }
.avatar.xl { width: 64px; height: 64px; font-size: 26px; }
.avatar.editable { cursor: pointer; }
.avatar.c0 { background: #e0f0ec; color: #0e8a74; }
.avatar.c1 { background: #ede7f8; color: #5b3fb5; }
.avatar.c2 { background: #fcebd9; color: #b4561c; }
.avatar.c3 { background: #ddebfa; color: #1d5fb3; }
.avatar.c4 { background: #fbe3e3; color: #b52a2a; }
.avatar.c5 { background: #e6f0d6; color: #4a7a12; }
.avatar.c6 { background: #fdf0c8; color: #8a6400; }
.avatar.c7 { background: #e5e6ea; color: #3a3f47; }
html[data-theme="dark"] .avatar.c0 { background: #1e3a33; color: #35b99f; }
html[data-theme="dark"] .avatar.c1 { background: #2e2748; color: #b39df0; }
html[data-theme="dark"] .avatar.c2 { background: #3d2e1a; color: #f0b36a; }
html[data-theme="dark"] .avatar.c3 { background: #1e2b3f; color: #5b9bf0; }
html[data-theme="dark"] .avatar.c4 { background: #3f1f1f; color: #f08080; }
html[data-theme="dark"] .avatar.c5 { background: #263a14; color: #a0d060; }
html[data-theme="dark"] .avatar.c6 { background: #3f3412; color: #f0d070; }
html[data-theme="dark"] .avatar.c7 { background: #2b2f36; color: #eceef1; }
.avatar.me { background: var(--accent); color: var(--accent-ink); }
.avatar.sys { background: var(--text); color: var(--bg); }

.card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }
.card.pad { padding: 14px; }
.card.list { overflow: hidden; display: flex; flex-direction: column; }
.card + .card, .card + .btn, .card + form, form + .card, .btn + .card { margin-top: 12px; }
.row-item {
  display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 10px 14px; border: 0; background: transparent;
  text-align: left; width: 100%; border-bottom: 1px solid var(--border-soft); color: var(--text);
}
.row-item:last-child { border-bottom: 0; }
button.row-item:active { background: var(--surface-2); }
.row-item .row-main { flex: 1; min-width: 0; font-size: 15px; }
.row-item .chev { width: 18px; height: 18px; color: var(--text-3); stroke-width: 2; }
.row-item.danger .row-main { color: var(--danger); }
.row-item.warn { background: var(--warn-bg); color: var(--warn-ink); }
.card.list.static .row-item { align-items: flex-start; padding: 12px 14px; }
.row-icon {
  width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.row-icon .ic { width: 18px; height: 18px; }
.row-icon.big { width: 56px; height: 56px; border-radius: 16px; }
.row-icon.big .ic { width: 26px; height: 26px; }
.row-icon.teal { background: var(--accent-soft); color: var(--accent); }
.row-icon.blue { background: #ddebfa; color: #1d5fb3; }
.row-icon.orange { background: #fcebd9; color: #b4561c; }
.row-icon.green { background: #e0f0ec; color: #0e8a74; }
.row-icon.purple { background: #ede7f8; color: #5b3fb5; }
.row-icon.red { background: #fbe3e3; color: #b52a2a; }
.row-icon.gray { background: var(--surface-3); color: var(--text); }
html[data-theme="dark"] .row-icon.blue { background: #1e2b3f; color: #5b9bf0; }
html[data-theme="dark"] .row-icon.orange { background: #3d2e1a; color: #f0b36a; }
html[data-theme="dark"] .row-icon.green { background: #1e3a33; color: #35b99f; }
html[data-theme="dark"] .row-icon.purple { background: #2e2748; color: #b39df0; }
html[data-theme="dark"] .row-icon.red { background: #3f1f1f; color: #f08080; }

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input {
  height: 48px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); padding: 0 14px;
  font-size: 16px; font-weight: 400; color: var(--text); outline: none; width: 100%;
}
.field input:focus { border-color: var(--accent); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.search-field {
  display: flex; align-items: center; gap: 8px; height: 38px; border-radius: 12px; background: var(--surface-3); padding: 0 12px; color: var(--text-2); flex: 1;
}
.search-field.tall { height: 46px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); margin-top: 12px; }
.search-field .ic { width: 18px; height: 18px; }
.search-field input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 15px; color: var(--text); outline: none; }
.search-field input::placeholder { color: var(--text-3); }
.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-3); margin-top: 10px; }
.segmented button { height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.segmented button .ic { width: 16px; height: 16px; }
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- 屏幕 ---------- */
.screen { position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: 100%; height: 100dvh; height: var(--vvh, 100dvh); }
#screen-auth { align-items: center; justify-content: center; background: var(--bg); overflow-y: auto; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 22px; padding: 28px 24px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; margin: auto; }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.auth-logo h1 { margin: 6px 0 0; font-size: 26px; font-weight: 700; }
.auth-logo p { margin: 0; color: var(--text-2); font-size: 14px; }
.auth-mark { width: 72px; height: 72px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; }
.auth-mark .ic { width: 40px; height: 40px; stroke-width: 2; }
.auth-mark.small { width: 56px; height: 56px; border-radius: 15px; flex-shrink: 0; }
.auth-mark.small .ic { width: 30px; height: 30px; }
.invite-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--text); }
.invite-banner.bad { background: var(--warn-bg); color: var(--warn-ink); }
.invite-banner .avatar { background: var(--surface); color: var(--accent); width: 40px; height: 40px; font-size: 16px; }
.invite-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-2); }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.security-note { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: transparent; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.security-note .ic { width: 20px; height: 20px; color: var(--accent); margin-top: 1px; }
.security-note b { color: var(--accent); }

#app { display: flex; background: var(--bg); overflow: hidden; }
#pane-list { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; background: var(--bg); position: relative; }
.tab { display: none; flex-direction: column; flex: 1; min-height: 0; }
.tab.active { display: flex; }
.pane-header { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-top) + 8px) 16px 8px 20px; min-height: 56px; }
.pane-header h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.3px; }
.pane-header .icon-btn { background: var(--surface); box-shadow: var(--shadow); width: 40px; height: 40px; }
.pane-header .icon-btn.accent { background: var(--accent); color: var(--accent-ink); }
.search-bar { display: flex; align-items: center; gap: 4px; padding: 0 8px 8px 16px; }
.net-banner { background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; text-align: center; padding: 6px; }
.list.scroll { flex: 1; min-height: 0; }
#room-list { background: var(--surface); border-top: 1px solid var(--border); }
.room-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 76px; border: 0; border-bottom: 1px solid var(--border-soft);
  background: transparent; width: 100%; text-align: left; color: var(--text);
}
.room-row.active { background: var(--surface-2); }
.room-row:active { background: var(--surface-2); }
.room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.room-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.room-name { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-time { font-size: 12px; color: var(--text-3); flex-shrink: 0; }
.room-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.room-preview { font-size: 14px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.room-preview .ic { width: 14px; height: 14px; }
.room-preview .ic.read { color: var(--accent); stroke-width: 2; }
.room-row .badge.accent { flex-shrink: 0; }
.room-row .muted-ic { width: 16px; height: 16px; color: var(--text-3); }
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-3); font-size: 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty-state .ic { width: 40px; height: 40px; color: var(--text-3); }
.skeleton { height: 76px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.skeleton i { display: block; border-radius: 6px; background: var(--surface-3); }

#tabbar { display: flex; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 8px calc(var(--safe-bottom) + 6px); flex-shrink: 0; }
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border: 0; background: transparent; color: var(--text-2); font-size: 11px; font-weight: 500; position: relative; }
.tab-btn .ic { width: 26px; height: 26px; }
.tab-btn.active { color: var(--accent); font-weight: 600; }
.tab-btn.active .ic { fill: var(--accent); }
.tab-btn .badge { position: absolute; top: 2px; left: calc(50% + 8px); }

.invite-card { display: flex; gap: 14px; align-items: center; padding: 14px; }
.qr-box { width: 112px; height: 112px; flex-shrink: 0; padding: 6px; border-radius: 10px; border: 1px solid var(--border); background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.qr-box img, .qr-box svg { width: 100%; height: 100%; }
.invite-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.friend-row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--border-soft); background: transparent; width: 100%; text-align: left; color: var(--text); }
.friend-row:last-child { border-bottom: 0; }
.friend-row .col { flex: 1; }
.friend-row .circle { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); color: var(--accent); border: 0; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.friend-row .circle .ic { width: 18px; height: 18px; }
.check-row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--border-soft); background: transparent; width: 100%; text-align: left; color: var(--text); }
.check-row .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); display: inline-flex; align-items: center; justify-content: center; color: var(--accent-ink); flex-shrink: 0; }
.check-row .tick .ic { width: 14px; height: 14px; stroke-width: 3; display: none; }
.check-row.on .tick { background: var(--accent); border-color: var(--accent); }
.check-row.on .tick .ic { display: block; }

.profile-head { display: flex; align-items: center; gap: 14px; padding: calc(var(--safe-top) + 10px) 4px 18px; }
.profile-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.profile-text b { font-size: 20px; font-weight: 700; }
.profile-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 对话 ---------- */
#pane-chat { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.25s ease; will-change: transform; z-index: 2; }
body.chat-open #pane-chat { transform: none; }
#chat-view { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.chat-empty { display: none; flex: 1; align-items: center; justify-content: center; flex-direction: column; gap: 14px; color: var(--text-3); }
.chat-header { display: flex; align-items: center; gap: 4px; padding: calc(var(--safe-top) + 4px) 8px 6px 4px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 54px; flex-shrink: 0; }
.chat-title-btn { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 6px; min-width: 0; text-align: left; color: var(--text); }
.chat-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chat-title b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span.typing { color: var(--accent); }
.page-title { flex: 1; text-align: center; font-size: 17px; padding-right: 44px; }

.timeline { flex: 1; min-height: 0; padding: 10px 12px 8px; display: flex; flex-direction: column; }
.timeline-top { text-align: center; padding: 4px 0 10px; min-height: 40px; }
#timeline-list { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
.day-sep { align-self: center; font-size: 12px; color: var(--text-3); padding: 2px 10px; border-radius: 10px; background: var(--surface-3); margin: 10px 0 8px; }
.sys-msg { align-self: center; font-size: 12px; color: var(--text-3); padding: 2px 10px; margin: 4px 0; text-align: center; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 84%; margin-top: 2px; position: relative; }
.msg.gap { margin-top: 10px; }
.msg.self { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 28px; height: 28px; font-size: 12px; visibility: hidden; }
.msg.first .avatar { visibility: visible; }
.msg.self .avatar { display: none; }
.msg-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg.self .msg-col { align-items: flex-end; }
.msg-sender { font-size: 12px; color: var(--text-2); padding-left: 4px; }
.bubble {
  background: var(--bubble-peer); color: var(--bubble-peer-ink); border-radius: 18px 18px 18px 6px; padding: 9px 13px;
  font-size: 16px; line-height: 1.4; box-shadow: var(--shadow); word-break: break-word; overflow-wrap: anywhere; white-space: pre-wrap; position: relative; max-width: 100%;
  user-select: text; -webkit-user-select: text;
}
.msg.self .bubble { background: var(--bubble-self); color: var(--bubble-self-ink); border-radius: 18px 18px 6px 18px; }
.msg.cont .bubble { border-radius: 18px; }
.bubble a { color: inherit; text-decoration: underline; }
.msg .bubble.emoji-only, .msg.self .bubble.emoji-only { background: transparent; box-shadow: none; font-size: 44px; line-height: 1.2; padding: 2px 4px; }
.bubble.media { padding: 0; overflow: hidden; background: var(--surface-3); border-radius: 16px; }
.bubble.media img, .bubble.media video { display: block; max-width: min(260px, 70vw); max-height: 320px; width: auto; height: auto; min-width: 80px; min-height: 60px; object-fit: cover; cursor: zoom-in; }
.bubble.media .media-time { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #fff; background: rgba(20, 21, 22, 0.55); padding: 2px 7px; border-radius: 8px; }
.bubble.media .play-badge { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; pointer-events: none; }
.bubble.media .play-badge .ic { width: 44px; height: 44px; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.4)); }
.bubble.file { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 200px; }
.bubble.file .row-icon { background: rgba(127, 127, 127, 0.15); color: inherit; }
.bubble.file .col b { font-size: 15px; word-break: break-all; }
.bubble.file .col span { font-size: 12px; opacity: 0.75; }
.bubble.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 8px 12px 8px 10px; }
.bubble.voice .play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.msg.self .bubble.voice .play { background: rgba(255, 255, 255, 0.22); color: #fff; }
.bubble.voice .wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 24px; min-width: 100px; }
.bubble.voice .wave i { width: 3px; border-radius: 2px; background: currentColor; opacity: 0.35; min-height: 4px; }
.bubble.voice .wave i.on { opacity: 1; }
.bubble.voice .dur { font-size: 12px; opacity: 0.8; flex-shrink: 0; min-width: 32px; text-align: right; }
.bubble.notice { font-family: ui-monospace, Menlo, monospace; font-size: 13px; white-space: pre-wrap; }
.bubble.redacted { font-style: italic; opacity: 0.7; font-size: 14px; }
.bubble.pending { opacity: 0.6; }
.bubble.failed { border: 1px solid var(--danger); }
.quote { border-left: 3px solid currentColor; padding: 2px 8px; margin: 0 0 6px; font-size: 13px; line-height: 1.35; opacity: 0.85; border-radius: 2px; max-width: 260px; cursor: pointer; }
.quote b { display: block; }
.quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); padding: 0 4px; }
.msg-meta .ic { width: 14px; height: 14px; stroke-width: 2; color: var(--accent); }
.msg-meta .read { color: var(--accent); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reaction { height: 26px; padding: 0 9px; border-radius: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }
.reaction b { color: var(--accent); }
.typing-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; }
.typing-bubble { background: var(--bubble-peer); border-radius: 18px 18px 18px 6px; padding: 12px 16px; display: flex; gap: 4px; box-shadow: var(--shadow); }
.typing-bubble i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing-bubble i:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
.scroll-bottom { position: absolute; right: 14px; bottom: 76px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center; z-index: 3; }
.scroll-bottom .badge { position: absolute; top: -6px; right: -6px; }

.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 0 14px; background: var(--surface); border-top: 1px solid var(--border); }
.reply-quote { flex: 1; min-width: 0; border-left: 3px solid var(--accent); padding: 2px 8px; font-size: 13px; display: flex; flex-direction: column; }
.reply-quote span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.composer { display: flex; align-items: flex-end; gap: 2px; padding: 6px 6px calc(var(--safe-bottom) + 6px); background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0; }
.reply-bar + .composer { border-top: 0; }
.input-pill { flex: 1; min-width: 0; display: flex; align-items: flex-end; min-height: 40px; border-radius: 20px; background: var(--surface-2); padding: 2px 2px 2px 14px; margin: 2px 0; }
#msg-input {
  flex: 1; min-width: 0; border: 0; background: transparent; resize: none; font-size: 16px; line-height: 22px; padding: 7px 0; color: var(--text);
  outline: none; max-height: 132px; -webkit-user-select: text; user-select: text; -webkit-appearance: none; appearance: none;
}
#msg-input::placeholder { color: var(--text-3); }
.record-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px calc(var(--safe-bottom) + 12px); background: var(--surface); border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.record-bar.cancel { background: var(--warn-bg); color: var(--warn-ink); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
#btn-mic.recording { background: var(--danger); color: #fff; }
.emoji-panel { height: 300px; background: var(--bg); border-top: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; padding-bottom: var(--safe-bottom); }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 8px 0; overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tabs button { height: 34px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.emoji-tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
.emoji-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; padding: 8px 10px; align-content: start; }
.emoji-grid button { height: 42px; border: 0; background: transparent; border-radius: 8px; font-size: 28px; line-height: 1; display: flex; align-items: center; justify-content: center; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.emoji-grid button:active { background: var(--surface-3); }
.emoji-foot { display: flex; justify-content: space-between; padding: 6px 10px 8px; flex-shrink: 0; }

/* ---------- 弹层 ---------- */
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 50; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 20px calc(var(--safe-bottom) + 20px);
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-lg); z-index: 51; max-height: 90%; max-height: calc(var(--vvh, 100dvh) * 0.9); overflow-y: auto; animation: rise 0.22s ease;
}
.sheet.tall { height: 80%; height: calc(var(--vvh, 100dvh) * 0.8); }
@keyframes rise { from { transform: translateY(40px); } to { transform: none; } }
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--border); align-self: center; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.sheet-head b { font-size: 17px; }
.sheet .card { background: var(--surface-2); box-shadow: none; }
.sheet .card .row-item { border-color: var(--border); }
.attach-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 6px 0; }
.attach-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: transparent; font-size: 13px; padding: 8px 0; color: var(--text); }
.react-bar { display: flex; justify-content: space-between; gap: 4px; padding: 2px 0; }
.react-bar button { flex: 1; height: 46px; border: 0; border-radius: 12px; background: var(--surface-2); font-size: 26px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.react-bar button.mine { background: var(--accent-soft); outline: 2px solid var(--accent); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 15px; }
.steps li i { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; font-style: normal; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.steps li span { flex: 1; }
.steps li .ic { width: 26px; height: 26px; }
.big-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; margin: 6px auto 0; }
.big-icon .ic { width: 36px; height: 36px; }
.check-line { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check-line .ic { width: 18px; height: 18px; color: var(--accent); stroke-width: 2; }
.check-line.todo { color: var(--text-2); }
.check-line.todo .ic { color: var(--border); }
.check-line .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.sheet p { margin: 0; }

.page { position: fixed; inset: 0; background: var(--bg); z-index: 40; display: flex; flex-direction: column; animation: slide 0.2s ease; }
@keyframes slide { from { transform: translateX(40px); } to { transform: none; } }
.page .scroll { flex: 1; min-height: 0; }
.hero-card { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); }
.hero-card .ic { width: 28px; height: 28px; }
.hero-card span { font-size: 13px; opacity: 0.9; }

.lightbox { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox #lightbox-close { position: absolute; top: calc(var(--safe-top) + 10px); right: 12px; }
.lightbox #lightbox-download { position: absolute; bottom: calc(var(--safe-bottom) + 14px); right: 12px; }

.call { position: fixed; inset: 0; background: #0e0f12; color: #fff; z-index: 70; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: calc(var(--safe-top) + 40px) 20px calc(var(--safe-bottom) + 36px); }
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#local-video { position: absolute; top: calc(var(--safe-top) + 16px); right: 16px; width: 110px; height: 150px; object-fit: cover; border-radius: 14px; background: #222; border: 1px solid rgba(255, 255, 255, 0.2); z-index: 2; }
.call-top { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.call-top b { font-size: 24px; }
.call-top span { color: rgba(255, 255, 255, 0.75); }
.call-controls { position: relative; z-index: 1; display: flex; gap: 20px; }
.call-btn { width: 64px; height: 64px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.18); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-btn .ic { width: 26px; height: 26px; }
.call-btn.on { background: #fff; color: #0e0f12; }
.call-btn.answer { background: #23a55a; }
.call-btn.hangup { background: #e53935; }
.call.audio-only #remote-video { display: none; }
.call.audio-only #local-video { display: none; }

.dialog { position: fixed; inset: 0; background: var(--overlay); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.dialog-box { background: var(--surface); border-radius: 18px; padding: 22px 20px 16px; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.dialog-box b { font-size: 17px; }
.dialog-box p { margin: 0 0 6px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 90; max-width: 86%; text-align: center; box-shadow: var(--shadow-lg); }

/* ---------- 桌面双栏 ---------- */
@media (min-width: 900px) {
  #pane-list { width: 360px; flex-shrink: 0; border-right: 1px solid var(--border); background: var(--surface); }
  #room-list { border-top: 0; }
  #pane-chat { position: relative; flex: 1; transform: none; transition: none; }
  .chat-empty { display: flex; }
  body.chat-open .chat-empty { display: none; }
  .only-mobile { display: none !important; }
  .pane-header { padding-top: 14px; }
  .pane-header h1 { font-size: 22px; }
  .room-row { min-height: 68px; padding: 10px 14px; }
  .timeline { padding: 16px 32px 8px; }
  #timeline-list { max-width: 900px; width: 100%; align-self: center; }
  .msg { max-width: 70%; }
  .composer { padding: 10px 24px 14px; }
  .emoji-panel { height: 320px; }
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 420px; border-radius: 22px; padding: 20px 20px; max-height: 80vh; animation: none; }
  .sheet.tall { height: auto; max-height: 80vh; }
  .grabber { display: none; }
  .page { left: 360px; }
  .toast { bottom: 40px; }
  .scroll-bottom { bottom: 84px; right: 32px; }
  #local-video { width: 200px; height: 150px; }
}
@media (hover: hover) {
  .room-row:hover, .friend-row:hover, button.row-item:hover { background: var(--surface-2); }
  .icon-btn:hover { background: var(--surface-3); }
  .icon-btn.accent-fill:hover { background: var(--accent); filter: brightness(1.08); }
}
