/* Waves — styles (§12.4). Tokens on :root; dark mode via prefers-color-scheme and [data-theme].
   Light, airy, friendly: soft neutrals, one teal accent, 18px bubbles, very light shadows. */

/* ---------------------------------------------------------------- tokens */
:root {
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", Roboto, sans-serif;
  --fs: 16px;
  --fs-msg: 16px;
  --lh-msg: 1.42;

  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --surface-3: #e7ecef;
  --glass: rgba(255, 255, 255, 0.86);
  --text: #15202b;
  --text-2: #5b6873;
  --text-3: #87939c;
  --line: #e3e8eb;
  --line-2: #d3dadf;

  --accent: #0b7f73;
  --accent-ink: #ffffff;
  --accent-text: #0b7f73;
  --accent-soft: #e2f4f1;
  --accent-soft-2: #cdeee8;
  --danger: #c62f35;
  --danger-soft: #fdecec;
  --ok: #1d8a4c;
  --warn-bg: #fff6d6;
  --warn-text: #6b5300;

  --bubble-other: #ffffff;
  --bubble-other-text: #15202b;
  --bubble-own: #d6f3ec;
  --bubble-own-text: #102a26;
  --bubble-own-link: #0a6a60;
  --bubble-hot: #fff6da;
  --mention-bg: rgba(11, 127, 115, 0.12);
  --mention-me-bg: rgba(237, 170, 0, 0.26);
  --meta: #5f6c76;
  --pill-bg: rgba(255, 255, 255, 0.82);
  --pill-text: #4f5d68;
  --dim: rgba(12, 18, 24, 0.38);
  --badge: #0b7f73;
  --badge-muted: #9aa6ae;
  --online: #22b14c;

  --shadow-1: 0 1px 1px rgba(16, 32, 40, 0.05), 0 1px 3px rgba(16, 32, 40, 0.05);
  --shadow-2: 0 4px 16px rgba(16, 32, 40, 0.10), 0 1px 3px rgba(16, 32, 40, 0.06);
  --shadow-3: 0 12px 40px rgba(16, 32, 40, 0.18), 0 2px 8px rgba(16, 32, 40, 0.08);
  --r-bubble: 18px;
  --r-tight: 5px;

  --chat-fallback-css: linear-gradient(180deg, #f4f9f8 0%, #eef4f8 100%);
  --chat-fallback: #f0f6f7;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --head-h: 56px;
  --tab-h: 56px;

  /* 16-color personal palette (§12.2): --cNN avatar / quote line (white text ≥ 3:1),
     --cNN-t name text (≥ 4.8:1 on white bubbles; dark values ≥ 5:1 on #232a31). */
  --c01: #e6656e; --c01-t: #d0242f;
  --c02: #ec671a; --c02-t: #b54b0c;
  --c03: #bf830a; --c03-t: #966607;
  --c04: #8f931a; --c04-t: #6f7214;
  --c05: #5ea02e; --c05-t: #477a23;
  --c06: #2fa255; --c06-t: #247e43;
  --c07: #138d75; --c07-t: #147a66;
  --c08: #149cb1; --c08-t: #0f7889;
  --c09: #1996e3; --c09-t: #1372ad;
  --c10: #3b6ad8; --c10-t: #2f62d2;
  --c11: #6359cf; --c11-t: #5a50cf;
  --c12: #9f7edf; --c12-t: #7d52d2;
  --c13: #a24dc7; --c13-t: #9c3fc4;
  --c14: #d265c9; --c14-t: #b533aa;
  --c15: #e361a2; --c15-t: #cc2278;
  --c16: #b7845f; --c16-t: #92623f;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14191d; --surface: #1c2328; --surface-2: #252d33; --surface-3: #2e373e; --glass: rgba(28, 35, 40, 0.88);
    --text: #e8eef1; --text-2: #a6b2ba; --text-3: #7f8b93; --line: #2b343b; --line-2: #39434b;
    --accent: #36c9b4; --accent-ink: #062320; --accent-text: #5fd4c2; --accent-soft: #173a36; --accent-soft-2: #1d4842;
    --danger: #ff7a7f; --danger-soft: #3a2124; --ok: #5ad08a; --warn-bg: #3a3218; --warn-text: #f3d77c;
    --bubble-other: #232a31; --bubble-other-text: #e8eef1; --bubble-own: #1d4842; --bubble-own-text: #e6f6f3; --bubble-own-link: #8fe6d8;
    --bubble-hot: #302d24; --mention-bg: rgba(54, 201, 180, 0.18); --mention-me-bg: rgba(240, 190, 60, 0.28);
    --meta: #a2aeb6; --pill-bg: rgba(30, 37, 43, 0.82); --pill-text: #b6c1c8; --dim: rgba(0, 0, 0, 0.55);
    --badge: #36c9b4; --badge-muted: #5f6b73; --online: #45d06e;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.28); --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.35); --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.5);
    --chat-fallback-css: linear-gradient(180deg, #11171a 0%, #131a20 100%); --chat-fallback: #12191d;
    --c01-t: #f16f78; --c02-t: #f9792f; --c03-t: #d99a1a; --c04-t: #b4b81f; --c05-t: #6cba34; --c06-t: #31bb61;
    --c07-t: #1fbf9c; --c08-t: #18b2c8; --c09-t: #36a8f0; --c10-t: #7ba1f5; --c11-t: #9a94f0; --c12-t: #ad8ff0;
    --c13-t: #c784e8; --c14-t: #e576dc; --c15-t: #f176b4; --c16-t: #cf9670;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14191d; --surface: #1c2328; --surface-2: #252d33; --surface-3: #2e373e; --glass: rgba(28, 35, 40, 0.88);
  --text: #e8eef1; --text-2: #a6b2ba; --text-3: #7f8b93; --line: #2b343b; --line-2: #39434b;
  --accent: #36c9b4; --accent-ink: #062320; --accent-text: #5fd4c2; --accent-soft: #173a36; --accent-soft-2: #1d4842;
  --danger: #ff7a7f; --danger-soft: #3a2124; --ok: #5ad08a; --warn-bg: #3a3218; --warn-text: #f3d77c;
  --bubble-other: #232a31; --bubble-other-text: #e8eef1; --bubble-own: #1d4842; --bubble-own-text: #e6f6f3; --bubble-own-link: #8fe6d8;
  --bubble-hot: #302d24; --mention-bg: rgba(54, 201, 180, 0.18); --mention-me-bg: rgba(240, 190, 60, 0.28);
  --meta: #a2aeb6; --pill-bg: rgba(30, 37, 43, 0.82); --pill-text: #b6c1c8; --dim: rgba(0, 0, 0, 0.55);
  --badge: #36c9b4; --badge-muted: #5f6b73; --online: #45d06e;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.28); --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.35); --shadow-3: 0 12px 40px rgba(0, 0, 0, 0.5);
  --chat-fallback-css: linear-gradient(180deg, #11171a 0%, #131a20 100%); --chat-fallback: #12191d;
  --c01-t: #f16f78; --c02-t: #f9792f; --c03-t: #d99a1a; --c04-t: #b4b81f; --c05-t: #6cba34; --c06-t: #31bb61;
  --c07-t: #1fbf9c; --c08-t: #18b2c8; --c09-t: #36a8f0; --c10-t: #7ba1f5; --c11-t: #9a94f0; --c12-t: #ad8ff0;
  --c13-t: #c784e8; --c14-t: #e576dc; --c15-t: #f176b4; --c16-t: #cf9670;
  color-scheme: dark;
}

:root[data-size="s"] { --fs: 15px; --fs-msg: 15px; }
:root[data-size="l"] { --fs: 17px; --fs-msg: 18px; --lh-msg: 1.4; }

.uc-c01 { --u: var(--c01); --ut: var(--c01-t); } .uc-c02 { --u: var(--c02); --ut: var(--c02-t); }
.uc-c03 { --u: var(--c03); --ut: var(--c03-t); } .uc-c04 { --u: var(--c04); --ut: var(--c04-t); }
.uc-c05 { --u: var(--c05); --ut: var(--c05-t); } .uc-c06 { --u: var(--c06); --ut: var(--c06-t); }
.uc-c07 { --u: var(--c07); --ut: var(--c07-t); } .uc-c08 { --u: var(--c08); --ut: var(--c08-t); }
.uc-c09 { --u: var(--c09); --ut: var(--c09-t); } .uc-c10 { --u: var(--c10); --ut: var(--c10-t); }
.uc-c11 { --u: var(--c11); --ut: var(--c11-t); } .uc-c12 { --u: var(--c12); --ut: var(--c12-t); }
.uc-c13 { --u: var(--c13); --ut: var(--c13-t); } .uc-c14 { --u: var(--c14); --ut: var(--c14-t); }
.uc-c15 { --u: var(--c15); --ut: var(--c15-t); } .uc-c16 { --u: var(--c16); --ut: var(--c16-t); }
.uc-none { --u: #9aa6ae; --ut: var(--text-2); }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
/* T34: no pinch / double-tap zoom of the whole page (the lightbox zooms itself with pointer events).
   touch-action is not inherited but it intersects down the tree, so every element can pan only;
   elements with their own value (lightbox stage, voice key, crop box: none; scrollers: pan-y) keep it. */
html { touch-action: pan-x pan-y; }
body {
  font-family: var(--font); font-size: var(--fs); line-height: 1.5; color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0 0 0.6em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.88em; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 16px; }
.pad-s { padding: 10px 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.scroll-locked .msg-scroll, .scroll-locked .page-body { overscroll-behavior: contain; }
.icon { flex: none; display: block; }

.app {
  position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh);
  display: flex; flex-direction: column; overflow: hidden;
}
.boot, .panel-center { display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; min-height: 160px; padding: 24px; text-align: center; }
.boot { height: 100%; }

.spinner {
  display: inline-block; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 15px;
  text-decoration: none; transition: background 0.15s, transform 0.1s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-lg { min-height: 54px; font-size: 17px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
@media (pointer: coarse) { .btn-sm { min-height: 40px; } }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); padding: 0; position: relative;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.on { color: var(--accent-text); background: var(--accent-soft); }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.danger { color: var(--danger); }
.icon-btn:disabled { opacity: 0.35; }
@media (pointer: coarse) { .icon-btn.sm { width: 42px; height: 42px; } }

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1.5px solid var(--line-2); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 16px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 16px; }
.field-label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 13px; color: var(--text-3); }
.field-hint.bad, .field-error { font-size: 13px; color: var(--danger); }
.form { display: flex; flex-direction: column; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

/* switch */
.row-switch { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; cursor: pointer; }
.row-switch + .row-switch, .row-switch + .row, .row + .row-switch { border-top: 1px solid var(--line); }
.row-switch-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.switch {
  appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 15px; background: var(--line-2);
  position: relative; flex: none; margin: 0; cursor: pointer; transition: background 0.18s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.18s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
/* 我的裝置: each signed-in device's own app lock switch (§3.3 T40), caption above the switch */
.device-lock { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: none; cursor: pointer; }
.device-lock-text { font-size: 11px; color: var(--text-2); white-space: nowrap; line-height: 1; }
/* Same slot width with or without 登出 (this device has none), so the switches line up. */
.device-row .btn-sm, .device-row-gap { flex: none; width: 56px; padding: 0; justify-content: center; }
/* 「登出其他所有裝置」 under the list (§3.3 T57): a card-like danger button. */
.logout-others-btn { background: var(--surface); box-shadow: var(--shadow-1); margin: -8px 0 22px; border-radius: 16px; }

/* segmented */
.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; width: 100%; }
.seg {
  flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 9px; font-size: 14px; font-weight: 600;
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 8px; white-space: nowrap;
}
.seg.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg.on { background: var(--surface-3); } }
:root[data-theme="dark"] .seg.on { background: var(--surface-3); }

/* color swatches */
.swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; max-width: 420px; }
.swatch {
  aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--u); color: #fff; display: flex; align-items: center; justify-content: center;
  min-width: 32px; transition: transform 0.12s, box-shadow 0.12s; padding: 0;
}
.swatch:hover { transform: scale(1.08); }
.swatch.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5.5px var(--u); }
.swatches-wrap { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.swatch-auto { border-style: dashed; }

.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-2); vertical-align: 1px; letter-spacing: 0.02em; white-space: nowrap;
}
.tag-admin { background: var(--accent-soft); color: var(--accent-text); margin-left: 5px; }
.tag-ok { background: var(--accent-soft); color: var(--accent-text); }
.tag-bad { background: var(--danger-soft); color: var(--danger); }
.tag-unsent { background: var(--surface-3); color: var(--text-2); margin-left: 6px; font-style: normal; }

