/* ==========================================================================
   VibeRoom — design system & layout
   ========================================================================== */
:root {
  --accent: #7c5cff;
  --fs: 1;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-strong: color-mix(in srgb, var(--accent) 80%, #fff);
  --red: #f2555a; --green: #2bd98a; --yellow: #f5b83d; --blue: #4aa8ff;
  --radius: 10px; --radius-lg: 16px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --rail-w: 72px; --side-w: 248px; --right-w: 272px;
  --shadow: 0 10px 40px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.2);
  --ease: cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"] {
  --bg-0: #111216; --bg-1: #17181e; --bg-2: #1d1e25; --bg-3: #26272f; --bg-4: #30313b;
  --hover: rgba(255,255,255,.045); --hover-2: rgba(255,255,255,.08);
  --text: #ececf1; --text-2: #b9bbc7; --muted: #868999; --border: rgba(255,255,255,.07);
  --code-bg: #14151a; --mention-bg: rgba(245,184,61,.09); --mention-bar: #f5b83d;
  color-scheme: dark;
}
[data-theme="midnight"] {
  --bg-0: #000; --bg-1: #08080b; --bg-2: #0d0d11; --bg-3: #18181e; --bg-4: #222229;
  --hover: rgba(255,255,255,.045); --hover-2: rgba(255,255,255,.08);
  --text: #ececf1; --text-2: #b0b2bd; --muted: #7d8090; --border: rgba(255,255,255,.07);
  --code-bg: #050507; --mention-bg: rgba(245,184,61,.08); --mention-bar: #f5b83d;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg-0: #e3e5ec; --bg-1: #f0f1f5; --bg-2: #ffffff; --bg-3: #eceef3; --bg-4: #dfe1e8;
  --hover: rgba(20,22,40,.045); --hover-2: rgba(20,22,40,.08);
  --text: #1c1e26; --text-2: #3e4250; --muted: #6c7082; --border: rgba(20,22,40,.09);
  --code-bg: #f4f5f8; --mention-bg: rgba(245,184,61,.14); --mention-bar: #d99a14;
  --shadow: 0 10px 40px rgba(20,22,40,.15), 0 2px 8px rgba(20,22,40,.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font); font-size: calc(15px * var(--fs)); line-height: 1.45; color: var(--text); background: var(--bg-2);
  -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
code, pre, kbd { font-family: var(--mono); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .82em; }
.pad { padding: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 12px; }
.row.top { align-items: flex-start; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.center-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clickable { cursor: pointer; }
.red { color: var(--red) !important; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 8px;
  background: var(--bg-4); color: var(--text); font-weight: 600; font-size: .92em; transition: background .15s, transform .1s, filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn.success { background: var(--green); color: #062; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 12px; font-size: .85em; }
.btn.big { height: 46px; padding: 0 24px; font-size: 1em; border-radius: 10px; }
.btn.wide { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: var(--text-2); transition: background .12s, color .12s; flex-shrink: 0; }
.icon-btn:hover { background: var(--hover-2); color: var(--text); }
.icon-btn.active { color: var(--text); background: var(--hover-2); }
.icon-btn.sm { width: 24px; height: 24px; border-radius: 6px; }
.icon-btn.round { border-radius: 50%; background: var(--bg-3); width: 36px; height: 36px; }
.icon-btn.red { color: var(--red); }
.link { color: var(--blue); font-weight: 500; }
.link:hover { text-decoration: underline; }
.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; background: var(--bg-0); border: 1px solid var(--border); outline: 0; transition: border .15s, box-shadow .15s;
}
[data-theme="light"] .input { background: var(--bg-3); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 40px; line-height: 1.4; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.big { height: 50px; font-size: 1.05em; border-radius: 12px; }
select.input { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.field > span, .label { font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.label { margin: 14px 0 6px; display: block; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.color-input { width: 48px; height: 40px; border: 0; padding: 0; background: none; border-radius: 8px; cursor: pointer; }
.range { flex: 1; accent-color: var(--accent); }
kbd { font-size: .75em; padding: 2px 6px; border-radius: 5px; background: var(--bg-4); border-bottom: 2px solid rgba(0,0,0,.25); color: var(--text-2); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--bg-4); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.badge.inline { margin-left: auto; }
.tag-bot { font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; background: var(--accent); color: #fff; margin-left: 6px; vertical-align: 2px; letter-spacing: .02em; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.online { background: var(--green); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.toggle-label { font-weight: 600; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--bg-4); border-radius: 12px; transition: background .2s; }
.switch i::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s var(--ease); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); }

/* ------------------------------------------------------------------ avatars */
.avatar { position: relative; border-radius: 50%; background: var(--c, var(--accent)); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; font-weight: 700; user-select: none; }
.avatar > img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar > span { line-height: 1; letter-spacing: -.02em; }
.avatar.group-av { background: var(--bg-4); color: var(--text-2); overflow: hidden; }
.status-dot { position: absolute; right: -2px; bottom: -2px; width: 34%; height: 34%; min-width: 10px; min-height: 10px; max-width: 18px; max-height: 18px; border-radius: 50%; border: 3px solid var(--bg-1); background: #80848e; box-sizing: content-box; }
.status-dot.online { background: var(--green); }
.status-dot.idle { background: var(--yellow); }
.status-dot.dnd { background: var(--red); }
.status-dot.offline { background: #80848e; }
.avatar.ringing { animation: ringPulse 1.2s infinite; }
@keyframes ringPulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 60%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }

/* ------------------------------------------------------------------ auth */
.auth-page { position: fixed; inset: 0; display: grid; place-items: center; overflow: auto; padding: 24px; background: var(--bg-0); }
.auth-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.auth-bg i { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; animation: float 18s ease-in-out infinite; }
.auth-bg i:nth-child(1) { width: 520px; height: 520px; background: var(--accent); left: -120px; top: -140px; }
.auth-bg i:nth-child(2) { width: 460px; height: 460px; background: #ff5c8a; right: -120px; bottom: -160px; animation-delay: -6s; }
.auth-bg i:nth-child(3) { width: 340px; height: 340px; background: #2bd9a8; left: 45%; top: 55%; opacity: .25; animation-delay: -12s; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,-30px) scale(1.08); } }
.auth-wrap { position: relative; display: flex; gap: 32px; align-items: stretch; max-width: 940px; width: 100%; }
.auth-card { flex: 0 0 420px; background: color-mix(in srgb, var(--bg-2) 88%, transparent); backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.6em; font-weight: 800; }
.auth-logo { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 1.3em; letter-spacing: -.02em; margin-bottom: 8px; }
.auth-error { color: var(--red); font-size: .9em; min-height: 1.2em; }
.auth-switch { font-size: .9em; color: var(--muted); }
.auth-side { flex: 1; padding: 32px; border-radius: 20px; color: #fff; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 85%, #000), #2a1240); position: relative; overflow: hidden; }
.auth-side h2 { font-size: 2em; font-weight: 800; letter-spacing: -.03em; margin-bottom: 24px; max-width: 12em; }
.feature-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.feature-list li { display: flex; gap: 14px; align-items: flex-start; }
.feature-list li .ic { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.15); }
.feature-list b { display: block; }
.feature-list span { opacity: .8; font-size: .9em; }
.invite-preview { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--accent-soft); }
.logo { display: inline-block; flex-shrink: 0; }
.splash { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg-1); }
.splash .logo { animation: bob 1.6s ease-in-out infinite; }
.splash-text { color: var(--muted); font-weight: 600; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(-4deg); } }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--rail-w) var(--side-w) 1fr; height: 100vh; height: 100dvh; }
.rail { background: var(--bg-0); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 8px; overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail-servers { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.rail-sep { width: 32px; height: 2px; border-radius: 1px; background: var(--border); margin: 2px 0; flex-shrink: 0; }
.rail-item { position: relative; width: var(--rail-w); display: flex; justify-content: center; flex-shrink: 0; }
.rail-item .pill { position: absolute; left: 0; top: 50%; width: 4px; height: 0; border-radius: 0 4px 4px 0; background: var(--text); transform: translateY(-50%); transition: height .2s var(--ease); }
.rail-item.unread .pill { height: 8px; }
.rail-item:hover .pill { height: 20px; }
.rail-item.active .pill { height: 40px; }
.rail-btn { border-radius: 50%; transition: border-radius .2s var(--ease), transform .1s; overflow: hidden; display: block; }
.rail-item:hover .rail-btn, .rail-item.active .rail-btn { border-radius: 16px; }
.rail-btn:active { transform: translateY(1px); }
.rail-btn .logo svg { display: block; }
.rail-item.home-item .rail-btn { border-radius: 16px; }
.rail-item .badge { position: absolute; right: 10px; bottom: -2px; border: 3px solid var(--bg-0); height: 22px; min-width: 22px; border-radius: 11px; }
.rail-item.in-voice .rail-btn::after { content: ''; position: absolute; right: 10px; top: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--green); border: 3px solid var(--bg-0); }
.rail-item.dragging { opacity: .4; }
.rail-item.drop-before::before { content: ''; position: absolute; top: -5px; left: 16px; right: 16px; height: 3px; border-radius: 2px; background: var(--accent); }
.srv-icon { width: 48px; height: 48px; border-radius: inherit; background: var(--bg-3); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--text); font-size: 15px; transition: background .2s, color .2s; overflow: hidden; flex-shrink: 0; }
.srv-icon img { width: 100%; height: 100%; object-fit: cover; }
.rail-item:hover .srv-icon:not(.action), .rail-item.active .srv-icon:not(.action) { background: var(--c, var(--accent)); color: #fff; }
.srv-icon.action { color: var(--green); }
.rail-item:hover .srv-icon.action, .rail-item.active .srv-icon.action { background: var(--green); color: #fff; }
.srv-icon.group { background: var(--bg-4); }
.profile-card .srv-icon, .discover .srv-icon, .invite-preview .srv-icon { border-radius: 16px; }
.invite-preview .srv-icon, .palette-item .srv-icon { background: var(--c); color: #fff; }
.palette-item .srv-icon { border-radius: 8px; font-size: 10px; }

.sidebar { background: var(--bg-1); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side-head { height: 52px; flex-shrink: 0; display: flex; align-items: center; padding: 0 10px; border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.find-btn { width: 100%; height: 32px; border-radius: 8px; background: var(--bg-0); color: var(--muted); font-size: .85em; display: flex; align-items: center; gap: 8px; padding: 0 10px; text-align: left; }
[data-theme="light"] .find-btn { background: var(--bg-4); }
.find-btn { white-space: nowrap; overflow: hidden; }
.find-btn kbd { margin-left: auto; font-size: .7em; white-space: nowrap; }
.server-head { width: 100%; height: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; font-weight: 700; border-radius: 6px; background-size: cover; background-position: center; }
.server-head:hover { background-color: var(--hover); }
.server-head.has-banner { color: #fff; height: 52px; margin: 0 -10px; padding: 0 16px; border-radius: 0; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.server-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-body { flex: 1; overflow-y: auto; padding: 8px 8px 16px; min-height: 0; }
.side-label { display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 4px 6px; font-size: .72em; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.side-label.cat { cursor: pointer; user-select: none; justify-content: flex-start; gap: 2px; }
.side-label.cat:hover { color: var(--text-2); }
.side-label.cat .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-label .cat-chev { transition: transform .15s; }
.side-label.collapsed .cat-chev { transform: rotate(-90deg); }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; margin-bottom: 2px; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--hover-2); color: var(--text); }
.empty-side { padding: 8px 10px; }
.dm-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--text-2); margin-bottom: 1px; position: relative; }
.dm-row:hover { background: var(--hover); color: var(--text); }
.dm-row.active { background: var(--hover-2); color: var(--text); }
.dm-row.unread .dm-name { color: var(--text); font-weight: 700; }
.dm-meta { flex: 1; min-width: 0; }
.dm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.dm-sub { font-size: .76em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-call { color: var(--green); display: inline-flex; align-items: center; gap: 3px; }
.close-dm { opacity: 0; }
.dm-row:hover .close-dm { opacity: 1; }
.chan-row { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px; border-radius: 6px; color: var(--muted); cursor: pointer; margin: 1px 0; position: relative; font-weight: 500; }
.chan-row:hover { background: var(--hover); color: var(--text-2); }
.chan-row.active { background: var(--hover-2); color: var(--text); }
.chan-row.unread { color: var(--text); font-weight: 700; }
.chan-row.unread::before { content: ''; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text); }
.chan-row.muted { opacity: .45; }
.chan-row.connected { color: var(--green); }
.chan-row .chan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chan-row .chan-ic { opacity: .75; }
.chan-row .lock-ic { position: absolute; left: 20px; top: 8px; }
.chan-row .hover-only { display: none; }
.chan-row:hover .hover-only, .chan-row.active .hover-only { display: inline-flex; }
.chan-row.nested { padding-left: 26px; height: 30px; font-size: .92em; }
.chan-row .thread-spine { position: absolute; left: 14px; top: -8px; width: 10px; height: 23px; border-left: 2px solid var(--bg-4); border-bottom: 2px solid var(--bg-4); border-bottom-left-radius: 8px; }
.chan-row.dragging { opacity: .4; }
.chan-row.drop-before::after { content: ''; position: absolute; top: -2px; left: 4px; right: 4px; height: 2px; background: var(--accent); border-radius: 2px; }
.voice-users { padding: 0 0 4px 30px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: .9em; }
.voice-user:hover { background: var(--hover); }
.voice-user .avatar { transition: box-shadow .15s; }
.voice-user.speaking .avatar { box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--green); }
.vu-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vu-ic { color: var(--muted); }
.live-tag { font-size: 10px; font-weight: 800; background: var(--red); color: #fff; padding: 1px 5px; border-radius: 4px; }

.voice-panel { border-top: 1px solid var(--border); padding: 10px; background: var(--bg-1); }
.vp-top { margin-bottom: 8px; }
.vp-status { color: var(--green); font-weight: 700; font-size: .88em; display: flex; align-items: center; gap: 4px; }
.vp-status.warn { color: var(--yellow); }
.vp-where { font-size: .8em; color: var(--muted); text-align: left; }
.vp-where:hover { text-decoration: underline; color: var(--text-2); }
.vp-btns { display: flex; gap: 6px; }
.vbtn { flex: 1; height: 34px; border-radius: 8px; background: var(--bg-3); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.vbtn:hover { background: var(--bg-4); color: var(--text); }
.vbtn.on { background: var(--accent); color: #fff; }
.vbtn.danger { color: var(--red); }
.vbtn.danger:hover { background: var(--red); color: #fff; }
.user-panel { height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: color-mix(in srgb, var(--bg-0) 60%, var(--bg-1)); }
.me-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 8px; text-align: left; }
.me-btn:hover { background: var(--hover-2); }
.me-btn .status-dot { border-color: color-mix(in srgb, var(--bg-0) 60%, var(--bg-1)); }
.me-meta { min-width: 0; }
.me-name { font-weight: 600; font-size: .9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: .74em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-2); position: relative; }
.conn-banner { display: none; }
.conn-banner.offline, .conn-banner.connecting { display: block; text-align: center; padding: 4px; font-size: .82em; font-weight: 600; background: var(--yellow); color: #3b2b00; }
.chan-head { height: 52px; flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0,0,0,.06); min-width: 0; }
.chan-head h1 { font-size: 1em; font-weight: 700; white-space: nowrap; }
.chan-head .head-ic { color: var(--muted); }
.head-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.head-topic { color: var(--muted); font-size: .86em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; text-align: left; }
.head-tools { margin-left: auto; display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.head-search-wrap { position: relative; display: flex; align-items: center; margin: 0 4px; }
.head-search-wrap .ic { position: absolute; left: 8px; color: var(--muted); pointer-events: none; }
.head-search { width: 160px; height: 28px; border-radius: 6px; border: 0; outline: 0; background: var(--bg-0); padding: 0 8px 0 28px; font-size: .85em; transition: width .2s var(--ease); }
[data-theme="light"] .head-search { background: var(--bg-3); }
.head-search:focus { width: 240px; }
.mobile-only { display: none !important; }
.chan-body { flex: 1; display: flex; min-height: 0; }
.content-area { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.right-panel { width: var(--right-w); flex-shrink: 0; background: var(--bg-1); display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--border); }
.right-panel[data-mode="thread"], .right-panel[data-mode="search"], .right-panel[data-mode="pins"], .right-panel[data-mode="saved"], .right-panel[data-mode="threads"] { width: 400px; background: var(--bg-2); }
.rp-head { height: 52px; display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.rp-head h3 { font-size: .95em; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ chat */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat.dropping::after { content: 'Drop files to upload'; position: absolute; inset: 12px; border: 3px dashed var(--accent); border-radius: 16px; background: color-mix(in srgb, var(--bg-2) 85%, transparent); display: flex; align-items: center; justify-content: center; font-size: 1.3em; font-weight: 700; color: var(--accent); z-index: 10; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; min-height: 0; overflow-anchor: none; }
.messages { padding: 16px 0 12px; display: flex; flex-direction: column; min-height: 100%; justify-content: flex-end; }
.intro { padding: 16px 16px 20px; margin-bottom: 8px; }
.intro h1 { font-size: 1.9em; font-weight: 800; margin: 10px 0 4px; letter-spacing: -.02em; }
.intro-icon { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-4); display: flex; align-items: center; justify-content: center; }
.chat.in-panel .intro h1 { font-size: 1.35em; }
.chat.in-panel .intro-icon { width: 52px; height: 52px; }
.chat.in-panel .msg { padding-right: 12px; grid-template-columns: 60px 1fr; }
.chat.in-panel .reply-ref { padding-left: 60px; }
.chat.in-panel .msg-tools .emoji-quick, .chat.in-panel .msg-tools .tool-sep { display: none; }
.intro-sub { font-size: 1.1em; color: var(--text-2); margin-bottom: 8px; }
.loading-older .spinner { margin: 12px auto; width: 22px; height: 22px; }
.day-divider { display: flex; align-items: center; margin: 14px 16px 6px; color: var(--muted); font-size: .75em; font-weight: 600; }
.day-divider::before, .day-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.day-divider span { padding: 0 8px; }
.new-divider { display: flex; align-items: center; margin: 4px 16px 4px 16px; height: 0; border-top: 1px solid var(--red); position: relative; }
.new-divider span { position: absolute; right: 0; top: -8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 4px; }

.msg { position: relative; display: grid; grid-template-columns: 72px 1fr; padding: 2px 48px 2px 0; transition: background .1s; }
.msg.head { margin-top: 14px; }
.msg:hover { background: var(--hover); }
.msg.mentioned { background: var(--mention-bg); box-shadow: inset 2px 0 0 var(--mention-bar); }
.msg.mentioned:hover { background: color-mix(in srgb, var(--mention-bg) 100%, var(--hover)); }
.msg.flash { animation: flash 2s ease; }
@keyframes flash { 0%, 30% { background: var(--accent-soft); } }
.msg.fresh { animation: fadeUp .25s var(--ease); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
.msg.pending { opacity: .55; }
.msg.failed { opacity: 1; }
.msg.failed .content { color: var(--red); }
.fail-actions { display: flex; gap: 8px; margin-top: 4px; }
.msg .gutter { display: flex; justify-content: center; padding-top: 2px; }
.msg.head .gutter { padding-top: 3px; }
.msg .body { min-width: 0; }
.msg .avatar.clickable:hover { filter: brightness(1.1); }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 600; cursor: pointer; color: var(--text); }
.author:hover { text-decoration: underline; }
.msg-head time, .msg.system time { font-size: .74em; color: var(--muted); }
.hover-time { font-size: .68em; color: var(--muted); opacity: 0; padding-top: 4px; }
.msg:hover .hover-time { opacity: 1; }
.content { word-wrap: break-word; overflow-wrap: anywhere; color: var(--text); white-space: normal; }
.content.jumbo { font-size: 2.6em; line-height: 1.25; }
.content.jumbo .emoji { width: 48px; height: 48px; }
.edited { font-size: .7em; color: var(--muted); margin-left: 4px; }
.edited:hover { text-decoration: underline; }
.msg.system { grid-template-columns: 72px 1fr; padding-top: 4px; padding-bottom: 4px; color: var(--muted); font-size: .92em; }
.msg.system .gutter { padding-top: 3px; }
.msg.system .body { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg.system .author { color: var(--text); }
.sys-ic.join { color: var(--green); }
.sys-ic.call { color: var(--green); }
.sys-ic.pin { color: var(--text-2); }
.sys-ic.group\.leave { color: var(--red); }
.reply-ref { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; padding-left: 72px; font-size: .84em; color: var(--text-2); cursor: pointer; position: relative; min-width: 0; margin-bottom: 2px; }
.reply-ref .reply-spine { position: absolute; left: 34px; top: 9px; width: 30px; height: 10px; border-left: 2px solid var(--bg-4); border-top: 2px solid var(--bg-4); border-top-left-radius: 6px; }
.reply-ref b { white-space: nowrap; }
.reply-ref .reply-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; opacity: .85; }
.reply-ref .reply-text br { display: none; }
.reply-ref:hover .reply-text { opacity: 1; color: var(--text); }
.msg.blocked .body { padding: 4px 0; }

/* markdown */
.md strong { font-weight: 700; }
.md blockquote { margin: 4px 0; padding: 0 0 0 12px; border-left: 4px solid var(--bg-4); }
.md ul, .md ol { margin: 4px 0; padding-left: 24px; }
.md .md-h { margin: 8px 0 4px; font-weight: 800; }
.md h3.md-h { font-size: 1.5em; } .md h4.md-h { font-size: 1.25em; } .md h5.md-h { font-size: 1.08em; }
.md .md-sub { font-size: .8em; color: var(--muted); }
.md code.inline, code.inline { background: var(--code-bg); padding: 1px 5px; border-radius: 5px; font-size: .86em; border: 1px solid var(--border); }
.codeblock { margin: 6px 0; border-radius: 10px; background: var(--code-bg); border: 1px solid var(--border); overflow: hidden; max-width: 100%; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 10px; font-size: .72em; color: var(--muted); border-bottom: 1px solid var(--border); text-transform: lowercase; font-family: var(--mono); }
.code-copy { font-size: 1em; color: var(--text-2); padding: 2px 6px; border-radius: 4px; }
.code-copy:hover { background: var(--hover-2); }
.codeblock pre { margin: 0; padding: 10px 12px; overflow-x: auto; font-size: .86em; line-height: 1.5; }
.tk-k { color: #c792ea; } .tk-s { color: #c3e88d; } .tk-c { color: #7f8597; font-style: italic; } .tk-n { color: #f78c6c; } .tk-f { color: #82aaff; } .tk-t { color: #ffcb6b; }
[data-theme="light"] .tk-k { color: #8e3bd1; } [data-theme="light"] .tk-s { color: #2c8a3d; } [data-theme="light"] .tk-n { color: #c55316; } [data-theme="light"] .tk-f { color: #1f5fd1; } [data-theme="light"] .tk-t { color: #a66b00; }
.spoiler { background: var(--bg-4); color: transparent; border-radius: 4px; cursor: pointer; transition: color .2s, background .2s; padding: 0 2px; }
.spoiler > * { visibility: hidden; }
.spoiler.revealed { background: var(--hover-2); color: inherit; cursor: text; }
.spoiler.revealed > * { visibility: visible; }
.mention { background: var(--accent-soft); color: var(--accent-strong); padding: 0 3px; border-radius: 4px; font-weight: 500; cursor: pointer; }
[data-theme="light"] .mention { color: color-mix(in srgb, var(--accent) 80%, #000); }
.mention:hover { background: var(--accent); color: #fff; }
.mention.role { background: color-mix(in srgb, var(--rc) 18%, transparent); color: var(--rc); }
.emoji { width: 22px; height: 22px; vertical-align: -5px; object-fit: contain; }

/* attachments, embeds, polls */
.attachments { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; max-width: 560px; }
.img-grid { display: grid; gap: 4px; border-radius: 10px; overflow: hidden; }
.img-grid.n1 { grid-template-columns: 1fr; max-width: 420px; }
.img-grid.n2 { grid-template-columns: 1fr 1fr; }
.img-grid.n3 { grid-template-columns: 1fr 1fr 1fr; }
.img-grid.n4 { grid-template-columns: 1fr 1fr; }
.img-wrap { position: relative; overflow: hidden; background: var(--bg-3); border-radius: 6px; }
.img-grid.n1 .img-wrap { border-radius: 10px; }
.img-wrap img { display: block; width: 100%; max-height: 360px; object-fit: cover; cursor: zoom-in; transition: filter .2s; }
.img-grid.n1 .img-wrap img { object-fit: contain; max-height: 400px; width: auto; max-width: 100%; }
.spoiler-media { cursor: pointer; }
.spoiler-media img, .spoiler-media video { filter: blur(40px); pointer-events: none; }
.spoiler-media::after { content: 'SPOILER'; position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; padding: 6px 12px; border-radius: 20px; background: rgba(0,0,0,.6); color: #fff; font-weight: 800; font-size: .8em; letter-spacing: .05em; }
.video-wrap { position: relative; max-width: 480px; border-radius: 10px; overflow: hidden; background: #000; }
.video-wrap video { display: block; width: 100%; max-height: 360px; }
.file-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-3); border: 1px solid var(--border); max-width: 420px; color: var(--accent); }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-meta a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card.audio audio { width: 100%; height: 34px; margin-top: 4px; }
.embed { margin-top: 6px; max-width: 480px; border-radius: 8px; background: var(--bg-3); border-left: 4px solid var(--ec); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 4px; }
[data-theme="light"] .embed { background: var(--bg-1); }
.embed-site { font-size: .74em; color: var(--muted); }
.embed-title { font-weight: 700; color: var(--blue); }
.embed-desc { font-size: .86em; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.embed-img { margin-top: 6px; border-radius: 6px; max-height: 260px; object-fit: cover; }
.yt { position: relative; margin-top: 6px; border-radius: 8px; overflow: hidden; cursor: pointer; aspect-ratio: 16/9; background: #000; }
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: .85; }
.yt-play { position: absolute; inset: 0; margin: auto; width: 64px; height: 44px; border-radius: 12px; background: #f00; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.yt-frame { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 8px; margin-top: 6px; }
.poll { margin-top: 6px; max-width: 460px; padding: 14px; border-radius: 12px; background: var(--bg-3); border: 1px solid var(--border); }
[data-theme="light"] .poll { background: var(--bg-1); }
.poll-q { font-weight: 700; display: flex; gap: 8px; align-items: center; font-size: 1.02em; }
.poll-q .ic { color: var(--accent); }
.poll-hint { margin: 2px 0 10px; }
.poll-opt { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 8px 12px; margin-bottom: 6px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--border); overflow: hidden; text-align: left; transition: border .15s; }
.poll-opt:hover:not(:disabled) { border-color: var(--accent); }
.poll-opt.mine { border-color: var(--accent); }
.poll-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-soft); transition: width .5s var(--ease); }
.poll-opt.lead .poll-bar { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.poll-check { position: relative; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.poll-opt.mine .poll-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.poll-text { position: relative; flex: 1; font-weight: 500; }
.poll-pct { position: relative; font-size: .82em; font-weight: 700; color: var(--text-2); }
.poll-foot { margin-top: 4px; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.reaction { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border-radius: 8px; background: var(--bg-3); border: 1px solid transparent; font-size: .9em; transition: background .12s, border .12s, transform .1s; }
.reaction:hover { border-color: var(--muted); }
.reaction:active { transform: scale(.94); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction .r-emoji { font-size: 1.1em; line-height: 1; }
.reaction .emoji { width: 18px; height: 18px; vertical-align: 0; }
.reaction .r-count { font-weight: 700; font-size: .85em; color: var(--text-2); }
.reaction.mine .r-count { color: var(--accent-strong); }
.reaction.add { opacity: 0; color: var(--muted); }
.msg:hover .reaction.add { opacity: 1; }
.thread-chip { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px 10px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--border); font-size: .86em; max-width: 100%; }
.thread-chip:hover { border-color: var(--accent); }
.thread-chip b { color: var(--text); }
.thread-chip span:not(.muted) { color: var(--accent-strong); font-weight: 600; }
.msg-tools { position: absolute; right: 16px; top: -16px; display: none; align-items: center; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); padding: 2px; z-index: 2; }
.msg:hover .msg-tools { display: flex; }
.msg.editing .msg-tools, .msg.pending .msg-tools, .msg.system .msg-tools { display: none !important; }
.tool { width: 32px; height: 30px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 16px; }
.tool:hover { background: var(--hover-2); color: var(--text); }
.tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.edit-box { margin: 4px 0; }
.edit-input { width: 100%; border: 0; outline: 0; resize: none; background: var(--bg-3); border-radius: 8px; padding: 10px 12px; line-height: 1.4; color: var(--text); }
.edit-hint { margin-top: 4px; }
.jump-bar { position: absolute; left: 16px; right: 16px; bottom: 96px; height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-radius: 8px; background: var(--accent); color: #fff; font-size: .86em; z-index: 3; box-shadow: var(--shadow); }
.jump-bar.pulse { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { filter: brightness(1.2); } }
.new-pill { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; background: var(--accent); color: #fff; border-radius: 16px; padding: 6px 16px; font-weight: 700; font-size: .85em; box-shadow: var(--shadow); z-index: 3; animation: fadeUp .2s; }
.skeleton { padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.sk-row { display: flex; gap: 16px; }
.sk-av { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-3); flex-shrink: 0; }
.sk-lines { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.sk-line { height: 12px; border-radius: 6px; background: var(--bg-3); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 50% { opacity: .5; } }
html.compact .msg { grid-template-columns: 56px 1fr; }
html.compact .msg.head { margin-top: 6px; }
html.compact .msg .gutter .avatar { width: 24px !important; height: 24px !important; }
html.compact .msg .gutter .avatar span { font-size: 10px !important; }
html.compact .reply-ref { padding-left: 56px; }

/* composer */
.composer-wrap { padding: 0 16px 6px; position: relative; flex-shrink: 0; }
.composer { display: flex; align-items: flex-end; gap: 4px; background: var(--bg-3); border-radius: 12px; padding: 6px 8px; border: 1px solid transparent; transition: border .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.composer-input { flex: 1; min-height: 34px; max-height: 320px; resize: none; border: 0; outline: 0; background: none; padding: 7px 4px; line-height: 1.4; color: var(--text); }
.composer-input::placeholder { color: var(--muted); }
.composer-input:disabled { cursor: not-allowed; }
.cbtn { width: 34px; height: 34px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; transition: color .12s, background .12s, transform .1s; }
.cbtn:hover { color: var(--text); background: var(--hover-2); }
.cbtn.send { color: var(--accent); }
.cbtn.send:hover { background: var(--accent); color: #fff; }
.cbtn.waiting { animation: pulse 1s infinite; }
.composer-foot { display: flex; justify-content: space-between; align-items: center; min-height: 20px; padding: 2px 4px 0; }
.typing { font-size: .78em; color: var(--text-2); display: flex; align-items: center; gap: 6px; min-height: 18px; }
.typing .dots { display: inline-flex; gap: 3px; }
.typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-2); animation: typing 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .15s; } .typing .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }
.char-count { font-size: .75em; color: var(--muted); }
.char-count.over { color: var(--red); font-weight: 700; }
.reply-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--bg-1); border-radius: 12px 12px 0 0; font-size: .85em; color: var(--text-2); margin-bottom: -6px; padding-bottom: 14px; }
[data-theme="light"] .reply-bar { background: var(--bg-4); }
.files-row { display: flex; gap: 10px; padding: 10px; background: var(--bg-3); border-radius: 12px 12px 0 0; margin-bottom: -8px; padding-bottom: 16px; overflow-x: auto; }
.file-chip { position: relative; width: 150px; flex-shrink: 0; background: var(--bg-2); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.file-chip img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; }
.file-chip.spoiler img { filter: blur(12px); }
.file-chip-ic { height: 90px; display: flex; align-items: center; justify-content: center; color: var(--accent); background: var(--bg-3); border-radius: 6px; }
.file-chip-name { font-size: .78em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip.error { box-shadow: inset 0 0 0 2px var(--red); }
.file-progress { height: 4px; border-radius: 2px; background: var(--bg-4); overflow: hidden; }
.file-progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.file-chip-tools { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; background: var(--bg-2); border-radius: 6px; padding: 2px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.autocomplete { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; max-height: 340px; overflow-y: auto; z-index: 20; }
.ac-head { font-size: .7em; font-weight: 700; text-transform: uppercase; color: var(--muted); padding: 4px 8px 6px; letter-spacing: .04em; }
.ac-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 8px; text-align: left; }
.ac-item.sel { background: var(--hover-2); }
.ac-label { font-weight: 600; }
.ac-sub { color: var(--muted); font-size: .85em; }
.ac-desc { color: var(--muted); font-size: .85em; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-emoji { font-size: 20px; width: 24px; text-align: center; }

/* stage (voice/video) */
.content-area.voice-mode { background: #0b0c10; }
[data-theme="light"] .content-area.voice-mode { background: #16171d; color: #ececf1; }
.stage-host { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.call-host { height: 46%; min-height: 240px; max-height: 520px; display: flex; flex-direction: column; background: #0b0c10; color: #ececf1; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.stage { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 16px; gap: 12px; }
.stage-join { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; color: #ececf1; }
.stage-join-ic { width: 88px; height: 88px; border-radius: 50%; background: rgba(255,255,255,.08); display: flex; align-items: center; justify-content: center; }
.stage-join h2 { font-size: 1.6em; }
.stage.compact .stage-join { gap: 8px; }
.stage.compact .stage-join-ic { width: 56px; height: 56px; }
.stage-avatars { display: flex; }
.stage-avatars .avatar { margin-left: -8px; box-shadow: 0 0 0 3px #0b0c10; }
.stage-avatars .avatar:first-child { margin-left: 0; }
.tiles { flex: 1; display: grid; gap: 10px; min-height: 0; overflow-y: auto; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); grid-auto-rows: auto; align-content: center; }
.tiles[data-n="1"] { grid-template-columns: minmax(0, 900px); justify-content: center; }
.tiles[data-n="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tiles.has-focus { display: flex; flex-direction: column; }
.tile-focus { flex: 1; min-height: 0; display: flex; }
.tile-focus .tile { flex: 1; }
.tile-strip { display: flex; gap: 8px; height: 120px; flex-shrink: 0; overflow-x: auto; }
.tile-strip .tile { width: 200px; flex-shrink: 0; }
.tile { position: relative; border-radius: 14px; overflow: hidden; background: color-mix(in srgb, var(--c, #7c5cff) 35%, #15161b); display: flex; align-items: center; justify-content: center; min-height: 120px; cursor: pointer; transition: box-shadow .15s; aspect-ratio: 16/9; max-height: 100%; }
.tile.speaking { box-shadow: 0 0 0 3px var(--green), 0 0 24px color-mix(in srgb, var(--green) 40%, transparent); }
.tile.has-video { background: #000; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.screen video { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }
.tile-av .avatar { box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.tile-label { position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: .82em; font-weight: 600; backdrop-filter: blur(6px); max-width: calc(100% - 20px); }
.tile-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-full { position: absolute; right: 8px; top: 8px; background: rgba(0,0,0,.5); color: #fff; opacity: 0; }
.tile:hover .tile-full { opacity: 1; }
.stage-controls { display: flex; justify-content: center; gap: 12px; flex-shrink: 0; }
.sbtn { width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; display: inline-flex; align-items: center; justify-content: center; transition: background .15s, transform .1s; }
.sbtn:hover { background: rgba(255,255,255,.2); }
.sbtn:active { transform: scale(.95); }
.sbtn.on { background: #fff; color: #111; }
.sbtn.off { background: rgba(242,85,90,.25); color: var(--red); }
.sbtn.danger { background: var(--red); }
.sbtn.danger:hover { filter: brightness(1.1); }
.stage.compact { padding: 10px; }
.stage.compact .sbtn { width: 42px; height: 42px; }
.stage.compact .tile { min-height: 80px; }

/* home & discover */
.home, .discover { flex: 1; overflow-y: auto; padding: 24px 32px; }
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.home-head h2 { font-size: 1.6em; font-weight: 800; letter-spacing: -.02em; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { padding: 6px 14px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: .9em; }
.tab:hover { background: var(--hover); color: var(--text); }
.tab.active { background: var(--hover-2); color: var(--text); }
.people-list { margin-top: 8px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; border-top: 1px solid var(--border); cursor: pointer; }
.person:hover { background: var(--hover); border-top-color: transparent; }
.person:hover + .person { border-top-color: transparent; }
.person-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-actions { display: flex; gap: 8px; }
.activity { margin-top: 28px; }
.activity h3 { margin-bottom: 10px; }
.activity-card { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 12px; background: var(--bg-3); margin-bottom: 8px; width: 100%; text-align: left; }
.activity-card:hover { background: var(--bg-4); }
.activity .stage-avatars .avatar { box-shadow: 0 0 0 3px var(--bg-3); }
.empty { text-align: center; padding: 40px 16px; }
.empty-art { font-size: 48px; margin-bottom: 10px; }
.result-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.home .result-list { padding: 0; overflow: visible; }
.result { position: relative; padding: 10px 12px; border-radius: 10px; background: var(--bg-3); cursor: pointer; border: 1px solid transparent; }
[data-theme="light"] .result { background: var(--bg-1); }
.result:hover { border-color: var(--border); background: var(--bg-4); }
.result-where { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.result-msg { display: flex; gap: 10px; }
.result-body { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.result-imgs { display: flex; gap: 4px; margin-top: 6px; }
.result-imgs img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }
.result-x { position: absolute; top: 6px; right: 6px; opacity: 0; }
.result:hover .result-x { opacity: 1; }
.thread-card.archived { opacity: .6; }
.search-hint { padding: 10px 12px 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.discover { padding: 0 0 32px; }
.discover-hero { padding: 48px 32px 32px; text-align: center; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 70%, #000), #3a1048); color: #fff; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.discover-hero h2 { font-size: 2em; font-weight: 800; letter-spacing: -.02em; }
.discover-hero .input { max-width: 520px; margin-top: 10px; background: #fff; color: #111; }
.discover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 24px 32px; }
.disc-card { border-radius: 14px; overflow: hidden; background: var(--bg-1); border: 1px solid var(--border); transition: transform .15s, box-shadow .15s; }
.disc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.disc-banner { height: 96px; }
.disc-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.disc-body .srv-icon { margin-top: -28px; border: 4px solid var(--bg-1); border-radius: 16px; width: 64px; height: 64px; background: var(--c); color: #fff; }
.disc-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.disc-foot .btn { margin-left: auto; }

/* members & profile */
.member-list { flex: 1; overflow-y: auto; padding: 0 8px 16px; }
.member { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.member:hover { background: var(--hover); }
.member.offline { opacity: .45; }
.member.offline:hover { opacity: 1; }
.member-meta { min-width: 0; flex: 1; }
.member-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.member-sub { font-size: .75em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown { color: var(--yellow); }
.profile-card { width: 320px; background: var(--bg-1); border-radius: 14px; overflow: hidden; position: relative; }
.profile-card.panel { width: 100%; border-radius: 0; flex: 1; overflow-y: auto; }
.profile-card.mini { width: 100%; background: transparent; }
.pc-banner { height: 92px; }
.profile-card.mini .pc-banner { height: 56px; border-radius: 10px; }
.pc-av { position: absolute; left: 16px; top: 46px; border-radius: 50%; padding: 6px; background: var(--bg-1); }
.profile-card.mini .pc-av { top: 22px; left: 10px; background: var(--bg-2); padding: 4px; }
.pc-av .status-dot { border-color: var(--bg-1); }
.pc-body { padding: 52px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.profile-card.mini .pc-body { padding: 42px 10px 4px; }
.pc-name { font-size: 1.25em; font-weight: 800; letter-spacing: -.01em; }
.pc-user { color: var(--text-2); font-size: .9em; }
.pc-status { margin-top: 6px; padding: 8px 10px; background: var(--bg-3); border-radius: 8px; font-size: .9em; }
.pc-section { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.pc-section .label { margin: 0 0 4px; }
.pc-bio { white-space: pre-wrap; font-size: .9em; }
.pc-note { width: 100%; resize: none; background: transparent; border: 0; outline: 0; font-size: .85em; color: var(--text-2); padding: 4px; border-radius: 6px; }
.pc-note:focus { background: var(--bg-0); }
.pc-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pc-quick { height: 36px; font-size: .88em; }
.pc-voice { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); font-size: .85em; text-align: left; display: flex; align-items: center; gap: 4px; }
.pc-warn { margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--yellow) 18%, transparent); font-size: .85em; }
.role-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; background: var(--bg-3); font-size: .78em; font-weight: 500; }
.role-chip.add { padding: 2px 9px; font-weight: 700; }
.role-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ------------------------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; opacity: 0; transition: opacity .18s; }
.overlay.in { opacity: 1; }
.modal { background: var(--bg-2); border-radius: var(--radius-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); transform: scale(.96) translateY(8px); transition: transform .22s var(--ease); overflow: hidden; }
.overlay.in .modal { transform: none; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 20px 8px; }
.modal-head h2 { font-size: 1.3em; font-weight: 800; }
.modal-head p { margin-top: 4px; font-size: .9em; }
.modal-body { padding: 8px 20px 20px; overflow-y: auto; min-height: 0; }
.modal-body.nopad { padding: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--bg-1); }
.modal-foot.inline { margin: 16px -20px -20px; }
.settings-modal { max-width: 1040px !important; height: min(760px, calc(100vh - 32px)); }
.settings-modal .modal-body { flex: 1; display: flex; }
.settings-layout { display: flex; flex: 1; min-height: 0; position: relative; width: 100%; }
.settings-nav { width: 220px; flex-shrink: 0; background: var(--bg-1); padding: 24px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .72em; font-weight: 800; text-transform: uppercase; color: var(--muted); padding: 0 10px 8px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sep { height: 1px; background: var(--border); margin: 8px 10px; }
.settings-tab { text-align: left; padding: 8px 10px; border-radius: 6px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.settings-tab:hover { background: var(--hover); color: var(--text); }
.settings-tab.active { background: var(--hover-2); color: var(--text); }
.settings-tab.danger { color: var(--red); }
.settings-pane { flex: 1; overflow-y: auto; padding: 28px 40px 40px; min-width: 0; }
.settings-pane h2 { font-size: 1.35em; font-weight: 800; margin-bottom: 16px; }
.settings-pane h3 { font-size: 1em; margin-bottom: 8px; }
.settings-close { position: absolute; right: 16px; top: 16px; border: 2px solid var(--muted); border-radius: 50%; width: 36px; height: 36px; }
.section { margin: 20px 0; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.account-card { max-width: 420px; background: var(--bg-1); border-radius: 12px; padding: 8px; }
.profile-edit { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.profile-preview { width: 320px; }
.profile-preview .profile-card { box-shadow: var(--shadow); }
.theme-row, .accent-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.theme-swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .85em; color: var(--text-2); }
.theme-swatch i { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--border); display: block; }
.theme-swatch.active i { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-swatch.active { color: var(--text); font-weight: 600; }
.accent-swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; }
.accent-swatch.active { border-color: var(--text); }
.meter { height: 10px; border-radius: 5px; background: var(--bg-4); overflow: hidden; margin-bottom: 8px; }
.meter i { display: block; height: 100%; width: 0; background: var(--green); transition: width .08s; }
.cam-preview { width: 100%; max-width: 360px; border-radius: 12px; background: #000; margin: 8px 0; transform: scaleX(-1); min-height: 0; }
.cam-preview:not([src]):not([srcObject]) { aspect-ratio: 16/9; }
.warn-box { margin-top: 16px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--yellow) 15%, transparent); }
.md-cheats { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 16px; }
.md-cheat { display: flex; justify-content: space-between; gap: 8px; font-size: .9em; padding: 4px 0; border-bottom: 1px solid var(--border); }
.about { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.about-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.roles-layout { display: flex; gap: 20px; margin-top: 12px; align-items: flex-start; }
.role-list { width: 200px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; }
.role-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; text-align: left; }
.role-item span { margin-left: auto; }
.role-item:hover { background: var(--hover); }
.role-item.active { background: var(--hover-2); font-weight: 600; }
.role-editor { flex: 1; min-width: 0; }
.admin-list, .admin-members { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; }
.admin-row, .admin-member { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-1); }
.admin-row code { font-size: .85em; }
.emoji-admin { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 16px; }
.emoji-admin-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--bg-1); }
.emoji-admin-row img { width: 32px; height: 32px; object-fit: contain; }
.emoji-admin-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; font-size: .82em; }
.icon-upload { width: 80px; height: 80px; border-radius: 50%; border: 2px dashed var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 10px; font-weight: 800; overflow: hidden; flex-shrink: 0; }
.icon-upload.big { width: 100px; height: 100px; }
.icon-upload:hover { border-color: var(--accent); color: var(--accent); }
.icon-upload img { width: 100%; height: 100%; object-fit: cover; }
.banner-upload { height: 100px; border-radius: 12px; border: 2px dashed var(--muted); background-size: cover; background-position: center; color: var(--muted); font-weight: 600; }
.danger-zone { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--border); }
.template-list { display: flex; flex-direction: column; gap: 8px; }
.template { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); text-align: left; transition: background .12s; }
.template:hover { background: var(--hover); }
.template > div { flex: 1; }
.tpl-emo { font-size: 26px; width: 44px; height: 44px; border-radius: 12px; background: var(--bg-3); display: flex; align-items: center; justify-content: center; }
.join-box { margin-top: 12px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.invite-people { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.invite-person { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.invite-person span { flex: 1; }
.radio-list { display: flex; flex-direction: column; gap: 6px; }
.radio-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg-1); cursor: pointer; }
.radio-row:hover { background: var(--hover-2); }
.radio-row input { accent-color: var(--accent); width: 18px; height: 18px; }
.pick-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.pick-row:hover { background: var(--hover); }
.pick-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.pick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 14px; background: var(--accent-soft); font-size: .85em; font-weight: 600; }
.chip button { width: 18px; height: 18px; border-radius: 50%; line-height: 1; }
.chip button:hover { background: var(--hover-2); }
.poll-opts-edit { display: flex; flex-direction: column; gap: 6px; }
.sched-list { display: flex; flex-direction: column; gap: 6px; }
.sched-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: var(--bg-1); }
.sched-item > div { flex: 1; min-width: 0; }
.history { display: flex; flex-direction: column; gap: 10px; }
.history-item { padding: 10px 12px; border-radius: 10px; background: var(--bg-1); }
.history-item.current { box-shadow: inset 3px 0 0 var(--accent); }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 24px; }
.shortcut { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .92em; }
.profile-modal { max-width: 360px !important; }
.profile-modal .profile-card { width: 100%; }

/* palette */
.modal.palette { max-width: 600px; align-self: flex-start; margin-top: 12vh; }
.palette-input { width: 100%; height: 56px; border: 0; outline: 0; background: var(--bg-0); border-radius: 10px; padding: 0 16px; font-size: 1.1em; margin-top: 12px; }
[data-theme="light"] .palette-input { background: var(--bg-3); }
.palette-list { margin-top: 10px; display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 8px; text-align: left; color: var(--text-2); }
.palette-item.sel { background: var(--hover-2); color: var(--text); }
.pi-label { font-weight: 600; flex-shrink: 0; }
.pi-label.unread { color: var(--text); }
.pi-sub { margin-left: auto; font-size: .78em; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.palette-foot { display: flex; gap: 16px; margin-top: 12px; }

/* menus / popovers / toasts */
.menu { position: fixed; z-index: 200; min-width: 200px; max-width: 340px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; animation: pop .14s var(--ease); max-height: calc(100vh - 16px); overflow-y: auto; }
[data-theme="dark"] .menu, [data-theme="midnight"] .menu { background: #111216; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 6px; text-align: left; font-size: .9em; color: var(--text-2); font-weight: 500; }
.menu-item:hover { background: var(--accent); color: #fff; }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red); color: #fff; }
.menu-item.active { color: var(--text); font-weight: 700; }
.menu-item.active::after { content: '●'; margin-left: auto; color: var(--accent); font-size: .7em; }
.menu-item:hover.active::after { color: #fff; }
.menu-label { flex: 1; }
.menu-hint { font-size: .78em; opacity: .7; }
.ic-spacer { width: 16px; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.menu-head { font-size: .7em; font-weight: 800; text-transform: uppercase; color: var(--muted); padding: 6px 8px 2px; letter-spacing: .04em; }
.popover.profile-pop { padding: 0; border-radius: 14px; overflow: hidden; max-width: 320px; }
.popover.emoji-pop { padding: 0; max-width: none; }
.emoji-picker { width: 360px; height: 420px; display: flex; flex-direction: column; }
.emoji-search { margin: 10px; width: calc(100% - 20px); height: 36px; }
.emoji-tabs { display: flex; gap: 2px; padding: 0 8px 6px; border-bottom: 1px solid var(--border); }
.emoji-tab { flex: 1; height: 30px; border-radius: 6px; font-size: 17px; filter: grayscale(.6); }
.emoji-tab:hover { background: var(--hover-2); filter: none; }
.emoji-grid { flex: 1; overflow-y: auto; padding: 4px 8px; }
.emoji-cat { font-size: .7em; font-weight: 800; text-transform: uppercase; color: var(--muted); padding: 8px 4px 4px; letter-spacing: .04em; position: sticky; top: 0; background: inherit; }
.emoji-section { display: grid; grid-template-columns: repeat(9, 1fr); }
.emoji-cell { height: 38px; border-radius: 8px; font-size: 24px; display: flex; align-items: center; justify-content: center; transition: transform .1s; }
.emoji-cell:hover { background: var(--hover-2); transform: scale(1.12); }
.emoji-cell img { width: 28px; height: 28px; object-fit: contain; }
.emoji-preview { height: 40px; border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 12px; font-size: .9em; color: var(--text-2); font-weight: 600; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--bg-4); color: var(--text); box-shadow: var(--shadow); font-weight: 500; font-size: .92em; opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .2s, transform .2s var(--ease); max-width: 520px; }
[data-theme="dark"] .toast, [data-theme="midnight"] .toast { background: #2b2c36; }
.toast.in { opacity: 1; transform: none; }
.toast.error { background: var(--red); color: #fff; }
.toast.success { background: #1f9d63; color: #fff; }
.toast.warn { background: var(--yellow); color: #3b2b00; }
.toast.call { background: var(--bg-1); padding: 14px 16px; border: 1px solid var(--border); }
.toast-actions { display: flex; gap: 6px; }
.toast-msg { display: flex; align-items: center; gap: 10px; }
.ring { display: flex; align-items: center; gap: 12px; }
.lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.lb-img { max-width: 92vw; max-height: 84vh; object-fit: contain; border-radius: 6px; cursor: zoom-out; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lb-cap { position: absolute; bottom: 16px; left: 0; right: 0; display: flex; justify-content: center; gap: 16px; color: #ddd; font-size: .9em; }
.lb-open { color: #fff; }
.lb-close { position: absolute; top: 16px; right: 16px; color: #fff; background: rgba(255,255,255,.1); width: 44px; height: 44px; border-radius: 50%; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; font-size: 32px; line-height: 1; }
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-nav.prev { left: 20px; } .lb-nav.next { right: 20px; }
.scrim { display: none; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .right-panel { position: absolute; right: 0; top: 52px; bottom: 0; z-index: 30; box-shadow: var(--shadow); display: none; }
  .shell.right-open .right-panel:not(.hidden) { display: flex; }
  .head-search { width: 120px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 50; transition: transform .25s var(--ease); }
  .rail { left: 0; width: var(--rail-w); transform: translateX(-100%); }
  .sidebar { left: var(--rail-w); width: min(300px, calc(100vw - var(--rail-w) - 40px)); transform: translateX(calc(-100% - var(--rail-w))); }
  .shell.nav-open .rail, .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim, .shell.right-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
  .right-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100vw) !important; z-index: 50; }
  .mobile-only { display: inline-flex !important; }
  .head-search-wrap, .head-topic, .head-sep { display: none; }
  .head-tools .icon-btn[title="Inbox"], .head-tools .icon-btn[title="Saved Items"] { display: none; }
  .msg { grid-template-columns: 56px 1fr; padding-right: 12px; }
  .reply-ref { padding-left: 56px; }
  .msg-tools { right: 8px; }
  .composer-wrap { padding: 0 8px calc(6px + env(safe-area-inset-bottom)); }
  .home { padding: 16px; }
  .auth-wrap { flex-direction: column; }
  .auth-card { flex: none; }
  .auth-side { display: none; }
  .settings-layout { flex-direction: column; }
  .settings-nav { width: 100%; flex-direction: row; overflow-x: auto; padding: 10px; }
  .nav-label, .nav-sep { display: none; }
  .settings-tab { white-space: nowrap; }
  .settings-pane { padding: 20px 16px; }
  .settings-close { top: 8px; right: 8px; }
  .roles-layout { flex-direction: column; }
  .role-list { width: 100%; }
  .tiles { grid-template-columns: 1fr 1fr !important; }
  .emoji-picker { width: min(360px, calc(100vw - 16px)); }
  .modal.palette { margin-top: 8px; }
}
