/* ================= Темы ================= */
body.theme-ash { --bg: #232428; --bg2: #2b2c31; --bg3: #313238; --bg4: #3c3d44; --input: #383a40; --border: #3a3b42; }
body.theme-onyx { --bg: #000; --bg2: #0b0b0d; --bg3: #101013; --bg4: #1d1d22; --input: #18181c; --border: #1f1f24; --muted: #8f919b; }
/* Цветные (градиентные) темы: фон — градиент, панели полупрозрачные */
body.grad { background: var(--grad) fixed; --bg4: rgba(255,255,255,.1); --input: rgba(0,0,0,.25); --border: rgba(255,255,255,.08); --bg2: rgba(22,22,28,.94); --bg3: rgba(30,30,38,.92); }
body.grad #main, body.grad #sidebar, body.grad #members, body.grad #rail { background-color: transparent; }
body.grad #rail { background: rgba(0,0,0,.32); }
body.grad #sidebar, body.grad #members { background: rgba(0,0,0,.2); }
body.grad #main { background: rgba(0,0,0,.08); }
body.grad #userbar, body.grad #voicebar { background: rgba(0,0,0,.22); }
body.grad.grad-light { --text: #17181c; --muted: #3f414a; --faint: #5c5e68; --bg4: rgba(255,255,255,.45); --input: rgba(255,255,255,.55); --border: rgba(0,0,0,.08); --bg2: rgba(255,255,255,.95); --bg3: rgba(255,255,255,.9); }
body.grad.grad-light #rail { background: rgba(255,255,255,.35); }
body.grad.grad-light #sidebar, body.grad.grad-light #members { background: rgba(255,255,255,.28); }
body.grad.grad-light #main { background: rgba(255,255,255,.18); }
body.grad.grad-light #userbar, body.grad.grad-light #voicebar { background: rgba(255,255,255,.3); }
body.grad #settings { background: var(--grad); }
body.grad #settings nav { background: rgba(0,0,0,.22); }
body.grad.grad-light #settings nav { background: rgba(255,255,255,.3); }
body.grad .card { background: rgba(0,0,0,.22); }
/* Всплывающие окна в цветных темах — непрозрачные, чтобы текст не смешивался с фоном */
body.grad .profile-card, body.grad .menu, body.grad .modal, body.grad .ntf, body.grad .toast, body.grad .incoming { --bg2: #1c1c23; --bg3: #26262f; background: #1c1c23; }
body.grad.grad-light .profile-card, body.grad.grad-light .menu, body.grad.grad-light .modal, body.grad.grad-light .ntf, body.grad.grad-light .toast, body.grad.grad-light .incoming { --bg2: #fff; --bg3: #f0f1f4; background: #fff; }
body.grad .profile-card .pc-box { background: var(--bg3); }
body.grad.grad-light .card { background: rgba(255,255,255,.45); }

.theme-row { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-swatch { position: relative; width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--border); cursor: pointer; transition: transform var(--t); }
.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-swatch.sel::after { content: "✓"; position: absolute; right: -9px; top: -9px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.theme-swatch.off { display: grid; place-items: center; background: var(--bg4); color: var(--muted); }
.grad-grid { display: grid; grid-template-columns: repeat(auto-fill, 52px); gap: 10px; }

/* ================= Профиль ================= */
.profile-card { width: 340px; max-width: calc(100vw - 24px); background: var(--bg2); border-radius: 14px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.55); color: var(--text); }
.profile-card.big { width: 600px; max-height: 90vh; overflow-y: auto; }
.pc-banner { height: 105px; background: var(--accent) center/cover no-repeat; position: relative; }
.profile-card.big .pc-banner { height: 210px; }
.pc-head { position: relative; padding: 0 16px; }
.pc-avatar { position: relative; width: 92px; height: 92px; margin-top: -48px; border-radius: 50%; border: 6px solid var(--bg2); background: var(--bg2); }
.profile-card.big .pc-avatar { width: 136px; height: 136px; margin-top: -72px; border-width: 8px; }
.pc-avatar .avatar { width: 100%; height: 100%; font-size: 34px; }
.pc-avatar .avatar .dot { width: 22px; height: 22px; border-width: 5px; border-color: var(--bg2); right: -2px; bottom: -2px; }
.profile-card.big .pc-avatar .avatar .dot { width: 30px; height: 30px; border-width: 6px; }
.pc-bubble { position: absolute; left: 112px; top: -34px; max-width: calc(100% - 124px); background: var(--bg3); border: 1px solid var(--border); border-radius: 14px; padding: 6px 12px; font-size: 13px; box-shadow: var(--shadow); word-break: break-word; }
.pc-bubble::before, .pc-bubble::after { content: ""; position: absolute; border-radius: 50%; background: var(--bg3); border: 1px solid var(--border); }
.pc-bubble::before { width: 12px; height: 12px; left: -10px; bottom: -4px; }
.pc-bubble::after { width: 6px; height: 6px; left: -19px; bottom: 6px; }
.profile-card.big .pc-bubble { left: 166px; top: -52px; }
.pc-body { padding: 10px 16px 16px; }
.pc-name { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 4px; }
.profile-card.big .pc-name { font-size: 24px; }
.pc-sub { font-size: 14px; opacity: .85; margin-top: 2px; }
.pc-section { margin-top: 14px; }
.pc-section h5 { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.pc-section .txt { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.pc-box { background: var(--bg3); border-radius: 10px; padding: 4px; margin-top: 12px; }
.pc-box button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 10px; border-radius: 8px; text-align: left; font-size: 14px; }
.pc-box button:hover { background: var(--bg4); }
.pc-box button .ic { width: 18px; height: 18px; opacity: .8; }
.pc-box button .chev { margin-left: auto; opacity: .6; transform: rotate(-90deg); }
.pc-box hr { border: 0; border-top: 1px solid var(--border); margin: 2px 8px; }
.pc-box .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--off); margin: 0 3px; }
.pc-note { width: 100%; border: 0; background: transparent; resize: none; font-size: 13px; color: var(--text); outline: none; padding: 4px 0; font-style: italic; }
.pc-note:focus { font-style: normal; }
.pc-msg { display: flex; align-items: center; gap: 6px; margin-top: 14px; background: var(--input); border-radius: 10px; padding: 4px 6px 4px 12px; border: 1px solid var(--border); }
.pc-msg input { flex: 1; border: 0; background: transparent; outline: none; padding: 8px 0; font-size: 14px; }
.pc-actions { display: flex; gap: 8px; margin-top: 14px; }
.pc-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.pc-actions .btn .ic { width: 16px; height: 16px; }
.pc-top { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.pc-top button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.pc-top button .ic { width: 16px; height: 16px; }
.pc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-chip { display: inline-flex; align-items: center; gap: 5px; background: var(--bg3); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.pc-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.popout { position: fixed; z-index: 150; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
.banner-edit { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
@media (max-width: 1100px) { .banner-edit { grid-template-columns: 1fr; } }

.pc-bubble.empty { color: var(--muted); font-style: italic; }
.pc-bubble.mine { cursor: pointer; }
.pc-bubble.mine:hover { border-color: var(--accent); }
.cs-preview { display: flex; justify-content: center; margin-top: 30px; }
.cs-preview .profile-card { box-shadow: none; border: 1px solid var(--border); width: 300px; }
.cs-input { display: flex; align-items: center; gap: 4px; background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: 4px 6px; }
.cs-input:focus-within { border-color: var(--accent); }
.cs-input input { flex: 1; border: 0; background: transparent; outline: none; padding: 8px 4px; font-size: 15px; }

.status-wrap { position: relative; }
.status-fly { position: absolute; left: calc(100% + 16px); top: -8px; width: 300px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 32px rgba(0,0,0,.5); padding: 6px; z-index: 5; }
.status-fly button { align-items: flex-start !important; }
.status-fly button .dot { margin-top: 5px; }
.status-fly small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.status-fly b { font-weight: 600; }
.status-fly .cur { background: var(--bg4); }
.status-fly hr { border: 0; border-top: 1px solid var(--border); margin: 4px 6px; }
@media (max-width: 760px) { .status-fly { left: 0; top: 100%; width: 100%; } }
.pc-mutual { font-size: 12px; color: var(--muted); margin-top: 6px; }
.staff-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent); background: color-mix(in srgb, var(--c) 12%, transparent); border-radius: 6px; padding: 1px 7px; }
.staff-badge .ic { width: 12px; height: 12px; }
.profile-card { overflow: visible; }
.pc-banner { border-radius: 14px 14px 0 0; }

/* Список ЛС: вторая строка и «печатает» */
.side-item .name { display: flex; flex-direction: column; line-height: 1.25; }
.side-item .name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .sub { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.side-item.unread .sub { color: var(--text); font-weight: 600; }
.sub.typing { color: var(--ok); display: inline-flex; align-items: center; gap: 2px; }
.sub.typing i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: tdot 1.2s infinite; display: inline-block; }
.sub.typing i:nth-child(2) { animation-delay: .15s; } .sub.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes tdot { 0%, 60%, 100% { opacity: .25; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
/* Профиль справа от ЛС */
#members.dm-side { width: 340px; padding: 0; display: flex; flex-direction: column; }
#members.dm-side .profile-card { width: 100%; max-width: none; border-radius: 0; box-shadow: none; background: transparent; flex: 1; }
#members.dm-side .pc-banner { border-radius: 0; height: 120px; }
#members.dm-side .pc-avatar { border-color: var(--bg2); }
#members.dm-side .full-btn { margin: 12px 16px 16px; }
body.grad #members.dm-side .pc-avatar { border-color: transparent; background: transparent; }

/* Шапка сервера и каналы */
.srv-title { display: flex; align-items: center; gap: 6px; border: 0; background: transparent; font-weight: 700; padding: 6px 8px; margin-left: -8px; border-radius: 8px; min-width: 0; text-align: left; }
.srv-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-title:hover { background: var(--bg3); }
.srv-title .ic { width: 16px; height: 16px; flex-shrink: 0; }
.ch-gear { display: none; border: 0; background: transparent; color: var(--muted); padding: 2px; border-radius: 4px; margin-left: auto; }
.ch-gear .ic { width: 15px; height: 15px; }
.ch-gear:hover { color: var(--text); }
.side-item:hover .ch-gear, .side-item.active .ch-gear { display: grid; }
.inv-list { max-height: 300px; overflow-y: auto; margin: 0 -8px; }
.inv-list .person { border-top: 0; padding: 6px 8px; }
.cs-input > .ic { width: 18px; height: 18px; color: var(--muted); margin-left: 6px; }
/* Права канала */
.perm-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 12px; background: var(--bg3); border-radius: 10px; padding: 8px; }
.perm-roles { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--border); padding-right: 8px; max-height: 260px; overflow-y: auto; }
.perm-roles button { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 7px 8px; border-radius: 6px; text-align: left; font-size: 14px; }
.perm-roles button i { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.perm-roles button:hover { background: var(--bg4); }
.perm-roles button.sel { background: var(--bg4); font-weight: 600; }
.tri { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tri button { width: 34px; height: 30px; border: 0; background: transparent; color: var(--muted); font-weight: 800; }
.tri button + button { border-left: 1px solid var(--border); }
.tri button.on { background: var(--bg4); color: var(--text); }
.tri button.on.deny { background: var(--danger); color: #fff; }
.tri button.on.allow { background: var(--ok); color: #fff; }
@media (max-width: 600px) { .perm-wrap { grid-template-columns: 1fr; } .perm-roles { border-right: 0; flex-direction: row; flex-wrap: wrap; } }

/* Плеер голосовых */
.vplayer { display: flex; align-items: center; gap: 10px; width: min(360px, 100%); background: var(--bg2); border: 1px solid var(--border); border-radius: 24px; padding: 6px 12px 6px 6px; }
.vp-play { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex-shrink: 0; transition: transform var(--t); }
.vp-play:hover { transform: scale(1.06); }
.vp-play .ic { width: 16px; height: 16px; }
.vp-mid { flex: 1; min-width: 0; }
.vp-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-wave { display: flex; align-items: center; gap: 2px; height: 28px; cursor: pointer; }
.vp-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: color-mix(in srgb, var(--text) 30%, transparent); transition: background .15s; }
.vp-wave i.on { background: var(--accent); }
.vplayer.playing .vp-wave i.on:last-of-type { box-shadow: 0 0 6px var(--accent); }
.vp-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vp-speed { border: 0; background: var(--bg4); border-radius: 6px; font-size: 11px; font-weight: 700; padding: 3px 6px; color: var(--text); }
.vp-dl { color: var(--muted); display: grid; } .vp-dl:hover { color: var(--text); }
.vp-dl .ic { width: 16px; height: 16px; }

/* Мини-окно звонка */
#pip { position: fixed; right: 260px; top: 64px; width: 300px; z-index: 60; background: #111216; border-radius: 12px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.55); cursor: grab; animation: pop .2s ease-out; touch-action: none; user-select: none; }
#pip:active { cursor: grabbing; }
.pip-stage { position: relative; height: 168px; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #2a2c36, #121318); cursor: pointer; }
.pip-stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.pip-ava .avatar { width: 84px; height: 84px; font-size: 30px; transition: box-shadow .15s; }
.pip-ava.speaking .avatar { box-shadow: 0 0 0 3px #111216, 0 0 0 6px var(--ok); }
.pip-name { position: absolute; left: 10px; bottom: 8px; color: #fff; font-size: 13px; font-weight: 600; background: rgba(0,0,0,.5); border-radius: 6px; padding: 2px 8px; }
.pip-live { position: absolute; left: 8px; top: 8px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.pip-bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; color: #ddd; }
.pip-bar .pip-title { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #aab; }
.pip-bar .icon-btn { color: #ccd; }
.pip-bar .icon-btn.on { color: var(--danger); }

/* Нижняя панель пользователя поверх колонки серверов, как в Discord */
#app { position: relative; }
#rail { padding-bottom: 80px; }
#sidebar { padding-bottom: 72px; }
#userbar { position: absolute; left: 8px; bottom: 8px; width: calc(72px + 248px - 16px); height: 58px; border-radius: 12px; z-index: 25; background: var(--bg2); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0,0,0,.35); padding: 0 8px; }
body.grad #userbar { background: rgba(10,10,14,.75); backdrop-filter: blur(10px); }
body.grad.grad-light #userbar { background: rgba(255,255,255,.75); }
#userbar .who .n { font-size: 15px; }
@media (max-width: 640px) { #userbar { width: calc(100vw - 16px); } body.mobile-chat #userbar { display: none; } }

/* ================= Уведомления ================= */
.ntf { width: 360px; max-width: calc(100vw - 32px); background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 32px rgba(0,0,0,.5); padding: 10px 12px 12px; cursor: pointer; animation: ntf-in .2s ease-out; }
@keyframes ntf-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.ntf-top { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.ntf-top img { width: 16px; height: 16px; border-radius: 4px; }
.ntf-top .icon-btn { margin-left: auto; width: 26px; height: 26px; }
.ntf-top .icon-btn .ic { width: 16px; height: 16px; }
.ntf-body { display: flex; gap: 12px; align-items: center; }
.ntf-body .avatar { width: 48px; height: 48px; font-size: 18px; }
.ntf-body .t { font-weight: 700; }
.ntf-body .m { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