.name { color: var(--ut, var(--text)); font-weight: 600; }

/* ---------------------------------------------------------------- avatars */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex: none; position: relative;
  background: var(--u, #9aa6ae); color: #fff; font-weight: 700; line-height: 1; user-select: none; letter-spacing: 0.01em;
}
.avatar img:not(.emoji-img) { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.avatar-emoji { background: color-mix(in srgb, var(--u) 22%, var(--surface)); }
.avatar-room { border-radius: 30%; }
.avatar-dot {
  position: absolute; right: -1px; bottom: -1px; width: 28%; height: 28%; min-width: 10px; min-height: 10px; border-radius: 50%;
  background: var(--online); box-shadow: 0 0 0 2px var(--surface);
}
.emoji-img { display: inline-block; vertical-align: -0.2em; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.emoji-txt { display: inline-block; text-align: center; }

/* ---------------------------------------------------------------- empty / notes / cards */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; gap: 10px; max-width: 420px; margin: 0 auto; }
.empty-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.empty-title { font-size: 19px; font-weight: 700; }
.empty-text { color: var(--text-2); line-height: 1.6; }
.empty-action { margin-top: 8px; }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; font-size: 14px; margin-top: 12px; text-align: left; line-height: 1.5; }
.note .icon { margin-top: 2px; }
.note-error { background: var(--danger-soft); color: var(--danger); }
.note-soft { background: var(--surface-2); color: var(--text-2); }
.notice-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft);
  color: var(--text); font-size: 14px; line-height: 1.55; margin: 12px 0; text-align: left;
}
.notice-card .icon { color: var(--accent-text); margin-top: 1px; }
.notice-card p { margin: 0; }
.soon-card { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; }
.soon-card .icon { color: var(--accent-text); margin-top: 2px; }
.soon-card p { margin: 2px 0 0; font-size: 14px; }
.card-cta { display: flex; gap: 14px; align-items: center; padding: 16px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-1); margin: 4px 0 18px; flex-wrap: wrap; }
.card-cta > div { flex: 1 1 260px; }
.card-cta p { margin: 4px 0 0; font-size: 14px; line-height: 1.55; }

