:root {
  --bg0: #0e0f13;
  --bg1: #15171c;
  --bg2: #1b1e24;
  --bg3: #23272f;
  --bg4: #2c313a;
  --line: #2a2e36;
  --text: #e8eaef;
  --text2: #a7adba;
  --text3: #6f7685;
  --accent: #6c7bff;
  --accent2: #8b97ff;
  --good: #3fd28b;
  --warn: #f2b84b;
  --bad: #ff5d68;
  --live: #ff3b5c;
  --mention: rgba(242, 184, 75, .09);
  --radius: 10px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg0); color: var(--text); font: 15px/1.45 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent2); }
.muted { color: var(--text2); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
.ic { flex-shrink: 0; display: block; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--line); background: var(--bg3); padding: 8px 14px; border-radius: 8px; font-weight: 600; transition: background .12s, transform .06s; }
.btn:hover { background: var(--bg4); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { background: transparent; border-color: rgba(255, 93, 104, .4); color: var(--bad); }
.btn.danger:hover { background: rgba(255, 93, 104, .12); }
.btn.big { padding: 12px 22px; font-size: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: transparent; color: var(--text2); border-radius: 8px; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--bg4); color: var(--text); }
.icon-btn.tiny { width: 24px; height: 24px; border-radius: 6px; }
.icon-btn.off { color: var(--bad); }
.icon-btn.on { color: var(--text); background: var(--bg4); }
.icon-btn.live-on { color: #fff; background: var(--live); }
.icon-btn.danger { color: var(--bad); }
.icon-btn.danger:hover { background: rgba(255, 93, 104, .15); }
label { display: block; color: var(--text2); font-size: 13px; font-weight: 600; margin: 0 0 14px; }
label > input:not([type=checkbox]):not([type=range]), label > select, label > .btn { display: flex; width: 100%; margin-top: 6px; }
input:not([type=checkbox]):not([type=range]):not([type=color]), select, textarea { background: var(--bg0); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type=color] { height: 40px; padding: 2px; background: var(--bg0); border: 1px solid var(--line); border-radius: 8px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; color: var(--text); }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.error { color: var(--bad); }

/* ---------- login ---------- */
.center-card { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, rgba(108, 123, 255, .18), transparent 60%), var(--bg0); }
.center-card.login form { width: min(360px, 90vw); text-align: left; margin-top: 18px; }
.center-card h1 { margin: 10px 0 4px; font-size: 28px; }
.logo { width: 68px; height: 68px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 12px 40px rgba(108, 123, 255, .4); }
.login .btn { width: 100%; margin-top: 6px; }
.login-app { width: min(360px, 90vw); margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.login-app .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr 240px; height: 100vh; }
body.members-hidden .shell { grid-template-columns: 260px 1fr 0; }
body.members-hidden .members { display: none; }
.side { background: var(--bg1); display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.server-head { height: 52px; display: flex; align-items: center; padding: 0 10px 0 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.server-name { flex: 1; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channels { flex: 1; overflow-y: auto; padding: 8px; }
.section { display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 6px; color: var(--text3); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.ch { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; color: var(--text3); cursor: pointer; user-select: none; position: relative; }
.ch:hover { background: var(--bg3); color: var(--text2); }
.ch.active { background: var(--bg4); color: var(--text); }
.ch.unread { color: var(--text); font-weight: 600; }
.ch.unread::before { content: ""; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text); }
.ch.connected { color: var(--good); }
.ch.muted:not(.active) { opacity: .5; }
.ch-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-edit { opacity: 0; }
.ch:hover .ch-edit { opacity: 1; }
.badge { background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.vc-people { padding: 2px 0 4px 26px; }
.vc-person { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 6px; color: var(--text2); font-size: 14px; cursor: pointer; }
.vc-person:hover { background: var(--bg3); }
.vc-person .vc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-person .st { color: var(--bad); }
.vc-person .st.srv { background: rgba(255, 93, 104, .18); border-radius: 4px; padding: 1px; }
.vc-person .avatar { transition: box-shadow .1s; }
.vc-person.speaking .avatar, .av-wrap.speaking .avatar { box-shadow: 0 0 0 2px var(--bg1), 0 0 0 4px var(--good); }
.live { background: var(--live); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .04em; padding: 1px 5px; border-radius: 4px; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; background: rgba(108, 123, 255, .18); color: var(--accent2); padding: 1px 5px; border-radius: 4px; margin-left: 6px; }

.avatar { display: inline-grid; place-items: center; border-radius: 50%; background: var(--c); color: #0e0f13; font-weight: 800; flex-shrink: 0; letter-spacing: -.02em; }
.av-wrap { position: relative; display: inline-flex; border-radius: 50%; }
.av-wrap .dot { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--good); border: 3px solid var(--bg1); }
.member.offline .dot { background: var(--text3); }
.av-wrap .dot.off, .dot.off { background: var(--text3); }
.dot.idle { background: var(--warn); }
.dot.dnd { background: var(--bad); }
img.avatar { object-fit: cover; background: var(--bg3); }
.ch.dm { padding: 5px 8px; }
.ch.dm .av-wrap .dot { width: 10px; height: 10px; border-width: 2px; }
.ch.dm:hover .av-wrap .dot { border-color: var(--bg3); }
.ch.dm.active .av-wrap .dot { border-color: var(--bg4); }
.dm-group { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--bg4); color: var(--text2); flex-shrink: 0; }
.dm-call { color: var(--good); }
.dm-empty { padding: 4px 8px 8px; color: var(--text3); }
.dm-pick { max-height: 300px; overflow-y: auto; margin: 10px 0 0; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.dm-person { margin: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.dm-person:hover { background: var(--bg3); }
.dm-person[hidden] { display: none; }
.dm-person span:not(.avatar) { flex: 1; }
#dmFilter { width: 100%; margin-top: 12px; }
.ring { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 65; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg3); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); animation: ringIn .2s; max-width: calc(100vw - 24px); }
@keyframes ringIn { from { opacity: 0; transform: translate(-50%, -8px); } }
.ring .avatar { animation: ringPulse 1.4s infinite; }
.ring-text { display: flex; flex-direction: column; min-width: 0; margin-right: 6px; }
@keyframes ringPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(63, 210, 139, .6); } 50% { box-shadow: 0 0 0 8px rgba(63, 210, 139, 0); } }

.voice-bar { display: none; border-top: 1px solid var(--line); padding: 10px 10px 8px; background: var(--bg1); }
.voice-bar.show { display: block; }
.vb-info { cursor: pointer; padding: 0 4px 8px; display: flex; flex-direction: column; }
.vb-info b { font-size: 13.5px; }
.vb-info .good { color: var(--good); } .vb-info .warn { color: var(--warn); } .vb-info .bad { color: var(--bad); }
.vb-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vb-actions .icon-btn { width: 100%; background: var(--bg3); }
.vb-actions .icon-btn:hover { background: var(--bg4); }
.vb-actions .icon-btn.danger { background: rgba(255, 93, 104, .12); }
.me-panel { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--bg0); border-top: 1px solid var(--line); }
.me-panel .dot { border-color: var(--bg0); }
.me-status { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 2px 4px 2px 2px; margin: -2px 0 -2px -2px; border-radius: 8px; text-align: left; }
.me-status:hover { background: var(--bg3); }
.me-status:hover .dot { border-color: var(--bg3); }
.me-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* ---------- main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg2); }
/* browser-like tabs */
.tabbar { display: flex; gap: 2px; padding: 6px 8px 0; background: var(--bg1); border-bottom: 1px solid var(--line); overflow-x: auto; flex-shrink: 0; scrollbar-width: none; }
.tabbar.empty { display: none; }
.tab { display: flex; align-items: center; gap: 6px; padding: 6px 8px 7px 10px; border-radius: 8px 8px 0 0; color: var(--text2); cursor: pointer; max-width: 200px; min-width: 0; flex-shrink: 0; position: relative; user-select: none; font-size: 13.5px; }
.tab:hover { background: var(--bg3); color: var(--text); }
.tab.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 0 var(--bg2); }
.tab.unread .tab-name { font-weight: 700; color: var(--text); }
.tab.pinned { padding-right: 10px; }
.tab.pinned .tab-name { max-width: 90px; }
.tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-x { border: 0; background: transparent; color: var(--text3); width: 18px; height: 18px; display: grid; place-items: center; border-radius: 4px; opacity: 0; }
.tab:hover .tab-x, .tab.active .tab-x { opacity: 1; }
.tab-x:hover { background: var(--bg4); color: var(--text); }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text); flex-shrink: 0; }
.tab .badge { font-size: 10px; padding: 0 5px; }
.main-head { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--line); color: var(--text3); }
.main-head h2 { margin: 0; font-size: 16px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-sub { color: var(--text3); font-size: 13px; }
.main-body { flex: 1; display: flex; min-height: 0; }
.stage { display: none; }
.main-body.is-voice .stage { display: flex; flex: 1; min-width: 0; flex-direction: column; background: var(--bg0); }
.main-body.is-voice .chat { width: 360px; flex: none; border-left: 1px solid var(--line); }
.main-body.is-voice.chat-closed .chat { display: none; }
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.jump-new { position: absolute; left: 50%; bottom: 86px; transform: translate(-50%, 8px); z-index: 15; display: flex; align-items: center; gap: 6px; padding: 7px 14px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; }
.jump-new.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }

.messages { flex: 1; overflow-y: auto; padding: 0 0 12px; overflow-anchor: none; }
.channel-start { padding: 40px 20px 12px; }
.channel-start h1 { margin: 12px 0 2px; font-size: 26px; }
.big-hash { width: 68px; height: 68px; border-radius: 50%; background: var(--bg4); display: grid; place-items: center; color: var(--text); }
.history-more, .loading { text-align: center; padding: 20px; color: var(--text3); }
.day { display: flex; align-items: center; margin: 18px 16px 4px; color: var(--text3); font-size: 12px; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.day span { padding: 0 10px; }
.new-line { display: flex; align-items: center; margin: 14px 16px 0; color: var(--bad); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.new-line::before { content: ""; flex: 1; border-top: 1px solid var(--bad); }
.new-line span { padding-left: 8px; }
.new-line + .msg { margin-top: 4px; }
.msg { position: relative; padding: 2px 16px; margin-top: 14px; }
.msg.grouped { margin-top: 0; }
.msg:hover { background: rgba(255, 255, 255, .025); }
.msg.ping { background: var(--mention); box-shadow: inset 3px 0 var(--warn); }
.msg.flash { animation: flash 1.4s; }
@keyframes flash { 0%, 40% { background: rgba(108, 123, 255, .2); } }
.msg-row { display: flex; gap: 14px; }
.gutter { width: 40px; flex-shrink: 0; display: flex; justify-content: center; }
.hover-time { visibility: hidden; font-size: 11px; color: var(--text3); padding-top: 4px; }
.msg:hover .hover-time { visibility: visible; }
.msg-main { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 700; }
.msg-head time { font-size: 12px; color: var(--text3); }
.text { white-space: normal; word-wrap: break-word; overflow-wrap: anywhere; }
.text.collapsed { max-height: 22em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.show-more { border: 0; background: none; color: var(--accent2); font-weight: 600; padding: 2px 0; font-size: 13px; }
.show-more:hover { text-decoration: underline; }
.text.jumbo { font-size: 42px; line-height: 1.2; }
.text code { background: var(--bg0); padding: 1px 5px; border-radius: 4px; font: 13.5px Consolas, "Cascadia Code", monospace; }
.codeblock { background: var(--bg0); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 6px 0; font: 13.5px/1.5 Consolas, "Cascadia Code", monospace; }
.text .quote { display: block; border-left: 4px solid var(--bg4); padding-left: 10px; color: var(--text2); }
.spoiler { background: var(--bg4); color: transparent; border-radius: 4px; cursor: pointer; transition: color .1s; }
.spoiler.shown { color: inherit; background: rgba(255, 255, 255, .06); }
.mention { background: rgba(108, 123, 255, .22); color: var(--accent2); padding: 0 3px; border-radius: 4px; font-weight: 600; }
.edited { font-size: 11px; color: var(--text3); }
.reply-ref { display: flex; align-items: center; gap: 6px; margin: 0 0 2px 54px; font-size: 13px; color: var(--text3); cursor: pointer; white-space: nowrap; overflow: hidden; }
.reply-ref span { overflow: hidden; text-overflow: ellipsis; }
.reply-ref:hover span { color: var(--text); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-img img { max-width: min(420px, 100%); max-height: 340px; border-radius: 8px; display: block; cursor: zoom-in; }
.att-video { max-width: min(520px, 100%); max-height: 360px; border-radius: 8px; background: #000; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); background: var(--bg1); border-radius: 8px; color: var(--text); text-decoration: none; max-width: 420px; }
.att-file span { display: flex; flex-direction: column; min-width: 0; }
.att-file b { color: var(--accent2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; border: 1px solid transparent; background: var(--bg3); border-radius: 8px; padding: 1px 8px; font-size: 14px; }
.reaction b { font-size: 12.5px; color: var(--text2); }
.reaction.mine { border-color: var(--accent); background: rgba(108, 123, 255, .15); }
.reaction:hover { border-color: var(--bg4); }
.msg-tools { position: absolute; right: 16px; top: -14px; display: none; background: var(--bg1); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: 0 4px 16px rgba(0, 0, 0, .35); z-index: 2; }
.msg:hover .msg-tools { display: flex; }
.msg-tools button { border: 0; background: transparent; width: 30px; height: 28px; border-radius: 6px; color: var(--text2); display: grid; place-items: center; font-size: 15px; }
.msg-tools button:hover { background: var(--bg4); color: var(--text); }
.msg-tools button.danger:hover { color: var(--bad); }
.edit-box textarea { width: 100%; resize: none; min-height: 42px; }

.composer-wrap { padding: 0 16px 6px; flex-shrink: 0; position: relative; }
.ac-pop { display: none; position: absolute; left: 16px; right: 16px; bottom: calc(100% - 2px); z-index: 20; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 -8px 30px rgba(0, 0, 0, .35); max-width: 420px; }
.ac-pop.show { display: block; }
.ac-pop button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; text-align: left; }
.ac-pop button.active, .ac-pop button:hover { background: var(--bg4); }
.ac-pop button .muted { margin-left: auto; }
.ac-all { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--warn); color: #1a1300; font-weight: 800; font-size: 13px; }
.composer { display: flex; align-items: flex-end; gap: 4px; background: var(--bg3); border-radius: var(--radius); padding: 5px 6px; }
.composer textarea { flex: 1; resize: none; background: transparent; border: 0; padding: 7px 4px; max-height: 300px; line-height: 1.4; }
.typing { height: 22px; font-size: 12.5px; color: var(--text2); padding: 3px 4px 0; display: flex; align-items: center; gap: 6px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text2); animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.reply-bar { display: none; justify-content: space-between; align-items: center; background: var(--bg1); padding: 6px 10px; border-radius: var(--radius) var(--radius) 0 0; font-size: 13px; color: var(--text2); }
.reply-bar.show { display: flex; }
.pending { display: flex; gap: 8px; flex-wrap: wrap; }
.pending:not(:empty) { padding: 8px 0; }
.pend { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--bg1); border: 1px solid var(--line); border-radius: 8px; max-width: 280px; }
.pend img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.pend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; min-width: 60px; }
.pend-status { display: block; color: var(--text2); font-size: 11.5px; }
.pend:has(.pend-status) { max-width: 360px; }
.pend .bar { width: 60px; height: 4px; border-radius: 4px; background: var(--bg4); overflow: hidden; }
.pend .bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.pend.done .bar i { background: var(--good); }

/* ---------- members ---------- */
.members { background: var(--bg1); border-left: 1px solid var(--line); overflow-y: auto; padding: 4px 8px; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.member:hover { background: var(--bg3); }
.member.offline { opacity: .45; }
.m-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.m-status { font-size: 12px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-voice { color: var(--good); }

/* ---------- stage ---------- */
.stage-empty { margin: auto; text-align: center; padding: 24px; }
.stage-empty h2 { margin: 18px 0 6px; }
.stage-empty .btn { margin-top: 16px; }
.faces { display: flex; justify-content: center; }
.faces .avatar { margin: 0 -6px; border: 4px solid var(--bg0); }
.faces .big-hash { width: 96px; height: 96px; }
.stage-grid { flex: 1; display: grid; gap: 10px; padding: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-content: center; overflow-y: auto; }
.stage-grid.n1 { grid-template-columns: 1fr; }
.stage-grid.n2 { grid-template-columns: repeat(2, 1fr); }
.stage-focus { flex: 1; min-height: 0; padding: 12px 12px 0; display: flex; }
.stage-focus .tile { flex: 1; aspect-ratio: auto; }
.stage-strip { display: flex; gap: 10px; padding: 10px 12px 12px; overflow-x: auto; flex-shrink: 0; }
.stage-strip .tile { width: 200px; flex-shrink: 0; }
.tile { position: relative; aspect-ratio: 16 / 9; background: var(--bg2); border-radius: 12px; overflow: hidden; display: grid; place-items: center; cursor: pointer; outline: 2px solid transparent; outline-offset: -2px; transition: outline-color .1s; }
.tile.speaking { outline-color: var(--good); }
.tile.screen { background: #000; }
.tile-avatar { display: grid; place-items: center; width: 100%; height: 100%; background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%); }
.stage-strip .tile-avatar .avatar { width: 48px !important; height: 48px !important; font-size: 18px !important; }
.vslot { position: absolute; inset: 0; }
.vslot video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
.vslot video.local:not(.screenvid) { }
.tile:not(.screen) .vslot video { object-fit: cover; }
.tile-label { position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); padding: 3px 8px; border-radius: 6px; font-size: 13px; font-weight: 600; max-width: calc(100% - 16px); }
.tile-tools { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.tile.screen .tile-tools { right: 48px; }
/* always visible (also on touch screens without hover) */
.tile-close { position: absolute; right: 8px; top: 8px; z-index: 2; width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(0, 0, 0, .6); color: #fff; backdrop-filter: blur(6px); }
.tile-close:hover { background: var(--bad); }
.stage-hidden { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 12px 0; }
.hidden-chip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); padding: 7px 12px; border-radius: 20px; font-weight: 600; }
.hidden-chip:hover { background: var(--bg3); border-color: var(--accent); }
.tile:hover .tile-tools { opacity: 1; }
.tile-tools .icon-btn { background: rgba(0, 0, 0, .6); color: #fff; width: 30px; height: 30px; }
.tile:fullscreen { border-radius: 0; }
.tile:fullscreen .vslot video { object-fit: contain; }

/* ---------- popovers & modals ---------- */
.pop { position: fixed; z-index: 50; background: var(--bg1); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); padding: 8px; max-width: 340px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 36px); max-height: 280px; overflow-y: auto; }
.emoji-grid button { border: 0; background: transparent; font-size: 22px; height: 36px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--bg4); }
.menu { display: flex; flex-direction: column; min-width: 220px; }
/* right-click menu */
.pop.ctx { padding: 5px; min-width: 210px; display: flex; flex-direction: column; animation: fade .08s; }
.ctx button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; padding: 7px 10px; border-radius: 6px; font-size: 14px; color: var(--text); }
.ctx button:hover { background: var(--accent); color: #fff; }
.ctx button.danger { color: var(--bad); }
.ctx button.danger:hover { background: var(--bad); color: #fff; }
.ctx .ctx-noicon { width: 15px; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-title { font-size: 12px; color: var(--text3); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 6px 10px; }
.share-menu { min-width: 280px; gap: 6px; }
.share-menu .share-big { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; background: var(--bg3); border: 1px solid var(--line); text-align: left; }
.share-menu .share-big:hover { background: var(--accent); color: #fff; border-color: transparent; }
.share-menu .share-big span { display: flex; flex-direction: column; }
.share-menu .share-big b { font-size: 15px; }
.share-menu .share-big small { color: var(--text2); font-size: 12.5px; }
.share-menu .share-big:hover small { color: rgba(255, 255, 255, .85); }
.share-menu .share-small { font-size: 13px; color: var(--text2); padding: 6px 10px; }
.share-q { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 0; padding: 8px 10px 2px; border-top: 1px solid var(--line); font-weight: 500; }
.share-q select { padding: 4px 8px; }
.share-audio { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; font-weight: 600; cursor: pointer; }
.share-audio span { display: inline-flex; align-items: center; gap: 8px; }
.share-audio input { width: 18px; height: 18px; accent-color: var(--accent); }
.helper-status .muted { margin-top: 4px; }
.helper-status { font-size: 12.5px; color: var(--text2); padding: 2px 10px 8px; line-height: 1.45; max-width: 300px; }
.helper-status .ok { color: var(--good); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.helper-status .btn, .modal .small-btn { margin-top: 6px; padding: 6px 10px; font-size: 13px; text-decoration: none; color: var(--text); }
.fix-steps { background: var(--bg1); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.fix-steps ol { margin: 8px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.fix-steps code, .fix-alt code { background: var(--bg0); padding: 1px 5px; border-radius: 4px; }
.fix-alt { margin: 8px 0; font-size: 13.5px; }
.fix-alt summary { cursor: pointer; color: var(--text2); }
.fix-alt[open] { background: var(--bg1); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.fix-alt ol { margin: 8px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.app-offer { background: var(--bg1); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.app-offer > b { display: inline-flex; align-items: center; gap: 6px; }
.app-offer .btn { text-decoration: none; color: var(--text); padding: 6px 10px; font-size: 13px; }
.share-warn { color: var(--warn); font-size: 13px; padding: 2px 10px 6px; }
.share-coach { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 90; max-width: calc(100vw - 32px); background: var(--warn); color: #1a1300; font-size: 16px; padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); text-align: center; animation: up .2s; }
body.lydtest { overflow: auto; }
.pip-source { position: fixed; left: -10px; top: -10px; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
/* pop-out stream window */
body.popout { background: #000; }
body.popout video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.po-bar { position: fixed; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: linear-gradient(rgba(0, 0, 0, .7), transparent); transition: opacity .3s; }
.po-title { font-weight: 700; }
body.popout.idle .po-bar { opacity: 0; }
body.popout.idle { cursor: none; }
.po-gone { position: fixed; inset: 0; display: grid; place-items: center; color: var(--text2); font-size: 18px; }
.lt { max-width: 640px; margin: 0 auto; padding: 32px 16px; }
.lt ol { padding-left: 20px; display: flex; flex-direction: column; gap: 14px; }
.lt li span { display: block; margin-top: 6px; }
.menu-hint { font-size: 12.5px; color: var(--text2); padding: 8px 10px 4px; margin-top: 4px; border-top: 1px solid var(--line); max-width: 260px; line-height: 1.4; }
.no-sound { display: inline-flex; align-items: center; gap: 3px; color: var(--warn); font-size: 12px; font-weight: 600; margin-left: 4px; }
.viewers { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 0 6px; border-radius: 10px; background: rgba(255, 255, 255, .12); font-size: 12px; font-weight: 600; cursor: help; }
.menu button { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.active { color: var(--accent2); font-weight: 700; }
.menu button.active:hover { color: #fff; }
.user-card { width: 260px; padding: 4px; }
.uc-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.user-card .btn { width: 100%; }
.uc-route { margin: -4px 0 12px; line-height: 1.6; }
.uc-route:empty { display: none; }
.q.good { color: var(--good); } .q.warn { color: var(--warn); } .q.bad { color: var(--bad); }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 40; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(440px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); position: relative; }
.modal.wide { width: min(640px, 100%); }
.modal h2 { margin: 0 0 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.invite-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 12px; background: var(--bg1); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.invite-row code { background: var(--bg0); padding: 8px 10px; border-radius: 6px; word-break: break-all; font-size: 13px; }
.invite-row .btn { justify-self: start; }
.invite-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.search-bar { display: flex; gap: 8px; }
.search-bar input { flex: 1; min-width: 0; }
.search-results { margin-top: 12px; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.search-hit { display: flex; gap: 10px; align-items: flex-start; text-align: left; border: 0; background: transparent; padding: 8px; border-radius: 8px; width: 100%; }
.search-hit:hover { background: var(--bg3); }
.sh-main { display: flex; flex-direction: column; min-width: 0; }
.sh-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sh-text { color: var(--text); overflow-wrap: anywhere; }
.sh-text mark { background: rgba(242, 184, 75, .3); color: inherit; border-radius: 3px; padding: 0 1px; }
.modal.search-modal { align-self: start; margin-top: 8vh; }
.modal.settings-modal { width: min(760px, 100%); padding: 0; height: min(600px, 90vh); }
.settings { display: grid; grid-template-columns: 190px 1fr; height: 100%; }
.settings nav { background: var(--bg1); padding: 16px 8px; display: flex; flex-direction: column; gap: 2px; border-radius: 14px 0 0 14px; }
.settings nav button { border: 0; background: transparent; text-align: left; padding: 8px 12px; border-radius: 6px; color: var(--text2); font-weight: 600; }
.settings nav button:hover { background: var(--bg3); color: var(--text); }
.settings nav button.active { background: var(--bg4); color: var(--text); }
.settings-body { padding: 22px 26px; overflow-y: auto; }
.settings .close { position: absolute; right: 12px; top: 12px; }
.meter { position: relative; height: 10px; background: var(--bg0); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.meter i { display: block; height: 100%; width: 0; background: var(--good); transition: width .06s; }
.meter i.gated { background: var(--text3); }
.meter b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--warn); margin-left: -1px; }
.modal.lightbox { width: auto; max-width: 95vw; background: transparent; border: 0; box-shadow: none; text-align: center; padding: 0; }
.lightbox-img { max-width: 84vw; max-height: 82vh; border-radius: 8px; display: block; margin: 0 auto 10px; }
.lb-wrap { display: flex; align-items: center; gap: 10px; }
.lb-prev, .lb-next { width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; flex-shrink: 0; }
.lb-next .ic { transform: scaleX(-1); }
.lb-bar { display: flex; gap: 12px; align-items: center; justify-content: center; }
.att-grid { display: grid; gap: 4px; max-width: min(420px, 100%); border-radius: 8px; overflow: hidden; }
.att-grid.n2, .att-grid.n4 { grid-template-columns: 1fr 1fr; }
.att-grid.n3 { grid-template-columns: 1fr 1fr; }
.att-grid.n3 .att-img:first-child { grid-column: span 2; }
.att-grid .att-img img { width: 100%; height: 100%; max-width: none; max-height: 220px; object-fit: cover; border-radius: 0; aspect-ratio: 4 / 3; }
.att-grid.n3 .att-img:first-child img { aspect-ratio: 16 / 9; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; pointer-events: none; }
.toast { background: var(--bg4); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: up .18s; transition: opacity .4s, transform .4s; max-width: 90vw; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }
.conn-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--warn); color: #1a1300; text-align: center; font-weight: 700; font-size: 13px; padding: 5px; transform: translateY(-100%); transition: transform .2s; z-index: 70; }
.conn-banner.show { transform: none; }
.drop-hint { position: fixed; inset: 16px; border: 3px dashed var(--accent); border-radius: 18px; background: rgba(108, 123, 255, .12); display: grid; place-items: center; font-size: 22px; font-weight: 700; z-index: 80; pointer-events: none; opacity: 0; transition: opacity .12s; }
.drop-hint.show { opacity: 1; }

/* ---------- narrow screens ---------- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: 240px 1fr 0; }
  .members { display: none; }
  /* on narrow screens the class means "drawer open" */
  body.members-hidden .members { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: min(280px, 85vw); z-index: 35; box-shadow: -12px 0 40px rgba(0, 0, 0, .4); }
  body.members-hidden .nav-back { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 34; }
  .main-body.is-voice .chat { width: 300px; }
}
.nav-btn, .nav-back { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; height: 100dvh; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 35; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .side { transform: none; }
  .nav-btn { display: inline-grid; margin-left: -8px; }
  body.nav-open .nav-back { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 34; }
  .main-head { padding-left: 12px; gap: 6px; }
  .msg-tools { right: 8px; }
  .composer textarea { font-size: 16px; } /* stops iOS zooming in */
  .main-body.is-voice { flex-direction: column; }
  .main-body.is-voice .chat { width: auto; height: 45%; border-left: 0; border-top: 1px solid var(--line); }
  .settings { grid-template-columns: 1fr; }
  .settings nav { flex-direction: row; overflow-x: auto; border-radius: 14px 14px 0 0; }
  /* installed on a phone: keep clear of the notch and the home bar */
  .main-head, .server-head { padding-top: env(safe-area-inset-top); height: calc(52px + env(safe-area-inset-top)); }
  .composer-wrap { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .me-panel { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* ---------- link previews ---------- */
.embeds { position: relative; width: fit-content; max-width: 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; align-items: flex-start; }
.embed { max-width: 460px; background: var(--bg2); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.embed-site { font-size: 12px; color: var(--text3); }
.embed-title { font-weight: 700; color: var(--accent2); text-decoration: none; overflow-wrap: anywhere; }
.embed-title:hover { text-decoration: underline; }
.embed-desc { font-size: 13.5px; color: var(--text2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.embed-img { margin-top: 6px; display: block; }
.embed-img img { max-width: 100%; max-height: 260px; border-radius: 6px; display: block; }
.embeds-x { position: absolute; top: 2px; right: -28px; opacity: 0; }
.msg:hover .embeds-x { opacity: 1; }

/* ---------- status & profile picture ---------- */
.status-menu { width: 280px; }
.status-menu button { display: flex; gap: 10px; align-items: center; }
.status-menu button > span { display: flex; flex-direction: column; }
.status-menu button:hover .muted { color: rgba(255, 255, 255, .8); }
.status-menu .dot { position: static; display: block; width: 10px; height: 10px; border-radius: 50%; border: 0; background: var(--good); flex-shrink: 0; }
.status-menu .dot.idle { background: var(--warn); } .status-menu .dot.dnd { background: var(--bad); } .status-menu .dot.off { background: var(--text3); }
#statusText { display: flex; gap: 4px; align-items: center; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
#statusText input { flex: 1; min-width: 0; padding: 8px 10px; }
.uc-status { font-size: 13px; color: var(--text); margin: 2px 0; overflow-wrap: anywhere; }
.avatar-edit { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.avatar-edit .btn { margin-right: 6px; }
.avatar-edit p { margin: 8px 0 0; }

/* ---------- moderation ---------- */
.tag.mod { background: rgba(63, 210, 139, .16); color: var(--good); }
.tag.timeout { background: rgba(242, 184, 75, .16); color: var(--warn); }
.uc-mod { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.uc-mod .menu-title { padding: 4px 0 0; }
.uc-row { display: flex; gap: 8px; }
.uc-row > * { flex: 1; }
.uc-row select { padding: 8px; }
.ban-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }

/* ---------- threads & pins ---------- */
.ch.thread { margin-left: 18px; padding: 4px 8px; font-size: 14px; }
.thread-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px 10px; border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; color: var(--text); max-width: 100%; }
.thread-link:hover { background: var(--bg3); }
.thread-link b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-start { text-align: left; }
.thread-start .msg.preview { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg1); }
.pin-ref { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--warn); padding: 0 0 2px 56px; }
.msg.pinned { box-shadow: inset 2px 0 0 var(--warn); }
.pins-pop { width: min(420px, 90vw); max-height: 60vh; overflow-y: auto; }
.pin-hit { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; }
.pin-hit:hover { background: var(--bg3); }

/* ---------- clips ---------- */
.tile-tools:has(.clip-on) { opacity: 1; }
.icon-btn.clip-on { color: #fff; background: var(--live); animation: clipPulse 2s infinite; }
@keyframes clipPulse { 50% { box-shadow: 0 0 0 3px rgba(255, 59, 92, .35); } }
.clip-preview { width: 100%; max-height: 60vh; background: #000; border-radius: 8px; display: block; }

/* ---------- emoji picker ---------- */
.emoji-pick { width: min(340px, 86vw); display: flex; flex-direction: column; gap: 6px; }
.emoji-search { width: 100%; padding: 8px 10px !important; }
.emoji-body { max-height: 300px; overflow-y: auto; }
.emoji-body .emoji-grid { max-height: none; overflow: visible; }
.emoji-sec { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; padding: 8px 4px 4px; }
.ac-emoji { font-size: 20px; width: 22px; text-align: center; }

/* ---------- QR ---------- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.qr-box:not(:empty) { margin: 14px 0 4px; }
.qr { border-radius: 10px; background: #fff; max-width: 70vw; height: auto; }

/* ---------- markdown blocks ---------- */
.md-h { display: block; font-weight: 800; line-height: 1.25; margin: 6px 0 2px; color: var(--text); }
.md-h1 { font-size: 1.45em; } .md-h2 { font-size: 1.25em; } .md-h3 { font-size: 1.08em; }
.md-list { margin: 2px 0; padding-left: 22px; }
.md-list li { margin: 1px 0; }

/* ---------- channel settings ---------- */
.ch-move { display: flex; gap: 8px; align-items: center; margin: -4px 0 6px; }
.ch-move .muted { margin-right: auto; }
.ch-move [data-move="-1"] .ic { transform: rotate(180deg); }
.topic { display: block; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 1px solid var(--line); padding-left: 10px; }

/* ---------- polls ---------- */
.poll { max-width: 460px; margin-top: 6px; padding: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; }
.poll-q { font-weight: 700; display: flex; gap: 8px; align-items: center; margin-bottom: 2px; overflow-wrap: anywhere; }
.poll-opt { position: relative; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg1); text-align: left; overflow: hidden; }
.poll-opt i { position: absolute; inset: 0 auto 0 0; background: rgba(108, 123, 255, .18); transition: width .25s; }
.poll-opt.lead i { background: rgba(108, 123, 255, .3); }
.poll-opt span, .poll-opt b { position: relative; }
.poll-opt span { overflow-wrap: anywhere; }
.poll-opt b { font-size: 12.5px; color: var(--text2); white-space: nowrap; }
.poll-opt.mine { border-color: var(--accent); }
.poll-opt:hover { border-color: var(--accent2); }
#pollOpts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
#pollForm .check { margin-top: 12px; }
