/* Chat test stand — messenger look (night theme), mobile first. */
:root {
  --bg: #0E1621; --bar: #17212B; --field: #242F3D; --line: #0B121B; --sep: rgba(255,255,255,.06);
  --text: #F5F5F5; --muted: #708499; --accent: #5288C1; --link: #6AB2F2;
  --in: #182533; --out: #2B5278; --out-meta: #7DA8D3; --in-meta: #6D7F8F;
  --badge: #3E6A99; --ok: #4FAE4E; --warn: #E8B04B; --err: #EC5F5F;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bar); color: var(--text); }
body { font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif; -webkit-text-size-adjust: 100%; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, textarea, select { font: inherit; color: var(--text); }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }
.flag { width: 18px; height: 13px; border-radius: 2px; vertical-align: -1px; flex: none; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; height: 100dvh; background: var(--bg); }

/* ---------- auth ---------- */
.auth { overflow-y: auto; align-items: center; padding: calc(28px + var(--safe-t)) 16px calc(24px + var(--safe-b)); background: var(--bar); }
.auth-box { width: 100%; max-width: 400px; margin: auto 0; }
.logo { width: 96px; height: 96px; border-radius: 50%; background: linear-gradient(160deg, #6AB2F2, #2B5278); display: grid; place-items: center; font-size: 34px; font-weight: 700; margin: 0 auto 18px; letter-spacing: -2px; }
.logo span { font-size: 28px; margin-left: 2px; opacity: .9; }
.auth h1 { text-align: center; font-size: 26px; font-weight: 600; margin: 0 0 6px; }
.auth p.center { margin: 0 0 20px; font-size: 15px; }
.invite-preview { background: var(--field); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; text-align: center; display: grid; gap: 2px; }
.ui-lang { display: flex; gap: 8px; justify-content: center; margin-bottom: 16px; }
.ui-lang button { display: flex; align-items: center; gap: 6px; background: var(--field); border: 1.5px solid transparent; border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.ui-lang button.on { border-color: var(--accent); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.tab { background: none; border: 0; border-radius: 8px; padding: 8px; color: var(--muted); font-size: 15px; }
.tab.on { background: var(--field); color: var(--text); font-weight: 600; }
#authForm { display: grid; gap: 12px; }
#authForm label { display: grid; gap: 6px; font-size: 13.5px; color: var(--muted); }
#authForm input:not([type=radio]), .dlg input, .dlg select { width: 100%; background: var(--bg); border: 1.5px solid var(--field); border-radius: 10px; padding: 12px 14px; outline: none; font-size: 16px; }
#authForm input:focus, .dlg input:focus, .dlg select:focus { border-color: var(--accent); }
.lang-pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lang-pick legend { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; padding: 0; }
.lang-opt { display: flex !important; align-items: center; gap: 8px; background: var(--bg); border: 1.5px solid var(--field); border-radius: 10px; padding: 12px; color: var(--text) !important; font-size: 16px !important; }
.lang-opt input { accent-color: var(--accent); margin: 0; }
.lang-opt:has(input:checked) { border-color: var(--accent); }
.err { color: var(--err); min-height: 1.2em; margin: 0; font-size: 14px; }
.btn-primary { background: var(--accent); border: 0; border-radius: 10px; padding: 13px 18px; font-weight: 600; color: #fff; font-size: 16px; }
.btn-secondary { background: transparent; border: 0; border-radius: 10px; padding: 12px 16px; color: var(--link); font-size: 16px; }

/* ---------- bars ---------- */
.bar { display: flex; align-items: center; gap: 6px; padding: calc(6px + var(--safe-t)) 8px 6px; background: var(--bar); flex: none; min-height: calc(52px + var(--safe-t)); box-shadow: 0 1px 0 var(--line); position: relative; z-index: 2; }
.bar-title { flex: 1; min-width: 0; display: grid; line-height: 1.2; }
.bar-title.center { text-align: center; }
.bar-title b { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-btn { background: none; border: 0; padding: 2px 0; }
.icon-btn { min-width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; gap: 2px; flex: none; color: var(--muted); }
.icon-btn.accent { color: var(--link); }
.icon-btn svg { width: 24px; height: 24px; }
.back-badge { background: var(--field); color: var(--text); border-radius: 999px; font-size: 12.5px; font-weight: 600; padding: 1px 7px; }

.search { display: flex; align-items: center; gap: 8px; margin: 6px 10px 4px; padding: 0 10px; background: var(--field); border-radius: 10px; height: 36px; color: var(--muted); flex: none; }
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; background: none; border: 0; outline: none; font-size: 16px; min-width: 0; }

/* ---------- avatars ---------- */
.avatar { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 19px; color: #fff; flex: none; border: 0; padding: 0; text-transform: uppercase; letter-spacing: .5px;
  background: linear-gradient(180deg, var(--c1, #72D5FD), var(--c2, #2A9EF1)); }
.avatar.sm { width: 38px; height: 38px; font-size: 14.5px; }
.avatar.xs { width: 34px; height: 34px; font-size: 13px; }
.c0 { --c1: #FF885E; --c2: #FF516A; } .c1 { --c1: #FFCD6A; --c2: #FFA85C; } .c2 { --c1: #82B1FF; --c2: #665FFF; }
.c3 { --c1: #A0DE7E; --c2: #54CB68; } .c4 { --c1: #53EDD6; --c2: #28C9B7; } .c5 { --c1: #72D5FD; --c2: #2A9EF1; } .c6 { --c1: #E0A2F3; --c2: #D669ED; }
.n0 { color: #FF8E86; } .n1 { color: #FFC168; } .n2 { color: #B19CFF; } .n3 { color: #7DD87B; } .n4 { color: #5BDDCD; } .n5 { color: #6FC3FF; } .n6 { color: #EE90E8; }

/* ---------- chat list ---------- */
.chat-list { flex: 1; overflow-y: auto; background: var(--bar); padding-bottom: var(--safe-b); }
.chat-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 7px 12px 7px 10px; background: none; border: 0; text-align: left; }
.chat-item:active { background: var(--field); }
.ci-body { flex: 1; min-width: 0; display: grid; gap: 3px; padding: 4px 0 8px; box-shadow: inset 0 -1px 0 var(--sep); align-self: stretch; align-content: center; }
.ci-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ci-row b { flex: 1; font-size: 16.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 3px; flex: none; }
.ci-time .chk { width: 17px; height: 11px; color: var(--link); }
.ci-prev { flex: 1; color: var(--muted); font-size: 15px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.6em; }
.ci-prev .who { color: var(--text); }
.badge { background: var(--accent); color: #fff; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 7px; font-size: 13.5px; font-weight: 600; display: grid; place-items: center; flex: none; align-self: flex-end; margin-bottom: 4px; }
.empty { color: var(--muted); text-align: center; padding: 48px 28px; margin: 0; font-size: 15px; }

/* ---------- conversation ---------- */
.wallpaper {
  background-color: #0E1621;
  background-image:
    radial-gradient(1200px 600px at 100% 0%, rgba(82,136,193,.10), transparent 60%),
    radial-gradient(900px 500px at 0% 100%, rgba(106,178,242,.07), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.045' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 30h28a6 6 0 0 1 6 6v14a6 6 0 0 1-6 6H34l-8 7v-7h-6a6 6 0 0 1-6-6V36a6 6 0 0 1 6-6z'/%3E%3Cpath d='M110 22h26v18h-26zM136 28h9l6 7v5h-15'/%3E%3Ccircle cx='117' cy='43' r='3'/%3E%3Ccircle cx='144' cy='43' r='3'/%3E%3Cpath d='M128 110l10-6 10 6v12l-10 6-10-6zM128 110l10 6 10-6M138 116v12'/%3E%3Cpath d='M30 120c8-10 22-10 30 0M38 128c4-4 10-4 14 0'/%3E%3Ccircle cx='45' cy='134' r='2'/%3E%3Cpath d='M80 70l14 4-14 4 3-4zM150 160l4-10 4 10-4-2z'/%3E%3Cpath d='M70 150h16M78 142v16'/%3E%3Ccircle cx='160' cy='80' r='6'/%3E%3C/g%3E%3C/svg%3E");
  background-attachment: local, local, local;
}
.msgs { flex: 1; overflow-y: auto; padding: 8px 8px 10px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.day { align-self: center; margin: 10px 0 8px; padding: 3px 10px; border-radius: 999px; background: rgba(0,0,0,.35); color: #fff; font-size: 13.5px; font-weight: 500; position: sticky; top: 4px; z-index: 1; }

.row { display: flex; align-items: flex-end; gap: 6px; margin-top: 2px; }
.row.first { margin-top: 8px; }
.row.mine { justify-content: flex-end; }
.row .av-slot { width: 34px; flex: none; }
.row:not(.group) .av-slot { display: none; }
.bubble { position: relative; max-width: min(80%, 520px); padding: 6px 9px 6px 11px; border-radius: 16px; background: var(--in); overflow-wrap: anywhere; cursor: default; }
.mine .bubble { background: var(--out); }
.row.last .bubble { border-bottom-left-radius: 4px; }
.row.mine.last .bubble { border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }
/* tail */
.row.last .bubble::before { content: ""; position: absolute; bottom: 0; left: -8px; width: 11px; height: 17px; background: inherit;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 17'%3E%3Cpath d='M11 0v17H0c4-1 9-4 10-9 .5-3 1-5 1-8z'/%3E%3C/svg%3E") no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 17'%3E%3Cpath d='M11 0v17H0c4-1 9-4 10-9 .5-3 1-5 1-8z'/%3E%3C/svg%3E") no-repeat; }
.row.mine.last .bubble::before { left: auto; right: -8px; transform: scaleX(-1); }
.sender { font-size: 14.5px; font-weight: 600; margin-bottom: 1px; display: block; }
.text { white-space: pre-wrap; font-size: 16.5px; line-height: 1.32; }
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; margin: 7px -2px -4px 12px; font-size: 12.5px; color: var(--in-meta); line-height: 1; user-select: none; position: relative; top: 2px; }
.mine .meta { color: var(--out-meta); }
.meta svg { width: 14px; height: 14px; }
.meta .chk { width: 17px; height: 11px; }
.meta .tr { width: 13px; height: 13px; opacity: .9; }
.pending-text { color: var(--muted); font-style: italic; }
.dots { display: inline-block; width: 18px; height: 6px; vertical-align: middle; background: radial-gradient(circle, currentColor 2px, transparent 2.5px) 0 50% / 6px 6px repeat-x; animation: blink 1.2s infinite; }
.note-err { color: var(--err); font-size: 13px; margin-top: 2px; }

.extra { clear: both; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.1); display: grid; gap: 6px; }
.orig-label { font-size: 12.5px; color: var(--link); display: flex; align-items: center; gap: 4px; }
.orig-label svg { width: 14px; height: 14px; }
.mine .orig-label { color: #A9CBEF; }
.orig { white-space: pre-wrap; font-size: 15px; color: #C9D3DE; }
.act { justify-self: start; display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08); border: 0; border-radius: 999px; padding: 5px 12px 5px 9px; font-size: 14px; color: var(--link); }
.mine .act { color: #fff; background: rgba(255,255,255,.14); }
.act svg { width: 17px; height: 17px; }
.act.on { color: var(--warn); }
.warn { margin-top: 6px; background: rgba(232,176,75,.12); border-left: 3px solid var(--warn); color: #F3CF86; border-radius: 4px 8px 8px 4px; padding: 5px 8px; font-size: 13.5px; clear: both; }
.warn b { display: block; font-weight: 600; }

/* voice message */
.voice { display: flex; align-items: center; gap: 10px; min-width: 200px; margin: 2px 0 4px; }
.vplay { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.mine .vplay { background: #fff; color: var(--out); }
.vplay svg { width: 22px; height: 22px; }
.wave { display: flex; align-items: center; gap: 2px; height: 26px; flex: 1; }
.wave i { width: 3px; border-radius: 2px; background: var(--link); opacity: .75; }
.mine .wave i { background: #A9CBEF; }
.vlabel { font-size: 12.5px; color: var(--in-meta); margin-top: 1px; }
.mine .vlabel { color: var(--out-meta); }

/* composer */
.composer { position: relative; display: flex; align-items: flex-end; gap: 6px; padding: 6px 8px calc(6px + var(--safe-b)); background: var(--bar); flex: none; }
.composer textarea { flex: 1; resize: none; min-height: 40px; max-height: 140px; background: var(--field); border: 0; border-radius: 20px; padding: 9px 14px; outline: none; line-height: 1.35; font-size: 16.5px; }
.composer textarea::placeholder { color: var(--muted); }
.round-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; color: var(--muted); background: transparent; }
.round-btn svg { width: 26px; height: 26px; }
.round-btn.send { background: var(--accent); color: #fff; }
.round-btn.send svg { width: 22px; height: 22px; }
.round-btn.mic.on { background: var(--accent); color: #fff; transform: scale(1.12); box-shadow: 0 0 0 8px rgba(82,136,193,.25); }
.rec-bar { position: absolute; left: 8px; right: 56px; top: 6px; bottom: calc(6px + var(--safe-b)); display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--field); border-radius: 20px; z-index: 1; font-variant-numeric: tabular-nums; }
.rec-bar .link { margin-left: auto; background: none; border: 0; color: var(--link); font-size: 15px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--err); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- dialog / toast ---------- */
.dlg { border: 0; border-radius: 14px; background: var(--bar); color: var(--text); padding: 0; width: min(92vw, 420px); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.dlg::backdrop { background: rgba(0,0,0,.55); }
.dlg form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 18px; }
.dlg form > * { min-width: 0; }
.dlg h2 { margin: 0 0 2px; font-size: 18px; font-weight: 600; }
.dlg label { color: var(--muted); font-size: 13.5px; }
.dlg p { margin: 0; font-size: 14.5px; }
.dlg-actions { display: flex; flex-direction: row-reverse; gap: 4px; margin-top: 4px; }
.dlg-actions .btn-primary, .dlg-actions .btn-secondary { padding: 10px 14px; }
.info-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.info-head .avatar { width: 80px; height: 80px; font-size: 28px; }
.mlist { display: grid; gap: 0; background: var(--bg); border-radius: 10px; overflow: hidden; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.mrow + .mrow { box-shadow: inset 0 1px 0 var(--sep); }
.mrow span { flex: 1; }
.linkbox { display: flex; align-items: center; gap: 8px; background: var(--bg); border-radius: 10px; padding: 4px 4px 4px 12px; color: var(--link); }
.linkbox svg { width: 20px; height: 20px; flex: none; }
.linkbox input { flex: 1; min-width: 0; text-overflow: ellipsis; border: 0 !important; background: none !important; padding: 8px 0 !important; color: var(--link) !important; font-size: 14px !important; }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); background: rgba(30,40,52,.96); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14.5px; max-width: calc(100vw - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 10; }

@media (min-width: 900px) {
  .screen:not(.auth) { max-width: 760px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
  .bubble { max-width: min(70%, 520px); }
}