/* ---------------------------------------------------------------- sections / rows (settings style) */
.section { margin: 0 0 22px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 0 4px 8px; letter-spacing: 0.04em; }
.section-body { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-1); overflow: hidden; }
.section-foot { font-size: 13px; color: var(--text-3); margin: 8px 6px 0; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px 8px 16px; border: 0; background: transparent;
  text-align: left; color: var(--text); text-decoration: none;
}
.row + .row, .row-block + .row, .row + .row-block, .row-block + .row-block, .soon-card + .row-block { border-top: 1px solid var(--line); }
a.row:hover, button.row:hover { background: var(--surface-2); text-decoration: none; }
.row.danger, .row.danger .row-icon { color: var(--danger); }
.row.dead { opacity: 0.55; }
.row-icon { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.row-main { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.row-label { font-size: 16px; font-weight: 500; }
.row-hint { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.row-value { color: var(--text-2); font-size: 14px; }
.row-chev { color: var(--text-3); }
.row-thumb { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px var(--line); }
.row-block { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 14px; }

/* ---------------------------------------------------------------- layout: phone */
.phone-shell { height: 100%; display: flex; flex-direction: column; }
.phone-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.phone-main > * { flex: 1; min-height: 0; }
.tabbar {
  flex: none; display: flex; justify-content: space-around; background: var(--glass); backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); border-top: 1px solid var(--line);
  padding: 0 calc(8px + var(--safe-r)) var(--safe-b) calc(8px + var(--safe-l));
}
.tab {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tab-h); color: var(--text-3); font-size: 11px; font-weight: 600; text-decoration: none;
}
.tab:hover { text-decoration: none; }
.tab.on { color: var(--accent-text); }
.tab-icon { position: relative; }
.tab-badge {
  position: absolute; top: -5px; left: 15px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--surface);
}
.kb-open .tabbar { display: none; }

/* ---------------------------------------------------------------- layout: desktop */
.desk-shell { height: 100%; display: grid; grid-template-columns: 320px minmax(0, 1fr); }
.desk-shell.with-info { grid-template-columns: 320px minmax(0, 1fr) 340px; }
.list-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.desk-shell .list-pane { border-right: 1px solid var(--line); }
.main-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.main-pane > * { flex: 1; min-height: 0; }
.info-pane { border-left: 1px solid var(--line); background: var(--bg); min-height: 0; overflow-y: auto; }
.pane-empty { display: flex; align-items: center; justify-content: center; background: var(--chat-fallback-css); }
@media (min-width: 768px) and (max-width: 1023px) {
  .desk-shell.with-info { grid-template-columns: 300px minmax(0, 1fr); }
  .desk-shell.with-info .info-pane { position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 90vw); z-index: 30; box-shadow: var(--shadow-3); }
}

