:root{
  --bg-rail:#1e1f22; --bg-side:#2b2d31; --bg-main:#313338; --bg-input:#383a40;
  --bg-hover:#35373c; --bg-active:#404249; --accent:#5865f2; --accent-hi:#4752c4;
  --text:#dbdee1; --text-mut:#949ba4; --text-dim:#80848e; --green:#23a55a; --red:#f23f42;
  --divider:#3f4147;
}
*{box-sizing:border-box;margin:0;padding:0;}
html,body{height:100%;}
body{font-family:"gg sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:var(--bg-main);color:var(--text);overflow:hidden;-webkit-tap-highlight-color:transparent;}
.hidden{display:none !important;}
button{font-family:inherit;cursor:pointer;border:none;background:none;color:inherit;}
input,textarea{font-family:inherit;}
::-webkit-scrollbar{width:8px;height:8px;}
::-webkit-scrollbar-thumb{background:#1a1b1e;border-radius:4px;}
::-webkit-scrollbar-track{background:transparent;}
a{color:#00a8fc;}

/* ---------------- AUTH ---------------- */
.auth{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#5865f2,#404eed 60%,#1e1f22);padding:16px;}
.auth-card{background:var(--bg-main);border-radius:8px;padding:28px;width:100%;max-width:420px;box-shadow:0 8px 24px rgba(0,0,0,.4);}
.auth-logo{font-size:28px;font-weight:800;letter-spacing:.5px;text-align:center;background:linear-gradient(90deg,#7984f5,#c471ed);-webkit-background-clip:text;background-clip:text;color:transparent;}
.auth-sub{text-align:center;color:var(--text-mut);margin:6px 0 22px;}
.auth label{display:block;font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-mut);margin:14px 0 6px;}
.auth input{width:100%;background:#1e1f22;border:1px solid #1e1f22;border-radius:4px;padding:11px;color:var(--text);font-size:15px;outline:none;}
.auth input:focus{border-color:var(--accent);}
.auth-err{color:#fca5a5;font-size:13px;min-height:18px;margin-top:10px;}
#auth-submit{width:100%;margin-top:18px;background:var(--accent);color:#fff;font-weight:600;font-size:15px;padding:12px;border-radius:4px;transition:background .15s;}
#auth-submit:hover{background:var(--accent-hi);}
.auth-switch{margin-top:16px;font-size:13px;color:var(--text-mut);}
.auth-switch a{margin-left:5px;text-decoration:none;}
.auth-switch a:hover{text-decoration:underline;}

/* ---------------- LAYOUT ---------------- */
.app{display:grid;grid-template-columns:72px 240px 1fr auto;grid-template-rows:1fr auto;height:100%;grid-template-areas:"rail side main members" "rail userbar main members";}
.rail{grid-area:rail;background:var(--bg-rail);display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px 0;overflow-y:auto;}
.sidebar{grid-area:side;background:var(--bg-side);display:flex;flex-direction:column;overflow:hidden;}
.userbar{grid-area:userbar;background:#232428;}
.main{grid-area:main;background:var(--bg-main);display:flex;flex-direction:column;overflow:hidden;position:relative;min-width:0;}
.members{grid-area:members;width:240px;background:var(--bg-side);overflow-y:auto;padding:16px 8px;}

/* ---------------- RAIL ---------------- */
.rail-btn{width:48px;height:48px;border-radius:50%;background:var(--bg-side);color:var(--text);font-weight:700;font-size:15px;display:flex;align-items:center;justify-content:center;transition:border-radius .15s,background .15s;flex-shrink:0;overflow:hidden;text-align:center;line-height:1;}
.rail-btn:hover{border-radius:30%;background:var(--accent);color:#fff;}
.rail-btn.active{border-radius:30%;}
.rail-btn.home{background:var(--accent);color:#fff;}
.rail-btn.add{background:var(--bg-side);color:var(--green);font-size:24px;}
.rail-btn.add:hover{background:var(--green);color:#fff;}
.rail-sep{width:32px;height:2px;background:var(--divider);border-radius:1px;flex-shrink:0;}
.rail-server{position:relative;}
.rail-server .pill{position:absolute;left:-12px;top:50%;transform:translateY(-50%);width:4px;height:0;background:#fff;border-radius:0 4px 4px 0;transition:height .15s;}
.rail-server:hover .pill{height:20px;}
.rail-server.active .pill{height:36px;}

/* ---------------- SIDEBAR ---------------- */
.side-head{height:48px;display:flex;align-items:center;padding:0 16px;font-weight:700;font-size:15px;box-shadow:0 1px 0 rgba(0,0,0,.2);flex-shrink:0;cursor:pointer;}
.side-scroll{flex:1;overflow-y:auto;padding:8px;}
.nav-item{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:4px;color:var(--text-mut);font-weight:500;font-size:15px;cursor:pointer;margin-bottom:2px;}
.nav-item:hover{background:var(--bg-hover);color:var(--text);}
.nav-item.active{background:var(--bg-active);color:#fff;}
.nav-item .ic{width:20px;text-align:center;opacity:.8;}
.cat-label{font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-dim);padding:14px 8px 4px;display:flex;justify-content:space-between;align-items:center;}
.cat-label button{color:var(--text-dim);font-size:18px;line-height:1;}
.cat-label button:hover{color:var(--text);}
.chan{display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:4px;color:var(--text-mut);cursor:pointer;font-size:15px;}
.chan:hover{background:var(--bg-hover);color:var(--text);}
.chan.active{background:var(--bg-active);color:#fff;}
.chan .hash{color:var(--text-dim);font-size:16px;width:20px;text-align:center;}
.voice-members{margin:0 0 4px 26px;}
.voice-member{display:flex;align-items:center;gap:6px;padding:3px 6px;font-size:13px;color:var(--text-mut);}

/* avatars */
.av{border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:#fff;font-weight:600;flex-shrink:0;text-transform:uppercase;overflow:hidden;}
.av img{width:100%;height:100%;object-fit:cover;display:block;}
.av.lg{width:80px;height:80px;font-size:32px;}
.av.md{width:40px;height:40px;font-size:16px;}
.av.sm{width:32px;height:32px;font-size:13px;}
.voice-member .av.sm,.voice-member .av{width:20px;height:20px;font-size:10px;}
.av-wrap{position:relative;flex-shrink:0;}
.av-wrap .pres{position:absolute;right:-2px;bottom:-2px;width:12px;height:12px;border-radius:50%;border:3px solid var(--bg-side);background:var(--text-dim);}
.av-wrap .pres.on{background:var(--green);}

/* ---------------- USERBAR ---------------- */
.userbar{display:flex;align-items:center;gap:8px;padding:8px;}
.userbar .uname{font-size:14px;font-weight:600;line-height:1.1;}
.userbar .utag{font-size:12px;color:var(--text-mut);}
.userbar .grow{flex:1;min-width:0;}
.userbar button{width:32px;height:32px;border-radius:4px;color:var(--text-mut);font-size:15px;flex-shrink:0;}
.userbar button:hover{background:var(--bg-hover);color:var(--text);}

/* ---------------- MAIN ---------------- */
.main-head{height:48px;display:flex;align-items:center;gap:8px;padding:0 16px;box-shadow:0 1px 0 rgba(0,0,0,.2);flex-shrink:0;font-weight:700;}
.main-head .hash{color:var(--text-dim);font-size:22px;}
.msgs{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:2px;}
.msg{display:flex;gap:14px;padding:4px 8px 4px 0;position:relative;border-radius:4px;}
.msg:hover{background:rgba(0,0,0,.06);}
.msg .body{min-width:0;flex:1;}
.msg .head{display:flex;align-items:baseline;gap:8px;}
.msg .author{font-weight:600;font-size:15px;}
.msg .time{font-size:11px;color:var(--text-dim);}
.msg .text{font-size:15px;line-height:1.375;white-space:pre-wrap;word-wrap:break-word;overflow-wrap:anywhere;color:#dbdee1;}
.msg.cont{padding:1px 8px 1px 54px;}
.edited{color:var(--text-dim);font-size:11px;margin-left:6px;}
.msg-img{max-width:min(360px,80%);max-height:300px;border-radius:8px;margin-top:6px;display:block;cursor:pointer;background:#1e1f22;}
.msg-actions{position:absolute;top:-12px;right:12px;display:none;background:var(--bg-rail);border:1px solid var(--divider);border-radius:8px;overflow:hidden;}
.msg:hover .msg-actions{display:flex;}
.msg-actions button{padding:5px 9px;font-size:14px;color:var(--text-mut);}
.msg-actions button:hover{background:var(--bg-hover);color:var(--text);}
.edit-area{width:100%;background:var(--bg-input);border:none;border-radius:6px;color:var(--text);padding:8px 10px;font-size:15px;line-height:1.375;outline:none;resize:none;}
.composer{padding:0 16px 22px;flex-shrink:0;}
.composer .box{background:var(--bg-input);border-radius:8px;display:flex;align-items:flex-end;}
.composer .attach{font-size:24px;color:var(--text-mut);padding:0 4px 9px 14px;align-self:flex-end;line-height:1;}
.composer .attach:hover{color:var(--text);}
.composer textarea{flex:1;background:none;border:none;outline:none;resize:none;color:var(--text);font-size:15px;padding:11px 14px;max-height:180px;line-height:1.375;}
.composer textarea::placeholder{color:var(--text-dim);}
.empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--text-mut);gap:10px;text-align:center;padding:20px;}
.empty .big{font-size:46px;}

/* friends page */
.friends-tabs{display:flex;align-items:center;gap:8px;height:48px;padding:0 16px;box-shadow:0 1px 0 rgba(0,0,0,.2);flex-shrink:0;}
.fr-body{flex:1;overflow-y:auto;padding:16px 20px;}
.fr-addbox{display:flex;gap:8px;margin-bottom:18px;}
.fr-addbox input{flex:1;background:#1e1f22;border:1px solid #111;border-radius:8px;padding:11px;color:var(--text);outline:none;font-size:15px;}
.fr-addbox button{background:var(--accent);color:#fff;font-weight:600;padding:0 16px;border-radius:8px;white-space:nowrap;}
.fr-section-label{font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-mut);margin:8px 0;}
.fr-row{display:flex;align-items:center;gap:12px;padding:10px 6px;border-top:1px solid var(--divider);}
.fr-row .grow{flex:1;min-width:0;}
.fr-row .nm{font-weight:600;}
.fr-row .st{font-size:13px;color:var(--text-mut);}
.fr-row .acts{display:flex;gap:8px;}
.fr-row .acts button{width:38px;height:38px;border-radius:50%;background:var(--bg-rail);font-size:16px;display:flex;align-items:center;justify-content:center;}
.fr-row .acts button:hover{background:var(--bg-active);}

/* members panel */
.mem-label{font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-dim);padding:8px;}
.mem-row{display:flex;align-items:center;gap:10px;padding:6px 8px;border-radius:4px;cursor:pointer;}
.mem-row:hover{background:var(--bg-hover);}
.mem-row .nm{font-size:15px;color:var(--text);}
.mem-row.off{opacity:.4;}

/* voicebar */
.app .voicebar{grid-area:userbar;}
.voicebar{background:#1e1f22;display:flex;align-items:center;justify-content:space-between;padding:8px 10px;}
.voicebar-info{display:flex;align-items:center;gap:8px;min-width:0;}
.vb-dot{width:8px;height:8px;border-radius:50%;background:var(--green);box-shadow:0 0 0 3px rgba(35,165,90,.2);flex-shrink:0;}
.vb-status{font-size:13px;font-weight:700;color:var(--green);}
.vb-channel{font-size:12px;color:var(--text-mut);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.voicebar-actions{display:flex;gap:4px;}
.voicebar-actions button{width:34px;height:34px;border-radius:6px;font-size:15px;background:var(--bg-active);}
.voicebar-actions button:hover{background:#4e5058;}
.voicebar-actions button.muted{background:var(--red);}
.voicebar-actions button.danger:hover{background:var(--red);}

/* modal */
.modal{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;z-index:60;padding:16px;}
.modal-box{background:var(--bg-main);border-radius:8px;width:100%;max-width:440px;padding:24px;max-height:90vh;overflow-y:auto;}
.modal-box h2{font-size:20px;margin-bottom:6px;}
.modal-box p{color:var(--text-mut);font-size:14px;margin-bottom:8px;}
.modal-box label{display:block;font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-mut);margin:12px 0 6px;}
.modal-box input{width:100%;background:#1e1f22;border:none;border-radius:4px;padding:11px;color:var(--text);font-size:15px;outline:none;}
.modal-tabs{display:flex;gap:8px;margin-bottom:14px;}
.modal-tabs button{flex:1;padding:9px;border-radius:6px;background:var(--bg-input);color:var(--text-mut);font-weight:600;}
.modal-tabs button.active{background:var(--accent);color:#fff;}
.modal-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:20px;align-items:center;}
.modal-actions .ghost{color:var(--text);padding:10px 16px;}
.modal-actions .ghost:hover{text-decoration:underline;}
.modal-actions .primary{background:var(--accent);color:#fff;font-weight:600;padding:10px 20px;border-radius:4px;}
.modal-actions .primary:hover{background:var(--accent-hi);}
.invite-code{background:#1e1f22;border-radius:4px;padding:10px;font-family:monospace;font-size:15px;display:flex;justify-content:space-between;align-items:center;margin-top:6px;}
.invite-code button{color:var(--accent);font-weight:600;}

/* toasts */
.toasts{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);display:flex;flex-direction:column;gap:8px;z-index:80;align-items:center;max-width:92vw;}
.toast{background:#111214;color:#fff;padding:10px 18px;border-radius:8px;font-size:14px;box-shadow:0 4px 16px rgba(0,0,0,.5);border-left:4px solid var(--accent);animation:tin .2s ease;text-align:center;}
.toast.ok{border-color:var(--green);}
.toast.err{border-color:var(--red);}
@keyframes tin{from{opacity:0;transform:translateY(10px);}to{opacity:1;}}

/* backdrop for mobile drawers */
.nav-backdrop{display:none;}

/* mobile */
.mobile-only{display:none;}
@media(max-width:820px){
  html,body{height:100dvh;}
  .app{grid-template-columns:1fr;grid-template-rows:1fr;grid-template-areas:"main";height:100dvh;}
  .main{grid-area:main;width:100vw;}
  .rail{position:fixed;top:0;bottom:0;left:0;z-index:42;transform:translateX(-100%);transition:transform .22s ease;}
  .sidebar{position:fixed;top:0;bottom:54px;left:72px;width:min(calc(100vw - 72px),300px);z-index:42;transform:translateX(calc(-72px - 100%));transition:transform .22s ease;}
  .userbar{display:flex;position:fixed;left:72px;bottom:0;height:54px;width:min(calc(100vw - 72px),300px);z-index:42;transform:translateX(calc(-72px - 100%));transition:transform .22s ease;}
  .app.nav-open .rail,.app.nav-open .sidebar,.app.nav-open .userbar{transform:translateX(0);}
  .members{position:fixed;top:0;bottom:0;right:0;width:min(78vw,300px);z-index:42;transform:translateX(110%);transition:transform .22s ease;}
  .app.mem-open .members{transform:translateX(0);}
  .nav-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:41;}
  .app.nav-open .nav-backdrop,.app.mem-open .nav-backdrop{display:block;}
  .voicebar{position:fixed;left:0;right:0;bottom:0;width:100%;z-index:30;}
  .app.nav-open .voicebar{left:min(calc(100vw - 72px),300px);}
  .mobile-only{display:flex;align-items:center;}
  .msg-actions{display:flex;top:auto;bottom:6px;}
  .msg-img{max-width:80%;}
}

/* ---- userbar controls (Discord-style) ---- */
.ub-inner{display:flex;align-items:center;width:100%;gap:4px;}
.ub-user{display:flex;align-items:center;gap:8px;flex:1;min-width:0;}
.ub-ctrls{display:flex;gap:1px;flex-shrink:0;}
.ub-ctrls button{width:34px;height:34px;border-radius:6px;color:var(--text-mut);font-size:15px;}
.ub-ctrls button:hover{background:var(--bg-hover);color:var(--text);}
.ub-ctrls button.off{color:var(--red);}

/* ---- header buttons (call / hamburger / members) ---- */
.headbtn{width:36px;height:36px;border-radius:6px;color:var(--text-mut);font-size:18px;line-height:36px;text-align:center;flex-shrink:0;}
.headbtn:hover{background:var(--bg-hover);color:var(--text);}
.fr-row .acts button.call:hover{color:var(--green);}

/* ---- voice settings select ---- */
.vk-select{width:100%;background:#1e1f22;border:none;border-radius:4px;padding:11px;color:var(--text);font-size:15px;outline:none;}

/* ---- incoming call banner ---- */
.incoming-call{position:fixed;top:16px;left:50%;transform:translateX(-50%);background:var(--bg-side);border:1px solid var(--divider);border-radius:14px;padding:12px 16px;display:flex;align-items:center;gap:14px;z-index:90;box-shadow:0 10px 30px rgba(0,0,0,.55);animation:tin .2s ease;max-width:92vw;}
.incoming-call .ic-info{min-width:0;}
.incoming-call .ic-name{font-weight:700;font-size:15px;}
.incoming-call .ic-sub{font-size:12px;color:var(--text-mut);}
.incoming-call .ic-actions{display:flex;gap:8px;}
.incoming-call .ic-actions button{width:44px;height:44px;border-radius:50%;font-size:18px;color:#fff;display:flex;align-items:center;justify-content:center;}
#ic-accept{background:var(--green);}
#ic-accept:hover{filter:brightness(1.1);}
#ic-decline{background:var(--red);}
#ic-decline:hover{filter:brightness(1.1);}

/* ---- svg buttons / clickable ---- */
.ub-ctrls button{display:inline-flex;align-items:center;justify-content:center;}
.headbtn{display:inline-flex;align-items:center;justify-content:center;line-height:1;}
.mobile-only{display:none!important;}
@media(max-width:820px){.mobile-only{display:inline-flex!important;align-items:center;justify-content:center;}}
.clickable,.hname{cursor:pointer;}
.hname:hover{text-decoration:underline;}
.headbtn svg,.ccb svg,.ub-ctrls svg,.acts svg{pointer-events:none;}
.fr-row .acts button.call{color:var(--green);}

/* ---- avatar xl + speaking ring ---- */
.av.xl{width:88px;height:88px;font-size:34px;}
.av-wrap.speaking .av,.voice-member.speaking .av,.mem-row.speaking .av,.nav-item.speaking .av{box-shadow:0 0 0 2px var(--green),0 0 8px 1px rgba(35,165,90,.55);}
.voice-member{border-radius:6px;cursor:pointer;}
.voice-member:hover{background:var(--bg-hover);}

/* ---- call view ---- */
.call-stage{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:24px;padding:24px;overflow:auto;background:radial-gradient(circle at 50% 28%,#33363d,#1e1f22);}
.call-grid{display:flex;flex-wrap:wrap;gap:18px;justify-content:center;align-items:center;max-width:900px;}
.call-tile{display:flex;flex-direction:column;align-items:center;gap:12px;background:#232428;border-radius:16px;padding:26px 30px;min-width:150px;box-shadow:0 4px 14px rgba(0,0,0,.25);}
.ct-ring{border-radius:50%;padding:4px;transition:box-shadow .1s;}
.call-tile.speaking .ct-ring{box-shadow:0 0 0 3px var(--green),0 0 24px 4px rgba(35,165,90,.45);}
.ct-name{font-weight:600;font-size:15px;display:flex;align-items:center;gap:6px;}
.ct-mute svg{width:15px;height:15px;color:var(--red);vertical-align:middle;}
.call-hint{color:var(--text-mut);font-size:14px;}
.call-controls{display:flex;gap:14px;padding:6px;}
.ccb{width:56px;height:56px;border-radius:50%;background:#3a3c42;color:#fff;display:flex;align-items:center;justify-content:center;transition:background .12s,filter .12s;}
.ccb:hover{background:#4a4d55;}
.ccb.off{background:var(--red);}
.ccb.hang{background:var(--red);}
.ccb.hang:hover{filter:brightness(1.12);}

/* ---- profile modal ---- */
.profile-head{height:72px;border-radius:8px 8px 0 0;margin:-24px -24px 0;}
.profile-body{text-align:center;}
.profile-av{margin-top:-46px;display:inline-block;border:6px solid var(--bg-main);border-radius:50%;background:var(--bg-main);}
.profile-name{font-size:20px;font-weight:700;margin-top:10px;}
.profile-tag{color:var(--text-mut);font-size:14px;margin-bottom:16px;}
.profile-body .modal-actions button{padding:9px 16px;}

/* ---- voice quick popover (slide-out) ---- */
#voice-pop{position:fixed;left:8px;bottom:66px;width:300px;max-width:calc(100vw - 16px);background:#111214;border:1px solid var(--divider);border-radius:12px;padding:14px;z-index:70;box-shadow:0 12px 34px rgba(0,0,0,.6);transform:translateY(10px);opacity:0;transition:transform .16s ease,opacity .16s ease;}
#voice-pop.open{transform:translateY(0);opacity:1;}
#voice-pop.hidden{display:none;}
.vp-row{margin-bottom:12px;}
.vp-row label{display:block;font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-mut);margin-bottom:5px;}
.vp-screen,.vp-settings{width:100%;padding:10px;border-radius:8px;margin-top:6px;font-weight:600;display:flex;align-items:center;justify-content:center;gap:8px;}
.vp-screen{background:var(--accent);color:#fff;}
.vp-screen.on{background:var(--red);}
.vp-screen:hover{filter:brightness(1.08);}
.vp-settings{background:var(--bg-input);color:var(--text);}
.vp-settings:hover{background:var(--bg-active);}
@media(max-width:820px){#voice-pop{left:50%;transform:translate(-50%,10px);bottom:70px;}#voice-pop.open{transform:translate(-50%,0);}}

/* ---- screen share tiles ---- */
.call-screens{display:flex;flex-wrap:wrap;gap:14px;justify-content:center;width:100%;}
.screen-tile{background:#000;border-radius:12px;overflow:hidden;position:relative;max-width:min(680px,94%);box-shadow:0 6px 20px rgba(0,0,0,.4);}
.screen-tile video{display:block;width:100%;max-height:54vh;background:#000;}
.screen-tile .st-name{position:absolute;left:8px;bottom:8px;background:rgba(0,0,0,.65);padding:4px 9px;border-radius:6px;font-size:12px;color:#fff;}
.ccb.live{background:var(--accent);}
.ccb.live:hover{filter:brightness(1.1);}
.vm-live{color:var(--red);font-size:10px;margin-left:auto;}
.voice-member{justify-content:flex-start;}

/* ---- camera / video tiles ---- */
.ct-video{width:240px;height:150px;border-radius:14px;object-fit:cover;background:#000;display:block;box-shadow:0 4px 14px rgba(0,0,0,.3);}
.call-tile.hasvid{background:transparent;box-shadow:none;padding:0;}
.call-tile.hasvid .ct-name{margin-top:8px;}
.call-tile.hasvid.speaking .ct-video{box-shadow:0 0 0 3px var(--green),0 0 22px 3px rgba(35,165,90,.45);}
.mirror{transform:scaleX(-1);}
.screen-tile video{max-height:70vh;}
.screen-tile .st-full{position:absolute;top:8px;right:8px;background:rgba(0,0,0,.55);color:#fff;width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;}
.screen-tile .st-full:hover{background:rgba(0,0,0,.85);}
.vp-btn{width:100%;padding:11px;border-radius:8px;margin-top:6px;font-weight:600;display:flex;align-items:center;justify-content:center;gap:8px;color:#fff;}
.vp-btn.cam{background:#3a3c42;} .vp-btn.cam.on{background:var(--accent);}
.vp-btn.screen{background:var(--accent);} .vp-btn.screen.on{background:var(--red);}
.vp-btn:hover{filter:brightness(1.08);}

/* ---- settings window (Discord-like) ---- */
#settings{position:fixed;inset:0;background:var(--bg-main);z-index:100;display:flex;}
#settings.hidden{display:none;}
.set-nav{width:230px;background:var(--bg-side);padding:46px 10px 20px;overflow-y:auto;flex-shrink:0;display:flex;flex-direction:column;align-items:flex-end;}
.set-nav-inner{width:170px;}
.set-cat{font-size:12px;font-weight:700;color:var(--text-dim);text-transform:uppercase;padding:14px 10px 6px;}
.sn-item{padding:8px 10px;border-radius:4px;color:var(--text-mut);font-weight:500;cursor:pointer;margin-bottom:2px;}
.sn-item:hover{background:var(--bg-hover);color:var(--text);}
.sn-item.active{background:var(--bg-active);color:#fff;}
.sn-item.danger{color:#f0a0a0;}
.set-main{flex:1;overflow-y:auto;padding:46px 40px 80px;}
.set-inner{max-width:680px;}
.set-close{position:fixed;top:34px;right:44px;width:38px;height:38px;border-radius:50%;border:2px solid var(--text-mut);color:var(--text-mut);display:flex;align-items:center;justify-content:center;font-size:16px;background:transparent;}
.set-close:hover{background:var(--bg-hover);color:#fff;border-color:#fff;}
.set-h1{font-size:20px;font-weight:700;margin-bottom:22px;}
.set-sec{margin-bottom:26px;}
.set-label{font-size:12px;font-weight:700;text-transform:uppercase;color:var(--text-mut);margin-bottom:8px;}
.set-hint{font-size:12px;color:var(--text-dim);margin-top:6px;}
.set-row{display:flex;gap:18px;flex-wrap:wrap;}
.set-row > div{flex:1;min-width:230px;}
.set-divider{height:1px;background:var(--divider);margin:18px 0;}
input[type=range].rng{-webkit-appearance:none;width:100%;height:8px;border-radius:4px;background:#1e1f22;outline:none;margin-top:6px;}
input[type=range].rng::-webkit-slider-thumb{-webkit-appearance:none;width:18px;height:18px;border-radius:50%;background:#fff;cursor:pointer;box-shadow:0 1px 4px rgba(0,0,0,.5);}
input[type=range].rng::-moz-range-thumb{width:18px;height:18px;border:none;border-radius:50%;background:#fff;cursor:pointer;}
.btn-test{background:var(--accent);color:#fff;font-weight:600;padding:10px 18px;border-radius:4px;}
.btn-test.on{background:var(--red);}
.bars{display:flex;gap:3px;height:26px;align-items:flex-end;margin:10px 0;}
.bars > i{flex:1;background:#4e5058;border-radius:2px;height:18%;transition:height .05s,background .05s;}
.set-toggle-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 0;border-top:1px solid var(--divider);}
.set-toggle-row .tt{font-weight:600;} .set-toggle-row .td{font-size:12px;color:var(--text-mut);}
.set-radio{display:flex;align-items:center;gap:10px;padding:9px 0;cursor:pointer;color:var(--text);}
.set-radio input{width:18px;height:18px;accent-color:var(--accent);}
.sens-wrap{position:relative;height:10px;border-radius:5px;background:#1e1f22;margin-top:10px;overflow:hidden;}
.sens-fill{position:absolute;left:0;top:0;bottom:0;width:0;background:linear-gradient(90deg,#23a55a,#f0b232,#f23f42);opacity:.7;}
.sens-thumb{position:absolute;top:-4px;width:4px;height:18px;background:#fff;border-radius:2px;}
.sw{width:42px;height:24px;border-radius:12px;background:#72767d;position:relative;flex-shrink:0;cursor:pointer;transition:background .15s;}
.sw.on{background:var(--green);}
.sw::after{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff;transition:left .15s;}
.sw.on::after{left:21px;}
@media(max-width:820px){.set-nav{width:140px;padding-top:54px;align-items:stretch;}.set-nav-inner{width:auto;}.set-main{padding:54px 16px 70px;}.set-close{top:12px;right:14px;}}

/* ---- video gallery (camera + screen big) ---- */
.call-videos{display:flex;flex-wrap:wrap;gap:14px;justify-content:center;width:100%;}
.video-tile{background:#000;border-radius:12px;overflow:hidden;position:relative;max-width:min(680px,94%);box-shadow:0 6px 20px rgba(0,0,0,.4);}
.video-tile video{display:block;width:100%;max-height:62vh;background:#000;}
.video-tile .st-full{position:absolute;top:8px;right:8px;background:rgba(0,0,0,.55);color:#fff;width:36px;height:36px;border-radius:8px;display:flex;align-items:center;justify-content:center;}
.video-tile .st-full:hover{background:rgba(0,0,0,.85);}
.video-tile .st-name{position:absolute;left:8px;bottom:8px;background:rgba(0,0,0,.65);padding:4px 9px;border-radius:6px;font-size:12px;color:#fff;}

/* ---- dm call banner ---- */
.call-banner{display:flex;align-items:center;justify-content:space-between;gap:12px;background:#1e1f22;border-bottom:1px solid var(--divider);padding:8px 16px;color:var(--green);font-weight:600;flex-shrink:0;}
.call-banner .cb-acts{display:flex;gap:8px;}
.call-banner button{padding:6px 12px;border-radius:6px;font-weight:600;color:#fff;}
.call-banner #cb-open{background:var(--accent);}
.call-banner #cb-end{background:var(--red);}

/* ---- channel delete (owner) ---- */
.chan .cn{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.chan .chdel{margin-left:auto;color:var(--text-dim);font-size:13px;width:20px;height:20px;border-radius:4px;display:none;flex-shrink:0;line-height:18px;text-align:center;}
.chan:hover .chdel{display:block;}
.chan .chdel:hover{color:var(--red);background:rgba(0,0,0,.25);}

/* ---- image lightbox ---- */
#lightbox{position:fixed;inset:0;background:rgba(0,0,0,.85);z-index:110;display:flex;align-items:center;justify-content:center;padding:20px;cursor:zoom-out;}
#lightbox.hidden{display:none;}
#lightbox img{max-width:96vw;max-height:96vh;border-radius:8px;box-shadow:0 10px 40px rgba(0,0,0,.6);}

/* ---- staged attachments + send button ---- */
.attach-preview{display:flex;flex-wrap:wrap;gap:8px;padding:10px 12px 2px;}
.att-chip{position:relative;width:84px;height:84px;border-radius:8px;overflow:hidden;background:#1e1f22;flex-shrink:0;}
.att-chip img{width:100%;height:100%;object-fit:cover;}
.att-chip .att-x{position:absolute;top:3px;right:3px;width:22px;height:22px;border-radius:50%;background:rgba(0,0,0,.7);color:#fff;font-size:12px;display:flex;align-items:center;justify-content:center;line-height:1;}
.att-chip .att-x:hover{background:var(--red);}
.composer .sendbtn{align-self:flex-end;color:var(--accent);font-size:20px;padding:0 14px 9px 4px;line-height:1;}
.composer .sendbtn:hover{filter:brightness(1.25);}

/* ---- profile dates ---- */
.profile-meta{text-align:left;background:#1e1f22;border-radius:8px;padding:10px 14px;margin:0 0 16px;}
.profile-meta .pm-row{display:flex;justify-content:space-between;gap:12px;font-size:13px;padding:4px 0;}
.profile-meta .pm-l{color:var(--text-mut);}
.profile-meta .pm-v{color:var(--text);font-weight:600;white-space:nowrap;}

/* ---- per-user volume + ping in call tile ---- */
.ct-ping{font-size:11px;color:var(--text-mut);margin-top:4px;}
.ct-vol{width:110px;margin-top:8px;height:6px;}

/* ---- ping in userbar + right-click context menu ---- */
.ub-ping{font-weight:600;}
#ctxmenu{position:fixed;z-index:120;background:#111214;border:1px solid var(--divider);border-radius:8px;padding:6px;min-width:210px;box-shadow:0 8px 30px rgba(0,0,0,.6);}
#ctxmenu.hidden{display:none;}
.ctx-item{padding:9px 10px;border-radius:5px;cursor:pointer;font-size:14px;color:var(--text);}
.ctx-item:hover{background:var(--accent);color:#fff;}
.ctx-sep{height:1px;background:var(--divider);margin:6px 0;}
.ctx-vol{padding:6px 10px 8px;}
.ctx-vl{font-size:13px;color:var(--text-mut);margin-bottom:8px;}
.ctx-vol .rng{width:100%;}

/* ---- upload progress chip ---- */
.att-chip.uploading{display:flex;flex-direction:column;align-items:center;justify-content:center;background:#1e1f22;gap:6px;padding:6px;}
.att-prog{width:72%;height:6px;border-radius:3px;background:#111214;overflow:hidden;}
.att-prog > i{display:block;height:100%;width:0;background:var(--accent);transition:width .12s;}
.att-pct{font-size:11px;color:var(--text-mut);}

/* ---- server icon ---- */
.srv-ic{display:inline-flex;align-items:center;justify-content:center;border-radius:50%;background:var(--accent);color:#fff;font-weight:700;overflow:hidden;text-transform:uppercase;flex-shrink:0;}
.srv-ic.lg{width:64px;height:64px;font-size:24px;}
.srv-ic img{width:100%;height:100%;object-fit:cover;}
.rail-btn.hasimg{padding:0;background:#1e1f22;}
.rail-btn img{width:100%;height:100%;object-fit:cover;}

/* ---- ping in voicebar (right) ---- */
.vb-ping{font-size:12px;font-weight:600;color:var(--text-mut);white-space:nowrap;}
.vb-status{font-size:12px;}

/* ---- bottom-left stack (voicebar / quick controls / userbar) ---- */
#botleft{grid-area:userbar;display:flex;flex-direction:column;min-width:0;}
.voice-quick{display:flex;gap:6px;padding:6px 8px;background:#232428;box-shadow:0 -1px 0 rgba(0,0,0,.2);}
.voice-quick.hidden{display:none;}
.vq-btn{flex:1;height:34px;border-radius:6px;background:var(--bg-active);color:var(--text);display:flex;align-items:center;justify-content:center;}
.vq-btn:hover{background:#4e5058;}
.vq-btn.on{background:var(--accent);color:#fff;}
@media(max-width:820px){#botleft{display:contents;}.voice-quick{display:none!important;}}

/* ===== call view redesign (Discord-like) ===== */
.call-stage{flex:1;display:flex;align-items:center;justify-content:center;background:#070708;padding:14px 14px 100px;position:relative;overflow:hidden;}
.tiles-grid{display:grid;gap:10px;width:100%;max-width:1300px;margin:auto;align-content:center;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));}
.tiles-grid.n1{grid-template-columns:minmax(0,960px);}
.vtile{position:relative;background:#16191f;border-radius:10px;overflow:hidden;aspect-ratio:16/9;width:100%;min-height:0;display:flex;align-items:center;justify-content:center;}
.vtile.video video{width:100%;height:100%;object-fit:contain;background:#000;}
.vtile .vt-name{position:absolute;left:8px;bottom:8px;background:rgba(0,0,0,.6);padding:3px 9px;border-radius:6px;font-size:13px;color:#fff;display:flex;align-items:center;gap:6px;max-width:80%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.vtile .vt-name .ct-mute svg{width:14px;height:14px;color:var(--red);vertical-align:middle;}
.vtile .st-full{position:absolute;top:8px;right:8px;background:rgba(0,0,0,.55);color:#fff;width:34px;height:34px;border-radius:8px;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .12s;}
.vtile:hover .st-full{opacity:1;}
.vtile.speaking{box-shadow:inset 0 0 0 3px var(--green),0 0 16px rgba(35,165,90,.35);}
.focus-wrap{width:100%;height:100%;display:flex;flex-direction:column;gap:10px;align-items:center;justify-content:center;min-height:0;}
.ftile{width:96%;max-width:1500px;flex:1;min-height:0;aspect-ratio:auto;}
.tiles-strip{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;flex-shrink:0;max-height:120px;overflow:auto;}
.tiles-strip .vtile{width:170px;aspect-ratio:16/9;}
.call-controls{position:absolute;left:50%;bottom:20px;transform:translateX(-50%);display:flex;gap:8px;align-items:center;background:rgba(0,0,0,.45);padding:8px 10px;border-radius:18px;z-index:5;}
.ccb{width:48px;height:48px;border-radius:14px;background:#2b2d34;color:#fff;display:flex;align-items:center;justify-content:center;transition:background .12s,filter .12s;}
.ccb:hover{background:#3a3c44;}
.ccb.off{background:var(--red);}
.ccb.live{background:var(--accent);}
.ccb.hang{width:64px;background:#da373c;}
.ccb.hang:hover{filter:brightness(1.1);}
.call-hint{position:absolute;top:66px;left:50%;transform:translateX(-50%);color:var(--text-mut);font-size:14px;}
/* whole-row speaking glow in sidebar voice list */
.voice-member.speaking{box-shadow:inset 0 0 0 2px var(--green);border-radius:6px;}
.voice-member.speaking .av{box-shadow:none;}

/* camera fills tile (no bars); screen stays contain */
.vtile.cam video{object-fit:cover;}
/* expanded tile: exactly 16:9 so 16:9 video has no black top/bottom bars */
.ftile{flex:1 1 auto;min-height:0;width:auto;max-width:96%;aspect-ratio:16/9;margin:auto;background:#000;}
.ftile.cam video{object-fit:cover;}

/* ---- activities ---- */
.act-list{display:flex;flex-direction:column;gap:8px;margin:6px 0;}
.act-card{display:flex;align-items:center;gap:12px;background:#1e1f22;border-radius:10px;padding:12px 14px;}
.act-card.disabled{opacity:.65;}
.act-ic{font-size:26px;width:42px;height:42px;display:flex;align-items:center;justify-content:center;background:#111214;border-radius:10px;flex-shrink:0;}
.act-info{flex:1;min-width:0;}
.act-name{font-weight:700;}
.act-sub{font-size:12px;color:var(--text-mut);}
.act-soon{font-size:11px;font-weight:700;color:var(--text-mut);background:#111214;padding:4px 8px;border-radius:6px;}

/* ---- file attachments ---- */
.att-chip.file{display:flex;flex-direction:column;align-items:center;justify-content:center;background:#1e1f22;gap:4px;padding:6px;text-align:center;}
.att-chip.file .af-ic{font-size:24px;}
.att-chip.file .af-nm{font-size:10px;color:var(--text-mut);max-width:78px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.att-chip.file .att-x{position:absolute;top:3px;right:3px;width:20px;height:20px;border-radius:50%;background:rgba(0,0,0,.7);color:#fff;font-size:11px;display:flex;align-items:center;justify-content:center;}
.msg-files{display:flex;flex-wrap:wrap;gap:8px;margin-top:4px;align-items:flex-start;}
.msg-file{display:flex;align-items:center;gap:10px;background:#2b2d31;border:1px solid var(--divider);border-radius:8px;padding:10px 12px;text-decoration:none;color:var(--text);max-width:320px;}
.msg-file:hover{background:var(--bg-hover);}
.msg-file .mf-ic{font-size:24px;flex-shrink:0;}
.msg-file .mf-info{display:flex;flex-direction:column;min-width:0;}
.msg-file .mf-nm{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.msg-file .mf-dl{font-size:12px;color:var(--accent);}
.main.dragover::after{content:'Перетащите файлы сюда';position:absolute;inset:8px;border:2px dashed var(--accent);border-radius:12px;background:rgba(88,101,242,.14);display:flex;align-items:center;justify-content:center;font-size:18px;font-weight:700;color:#fff;z-index:20;pointer-events:none;}

/* ---- shared browser activity ---- */
.act-card{cursor:pointer;}
.act-card:hover{background:#26272b;}
.act-go-b{font-size:12px;font-weight:700;color:#fff;background:var(--accent);padding:6px 12px;border-radius:6px;white-space:nowrap;}
.act-view{position:relative;flex:1 1 auto;min-height:0;width:auto;max-width:100%;aspect-ratio:16/9;margin:auto;background:#000;border-radius:10px;overflow:hidden;}
.act-bar{position:absolute;top:0;left:0;right:0;z-index:3;display:flex;gap:6px;padding:8px;background:rgba(22,25,31,.92);align-items:center;transform:translateY(-100%);transition:transform .18s;}
.act-bar.open{transform:translateY(0);}
#act-ctrls{position:absolute;inset:0;pointer-events:none;}
#act-ctrls .act-toggle,#act-ctrls .act-bar{pointer-events:auto;}
.act-toggle{position:absolute;top:8px;left:8px;z-index:4;width:34px;height:34px;border-radius:8px;background:rgba(22,25,31,.8);color:#fff;font-size:16px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center;border:none;}
.act-toggle:hover{background:rgba(40,43,52,.95);}
.act-bar .act-url{flex:1;background:#0b0c0e;border:1px solid var(--divider);border-radius:6px;padding:8px 10px;color:#fff;outline:none;font-size:14px;}
.act-bar .act-btn{background:var(--bg-active);color:#fff;border-radius:6px;padding:8px 12px;}
.act-bar .act-btn:hover{background:#4e5058;}
.act-screen{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#000;outline:none;cursor:default;}
.act-screen img,.act-screen video{width:100%;height:100%;object-fit:contain;display:block;}
.act-screen.viewonly{cursor:default;}
.act-viewonly{align-self:center;color:#f0b232;font-size:13px;padding:0 8px;white-space:nowrap;}
.ap-list{display:flex;flex-direction:column;gap:6px;margin:10px 0;max-height:320px;overflow:auto;}
.ap-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 10px;background:#1e2127;border-radius:8px;}
.ap-name{color:#fff;font-size:14px;}
.ap-toggle{background:#404249;color:#fff;border-radius:6px;padding:6px 12px;font-size:13px;cursor:pointer;}
.ap-toggle:hover{background:#4e5058;}
.ap-toggle.on{background:#248046;}
.ap-toggle.on:hover{background:#1f6e3c;}

.sq-row{display:flex;gap:8px;margin:10px 0;flex-wrap:wrap;}
.sq-b{background:#404249;color:#fff;border-radius:8px;padding:9px 16px;cursor:pointer;border:none;font-size:14px;}
.sq-b:hover{background:#4e5058;}
.sq-b.on{background:#5865f2;}
/* drag & drop: move users into voice rooms */
.chan.drop-ok{background:rgba(88,101,242,.30)!important;box-shadow:inset 0 0 0 2px var(--accent,#5865f2)}
.voice-member.dragging,.mem-row.dragging,.vtile.dragging,.nav-item.dragging{opacity:.4}
.voice-member[draggable="true"],.mem-row[draggable="true"]{cursor:grab}
.voice-member.dragging,.mem-row.dragging{cursor:grabbing}
/* avatar cropper */
.crop-stage{position:relative;width:280px;height:280px;margin:14px auto 4px;border-radius:50%;overflow:hidden;background:#1e1f22;cursor:grab;touch-action:none;user-select:none}
.crop-stage:active{cursor:grabbing}
.crop-stage img{position:absolute;max-width:none;user-select:none;-webkit-user-drag:none;pointer-events:none}
.crop-mask{position:absolute;inset:0;border-radius:50%;box-shadow:0 0 0 2000px rgba(0,0,0,.5) inset,0 0 0 2px rgba(255,255,255,.5) inset;pointer-events:none}
.crop-zoom{display:flex;align-items:center;gap:10px;width:280px;margin:8px auto 0}
.crop-zoom .rng{flex:1}
.crop-zoom span{color:var(--text-mut);font-size:20px;width:14px;text-align:center;line-height:1}
