:root {
  --bg-0: #1e1f22; --bg-1: #2b2d31; --bg-2: #313338; --bg-3: #383a40; --bg-hover: #35373c;
  --text: #dbdee1; --muted: #949ba4; --bright: #f2f3f5;
  --accent: #5865f2; --green: #23a55a; --red: #da373c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg-2); color: var(--text);
  font: 15px/1.4 "gg sans", "Segoe UI", system-ui, -apple-system, sans-serif; overflow: hidden; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* вход */
.login { position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, #404eed, #23272a 70%); }
.login-card { background: var(--bg-2); padding: 32px; border-radius: 8px; width: min(420px, 92vw);
  text-align: center; box-shadow: 0 8px 32px #0008; }
.login-logo { font-size: 48px; }
.login-card h1 { margin: 8px 0 4px; color: var(--bright); font-size: 24px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card input, .modal input, .modal select { width: 100%; padding: 10px; border: 0; border-radius: 4px;
  background: var(--bg-0); color: var(--text); font: inherit; outline: none; }
.login-card button, .modal-actions button { width: 100%; margin-top: 16px; padding: 11px; border: 0; border-radius: 4px;
  background: var(--accent); color: #fff; font-weight: 600; }
.login-card button:hover, .modal-actions button:hover { background: #4752c4; }

/* каркас */
.app { display: flex; height: 100%; }
.servers { width: 72px; background: var(--bg-0); padding: 12px 0; display: flex; flex-direction: column; align-items: center; flex: none; }
.server-icon { width: 48px; height: 48px; border-radius: 16px; background: var(--accent); display: grid; place-items: center; font-size: 24px; }

.sidebar { width: 240px; background: var(--bg-1); display: flex; flex-direction: column; flex: none; }
.sidebar-header, .main-header { height: 48px; padding: 0 16px; display: flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--bright); box-shadow: 0 1px 0 #0003, 0 2px 0 #0000000d; flex: none; }
.channels { flex: 1; overflow-y: auto; padding: 8px; }
.category { display: flex; align-items: center; justify-content: space-between; padding: 16px 8px 4px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }
.category button { background: none; border: 0; color: var(--muted); padding: 0; font-size: 18px; line-height: 1; }
.category button:hover { color: var(--bright); }
.channel { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 4px; color: var(--muted);
  cursor: pointer; margin: 1px 0; user-select: none; position: relative; }
.channel:hover { background: var(--bg-hover); color: var(--text); }
.channel.active { background: var(--bg-3); color: var(--bright); }
.channel.unread { color: var(--bright); font-weight: 600; }
.channel.unread::before { content: ""; position: absolute; left: -8px; width: 4px; height: 8px; border-radius: 0 4px 4px 0; background: var(--bright); }
.channel .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel .del { display: none; background: none; border: 0; color: var(--muted); padding: 0 2px; }
.channel:hover .del { display: block; }
.channel .del:hover { color: var(--red); }
.voice-users { padding-left: 28px; }
.voice-user { display: flex; align-items: center; gap: 8px; padding: 3px 8px; border-radius: 4px; color: var(--muted); font-size: 14px; }
.voice-user .avatar { width: 24px; height: 24px; font-size: 11px; }
.voice-user .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-user svg { width: 16px; height: 16px; }
.live { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: 14px; flex: none; transition: box-shadow .1s; }
.speaking .avatar, .avatar.speaking { box-shadow: 0 0 0 2px var(--bg-1), 0 0 0 4px var(--green); }

.voice-panel { display: flex; align-items: center; gap: 4px; padding: 8px; border-bottom: 1px solid #ffffff0f; background: #232428; }
.voice-panel-info { flex: 1; min-width: 0; }
.voice-status { color: var(--green); font-weight: 600; font-size: 14px; }
.voice-channel-name { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel { display: flex; align-items: center; gap: 4px; padding: 8px; background: #232428; }
.user-panel-name { flex: 1; min-width: 0; padding-left: 4px; font-size: 14px; color: var(--bright); font-weight: 600; }
.user-panel-name div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel-name small { color: var(--muted); font-weight: 400; font-size: 12px; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 4px; background: none; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.off { color: var(--red); }

/* основная часть */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-2); }
.main-header svg { color: var(--muted); }
.text-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 0; }
.msg { display: flex; gap: 16px; padding: 2px 16px 2px 16px; }
.msg:hover { background: #2e3035; }
.msg.first { margin-top: 16px; }
.msg .avatar { width: 40px; height: 40px; font-size: 16px; margin-top: 2px; }
.msg .gutter { width: 40px; flex: none; font-size: 11px; color: transparent; text-align: right; padding-top: 3px; }
.msg:hover .gutter { color: var(--muted); }
.msg-body { min-width: 0; flex: 1; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-author { font-weight: 600; }
.msg-time { font-size: 12px; color: var(--muted); }
.msg-text { white-space: pre-wrap; word-wrap: break-word; color: var(--text); }
.msg-text a { color: #00a8fc; }
.msg-text img { display: block; max-width: min(400px, 100%); max-height: 300px; border-radius: 8px; margin-top: 4px; }
.welcome { padding: 16px; color: var(--muted); }
.welcome h2 { color: var(--bright); margin: 0 0 4px; font-size: 28px; }
.welcome .big { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-3); display: grid; place-items: center; margin-bottom: 8px; }
.welcome .big svg { width: 40px; height: 40px; color: var(--bright); }
.composer { margin: 0 16px; background: var(--bg-3); border-radius: 8px; padding: 11px 16px; }
.composer textarea { width: 100%; resize: none; border: 0; outline: none; background: none; color: var(--text);
  font: inherit; max-height: 200px; display: block; }
.typing { height: 24px; padding: 2px 16px; font-size: 13px; color: var(--muted); }

/* голос */
.voice-view { flex: 1; display: flex; flex-direction: column; background: #000; min-height: 0; }
.tiles { flex: 1; display: grid; gap: 8px; padding: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-content: center; overflow-y: auto; }
.tile { position: relative; aspect-ratio: 16/9; border-radius: 8px; background: var(--bg-1); display: grid; place-items: center; overflow: hidden; }
.tile.speaking { box-shadow: inset 0 0 0 3px var(--green); }
.tile .avatar { width: 80px; height: 80px; font-size: 32px; box-shadow: none !important; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile.focus { grid-column: 1 / -1; }
.tile-name { position: absolute; left: 8px; bottom: 8px; background: #000a; padding: 2px 8px; border-radius: 4px; font-size: 13px;
  display: flex; gap: 4px; align-items: center; color: #fff; }
.tile-name svg { width: 14px; height: 14px; color: var(--red); }
.tile-vol { position: absolute; right: 8px; bottom: 8px; display: none; align-items: center; gap: 4px; background: #000a; padding: 4px 8px; border-radius: 4px; }
.tile:hover .tile-vol { display: flex; }
.tile-vol input { width: 90px; }
.tile-full { position: absolute; right: 8px; top: 8px; display: none; }
.tile:hover .tile-full { display: grid; background: #000a; }
.voice-controls { display: flex; justify-content: center; gap: 12px; padding: 16px; }
.round-btn { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--bg-3); color: var(--bright); display: grid; place-items: center; }
.round-btn svg { width: 24px; height: 24px; }
.round-btn:hover { background: #4e5058; }
.round-btn.on { background: var(--bright); color: #000; }
.round-btn.off { background: var(--bright); color: var(--red); }
.round-btn.danger { background: var(--red); color: #fff; }
.round-btn.danger:hover { background: #a12828; }

/* участники */
.members { width: 240px; background: var(--bg-1); padding: 16px 8px; overflow-y: auto; flex: none; }
.member { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 4px; }
.member:hover { background: var(--bg-hover); }
.member .avatar { position: relative; }
.member .avatar::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--green); border: 3px solid var(--bg-1); }
.member-name { font-weight: 500; color: var(--text); }
.member small { display: block; color: var(--muted); font-size: 12px; }

/* модалки и уведомления */
.modal { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 10; }
.modal-card { background: var(--bg-2); border-radius: 8px; padding: 24px; width: min(440px, 92vw); }
.modal-card h2 { margin: 0 0 16px; color: var(--bright); }
.modal label { display: block; margin-bottom: 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.modal label > input, .modal label > select, .modal label > .meter { margin-top: 6px; }
.modal label.check { display: flex; gap: 8px; align-items: center; text-transform: none; font-size: 14px; font-weight: 400; color: var(--text); }
.modal label.check input { width: auto; }
.meter { height: 8px; background: var(--bg-0); border-radius: 4px; overflow: hidden; }
.meter { position: relative; height: 10px; }
.meter div { height: 100%; width: 0; background: #faa61a; transition: width .05s; }
.meter div.open { background: var(--green); }
.meter i { position: absolute; top: -3px; bottom: -3px; width: 3px; background: #fff; border-radius: 2px; }
.modal-actions .ghost-btn { background: var(--bg-3); }
.modal-actions .ghost-btn.on { background: var(--green); }
.modal select { margin-top: 6px; }
.modal input[type=range] { padding: 0; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--bg-0); color: var(--bright);
  padding: 10px 16px; border-radius: 6px; box-shadow: 0 4px 16px #0008; z-index: 20; }
.conn { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 4px; z-index: 30; font-size: 13px; }
::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 4px; }

/* вход */
.login-card .field { display: block; text-align: left; margin-bottom: 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.login-card .field input { margin-top: 6px; }
.auth-error { color: #fa777c; font-size: 14px; min-height: 18px; text-align: left; }
.auth-switch { margin-top: 12px; font-size: 14px; color: var(--muted); text-align: left; }
.auth-switch a { color: #00a8fc; text-decoration: none; }

/* рельса серверов */
.servers { gap: 8px; }
.server-icon { position: relative; cursor: pointer; background: var(--bg-2); color: var(--text); font-size: 16px; font-weight: 600;
  border-radius: 50%; transition: border-radius .15s, background .15s; }
.server-icon:hover, .server-icon.active { border-radius: 16px; background: var(--accent); color: #fff; }
.server-icon.home { font-size: 24px; }
.rail-sep { width: 32px; height: 2px; background: var(--bg-3); border-radius: 1px; }
.badge { position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red);
  color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; border: 3px solid var(--bg-0); box-sizing: content-box; }
.channel .badge { position: static; border: 0; min-width: 16px; height: 16px; font-size: 11px; }

/* ЛС в сайдбаре */
.search-btn { width: 100%; text-align: left; background: var(--bg-0); color: var(--muted); border: 0; border-radius: 4px; padding: 6px 8px; font-size: 13px; }
.sidebar-header .search-btn { height: 28px; }
.dm-item .avatar { width: 32px; height: 32px; }
.dot { position: relative; }
.dot::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 3px solid var(--bg-1);
  background: #80848e; }
.dot.on::after { background: var(--green); }

/* друзья */
.friends-view { flex: 1; overflow-y: auto; padding: 16px 24px; }
.main-header .tab { background: none; border: 0; color: var(--muted); padding: 2px 10px; border-radius: 4px; font-weight: 500; }
.main-header .tab:hover { background: var(--bg-hover); color: var(--text); }
.main-header .tab.active { background: var(--bg-3); color: var(--bright); }
.main-header .tab.add { background: var(--green); color: #fff; }
.main-header .tab.add.active { background: none; color: var(--green); }
.main-header .sep { width: 1px; height: 24px; background: var(--bg-3); margin: 0 8px; }
.main-header .spacer { flex: 1; }
.main-header .hbtn { background: none; border: 0; color: var(--muted); display: grid; place-items: center; width: 32px; height: 32px; border-radius: 4px; }
.main-header .hbtn:hover { color: var(--bright); }
.list-title { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin: 8px 0; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-top: 1px solid #ffffff0f; border-radius: 8px; }
.person:hover { background: var(--bg-hover); }
.person .info { flex: 1; min-width: 0; }
.person .pname { color: var(--bright); font-weight: 600; }
.person .puser { color: var(--muted); font-size: 13px; }
.person .acts { display: flex; gap: 8px; }
.circle-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-1); color: var(--muted); display: grid; place-items: center; }
.circle-btn:hover { color: var(--bright); }
.circle-btn.ok:hover { color: var(--green); }
.circle-btn.no:hover { color: var(--red); }
.pill { font-size: 13px; color: var(--muted); padding: 6px 10px; }
.add-box h3 { color: var(--bright); margin: 8px 0 4px; font-size: 16px; text-transform: uppercase; }
.add-box p { color: var(--muted); margin: 0 0 16px; font-size: 14px; }
.add-input { display: flex; gap: 8px; background: var(--bg-0); border-radius: 8px; padding: 6px 6px 6px 14px; border: 1px solid var(--bg-0); }
.add-input:focus-within { border-color: #00a8fc; }
.add-input input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: 16px; }
.btn { border: 0; border-radius: 4px; padding: 8px 16px; background: var(--accent); color: #fff; font-weight: 500; }
.btn:hover { background: #4752c4; }
.btn.ghost { background: var(--bg-3); }
.btn.green { background: var(--green); }
.empty { color: var(--muted); text-align: center; padding: 48px 16px; }

/* звонок в ЛС */
.call-area { background: #000; height: 45%; min-height: 260px; display: flex; flex-direction: column; flex: none; }
.call-area .join-call { margin: auto; text-align: center; color: var(--muted); }
.call-area .tiles { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; }
.call-area .tile { flex: 1 1 140px; max-width: 320px; }
.call-area .tile.focus { flex-basis: 100%; max-width: 640px; }
.call-area .tile .avatar { width: 56px; height: 56px; font-size: 22px; }
.stage { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.main > .stage { display: none; }
.msg { position: relative; }
.msg .msg-del { position: absolute; right: 16px; top: -10px; display: none; background: var(--bg-2); border: 1px solid var(--bg-0); color: var(--muted);
  border-radius: 4px; padding: 2px 6px; }
.msg:hover .msg-del { display: block; }
.msg .msg-del:hover { color: var(--red); }
.member .avatar.dot::after { display: none; }
.member.off { opacity: .4; }

/* входящий звонок */
.ring-card { background: var(--bg-0); border-radius: 12px; padding: 28px 40px; text-align: center; width: 260px; box-shadow: 0 8px 32px #000a; }
.ring-card .avatar { width: 80px; height: 80px; font-size: 32px; margin: 0 auto 12px; animation: pulse 1.2s infinite; }
.ring-name { color: var(--bright); font-weight: 700; font-size: 18px; }
.ring-sub { color: var(--muted); margin-bottom: 20px; }
.ring-actions { display: flex; justify-content: center; gap: 32px; }
.round-btn.accept { background: var(--green); color: #fff; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 #23a55a88; } 50% { box-shadow: 0 0 0 12px #23a55a00; } }

/* настройки */
.settings-card { position: relative; width: min(520px, 94vw); max-height: 92vh; overflow-y: auto; }
.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.settings-tabs button { background: none; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 4px; }
.settings-tabs button.active { background: var(--bg-3); color: var(--bright); }
.modal-close { position: absolute; right: 12px; top: 12px; background: none; border: 0; color: var(--muted); font-size: 18px; }
.swatches { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 3px solid transparent; }
.swatches button.sel { border-color: #fff; }
.modal-actions .danger-btn { background: var(--red); }
.modal-actions .danger-btn:hover { background: #a12828; }

/* вход по почте */
.code-input { text-align: center; font-size: 28px !important; letter-spacing: 10px; font-weight: 700; }
.auth-link { display: block; text-align: left; font-size: 14px; color: #00a8fc; text-decoration: none; margin: -6px 0 6px; }
.auth-switch a, .modal a { color: #00a8fc; text-decoration: none; }

/* рельса серверов */
.servers { overflow-y: auto; }
.server-icon.guild { background: var(--bg-2); color: var(--bright); }
.server-icon.guild:hover, .server-icon.guild.active { background: var(--gc); }
.server-icon.guild.has-unread::before, .server-icon.guild.active::before { content: ""; position: absolute; left: -12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--bright); }
.server-icon.guild.has-unread::before { height: 8px; }
.server-icon.guild.active::before { height: 40px; }
.server-icon.add { color: var(--green); font-size: 24px; font-weight: 400; }
.server-icon.add:hover, .server-icon.add.active { background: var(--green); color: #fff; }
.rail-voice { position: absolute; right: -4px; bottom: -4px; background: var(--green); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; border: 3px solid var(--bg-0); box-sizing: content-box; }
.rail-voice svg { width: 12px; height: 12px; color: #fff; }

/* шапка сервера и меню */
.sidebar-header { padding: 0; }
.sidebar-header > :not(.guild-head) { margin: 0 10px; }
.sidebar-header:not(:has(.guild-head)):not(:has(.search-btn)) { padding: 0 16px; }
.guild-head { width: 100%; height: 100%; background: none; border: 0; color: var(--bright); font-weight: 600; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 15px; }
.guild-head:hover { background: var(--bg-hover); }
.guild-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popup-menu { position: fixed; z-index: 15; background: #111214; border-radius: 6px; padding: 6px; box-shadow: 0 8px 24px #000a; }
.popup-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 3px; font-size: 14px; }
.popup-menu button:hover { background: var(--accent); color: #fff; }
.popup-menu button.accent { color: #949cf7; }
.popup-menu button.danger { color: #f23f42; }
.popup-menu button.danger:hover { background: var(--red); color: #fff; }
.menu-sep { height: 1px; background: #ffffff14; margin: 6px 4px; }
.channel .del + .del { margin-left: -2px; }

/* карточка пользователя */
.user-card { position: fixed; z-index: 15; width: 300px; background: #111214; border-radius: 8px; overflow: hidden; box-shadow: 0 8px 24px #000a; }
.uc-banner { height: 60px; }
.uc-avatar { margin: -40px 0 0 16px; }
.uc-avatar .avatar { width: 80px; height: 80px; font-size: 32px; border: 6px solid #111214; }
.uc-avatar .dot::after { width: 16px; height: 16px; border-color: #111214; right: 2px; bottom: 2px; }
.uc-body { padding: 8px 16px 16px; }
.uc-body .pname { font-size: 20px; color: var(--bright); font-weight: 700; }
.uc-body .puser { color: var(--muted); }
.uc-acts { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.uc-admin { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.uc-admin .btn { text-align: left; }
.member { cursor: pointer; }

/* окна */
.modal-card { position: relative; max-height: 92vh; overflow-y: auto; }
.modal-card .center { text-align: center; }
.modal-card .muted { color: var(--muted); }
.modal-card h3 { color: var(--bright); font-size: 16px; }
.guild-big { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; color: #fff; font-size: 26px; font-weight: 700; margin: 0 auto 8px; }
.dot-on { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.modal .add-input input { background: none; margin: 0; padding: 4px 0; }
#inviteFriends .person { border-top: 0; }

/* обзор серверов */
.discover-hero { padding: 24px; border-radius: 8px; background: linear-gradient(135deg, #5865f2, #3c45a5); margin-bottom: 20px; }
.discover-hero h2 { margin: 0 0 4px; color: #fff; }
.discover-hero p { margin: 0 0 16px; color: #dfe1ff; }
.discover-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.guild-card { background: var(--bg-1); border-radius: 8px; overflow: hidden; }
.guild-card-banner { height: 60px; position: relative; opacity: .9; }
.guild-card-icon { position: absolute; left: 16px; bottom: -24px; width: 48px; height: 48px; border-radius: 16px; border: 4px solid var(--bg-1); display: grid; place-items: center; color: #fff; font-weight: 700; }
.guild-card-body { padding: 32px 16px 16px; }
.guild-card-body .pname { color: var(--bright); font-weight: 700; }
.guild-card-body .puser { color: var(--muted); font-size: 13px; margin-top: 4px; min-height: 18px; }
.guild-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.empty-view, #emptyView { display: grid; place-items: center; }

@media (max-width: 900px) { .members { display: none; } }
@media (max-width: 640px) { .servers { display: none; } .sidebar { width: 190px; } }