/* ---------------------------------------------------------------- room list */
.list-head {
  display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--safe-t)) 8px 4px 18px; min-height: calc(var(--head-h) + var(--safe-t)); flex: none;
}
.list-title { font-size: 26px; font-weight: 800; flex: 1; letter-spacing: 0.01em; }
.list-actions { display: flex; gap: 2px; }
.room-list { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-search {
  display: flex; align-items: center; gap: 8px; margin: 4px 14px 8px; padding: 0 6px 0 12px; background: var(--surface-2);
  border-radius: 12px; color: var(--text-3); flex: none;
}
.list-search input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 8px 0 !important; min-height: 40px !important; }
/* Search + 「立即上鎖」 (T19). The wrapper takes over the search box's outer margin. */
.list-tools { display: flex; align-items: center; gap: 2px; margin: 4px 14px 8px; flex: none; }
.list-tools > .list-search { flex: 1; min-width: 0; margin: 0; }
.list-tools > .lock-now { margin-right: -6px; }
.list-tools-end { justify-content: flex-end; margin-top: 0; margin-bottom: 0; }
.rooms { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 6px calc(12px + var(--safe-b)); }
.with-tabs .rooms { padding-bottom: 12px; }
.room-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; color: var(--text); text-decoration: none; min-height: 72px;
  transition: background 0.12s;
}
.room-item:hover { background: var(--surface-2); text-decoration: none; }
.room-item.active { background: var(--accent-soft); }
.room-av { position: relative; flex: none; }
.room-call {
  position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--online); color: #fff;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--surface);
}
.room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.room-top, .room-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.room-name { font-weight: 650; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.room-time { margin-left: auto; font-size: 12px; color: var(--text-3); flex: none; padding-left: 4px; }
.has-unread .room-time { color: var(--accent-text); font-weight: 600; }
.room-flag { color: var(--text-3); }
.room-flag.pin { transform: rotate(35deg); }
.room-preview { flex: 1; min-width: 0; font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-preview.typing { color: var(--accent-text); font-style: italic; }
.has-unread .room-preview { color: var(--text); }
.badge {
  flex: none; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--badge); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}
.badge.muted { background: var(--badge-muted); color: #fff; }
.archived { margin-top: 10px; }
.archived-toggle {
  display: flex; align-items: center; gap: 6px; margin: 0 auto; border: 0; background: transparent; color: var(--text-3);
  font-size: 13px; font-weight: 600; min-height: 40px; padding: 0 12px; border-radius: 10px;
}
.archived-toggle:hover { background: var(--surface-2); }
.archived .room-item { opacity: 0.7; }
.room-at {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: #f08c00; color: #fff; font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* ---------------------------------------------------------------- pages */
.page { height: 100%; display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.page-head {
  flex: none; display: flex; align-items: center; gap: 4px; min-height: calc(var(--head-h) + var(--safe-t));
  padding: var(--safe-t) 12px 0 calc(12px + var(--safe-l)); background: var(--bg);
}
.page-head .back-btn { margin-left: -8px; }
.page-head-titles { flex: 1; min-width: 0; padding-left: 6px; }
.page-title { font-size: 22px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-sub { font-size: 13px; color: var(--text-2); }
.page-actions { display: flex; gap: 6px; }
.page-tabs { padding: 0 16px 10px; flex: none; max-width: 720px; width: 100%; margin: 0 auto; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px calc(28px + var(--safe-b)); }
.with-tabs .page-body { padding-bottom: 24px; }
.narrow { max-width: 720px; margin: 0 auto; width: 100%; }
.page-scroll-y { overflow-y: auto; height: 100%; }

/* ---------------------------------------------------------------- auth pages */
.auth-page {
  display: flex; flex-direction: column; align-items: center; padding: calc(32px + var(--safe-t)) 18px calc(20px + var(--safe-b));
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft) 0%, transparent 60%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 24px; padding: 28px 22px 24px; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; align-items: stretch; text-align: center; gap: 4px; margin: auto 0;
}
.auth-card .logo { align-self: center; border-radius: 22%; margin-bottom: 6px; box-shadow: var(--shadow-1); }
.auth-title { font-size: 30px; font-weight: 800; margin: 4px 0 2px; }
.auth-title.sm { font-size: 22px; }
.auth-lead { color: var(--text-2); margin: 0 0 18px; }
.auth-card > .btn { margin-top: 8px; }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-direction: column; gap: 12px; text-align: left; font-size: 14px; color: var(--text-2); line-height: 1.6; }
.auth-points li { display: flex; gap: 10px; }
.auth-points .icon { color: var(--accent-text); margin-top: 3px; }
.auth-points b { color: var(--text); }
.auth-foot { margin-top: 18px; font-size: 13px; }
.fine { font-size: 13px; color: var(--text-3); margin: 10px 0 0; }
.back-link { align-self: flex-start; margin: -10px 0 6px -8px; }
.invite-head { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 4px; }
.invite-kicker { margin-top: 8px; color: var(--text-2); font-size: 14px; }
.namecolor { text-align: left; margin: 4px 0 6px; }
.preview-card { display: flex; align-items: flex-end; gap: 10px; padding: 14px; background: var(--chat-fallback-css); border-radius: 16px; margin-bottom: 16px; }
.preview-bubble {
  background: var(--bubble-other); border-radius: 18px 18px 18px 5px; padding: 7px 12px 8px; display: flex; flex-direction: column;
  box-shadow: var(--shadow-1); font-size: 15px; min-width: 0;
}
.preview-bubble .name { font-size: 13px; }

/* ---------------------------------------------------------------- chat */
.chat { height: 100%; display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.chat-head {
  flex: none; display: flex; align-items: center; gap: 2px; min-height: calc(var(--head-h) + var(--safe-t));
  padding: var(--safe-t) calc(4px + var(--safe-r)) 0 calc(4px + var(--safe-l));
  background: var(--glass); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--line); z-index: 5;
}
.back-btn { color: var(--accent-text); }
@media (min-width: 768px) { .chat-head .back-btn { display: none; } .chat-head { padding-left: 12px; } }
.chat-title {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 4px 6px; border-radius: 12px;
  text-align: left; min-height: 44px;
}
.chat-title:hover { background: var(--surface-2); }
.chat-title-text { display: flex; flex-direction: column; min-width: 0; }
.chat-name { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.25; }
.chat-sub { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.chat-actions { display: flex; flex: none; }
@media (max-width: 380px) { .chat-actions .icon-btn { width: 40px; } }
.typing-text { color: var(--accent-text); display: inline-flex; align-items: center; gap: 5px; }
.typing-dots { display: inline-flex; gap: 2px; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; display: block; }
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.banner {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 16px; font-size: 14px; border: 0; width: 100%; text-align: left;
}
.banner-call { background: var(--online); color: #fff; font-weight: 600; }
.banner-cta { margin-left: auto; background: rgba(255, 255, 255, 0.25); border-radius: 999px; padding: 2px 12px; }
.banner-archived { background: var(--warn-bg); color: var(--warn-text); }

.chat-body { flex: 1; min-height: 0; position: relative; }
.chat-bg {
  background-color: var(--bg-color, var(--chat-fallback));
  background-image: var(--bg-ov, none), var(--bg-img, none), var(--bg-css, var(--chat-fallback-css));
  background-size: 100% 100%, var(--bg-size, cover), 100% 100%;
  background-repeat: no-repeat, var(--bg-repeat, no-repeat), no-repeat;
  background-position: 0 0, var(--bg-pos, 50% 50%), 0 0;
}
@media (max-width: 767px) and (orientation: portrait) {
  .chat-bg { background-image: var(--bg-ov, none), var(--bg-img-p, none), var(--bg-css, var(--chat-fallback-css)); }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chat-bg {
    background-color: var(--bg-color-d, var(--chat-fallback));
    background-image: var(--bg-ov-d, none), var(--bg-img-d, none), var(--bg-css-d, var(--chat-fallback-css));
  }
}
@media (prefers-color-scheme: dark) and (max-width: 767px) and (orientation: portrait) {
  :root:not([data-theme="light"]) .chat-bg { background-image: var(--bg-ov-d, none), var(--bg-img-dp, none), var(--bg-css-d, var(--chat-fallback-css)); }
}
:root[data-theme="dark"] .chat-bg {
  background-color: var(--bg-color-d, var(--chat-fallback));
  background-image: var(--bg-ov-d, none), var(--bg-img-d, none), var(--bg-css-d, var(--chat-fallback-css));
}
@media (max-width: 767px) and (orientation: portrait) {
  :root[data-theme="dark"] .chat-bg { background-image: var(--bg-ov-d, none), var(--bg-img-dp, none), var(--bg-css-d, var(--chat-fallback-css)); }
}

/* Query container for the hover toolbar (.msg-tools, T45 / T46). Absolutely positioned with inset: 0, so inline-size
   containment does not change its width. Not on the rows / lines: that would break their shrink-to-fit widths. */
.msg-wrap { position: absolute; inset: 0; container-type: inline-size; container-name: msgs; }
.msg-scroll {
  position: relative; height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; overflow-anchor: none;
  padding: 4px 0 6px;
}
/* Spacer above the rows (T39a, §12.3): takes the height of rows added / trimmed above while the user scrolls. */
.msg-pad { flex-shrink: 0; }
.msg-top { min-height: 40px; display: flex; align-items: center; justify-content: center; padding: 10px 0 2px; }
.msg-loading { display: flex; justify-content: center; padding: 10px; }
.msg-start { font-size: 12px; color: var(--pill-text); background: var(--pill-bg); padding: 3px 12px; border-radius: 999px; }
.msg-bottom-pad { height: 6px; }

.day-sep { position: relative; z-index: 1; display: flex; justify-content: center; margin: 12px 0 6px; pointer-events: none; }
.day-sep span, .sys-pill {
  font-size: 12.5px; color: var(--pill-text); background: var(--pill-bg); padding: 3px 12px; border-radius: 999px; font-weight: 600;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: var(--shadow-1);
}
.unread-sep { display: flex; align-items: center; gap: 10px; margin: 14px 16px 6px; color: var(--accent-text); font-size: 12.5px; font-weight: 700; }
.unread-sep::before, .unread-sep::after { content: ''; flex: 1; height: 1.5px; background: currentColor; opacity: 0.35; border-radius: 1px; }
.unread-sep span { background: var(--pill-bg); padding: 2px 10px; border-radius: 999px; }
.sys-row { display: flex; justify-content: center; padding: 6px 16px; }
.sys-pill { font-weight: 500; text-align: center; max-width: 92%; display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; line-height: 1.45; }
.sys-time { opacity: 0.7; font-weight: 400; font-size: 11px; }
.sys-call .icon { opacity: 0.85; }

.msg-row {
  display: flex; align-items: flex-end; gap: 8px; padding: 1.5px calc(12px + var(--safe-r)) 1.5px calc(10px + var(--safe-l));
  position: relative; touch-action: pan-y;
}
.msg-row.first { margin-top: 9px; }
.msg-row.own { justify-content: flex-end; }
.msg-av { width: 34px; flex: none; align-self: flex-end; margin-bottom: 1px; }
.msg-col { display: flex; flex-direction: column; min-width: 0; max-width: min(80%, 560px); }
.own .msg-col { align-items: flex-end; }
.msg-line { display: flex; align-items: flex-end; gap: 6px; position: relative; max-width: 100%; transition: transform 0.18s ease-out; }
.msg-line.swiping { transition: none; }
.own .msg-line { flex-direction: row-reverse; }
.swipe-hint {
  position: absolute; left: -38px; top: 50%; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%; background: var(--pill-bg);
  color: var(--accent-text); display: flex; align-items: center; justify-content: center; opacity: var(--swipe, 0);
  transform: scale(calc(0.6 + var(--swipe, 0) * 0.4)); pointer-events: none; box-shadow: var(--shadow-1);
}

.bubble {
  position: relative; background: var(--bubble-other); color: var(--bubble-other-text); border-radius: var(--r-bubble);
  padding: 7px 12px 8px; box-shadow: var(--shadow-1); min-width: 0; max-width: 100%;
  font-size: var(--fs-msg); line-height: var(--lh-msg); overflow-wrap: anywhere; word-break: break-word;
}
.bubble:focus-visible { outline-offset: 1px; border-radius: var(--r-bubble); }
.bubble-own { background: var(--bubble-own); color: var(--bubble-own-text); }
.bubble-own a { color: var(--bubble-own-link); }
.bubble a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.bubble.hot:not(.bubble-own) { background: var(--bubble-hot); }
.msg-text { white-space: pre-wrap; }
/* Group corners (Messenger-like): the side facing the avatar tightens between grouped bubbles. */
.other:not(.last) .bubble { border-bottom-left-radius: var(--r-tight); }
.other:not(.first) .bubble { border-top-left-radius: var(--r-tight); }
.own:not(.last) .bubble { border-bottom-right-radius: var(--r-tight); }
.own:not(.first) .bubble { border-top-right-radius: var(--r-tight); }
.msg-name { font-size: 13px; font-weight: 700; color: var(--ut, var(--text-2)); line-height: 1.3; margin: 0 0 2px 2px; display: flex; align-items: center; }
.msg-name .tag-admin { height: 16px; font-size: 10px; }
.bubble .msg-name { margin: 0 0 1px; }
.msg-name.floating { background: var(--pill-bg); padding: 1px 8px; border-radius: 999px; align-self: flex-start; margin: 0 0 3px; backdrop-filter: blur(6px); }
.mention { background: var(--mention-bg); border-radius: 5px; padding: 0 2px; font-weight: 600; }
.mention-me { background: var(--mention-me-bg); }
.fwd { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); font-style: italic; margin-bottom: 2px; }
.bubble-own .fwd { color: inherit; opacity: 0.75; }
.quote {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-width: 120px; border: 0; text-align: left;
  border-left: 3px solid var(--u, var(--accent)); background: color-mix(in srgb, var(--u, var(--accent)) 10%, transparent);
  border-radius: 6px 10px 10px 6px; padding: 4px 10px 5px 9px; margin: 2px 0 5px; font-size: 13.5px; line-height: 1.35; color: inherit;
}
.quote:hover { background: color-mix(in srgb, var(--u, var(--accent)) 16%, transparent); }
.quote-name { color: var(--ut, var(--accent-text)); font-weight: 700; font-size: 12.5px; }
.quote-text { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; display: block; }
.bubble-unsent { background: var(--surface-2) !important; color: var(--text-2) !important; box-shadow: none; border: 1.5px dashed var(--line-2); }
.unsent-orig { font-style: italic; }
.bubble-gone { background: transparent !important; box-shadow: none; border: 1.5px dashed var(--line-2); color: var(--text-2) !important; font-size: 14px; }
.msg-gone { display: inline-flex; align-items: center; gap: 5px; font-style: italic; }
.bubble-media { padding: 4px; }
.bubble-media .att-caption { padding: 4px 8px 3px; }
/* Bare content (big emoji, sticker) is a flex item of .msg-line like .bubble, and needs the same min-width: 0 /
   max-width: 100%: otherwise its automatic minimum width is the max-content of a reply quote (one nowrap line) and
   a long quoted text widens the whole line past the screen edge (T54). */
.bare { position: relative; min-width: 0; max-width: 100%; }
/* A reply quote over bare content has no bubble behind it: the plain 10% tint would sit on the chat background.
   Give it the floating-name backing (pill-bg + blur) with the sender tint mixed in. */
.bare > .quote {
  background: color-mix(in srgb, var(--u, var(--accent)) 10%, var(--pill-bg));
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.bare > .quote:hover { background: color-mix(in srgb, var(--u, var(--accent)) 16%, var(--pill-bg)); }
/* Own bare content is right-aligned, where it sits without a quote (the quote may be wider than it). */
.own .bare:has(> .quote) { text-align: right; }
.big-emoji { display: inline-flex; gap: 2px; padding: 2px 0; }
.big-emoji .emoji-img { vertical-align: 0; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12)); }
.big-emoji .emoji-txt { font-size: 52px; }
.sticker { display: block; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1)); }

.msg-meta {
  display: flex; flex-direction: column; align-items: flex-start; flex: none; font-size: 11px; color: var(--meta); line-height: 1.3;
  padding-bottom: 2px; white-space: nowrap; gap: 0;
}
.own .msg-meta { align-items: flex-end; }
.msg-meta .icon { display: inline-block; }
.meta-read { border: 0; background: transparent; padding: 0; color: var(--accent-text); font-size: 11px; font-weight: 700; line-height: 1.3; min-height: 0; }
.meta-read:hover { text-decoration: underline; }
.meta-sent { color: var(--meta); }
.meta-edited { font-style: italic; }
.meta-failed {
  flex-direction: row; align-items: center; gap: 4px; border: 0; background: var(--danger-soft); color: var(--danger); border-radius: 10px;
  padding: 4px 8px; font-size: 12px; font-weight: 600; white-space: normal; text-align: left; max-width: 120px;
}
.chat-bg-photo .msg-meta time, .chat-bg-photo .meta-sent { background: var(--pill-bg); border-radius: 6px; padding: 0 4px; }
.st-sending .bubble, .st-queued .bubble { opacity: 0.75; }
.meta-queued { display: inline-flex; align-items: center; gap: 3px; color: var(--warn-text); font-weight: 600; }
.st-failed .bubble { box-shadow: 0 0 0 1.5px var(--danger); }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; padding: 0 4px; position: relative; z-index: 1; }
.react {
  position: relative; display: inline-flex; align-items: center; gap: 3px; height: 28px; padding: 0 8px 0 5px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 700; color: var(--text-2); box-shadow: var(--shadow-1);
}
.react::before { content: ''; position: absolute; inset: -8px -2px; }
.react.mine { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.react:hover { border-color: var(--line-2); }
.react.mine:hover { border-color: var(--accent); }
.react:disabled { opacity: 0.8; }

/* Desktop hover toolbar (T46, §12.3). Always beside the line (bubble + time), bottom-aligned — right of others'
   lines, left of own — so it never covers a bubble, the stickers or the message above. Three buttons
   (加反應 / 回覆 conditional, 更多 always), horizontal.
   Narrow pane (default): 26px buttons, no padding → toolbar 3 × 26 + 2 border = 80px. To leave room for it,
   .msg-col is capped at 100% - 42 (avatar 34 + gap 8) - 84 (4 gap + toolbar 80), on both sides alike, but only
   where the toolbar can appear (hover + fine pointer; phones keep 80%). 420px pane: row content 398 → 272
   (was 80% = 318), line ends at 324, toolbar [328, 408] inside the row's 12px right padding; with a 17px
   classic scrollbar (403): 255, toolbar ends at 391. At 700 the cap is 552 > 80% = 542, so nothing changes.
   Wide pane: 30px buttons + 2px padding → 96px. "Wide" = the widest line plus the toolbar fits: row padding-left
   10 + avatar 34 + gap 8 + .msg-col cap 560 + 4 + 96 = 712, + up to 17px of classic scrollbar inside
   .msg-scroll, + slack → 750px.
   Always display: flex; shown by visibility + opacity. Hover reveals it after the pointer rests ~100 ms (a sweep
   across the list does not flicker); focus-within at once. Hidden = no pointer events, not reachable by Tab. */
.msg-tools {
  position: absolute; bottom: 0; display: flex; gap: 0; z-index: 4; padding: 0; border-radius: 999px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); box-shadow: var(--shadow-1);
  visibility: hidden; opacity: 0; transition: opacity 0.12s ease-out, visibility 0s linear 0.12s;
}
.other .msg-tools { left: calc(100% + 4px); }
.own .msg-tools { right: calc(100% + 4px); }
.msg-tools > .icon-btn.sm { width: 26px; height: 26px; }
.msg-tools .icon { width: 16px; height: 16px; }
@container msgs (min-width: 750px) {
  .msg-tools { padding: 2px; }
  .msg-tools > .icon-btn.sm { width: 30px; height: 30px; }
}
@media (hover: hover) and (pointer: fine) {
  .msg-row:hover .msg-tools { visibility: visible; opacity: 1; transition: opacity 0.12s ease-out 0.1s, visibility 0s linear 0.1s; }
  .msg-row:focus-within .msg-tools { visibility: visible; opacity: 1; transition: opacity 0.12s ease-out, visibility 0s; }
  @container msgs (width < 750px) {
    .msg-col { max-width: min(80%, 560px, calc(100% - 42px - 84px)); }
  }
}
.msg-row.flash .bubble, .msg-row.flash .bare { animation: flash 1.4s ease-out; }
@keyframes flash {
  0%, 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* Touch: the whole message list is not selectable (bubbles, meta time / read, names, day separators,
   system pills, the room start). A long press there opens our menu; copying goes through its 「複製」.
   Otherwise iOS's own long press selects text and shows its Copy / Look Up / Translate callout (T43).
   There are no inputs inside .msg-scroll (editing happens in the composer). Desktop keeps selection. */
@media (pointer: coarse) {
  .msg-scroll { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

.jump-down {
  position: absolute; right: calc(14px + var(--safe-r)); bottom: 12px; z-index: 6; display: inline-flex; align-items: center; gap: 6px;
  height: 44px; min-width: 44px; padding: 0 12px; border-radius: 22px; border: 0; background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-2); font-size: 13px; font-weight: 700; justify-content: center; animation: pop 0.16s ease-out;
}
.jump-down.has-new { background: var(--accent); color: var(--accent-ink); }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.drop-hint {
  position: absolute; inset: 10px; border: 2.5px dashed var(--accent); border-radius: 18px; background: color-mix(in srgb, var(--accent-soft) 80%, transparent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--accent-text); font-weight: 700; z-index: 8; pointer-events: none;
}

/* attachments, lightbox, voice, stickers, uploads: web/styles/media.css (T6) */

/* ---------------------------------------------------------------- composer */
.composer {
  flex: none; position: relative; z-index: 5; background: var(--glass); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line); padding: 6px calc(6px + var(--safe-r)) calc(6px + var(--safe-b)) calc(6px + var(--safe-l));
}
.kb-open .composer { padding-bottom: 6px; }
.composer-row { display: flex; align-items: flex-end; gap: 2px; }
.composer-btn { color: var(--text-2); }
.composer-box {
  flex: 1; min-width: 0; display: flex; align-items: flex-end; background: var(--surface); border-radius: 22px; border: 1.5px solid var(--line-2);
  transition: border-color 0.15s; margin: 0 4px;
}
.composer-box:focus-within { border-color: var(--accent); }
.composer-box textarea {
  flex: 1; min-width: 0; border: 0 !important; box-shadow: none !important; background: transparent !important; resize: none;
  padding: 10px 2px 10px 15px !important; min-height: 42px !important; line-height: 22px; font-size: max(16px, var(--fs-msg)); max-height: 160px;
  overflow-y: hidden; border-radius: 22px;
}
.composer-emoji { width: 42px; height: 42px; color: var(--text-3); }
.send-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; animation: pop 0.14s ease-out;
}
.send-btn:disabled { opacity: 0.5; }
.composer.disabled .composer-box { opacity: 0.6; }
.composer-ctx { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px 8px; }
.composer-ctx-icon { color: var(--accent-text); flex: none; }
.composer-ctx-main { flex: 1; min-width: 0; border-left: 3px solid var(--u, var(--accent)); padding-left: 9px; }
.composer-ctx-title { font-size: 13px; font-weight: 700; color: var(--ut, var(--accent-text)); }
.composer-ctx-text { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-count { font-size: 12px; color: var(--text-3); text-align: right; padding: 2px 12px 0; }
.mention-menu {
  position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); max-width: 360px; max-height: 300px; overflow-y: auto; background: var(--surface);
  border-radius: 16px; box-shadow: var(--shadow-3); padding: 6px; z-index: 20; border: 1px solid var(--line);
}
.mention-opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 6px 10px; border: 0; background: transparent; border-radius: 10px; text-align: left; }
.mention-opt.on, .mention-opt:hover { background: var(--accent-soft); }
.mention-name { font-weight: 600; flex: 1; }
.mention-all { background: var(--accent); color: var(--accent-ink); }
.attach { position: relative; }
.attach-menu {
  position: absolute; bottom: calc(100% + 10px); left: 0; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-3);
  padding: 6px; min-width: 180px; z-index: 20; border: 1px solid var(--line); display: flex; flex-direction: column; animation: pop 0.14s ease-out;
}
.attach-menu button { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border: 0; background: transparent; border-radius: 10px; font-size: 15px; font-weight: 500; text-align: left; }
.attach-menu button:hover { background: var(--surface-2); }
.attach-ic { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.ic-album { background: var(--c09); } .ic-camera { background: var(--c06); } .ic-file { background: var(--c02); }

/* ---------------------------------------------------------------- sheets, dialogs, popovers */
.sheet-wrap {
  /* Follow the visual viewport (keyboard) like the app root does. */
  position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); z-index: 60; background: var(--dim); display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-height: min(88%, 900px); background: var(--surface); border-radius: 22px 22px 0 0; display: flex; flex-direction: column;
  box-shadow: var(--shadow-3); padding-bottom: var(--safe-b); animation: up 0.2s cubic-bezier(0.2, 0.9, 0.3, 1); outline: none;
}
.sheet-tall { height: min(88%, 900px); }
@keyframes up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 8px; padding: 8px 8px 6px 20px; flex: none; }
.sheet-titles { flex: 1; min-width: 0; padding-top: 8px; }
.sheet-title { font-size: 18px; font-weight: 800; }
.sheet-sub { font-size: 13.5px; color: var(--text-2); margin-top: 2px; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 20px 16px; }
.sheet-foot { flex: none; padding: 10px 20px 14px; border-top: 1px solid var(--line); }
/* Heights in a sheet are fractions of .sheet-wrap, which is the visible area (--app-h from
   visualViewport), never vh: iOS vh is the large viewport and ignores the keyboard (§12 T14).
   The picker has a definite height so its inner list is the only scroller. */
