/* ZirconChat by Red Zircon. One accent (ruby), neutral greys, Geist.
   Radius rule: bubbles 18px (6px on the joined corner), cards and dialogs 16px, inputs 12px, icon buttons and pills round. */
@font-face { font-family: 'Geist'; src: url('/assets/fonts/Geist-Variable.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }

:root {
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
  --accent: #a52d3b; --accent-strong: #8a2130; --accent-soft: #f8e7e8; --accent-ink: #fdf6f6;
  --bg: #eef0f3; --surface: #fcfcfd; --surface-2: #f4f5f7; --surface-3: #e9ebef; --hover: #f0f1f4;
  --ink: #15171c; --ink-2: #3d424b; --muted: #6a707b; --faint: #9aa0aa; --line: #e3e5ea;
  --mine: #f6e1e3; --mine-ink: #2a1418; --mine-meta: #9b5a62; --theirs: #fcfcfd;
  --wall: #e7e9ee; --wall-dot: rgba(21, 23, 28, .045);
  --ok: #2f7d5b; --danger: #b3261e;
  --shadow-1: 0 1px 2px rgba(22, 26, 34, .06), 0 1px 1px rgba(22, 26, 34, .04);
  --shadow-2: 0 10px 30px rgba(22, 26, 34, .14), 0 2px 6px rgba(22, 26, 34, .08);
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 34%, transparent);
  --h-a: #c2566a; --h-b: #3f7fb5; --h-c: #3d8c6e; --h-d: #b7792a; --h-e: #7a5bb5; --h-f: #3b8b9c;
  --side-w: 360px; --info-w: 360px;
  color-scheme: light;
}
[data-theme="dark"] {
  --accent: #e0707a; --accent-strong: #f08e96; --accent-soft: #3f262b; --accent-ink: #1a0f11;
  --bg: #0f1115; --surface: #171a20; --surface-2: #1d2027; --surface-3: #262a33; --hover: #20242c;
  --ink: #eceef2; --ink-2: #c6cad2; --muted: #969ca8; --faint: #6c727e; --line: #2a2e37;
  --mine: #4a2a30; --mine-ink: #f7e9eb; --mine-meta: #d79aa1; --theirs: #1f232a;
  --wall: #101318; --wall-dot: rgba(255, 255, 255, .035);
  --ok: #6cc59b; --danger: #f2817a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 14px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .4);
  --h-a: #e07e90; --h-b: #6aa7dc; --h-c: #66bb98; --h-d: #dba45a; --h-e: #a58ae0; --h-f: #63b6c6;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; }
a { color: var(--accent); }
img { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 22px; height: 22px; flex: none; fill: currentColor; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 8px 16px; }
.accent { color: var(--accent) !important; }
.flip { transform: rotate(180deg); }
.flip-x { transform: scaleX(-1); }
.boot { height: 100dvh; }
.noscript, .fatal { padding: 40px; text-align: center; }
.fatal { display: grid; gap: 16px; justify-items: center; margin-top: 20vh; }

/* ---------- buttons, fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 999px; font-weight: 600; font-size: 14.5px; white-space: nowrap; transition: background .15s, transform .1s, opacity .15s; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn.danger { background: var(--danger); color: #fff; }
[data-theme="dark"] .btn.danger { color: #1a0d0c; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn.small { height: 34px; padding: 0 14px; font-size: 13.5px; }
.btn.small .icon { width: 18px; height: 18px; }
.btn:disabled { opacity: .55; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent-ink); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.ghost.busy::after { border-color: var(--ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:focus-visible { border-radius: 50%; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

.field { display: grid; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field textarea, .dlg input[type="text"], .invite-url {
  width: 100%; min-width: 0; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 11px 14px; resize: vertical; line-height: 1.4; }
.field input:focus, .field textarea:focus, .dlg input[type="text"]:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.form-error { margin: 0 0 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-size: 13.5px; }
.form-error:empty { display: none; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.counter { font-variant-numeric: tabular-nums; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; background:
  radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%), var(--bg); }
.auth-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 18px; letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 650; }
.logo { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, #c13a49, #8a2130); color: #fdf5f4; box-shadow: 0 4px 12px rgba(138, 33, 48, .25); }
.logo .icon { width: 22px; height: 22px; }
.auth-main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 12px 16px; }
.auth-card { margin: auto 0; width: 100%; max-width: 420px; padding: 32px 32px 28px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2); }
.auth-card h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.15; letter-spacing: -.02em; font-weight: 650; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; }
.auth-card form { margin: 0; }
.auth-card .actions .btn { min-width: 110px; }
.auth-foot { padding: 18px 24px; text-align: center; font-size: 12.5px; color: var(--muted); }
.or { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; color: var(--faint); font-size: 12.5px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.providers { display: flex; justify-content: center; gap: 12px; }
.provider { width: 52px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; transition: background .15s, border-color .15s, transform .1s; }
.provider:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.provider:active { transform: scale(.97); }
.provider img { width: 22px; height: 22px; }
.provider-note { margin: 10px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }
.alt { margin: 22px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.alt a { font-weight: 600; text-decoration: none; }
.alt a:hover { text-decoration: underline; }
.who { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 12px 4px 4px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }
.who-avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.who-avatar .icon { width: 16px; height: 16px; }
.who-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pass { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.pass:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.pass input { border: 0 !important; box-shadow: none !important; background: transparent; flex: 1; }
.pass-toggle { display: grid; place-items: center; width: 44px; height: 44px; color: var(--muted); border-radius: 10px; }
.pass-toggle:hover { color: var(--ink); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 22px; }
.steps span { height: 3px; border-radius: 3px; background: var(--surface-3); transition: background .2s; }
.steps span.on { background: var(--accent); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.shell[data-info="open"] { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--info-w); }
.sidebar { position: relative; display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.side-base, .panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.side-head, .panel-head { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 12px; flex: none; }
.panel-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.search { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
.search .search-icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.search-input { width: 100%; height: 40px; padding: 0 36px 0 38px; border-radius: 999px; border: 1px solid transparent; background: var(--surface-2); transition: border-color .15s, background .15s, box-shadow .15s; }
.search-input::-webkit-search-cancel-button { display: none; }
.search-input:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: var(--focus); }
.search-input::placeholder { color: var(--faint); }
.search-clear { position: absolute; right: 6px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--muted); }
.search-clear .icon { width: 16px; height: 16px; }
.search.in-panel { margin: 4px 12px 10px; flex: none; }
.conn { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--faint); border-right-color: transparent; animation: spin .8s linear infinite; }
.side-body, .panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat-list { list-style: none; margin: 0; padding: 4px 8px 88px; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px; color: inherit; text-decoration: none; transition: background .12s; }
.chat-item:hover { background: var(--hover); }
.chat-item[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.chat-item[aria-current="page"] .ci-preview, .chat-item[aria-current="page"] time, .chat-item[aria-current="page"] .ci-who, .chat-item[aria-current="page"] .ci-draft, .chat-item[aria-current="page"] .ci-typing, .chat-item[aria-current="page"] .tick { color: color-mix(in srgb, var(--accent-ink) 82%, transparent) !important; }
.chat-item[aria-current="page"] .badge { background: var(--accent-ink); color: var(--accent); }
.chat-item[aria-current="page"] .online-dot { border-color: var(--accent); }
.ci-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ci-top, .ci-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ci-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; font-weight: 600; }
.ci-kind { width: 16px; height: 16px; opacity: .7; }
.ci-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-meta { display: flex; align-items: center; gap: 3px; flex: none; font-size: 12.5px; color: var(--muted); }
.ci-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--muted); }
.ci-who { color: var(--ink-2); }
.ci-draft { color: var(--danger); }
.ci-typing { color: var(--accent); }
.ci-sys, .ci-empty { font-style: italic; }
.ci-badges { display: flex; align-items: center; gap: 4px; flex: none; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 650; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.pin .icon { width: 16px; height: 16px; color: var(--faint); transform: rotate(45deg); }
.tick { display: inline-flex; color: var(--muted); }
.tick .icon { width: 17px; height: 17px; }
.tick.read { color: var(--accent); }
.tick.failed { color: var(--danger); }
.has-unread .ci-preview { color: var(--ink-2); }
.list-empty { list-style: none; }
.fab { position: absolute; right: 18px; bottom: 18px; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 38%, transparent); transition: transform .15s, background .15s; z-index: 2; }
.fab:hover { background: var(--accent-strong); transform: translateY(-1px); }
.fab:active { transform: scale(.96); }
.fab.static { position: sticky; margin: 16px 18px 18px auto; display: grid; }

.results { padding: 0 8px 16px; }
.res-sec { margin-bottom: 6px; }
.sec-title { margin: 14px 10px 6px; font-size: 12.5px; font-weight: 650; color: var(--muted); letter-spacing: .01em; }
.rows { list-style: none; margin: 0; padding: 0 8px; }
.results .rows { padding: 0; }
.row-btn, .member { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; text-align: left; color: inherit; }
.row-btn:hover:not(:disabled) { background: var(--hover); }
.row-btn:disabled { opacity: .55; }
.row-btn.selected { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; display: grid; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12.5px; color: var(--muted); flex: none; }
.check-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; flex: none; }
.check-dot .icon { width: 14px; height: 14px; }
.selected .check-dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* avatars */
.avatar { position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 650; background: var(--h-a); overflow: visible; }
.avatar > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar .icon { width: 55%; height: 55%; }
.avatar.h-a { background: var(--h-a); } .avatar.h-b { background: var(--h-b); } .avatar.h-c { background: var(--h-c); }
.avatar.h-d { background: var(--h-d); } .avatar.h-e { background: var(--h-e); } .avatar.h-f { background: var(--h-f); }
[data-theme="dark"] .avatar { color: #121418; }
.s-xs { width: 28px; height: 28px; font-size: 11px; }
.s-sm { width: 40px; height: 40px; font-size: 14px; }
.s-md { width: 52px; height: 52px; font-size: 17px; }
.s-xl { width: 104px; height: 104px; font-size: 34px; }
.online-dot { position: absolute; right: 1px; bottom: 1px; width: 14px; height: 14px; border-radius: 50%; background: #3fb07f; border: 2.5px solid var(--surface); }
.s-sm .online-dot { width: 12px; height: 12px; right: 0; bottom: 0; }

/* menus */
.menu { position: fixed; z-index: 50; min-width: 220px; max-width: min(320px, calc(100vw - 16px)); padding: 6px; border-radius: 14px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%); border: 1px solid var(--line); box-shadow: var(--shadow-2); animation: pop .14s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.menu-item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 9px 12px; border-radius: 9px; font-size: 14.5px; font-weight: 500; text-align: left; }
.menu-item .icon { width: 20px; height: 20px; color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); box-shadow: none; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--line); }
.menu-profile { display: flex; align-items: center; gap: 12px; padding: 8px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.mp-text { display: grid; min-width: 0; }
.mp-text strong { font-weight: 650; }
.mp-text span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.react-row { display: flex; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.react-btn { width: 34px; height: 34px; border-radius: 50%; font-size: 19px; display: grid; place-items: center; transition: transform .12s, background .12s; }
.react-btn:hover, .react-btn:focus-visible { background: var(--hover); transform: scale(1.15); border-radius: 50%; }
.react-btn.on { background: var(--accent-soft); }

/* ---------- conversation ---------- */
.convo-pane { position: relative; min-width: 0; min-height: 0; display: flex; background: var(--wall); background-image: radial-gradient(var(--wall-dot) 1.2px, transparent 1.3px); background-size: 22px 22px; }
.convo-empty { flex: 1; display: grid; place-items: center; }
.empty-chip { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px; background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--muted); font-size: 14px; backdrop-filter: blur(8px); }
.empty-chip .icon { width: 20px; height: 20px; }
.convo { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.convo-head { display: flex; align-items: center; gap: 6px; height: 60px; padding: 0 10px 0 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex: none; z-index: 3; }
.back-btn { display: none; }
.convo-peer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 12px; text-align: left; }
.convo-peer:hover { background: var(--hover); }
.cp-text { min-width: 0; display: grid; }
.cp-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-status { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-actions { display: flex; gap: 2px; }
.convo-search { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.convo-search input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); }
.convo-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.cs-icon { color: var(--faint); width: 18px; height: 18px; }
.cs-count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 0 8px; outline: none; }
.messages:focus-visible { box-shadow: inset var(--focus); border-radius: 0; }
.sentinel { height: 1px; }
.msg-list { max-width: 780px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; }
.day { position: sticky; top: 6px; z-index: 2; align-self: center; margin: 10px 0; }
.day span { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(8px); box-shadow: var(--shadow-1); }
.unread-sep { align-self: stretch; text-align: center; margin: 8px -16px; padding: 4px; background: color-mix(in srgb, var(--surface) 70%, transparent); font-size: 13px; color: var(--muted); font-weight: 600; }
.msg { position: relative; display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; outline: none; }
.msg.first { margin-top: 8px; }
.msg.mine { flex-direction: row-reverse; }
.msg-av { width: 28px; flex: none; }
.msg-col { display: flex; flex-direction: column; max-width: min(560px, 78%); min-width: 0; }
.mine .msg-col { align-items: flex-end; }
.bubble { position: relative; padding: 7px 11px 6px; border-radius: 18px; background: var(--theirs); color: var(--ink); box-shadow: var(--shadow-1); overflow-wrap: anywhere; min-width: 64px; }
.mine .bubble { background: var(--mine); color: var(--mine-ink); }
.theirs:not(.last) .bubble { border-bottom-left-radius: 6px; }
.theirs:not(.first) .bubble { border-top-left-radius: 6px; }
.mine:not(.last) .bubble { border-bottom-right-radius: 6px; }
.mine:not(.first) .bubble { border-top-right-radius: 6px; }
.theirs.last .bubble { border-bottom-left-radius: 6px; }
.mine.last .bubble { border-bottom-right-radius: 6px; }
.msg.flash .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: var(--shadow-1); } }
.msg:focus-visible .bubble { box-shadow: var(--focus); }
.pending .bubble { opacity: .85; }
.sender { font-size: 13.5px; font-weight: 650; margin-bottom: 1px; }
.sender.h-a { color: var(--h-a); } .sender.h-b { color: var(--h-b); } .sender.h-c { color: var(--h-c); }
.sender.h-d { color: var(--h-d); } .sender.h-e { color: var(--h-e); } .sender.h-f { color: var(--h-f); }
.fwd { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.fwd .icon { width: 14px; height: 14px; }
.fwd strong { font-weight: 650; }
.quote { display: grid; width: 100%; margin: 2px 0 4px; padding: 4px 10px; border-left: 3px solid var(--accent); border-radius: 6px 10px 10px 6px; background: color-mix(in srgb, var(--accent) 9%, transparent); text-align: left; min-width: 0; }
.quote:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.q-name { font-size: 13px; font-weight: 650; color: var(--accent); }
.q-text { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; opacity: .85; }
.text { white-space: pre-wrap; font-size: 15px; line-height: 1.42; }
.text a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.mine .text a { color: var(--accent-strong); }
[data-theme="dark"] .mine .text a { color: #ffc7cc; }
.text code { font: 13.5px ui-monospace, 'SF Mono', Menlo, Consolas, monospace; padding: 1px 5px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.text pre { margin: 4px 0; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 7%, transparent); overflow-x: auto; white-space: pre; }
.text pre code { padding: 0; background: none; }
.meta { float: right; display: inline-flex; align-items: center; gap: 4px; margin: 6px 0 -3px 12px; font-size: 11.5px; color: var(--muted); line-height: 1; white-space: nowrap; user-select: none; font-variant-numeric: tabular-nums; }
.mine .meta, .mine .meta .tick { color: var(--mine-meta); }
.mine .meta .tick.read { color: var(--accent); }
[data-theme="dark"] .mine .meta .tick.read { color: #ffb3ba; }
.meta .tick .icon { width: 16px; height: 16px; }
.edited { font-style: italic; }
.bubble.has-photo { padding: 3px; }
.bubble.has-photo .text, .bubble.has-photo .sender, .bubble.has-photo .fwd, .bubble.has-photo .quote { margin-left: 8px; margin-right: 8px; }
.bubble.has-photo .text { padding-bottom: 4px; }
.bubble.has-photo .meta { margin-right: 8px; margin-bottom: 3px; }
.bubble.media-only .meta { position: absolute; right: 10px; bottom: 9px; margin: 0; padding: 3px 7px; border-radius: 999px; background: rgba(15, 17, 21, .55); color: #fff !important; }
.bubble.media-only .meta .tick, .bubble.media-only .meta .tick.read { color: #fff !important; }
.photo { display: block; border-radius: 15px; overflow: hidden; max-width: 100%; }
.photo img { max-width: 100%; height: auto; background: var(--surface-3); }
.msg.first .bubble.has-photo .photo { border-radius: 15px; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 3px 0 2px; }
.vp-play { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; }
.vp-play .icon { width: 20px; height: 20px; }
.vp-main { flex: 1; display: grid; gap: 6px; }
.vp-bar { position: relative; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 15%, transparent); cursor: pointer; }
.vp-bar::before { content: ''; position: absolute; inset: -8px 0; }
.vp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 4px; background: var(--accent); }
.vp-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mine .vp-time { color: var(--mine-meta); }
.file-card { display: flex; align-items: center; gap: 12px; min-width: 220px; padding: 4px 2px; color: inherit; text-decoration: none; }
.file-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.file-meta { flex: 1; min-width: 0; display: grid; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12.5px; color: var(--muted); }
.mine .file-size { color: var(--mine-meta); }
.file-dl { color: var(--muted); width: 20px; height: 20px; }
.file-card:hover .file-name { text-decoration: underline; }
.file-card.static { padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; box-shadow: var(--shadow-1); transition: transform .1s; }
.reaction:hover { transform: translateY(-1px); }
.reaction.mine { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.r-emoji { font-size: 15px; line-height: 1; }
.r-count { font-weight: 650; font-variant-numeric: tabular-nums; }
.msg-more { align-self: center; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .12s, background .12s; }
.msg-more .icon { width: 18px; height: 18px; }
.msg:hover .msg-more, .msg:focus-within .msg-more, .msg-more:focus-visible { opacity: 1; }
.msg-more:hover { background: color-mix(in srgb, var(--surface) 80%, transparent); }
.retry { align-self: center; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--danger); font-weight: 600; }
.retry .icon { width: 16px; height: 16px; }
.msg.sys { justify-content: center; margin: 8px 0; }
.msg.sys span { padding: 4px 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(8px); text-align: center; }
.convo-hello { flex: 1; display: grid; place-items: center; min-height: 50vh; }
.convo-hello .empty { padding: 24px 28px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); }
.load-error { display: grid; gap: 10px; justify-items: center; margin: 40px auto; padding: 18px; border-radius: 16px; background: var(--surface); }
.load-error p { margin: 0; }
.to-bottom { position: absolute; right: 22px; bottom: 92px; width: 46px; height: 46px; border-radius: 50%; background: var(--surface); color: var(--muted); display: grid; place-items: center; box-shadow: var(--shadow-2); z-index: 4; }
.to-bottom:hover { color: var(--ink); }
.to-bottom .badge { position: absolute; top: -6px; right: -4px; }

.composer { flex: none; max-width: 812px; width: 100%; margin: 0 auto; padding: 6px 16px 16px; }
.compose-row, .rec, .compose-blocked { display: flex; align-items: flex-end; gap: 8px; }
.compose-field { flex: 1; min-width: 0; display: flex; align-items: flex-end; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--line); transition: border-color .15s, box-shadow .15s; }
.compose-field:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.compose-input:focus-visible { box-shadow: none; }
.compose-input { flex: 1; min-width: 0; border: 0; resize: none; background: transparent; padding: 12px 16px; max-height: 200px; line-height: 1.4; outline: none; }
.compose-input::placeholder { color: var(--faint); }
.attach { width: 48px; height: 48px; background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--line); }
.send { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-1); border: 1px solid var(--line); transition: background .15s, color .15s, transform .1s; }
.send:hover { color: var(--accent); }
.send.is-send { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.send.is-send:hover { background: var(--accent-strong); color: var(--accent-ink); }
.send:active { transform: scale(.95); }
.compose-ctx { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding: 6px 6px 6px 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--line); }
.ctx-icon { color: var(--accent); }
.ctx-main { flex: 1; min-width: 0; display: grid; text-align: left; padding-left: 10px; border-left: 3px solid var(--accent); }
.ctx-title { font-size: 13px; font-weight: 650; color: var(--accent); }
.ctx-text { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec { align-items: center; padding: 0 0 0 4px; border-radius: 26px; }
.rec-cancel { background: var(--surface); box-shadow: var(--shadow-1); width: 48px; height: 48px; color: var(--danger); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1.2s ease-in-out infinite; margin-left: 8px; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-label { flex: 1; color: var(--muted); font-size: 14px; }
.compose-blocked { justify-content: center; align-items: center; gap: 14px; padding: 12px; border-radius: 18px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-1); }
.drop { position: absolute; inset: 8px; z-index: 10; display: grid; place-items: center; border-radius: 20px; border: 2px dashed var(--accent); background: color-mix(in srgb, var(--surface) 88%, transparent); }
.drop-box { display: grid; justify-items: center; gap: 8px; color: var(--accent); font-weight: 600; pointer-events: none; }
.drop-box .icon { width: 36px; height: 36px; }

/* ---------- info pane ---------- */
.info-pane { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.info-head { display: flex; align-items: center; gap: 8px; height: 60px; padding: 0 10px; flex: none; }
.info-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.info-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.info-hero, .set-hero { display: grid; justify-items: center; gap: 2px; padding: 12px 20px 18px; text-align: center; }
.info-hero h3, .set-hero h3 { margin: 12px 0 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.info-hero p, .set-hero p { margin: 0; font-size: 14px; }
.info-list { margin: 0 12px; padding: 4px 0; border-top: 1px solid var(--line); }
.info-list > div { display: grid; grid-template-columns: 22px 1fr; column-gap: 16px; padding: 10px 8px; }
.info-list .icon { grid-row: span 2; color: var(--muted); margin-top: 2px; }
.info-list dt { font-size: 12.5px; color: var(--muted); order: 2; }
.info-list dd { margin: 0; overflow-wrap: anywhere; }
.info-actions { margin: 4px 12px; padding-top: 6px; border-top: 1px solid var(--line); display: grid; }
.row-action { display: flex; align-items: center; gap: 16px; padding: 11px 10px; border-radius: 12px; font-weight: 500; text-align: left; }
.row-action .icon { color: var(--muted); }
.row-action:hover { background: var(--hover); }
.row-action.danger, .row-action.danger .icon { color: var(--danger); }
.avatar-edit { position: relative; border-radius: 50%; }
.ae-badge { position: absolute; right: 2px; bottom: 2px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); border: 3px solid var(--surface); }
.ae-badge .icon { width: 16px; height: 16px; }
.invite { margin: 6px 12px; padding: 4px 8px 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; justify-items: start; }
.invite .sec-title { margin: 10px 0 2px; }
.invite-row { display: flex; gap: 6px; width: 100%; align-items: center; }
.invite-url { height: 40px; font-size: 13px; color: var(--ink-2); background: var(--surface-2); }
.invite p { margin: 0; font-size: 13.5px; }
.members-sec { margin: 4px 12px; border-top: 1px solid var(--line); }
.members-sec .sec-title { margin-left: 8px; }
.members { list-style: none; margin: 0; padding: 0; }
.member { padding: 7px 8px; }
.role { font-size: 12px; color: var(--muted); padding: 2px 8px; border-radius: 999px; background: var(--surface-2); }
.role.owner { color: var(--accent); background: var(--accent-soft); }

/* ---------- settings panels ---------- */
.settings { padding-bottom: 24px; }
.set-group { margin: 8px 12px; padding: 4px; border-radius: 16px; background: var(--surface-2); display: grid; }
.set-row { display: flex; align-items: center; gap: 16px; padding: 10px 12px; border-radius: 12px; text-align: left; width: 100%; }
.set-row .icon { color: var(--muted); }
.set-row .chev { width: 18px; height: 18px; color: var(--faint); }
button.set-row:hover { background: var(--hover); }
.set-row.danger, .set-row.danger .icon { color: var(--danger); }
.set-row.static { cursor: default; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-3); }
.seg button { height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.pf { padding: 8px 16px 24px; }
.pf-photo { display: grid; justify-items: center; gap: 10px; margin: 6px 0 18px; }
.pf-av .avatar { pointer-events: none; }
.privacy { padding: 0 8px 24px; }
.privacy fieldset { border: 0; margin: 0 0 8px; padding: 0; }
.privacy legend { padding: 0; }
.radio { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.radio:hover { background: var(--hover); }
.radio input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.switch { position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); transition: transform .18s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; }
.notif { padding: 8px 12px; }
.sessions { list-style: none; margin: 0; padding: 0 8px; }
.session { display: flex; align-items: center; gap: 14px; padding: 10px; border-radius: 12px; }
.session > .icon { color: var(--muted); }
.people-results .rows, .people .rows { padding: 0 8px; }
.newgroup { position: relative; display: flex; flex-direction: column; min-height: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px 0 2px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13.5px; }
.chip .icon { width: 14px; height: 14px; }
.newgroup .fab.static { margin-top: auto; }

.empty { display: grid; justify-items: center; gap: 4px; padding: 36px 24px; text-align: center; }
.empty-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.empty-icon .icon { width: 30px; height: 30px; }
.empty-title { margin: 0; font-weight: 650; font-size: 16px; }
.empty-text { margin: 0 0 12px; color: var(--muted); font-size: 14px; max-width: 30ch; }

/* skeletons */
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-list { padding: 4px 8px; }
.sk-row { display: flex; gap: 12px; align-items: center; padding: 9px 10px; }
.sk-av { width: 52px; height: 52px; border-radius: 50%; flex: none; }
.sk-lines { flex: 1; display: grid; gap: 8px; }
.sk-l1 { height: 13px; width: 55%; }
.sk-l2 { height: 11px; width: 80%; }
.sk-msgs { display: flex; flex-direction: column; gap: 10px; padding: 24px 0; }
.sk-bubble { height: 40px; border-radius: 18px; background-color: var(--surface); }
.sk-bubble.mine { align-self: flex-end; }

/* dialogs */
.dlg { width: min(440px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); display: flex; flex-direction: column; }
.dlg:not([open]) { display: none; }
.dlg.tall { height: min(640px, calc(100dvh - 32px)); }
.dlg::backdrop { background: rgba(10, 12, 16, .45); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px 20px; }
.dlg-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.dlg-body { padding: 6px 20px 8px; overflow-y: auto; flex: 1; min-height: 0; }
.dlg-body > div > p:first-child { margin-top: 0; }
.dlg.tall .dlg-body { padding: 0; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.pick-list { padding: 0 8px 8px; }
.upload { display: grid; gap: 12px; }
.up-list.photo { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.up-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; }
.up-list.photo:has(.up-img:only-child) { grid-template-columns: 1fr; }
.up-list.photo .up-img:only-child { aspect-ratio: auto; max-height: 340px; object-fit: contain; background: var(--surface-2); }
.up-list.file { display: grid; gap: 6px; }
.up-progress { width: 100%; height: 6px; accent-color: var(--accent); }
.join { display: grid; justify-items: center; gap: 2px; padding: 6px 0 4px; text-align: center; }
.join h3 { margin: 12px 0 0; font-size: 20px; }
.join p { margin: 0; }
.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(8, 9, 12, .94); color: #f3f4f6; display: flex; flex-direction: column; }
.viewer:not([open]) { display: none; }
.viewer::backdrop { background: rgba(8, 9, 12, .9); }
.viewer-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; }
.viewer-who { flex: 1; font-weight: 600; }
.viewer .icon-btn { color: #e7e9ee; }
.viewer .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 16px 16px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.viewer-cap { margin: 0 auto 20px; max-width: 70ch; text-align: center; padding: 0 16px; }

/* toasts */
.toasts { position: fixed; top: 14px; right: 14px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100vw - 28px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-2); font-size: 14px; animation: slide .2s cubic-bezier(.2, .9, .3, 1.1); text-align: left; }
.toast .icon { width: 18px; height: 18px; }
.toast.error { background: var(--danger); color: #fff; }
[data-theme="dark"] .toast.error { color: #1a0d0c; }
.toast.msg { background: var(--surface); color: var(--ink); border: 1px solid var(--line); width: 100%; }
.toast.msg:hover { background: var(--surface-2); }
.toast-text { display: grid; min-width: 0; }
.toast-text strong { font-weight: 650; }
.toast-text span { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity .2s, transform .2s; }
@keyframes slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1199px) {
  .shell[data-info="open"] { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .info-pane { position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--info-w), 100vw); z-index: 20; box-shadow: var(--shadow-2); }
}
@media (max-width: 1023px) { :root { --side-w: 320px; } }
@media (max-width: 767px) {
  .shell, .shell[data-info="open"] { grid-template-columns: 100%; }
  .shell[data-view="list"] .convo-pane { display: none; }
  .shell[data-view="chat"] .sidebar { display: none; }
  .back-btn { display: inline-grid; }
  .convo-head { padding-left: 4px; }
  .head-actions .icon-btn:nth-child(2) { display: none; }
  .msg-list { padding: 0 10px; }
  .msg-col { max-width: 84%; }
  .composer { padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); }
  .compose-row, .rec { gap: 6px; }
  .attach, .send, .rec-cancel { width: 44px; height: 44px; }
  .compose-input { padding: 11px 14px; }
  .info-pane { width: 100vw; border-left: 0; }
  .auth-card { padding: 26px 22px 22px; border-radius: 18px; }
  .auth-top { padding: 14px 16px; }
  .to-bottom { right: 14px; bottom: 80px; }
  .toasts { top: 8px; right: 8px; left: 8px; width: auto; }
  .msg-more { display: none; }
}
@media (hover: none) { .msg-more { display: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* settings and member rows: wrap helper text, keep pills aligned */
.radio .row-sub, .set-row .row-sub { white-space: normal; }
.privacy > .small { padding: 0 12px; min-height: 20px; }
.set-row.danger .chev { display: none; }
.member .slot { width: 40px; flex: none; }
