/* ===== Theme tokens =====
   Nullcord's identity: graphite neutrals, a monochrome brand (white on dark, ink on light — like the logo)
   and an acid-lime signal colour for mentions, focus and "new" states. */
:root {
  --chat-font: 16px;
  --brand: #f2f2f0; --brand-hover: #ffffff; --on-brand: #0a0a0b;
  --accent: #c8f560; --on-accent: #10140a; --link: #9cc2ff;
  --green: #3fcf8e; --green-hover: #2fb07a; --yellow: #f5c451; --red: #ff5a5f; --red-hover: #e5484d;
  --font: 'Geist', 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --code-font: 'Geist Mono', 'JetBrains Mono', Consolas, 'Lucida Console', monospace;
}
body[data-theme="dark"] {
  --bg-rail: #09090b; --bg-side: #101012; --bg-main: #151517; --bg-panel: #0d0d0f; --bg-float: #08080a;
  --bg-input: #1d1d21; --bg-hover: rgba(255, 255, 255, .05); --bg-active: rgba(255, 255, 255, .09); --bg-msg-hover: #18181b;
  --bg-mod: #09090b; --bg-card: #111113; --bg-modal: #151517; --bg-modal-foot: #101012;
  --text: #d8d8dc; --text-strong: #f6f6f4; --text-muted: #8c8c95; --text-faint: #5c5c64; --icon: #a1a1a9; --icon-hover: #f2f2f0;
  --border: #26262b; --divider: rgba(255, 255, 255, .07); --mention-bg: rgba(200, 245, 96, .06); --mention-bar: #c8f560;
  --mention-pill: rgba(200, 245, 96, .14); --mention-pill-text: #e1fba0; --code-bg: #0f0f11; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --scroll: #26262b; --scroll-track: #101012;
  color-scheme: dark;
}
body[data-theme="midnight"] {
  --bg-rail: #000; --bg-side: #050505; --bg-main: #000; --bg-panel: #050505; --bg-float: #000;
  --bg-input: #101010; --bg-hover: rgba(255, 255, 255, .05); --bg-active: rgba(255, 255, 255, .09); --bg-msg-hover: #070707;
  --bg-mod: #000; --bg-card: #0a0a0a; --bg-modal: #050505; --bg-modal-foot: #0a0a0a;
  --text: #d8d8dc; --text-strong: #fff; --text-muted: #8c8c95; --text-faint: #5c5c64; --icon: #a1a1a9; --icon-hover: #fff;
  --border: #1c1c1f; --divider: #151517; --mention-bg: rgba(200, 245, 96, .05); --mention-bar: #c8f560;
  --mention-pill: rgba(200, 245, 96, .14); --mention-pill-text: #e1fba0; --code-bg: #0a0a0a; --shadow: 0 10px 30px rgba(0, 0, 0, .6);
  --scroll: #1c1c1f; --scroll-track: #050505;
  color-scheme: dark;
}
body[data-theme="light"] {
  --brand: #111113; --brand-hover: #000; --on-brand: #fff; --accent: #4d7c0f; --on-accent: #fff; --link: #1d4ed8;
  --bg-rail: #e9e9e6; --bg-side: #f3f3f1; --bg-main: #fbfbfa; --bg-panel: #ececea; --bg-float: #fff;
  --bg-input: #ececea; --bg-hover: rgba(17, 17, 19, .05); --bg-active: rgba(17, 17, 19, .09); --bg-msg-hover: #f4f4f2;
  --bg-mod: #e9e9e6; --bg-card: #f3f3f1; --bg-modal: #fff; --bg-modal-foot: #f3f3f1;
  --text: #2a2a2e; --text-strong: #0a0a0b; --text-muted: #63636b; --text-faint: #8a8a92; --icon: #55555c; --icon-hover: #111113;
  --border: #deded9; --divider: #e2e2de; --mention-bg: rgba(101, 163, 13, .08); --mention-bar: #65a30d;
  --mention-pill: rgba(101, 163, 13, .14); --mention-pill-text: #3f6212; --code-bg: #f0f0ee; --shadow: 0 10px 30px rgba(0, 0, 0, .1);
  --scroll: #cfcfca; --scroll-track: #f3f3f1;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); background: var(--bg-main); color: var(--text); font-size: 16px; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: var(--text); }
a { color: var(--link); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.pad { padding: 16px; }
.grow { flex: 1; }
.green { color: var(--green); }
.red { color: var(--red); }
.ic { flex-shrink: 0; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar { width: 16px; }
.messages::-webkit-scrollbar-thumb { border: 4px solid var(--bg-main); border-radius: 8px; }
.messages::-webkit-scrollbar-track { background: var(--scroll-track); border: 4px solid var(--bg-main); border-radius: 8px; }

/* ===== Buttons ===== */
.btn { border: 0; border-radius: 3px; padding: 2px 16px; height: 38px; min-width: 96px; font-size: 14px; font-weight: 500; color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .17s; }
.btn-sm { height: 32px; min-width: 60px; }
.btn-block { width: 100%; height: 44px; font-size: 16px; }
.btn-brand { background: var(--brand); color: var(--on-brand); } .btn-brand:hover { background: var(--brand-hover); }
.btn-green { background: var(--green); } .btn-green:hover { background: var(--green-hover); }
.btn-red { background: var(--red); } .btn-red:hover { background: var(--red-hover); }
.btn-grey { background: #4e5058; } .btn-grey:hover { background: #6d6f78; }
.btn-link { background: none; color: var(--text); min-width: 0; } .btn-link:hover { text-decoration: underline; }
.btn-red-outline { background: none; border: 1px solid var(--red); color: var(--red); } .btn-red-outline:hover { background: var(--red); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--link); padding: 0; display: inline-flex; gap: 4px; align-items: center; font-size: 14px; }
.icon-btn { background: none; border: 0; color: var(--icon); padding: 4px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: var(--icon-hover); background: var(--bg-hover); }
.icon-btn.on { color: var(--text-strong); }
.icon-btn.danger { color: var(--red); }
.icon-btn .slash { stroke: var(--red); }

/* ===== Auth ===== */
.auth { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 20px; overflow-y: auto; background-color: #050506; background-image: radial-gradient(circle at 15% 12%, rgba(200, 245, 96, .12), transparent 38%), radial-gradient(circle at 88% 90%, rgba(255, 255, 255, .07), transparent 45%), linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px); background-size: auto, auto, 32px 32px, 32px 32px; }
.auth-card { background: rgba(16, 16, 18, .92); color: #d8d8dc; border: 1px solid #222226; border-radius: 14px; padding: 32px; width: 480px; max-width: 100%; box-shadow: 0 24px 60px rgba(0, 0, 0, .55); backdrop-filter: blur(8px); }
.auth h1 { color: #f6f6f4; text-align: center; font-size: 24px; margin: 0 0 8px; }
.auth .sub { color: #9a9aa3; text-align: center; margin: 0 0 20px; }
.auth label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: #9a9aa3; margin-bottom: 20px; letter-spacing: .02em; }
.auth input { display: block; width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid #26262b; border-radius: 8px; background: #1b1b1f; font-size: 16px; color: #d8d8dc; outline: none; }
.req { color: var(--red); }
.auth-error { color: #fa777c; font-size: 14px; min-height: 18px; margin: -8px 0 8px; }
.auth-switch { font-size: 14px; color: #8c8c95; margin: 12px 0 0; }

/* ===== Layout ===== */
.app { display: flex; height: 100vh; height: 100dvh; }
.rail { width: 72px; background: var(--bg-rail); padding: 12px 0; overflow-y: auto; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.sidebar { width: 240px; background: var(--bg-side); display: flex; flex-direction: column; flex-shrink: 0; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-main); }
.main-body { flex: 1; display: flex; min-height: 0; }

/* ===== Rail ===== */
.rail-item { position: relative; width: 72px; display: flex; justify-content: center; }
.rail-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--bg-main); color: var(--text); display: flex; align-items: center; justify-content: center; font-weight: 500; overflow: hidden; transition: border-radius .15s, background .15s, color .15s; cursor: pointer; user-select: none; }
.rail-icon img { width: 100%; height: 100%; object-fit: cover; }
.rail-icon.av { background: none; }
.rail-item:hover .rail-icon, .rail-item.active .rail-icon { border-radius: 16px; background: var(--brand); color: var(--on-brand); }
.rail-item:hover .rail-icon.has-img, .rail-item.active .rail-icon.has-img { background: none; }
.rail-icon.green { color: var(--green); }
.rail-item:hover .rail-icon.green { background: var(--green); color: #fff; }
.pill { position: absolute; left: 0; top: 50%; width: 8px; height: 0; margin-top: 0; background: var(--text-strong); border-radius: 0 4px 4px 0; margin-left: -4px; transition: height .15s, margin-top .15s; }
.pill.unread { height: 8px; margin-top: -4px; }
.rail-item:hover .pill { height: 20px; margin-top: -10px; }
.rail-item.active .pill { height: 40px; margin-top: -20px; }
.badge { position: absolute; bottom: -2px; right: 10px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 4px var(--bg-rail); }
.rail-voice { position: absolute; bottom: -2px; right: 10px; background: var(--green); color: #fff; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px var(--bg-rail); }
.rail-sep { width: 32px; height: 2px; background: var(--divider); border-radius: 1px; flex-shrink: 0; }

/* ===== Sidebar ===== */
.sidebar-header { height: 48px; flex-shrink: 0; display: flex; align-items: center; 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; }
.search-btn { margin: 0 10px; width: 100%; height: 28px; border: 0; border-radius: 4px; background: var(--bg-rail); color: var(--text-muted); font-size: 14px; text-align: left; padding: 0 6px; }
.server-header { width: 100%; height: 100%; background: none; border: 0; color: var(--text-strong); font-weight: 600; font-size: 16px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.server-header:hover { background: var(--bg-hover); }
.sidebar-body { flex: 1; overflow-y: auto; padding: 8px 8px 8px 8px; }
.sidebar-body::-webkit-scrollbar { width: 4px; }
.nav-item, .dm-item, .chan { display: flex; align-items: center; gap: 12px; color: var(--text-muted); border-radius: 4px; cursor: pointer; position: relative; }
.nav-item { padding: 8px 8px 8px 12px; font-weight: 500; height: 42px; margin-bottom: 8px; }
.nav-item:hover, .dm-item:hover, .chan:hover { background: var(--bg-hover); color: var(--icon-hover); }
.nav-item.active, .dm-item.active, .chan.active { background: var(--bg-active); color: var(--text-strong); }
.dm-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 8px 4px 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: .02em; }
.dm-head:hover span { color: var(--icon-hover); }
.dm-item { padding: 0 8px; height: 42px; margin-bottom: 2px; }
.dm-item.unread .dm-name { color: var(--text-strong); font-weight: 600; }
.dm-text { flex: 1; min-width: 0; }
.dm-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; font-weight: 500; }
.dm-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.dm-sub.green { color: var(--green); }
.dm-close { display: none; background: none; border: 0; color: var(--icon); padding: 0; }
.dm-item:hover .dm-close { display: flex; }
.dm-close:hover { color: var(--text-strong); }
.empty-dms .ph { height: 42px; margin: 4px 0; border-radius: 4px; background: linear-gradient(90deg, var(--bg-hover) 30px, transparent 30px, transparent 40px, var(--bg-hover) 40px); opacity: .5; }
.count-badge { background: var(--red); color: #fff; border-radius: 8px; font-size: 12px; font-weight: 700; min-width: 16px; height: 16px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; margin-left: auto; }
.cat { margin-top: 16px; }
.cat:first-child { margin-top: 4px; }
.cat-head { display: flex; align-items: center; gap: 2px; padding: 0 0 4px 0; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); cursor: pointer; letter-spacing: .02em; user-select: none; }
.cat-head span:nth-child(2) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-head:hover { color: var(--icon-hover); }
.cat-arrow { display: flex; transition: transform .15s; }
.cat-arrow.coll { transform: rotate(-90deg); }
.cat-head .icon-btn { padding: 0; }
.chan { height: 34px; padding: 0 8px; margin: 1px 0; gap: 6px; }
.chan .chan-ic { color: var(--text-faint); }
.chan-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.chan.unread { color: var(--text-strong); }
.chan.unread .chan-name { font-weight: 600; }
.unread-dot { position: absolute; left: -8px; width: 8px; height: 8px; border-radius: 0 4px 4px 0; background: var(--text-strong); }
.chan-actions { display: none; gap: 2px; }
.chan-actions .icon-btn { padding: 0; }
.chan:hover .chan-actions, .chan.active .chan-actions { display: flex; }
.voice-users { padding: 0 0 6px 32px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 4px; color: var(--text-muted); font-size: 14px; cursor: pointer; }
.voice-user:hover { background: var(--bg-hover); color: var(--icon-hover); }
.vu-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vu-av { border-radius: 50%; display: flex; box-shadow: 0 0 0 0 var(--green); transition: box-shadow .1s; }
.vu-av.speaking { box-shadow: 0 0 0 2px var(--green); }
.vu-ic.red { color: var(--red); }
.live { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 8px; padding: 0 6px; line-height: 16px; }

/* user & voice panels */
.voice-panel { background: var(--bg-panel); border-bottom: 1px solid var(--divider); padding: 8px; }
.vp-row { display: flex; align-items: center; }
.vp-info { flex: 1; min-width: 0; cursor: pointer; }
.vp-status { color: var(--green); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.vp-where { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vp-info:hover .vp-where { text-decoration: underline; }
.vp-btns { display: flex; gap: 8px; margin-top: 8px; }
.vp-btn { flex: 1; background: var(--bg-input); border: 0; color: var(--text); border-radius: 4px; height: 32px; display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 14px; }
.vp-btn:hover { background: var(--bg-active); }
.vp-btn.on { background: var(--green); color: #fff; }
.user-panel { height: 52px; background: var(--bg-panel); display: flex; align-items: center; padding: 0 8px; gap: 2px; flex-shrink: 0; }
.up-me { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 2px 4px 2px 2px; border-radius: 4px; cursor: pointer; }
.up-me:hover { background: var(--bg-hover); }
.up-text { min-width: 0; line-height: 1.2; }
.up-name { font-size: 14px; font-weight: 600; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-sub { font-size: 12px; color: var(--text-muted); height: 16px; overflow: hidden; }
.up-sub span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: transform .2s; }
.up-me:hover .up-sub span { transform: translateY(-100%); }

/* avatars */
.avatar { position: relative; flex-shrink: 0; border-radius: 50%; }
.avatar > img, .av-fallback { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av-fallback { display: flex; align-items: center; justify-content: center; color: #fff; }
.av-fallback .ic circle { fill: rgba(0, 0, 0, .25); }
.status-dot { position: absolute; right: -2px; bottom: -2px; width: 40%; height: 40%; max-width: 16px; max-height: 16px; min-width: 10px; min-height: 10px; border-radius: 50%; border: 3px solid var(--bg-side); background: var(--text-faint); }
.status-dot.static { position: static; display: inline-block; width: 10px; height: 10px; border: 0; vertical-align: middle; }
.s-online { background: var(--green); }
.s-idle { background: var(--yellow); }
.s-dnd { background: var(--red); }
.s-offline { background: #80848e; }
.user-panel .status-dot { border-color: var(--bg-panel); }
.members .status-dot { border-color: var(--bg-side); }
.friend-row .status-dot, .pc-av .status-dot { border-color: var(--bg-main); }
.pc-av .status-dot { border-width: 5px; max-width: 24px; max-height: 24px; }
.main-header .status-dot { border-color: var(--bg-main); }

/* ===== Header ===== */
.main-header { height: 48px; flex-shrink: 0; 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; }
.hd-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-strong); white-space: nowrap; }
.hd-title .muted { color: var(--text-faint); }
.clickable { cursor: pointer; } .clickable:hover { text-decoration: underline; }
.hd-div { width: 1px; height: 24px; background: var(--divider); margin: 0 8px; flex-shrink: 0; }
.hd-topic { color: var(--text-muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; cursor: pointer; min-width: 0; }
.hd-topic br { display: none; }
.hd-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tab { background: none; border: 0; color: var(--text-muted); padding: 2px 8px; border-radius: 4px; font-size: 16px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tab:hover { background: var(--bg-hover); color: var(--icon-hover); }
.tab.active { background: var(--bg-active); color: var(--text-strong); }
.tab.add { background: var(--accent); color: var(--on-accent); }
.tab.add.active { background: none; color: var(--accent); }
.search { position: relative; }
.search input { width: 144px; height: 24px; border: 0; border-radius: 4px; background: var(--bg-rail); padding: 0 24px 0 6px; font-size: 14px; outline: none; transition: width .25s; }
.search input:focus { width: 240px; }
.search .ic { position: absolute; right: 6px; top: 4px; color: var(--text-muted); }
.burger { display: none; }

/* ===== Chat ===== */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.messages { flex: 1; overflow-y: auto; overflow-x: hidden; font-size: var(--chat-font); padding-top: 16px; }
.msg-spacer { height: 24px; }
.loading-more { text-align: center; color: var(--text-muted); padding: 16px; font-size: 14px; }
.welcome { padding: 16px; margin: 0 0 8px; }
.welcome h1 { color: var(--text-strong); font-size: 32px; margin: 8px 0; }
.welcome p { color: var(--text-muted); margin: 0 0 8px; font-size: 16px; }
.welcome-ic { width: 68px; height: 68px; border-radius: 50%; background: #4e5058; color: #fff; display: flex; align-items: center; justify-content: center; }
.welcome-user { font-size: 22px; color: var(--text-strong); margin-bottom: 12px; }
.welcome-btns { display: flex; gap: 8px; margin-top: 12px; }
.day-div { display: flex; align-items: center; margin: 24px 16px 8px; height: 0; border-top: 1px solid var(--divider); justify-content: center; }
.day-div span { background: var(--bg-main); padding: 2px 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: -1px; }
.new-div { height: 0; border-top: 1px solid var(--red); margin: 8px 16px 8px; position: relative; }
.new-div span { position: absolute; right: -4px; top: -9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 0 4px 4px 0; line-height: 16px; }

.msg { position: relative; display: grid; grid-template-columns: 72px 1fr; padding: 2px 48px 2px 0; margin-top: 17px; line-height: 1.375; }
.msg.grouped { margin-top: 0; }
.msg:hover, .msg.editing { background: var(--bg-msg-hover); }
.msg.mentioned { background: var(--mention-bg); }
.msg.mentioned::before, .msg.replying::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--mention-bar); }
.msg.replying { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.msg.replying::before { background: var(--brand); }
.msg.flash { animation: flash 2s; }
@keyframes flash { 0%, 40% { background: color-mix(in srgb, var(--brand) 25%, transparent); } 100% { background: transparent; } }
.msg-gutter { display: flex; justify-content: center; padding-top: 2px; }
.msg:not(.grouped) .msg-gutter { cursor: pointer; }
.msg-gutter .avatar:active { transform: translateY(1px); }
.hover-ts { visibility: hidden; font-size: 11px; color: var(--text-muted); line-height: 22px; }
.msg:hover .hover-ts { visibility: visible; }
.msg-body { min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.author { font-weight: 500; color: var(--text-strong); cursor: pointer; }
.author:hover { text-decoration: underline; }
.ts { font-size: 12px; color: var(--text-muted); }
.bot-tag { background: var(--brand); color: var(--on-brand); font-size: 10px; font-weight: 600; border-radius: 3px; padding: 0 4px; display: inline-flex; align-items: center; gap: 2px; line-height: 15px; vertical-align: 1px; }
.msg-content { color: var(--text); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg-content.jumbo { font-size: 48px; line-height: 1.2; }
.edited { font-size: 10px; color: var(--text-muted); margin-left: 4px; }
.msg.system .msg-body { color: var(--text-muted); padding: 2px 0; }
.msg.system .msg-gutter { padding-top: 4px; }
.sys-text .mention { background: none; color: var(--text-strong); font-weight: 500; }
.reply-ref { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; font-size: 14px; color: var(--text-muted); padding-left: 72px; position: relative; cursor: pointer; margin-bottom: 4px; min-width: 0; }
.reply-spine { position: absolute; left: 36px; top: 9px; width: 33px; height: 13px; border-left: 2px solid #4e5058; border-top: 2px solid #4e5058; border-top-left-radius: 6px; }
.rr-name { font-weight: 500; white-space: nowrap; }
.rr-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-ref:hover .rr-text { color: var(--text-strong); }

.msg-toolbar { position: absolute; right: 14px; top: -16px; display: none; background: var(--bg-main); border: 1px solid var(--border); border-radius: 4px; box-shadow: 0 0 0 1px rgba(6, 6, 7, .08); z-index: 1; }
body[data-theme="dark"] .msg-toolbar { background: #313338; }
.msg:hover .msg-toolbar { display: flex; }
.msg.editing .msg-toolbar, .msg.system .msg-toolbar { display: none !important; }
.msg-toolbar button { background: none; border: 0; color: var(--icon); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.msg-toolbar button:hover { background: var(--bg-hover); color: var(--icon-hover); }
.tb-emoji { font-size: 18px; }
.tb-sep { width: 1px; background: var(--divider); margin: 6px 2px; }
.pinned-flag { position: absolute; right: 16px; top: 4px; color: var(--text-muted); }
.msg:hover .pinned-flag { display: none; }

/* markdown */
.msg-content strong { font-weight: 700; }
.mention { background: var(--mention-pill); color: var(--mention-pill-text); border-radius: 3px; padding: 0 2px; font-weight: 500; cursor: pointer; }
.mention:hover { background: var(--brand); color: var(--on-brand); }
code.inline { background: var(--code-bg); border-radius: 4px; padding: 0 .2em; font-family: var(--code-font); font-size: 85%; }
pre.codeblock { background: var(--code-bg); border: 1px solid var(--bg-rail); border-radius: 4px; padding: 8px; margin: 6px 0 0; max-width: 90%; overflow-x: auto; font-family: var(--code-font); font-size: 14px; white-space: pre-wrap; }
blockquote { margin: 0; padding: 0 8px 0 12px; border-left: 4px solid #4e5058; border-radius: 4px; }
.md-h1 { font-size: 1.5em; font-weight: 700; margin: 8px 0 4px; }
.md-h2 { font-size: 1.25em; font-weight: 700; margin: 8px 0 4px; }
.md-h3 { font-size: 1em; font-weight: 700; margin: 8px 0 4px; }
.spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; padding: 0 2px; }
.spoiler.revealed { background: var(--bg-hover); color: inherit; cursor: auto; }

/* attachments & embeds */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.att-img { max-width: min(400px, 100%); max-height: 350px; border-radius: 8px; cursor: pointer; display: block; }
.att-video { max-width: min(400px, 100%); border-radius: 8px; }
.att-file { display: flex; align-items: center; gap: 8px; background: var(--bg-side); border: 1px solid var(--bg-rail); border-radius: 8px; padding: 10px; max-width: 432px; color: var(--brand); }
.att-name { font-size: 16px; color: var(--link); word-break: break-all; }
.att-size { font-size: 12px; color: var(--text-muted); }
.att-file audio { margin-top: 6px; max-width: 300px; }
.embed { border-left: 4px solid #ff0000; background: var(--bg-side); border-radius: 4px; padding: 8px 16px 16px 12px; margin-top: 6px; max-width: 432px; }
.embed-provider { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.embed-title { font-weight: 600; font-size: 14px; display: block; margin-bottom: 8px; word-break: break-all; }
.embed-thumb { width: 100%; border-radius: 4px; display: block; }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.reaction { display: flex; align-items: center; gap: 6px; background: var(--bg-side); border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; color: var(--text-muted); font-size: 14px; height: 26px; }
.reaction:hover { border-color: var(--border); background: var(--bg-input); }
.reaction.me { background: color-mix(in srgb, var(--brand) 15%, transparent); border-color: var(--brand); color: var(--mention-pill-text); }
.reaction .r-emoji { font-size: 16px; }
.reaction .r-count { font-weight: 600; min-width: 9px; }
.reaction.add { opacity: 0; color: var(--icon); }
.msg:hover .reaction.add { opacity: 1; }

/* edit */
.edit-input { width: 100%; background: var(--bg-input); border: 0; border-radius: 8px; padding: 11px 16px; resize: none; outline: none; font-size: var(--chat-font); line-height: 1.375; margin: 4px 0 2px; overflow: hidden; }
.edit-hint { font-size: 12px; color: var(--text); padding: 2px 0 6px; }

/* skeletons */
.msg-skeletons { padding: 16px; }
.sk { display: flex; gap: 16px; margin-bottom: 24px; opacity: .5; }
.sk-av { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-active); }
.sk-l { height: 14px; border-radius: 7px; background: var(--bg-active); margin: 4px 0 8px; }
.sk-l.w1 { width: 120px; } .sk-l.w2 { width: 340px; max-width: 50vw; }

/* composer */
.composer-wrap { padding: 0 16px; flex-shrink: 0; position: relative; }
.composer { display: flex; align-items: flex-start; background: var(--bg-input); border-radius: 8px; padding: 0 8px 0 4px; min-height: 44px; }
.reply-bar + .attach-bar + .composer, .reply-bar + .composer, .attach-bar + .composer { border-top-left-radius: 0; border-top-right-radius: 0; }
.composer .icon-btn { margin-top: 6px; padding: 4px 8px; }
.composer textarea { flex: 1; background: none; border: 0; outline: none; resize: none; padding: 11px 4px; font-size: var(--chat-font); line-height: 1.375; max-height: 50vh; color: var(--text); }
.composer textarea::placeholder { color: var(--text-faint); }
.reply-bar { background: var(--bg-side); border-radius: 8px 8px 0 0; padding: 4px 8px 4px 16px; display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--text-muted); }
.reply-bar strong { color: var(--text); }
.attach-bar { background: var(--bg-input); border-radius: 8px 8px 0 0; padding: 20px 10px 10px; display: flex; gap: 24px; overflow-x: auto; border-bottom: 1px solid var(--divider); }
.reply-bar + .attach-bar { border-radius: 0; }
.att-prev { position: relative; width: 200px; height: 200px; background: var(--bg-side); border-radius: 4px; padding: 8px; display: flex; flex-direction: column; flex-shrink: 0; }
.att-prev img { flex: 1; min-height: 0; object-fit: contain; border-radius: 3px; }
.att-prev-file { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.att-prev-name { font-size: 14px; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-remove { position: absolute; top: -12px; right: -12px; background: var(--bg-main); border: 1px solid var(--border); color: var(--red); border-radius: 4px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.att-remove:hover { background: var(--bg-input); }
.typing { height: 24px; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 6px; padding-left: 4px; }
.typing strong { font-weight: 700; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text); animation: dot 1.2s infinite; opacity: .3; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.autocomplete { position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); background: var(--bg-side); border-radius: 8px; padding: 8px; box-shadow: var(--shadow); z-index: 5; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.ac-item .muted { margin-left: auto; font-size: 14px; }
.ac-item.sel, .ac-item:hover { background: var(--bg-active); }
.ac-emoji { font-size: 20px; }
.drop-overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; z-index: 10; pointer-events: none; }
.drop-overlay div { background: var(--brand); color: var(--on-brand); padding: 48px 64px; border-radius: 12px; font-size: 20px; font-weight: 700; border: 2px dashed rgba(255, 255, 255, .6); }

/* members */
.members { width: 240px; background: var(--bg-side); overflow-y: auto; flex-shrink: 0; padding: 0 8px 20px; }
.member-group { padding: 24px 8px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: .02em; }
.member { display: flex; align-items: center; gap: 12px; padding: 1px 8px; height: 42px; border-radius: 4px; cursor: pointer; color: var(--text-muted); }
.member:hover { background: var(--bg-hover); }
.member.off { opacity: .3; }
.member.off:hover { opacity: 1; }
.member-text { min-width: 0; }
.member-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.member-sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crown { font-size: 12px; }
.members .dm-profile { margin: 0 -8px; }

/* profile card */
.profile-card { width: 340px; background: var(--bg-float); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.profile-card.preview { width: 300px; }
.pc-banner { height: 120px; background-size: cover !important; background-position: center !important; }
.dm-profile .pc-banner { height: 140px; }
.pc-av { margin: -46px 0 0 16px; width: max-content; border: 6px solid var(--bg-float); border-radius: 50%; background: var(--bg-float); }
.dm-profile .pc-av { border-color: var(--bg-side); background: var(--bg-side); }
.dm-profile .pc-av .status-dot { border-color: var(--bg-side); }
.pc-av .status-dot { border-color: var(--bg-float); }
.pc-body { padding: 12px 16px 16px; }
.pc-name { font-size: 20px; font-weight: 700; color: var(--text-strong); }
.pc-user { font-size: 14px; color: var(--text); }
.pc-custom { font-size: 14px; margin-top: 8px; }
.pc-sec { background: var(--bg-card); border-radius: 8px; padding: 12px; margin-top: 12px; }
body[data-theme="light"] .pc-sec { background: var(--bg-side); }
.dm-profile .pc-sec { background: var(--bg-main); }
.pc-sec:empty { display: none; }
.pc-h { font-size: 12px; font-weight: 700; text-transform: uppercase; margin: 8px 0 4px; color: var(--text-strong); }
.pc-h:first-child { margin-top: 0; }
.pc-about { font-size: 14px; white-space: pre-wrap; }
.pc-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pc-note { padding: 0 16px 16px; }
.pc-note input { width: 100%; background: var(--bg-input); border: 0; border-radius: 4px; padding: 10px; outline: none; font-size: 14px; }

/* side panel (pins / search) */
.side-panel { width: 420px; max-width: 50%; background: var(--bg-side); display: flex; flex-direction: column; flex-shrink: 0; }
.sp-head { height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; font-weight: 600; color: var(--text-strong); border-bottom: 1px solid var(--divider); }
.sp-head .icon-btn { margin-left: auto; }
.sp-body { flex: 1; overflow-y: auto; padding: 8px; }
.result { display: flex; gap: 12px; padding: 12px; background: var(--bg-main); border-radius: 8px; margin-bottom: 8px; cursor: pointer; border: 1px solid transparent; }
.result:hover { border-color: var(--border); }
.result .msg-content { font-size: 14px; }
.sp-empty { text-align: center; color: var(--text-muted); padding: 40px 20px; }

/* ===== Friends ===== */
.friends { flex: 1; display: flex; flex-direction: column; padding: 16px 20px 0 30px; overflow-y: auto; min-width: 0; }
.friend-search { position: relative; margin: 0 0 8px; }
.friend-search input { width: 100%; height: 36px; background: var(--bg-rail); border: 0; border-radius: 4px; padding: 0 36px 0 10px; outline: none; font-size: 16px; }
.friend-search .ic { position: absolute; right: 10px; top: 9px; color: var(--text-muted); }
.fr-label { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); margin: 16px 0 8px; letter-spacing: .02em; }
.friend-row { display: flex; align-items: center; gap: 12px; height: 62px; border-top: 1px solid var(--divider); padding: 0 10px; margin: 0 -10px; border-radius: 8px; cursor: pointer; }
.friend-row:hover { background: var(--bg-hover); border-top-color: transparent; }
.friend-row:hover + .friend-row { border-top-color: transparent; }
.fr-text { flex: 1; min-width: 0; }
.fr-name { font-weight: 600; color: var(--text-strong); }
.fr-user { display: none; font-weight: 400; color: var(--text-muted); font-size: 14px; }
.friend-row:hover .fr-user { display: inline; }
.fr-sub { font-size: 14px; color: var(--text-muted); }
.fr-actions { display: flex; gap: 10px; }
.round-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-side); color: var(--icon); display: flex; align-items: center; justify-content: center; }
.friend-row:hover .round-btn { background: var(--bg-rail); }
.round-btn:hover { color: var(--icon-hover); }
.round-btn.ok:hover { color: var(--green); }
.round-btn.no:hover { color: var(--red); }
.add-friend { padding: 4px 0 20px; border-bottom: 1px solid var(--divider); }
.add-friend h2 { font-size: 16px; text-transform: uppercase; margin: 0 0 8px; color: var(--text-strong); }
.add-friend p { color: var(--text-muted); font-size: 14px; margin: 0 0 16px; }
.af-row { display: flex; align-items: center; background: var(--bg-rail); border-radius: 8px; padding: 0 12px; border: 1px solid transparent; }
.af-row:focus-within { border-color: var(--link); }
.af-row input { flex: 1; background: none; border: 0; outline: none; height: 50px; font-size: 16px; }
.af-msg { font-size: 14px; margin-top: 8px; }
.af-msg.ok { color: var(--green); } .af-msg.err { color: #fa777c; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); text-align: center; padding: 40px; gap: 16px; }
.empty-state .ic { color: var(--text-faint); }
.active-now { width: 360px; border-left: 1px solid var(--divider); padding: 16px; overflow-y: auto; flex-shrink: 0; }
.active-now h2 { font-size: 20px; font-weight: 800; color: var(--text-strong); margin: 8px 0 16px; }
.an-empty { text-align: center; padding: 16px; }
.an-empty h3 { color: var(--text-strong); font-size: 16px; margin: 0 0 4px; }
.an-empty p { color: var(--text-muted); font-size: 14px; margin: 0; }
.an-card { background: var(--bg-side); border-radius: 8px; padding: 16px; margin-bottom: 8px; cursor: pointer; border: 1px solid var(--divider); }
.an-card:hover { background: var(--bg-input); }
.an-top { display: flex; align-items: center; gap: 12px; }

/* ===== Voice stage ===== */
.stage { flex: 1; background: #000; display: flex; flex-direction: column; padding: 16px; min-height: 0; }
.stage-empty { margin: auto; text-align: center; color: #fff; }
.stage-empty h2 { margin: 0 0 4px; }
.stage-empty p { color: #b5bac1; margin: 0 0 20px; }
.tiles { flex: 1; display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-content: center; min-height: 0; }
.tiles.n1 { grid-template-columns: minmax(260px, 900px); justify-content: center; }
.tile { position: relative; aspect-ratio: 16 / 9; background: var(--tile, var(--brand)); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 0 var(--green); transition: box-shadow .1s; }
.tile.has-video { background: #111; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--green); }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile video.screen { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }
.tile-av { filter: drop-shadow(0 0 8px rgba(0, 0, 0, .3)); }
.tile-name { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 14px; padding: 2px 8px; border-radius: 4px; display: flex; gap: 4px; align-items: center; }
.call-controls { display: flex; gap: 16px; justify-content: center; padding: 16px 0 4px; }
.call-btn { width: 56px; height: 56px; border-radius: 50%; border: 0; background: #2b2d31; color: #fff; display: flex; align-items: center; justify-content: center; }
.call-btn:hover { background: #404249; }
.call-btn.on { background: #fff; color: #000; }
.call-btn.off { background: #fff; color: var(--red); }
.call-btn.hang { background: var(--red); }
.call-btn.hang:hover { background: var(--red-hover); }
.call-btn.accept { background: var(--green); }
.call-area { background: #000; padding: 16px; flex-shrink: 0; }
.tiles.small { grid-template-columns: repeat(auto-fit, minmax(180px, 280px)); justify-content: center; }
.tiles.small .tile-av .avatar { width: 64px !important; height: 64px !important; }
.incoming { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 240px; background: var(--bg-rail); border-radius: 8px; padding: 24px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 8px 40px rgba(0, 0, 0, .5); z-index: 300; animation: pop .2s; }
.ic-av .avatar { animation: ringpulse 1.4s infinite; }
@keyframes ringpulse { 0% { box-shadow: 0 0 0 0 rgba(35, 165, 90, .6); } 100% { box-shadow: 0 0 0 20px rgba(35, 165, 90, 0); } }
.ic-name { font-size: 20px; font-weight: 700; color: var(--text-strong); margin-top: 16px; }
.ic-sub { color: var(--text-muted); margin-bottom: 24px; }
.ic-btns { display: flex; gap: 40px; }

/* ===== Overlays ===== */
#layer { position: fixed; inset: 0; pointer-events: none; z-index: 150; }
#layer > * { pointer-events: auto; }
.popout { position: fixed; z-index: 120; animation: pop .12s; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; } }
.ctx-menu { position: fixed; z-index: 130; background: var(--bg-float); border-radius: 4px; padding: 6px 8px; min-width: 188px; max-width: 320px; box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, .15); }
.ctx-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; margin: 2px 0; border-radius: 2px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; min-height: 32px; }
.ctx-item:hover { background: var(--brand); color: var(--on-brand); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red); color: #fff; }
.ctx-sep { height: 1px; background: var(--divider); margin: 4px; }
.tooltip { position: fixed; z-index: 400; background: var(--bg-float); color: var(--text-strong); font-size: 14px; font-weight: 600; padding: 6px 10px; border-radius: 5px; box-shadow: var(--shadow); pointer-events: none; white-space: nowrap; animation: pop .1s; }
.tooltip::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--bg-float); }
.tooltip.right::after { left: -5px; top: 50%; bottom: auto; margin: -5px 0 0; border: 5px solid transparent; border-left: 0; border-right-color: var(--bg-float); }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--bg-float); color: var(--text-strong); padding: 10px 16px; border-radius: 6px; font-size: 14px; box-shadow: var(--shadow); animation: pop .15s; transition: opacity .3s; }
.toast.ok { background: var(--green); color: #fff; } .toast.err { background: var(--red); color: #fff; }
.toast.out { opacity: 0; }

.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; z-index: 110; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg-modal); border-radius: 8px; width: 440px; max-width: 100%; max-height: 90vh; overflow-y: auto; animation: pop .15s; box-shadow: var(--shadow); }
.modal.sm { width: 440px; }
.modal-pad { padding: 16px 16px 20px; }
.modal-pad.center, .center { text-align: center; }
.modal h2 { color: var(--text-strong); font-size: 20px; margin: 8px 0 8px; display: flex; align-items: center; gap: 8px; justify-content: inherit; }
.modal-pad.center h2 { justify-content: center; font-size: 24px; }
.modal h3 { color: var(--text-strong); font-size: 16px; margin: 0 0 12px; }
.modal-text { color: var(--text); font-size: 16px; line-height: 1.4; }
.modal-foot { background: var(--bg-modal-foot); padding: 16px; display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.modal-foot.col { flex-direction: column; }
.modal-foot.col h3 { margin: 0; font-size: 20px; }
.confirm-preview { margin: 16px 0; border-radius: 4px; box-shadow: 0 0 0 1px var(--divider); padding: 8px 0; pointer-events: none; }
.confirm-preview .msg { margin: 0; }
.confirm-preview .msg-toolbar { display: none !important; }
.field { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin: 16px 0 0; letter-spacing: .02em; }
.field.left, .left { text-align: left; }
.field input:not([type=radio]):not([type=color]):not([type=checkbox]), .field textarea, .field select, input.full { display: block; width: 100%; margin-top: 8px; background: var(--bg-rail); border: 0; border-radius: 3px; padding: 10px; font-size: 16px; outline: none; text-transform: none; font-weight: 400; color: var(--text); resize: vertical; }
body[data-theme="light"] .field input:not([type=radio]):not([type=color]):not([type=checkbox]), body[data-theme="light"] .field textarea, body[data-theme="light"] .field select { background: #e3e5e8; }
.field input[type=color] { display: block; margin-top: 8px; width: 64px; height: 40px; border: 0; padding: 0; background: none; cursor: pointer; }
.field-err { color: #fa777c; font-size: 14px; text-align: left; margin-top: 6px; min-height: 18px; }
.choice { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 8px 8px; margin-top: 8px; color: var(--text-strong); font-weight: 700; font-size: 16px; }
.choice span { flex: 1; text-align: left; }
.choice .ic:first-child { color: var(--brand); }
.choice:hover { background: var(--bg-hover); }
.icon-upload { display: inline-block; margin: 16px auto 0; cursor: pointer; }
.iu-circle { width: 80px; height: 80px; border-radius: 50%; border: 2px dashed var(--text-muted); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); font-size: 10px; font-weight: 700; overflow: hidden; }
.iu-circle img { width: 100%; height: 100%; object-fit: cover; }
.iu-circle.big { width: 100px; height: 100px; border: 0; background: var(--brand); color: var(--on-brand); font-size: 24px; }
.radio-card { display: flex; align-items: center; gap: 12px; background: var(--bg-side); border-radius: 4px; padding: 10px 12px; margin-top: 8px; cursor: pointer; text-transform: none; font-size: 16px; font-weight: 500; color: var(--text); letter-spacing: 0; }
.radio-card:hover { background: var(--bg-input); }
.radio-card:has(input:checked) { background: var(--bg-active); }
.radio-card input { order: 3; margin-left: auto; accent-color: var(--brand); width: 18px; height: 18px; }
.copy-row { display: flex; gap: 8px; align-items: center; background: var(--bg-rail); border-radius: 3px; padding: 4px; margin-top: 8px; }
.copy-row input { flex: 1; margin: 0 !important; background: none !important; border: 0; outline: none; padding: 6px; font-size: 16px; }
.inv-friends { max-height: 200px; overflow-y: auto; margin-bottom: 8px; }
.inv-friend { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 4px; }
.inv-friend span { flex: 1; }
.inv-friend:hover { background: var(--bg-hover); }
.inv-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--brand); color: var(--on-brand); display: flex; align-items: center; justify-content: center; margin: 8px auto; overflow: hidden; font-weight: 600; }
.inv-icon img { width: 100%; height: 100%; object-fit: cover; }
.pick-list { max-height: 300px; overflow-y: auto; margin-top: 12px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.pick:hover { background: var(--bg-hover); }
.pick .muted { margin-left: auto; font-size: 14px; }
.qs-modal { width: 570px; background: var(--bg-side); }
.qs { padding: 24px; }
.qs input { width: 100%; height: 70px; background: var(--bg-rail); border: 0; border-radius: 4px; padding: 0 16px; font-size: 20px; outline: none; }
.qs-list { margin: 16px 0 8px; max-height: 340px; overflow-y: auto; }
.qs-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 4px; cursor: pointer; font-weight: 500; }
.qs-item.sel, .qs-item:hover { background: var(--bg-active); }
.qs-item .muted { margin-left: auto; font-size: 13px; text-transform: uppercase; font-weight: 600; }
.qs-sicon { width: 20px; height: 20px; border-radius: 6px; background: var(--brand); color: var(--on-brand); font-size: 9px; display: flex; align-items: center; justify-content: center; }
.qs-tip { margin-top: 8px; }
.lightbox { background: none; box-shadow: none; width: auto; max-width: 90vw; overflow: visible; text-align: left; }
.lb-img { max-width: 90vw; max-height: 80vh; display: block; border-radius: 4px; }
.lb-open { color: #fff; opacity: .6; font-size: 14px; display: inline-block; margin-top: 8px; }
.lb-open:hover { opacity: 1; }

/* emoji picker */
.emoji-picker { width: 400px; max-width: 95vw; height: 420px; background: var(--bg-side); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.ep-search { padding: 12px; box-shadow: 0 1px 0 var(--divider); }
.ep-search input { width: 100%; background: var(--bg-rail); border: 0; border-radius: 4px; padding: 8px; outline: none; font-size: 15px; }
.ep-body { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.ep-cat { font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); padding: 12px 4px 4px; position: sticky; top: 0; background: var(--bg-side); }
.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, 44px); }
.ep-grid button { width: 44px; height: 44px; font-size: 28px; background: none; border: 0; border-radius: 4px; padding: 0; line-height: 1; }
.ep-grid button:hover { background: var(--bg-active); }

/* status menu */
.status-menu { width: 300px; background: var(--bg-float); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.status-menu .profile-card { box-shadow: none; }
.status-menu .pc-banner { height: 120px; background-size: cover !important; background-position: center !important; }
.sm-list { padding: 8px; }
.sm-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 4px; cursor: pointer; font-size: 14px; font-weight: 500; }
.sm-item > div { flex: 1; }
.sm-item:hover { background: var(--brand); color: var(--on-brand); }
.sm-item:hover .sm-desc { color: #fff; }
.sm-desc { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

/* ===== Settings ===== */
.settings { position: fixed; inset: 0; z-index: 105; display: flex; background: var(--bg-main); animation: fade .15s; }
.set-nav { flex: 1 0 218px; background: var(--bg-side); display: flex; justify-content: flex-end; overflow-y: auto; }
.set-nav-inner { width: 218px; padding: 60px 6px 60px 20px; }
.set-cat { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); padding: 6px 10px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-tab { padding: 6px 10px; margin-bottom: 2px; border-radius: 4px; color: var(--text-muted); cursor: pointer; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.set-tab:hover { background: var(--bg-hover); color: var(--icon-hover); }
.set-tab.active { background: var(--bg-active); color: var(--text-strong); }
.set-tab.danger { color: var(--red); }
.set-sep { height: 1px; background: var(--divider); margin: 8px 10px; }
.set-content { flex: 1 1 800px; position: relative; overflow-y: auto; }
.set-content-inner { max-width: 740px; padding: 60px 40px 80px; }
.set-content h2 { color: var(--text-strong); font-size: 20px; margin: 0 0 20px; }
.set-content h3 { color: var(--text-strong); font-size: 16px; margin: 0 0 12px; }
.set-close { position: absolute; top: 60px; right: 40px; background: none; border: 0; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.set-close .ic { border: 2px solid currentColor; border-radius: 50%; width: 36px; height: 36px; padding: 7px; }
.set-close:hover { color: var(--text-strong); }
.set-label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: .02em; }
.set-divider { height: 1px; background: var(--divider); margin: 32px 0; }
.set-form { max-width: 440px; }
.set-form .btn { margin-top: 20px; }
.acct-card { background: var(--bg-rail); border-radius: 8px; overflow: hidden; }
.acct-card .pc-banner { height: 140px; }
.acct-head { display: flex; align-items: flex-end; gap: 16px; padding: 0 16px; margin-top: -36px; }
.acct-head .avatar { border: 7px solid var(--bg-rail); box-sizing: content-box; }
.acct-head .status-dot { border-color: var(--bg-rail); }
.acct-name { flex: 1; font-size: 20px; font-weight: 700; color: var(--text-strong); padding-bottom: 12px; }
.acct-head .btn { margin-bottom: 12px; }
.acct-fields { background: var(--bg-side); margin: 8px 16px 16px; border-radius: 8px; padding: 16px; }
.acct-field { display: flex; justify-content: space-between; align-items: center; }
.acct-field + .acct-field { margin-top: 24px; }
.profile-edit { display: flex; gap: 40px; flex-wrap: wrap; }
.profile-edit .set-form { flex: 1; min-width: 260px; }
.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.row.gap { gap: 20px; }
.theme-row { display: flex; gap: 16px; }
.theme-swatch { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--border); }
.theme-swatch.sel { border: 3px solid var(--brand); box-shadow: 0 0 0 2px var(--bg-main); }
.t-dark { background: #313338; } .t-light { background: #fff; } .t-midnight { background: #000; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; cursor: pointer; }
.switch { appearance: none; width: 40px; height: 24px; background: #80848e; border-radius: 12px; position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 19px; }
.range { width: 100%; max-width: 400px; accent-color: var(--brand); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two-col .field { margin-top: 0; }
.meter { flex: 1; height: 8px; background: var(--bg-rail); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--green); transition: width .06s; }
.kb-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--divider); }
kbd { background: var(--bg-rail); border-radius: 4px; padding: 4px 8px; font-family: var(--font); font-size: 13px; font-weight: 600; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .3); }
.mem-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--divider); }

/* compact mode */
body.compact .msg { margin-top: 2px; grid-template-columns: 72px 1fr; padding-top: 0; padding-bottom: 0; }
body.compact .msg:not(.grouped) .msg-gutter .avatar { width: 24px !important; height: 24px !important; }
body.compact .msg-head { display: inline-flex; margin-right: 6px; flex-direction: row-reverse; }
body.compact .msg-body { display: block; }
body.compact .msg-body > .msg-head + .msg-content { display: inline; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .active-now { display: none; }
}
@media (max-width: 900px) {
  .members { display: none; }
  .side-panel { position: absolute; right: 0; top: 48px; bottom: 0; max-width: 100%; z-index: 20; box-shadow: var(--shadow); }
  .main-body { position: relative; }
  .search input { width: 100px; } .search input:focus { width: 160px; }
}
@media (max-width: 720px) {
  .rail, .sidebar { position: fixed; top: 0; bottom: 0; z-index: 50; transform: translateX(-312px); transition: transform .2s; }
  .rail { left: 0; } .sidebar { left: 72px; }
  body.nav-open .rail, body.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .burger { display: inline-flex; }
  .main-header { padding-left: 4px; overflow-x: auto; }
  .hd-topic, .search { display: none; }
  .msg { padding-right: 8px; grid-template-columns: 56px 1fr; }
  .reply-ref { padding-left: 56px; } .reply-spine { left: 28px; width: 25px; }
  .friends { padding: 12px; }
  .set-nav { flex: 0 0 160px; } .set-nav-inner { width: 160px; padding: 20px 6px; }
  .set-content-inner { padding: 20px 16px 60px; }
  .set-close { top: 12px; right: 12px; }
  .two-col { grid-template-columns: 1fr; }
}