.sheet-picker { height: clamp(min(340px, 88%), 62%, 88%); }
.sheet-picker .sheet-body { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.sheet-picker .ep { flex: 1; height: auto; }
@media (min-width: 768px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { width: min(520px, 100%); border-radius: 20px; max-height: 84%; padding-bottom: 0; }
  .sheet-wide { width: min(720px, 100%); }
  .sheet-tall { height: min(84%, 760px); }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 10px; }
}
.alert-wrap { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); height: var(--app-h, 100dvh); z-index: 70; background: var(--dim); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade 0.14s ease-out; }
.alert { width: min(380px, 100%); background: var(--surface); border-radius: 20px; padding: 22px 20px 16px; box-shadow: var(--shadow-3); animation: pop 0.16s ease-out; }
.alert-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.alert-msg { color: var(--text-2); line-height: 1.6; font-size: 15px; }
.alert-actions { display: flex; gap: 8px; margin-top: 20px; }
.alert-actions .btn { flex: 1; }
.action-list { display: flex; flex-direction: column; padding-bottom: 6px; }
.action-item { display: flex; align-items: center; gap: 14px; min-height: 54px; border: 0; background: transparent; padding: 0 8px; border-radius: 12px; text-align: left; font-size: 16px; }
.action-item:hover { background: var(--surface-2); }
.action-item.danger { color: var(--danger); }
.action-label { display: flex; flex-direction: column; }
.action-label small { color: var(--text-2); font-size: 13px; }
.popover {
  position: fixed; z-index: 65; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-3); border: 1px solid var(--line);
  overflow: hidden; display: flex; flex-direction: column; animation: pop 0.14s ease-out;
}

