/* =====================================================================
   Backroom styles. Everything is driven by the variables below so
   themes, accent colors and font size apply to the whole app.
   ===================================================================== */
:root, [data-theme="dark"] {
  --bg: #1e1f24; --panel: #17181c; --rail: #111214; --panel-2: #24262c; --panel-3: #2b2e35; --hover: #2c2f36;
  --border: #ffffff12; --text: #e6e7ea; --muted: #8b8f98; --faint: #5d616b;
  --online: #3fcf75; --idle: #f0b232; --dnd: #f05454; --offline: #6b6f78; --danger: #f87171; --live: #e5484d;
  --shadow: 0 16px 48px #0008; --overlay: #000000b0; --code: #111214;
}
[data-theme="midnight"] {
  --bg: #0e0f13; --panel: #0a0b0e; --rail: #050608; --panel-2: #16181e; --panel-3: #1c1f26; --hover: #1b1e25;
  --border: #ffffff10; --text: #e8e9ee; --muted: #858a96; --faint: #4f535d; --code: #050608;
}
[data-theme="light"] {
  --bg: #ffffff; --panel: #f2f3f5; --rail: #e3e5e8; --panel-2: #e9ebee; --panel-3: #dfe2e6; --hover: #e2e4e8;
  --border: #0000001a; --text: #1f2125; --muted: #5c616b; --faint: #9aa0a9; --offline: #9aa0a9;
  --shadow: 0 16px 48px #0003; --overlay: #0008; --code: #f2f3f5;
}
:root { --accent: #7c6cf0; --accent-text: #fff; --scale: 1; --radius: 10px; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: calc(15px * var(--scale))/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.8em; }
.ico { width: 1.15em; height: 1.15em; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { transition: none !important; animation: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- inputs & buttons ---------- */
input, textarea, select { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; outline: none; color: var(--text); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
select { width: 100%; cursor: pointer; }
input[type=range] { accent-color: var(--accent); padding: 0; border: 0; background: none; }
input[type=color] { width: 44px; height: 36px; padding: 2px; cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 13px; cursor: pointer; font-size: 0.93em; white-space: nowrap; text-decoration: none; color: var(--text); transition: background .12s, filter .12s; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.big { padding: 11px; font-size: 1em; }
.btn:disabled { opacity: .55; cursor: default; filter: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 5px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--hover); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.error { color: var(--danger); font-size: 0.87em; min-height: 1em; }
.note { font-size: 0.87em; min-height: 1em; }
.note.err { color: var(--danger); }
.note.okay { color: var(--online); }
.toggle { appearance: none; width: 40px; height: 22px; border-radius: 11px; background: var(--faint); position: relative; cursor: pointer; flex-shrink: 0; border: 0; padding: 0; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(18px); }
.toggle:disabled { opacity: .45; cursor: not-allowed; }
.row-form { display: flex; gap: 8px; align-items: center; }
.row-form > input:not([type]), .row-form > input[type=text] { flex: 1; min-width: 0; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { background: var(--panel-2); border: 1px solid var(--border); border-radius: 16px; padding: 6px 14px; cursor: pointer; font-size: 0.93em; }
.pill.active { background: var(--accent); border-color: transparent; color: var(--accent-text); font-weight: 600; }

/* ---------- auth ---------- */
.auth { height: 100%; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(370px, 90vw); background: var(--panel); padding: 32px; border-radius: 16px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1.7em; font-weight: 800; letter-spacing: -.5px; }
.auth-brand img { width: 44px; height: 44px; }
.sub { margin: -6px 0 4px; color: var(--muted); }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.87em; color: var(--muted); }
.auth-card a { color: var(--muted); font-size: 0.87em; text-align: center; }

/* ---------- layout ---------- */
.app { display: flex; height: 100%; }
.nav { display: flex; flex-shrink: 0; }
.rail { width: 72px; background: var(--rail); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; overflow-y: auto; scrollbar-width: none; }
.rail-btn { position: relative; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--panel-2); color: var(--text);
  font-weight: 700; font-size: 0.95em; cursor: pointer; transition: border-radius .15s, background .15s; flex-shrink: 0; display: grid; place-items: center; padding: 0; }
.rail-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.rail-btn:hover, .rail-btn.active { border-radius: 16px; background: var(--accent); color: var(--accent-text); }
.rail-btn.home { background: none; }
.rail-btn.home img { border-radius: 14px; }
.rail-btn.add { color: var(--online); }
.rail-btn.add:hover { background: var(--online); color: #111; }
.rail-btn .ico { width: 24px; height: 24px; }
.rail-btn::before { content: ""; position: absolute; left: -12px; top: 50%; width: 4px; height: 0; background: var(--text); border-radius: 0 4px 4px 0; transform: translateY(-50%); transition: height .15s; }
.rail-btn:hover::before { height: 18px; }
.rail-btn.active::before { height: 36px; }
.rail-btn.unread::before { height: 8px; }
.rail-badge { position: absolute; right: -4px; bottom: -4px; background: var(--live); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; border: 3px solid var(--rail); box-sizing: content-box; }
.rail-sep { width: 32px; height: 2px; background: var(--panel-2); border-radius: 1px; flex-shrink: 0; }

.sidebar { width: 248px; background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side-head { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 14px; font-weight: 700; border-bottom: 1px solid var(--border); gap: 8px; flex-shrink: 0; }
.side-head.clickable { cursor: pointer; }
.side-head.clickable:hover { background: var(--hover); }
.side-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-body { flex: 1; overflow-y: auto; padding: 8px; }
.side-banner { margin: -8px -8px 8px; padding: 12px 14px; font-size: 0.85em; color: var(--muted); border-bottom: 1px solid var(--border); }
.section-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.75em; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; padding: 14px 4px 5px 4px; user-select: none; }
.section-head .cat-toggle { display: flex; align-items: center; gap: 2px; cursor: pointer; flex: 1; min-width: 0; }
.section-head .cat-toggle:hover { color: var(--text); }
.section-head .cat-toggle .ico { width: 12px; height: 12px; transition: transform .15s; }
.section-head.collapsed .cat-toggle .ico { transform: rotate(-90deg); }
.section-head .icon-btn { padding: 2px; }
.section-head .icon-btn .ico { width: 15px; height: 15px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); margin-bottom: 1px; }
.list li:hover { background: var(--hover); color: var(--text); }
.list li.active { background: color-mix(in srgb, var(--accent) 22%, var(--hover)); color: var(--text); }
.list li.unread { color: var(--text); font-weight: 600; }
.list li.static { cursor: default; }
.list li.static:hover { background: none; color: var(--muted); }
.list li.hint { cursor: default; font-size: 0.87em; }
.list li.hint:hover { background: none; color: var(--muted); }
.list li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .badge { background: var(--live); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 0 6px; }
.list li .row-actions { display: none; gap: 0; }
.list li:hover .row-actions { display: flex; }
.list li .row-actions .icon-btn { padding: 2px; }
.list li .row-actions .ico { width: 15px; height: 15px; }
.ch-ico { color: var(--faint); }
.list li.active .ch-ico, .list li:hover .ch-ico { color: var(--muted); }
.crown { color: var(--idle); }
.crown .ico { width: 14px; height: 14px; }

/* ---------- avatars & status ---------- */
.avatar { position: relative; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #111; flex-shrink: 0; font-size: 0.95em; transition: box-shadow 80ms; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.has-img .av-letter { visibility: hidden; }
.avatar.sm { width: 24px; height: 24px; font-size: 0.75em; }
.avatar.md { width: 32px; height: 32px; }
.avatar.lg { width: 80px; height: 80px; font-size: 2em; }
.avatar.xl { width: 96px; height: 96px; font-size: 2.4em; }
.avatar.speaking { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--online); }
.status { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--panel); box-sizing: content-box; background: var(--offline); }
.avatar.sm .status { width: 8px; height: 8px; border-width: 2px; right: -3px; bottom: -3px; }
.avatar.lg .status, .avatar.xl .status { width: 18px; height: 18px; border-width: 5px; right: 0; bottom: 0; }
.status.online { background: var(--online); }
.status.idle { background: var(--idle); }
.status.dnd { background: var(--dnd); }
.status.offline, .status.invisible { background: var(--offline); }
.member { cursor: pointer !important; }
.member .name { color: var(--text); }
.member.offline { opacity: .5; }
.member .sub { display: block; font-size: 0.75em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- me box ---------- */
.me { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--rail); flex-shrink: 0; }
.me-who { flex: 1; min-width: 0; border-radius: 6px; padding: 2px 4px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.me-who:hover { background: var(--hover); }
.me-name { font-weight: 600; font-size: 0.9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: 0.75em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- voice box (sidebar) ---------- */
.voice-box { flex-direction: column; gap: 8px; padding: 10px; background: var(--rail); border-bottom: 1px solid var(--border); }
.voice-box:not([hidden]) { display: flex; }
.vb-top { display: flex; align-items: center; gap: 8px; }
.vb-info { flex: 1; min-width: 0; cursor: pointer; }
.vb-status { color: var(--online); font-size: 0.85em; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.vb-where { color: var(--muted); font-size: 0.78em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vb-actions { display: flex; gap: 4px; }
.vb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; background: var(--panel-2); border: 0; border-radius: 6px; padding: 7px 8px; cursor: pointer; color: var(--text); flex: 1; font-size: 0.82em; }
.vb-btn:hover { background: var(--hover); }
.vb-btn.on { background: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.vb-btn.live { background: color-mix(in srgb, var(--online) 22%, transparent); color: var(--online); }
.vb-btn.leave { flex: 0; color: var(--danger); background: none; }
.vb-btn.leave:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); }
.voice-users { flex-direction: column; align-items: stretch !important; gap: 2px; padding: 0 0 4px 26px !important; }
.voice-user { display: flex; align-items: center; gap: 8px; font-size: 0.87em; color: var(--muted); cursor: pointer; border-radius: 4px; padding: 3px 4px; }
.voice-user:hover { background: var(--hover); color: var(--text); }
.vu-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vicons { display: flex; gap: 2px; color: var(--danger); }
.vicons .ico { width: 14px; height: 14px; }
.live-badge { background: var(--live); color: #fff; border: 0; border-radius: 4px; font-size: 10px; font-weight: 800; padding: 2px 5px; cursor: pointer; letter-spacing: .05em; }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; min-width: 0; }
.chat-icon { color: var(--faint); display: flex; }
.chat-title { font-weight: 700; white-space: nowrap; }
.chat-topic { color: var(--muted); font-size: 0.87em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 1px solid var(--border); padding-left: 10px; margin-left: 4px; }
.chat-topic:empty { display: none; }
.menu-btn { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0 8px; }
.msg { position: relative; display: flex; gap: 14px; padding: 4px 18px 2px; }
.msg:hover { background: color-mix(in srgb, var(--panel) 60%, transparent); }
.msg.cont { padding-top: 0; }
.msg.cont > .avatar { visibility: hidden; height: 0; }
.msg.mentioned { background: color-mix(in srgb, var(--idle) 10%, transparent); box-shadow: inset 2px 0 0 var(--idle); }
.msg-body { min-width: 0; flex: 1; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; }
.msg-name { font-weight: 650; cursor: pointer; }
.msg-name:hover { text-decoration: underline; }
.msg-time { color: var(--faint); font-size: 0.75em; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text a { color: color-mix(in srgb, var(--accent) 55%, #8ab4ff); }
[data-theme="light"] .msg-text a { color: #2563eb; }
.edited { color: var(--faint); font-size: 0.72em; margin-left: 4px; }
.mention { background: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--text); border-radius: 4px; padding: 0 3px; font-weight: 600; cursor: pointer; }
.msg-actions { position: absolute; right: 16px; top: -14px; display: none; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.msg:hover .msg-actions { display: flex; }
.msg-actions .icon-btn .ico { width: 16px; height: 16px; }
.msg-actions .icon-btn.danger:hover { color: var(--danger); }
.edit-box { width: 100%; margin-top: 4px; }
.edit-hint { font-size: 0.75em; color: var(--muted); margin-top: 2px; }
.compact .msg { gap: 8px; padding-top: 1px; padding-bottom: 1px; }
.compact .msg > .avatar { display: none; }
.compact .msg-body { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.compact .msg.cont .msg-body { padding-left: 0; }
.compact .msg-meta { flex-direction: row-reverse; }
.compact .attachments { flex-basis: 100%; }
.empty { color: var(--muted); text-align: center; margin-top: 28vh; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ico { width: 48px; height: 48px; color: var(--faint); }
.typing { height: 20px; padding: 0 18px; font-size: 0.8em; color: var(--muted); flex-shrink: 0; }
.composer { padding: 0 16px 16px; flex-shrink: 0; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; background: var(--panel-2); border-radius: var(--radius); padding: 4px 6px; }
.composer-row textarea { flex: 1; background: none; border: 0; padding: 9px 6px; resize: none; max-height: 200px; }
.attach-btn { width: 32px; height: 32px; margin-bottom: 4px; border-radius: 50%; border: 0; background: var(--panel-3); color: var(--muted); cursor: pointer; flex-shrink: 0; display: grid; place-items: center; }
.attach-btn:hover { background: var(--accent); color: var(--accent-text); }
.composer.locked .composer-row { opacity: .6; }

/* ---------- attachments ---------- */
.pending { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.pending:empty { display: none; }
.pend { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 8px; padding: 6px 8px; width: 240px; }
.pend.err { outline: 1px solid var(--danger); }
.pend img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.pend-info { flex: 1; min-width: 0; }
.pend-name { font-size: 0.87em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pend.err .small { color: var(--danger); }
.bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.bar div { height: 100%; background: var(--accent); transition: width .1s; }
.att-icon { color: var(--muted); display: flex; }
.att-icon .ico { width: 28px; height: 28px; }
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; align-items: flex-start; }
.att-img { max-width: min(420px, 100%); max-height: 320px; border-radius: 8px; cursor: zoom-in; display: block; }
.att-video { max-width: min(480px, 100%); max-height: 320px; border-radius: 8px; background: #000; }
.att-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; max-width: 420px; width: 100%; }
.att-card.file { flex-direction: row; align-items: center; gap: 10px; }
.att-head { display: flex; align-items: center; gap: 8px; }
.att-card a { color: var(--accent); text-decoration: none; word-break: break-all; }
.att-card audio { width: 100%; }
.drop-hint { position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 80%, transparent); color: var(--accent-text); display: grid; place-items: center; font-size: 1.4em; font-weight: 700; pointer-events: none; z-index: 5; }
.overlay.lightbox { display: flex !important; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; background: rgba(5,5,10,.94); z-index: 80; }
.lb-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-shrink: 0; color: #fff; }
.lb-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bar .btn { background: rgba(255,255,255,.1); color: #fff; }
.lb-close { color: #fff; }
.lb-stage { flex: 1; min-height: 0; overflow: hidden; display: grid; place-items: center; padding: 0 3vw 3vh; cursor: zoom-out; }
.lb-stage img { display: block; border-radius: 6px; cursor: zoom-in; box-shadow: 0 10px 40px rgba(0,0,0,.5); max-width: none; max-height: none; }
.lightbox.zoomed .lb-stage { overflow: auto; display: block; padding: 0; }
.lightbox.zoomed .lb-stage img { cursor: zoom-out; border-radius: 0; margin: 0 auto; }
@media (max-width: 760px) { .lb-hint { display: none; } .lb-bar .btn { padding: 6px 8px; font-size: 12px; } }
/* downloads */
.dl-btn .dl-done, .dl-swap .dl-done { display: none; }
.dl-swap > span { display: inline-flex; align-items: center; gap: 6px; }
.dl-swap.done .dl-idle { display: none; }
.dl-swap.done .dl-done { display: inline-flex; }
.dl-swap.done { color: var(--online); }
.dl-btn.done > .ico:first-child { display: none; }
.dl-btn.done .dl-done { display: inline-flex; color: var(--online); }
a.dl-link.done:not(.btn) { color: var(--muted); }
a.dl-link.done:not(.btn)::after { content: ' · downloaded'; font-size: .8em; }
.lb-open { color: #ccc; font-size: 0.87em; }

/* ---------- friends page ---------- */
.friends-page { max-width: 680px; display: flex; flex-direction: column; gap: 10px; padding: 0 18px; }
.friends-page h3 { margin-top: 18px; color: var(--muted); font-size: 0.75em; text-transform: uppercase; letter-spacing: .06em; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 8px; border-top: 1px solid var(--border); }
.friend-row:hover { background: var(--panel-2); }
.fr-info { flex: 1; min-width: 0; }
.fr-name { font-weight: 600; }
.fr-sub { font-size: 0.8em; color: var(--muted); }
.fr-actions { display: flex; gap: 6px; }

/* ---------- voice room ---------- */
.vroom { flex: 1; display: flex; flex-direction: column; min-height: 0; background: var(--rail); }
.vr-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.vr-empty .vr-big { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--accent); }
.vr-empty .vr-big .ico { width: 44px; height: 44px; }
.vr-empty h2 { font-size: 1.5em; }
.vr-faces { display: flex; }
.vr-faces .avatar { margin-left: -10px; box-shadow: 0 0 0 3px var(--rail); }
.vr-faces .avatar:first-child { margin-left: 0; }
.vr-grid { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 10px; padding: 14px; overflow-y: auto; }
.vr-grid > .tile { width: var(--tw, 320px); aspect-ratio: 16 / 9; flex: none; }
.vr-focus { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px; }
.vr-stage { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
.vr-focus .tile.big { width: var(--bw, 100%); height: var(--bh, 100%); }
/* The row under the big view is centered (and still scrolls sideways when it's full). */
.vr-strip { display: flex; gap: 10px; height: 104px; flex-shrink: 0; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
.vr-strip > .tile:first-child { margin-left: auto; }
.vr-strip > .tile:last-child { margin-right: auto; }
.vr-strip .tile { height: 100%; aspect-ratio: 16 / 9; flex-shrink: 0; }
.tile { position: relative; background: var(--panel-2); border-radius: 12px; overflow: hidden; display: grid; place-items: center; min-height: 0; box-shadow: 0 0 0 2px transparent; transition: box-shadow 80ms; cursor: pointer; }
/* The speaking ring is drawn inside the tile, so scrolling areas can never clip it. */
.tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 3px transparent; transition: box-shadow 80ms; pointer-events: none; z-index: 3; }
.tile.speaking::after { box-shadow: inset 0 0 0 3px var(--online); }
.tile.speaking .avatar { box-shadow: none; }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; position: absolute; inset: 0; }
.tile .avatar { width: 72px; height: 72px; font-size: 1.8em; }
.vr-strip .tile .avatar { width: 44px; height: 44px; font-size: 1.1em; }
.tile-label { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; background: #000a; color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 0.82em; max-width: calc(100% - 16px); }
.tile-label .ico { width: 14px; height: 14px; color: #ff8080; }
.tile-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-tools { position: absolute; right: 8px; top: 8px; display: none; gap: 4px; }
.tile:hover .tile-tools { display: flex; }
.tile-tools .icon-btn { background: #000a; color: #fff; }
.tile-wait { color: var(--muted); font-size: 0.87em; }
.vr-bar { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 12px; flex-shrink: 0; flex-wrap: wrap; }
.round { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--panel-3); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.round:hover { filter: brightness(1.15); }
.round .ico { width: 22px; height: 22px; }
.round.on { background: color-mix(in srgb, var(--danger) 30%, var(--panel-3)); color: var(--danger); }
.round.live { background: var(--online); color: #111; }
.round.leave { background: var(--danger); color: #fff; }

/* ---------- modals & settings ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { width: min(480px, 100%); max-height: 90vh; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; transition: width .15s ease; background: var(--panel); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.modal.wide { width: min(960px, 100%); height: min(720px, 92vh); overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 10px; }
.modal-head h2 { font-size: 1.25em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-content { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.modal h3, .pane h3 { margin-top: 12px; font-size: 0.75em; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.modal p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.divider { text-align: center; color: var(--muted); font-size: 0.8em; margin: 6px 0; }
.invite { flex: 1; background: var(--code); padding: 9px 12px; border-radius: 8px; letter-spacing: 1px; font-family: ui-monospace, monospace; }
.settings { display: flex; gap: 18px; min-height: 0; flex: 1; }
.tabs { display: flex; flex-direction: column; gap: 2px; width: 180px; flex-shrink: 0; overflow-y: auto; }
.tab { display: flex; align-items: center; gap: 8px; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { background: color-mix(in srgb, var(--accent) 22%, var(--hover)); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.tab .ico { width: 16px; height: 16px; }
.tab-body { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; min-width: 0; padding-right: 6px; }
/* Long dropdown labels and grids shrink to fit instead of pushing the window wider. */
.grid2 > *, .row-form > *, .pe-body > *, .profile-edit > * { min-width: 0; }
.pane { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.slider-val { width: 48px; text-align: right; font-size: 0.85em; color: var(--muted); }
.perm { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.perm-label { font-weight: 600; }
.soon { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px; border: 1px dashed var(--border); border-radius: 10px; }
.soon-tag { font-size: 0.7em; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; background: var(--panel-3); color: var(--muted); padding: 3px 8px; border-radius: 10px; white-space: nowrap; }
.session { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.session .ico { width: 22px; height: 22px; color: var(--muted); }
.cur-tag { font-size: 0.7em; font-weight: 800; color: var(--online); text-transform: uppercase; margin-left: 6px; }

/* roles & permission editors */
.split { display: flex; gap: 16px; min-height: 0; }
.split-list { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; }
.split-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.split-item:hover, .split-item.active { background: var(--hover); }
.split-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-item .moves { display: flex; }
.split-item .moves .icon-btn { padding: 1px; }
.split-item .moves .ico { width: 13px; height: 13px; }
.split-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.role-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.member-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-bottom: 1px solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78em; background: var(--panel-2); border-radius: 10px; padding: 2px 8px; }
.chip-add { width: auto; font-size: 0.78em; padding: 2px 6px; border-radius: 10px; }
.tri { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.tri button { background: var(--panel-2); border: 0; padding: 5px 9px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.tri button + button { border-left: 1px solid var(--border); }
.tri button .ico { width: 15px; height: 15px; }
.tri button.on.deny { background: var(--danger); color: #fff; }
.tri button.on.inherit { background: var(--panel-3); color: var(--text); }
.tri button.on.allow { background: var(--online); color: #111; }

/* profile */
.profile-edit { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.pcard { background: var(--rail); border-radius: 14px; overflow: hidden; width: 300px; box-shadow: var(--shadow); }
.pcard-banner { height: 104px; }
.pcard-body { padding: 0 16px 16px; position: relative; }
.pcard-top { margin-top: -48px; }
.pcard-top > .avatar { box-shadow: 0 0 0 6px var(--rail); }
.pcard-name { font-size: 1.25em; font-weight: 800; margin-top: 8px; }
.pcard-user { color: var(--muted); font-size: 0.87em; }
.pcard-status { font-size: 0.87em; margin-top: 6px; }
.pcard-sec { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.pcard-sec h4 { margin: 0 0 4px; font-size: 0.72em; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pcard-bio { white-space: pre-wrap; font-size: 0.9em; }
.pcard-actions { display: flex; gap: 8px; margin-top: 12px; }
.popover { position: fixed; z-index: 60; }
.avatar-pick { display: flex; align-items: center; gap: 12px; }
.status-pick { display: flex; flex-direction: column; gap: 2px; }
.status-opt { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.status-opt:hover, .status-opt.active { background: var(--hover); }
.status-opt .status { position: static; border: 0; width: 12px; height: 12px; }

/* appearance */
.theme-cards { display: flex; gap: 10px; flex-wrap: wrap; }
.theme-card { width: 120px; border-radius: 10px; border: 2px solid var(--border); cursor: pointer; overflow: hidden; padding: 0; background: none; text-align: left; }
.theme-card.active { border-color: var(--accent); }
.theme-card .sw { height: 60px; display: flex; }
.theme-card .sw span { flex: 1; }
.theme-card .lbl { padding: 6px 8px; font-size: 0.85em; color: var(--text); background: var(--panel-2); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; }
.swatch.active { border-color: var(--text); }

/* meter */
.meter { position: relative; height: 10px; background: var(--panel-2); border-radius: 5px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--idle); transition: width 60ms linear; }
.meter-fill.open { background: var(--online); }
.meter-mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); }

/* toasts */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--panel-3); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 0.9em; display: flex; align-items: center; gap: 8px; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .nav { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px #000a; height: 100%; }
  .nav.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .settings { flex-direction: column; }
  /* Phones: tabs wrap onto extra lines so every tab is visible (no hidden sideways scrolling). */
  .tabs { flex-direction: row; flex-wrap: wrap; width: auto; overflow: visible; flex-shrink: 0; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .tabs .tab-section { display: none; }
  .tabs .tab { padding: 7px 10px; background: var(--panel-2); font-size: 14px; }
  .tabs .tab.active { background: var(--accent); color: #fff; }
  .split { flex-direction: column; }
  .split-list { width: auto; }
  .grid2, .profile-edit { grid-template-columns: 1fr; }
  .chat-topic { display: none; }
}

/* ---------- dropdown menus ---------- */
.menu { background: var(--rail); border: 1px solid var(--border); border-radius: 10px; padding: 6px; min-width: 220px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; background: none; border: 0; color: var(--text); text-align: left; width: 100%; font-size: 0.92em; }
.menu-item .ico { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover { background: var(--accent); color: var(--accent-text); }
.menu-item:hover .ico { color: inherit; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
.menu-item.danger:hover .ico { color: #fff; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.side-head .ico { width: 16px; height: 16px; color: var(--muted); }
.vb-status .ico { width: 14px; height: 14px; }
.vb-btn .ico, .vb-btn.leave .ico { width: 17px; height: 17px; }
.vb-btn:disabled { opacity: .5; cursor: not-allowed; }
.round:disabled { opacity: .6; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.pill .ico { width: 15px; height: 15px; vertical-align: -3px; }
.me .icon-btn .ico { width: 18px; height: 18px; }
.chip .ico { width: 12px; height: 12px; color: var(--idle); }
.tile-tools input[type=range] { width: 90px; background: #000a; border-radius: 6px; padding: 4px 6px; }

/* =================== v0.6 =================== */
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.avatar { overflow: visible; }
.avatar.xs { width: 16px; height: 16px; font-size: 0.55em; }
.avatar.xxl { width: 120px; height: 120px; font-size: 3em; }
.avatar.xxl .status { width: 22px; height: 22px; border-width: 6px; right: 2px; bottom: 2px; }
.avatar.clickable { cursor: pointer; }
.list li .name { display: block; }
.icon-only { padding: 7px 8px; }
.head-spacer { flex: 1; }

/* names, tags, badges */
.name-line { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; vertical-align: middle; }
.name-line .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stag { display: inline-flex; align-items: center; font-size: 0.68em; font-weight: 800; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px;
  background: color-mix(in srgb, var(--tc) 28%, transparent); color: color-mix(in srgb, var(--tc) 65%, var(--text)); border: 1px solid color-mix(in srgb, var(--tc) 45%, transparent); flex-shrink: 0; line-height: 1.4; }
.sbadge { display: inline-flex; align-items: center; font-size: 0.68em; font-weight: 700; padding: 1px 6px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; line-height: 1.4;
  background: color-mix(in srgb, var(--bc) 22%, transparent); color: color-mix(in srgb, var(--bc) 60%, var(--text)); }
.gbadge { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: color-mix(in srgb, var(--bc) 25%, var(--panel-2)); color: var(--bc); flex-shrink: 0; }
.gbadge .ico { width: 14px; height: 14px; }
.gbadge.big { width: 40px; height: 40px; border-radius: 12px; }
.gbadge.big .ico { width: 22px; height: 22px; }
.msg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.msg-meta { flex-wrap: wrap; row-gap: 2px; }

/* messages: replies, reactions, formatting */
.msg { flex-wrap: wrap; }
.msg > .avatar { margin-top: 2px; }
.reply-ref { flex-basis: 100%; display: flex; align-items: center; gap: 6px; font-size: 0.82em; color: var(--muted); margin: 2px 0 2px 18px; cursor: pointer; min-width: 0; }
.reply-ref:hover { color: var(--text); }
.reply-line { width: 30px; height: 10px; border-left: 2px solid var(--faint); border-top: 2px solid var(--faint); border-top-left-radius: 6px; margin-top: 8px; flex-shrink: 0; }
.reply-name { font-weight: 600; flex-shrink: 0; }
.reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cont-time { display: none; position: absolute; left: 6px; top: 6px; font-size: 0.66em; color: var(--faint); width: 48px; text-align: right; }
.msg.cont:hover .cont-time { display: block; }
.msg.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 25%, transparent); } 100% { background: transparent; } }
.msg.pinned { box-shadow: inset 2px 0 0 var(--accent); }
.pin-mark { color: var(--accent); display: inline-flex; }
.pin-mark .ico { width: 13px; height: 13px; }
.msg.blocked { padding: 4px 18px 4px 68px; }
.blocked-note { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82em; color: var(--muted); cursor: pointer; }
.blocked-note .ico { width: 14px; height: 14px; }
.inline-code { background: var(--code); border-radius: 4px; padding: 1px 5px; font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; }
.code-block { background: var(--code); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin: 4px 0; overflow-x: auto; font-family: ui-monospace, Consolas, monospace; font-size: 0.88em; white-space: pre; max-width: 100%; }
blockquote { margin: 2px 0; padding-left: 10px; border-left: 4px solid var(--faint); color: var(--text); }
.spoiler { background: var(--faint); color: transparent; border-radius: 4px; padding: 0 2px; cursor: pointer; transition: background .15s, color .15s; }
.spoiler * { visibility: hidden; }
.spoiler.shown { background: color-mix(in srgb, var(--faint) 35%, transparent); color: inherit; cursor: default; }
.spoiler.shown * { visibility: visible; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; background: var(--panel-2); border: 1px solid transparent; border-radius: 8px; padding: 2px 8px; cursor: pointer; font-size: 0.9em; color: var(--text); }
.reaction:hover { border-color: var(--faint); }
.reaction.mine { background: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); border-color: var(--accent); }
.reaction .r-count { font-weight: 700; font-size: 0.85em; }
.reaction.add { color: var(--muted); padding: 3px 7px; }
.reaction.add .ico { width: 16px; height: 16px; }
.msg:not(:hover) .reaction.add { opacity: 0; }
.msg-actions { top: -16px; }
.day-divider { display: flex; align-items: center; gap: 10px; margin: 14px 18px 6px; color: var(--muted); font-size: 0.75em; font-weight: 700; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.load-older { text-align: center; padding: 10px; color: var(--muted); font-size: 0.85em; }
.chat-start { padding: 18px 18px 10px; }
.chat-start-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; color: var(--text); margin-bottom: 10px; }
.chat-start-ico .ico { width: 32px; height: 32px; }
.chat-start h2 { font-size: 1.6em; margin-bottom: 4px; }

/* attachments: every image is framed so huge or skinny images can't break the layout */
.att-frame { position: relative; max-width: min(420px, 100%); border-radius: 8px; overflow: hidden; background: var(--panel-2); display: inline-block; }
.att-frame .att-img { display: block; max-width: 100%; max-height: 320px; width: auto; height: auto; border-radius: 0; cursor: zoom-in; }
.att-frame.extreme { width: 280px; height: 200px; }
.att-frame.extreme .att-img { width: 100%; height: 100%; max-height: none; object-fit: cover; object-position: top; }
.att-note { position: absolute; left: 6px; bottom: 6px; background: #000b; color: #fff; font-size: 0.75em; padding: 2px 7px; border-radius: 6px; pointer-events: none; }
.att-frame.video { background: #000; }
.att-frame.gif .att-img { width: 100%; height: 100%; object-fit: cover; max-height: none; }
.gif-tag { position: absolute; left: 6px; top: 6px; background: #000a; color: #fff; font-size: 0.65em; font-weight: 800; padding: 1px 5px; border-radius: 4px; }
.fav-btn { position: absolute; right: 6px; top: 6px; width: 30px; height: 30px; border-radius: 8px; border: 0; background: #000a; color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; }
.fav-btn .ico { width: 16px; height: 16px; }
.fav-btn.on { color: #ffd166; }
.fav-btn.on .ico path { fill: currentColor; }
.att-frame:hover .fav-btn, .gif-tile:hover .fav-btn { opacity: 1; }
.yt { position: relative; width: min(400px, 100%); aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; margin-top: 6px; cursor: pointer; background: #000; }
.yt img { width: 100%; height: 100%; object-fit: cover; }
.yt iframe { width: 100%; height: 100%; border: 0; }
.yt-play { position: absolute; inset: 0; margin: auto; width: 64px; height: 44px; border-radius: 12px; background: #e5484dee; color: #fff; display: grid; place-items: center; }
.yt-play .ico path { fill: currentColor; }

/* composer */
.reply-bar { display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 10px 10px 0 0; padding: 6px 10px; font-size: 0.85em; color: var(--muted); margin-bottom: -4px; }
.reply-bar:not([hidden]) + .pending + .composer-row, .reply-bar:not([hidden]) ~ .composer-row { border-top-left-radius: 0; border-top-right-radius: 0; }
.reply-bar .ico { width: 15px; height: 15px; }
.reply-bar .reply-text { flex: 1; }
.comp-btn { height: 32px; min-width: 32px; margin-bottom: 4px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; }
.comp-btn:hover { color: var(--text); background: var(--hover); }
.comp-btn .ico { width: 20px; height: 20px; }
.gif-btn { padding: 0 4px; }
.gif-badge { display: block; font-size: 10px; font-weight: 800; line-height: 1; letter-spacing: .05em; padding: 3px 3px 3px 4px; border: 1.5px solid currentColor; border-radius: 4px; }

/* pickers & popovers */
.picker { background: var(--rail); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 10px; width: 340px; max-height: 380px; overflow-y: auto; }
.picker-sec { font-size: 0.7em; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 8px 2px 4px; }
.picker-head { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 2px 2px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-btn { font-size: 1.35em; background: none; border: 0; border-radius: 6px; cursor: pointer; padding: 3px; line-height: 1.2; }
.emoji-btn:hover { background: var(--hover); }
.gif-picker { width: 420px; max-height: 460px; display: flex; flex-direction: column; gap: 6px; }
.gif-top { display: flex; flex-direction: column; gap: 8px; }
.gif-grid { columns: 2; column-gap: 6px; overflow-y: auto; }
.gif-tile { position: relative; break-inside: avoid; margin-bottom: 6px; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--panel-2); }
.gif-tile img { width: 100%; display: block; }
.gif-more { width: 100%; }
.gif-credit { font-size: 0.7em; color: var(--faint); text-align: right; }
.pins { width: 380px; }
.pin-item { display: flex; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.pin-item:hover { background: var(--hover); }
.pin-text { font-size: 0.88em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.live-preview { width: 300px; padding: 6px; }
.live-preview img { width: 100%; border-radius: 8px; display: block; }
.lp-label { display: flex; align-items: center; gap: 8px; font-size: 0.85em; padding: 6px 2px 2px; }
.quality { width: 350px; }
.ping-graph { width: 100%; height: 120px; background: var(--panel); border-radius: 8px; display: block; }
.ping-stats { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; font-size: 0.88em; }
.ping-stats > div { display: flex; align-items: center; gap: 8px; }
.ping-stats b { margin-left: auto; }
.dotc { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.menu-header { font-size: 0.7em; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 2px; }
.menu-quick { display: flex; justify-content: space-between; padding: 2px 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-quick:empty { display: none; }

/* voice box & sidebar extras */
.vb-status { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.vb-status:hover { text-decoration: underline; }
.vb-signal { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78em; color: var(--muted); margin-right: 4px; font-weight: 600; }
.vb-signal .ico { width: 16px; height: 16px; color: var(--muted); }
.vb-where { cursor: pointer; }
.vb-where:hover { color: var(--text); text-decoration: underline; }
.vcount { font-size: 0.72em; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 0 6px; }
.rail-voice { position: absolute; left: -3px; bottom: -3px; width: 20px; height: 20px; border-radius: 50%; background: var(--online); color: #111; display: grid; place-items: center; border: 3px solid var(--rail); box-sizing: content-box; }
.rail-voice .ico { width: 11px; height: 11px; }
.rail-btn.mini { width: 32px; height: 32px; font-size: 0.7em; display: inline-grid; cursor: pointer; }
.vr-previews { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.vr-preview { position: relative; width: 320px; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: var(--panel-2); display: grid; place-items: center; }
.vr-preview img { width: 100%; height: 100%; object-fit: cover; }
.tab-section { font-size: 0.7em; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; }
.chip.warn { background: color-mix(in srgb, var(--idle) 25%, transparent); color: var(--idle); }
.audit-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 0.92em; }
.feature-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.feature-opt { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 2px solid transparent; border-radius: 10px; padding: 4px 10px 4px 4px; cursor: pointer; color: var(--text); font-size: 0.88em; }
.feature-opt.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--panel-2)); }

/* profile card additions */
.pcard-top { display: flex; align-items: flex-end; justify-content: space-between; }
.pcard-badges { display: flex; gap: 4px; background: var(--panel); padding: 4px; border-radius: 10px; margin-bottom: 4px; }
.pcard-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pcard-status { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pcard-status .ico { width: 14px; height: 14px; }
.pcard-actions { flex-wrap: wrap; }

/* full-page profile */
.modal.full-profile { padding: 0; width: min(860px, 100%); height: min(720px, 92vh); overflow-y: auto; }
.modal.full-profile .modal-content { gap: 0; }
.fp-banner { height: 160px; position: relative; flex-shrink: 0; }
.fp-close { position: absolute; right: 12px; top: 12px; background: #0007; color: #fff; }
.fp-head { position: relative; display: flex; align-items: flex-start; gap: 18px; padding: 0 28px; margin-top: -60px; flex-wrap: wrap; }
.fp-head > .fp-names, .fp-head > .fp-actions { padding-top: 70px; }
.fp-head > .avatar { box-shadow: 0 0 0 8px var(--panel); }
.fp-names { flex: 1; min-width: 200px; padding-bottom: 6px; }
.fp-name { font-size: 1.7em; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fp-actions { display: flex; gap: 8px; padding-bottom: 10px; }
.fp-featured { display: flex; gap: 10px; flex-wrap: wrap; padding: 16px 28px 0; }
.fp-badge { display: flex; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 12px; padding: 8px 14px 8px 8px; }
.fp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; padding: 18px 28px 28px; }
.fp-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.fp-col section h3 { margin: 0 0 8px; font-size: 0.72em; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.fp-col p { margin: 0; }
.fp-server { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; cursor: pointer; }
.fp-server:hover { background: var(--hover); }
.fp-badges { display: flex; flex-direction: column; gap: 8px; }
.quest { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border-radius: 12px; padding: 10px; opacity: .75; }
.quest.done { opacity: 1; }
.quest:not(.done) .gbadge { filter: grayscale(1); opacity: .6; }
.quest-bar { height: 6px; margin-top: 6px; }
@media (max-width: 760px) { .fp-grid { grid-template-columns: 1fr; } .gif-picker, .picker { width: min(92vw, 420px); } }

/* fullscreen on phones */
.tile:fullscreen, .tile:-webkit-full-screen { border-radius: 0; background: #000; }
.tile:fullscreen video { object-fit: contain; }
.pseudo-fs { position: fixed; inset: 0; z-index: 200; background: #000; display: grid; place-items: center; }
.pseudo-fs video { width: 100vw; height: 100dvh; object-fit: contain; position: static; }
.fs-close { position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; background: #000a; color: #fff; width: 44px; height: 44px; }
/* touch screens have no hover: always show stream controls, with bigger tap targets */
@media (hover: none) {
  .tile-tools { display: flex !important; }
  .tile-tools .icon-btn { width: 40px; height: 40px; }
  .msg-actions { display: none !important; }
  .fav-btn { opacity: 1; }
}

/* ===== Alpha 1.2: account security ===== */
.sec-row { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.sec-log { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sec-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 0.88em; border-top: 1px solid var(--border); }
.sec-item:first-child { border-top: 0; }
.sec-item.warn { background: color-mix(in srgb, var(--idle) 12%, transparent); }
.qr-wrap { background: #fff; padding: 10px; border-radius: 12px; width: fit-content; }
.qr-wrap img { display: block; }
.backup-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.backup-codes code { background: var(--code); padding: 8px; border-radius: 8px; text-align: center; font-family: ui-monospace, monospace; letter-spacing: .08em; }
#passkeyBtn { margin-top: -4px; }

/* ---------- search (Alpha 1.3) ---------- */
.search-wrap { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 0 6px 0 8px; width: 220px; transition: width .15s; color: var(--muted); }
.search-wrap:focus-within { width: 300px; border-color: var(--accent); }
.search-wrap input { background: none; border: 0; padding: 6px 0; flex: 1; min-width: 0; font-size: 13px; }
.search-wrap input::-webkit-search-cancel-button { display: none; }
.search-wrap svg { width: 15px; height: 15px; flex-shrink: 0; }
.search-clear { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; display: flex; }
.search-panel { position: absolute; top: 52px; right: 0; bottom: 0; width: 400px; max-width: 100%; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; z-index: 20; box-shadow: -8px 0 24px rgba(0,0,0,.25); }
.search-head { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--border); font-weight: 600; z-index: 1; }
.search-hit { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.search-hit:hover { background: var(--hover); }
.search-ch { display: flex; align-items: center; gap: 3px; margin-bottom: 4px; }
.search-ch svg { width: 12px; height: 12px; }
.search-row { display: flex; gap: 10px; align-items: flex-start; }
.search-text { margin-top: 2px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.search-text mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.search-empty { padding: 14px 12px; }
.search-tips { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; }
.search-tip { display: grid; grid-template-columns: 70px 100px 1fr; gap: 8px; align-items: baseline; text-align: left; background: none; border: 0; color: var(--text); padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.search-tip:hover { background: var(--hover); }
@media (max-width: 760px) {
  .search-wrap { width: 120px; }
  .search-wrap:focus-within { width: 170px; }
  .chat-topic { display: none; }
  .search-panel { width: 100%; box-shadow: none; }
  .search-tip { grid-template-columns: 60px 1fr; }
  .search-tip > .small { grid-column: 1 / -1; }
}
@media (min-width: 761px) {
  .chat.searching > .messages, .chat.searching > .composer, .chat.searching > .typing, .chat.searching > .vroom { margin-right: 400px; }
}
.update-bar { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.4); font-size: 14px; max-width: calc(100vw - 24px); }
.update-bar > svg { color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.att-temp { display: inline-flex; flex-direction: column; gap: 4px; max-width: 100%; }
.att-expiry { display: flex; align-items: center; gap: 4px; }
.att-expiry svg { width: 12px; height: 12px; }
.att-card.expired { opacity: .65; }
.feature-count { flex-basis: 100%; }
.feature-opt .ico:last-child { width: 14px; height: 14px; color: var(--accent); }
.pcard-timeout { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 8px; border-radius: 8px; font-size: .85em; background: color-mix(in srgb, var(--danger, #ef4444) 15%, transparent); color: var(--danger, #ef4444); }
.pcard-timeout .ico { width: 14px; height: 14px; flex-shrink: 0; }

/* ---------- name styles & banners (Alpha 1.4) ---------- */
.nm.grad { -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.font-rounded { font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Varela Round", system-ui, sans-serif; }
.font-serif { font-family: "Iowan Old Style", Georgia, "Times New Roman", serif; }
.font-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.font-hand { font-family: "Bradley Hand", "Segoe Print", "Comic Sans MS", "Chalkboard SE", cursive; }
.font-display { font-family: Impact, Haettenschweiler, "Arial Narrow Bold", "Franklin Gothic Bold", sans-serif; letter-spacing: .02em; font-weight: 400; }
.font-wide { letter-spacing: .14em; text-transform: uppercase; font-weight: 800; font-size: .9em; }
.pcard-banner, .fp-banner { background-size: cover; background-position: center; }
.name-style { display: flex; flex-direction: column; gap: 8px; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 8px; padding: 3px; gap: 2px; align-self: flex-start; }
.seg button { background: none; border: 0; color: var(--muted); padding: 5px 12px; border-radius: 6px; cursor: pointer; font: inherit; font-size: .88em; }
.seg button.on { background: var(--panel-3); color: var(--text); }
.font-pick, .fancy-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fancy-row { margin-top: 6px; }
.font-opt, .chip-btn { background: var(--panel-2); border: 2px solid transparent; color: var(--text); border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; font-size: .9em; }
.font-opt.on { border-color: var(--accent); }
.chip-btn:hover, .font-opt:hover { background: var(--panel-3); }
/* ---------- streams (Alpha 1.4) ---------- */
.tile.stream.idle { cursor: pointer; }
.tile-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55) blur(1px); }
.watch-btn { position: relative; z-index: 2; }
.tile-tools { align-items: center; z-index: 4; }
.tile-tools .stream-vol { width: 90px; accent-color: #fff; }
@media (hover: none) { .tile.stream .tile-tools { display: flex; } }
/* ---------- camera (Alpha 1.5) ---------- */
.tile video.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile video.mirror { transform: scaleX(-1); }

/* ---------- members panel (Alpha 1.5) ---------- */
.member-panel { width: 240px; flex-shrink: 0; background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; padding: 0 8px 12px; }
.mp-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; height: 52px; padding: 0 6px; background: var(--panel); font-weight: 600; border-bottom: 1px solid var(--border); margin: 0 -8px 6px; padding: 0 12px; }
.mp-group { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 12px 8px 4px; }
.icon-btn.on { color: var(--text); background: var(--panel-3); }
@media (max-width: 1000px) {
  .member-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; box-shadow: -10px 0 30px rgba(0,0,0,.35); width: min(280px, 85vw); }
}
.pcard-banner { position: relative; }
.pcard-more { position: absolute; top: 8px; left: 8px; width: 30px; height: 30px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: #fff; background: rgba(0,0,0,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.pcard-more:hover { background: rgba(0,0,0,.65); }
.pcard-more .ico { width: 16px; height: 16px; }
.popover.stacked { z-index: 61; }
/* Only useful text can be highlighted: messages, names, bios, codes. Buttons, images and layout can't. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img, video, svg { -webkit-user-drag: none; }
input, textarea, [contenteditable="true"],
.msg-text, .msg-name, .nm, .pcard-name, .pcard-user, .pcard-bio, .pcard-status, .fp-name, .fp-names .muted,
.chat-topic, .search-text, .backup-codes, code, pre, .reply-preview, .att-card .fr-info, .quest-desc, .changelog, .sec-log, .selectable {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}

/* ---------- themed dropdowns (Alpha 1.5) ---------- */
select.dd-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0 !important; pointer-events: none !important; overflow: hidden; }
.dd-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px; padding: 8px 10px 8px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: border-color .12s, background .12s; }
.dd-btn:hover:not(:disabled) { background: var(--panel-3); }
.dd-btn:focus-visible, .dd-btn[aria-expanded="true"] { outline: none; border-color: var(--accent); }
.dd-btn:disabled { opacity: .55; cursor: default; }
.dd-btn .dd-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn .dd-label.placeholder { color: var(--muted); }
.dd-btn .ico { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.dd-btn.chip-add { width: auto; min-height: 26px; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.dd-menu { max-width: min(360px, 92vw); padding: 6px; }
.dd-list { max-height: min(320px, 50vh); overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.dd-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.dd-item:hover, .dd-item:focus-visible { background: var(--panel-3); outline: none; }
.dd-item.on { color: var(--accent); font-weight: 600; }
.dd-item .ico { width: 15px; height: 15px; }
.dd-item:disabled { opacity: .5; cursor: default; }
.dd-search { width: 100%; margin-bottom: 6px; }
/* ---------- collapsible profile settings (Alpha 1.5) ---------- */
.pe-sec { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--panel); overflow: hidden; }
.pe-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.pe-head:hover { background: var(--panel-2); }
.pe-title { display: flex; flex-direction: column; gap: 2px; }
.pe-title .small { font-weight: 400; }
.pe-head > .ico { width: 18px; height: 18px; color: var(--muted); transition: transform .15s; }
.pe-sec.open .pe-head > .ico { transform: rotate(180deg); }
.pe-body { display: none; padding: 0 14px 14px; }
.pe-sec.open .pe-body { display: block; }
.pe-body > h3:first-child { margin-top: 0; }
.pe-save { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
/* ---------- @mention suggestions (Alpha 1.5) ---------- */
.composer { position: relative; }
.mention-pop { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 8px); z-index: 30; background: var(--rail); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; max-height: 320px; overflow-y: auto; }
.mention-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.mention-opt .name-line { flex: 1; min-width: 0; }
.mention-opt.on { background: var(--panel-3); }
/* ---------- new messages line & jump to present (Alpha 1.5) ---------- */
.new-divider { display: flex; align-items: center; gap: 8px; margin: 10px 16px 6px; color: #f23f43; font-size: 12px; font-weight: 700; }
.new-divider::before { content: ''; flex: 1; height: 1px; background: #f23f43; }
.new-divider span { background: #f23f43; color: #fff; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .03em; font-size: 10px; }
.jump-bar { position: absolute; left: 24px; right: 24px; bottom: calc(100% + 6px); z-index: 25; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 0; border-radius: 8px; background: var(--panel-3); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; box-shadow: var(--shadow); }
.jump-bar > span { flex: 1; text-align: left; color: var(--muted); }
.jump-bar b { font-weight: 600; }
.jump-bar .ico { width: 16px; height: 16px; }
.jump-bar.has-new { background: var(--accent); color: #fff; }
.jump-bar.has-new > span { color: rgba(255,255,255,.85); }
.uname-row { display: flex; align-items: center; gap: 6px; }
.uname-row input { flex: 1; }
.uname-status { display: flex; align-items: center; gap: 4px; min-height: 18px; }
.uname-status .ico { width: 14px; height: 14px; }
.uname-status.ok { color: var(--online); }
.uname-status.bad { color: var(--danger, #f23f43); }

/* ---------- admin panel & screen effects (Alpha 1.5) ---------- */
.rail-btn.admin { margin-top: auto; color: #facc15; }
.adm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.adm-card { background: var(--panel-2); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.adm-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.adm-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 10px; background: var(--panel-2); border-radius: 10px; }
.adm-bar-wrap { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.adm-bar { width: 100%; background: color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.adm-bar.today { background: var(--accent); }
.adm-day { font-size: 10px; color: var(--muted); }
.adm-rank { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.adm-pos { width: 28px; text-align: center; }
.adm-person { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.adm-badge { cursor: pointer; opacity: .55; border: 1px solid var(--border); background: none; color: var(--text); font: inherit; }
.adm-badge.on { opacity: 1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.adm-fx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.adm-fx { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; text-align: left; transition: transform .1s; }
.adm-fx:hover { background: var(--panel-3); transform: translateY(-1px); }
.adm-fx-emoji { font-size: 26px; }
.announce { position: fixed; top: 0; left: 0; right: 0; z-index: 900; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 48px 8px 16px; background: var(--accent); color: #fff; font-size: 14px; box-shadow: 0 2px 12px rgba(0,0,0,.3); }
.announce.warn { background: #d97706; }
.announce.party { background: linear-gradient(90deg, #7c6cf0, #ec4899, #f59e0b); }
.announce .muted { color: rgba(255,255,255,.8); }
.announce .icon-btn { position: absolute; right: 10px; color: #fff; }
.announce > .ico { width: 18px; height: 18px; flex-shrink: 0; }
body:has(.announce) #app { padding-top: 38px; }
.fx-canvas { position: fixed; inset: 0; z-index: 2000; pointer-events: none; }
@keyframes fx-shake { 0%, 100% { transform: translate(0) } 15% { transform: translate(-8px, 4px) rotate(-.5deg) } 30% { transform: translate(7px, -5px) rotate(.5deg) } 45% { transform: translate(-6px, -3px) } 60% { transform: translate(5px, 5px) } 75% { transform: translate(-3px, 2px) } }
body.fx-shake #app { animation: fx-shake .8s ease-in-out; }
@keyframes fx-disco { to { filter: hue-rotate(360deg); } }
body.fx-disco #app { animation: fx-disco 1.2s linear infinite; }
/* ---------- per-user volume (Alpha 1.6) ---------- */
.uvol-wrap { display: flex; align-items: center; gap: 8px; }
.uvol-track { position: relative; flex: 1; display: flex; align-items: center; }
.uvol { width: 100%; }
.uvol-mark { position: absolute; left: calc(75% - 1px); top: 50%; width: 2px; height: 14px; transform: translateY(-50%); background: var(--muted); border-radius: 1px; pointer-events: none; opacity: .7; }
.slider-val.boost { color: var(--accent); font-weight: 600; }
/* phone announcements: a small button that opens a sheet */
.announce-pill { position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 900; display: flex; align-items: center; gap: 6px; padding: 6px 12px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font: inherit; font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,.35); cursor: pointer; }
.announce-pill.warn { background: #d97706; }
.announce-pill.party { background: linear-gradient(90deg, #7c6cf0, #ec4899, #f59e0b); }
.announce-pill .ico { width: 15px; height: 15px; }
.announce-sheet-back { position: fixed; inset: 0; z-index: 950; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
.announce-sheet { width: 100%; background: var(--panel); border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); border-top: 4px solid var(--accent); }
.announce-sheet.warn { border-top-color: #d97706; } .announce-sheet.party { border-top-color: #ec4899; }
.announce-sheet-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.announce-sheet p { font-size: 16px; margin: 10px 0 4px; white-space: pre-wrap; }
@media (max-width: 760px) { body:has(.announce) #app { padding-top: 0; } }
/* ---------- owner editor (Alpha 1.6) ---------- */
.adm-person-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.adm-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.adm-edit { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.pe-head.static { cursor: default; }
.pe-head.static:hover { background: none; }
.modal-foot.sticky { position: sticky; bottom: -18px; z-index: 2; background: var(--panel); padding: 12px 0 18px; margin-top: 10px; box-shadow: 0 -10px 16px -10px rgba(0,0,0,.4); }
/* The search box's "Search <server>" text can't be highlighted unless you're typing in it. */
.search-wrap, .search-wrap input:not(:focus), .search-wrap input::placeholder { -webkit-user-select: none; user-select: none; }
.search-wrap input:not(:focus) { cursor: pointer; }
.tile.big video.cam-video { object-fit: contain; background: #000; }
.cam-menu { min-width: 220px; padding: 6px; }
.cam-opt { padding: 6px 10px; display: flex; flex-direction: column; gap: 4px; }
.cam-opt input { width: 100%; }
@media (max-width: 760px) {
  .adm-person { flex-wrap: wrap; }
  .adm-person > .fr-info { flex: 1 1 calc(100% - 60px); }
  .adm-person-actions { width: 100%; justify-content: flex-start; padding-left: 52px; }
}

/* ---------- live-formatted message box (Alpha 1.6.2) ---------- */
.rich-input { flex: 1; min-width: 0; min-height: 40px; max-height: 200px; overflow-y: auto; padding: 9px 6px; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.4; color: var(--text); cursor: text; -webkit-user-select: text; user-select: text; }
.rich-input:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rich-input.disabled { cursor: not-allowed; opacity: .7; }
.rich-input .cm-m { color: var(--muted); opacity: .6; font-weight: 400; font-style: normal; text-decoration: none; }
.rich-input .cm-b { font-weight: 700; }
.rich-input .cm-i { font-style: italic; }
.rich-input .cm-u { text-decoration: underline; }
.rich-input .cm-s { text-decoration: line-through; }
.rich-input .cm-u.cm-s { text-decoration: underline line-through; }
.rich-input .cm-code, .rich-input .cm-pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; background: var(--panel-3); border-radius: 4px; padding: 1px 3px; }
.rich-input .cm-pre { display: inline; padding: 1px 0; }
.rich-input .cm-spoiler { background: var(--panel-3); border-radius: 3px; }
.rich-input .cm-q { color: var(--muted); }
.rich-input .cm-link { color: var(--accent); text-decoration: underline; }
.rich-input .cm-mention { display: inline-block; background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 4px; padding: 0 3px; font-weight: 600; cursor: default; -webkit-user-select: all; user-select: all; }
.tile-label .viewers { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; color: #ddd; font-size: .9em; }
.tile-label .viewers .ico { width: 13px; height: 13px; color: #ddd; }
/* Wide windows that aren't tabbed settings (like editing an account) scroll their own content. */
.modal.wide > .modal-content { overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; padding-right: 4px; }
.modal.wide > .modal-content:has(> .settings) { overflow: hidden; padding-right: 0; }
/* Home button: the B logo on a dark tile with a soft purple glow (Alpha 1.6.5) */
.rail-btn.home { background: radial-gradient(circle at 35% 80%, #2a1060, #0d0718 70%); overflow: visible; }
.rail-btn.home img { object-fit: contain; padding: 9px; border-radius: 0; filter: drop-shadow(0 2px 6px rgba(155, 92, 255, .45)); }
/* What's New / changelog (Alpha 2.0) */
.version-link { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.version-link:hover { color: var(--text); }
.changelog { display: flex; flex-direction: column; gap: 18px; }
.cl-section h3 { margin: 0 0 6px; font-size: 1.05em; }
.cl-section h4 { margin: 10px 0 4px; font-size: .95em; color: var(--muted); }
.cl-section ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.cl-section p { margin: 4px 0; }
.cl-section code { font-size: .9em; padding: 1px 5px; border-radius: 4px; background: var(--code); }
.cl-section + .cl-section { border-top: 1px solid var(--border, rgba(255,255,255,.08)); padding-top: 14px; }
/* Group and role mentions (Alpha 2.0) */
.mention.group { background: #f0b23226; color: #f0b232; }
.mention.role { background: color-mix(in srgb, var(--role, #7c6cf0) 18%, transparent); color: var(--role, #a99cff); }
.group-ico { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--panel-3); font-weight: 700; flex: none; }
.mention-group-name { font-weight: 600; }
.role-icon { font-size: .9em; line-height: 1; margin-left: 2px; }
.quick-roles { min-width: 220px; max-height: 60vh; overflow: auto; padding-bottom: 4px; }
.qr-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.qr-row:hover { background: var(--hover); }
/* Help tickets & reports (Alpha 2.0) */
.help-btn { position: relative; }
.help-btn .rail-badge { position: absolute; top: -2px; right: -4px; transform: scale(.85); }
.count-badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 6px; font-size: .75em; margin-left: 6px; }
.report-quote { margin: 0 0 4px; padding: 8px 12px; border-left: 3px solid var(--danger); background: var(--panel-2); border-radius: 6px; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; }
.tickets-modal { width: min(980px, 96vw); }
.tickets-modal .modal-content { padding: 0; }
.tk-wrap { display: grid; grid-template-columns: 300px 1fr; height: min(640px, 78vh); }
.tk-list { border-right: 1px solid var(--border); overflow: auto; display: flex; flex-direction: column; gap: 2px; padding: 6px; }
.tk-filters { display: flex; gap: 6px; padding: 4px 4px 8px; }
.tk-item { text-align: left; background: none; border: 0; color: inherit; padding: 10px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
.tk-item:hover { background: var(--hover); }
.tk-item.active { background: var(--panel-3); }
.tk-item.unread .tk-subj { font-weight: 700; }
.tk-item.unread .tk-subj::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; margin-right: 6px; }
.tk-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tk-subj { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-subj .ico { width: 14px; height: 14px; color: var(--danger); flex: none; }
.tk-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-status { font-size: .72em; padding: 2px 8px; border-radius: 999px; flex: none; background: var(--panel-3); }
.tk-status.s-open { background: #f0b23226; color: var(--idle); }
.tk-status.s-claimed { background: #3b82f626; color: #60a5fa; }
.tk-status.s-closed { color: var(--muted); }
.tk-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tk-empty { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px; }
.tk-empty > .ico { width: 40px; height: 40px; }
.tk-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tk-head-main { flex: 1; min-width: 0; }
.tk-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tk-back { display: none; }
.tk-report { margin: 10px 14px 0; padding: 10px 12px; border: 1px solid #f8717140; border-radius: 10px; background: #f8717110; display: flex; flex-direction: column; gap: 6px; }
.tk-report-head { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--danger); }
.tk-msgs { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.tk-msg { max-width: 85%; padding: 8px 12px; border-radius: 12px; background: var(--panel-2); align-self: flex-start; }
.tk-msg.mine { align-self: flex-end; background: color-mix(in srgb, var(--accent, #7c6cf0) 22%, var(--panel-2)); }
.tk-msg.staff { border: 1px solid #3b82f640; }
.tk-msg-who { font-weight: 600; font-size: .85em; margin-bottom: 2px; }
.tk-staff { display: inline-flex; align-items: center; gap: 4px; color: #60a5fa; }
.tk-staff .ico { width: 13px; height: 13px; }
.tk-msg-text { white-space: pre-wrap; word-break: break-word; }
.tk-sys { text-align: center; }
.tk-reply { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); align-items: flex-end; }
.tk-reply textarea { flex: 1; resize: vertical; min-height: 44px; }
.staff-ping { cursor: pointer; border-left: 3px solid #f0b232; max-width: 360px; }
@media (max-width: 760px) {
  .tk-wrap { grid-template-columns: 1fr; height: 80vh; }
  .tk-wrap.has-open .tk-list { display: none; }
  .tk-wrap:not(.has-open) .tk-main { display: none; }
  .tk-back { display: inline-grid; }
  .tk-msg { max-width: 92%; }
}
.btn.small { padding: 4px 10px; font-size: .85em; min-height: 0; }
.adm-card.warn { border-color: #f0b23280; background: #f0b23212; }
.adm-log-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
/* Link previews (Alpha 2.0) */
.link-preview { display: flex; gap: 12px; max-width: 520px; margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); border-left: 4px solid var(--lp, var(--accent)); color: inherit; text-decoration: none; }
.link-preview:hover { background: var(--panel-3); }
.lp-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lp-title { font-weight: 600; color: var(--accent); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lp-img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; flex: none; }
@media (max-width: 600px) { .lp-img { width: 64px; height: 64px; } }
.ios-guide { background: var(--panel-2); border-radius: 10px; padding: 12px 14px; }
.ios-guide ol { margin: 6px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.cl-section h3 { text-transform: none; letter-spacing: 0; color: var(--text); }
.adm-cards .adm-num { overflow-wrap: anywhere; }
/* ---------- Mobile breathing room (Alpha 2.0) ---------- */
@media (max-width: 760px) {
  /* iPhone notch and home bar: keep things out from under them. */
  .chat-head { padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); height: calc(54px + env(safe-area-inset-top)); gap: 4px; }
  .composer { padding: 0 max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .composer-row { padding: 5px 6px; min-height: 48px; align-items: center; border-radius: 14px; }
  .nav { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  /* Search shrinks to an icon until you tap it, so the title has room. */
  .search-wrap { width: 40px; padding: 0 9px; border-color: transparent; background: none; }
  .search-wrap input { width: 0; opacity: 0; }
  .search-wrap:focus-within { position: absolute; left: 8px; right: 8px; width: auto; background: var(--panel-2); border-color: var(--accent); z-index: 3; }
  .search-wrap:focus-within input { width: auto; flex: 1; opacity: 1; }
  .chat-head { position: relative; }
  .chat-title { font-size: 17px; }
  /* Messages: a little more space between people and around the edges. */
  .messages { padding: 12px 0 10px; }
  .msg { padding: 6px 14px 3px; gap: 12px; line-height: 1.45; }
  .msg:not(.cont) { margin-top: 6px; }
  .msg-text { font-size: 15.5px; }
  .msg-meta { flex-wrap: wrap; row-gap: 0; }
  /* The channel drawer dims the chat behind it; tap outside to close. */
  #app.nav-open::after { content: ''; position: fixed; inset: 0; background: #0008; z-index: 9; animation: fadeIn .15s; }
  .nav { width: min(86vw, 340px); }
  /* Bigger tap targets in menus and lists. */
  .menu-item { padding: 11px 12px; font-size: 1em; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .modal { border-radius: 16px; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.cl-section h4.cl-admin { display: flex; align-items: center; gap: 6px; color: #60a5fa; }
.cl-section h4.cl-admin .ico { width: 14px; height: 14px; }
/* Recording (Alpha 2.0.5) */
.rec-on { color: #fff !important; background: #e5484d !important; width: auto !important; padding: 0 8px; gap: 5px; display: inline-flex; align-items: center; }
.rec-time { font-size: 12px; font-variant-numeric: tabular-nums; }
.rec-badge { position: absolute; top: 8px; left: 8px; display: flex; align-items: center; gap: 5px; background: #000a; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; letter-spacing: .04em; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
/* Alpha 3.0: fullscreen button toggles */
.fs-btn .ico + .ico { display: none; }
:fullscreen .fs-btn .ico:first-child { display: none; }
:fullscreen .fs-btn .ico + .ico { display: inline-block; }
/* Alpha 3.0: feel like an app on phones — no double-tap zoom, no long-press callouts, no zoom when typing */
html, body { touch-action: manipulation; }
@media (pointer: coarse) {
  body { -webkit-touch-callout: none; }
  input, textarea, select, [contenteditable] { font-size: 16px !important; }
}
.sp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sp-item { text-align: left; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; color: inherit; cursor: pointer; }
.sp-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); }
.sp-name { font-weight: 600; }
.sp-preview { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
/* Changelog: updates with their patches tucked underneath */
details.cl-section > summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 8px; }
details.cl-section > summary::-webkit-details-marker { display: none; }
details.cl-section > summary h3 { margin: 0; }
details.cl-section > summary::before { content: '▸'; color: var(--muted); }
details.cl-section[open] > summary::before { content: '▾'; }
.cl-section h3 { font-size: 1.15em; }
.cl-patch { margin: 12px 0 0 14px; padding-left: 12px; border-left: 2px solid var(--border); font-size: .95em; }
.cl-patch-title { font-weight: 600; font-size: .92em; color: var(--muted); margin-bottom: 4px; }
.gbadge.emoji { font-size: 12px; line-height: 1; }
.gbadge.big.emoji { font-size: 16px; }
.adm-badge-form { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.adm-badge-form .row-form { align-items: center; }
