:root {
  --bg-1: #1e1f22; --bg-2: #2b2d31; --bg-3: #313338; --bg-4: #383a40; --bg-float: #111214;
  --bg-mod: rgba(78, 80, 88, .3); --bg-mod-hover: rgba(78, 80, 88, .48); --bg-mod-sel: rgba(78, 80, 88, .6);
  --input: #1e1f22; --text: #dbdee1; --text-hi: #f2f3f5; --muted: #949ba4; --faint: #6d6f78;
  --brand: #6d5dfc; --brand-hover: #5a4be0; --green: #23a55a; --red: #f23f43; --yellow: #f0b232;
  --link: #00a8fc; --mention-bg: rgba(240, 178, 50, .1); --mention-bar: #f0b232; --divider: #3f4147;
  --scroll: #1a1b1e; --shadow: 0 8px 16px rgba(0,0,0,.24); --code: #2b2d31;
  --radius: 8px; --font: "gg sans", "Noto Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}
html[data-theme="midnight"] { --bg-1: #000; --bg-2: #0b0b0d; --bg-3: #111113; --bg-4: #1a1a1e; --input: #1a1a1e; --code: #0b0b0d; --divider: #222; }
html[data-theme="light"] {
  --bg-1: #e3e5e8; --bg-2: #f2f3f5; --bg-3: #ffffff; --bg-4: #ebedef; --bg-float: #ffffff;
  --bg-mod: rgba(116,127,141,.16); --bg-mod-hover: rgba(116,127,141,.24); --bg-mod-sel: rgba(116,127,141,.32);
  --input: #ebedef; --text: #313338; --text-hi: #060607; --muted: #5c5e66; --faint: #80848e; --divider: #d7d9dc;
  --scroll: #c4c9ce; --code: #f2f3f5; --shadow: 0 8px 16px rgba(0,0,0,.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg-1); color: var(--text); font-family: var(--font);
  font-size: 15px; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
.hidden { display: none !important; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--text); background: var(--input);
  border: none; border-radius: 4px; padding: 10px; outline: none; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
input[type=color] { padding: 0; height: 40px; width: 64px; cursor: pointer; }
input[type=range] { padding: 0; accent-color: var(--brand); background: none; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
label.lbl { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; letter-spacing: .02em; }
.btn { background: var(--brand); color: #fff; border: none; border-radius: 4px; padding: 0 16px; height: 38px;
  font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--brand-hover); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #4e5058; } .btn.secondary:hover { background: #6d6f78; }
.btn.danger { background: var(--red); } .btn.danger:hover { background: #da373c; }
.btn.green { background: var(--green); } .btn.green:hover { background: #1a8b4b; }
.btn.link { background: none; color: var(--text); } .btn.link:hover { text-decoration: underline; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; border-radius: 4px; width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.icon-btn:hover { color: var(--text-hi); background: var(--bg-mod-hover); }
.icon-btn.on { color: var(--text-hi); }
.icon-btn.red { color: var(--red); }
svg.i { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---------- auth ---------- */
#auth { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #6d5dfc55, transparent 50%), radial-gradient(circle at 80% 80%, #23a55a44, transparent 50%), #1e1f22; }
#auth .card { background: var(--bg-3); padding: 32px; border-radius: 8px; width: 480px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
#auth h1 { margin: 0 0 8px; text-align: center; color: var(--text-hi); font-size: 24px; }
#auth p.sub { text-align: center; color: var(--muted); margin: 0 0 12px; }
#auth .err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }
#auth .btn { width: 100%; margin-top: 20px; height: 44px; font-size: 16px; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 16px; font-weight: 800; font-size: 26px; color: var(--text-hi); }

/* ---------- layout ---------- */
#app { display: flex; height: 100vh; }
#guilds { width: 72px; background: var(--bg-1); flex: none; overflow-y: auto; overflow-x: hidden; padding: 12px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; scrollbar-width: none; }
#guilds::-webkit-scrollbar { display: none; }
.g-item { position: relative; width: 72px; display: flex; justify-content: center; }
.g-pill { position: absolute; left: 0; top: 50%; width: 8px; height: 0; margin-left: -4px; background: var(--text-hi); border-radius: 0 4px 4px 0; transform: translateY(-50%); transition: height .15s; }
.g-item.unread .g-pill { height: 8px; } .g-item:hover .g-pill { height: 20px; } .g-item.active .g-pill { height: 40px; }
.g-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-3); color: var(--text); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-radius .15s, background .15s; overflow: hidden; font-weight: 600; font-size: 16px; user-select: none; }
.g-icon img { width: 100%; height: 100%; object-fit: cover; }
.g-item:hover .g-icon, .g-item.active .g-icon { border-radius: 16px; background: var(--brand); color: #fff; }
.g-item .g-icon.add { color: var(--green); } .g-item:hover .g-icon.add { background: var(--green); color: #fff; }
.g-sep { width: 32px; height: 2px; background: var(--bg-4); border-radius: 1px; flex: none; }
.badge { background: var(--red); color: #fff; font-size: 12px; font-weight: 700; border-radius: 9px; min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center; }
.g-item .badge { position: absolute; right: 10px; bottom: -2px; border: 3px solid var(--bg-1); height: 22px; min-width: 22px; border-radius: 11px; }

#sidebar { width: 240px; background: var(--bg-2); flex: none; display: flex; flex-direction: column; min-height: 0; }
#side-head { height: 48px; flex: none; display: flex; align-items: center; padding: 0 16px; font-weight: 600; color: var(--text-hi);
  box-shadow: 0 1px 0 rgba(4,4,5,.2), 0 1.5px 0 rgba(6,6,7,.05), 0 2px 0 rgba(4,4,5,.05); cursor: pointer; gap: 6px; position: relative; z-index: 2; }
#side-head:hover { background: var(--bg-mod); }
#side-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#side-head.has-banner { height: 138px; align-items: flex-start; padding-top: 14px; background-size: cover; background-position: center; text-shadow: 0 1px 3px #000; }
#side-head.search { cursor: default; padding: 0 10px; } #side-head.search:hover { background: none; }
.fake-search { width: 100%; height: 28px; background: var(--bg-1); color: var(--muted); border-radius: 4px; font-size: 14px; font-weight: 500; display: flex; align-items: center; padding: 0 8px; cursor: pointer; }
#side-list { flex: 1; overflow-y: auto; padding: 8px 8px 8px 8px; min-height: 0; }
.cat { display: flex; align-items: center; padding: 18px 8px 4px 2px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); cursor: pointer; letter-spacing: .02em; user-select: none; }
.cat:hover { color: var(--text-hi); } .cat .arrow { transition: transform .15s; width: 12px; height: 12px; margin-right: 2px; } .cat.collapsed .arrow { transform: rotate(-90deg); }
.cat .grow { flex: 1; } .cat .add { opacity: 0; } .cat:hover .add { opacity: 1; }
.ch { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; border-radius: 4px; color: var(--faint); cursor: pointer; margin: 1px 0; position: relative; user-select: none; }
.ch:hover { background: var(--bg-mod); color: var(--text); } .ch.active { background: var(--bg-mod-sel); color: var(--text-hi); }
.ch.unread { color: var(--text-hi); font-weight: 600; }
.ch.unread::before { content: ""; position: absolute; left: -8px; width: 8px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text-hi); }
.ch .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch .acts { display: none; } .ch:hover .acts, .ch.active .acts { display: flex; }
.ch .acts .icon-btn { width: 20px; height: 20px; } .ch .acts svg.i { width: 16px; height: 16px; }
.vc-users { padding-left: 30px; }
.vc-user { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 4px; color: var(--muted); font-size: 14px; cursor: pointer; }
.vc-user:hover { background: var(--bg-mod); color: var(--text); }
.vc-user .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-user .ic { display: flex; gap: 2px; } .vc-user svg.i { width: 16px; height: 16px; }
.live { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; border-radius: 4px; padding: 1px 4px; letter-spacing: .02em; }
.dm-item { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 8px; border-radius: 4px; cursor: pointer; color: var(--muted); margin: 1px 0; }
.dm-item:hover { background: var(--bg-mod); color: var(--text); } .dm-item.active { background: var(--bg-mod-sel); color: var(--text-hi); }
.dm-item.unread { color: var(--text-hi); font-weight: 600; }
.dm-item .nm { flex: 1; min-width: 0; } .dm-item .nm div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-item .nm .st { font-size: 12px; color: var(--muted); font-weight: 400; }
.dm-item .x { opacity: 0; } .dm-item:hover .x { opacity: 1; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 18px 8px 4px 10px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }

/* voice + user panel */
#voice-panel { background: var(--bg-2); border-bottom: 1px solid var(--divider); padding: 8px; flex: none; }
html:not([data-theme="light"]) #voice-panel { background: #232428; }
html[data-theme="midnight"] #voice-panel, html[data-theme="midnight"] #user-panel { background: #000; }
#voice-panel .row { display: flex; align-items: center; gap: 4px; }
#voice-panel .conn { flex: 1; min-width: 0; }
#voice-panel .conn .t { color: var(--green); font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 4px; }
#voice-panel .conn .t.bad { color: var(--yellow); }
#voice-panel .conn .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
#voice-panel .conn .s:hover { text-decoration: underline; }
#voice-panel .btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
#voice-panel .btns button { height: 32px; border-radius: 4px; background: var(--bg-mod); border: none; color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; }
#voice-panel .btns button:hover { background: var(--bg-mod-hover); } #voice-panel .btns button.on { color: var(--green); }
#user-panel { height: 52px; flex: none; display: flex; align-items: center; padding: 0 8px; gap: 4px; }
html:not([data-theme="light"]) #user-panel { background: #232428; }
#user-panel .me { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px; border-radius: 4px; cursor: pointer; }
#user-panel .me:hover { background: var(--bg-mod-hover); }
#user-panel .me .nm { min-width: 0; font-size: 14px; line-height: 18px; }
#user-panel .me .nm div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#user-panel .me .nm .s { color: var(--muted); font-size: 12px; line-height: 13px; }

/* avatars */
.av { position: relative; flex: none; border-radius: 50%; }
.av img.a { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.av .fallback { width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; }
.av .fallback svg { width: 62%; height: 62%; fill: #fff; }
.av .dot { position: absolute; right: -2px; bottom: -2px; width: 40%; height: 40%; border-radius: 50%; border: 3px solid var(--bg-2); box-sizing: content-box; max-width: 12px; max-height: 12px; min-width: 8px; min-height: 8px; }
.dot.online { background: var(--green); } .dot.idle { background: var(--yellow); } .dot.dnd { background: var(--red); } .dot.offline { background: #80848e; }
.dot.idle::after { content: ""; position: absolute; width: 60%; height: 60%; background: var(--bg-2); border-radius: 50%; top: -5%; left: -5%; }
.dot.dnd::after { content: ""; position: absolute; width: 64%; height: 22%; background: var(--bg-2); border-radius: 2px; top: 39%; left: 18%; }
.dot.offline::after { content: ""; position: absolute; width: 50%; height: 50%; background: var(--bg-2); border-radius: 50%; top: 25%; left: 25%; }
.av.speaking img.a, .av.speaking .fallback { box-shadow: 0 0 0 2px var(--green), 0 0 0 3px var(--bg-2); }

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; background: var(--bg-3); min-width: 0; }
#head { height: 48px; flex: none; display: flex; align-items: center; padding: 0 8px 0 16px; gap: 8px; box-shadow: 0 1px 0 rgba(4,4,5,.2), 0 1.5px 0 rgba(6,6,7,.05), 0 2px 0 rgba(4,4,5,.05); z-index: 2; }
#head .title { font-weight: 600; color: var(--text-hi); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#head .topic { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; border-left: 1px solid var(--divider); padding-left: 12px; margin-left: 4px; cursor: pointer; }
#head .grow { flex: 1; }
#head .search { width: 160px; height: 26px; padding: 0 8px; font-size: 13px; transition: width .2s; background: var(--bg-1); }
#head .search:focus { width: 240px; }
#head .tabs { display: flex; gap: 8px; margin-left: 8px; }
#head .tab { padding: 2px 8px; border-radius: 4px; cursor: pointer; color: var(--muted); font-weight: 500; }
#head .tab:hover { background: var(--bg-mod); color: var(--text); } #head .tab.active { background: var(--bg-mod-sel); color: var(--text-hi); }
#head .tab.add { background: var(--green); color: #fff; } #head .tab.add.active { background: none; color: var(--green); }
#body { flex: 1; display: flex; min-height: 0; }
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#members { width: 240px; background: var(--bg-2); flex: none; overflow-y: auto; padding: 0 8px 20px; }
#members h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 24px 8px 4px; font-weight: 700; letter-spacing: .02em; }
.member { display: flex; align-items: center; gap: 12px; padding: 4px 8px; height: 44px; border-radius: 4px; cursor: pointer; }
.member:hover { background: var(--bg-mod); }
.member.offline { opacity: .3; } .member.offline:hover { opacity: 1; }
.member .nm { min-width: 0; flex: 1; } .member .nm div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.member .nm .s { font-size: 12px; color: var(--muted); font-weight: 400; }
.crown { color: var(--yellow); width: 14px; height: 14px; vertical-align: -2px; margin-left: 4px; }

/* messages */
#messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: 12px; }
.welcome { padding: 16px; margin-top: 16px; }
.welcome .big { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-4); display: flex; align-items: center; justify-content: center; color: var(--text-hi); }
.welcome h1 { color: var(--text-hi); font-size: 32px; margin: 8px 0; } .welcome p { color: var(--muted); margin: 0; }
.day { display: flex; align-items: center; margin: 24px 16px 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--divider); } .day span { padding: 0 8px; }
.msg { position: relative; padding: 2px 48px 2px 72px; min-height: 22px; line-height: 1.375rem; word-wrap: break-word; }
.msg.head { margin-top: 17px; min-height: 44px; }
.msg:hover { background: rgba(2,2,2,.06); } html[data-theme="light"] .msg:hover { background: rgba(6,6,7,.02); }
.msg.mention { background: var(--mention-bg); } .msg.mention::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--mention-bar); }
.msg.editing, .msg.replying { background: rgba(88,101,242,.08); }
.msg .av { position: absolute; left: 16px; top: 2px; width: 40px; height: 40px; cursor: pointer; }
.msg .meta { display: flex; align-items: baseline; gap: 8px; }
.msg .author { font-weight: 500; color: var(--text-hi); cursor: pointer; } .msg .author:hover { text-decoration: underline; }
.msg .time { font-size: 12px; color: var(--muted); }
.msg .side-time { position: absolute; left: 0; width: 64px; text-align: right; font-size: 11px; color: var(--muted); opacity: 0; top: 4px; line-height: 1.375rem; }
.msg:hover .side-time { opacity: 1; }
.msg .content { color: var(--text); white-space: pre-wrap; user-select: text; }
.msg .content .edited { font-size: 10px; color: var(--muted); margin-left: 4px; }
.msg .content.jumbo img.emoji { width: 48px; height: 48px; } .msg .content.jumbo .uemoji { font-size: 44px; line-height: 52px; }
.msg.sys { padding-left: 72px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-height: 26px; margin-top: 8px; }
.msg.sys svg { position: absolute; left: 28px; color: var(--green); width: 18px; } .msg.sys b { color: var(--text-hi); font-weight: 500; cursor: pointer; }
.reply-ref { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 2px; position: relative; cursor: pointer; min-width: 0; }
.reply-ref::before { content: ""; position: absolute; left: -38px; top: 9px; width: 30px; height: 10px; border-left: 2px solid #4e5058; border-top: 2px solid #4e5058; border-top-left-radius: 6px; }
.reply-ref .av { position: static; width: 16px; height: 16px; } .reply-ref b { color: var(--text-hi); font-weight: 500; flex: none; }
.reply-ref span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.msg-tools { position: absolute; right: 14px; top: -16px; background: var(--bg-3); border: 1px solid var(--divider); border-radius: 6px; display: none; padding: 2px; box-shadow: var(--shadow); z-index: 3; }
.msg:hover .msg-tools { display: flex; } .msg-tools .icon-btn { width: 32px; height: 30px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; cursor: pointer; font-size: 14px; height: 26px; color: var(--muted); font-weight: 600; }
.reaction:hover { border-color: var(--faint); } .reaction.me { background: rgba(88,101,242,.15); border-color: var(--brand); color: var(--text-hi); }
.reaction img { width: 18px; height: 18px; object-fit: contain; }
.att { margin-top: 6px; max-width: 520px; }
.att img.media, .att video.media { max-width: 100%; max-height: 350px; border-radius: 8px; display: block; cursor: pointer; background: var(--bg-2); }
.att .file { display: flex; align-items: center; gap: 10px; background: var(--bg-2); border: 1px solid var(--divider); border-radius: 8px; padding: 14px; max-width: 432px; }
.att .file .n { flex: 1; min-width: 0; } .att .file .n a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .att .file .n span { font-size: 12px; color: var(--muted); }
.att audio { width: 100%; margin-top: 6px; }
.sticker { width: 160px; height: 160px; object-fit: contain; margin-top: 4px; }
img.emoji { width: 22px; height: 22px; object-fit: contain; vertical-align: bottom; }
.mention-pill { background: rgba(88,101,242,.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; cursor: pointer; }
html[data-theme="light"] .mention-pill { color: #505cdc; background: rgba(88,101,242,.15); }
.mention-pill:hover { background: var(--brand); color: #fff; }
code.inline { background: var(--code); padding: 2px 4px; border-radius: 4px; font-size: 85%; font-family: Consolas, "Courier New", monospace; }
pre.block { background: var(--code); border: 1px solid var(--bg-1); padding: 8px; border-radius: 4px; font-family: Consolas, monospace; font-size: 14px; margin: 6px 0; white-space: pre-wrap; max-width: 90%; }
blockquote { margin: 0; padding-left: 12px; border-left: 4px solid #4e5058; }
.spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; } .spoiler.open { background: var(--bg-mod); color: inherit; }
.msg h1, .msg h2, .msg h3 { margin: 6px 0 2px; color: var(--text-hi); line-height: 1.3; } .msg h1 { font-size: 24px; } .msg h2 { font-size: 20px; } .msg h3 { font-size: 16px; }
.embed-img { max-width: 400px; max-height: 300px; border-radius: 8px; margin-top: 6px; display: block; }
.load-more { text-align: center; padding: 12px; color: var(--muted); font-size: 13px; }

/* composer */
#composer { padding: 0 16px 24px; flex: none; position: relative; }
.typing { position: absolute; left: 16px; bottom: 3px; font-size: 13px; color: var(--text); height: 20px; display: flex; align-items: center; gap: 6px; }
.typing .dots { display: inline-flex; gap: 3px; } .typing .dots i { width: 5px; height: 5px; background: var(--text); border-radius: 50%; animation: tdot 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .2s; } .typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes tdot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.cbox { background: var(--bg-4); border-radius: 8px; }
html[data-theme="light"] .cbox { background: #ebedef; }
.cbox .bar { display: flex; align-items: center; padding: 8px 12px; font-size: 13px; color: var(--muted); background: var(--bg-2); border-radius: 8px 8px 0 0; gap: 8px; }
.cbox .bar b { color: var(--text-hi); } .cbox .bar .grow { flex: 1; }
.cbox .files { display: flex; gap: 12px; padding: 16px 12px 4px; overflow-x: auto; border-bottom: 1px solid var(--divider); }
.cbox .files .f { width: 200px; height: 180px; background: var(--bg-2); border-radius: 4px; padding: 8px; position: relative; display: flex; flex-direction: column; flex: none; }
.cbox .files .f .pv { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; border-radius: 3px; }
.cbox .files .f .pv img, .cbox .files .f .pv video { max-width: 100%; max-height: 100%; }
.cbox .files .f .fn { font-size: 13px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbox .files .f .rm { position: absolute; top: -10px; right: -10px; background: var(--bg-3); color: var(--red); box-shadow: var(--shadow); }
.cbox .files .f .prog { height: 4px; background: var(--bg-1); border-radius: 2px; margin-top: 4px; } .cbox .files .f .prog i { display: block; height: 100%; background: var(--brand); width: 0; border-radius: 2px; }
.cbox .row { display: flex; align-items: flex-start; padding: 0 8px 0 4px; }
.cbox textarea { background: none; resize: none; padding: 11px 6px; max-height: 50vh; min-height: 44px; line-height: 22px; outline: none !important; }
.cbox .row .icon-btn { height: 44px; width: 40px; } .cbox .row svg.i { width: 24px; height: 24px; }
.autocomplete { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 16px); background: var(--bg-2); border-radius: 8px; padding: 8px; box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; z-index: 20; }
.autocomplete .t { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 4px 8px 8px; }
.autocomplete .it { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.autocomplete .it.sel, .autocomplete .it:hover { background: var(--bg-mod-hover); } .autocomplete .it .u { color: var(--muted); font-size: 13px; margin-left: auto; }

/* popouts / menus / modals */
.layer { position: fixed; inset: 0; z-index: 100; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 100; display: flex; align-items: center; justify-content: center; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal { background: var(--bg-3); border-radius: 8px; width: 460px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); display: flex; flex-direction: column; animation: pop .15s; box-shadow: var(--shadow); }
.modal .mh { padding: 24px 24px 0; text-align: center; } .modal .mh h2 { margin: 0; color: var(--text-hi); font-size: 24px; } .modal .mh p { color: var(--muted); margin: 8px 0 0; }
.modal .mh.left { text-align: left; } .modal .mh.left h2 { font-size: 20px; }
.modal .mb { padding: 16px 24px; overflow-y: auto; }
.modal .mf { background: var(--bg-2); padding: 16px; display: flex; justify-content: flex-end; gap: 8px; border-radius: 0 0 8px 8px; align-items: center; }
.modal .mf .grow { flex: 1; }
.menu { position: fixed; background: var(--bg-float); border-radius: 4px; padding: 6px 8px; min-width: 188px; box-shadow: var(--shadow); z-index: 200; animation: pop .1s; max-height: 80vh; overflow-y: auto; }
html[data-theme="light"] .menu { border: 1px solid var(--divider); }
.menu .mi { padding: 6px 8px; border-radius: 2px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); margin: 2px 0; font-weight: 500; }
.menu .mi:hover { background: var(--brand); color: #fff; } .menu .mi.danger { color: var(--red); } .menu .mi.danger:hover { background: var(--red); color: #fff; }
.menu .sep { height: 1px; background: var(--divider); margin: 4px; }
.menu .mi input[type=range] { width: 100%; }
.menu .lbl2 { font-size: 12px; color: var(--muted); padding: 6px 8px 0; }
.profile { position: fixed; width: 340px; background: var(--bg-float); border-radius: 8px; overflow: hidden; z-index: 150; box-shadow: var(--shadow); animation: pop .12s; }
.profile.themed { padding: 4px; } .profile.themed .pinner { border-radius: 6px; overflow: hidden; background: rgba(0,0,0,.45); }
html[data-theme="light"] .profile.themed .pinner { background: rgba(255,255,255,.6); }
.profile .banner { height: 120px; background-size: cover; background-position: center; }
.profile .banner.short { height: 60px; }
.profile .pav { position: relative; margin: -46px 0 0 16px; width: 92px; height: 92px; border-radius: 50%; border: 6px solid var(--bg-float); background: var(--bg-float); }
.profile.themed .pav { border-color: transparent; background: none; }
.profile .pav .av { width: 80px; height: 80px; } .profile .pav .av .dot { border-color: var(--bg-float); max-width: 16px; max-height: 16px; width: 16px; height: 16px; border-width: 4px; }
.profile .pbody { margin: 12px 16px 16px; }
.profile .card2 { background: var(--bg-2); border-radius: 8px; padding: 12px; }
.profile.themed .card2 { background: rgba(0,0,0,.3); } html[data-theme="light"] .profile.themed .card2 { background: rgba(255,255,255,.5); }
.profile .dn { font-size: 20px; font-weight: 700; color: var(--text-hi); word-break: break-word; } .profile .un { font-size: 14px; color: var(--text); }
.profile .pr { font-size: 14px; color: var(--muted); }
.profile .sec { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-hi); margin: 12px 0 6px; }
.profile .bio { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.profile .roles { display: flex; flex-wrap: wrap; gap: 4px; }
.role-pill { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-mod); border-radius: 4px; padding: 2px 6px; font-size: 12px; font-weight: 500; }
.role-pill i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.profile .cstatus { margin-top: 8px; font-size: 14px; }
.profile .acts { display: flex; gap: 8px; margin-top: 12px; }
.profile .acts input { flex: 1; font-size: 14px; padding: 8px; }

/* friends */
.friends { flex: 1; overflow-y: auto; padding: 16px 20px; }
.friends h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 8px 0 16px; }
.friend { display: flex; align-items: center; gap: 12px; padding: 0 10px; height: 62px; border-top: 1px solid var(--divider); border-radius: 8px; cursor: pointer; }
.friend:hover { background: var(--bg-mod); border-color: transparent; }
.friend .nm { flex: 1; min-width: 0; } .friend .nm b { color: var(--text-hi); font-weight: 600; } .friend .nm .u { color: var(--muted); font-size: 14px; display: none; } .friend:hover .nm .u { display: inline; }
.friend .nm .s { font-size: 13px; color: var(--muted); }
.friend .round { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-2); color: var(--muted); } .friend:hover .round { background: var(--bg-1); }
.friend .round:hover { color: var(--text-hi); } .friend .round.ok:hover { color: var(--green); } .friend .round.no:hover { color: var(--red); }
.add-friend { padding: 20px 30px; border-bottom: 1px solid var(--divider); }
.add-friend h2 { margin: 0 0 8px; color: var(--text-hi); font-size: 16px; text-transform: uppercase; }
.add-friend p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.add-friend .inp { display: flex; background: var(--bg-1); border-radius: 8px; padding: 0 12px; align-items: center; border: 1px solid var(--bg-1); }
.add-friend .inp:focus-within { border-color: var(--link); }
.add-friend .inp input { background: none; outline: none !important; height: 50px; }
.add-friend .msgline { font-size: 14px; margin-top: 8px; } .add-friend .msgline.ok { color: var(--green); } .add-friend .msgline.bad { color: var(--red); }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 12px; text-align: center; padding: 20px; }
.empty .art { font-size: 72px; opacity: .8; }

/* voice / calls */
.call-area { background: #000; display: flex; flex-direction: column; flex: none; position: relative; min-height: 260px; }
.call-area.full { flex: 1; }
.call-area.dm { height: 45vh; min-height: 260px; resize: vertical; overflow: hidden; }
.call-grid { flex: 1; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px; padding: 16px; overflow: auto; min-height: 0; }
.tile { position: relative; background: var(--bg-2); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer;
  width: 320px; aspect-ratio: 16/9; flex: none; outline: 2px solid transparent; transition: outline-color .1s; }
.call-grid.n1 .tile { width: min(100%, calc((100vh - 260px) * 16 / 9)); }
.call-grid.n2 .tile { width: calc(50% - 4px); max-width: calc((100vh - 280px) * 16 / 9); }
.call-grid.n3 .tile, .call-grid.n4 .tile { width: calc(50% - 4px); max-width: calc((50vh - 140px) * 16 / 9); }
.call-grid.nmany .tile { width: calc(33.33% - 6px); }
.call-area.dm .call-grid .tile { width: auto; height: calc(100% - 8px); max-width: 48%; }
.tile.speaking { outline-color: var(--green); }
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.cam video { object-fit: cover; } .tile.mirror video { transform: scaleX(-1); }
.tile .av { width: 80px; height: 80px; } .tile .av .dot { display: none; }
.tile .bg { position: absolute; inset: 0; opacity: .9; }
.tile .tag { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; border-radius: 4px; padding: 3px 8px; font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: center; max-width: calc(100% - 16px); }
.tile .tag svg { width: 16px; height: 16px; } .tile .tag .red { color: var(--red); }
.tile .stats { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.6); color: #fff; border-radius: 4px; padding: 2px 6px; font-size: 11px; font-family: Consolas, monospace; }
.tile .sb-pop { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); font-size: 40px; animation: sbpop 2.2s forwards; pointer-events: none; }
@keyframes sbpop { 0% { transform: translate(-50%, 20px) scale(.5); opacity: 0; } 15% { transform: translate(-50%, 0) scale(1.2); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -30px); opacity: 0; } }
.tile.focus { position: absolute; inset: 0; width: auto !important; max-width: none !important; height: auto !important; z-index: 5; border-radius: 0; aspect-ratio: auto; }
.call-ctrls { display: flex; justify-content: center; gap: 12px; padding: 12px 16px 20px; flex: none; align-items: center; }
.call-ctrls .cb { width: 56px; height: 56px; border-radius: 50%; border: none; background: #2b2d31; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.call-ctrls .cb:hover { background: #3a3c42; } .call-ctrls .cb.off { background: #fff; color: #000; } .call-ctrls .cb.on { background: var(--green); }
.call-ctrls .cb.end { background: var(--red); } .call-ctrls .cb.end:hover { background: #da373c; }
.call-ctrls .cb svg.i { width: 24px; height: 24px; }
.call-head { color: #fff; display: flex; align-items: center; padding: 12px 16px; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.streams-list { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.stream-chip { background: rgba(255,255,255,.1); border-radius: 12px; padding: 3px 10px 3px 4px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.stream-chip:hover { background: rgba(255,255,255,.2); } .stream-chip.on { outline: 2px solid var(--red); }
.tile .unwatch { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.65); color: #fff; border: none; border-radius: 4px; padding: 4px 8px; font-size: 12px; cursor: pointer; opacity: 0; transition: opacity .15s; z-index: 2; }
.tile:hover .unwatch { opacity: 1; }
.vc-split { flex: 1; display: flex; min-height: 0; }
.call-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #000; }
.call-wrap .call-area { flex: 1; }
.vc-chat { width: 380px; flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--bg-3); border-left: 1px solid var(--divider); position: relative; }
.vc-chat .msg { padding-right: 16px; }
.vp-prev { position: relative; margin-top: 8px; border-radius: 6px; overflow: hidden; cursor: pointer; aspect-ratio: 16/9; background: #000; }
.vp-prev video { width: 100%; height: 100%; object-fit: contain; display: block; }
.vp-prev span { position: absolute; left: 6px; bottom: 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.6); border-radius: 4px; padding: 1px 6px; display: flex; gap: 6px; align-items: center; }
.voice-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; color: #fff; gap: 12px; }
.voice-empty h2 { margin: 0; }
.soundboard { position: fixed; width: 460px; max-height: 480px; background: var(--bg-2); border-radius: 8px; box-shadow: var(--shadow); z-index: 160; display: flex; flex-direction: column; animation: pop .12s; }
.soundboard .sh { padding: 12px 16px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--divider); }
.soundboard .sh input { height: 32px; padding: 0 8px; }
.soundboard .sl { overflow-y: auto; padding: 8px 16px 16px; }
.soundboard h5 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 12px 0 8px; display: flex; align-items: center; gap: 6px; }
.soundboard .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sbtn { position: relative; background: var(--bg-4); border: 1px solid transparent; border-radius: 8px; height: 40px; display: flex; align-items: center; gap: 6px; padding: 0 8px; cursor: pointer; color: var(--text); font-size: 13px; font-weight: 500; overflow: hidden; }
.sbtn:hover { border-color: var(--brand); } .sbtn .e { font-size: 18px; } .sbtn .n { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; }
.sbtn .pv { opacity: 0; } .sbtn:hover .pv { opacity: 1; }
.sbtn.playing { border-color: var(--green); }
.incoming { position: fixed; left: 50%; top: 80px; transform: translateX(-50%); background: var(--bg-float); border-radius: 12px; padding: 24px; width: 260px; text-align: center; z-index: 300; box-shadow: 0 0 0 1px var(--divider), var(--shadow); animation: pop .2s; }
.incoming .av { width: 80px; height: 80px; margin: 0 auto 12px; animation: ring 1.4s infinite; border-radius: 50%; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(35,165,90,.7); } 70% { box-shadow: 0 0 0 18px rgba(35,165,90,0); } 100% { box-shadow: 0 0 0 0 rgba(35,165,90,0); } }
.incoming h3 { margin: 0; color: var(--text-hi); } .incoming p { color: var(--muted); margin: 4px 0 16px; }
.incoming .r { display: flex; gap: 24px; justify-content: center; }
.incoming .r button { width: 52px; height: 52px; border-radius: 50%; border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* emoji picker */
.picker { position: fixed; width: 420px; height: 440px; background: var(--bg-2); border-radius: 8px; box-shadow: var(--shadow); z-index: 160; display: flex; flex-direction: column; overflow: hidden; animation: pop .12s; }
.picker .ptabs { display: flex; gap: 4px; padding: 12px 12px 0; }
.picker .ptabs div { padding: 4px 10px; border-radius: 4px; cursor: pointer; font-weight: 500; color: var(--muted); }
.picker .ptabs div.active { background: var(--bg-mod-sel); color: var(--text-hi); }
.picker .ps { padding: 12px; } .picker .ps input { height: 32px; padding: 0 8px; }
.picker .pbody { flex: 1; display: flex; min-height: 0; }
.picker .pnav { width: 48px; background: var(--bg-1); overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.picker .pnav div { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; background: var(--bg-3); flex: none; }
.picker .pnav img { width: 100%; height: 100%; object-fit: cover; }
.picker .plist { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.picker h6 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 8px 4px; position: sticky; top: 0; background: var(--bg-2); padding: 4px 0; z-index: 1; }
.picker .eg { display: grid; grid-template-columns: repeat(9, 1fr); }
.picker .eg.st { grid-template-columns: repeat(4, 1fr); gap: 4px; }
.picker .e { height: 40px; display: flex; align-items: center; justify-content: center; font-size: 26px; cursor: pointer; border-radius: 4px; }
.picker .e:hover { background: var(--bg-mod-hover); } .picker .e img { width: 32px; height: 32px; object-fit: contain; }
.picker .eg.st .e { height: 90px; } .picker .eg.st .e img { width: 80px; height: 80px; }
.picker .pfoot { height: 44px; background: var(--bg-1); display: flex; align-items: center; padding: 0 12px; gap: 8px; color: var(--text-hi); font-weight: 600; font-size: 14px; }
.picker .pfoot .p { font-size: 26px; } .picker .pfoot img { width: 28px; height: 28px; }

/* settings (full screen) */
.settings { position: fixed; inset: 0; display: flex; z-index: 120; background: var(--bg-3); animation: fade .15s; }
.settings .snav { flex: 1 0 218px; background: var(--bg-2); display: flex; justify-content: flex-end; overflow-y: auto; }
.settings .snav .in { width: 218px; padding: 60px 6px 60px 20px; }
.settings .snav h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 0; padding: 6px 10px; }
.settings .snav .it { padding: 6px 10px; border-radius: 4px; cursor: pointer; color: var(--muted); margin-bottom: 2px; font-weight: 500; }
.settings .snav .it:hover { background: var(--bg-mod); color: var(--text); } .settings .snav .it.active { background: var(--bg-mod-sel); color: var(--text-hi); }
.settings .snav .it.danger { color: var(--red); } .settings .snav .sep { height: 1px; background: var(--divider); margin: 8px 10px; }
.settings .scont { flex: 1 1 800px; overflow-y: auto; display: flex; }
.settings .scont .in { width: 740px; max-width: 100%; padding: 60px 40px 80px; }
.settings h2 { color: var(--text-hi); font-size: 20px; margin: 0 0 20px; }
.settings h3 { color: var(--text-hi); font-size: 16px; margin: 28px 0 8px; }
.settings .close { flex: none; padding-top: 60px; width: 72px; }
.settings .close button { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--muted); background: none; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.settings .close button:hover { background: var(--bg-mod-hover); color: var(--text-hi); }
.settings .close span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; text-align: center; width: 36px; }
.setcard { background: var(--bg-2); border-radius: 8px; padding: 16px; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--divider); }
.setrow:last-child { border-bottom: none; } .setrow .d { color: var(--muted); font-size: 14px; } .setrow b { color: var(--text-hi); font-weight: 500; }
.hint { color: var(--muted); font-size: 14px; margin: 4px 0 8px; }
.two { display: flex; gap: 40px; } .two > div { flex: 1; min-width: 0; }
.uploader { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #80848e; border-radius: 12px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); } .switch input:checked + span::before { transform: translateX(16px); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 8px; border-bottom: 1px solid var(--divider); }
.list-row:hover { background: var(--bg-mod); } .list-row .grow { flex: 1; min-width: 0; }
.list-row img.th { width: 32px; height: 32px; object-fit: contain; }
.role-list { display: flex; gap: 16px; } .role-list .rl { width: 200px; flex: none; } .role-list .re { flex: 1; min-width: 0; }
.role-item { padding: 6px 10px; border-radius: 4px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.role-item:hover { background: var(--bg-mod); } .role-item.active { background: var(--bg-mod-sel); }
.role-item i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.meter { height: 8px; background: var(--bg-1); border-radius: 4px; overflow: hidden; position: relative; }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); width: 0; transition: width .05s; }
.cam-prev { width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.cam-prev video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.opt-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.opt { background: var(--bg-2); border: 2px solid transparent; border-radius: 8px; padding: 10px 6px; text-align: center; cursor: pointer; font-weight: 600; font-size: 14px; }
.opt small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 2px; }
.opt:hover { background: var(--bg-mod-hover); } .opt.sel { border-color: var(--brand); background: rgba(109,93,252,.15); }
.preview-card { width: 300px; flex: none; }
.theme-sw { display: flex; gap: 12px; } .theme-sw div { width: 60px; height: 60px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.theme-sw div.sel { border-color: var(--brand); }
.invite-box { display: flex; background: var(--bg-1); border-radius: 4px; padding: 4px; align-items: center; }
.invite-box input { background: none; } .invite-box .btn { height: 32px; }
.img-viewer { max-width: 90vw; max-height: 85vh; border-radius: 4px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg-float); color: var(--text-hi); padding: 10px 16px; border-radius: 6px; z-index: 400; box-shadow: var(--shadow); animation: pop .15s; font-size: 14px; }
.drop-zone { position: absolute; inset: 0; background: rgba(109,93,252,.85); z-index: 50; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 700; pointer-events: none; border-radius: 8px; }
.invite-embed { background: var(--bg-2); border-radius: 8px; padding: 16px; width: 432px; max-width: 100%; margin-top: 6px; }
.invite-embed .t { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; margin-bottom: 12px; }
.invite-embed .r { display: flex; align-items: center; gap: 16px; }
.invite-embed .gi { width: 50px; height: 50px; border-radius: 16px; background: var(--bg-3); overflow: hidden; display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.invite-embed .gi img { width: 100%; height: 100%; object-fit: cover; }
.invite-embed .n { flex: 1; min-width: 0; } .invite-embed .n b { color: var(--text-hi); display: block; } .invite-embed .n span { color: var(--muted); font-size: 13px; }
.status-menu .mi .dot { position: relative; right: auto; bottom: auto; width: 10px; height: 10px; min-width: 10px; min-height: 10px; border: none; display: inline-block; margin-right: 8px; vertical-align: -1px; overflow: hidden; border-radius: 50%; }
.status-menu .mi .dot::after { background: var(--bg-float); }
.status-menu .mi:hover .dot::after { background: var(--brand); }
.searchres { width: 420px; flex: none; background: var(--bg-2); overflow-y: auto; padding: 12px; }
.searchres .msg { background: var(--bg-3); border-radius: 8px; margin-bottom: 8px; padding-right: 12px; }
.unsaved { position: sticky; bottom: 16px; margin-top: 24px; display: flex; align-items: center; gap: 8px; background: var(--bg-float); color: var(--text-hi);
  border-radius: 8px; padding: 10px 10px 10px 16px; box-shadow: var(--shadow); animation: pop .15s; z-index: 3; }
.unsaved span { flex: 1; }
.install-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 12px;
  background: var(--bg-float); color: var(--text-hi); border: 1px solid var(--divider); border-radius: 12px; padding: 10px 10px 10px 14px; box-shadow: var(--shadow);
  max-width: min(640px, calc(100vw - 16px)); width: max-content; animation: pop .2s; font-size: 14px; }
.install-bar .ib-ic { color: var(--brand); display: flex; } .install-bar .ib-t { flex: 1; min-width: 0; }
.install-bar a.btn { text-decoration: none; }
@media (max-width: 767px) { .install-bar { bottom: calc(80px + env(safe-area-inset-bottom)); width: calc(100vw - 16px); flex-wrap: wrap; } }
.m-back, .m-only { display: none !important; }
@media (max-width: 900px) and (min-width: 768px) { #members, .searchres { display: none; } .two { flex-direction: column; } .vc-chat { width: 300px; } }

/* ============================ mobile (phones) ============================ */
@media (max-width: 767px) {
  html, body { height: 100dvh; }
  #app { height: 100dvh; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .m-back, .m-only { display: inline-flex !important; }
  .m-hide { display: none !important; }
  /* two screens: list (servers + channels) and chat */
  #app.m-chat #guilds, #app.m-chat #sidebar { display: none; }
  #app:not(.m-chat) #main { display: none; }
  #sidebar { flex: 1; width: auto; }
  #guilds { width: 64px; } .g-item { width: 64px; }
  .ch, .dm-item { height: 44px; font-size: 16px; }
  .ch .acts { display: flex; }
  #head { padding: 0 6px; gap: 4px; }
  #head .topic, #head .search, #head .tabs .tab:not(.active):not(.add) { display: none; }
  #head .tabs { margin-left: 0; overflow-x: auto; }
  #head .title { min-width: 0; overflow: hidden; } #head .title span { overflow: hidden; text-overflow: ellipsis; }
  /* member list = slide-over panel */
  #members { position: fixed; top: 0; right: 0; bottom: 0; width: min(300px, 85vw); z-index: 60; box-shadow: -8px 0 24px rgba(0,0,0,.4); padding-top: env(safe-area-inset-top); }
  .searchres { position: fixed; inset: 48px 0 0 0; width: auto; z-index: 55; }
  /* messages */
  .msg { padding: 2px 12px 2px 60px; } .msg .av { left: 10px; } .msg .side-time { width: 52px; }
  .msg-tools { display: none !important; }
  .reply-ref::before { left: -30px; width: 24px; }
  .att { max-width: 100%; } .att img.media, .att video.media { max-height: 260px; }
  .embed-img { max-width: 100%; }
  #composer { padding: 0 8px calc(10px + env(safe-area-inset-bottom)); }
  #composer .typing { bottom: -2px; }
  .cbox textarea { font-size: 16px; } /* no zoom-on-focus on iOS */
  input, textarea, select { font-size: 16px; }
  .welcome h1 { font-size: 24px; }
  /* popups */
  .modal { width: calc(100vw - 16px) !important; max-height: calc(100dvh - 32px); }
  .menu { min-width: 220px; } .menu .mi { padding: 10px 8px; font-size: 15px; }
  .profile { width: calc(100vw - 16px); left: 8px !important; }
  .picker { width: calc(100vw - 16px); left: 8px !important; height: min(440px, 70dvh); }
  .picker .eg { grid-template-columns: repeat(7, 1fr); }
  .soundboard { width: calc(100vw - 16px); left: 8px !important; max-height: 70dvh; }
  .soundboard .grid { grid-template-columns: repeat(2, 1fr); }
  .soundboard .sh { flex-wrap: wrap; }
  .incoming { top: 40px; }
  /* settings: navigation becomes a scrollable strip on top */
  .settings { flex-direction: column; }
  .settings .snav { flex: none; justify-content: flex-start; }
  .settings .snav .in { width: auto; padding: 8px; display: flex; gap: 4px; overflow-x: auto; white-space: nowrap; }
  .settings .snav h4, .settings .snav .sep { display: none; }
  .settings .scont { flex: 1; }
  .settings .scont .in { padding: 16px 16px 80px; }
  .settings .close { position: fixed; top: 6px; right: 6px; padding: 0; width: auto; z-index: 2; } .settings .close span { display: none; }
  .two, .role-list { flex-direction: column; gap: 12px; } .role-list .rl { width: auto; }
  .preview-card { width: 100%; }
  .opt-grid { grid-template-columns: repeat(2, 1fr) !important; }
  /* calls */
  .vc-split { flex-direction: column; }
  .vc-chat { width: auto; flex: 1; border-left: none; border-top: 1px solid var(--divider); min-height: 40%; }
  .call-wrap { flex: none; max-height: 55dvh; }
  .call-grid { padding: 8px; gap: 6px; }
  .call-grid .tile, .call-grid.n1 .tile, .call-grid.n2 .tile, .call-grid.n3 .tile, .call-grid.nmany .tile { width: calc(50% - 3px); max-width: none; }
  .call-grid.n1 .tile { width: 100%; }
  .call-area.dm { height: 40dvh; }
  .call-area.dm .call-grid .tile { height: auto; max-width: none; width: calc(50% - 3px); }
  .call-ctrls { gap: 8px; padding: 8px 8px 12px; } .call-ctrls .cb { width: 46px; height: 46px; }
  .tile .unwatch { opacity: 1; }
  .friends { padding: 8px; } .add-friend { padding: 16px; }
  .add-friend .inp { flex-direction: column; align-items: stretch; padding: 8px; gap: 8px; } .add-friend .inp input { height: 44px; }
}