/* message menu */
.menu-dim {
  position: fixed; inset: 0; z-index: 75; background: var(--dim); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade 0.14s ease-out;
}
.menu-stack { position: absolute; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 24px); animation: lift 0.18s cubic-bezier(0.2, 0.9, 0.3, 1); }
.menu-stack.own { align-items: flex-end; }
.menu-stack.other { align-items: flex-start; }
@keyframes lift { from { transform: scale(0.96); opacity: 0.4; } to { transform: none; opacity: 1; } }
.react-bar { display: flex; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow-3); padding: 4px; gap: 0; }
.react-pick { width: 46px; height: 46px; border: 0; background: transparent; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: transform 0.12s; }
.react-pick:hover, .react-pick:focus-visible { transform: scale(1.18); background: var(--surface-2); }
.react-pick.mine { background: var(--accent-soft); }
.react-more { color: var(--text-2); background: var(--surface-2); }
.menu-clone { pointer-events: none; max-height: calc(var(--app-h, 100dvh) * 0.38); overflow: hidden; box-shadow: var(--shadow-3); }
.menu-clone.bare { box-shadow: none; }
.menu-time { font-size: 12px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); padding: 0 6px; }
.menu-pop .menu-time { color: var(--text-2); text-shadow: none; padding: 6px 14px 0; }
.menu-reactors { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-2); padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; max-width: 280px; font-size: 13.5px; color: var(--text-2); }
.menu-pop .menu-reactors { box-shadow: none; padding: 4px 14px; background: transparent; }
.menu-reactor { display: flex; gap: 8px; align-items: flex-start; }
.menu-list { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-3); min-width: 230px; overflow: hidden; display: flex; flex-direction: column; }
.menu-pop .menu-list { box-shadow: none; border-radius: 0; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; padding: 0 16px; border: 0; background: transparent; font-size: 16px; text-align: left; }
.menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { color: var(--text-2); }
.menu-item.danger .icon { color: var(--danger); }
/* Nothing in the menus is selectable: the phone overlay as a whole (.menu-dim: clone, time, reactors,
   list) and the desktop popover. iOS's long-press gesture (text selection + Copy / Look Up / Translate
   callout) fires after our 400 ms menu has mounted, and hit-tests the element under the finger at that
   moment, i.e. our overlay; any selectable text in it gets selected (T43: it picked the .menu-time date). */
.menu-dim, .menu-pop, .menu-list { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.menu-pop { position: fixed; z-index: 75; width: 280px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-3); border: 1px solid var(--line); overflow: hidden; animation: pop 0.12s ease-out; }
.menu-pop .react-bar { box-shadow: none; border-radius: 0; border-bottom: 1px solid var(--line); justify-content: space-between; padding: 4px 6px; }
.menu-pop .react-pick { width: 38px; height: 38px; }
.menu-pop .menu-item { min-height: 40px; font-size: 15px; }

/* toasts, connection banner */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(86px + var(--safe-b)); z-index: 95; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; max-width: 440px; background: #1f2a30; color: #fff; padding: 11px 16px; border-radius: 14px; box-shadow: var(--shadow-3);
  font-size: 14.5px; display: flex; gap: 12px; align-items: center; animation: up 0.18s ease-out; line-height: 1.45;
}
.toast-error { background: #a1262b; }
.toast-action { border: 0; background: transparent; color: #8ff0de; font-weight: 700; }
:root[data-theme="dark"] .toast { background: #33414a; }
.conn-banner {
  position: fixed; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(-50%); z-index: 96; display: flex; align-items: center; gap: 8px;
  background: var(--warn-bg); color: var(--warn-text); padding: 4px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-2);
}

/* ---------------------------------------------------------------- emoji picker */
.ep { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.popover .ep { height: 100%; }
.ep-modes { display: flex; gap: 4px; padding: 8px 10px 0; flex: none; }
.ep-mode { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; border: 0; border-radius: 10px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; }
.ep-mode.on { background: var(--accent-soft); color: var(--accent-text); }
.ep-search { display: flex; align-items: center; gap: 6px; margin: 8px 10px 4px; padding: 0 6px 0 12px; background: var(--surface-2); border-radius: 12px; color: var(--text-3); flex: none; }
.ep-search input { border: 0 !important; background: transparent !important; box-shadow: none !important; min-height: 40px !important; padding: 6px 0 !important; }
.ep-tabs { display: flex; gap: 2px; padding: 2px 8px 4px; overflow-x: auto; flex: none; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.ep-tab { width: 40px; height: 38px; flex: none; border: 0; background: transparent; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--text-2); opacity: 0.7; }
.ep-tab.on { background: var(--accent-soft); opacity: 1; color: var(--accent-text); }
.ep-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 0 6px 10px; }
.ep-sec { content-visibility: auto; contain-intrinsic-size: auto 600px; }
.ep-sec-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); padding: 10px 6px 4px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
.ep-cell { height: 46px; border: 0; background: transparent; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0; }
.ep-cell:hover, .ep-cell:focus-visible { background: var(--surface-2); }
.ep-cell img { width: 32px; height: 32px; }
.ep-txt { font-size: 27px; line-height: 1; }
.ep-stickers { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.sticker-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sticker-tabs { display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; flex: none; border-bottom: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px 0 8px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600; white-space: nowrap; color: var(--text-2); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.sticker-grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 4px; padding: 8px; align-content: start; }
.sticker-cell { aspect-ratio: 1; border: 0; background: transparent; border-radius: 14px; padding: 6px; }
.sticker-cell:hover { background: var(--surface-2); }
.sticker-cell img { width: 100%; height: 100%; object-fit: contain; }

/* ---------------------------------------------------------------- room info */
.info { padding: 0 0 24px; }
.info-page .page-body { padding-top: 0; }
.info-panel { padding: 0 14px 24px; }
.info-panel-head { display: flex; align-items: center; justify-content: space-between; min-height: var(--head-h); position: sticky; top: 0; background: var(--bg); z-index: 3; margin: 0 -4px; padding-left: 4px; }
.info-panel-head h2 { font-size: 17px; font-weight: 800; }
.info-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px 0 4px; }
.info-name { font-size: 22px; font-weight: 800; margin-top: 8px; }
.info-desc { color: var(--text-2); margin: 6px 0 0; white-space: pre-wrap; max-width: 420px; }
.info .section-body { margin: 12px 0 16px; }
.info-search { margin: 0 0 14px; }
.info-search .list-search { margin: 0; background: var(--surface); box-shadow: var(--shadow-1); }
.search-results { background: var(--surface); border-radius: 14px; margin-top: 8px; box-shadow: var(--shadow-1); overflow: hidden; }
.search-hit { display: flex; gap: 10px; width: 100%; border: 0; background: transparent; text-align: left; padding: 10px 12px; align-items: flex-start; }
.search-hit + .search-hit { border-top: 1px solid var(--line); }
.search-hit:hover { background: var(--surface-2); }
.search-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.search-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.search-text { font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.info-tabs { margin: 4px 0 8px; }
.info-tab-body { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-1); overflow: hidden; min-height: 80px; }
.member-list { list-style: none; margin: 0; padding: 4px 0; }
.member { display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 56px; }
.member-main { display: flex; flex-direction: column; min-width: 0; }
.member-name { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.member-seen { font-size: 12.5px; color: var(--text-3); }
.member-seen.online { color: var(--ok); font-weight: 600; }
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.album-cell { aspect-ratio: 1; border: 0; padding: 0; background: var(--surface-2); overflow: hidden; }
.album-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-cell.veiled img { filter: blur(10px); transform: scale(1.2); }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-row { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; padding: 10px 14px; text-align: left; color: var(--text-2); }
.file-row + .file-row, .file-list li + li { border-top: 1px solid var(--line); }
.file-main { display: flex; flex-direction: column; min-width: 0; }
.file-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-foot { margin-top: 18px; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.bg-grid.small { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.bg-cell { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; gap: 5px; align-items: stretch; text-align: center; }
.bg-thumb { display: block; aspect-ratio: 3 / 4; border-radius: 12px; overflow: hidden; background: var(--chat-fallback-css); box-shadow: 0 0 0 1px var(--line); }
.bg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-cell.on .bg-thumb { box-shadow: 0 0 0 3px var(--accent); }
.bg-name { font-size: 12.5px; color: var(--text-2); }
.bg-cell.on .bg-name { color: var(--accent-text); font-weight: 700; }

/* people lists in sheets */
.sub-head { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 12px 0 4px; }
.person { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.person-main { display: flex; flex-direction: column; }
.person-name { font-weight: 600; color: var(--ut, var(--text)); }
.person-sub { font-size: 12.5px; color: var(--text-3); }
.edits { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.edit-item { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.edit-item.current { background: var(--accent-soft); }
.edit-when { font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.edit-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.pick-list { display: flex; flex-direction: column; }
.pick-row { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 6px 4px; border-radius: 12px; cursor: pointer; position: relative; }
.pick-row:hover { background: var(--surface-2); }
.pick-name { flex: 1; font-weight: 600; min-width: 0; }
.check { position: absolute; opacity: 0; pointer-events: none; }
.check-ui { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-2); display: flex; align-items: center; justify-content: center; color: transparent; flex: none; }
.pick-row.on .check-ui { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check:focus-visible + .check-ui { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* share / QR */
.share-box { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding-bottom: 6px; }
.share-box p { margin: 0; }
.qr-wrap { background: #fff; padding: 10px; border-radius: 16px; box-shadow: var(--shadow-1); line-height: 0; }
.link-box { width: 100%; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; text-align: left; }
.link-box code { background: transparent; padding: 0; font-size: 13px; word-break: break-all; }

/* settings */
.profile { padding: 16px; }
.profile-av { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.profile-av-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.profile .field:last-child { margin-bottom: 0; }

/* admin */
.page-body > .narrow > .btn-lg { margin: 4px 0 20px; }
.admin-room { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; min-height: 64px; color: var(--text); text-decoration: none; }
.admin-room + .admin-room { border-top: 1px solid var(--line); }
.admin-room:hover { background: var(--surface-2); text-decoration: none; }
.admin-room-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-room-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-preview-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.room-preview { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.invite-form { padding: 6px 0 12px; }
.invite-form .row-block { padding: 10px 16px 4px; border-top: 0 !important; }
.invite-form .field { padding: 10px 16px 0; margin-bottom: 12px; }
.invite-form > .btn { width: calc(100% - 32px); margin: 0 16px; }
.invite-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.invite-item { display: flex; align-items: center; gap: 4px; padding: 10px 8px 10px 16px; }
.invite-item + .invite-item { border-top: 1px solid var(--line); }
.invite-item.dead { opacity: 0.6; }
.invite-main { flex: 1; min-width: 0; }
.invite-title { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-row { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 8px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-1); padding: 14px; display: flex; flex-direction: column; gap: 2px; }
.stat .icon { color: var(--accent-text); margin-bottom: 4px; }
.stat-v { font-size: 24px; font-weight: 800; }
.stat-l { font-size: 13px; color: var(--text-2); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12.5px; color: var(--text-2); font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.audit { list-style: none; margin: 0; padding: 0; }
.audit-item { display: flex; flex-direction: column; padding: 10px 16px; gap: 2px; }
.audit-item + .audit-item { border-top: 1px solid var(--line); }

/* about / markdown */
.md-page .about-intro { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-1); padding: 18px; margin-bottom: 18px; }
.about-intro h2 { font-size: 20px; margin-bottom: 8px; }
.md { line-height: 1.65; overflow-wrap: anywhere; }
.md .md-h { margin: 22px 0 8px; }
.md h2.md-h { font-size: 19px; }
.md h3.md-h { font-size: 16.5px; }
.md h4.md-h, .md h5.md-h { font-size: 15px; }
.md-ul { padding-left: 1.3em; margin: 0 0 0.8em; }
.md-pre { white-space: pre-wrap; font-size: 12px; background: var(--surface-2); padding: 12px; border-radius: 12px; overflow-x: auto; font-family: ui-monospace, Menlo, monospace; line-height: 1.5; }
.md-table-wrap { overflow-x: auto; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-1); margin: 8px 0 14px; }
.md-table { font-size: 13px; }

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .msg-row.flash .bubble, .msg-row.flash .bare { animation: none; box-shadow: 0 0 0 3px var(--accent); }
}
[tabindex="-1"]:focus { outline: none; }
.composer-box textarea:focus-visible, .list-search input:focus-visible, .ep-search input:focus-visible { outline: none; }
.list-search:focus-within, .ep-search:focus-within { box-shadow: 0 0 0 2px var(--accent); }

/* ---------------------------------------------------------------- code login (§3.2 T42) */
/* 「用代碼登入其他裝置」 sheet (components/LoginCodeSheet.js) */
.login-code-box { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 4px 4px 8px; }
.login-code-box > p { margin: 0 0 8px; color: var(--text-2); font-size: 14.5px; line-height: 1.6; }
.login-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 44px; font-weight: 800; letter-spacing: 0.22em;
  padding-left: 0.22em; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums;
}
.login-code-next { font-size: 14px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.login-code-left { font-size: 13px; font-variant-numeric: tabular-nums; }
.login-code-expired { font-size: 20px; font-weight: 700; color: var(--text-2); margin: 10px 0; }
.login-code-box .btn-row { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.card-cta > .card-cta-actions { flex: 0 1 auto; display: flex; gap: 8px; flex-wrap: wrap; }
/* The computer's code field (selector as specific as the generic input rule it overrides) */
input.code-input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 36px; font-weight: 700; letter-spacing: 0.4em;
  text-align: center; padding: 10px 0 10px 0.4em; margin: 8px auto 6px; width: 100%; max-width: 240px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--text);
  font-variant-numeric: tabular-nums;
}
input.code-input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.code-input:not([type="checkbox"]):not([type="radio"]):not([type="file"])[aria-invalid="true"] { border-color: var(--danger); }
.code-login-busy { margin: 6px 0 0; font-size: 14px; }
.code-session-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; color: var(--text-2); font-size: 14px; line-height: 1.6; }
.code-session-note p { margin: 0; }
.code-session-note .icon { flex: none; margin-top: 2px; color: var(--accent-text); }
.device-nolock { font-size: 12px; white-space: nowrap; cursor: default; }

/* ---------------------------------------------------------------- mini window (§12.9, T47) */
/* The tab while the app is in the mini window: a centered card with the button that brings it back. */
.mini-placeholder {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--bg);
}
.mini-placeholder-card {
  display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 32px 28px; max-width: 360px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
}
.mini-placeholder-title { margin: 0; font-size: 19px; font-weight: 700; color: var(--text); }
/* The chat header in the mini window (T50, both sizes): ≤ 40 px — back, a small avatar and the room
   name, 「更多」 (game, calls, info) and the compact toggle. */
.chat-head.slim { min-height: 0; height: 40px; padding-top: 0; padding-bottom: 0; }
.chat-head.slim .icon-btn { width: 34px; height: 34px; }
.chat-head.slim .chat-title { min-height: 0; padding: 2px 6px; gap: 8px; }
.chat-head.slim .chat-name { font-size: 14px; }
/* Compact mini window (T50; the class is on #app, only ever inside the mini window): tighter list padding. */
#app.mini-compact .msg-scroll { padding: 2px 0 3px; }
