/* Calls (calls.js): the voice channel's call view and a DM's call panel (one look, measured from the live client),
   the incoming call, and what calls add to the voice channel list and the Voice Connected panel. */

/* ---------- the call view: covers the chat column, black ---------- */
.chat { position: relative; }
.call-stage { position: absolute; inset: 0; z-index: 5; display: flex; background: #000; }
.call-stage[hidden] { display: none; }
.cs-root { position: relative; flex: 1; min-width: 0; overflow: hidden; background: #000; }

/* tiles: 16:9, 8px apart, centered (measured: two tiles 1080x608 at 8px from the sides, 8px kept free below) */
.cs-grid { position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px; padding: 0 8px 8px; overflow: auto; scrollbar-width: none; }
.cs-grid > .cs-tile { width: var(--tile-w, 320px); aspect-ratio: 16 / 9; }
.cs-tile { position: relative; flex: none; overflow: hidden; border-radius: 8px; background: #1e1f22; cursor: pointer; }
.cs-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.cs-bg.dark { background: #000; }
.cs-avatar { width: 80px; height: 80px; border-radius: 50%; }
.cs-vslot { position: absolute; inset: 0; }
.cs-video { display: block; width: 100%; height: 100%; object-fit: cover; background: #000; }
.cs-vslot.contain .cs-video { object-fit: contain; }
.cs-video.mirror { transform: scaleX(-1); }
.cs-overlay { position: absolute; inset: 12px; pointer-events: none; }
/* the name pill (measured: 32px, rgba(0,0,0,.56), 8px corners, 6px 8px, 16/20); a muted icon sits in it, white */
.cs-name { position: absolute; left: 0; bottom: 0; box-sizing: border-box; display: flex; align-items: center; gap: 4px; max-width: 100%; height: 32px; padding: 6px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.56); color: #fff; font-size: 16px; font-weight: 400; line-height: 20px; white-space: nowrap; overflow: hidden; transition: opacity 0.2s ease; }
.cs-nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cs-mic { flex: none; display: flex; color: #fff; }
/* the border: talking (the live view's 2px ring with a 1px dark edge inside, in the speaking green) */
.cs-border { position: absolute; inset: 0; border-radius: 8px; pointer-events: none; transition: box-shadow 50ms ease-out; }
.cs-tile.speaking .cs-border { box-shadow: inset 0 0 0 2px #3d9e60, inset 0 0 0 3px #000; }

/* a stream (measured): 8px from the top right, the grey quality badge joined to a red LIVE badge (16px, 6px sides,
   12/16 semibold caps); bottom right an Options button (32px, rgba(0,0,0,.56), 1px edge) while the mouse is on it */
.cs-indicators { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; pointer-events: none; }
.cs-badge { display: flex; align-items: center; box-sizing: border-box; height: 16px; padding: 0 6px; color: #fff; font-size: 12px; font-weight: 600; line-height: 16px; text-transform: uppercase; white-space: nowrap; }
.cs-badge.quality { border-radius: 16px 0 0 16px; background: #4f505a; }
.cs-res { margin-right: 4px; }
.cs-badge.live { border-radius: 0 16px 16px 0; background: #d22d39; }
.cs-badge.live.round { border-radius: 16px; }
.cs-options { position: absolute; right: 0; bottom: 0; display: grid; place-items: center; box-sizing: border-box; width: 32px; height: 32px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 8px; background: rgba(0, 0, 0, 0.56); color: #fff; opacity: 0; pointer-events: auto; transition: opacity 0.1s; }
.cs-tile:hover .cs-options, .cs-options:focus-visible { opacity: 1; }
.cs-strip .cs-indicators { top: 4px; right: 4px; }
.cs-strip .cs-options { display: none; }
/* someone's stream you aren't watching: Watch Stream */
.cs-stream-idle { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cs-watch { height: 40px; padding: 0 16px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 8px; background: rgba(151, 151, 159, 0.12); color: #dcdcdf; font-size: 16px; font-weight: 500; line-height: 20px; }
.cs-watch:hover { background: rgba(151, 151, 159, 0.2); color: #fff; }

/* alone in the channel (measured: a 16px-padded tile, art then two 40px secondary buttons 8px apart) */
.cs-tile.alone { cursor: default; background: rgba(0, 0, 0, 0.2); }
.cs-alone { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 16px; border-radius: 8px;
  background: radial-gradient(110.79% 100% at 50% 100%, #000 60%, rgba(0, 0, 0, 0) 100%), linear-gradient(270deg, #3a1340, #24123f); }
.cs-alone-art { width: min(400px, 60%); height: auto; margin-bottom: 8px; }
.cs-alone-btns { display: flex; gap: 8px; }
.cs-sbtn { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 15px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 8px; background: rgba(151, 151, 159, 0.12); color: #dcdcdf; font-size: 16px; font-weight: 500; line-height: 20px; white-space: nowrap; }
.cs-sbtn:hover { background: rgba(151, 151, 159, 0.2); color: #fff; }

/* focus (measured): the tile large between 80px above and below, the others in a strip of 195x112 tiles under it,
   and a participants pill over the strip */
.cs-grid.focus { flex-direction: column; flex-wrap: nowrap; align-content: stretch; justify-content: flex-start; padding: 80px 8px; }
.cs-focus-main { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.cs-focus-main > .cs-tile { width: var(--tile-w, 640px); aspect-ratio: 16 / 9; }
.cs-strip { position: relative; flex: none; display: flex; justify-content: center; gap: 8px; height: 112px; }
.cs-strip > .cs-tile { width: 195px; height: 112px; }
.cs-grid.focus.strip-hidden .cs-strip > .cs-tile { visibility: hidden; }
.cs-strip .cs-avatar { width: 40px; height: 40px; }
.cs-strip .cs-overlay { inset: 4px; }
.cs-strip .cs-name { height: 24px; padding: 2px 6px; border-radius: 6px; font-size: 12px; line-height: 20px; }
.cs-strip .cs-stream-idle .cs-watch { height: 28px; padding: 0 8px; font-size: 12px; }
.cs-participants { position: absolute; top: 8px; left: 50%; z-index: 1; transform: translateX(-50%); display: flex; align-items: center; justify-content: center; gap: 2px; box-sizing: border-box; width: 60px; height: 32px; padding: 4px; border-radius: 48px; background: #2c2d32; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 12px 24px rgba(0, 0, 0, 0.24); color: #fff; }

/* controls over the tiles (measured: 16px in from the sides and bottom, 160px gradients); they fade when idle */
.cs-controls { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 0 16px 16px; pointer-events: none; transition: opacity 0.2s ease; }
.cs-gradient { position: absolute; left: 0; right: 0; height: 160px; pointer-events: none; }
.cs-gradient.top { top: 0; background: linear-gradient(#000, rgba(0, 0, 0, 0.737) 19%, rgba(0, 0, 0, 0.54) 34%, rgba(0, 0, 0, 0.38) 47%, rgba(0, 0, 0, 0.26) 58%, rgba(0, 0, 0, 0.16) 69%, rgba(0, 0, 0, 0.08) 80%, rgba(0, 0, 0, 0.02) 91%, rgba(0, 0, 0, 0)); }
.cs-gradient.bottom { bottom: 0; background: linear-gradient(to top, #000, rgba(0, 0, 0, 0.737) 19%, rgba(0, 0, 0, 0.54) 34%, rgba(0, 0, 0, 0.38) 47%, rgba(0, 0, 0, 0.26) 58%, rgba(0, 0, 0, 0.16) 69%, rgba(0, 0, 0, 0.08) 80%, rgba(0, 0, 0, 0.02) 91%, rgba(0, 0, 0, 0)); }
.cs-top, .cs-bottom { position: relative; pointer-events: auto; transition: transform 0.2s ease; }
.cs-top { display: flex; align-items: center; height: 49px; margin: 0 -16px; padding: 8px 16px; box-sizing: border-box; }
.cs-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.cs-ch-icon { flex: none; display: flex; margin: 0 1px 0 -1px; color: #7a7b83; }
.cs-title h1 { margin: 0; color: #dcdcdf; font-size: 16px; font-weight: 500; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-tools { display: flex; gap: 16px; }
.cs-tray { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px; color: #96979e; }
.cs-tray:hover { color: #dcdcdf; }
.cs-bottom { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 24px; height: 50px; }
.cs-edge { display: flex; gap: 20px; }
.cs-edge.end { justify-content: flex-end; }
.call-stage.idle .cs-controls { opacity: 0; }
.call-stage.idle .cs-top { transform: translateY(-8px); }
.call-stage.idle .cs-bottom { transform: translateY(8px); }
.call-stage.idle .cs-name:not(.has-icon) { opacity: 0; }
.call-stage.idle .cs-name .cs-nm { display: none; }

/* the call bar (measured: two dark 50px groups, 40px buttons with 20px carets, a 66x50 red Disconnect; button looks
   from the live client's states: hover a 10% white, muted a faint red with a red icon, active white) */
.cs-center { display: flex; align-items: center; gap: 12px; }
.cs-section { display: flex; align-items: center; gap: 8px; box-sizing: border-box; height: 50px; padding: 4px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 12px; background: #0a0a0c; }
.cs-attached { display: flex; align-items: center; }
.cs-btn { display: grid; place-items: center; width: 40px; height: 40px; padding: 10px; border-radius: 8px; background: transparent; color: #fff; transition: background 0.15s ease-in-out, color 0.15s ease-in-out; }
.cs-btn.attached { border-radius: 8px 0 0 8px; }
.cs-nub { display: grid; place-items: center; width: 20px; height: 40px; margin-left: 1px; border-radius: 0 8px 8px 0; color: #fff; cursor: pointer; transition: background 0.15s ease-in-out, color 0.15s ease-in-out; }
.cs-attached:hover .cs-btn, .cs-attached:hover .cs-nub { background: var(--bg-mod-normal); }
.cs-btn:hover, .cs-nub:hover, .cs-attached:hover .cs-btn:hover, .cs-attached:hover .cs-nub:hover { background: rgba(255, 255, 255, 0.1); }
.cs-btn.danger, .cs-nub.danger, .cs-attached:hover .cs-btn.danger, .cs-attached:hover .cs-nub.danger { background: rgba(210, 45, 57, 0.12); color: #da3e44; }
.cs-btn.danger:hover, .cs-nub.danger:hover { background: rgba(210, 45, 57, 0.16); }
.cs-btn.danger:active, .cs-nub.danger:active { background: rgba(210, 45, 57, 0.24); }
.cs-btn.on, .cs-nub.on, .cs-attached:hover .cs-btn.on, .cs-attached:hover .cs-nub.on { background: #fff; color: #1e1f22; }
.cs-btn.on:hover, .cs-nub.on:hover { background: #dfe0e4; }
/* streaming (measured): the screen button and its caret glow green */
.cs-btn.green, .cs-nub.green, .cs-attached:hover .cs-btn.green, .cs-attached:hover .cs-nub.green { background: rgba(0, 133, 69, 0.12); color: #73c48b; }
.cs-btn.green:hover, .cs-nub.green:hover { background: rgba(0, 133, 69, 0.16); }
.cs-btn.green:active, .cs-nub.green:active { background: rgba(0, 133, 69, 0.24); }
.cs-disconnect { display: grid; place-items: center; box-sizing: border-box; width: 66px; height: 50px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 12px; background: #d22d39; color: #fff; transition: background 0.15s ease-in-out; }
.cs-disconnect:hover { background: #a9232e; }
.cs-disconnect:active { background: #8f1d27; }

/* ---------- a DM's call (measured): a black 240px panel at the top of the chat, the DM's header on top of it ---------- */
.dm-call { position: relative; flex: none; height: 240px; background: #000; }
.dm-call[hidden] { display: none; }
.dm-call.visual { height: clamp(360px, 55vh, 720px); }
.dm-call .cs-root { position: absolute; inset: 0; }
.dm-call .cs-controls { justify-content: flex-end; }
.dm-call .cs-grid { padding: 57px 8px 82px; }
.chat.dm-call-open #chat-header { position: absolute; top: 0; left: 0; right: 0; z-index: 6; border-bottom-color: transparent; background: transparent; box-shadow: none; }
.chat.dm-call-open #chat-header [data-action="call-voice"], .chat.dm-call-open #chat-header [data-action="call-video"] { display: none; }
.chat.dm-call-open #chat-header [data-action="toggle-profile"] { opacity: 0.6; pointer-events: none; }
.chat.dm-call-open #chat-header .search input { border: 1px solid rgba(151, 151, 159, 0.24); background: rgba(0, 0, 0, 0.12); }
.chat.dm-call-open .profile { display: none; }
/* everyone as an 80px circle, 16px apart, the others first and you last */
.dmc-list { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.dmc-p { position: relative; flex: none; width: 80px; height: 80px; margin: 0 8px; }
.dmc-av { position: relative; width: 80px; height: 80px; border-radius: 50%; }
.dmc-av img { display: block; width: 80px; height: 80px; border-radius: 50%; }
.dmc-border { position: absolute; inset: 0; border-radius: 50%; transition: box-shadow 50ms ease-out; }
.dmc-p.speaking .dmc-border { box-shadow: inset 0 0 0 2px #3d9e60, inset 0 0 0 3px #000; }
/* being rung (measured): the avatar dimmed and brightening twice every 2.5s with a 3px ring growing out of it each
   time; hovering offers an X */
.dmc-p.ringing .dmc-av img { opacity: 0.3; animation: outgoing-call-avatar 2.5s ease-out infinite; }
.dmc-p.ringing .dmc-av::after, .ci-avatar::after { content: ''; position: absolute; top: -3px; left: -3px; box-sizing: content-box; width: 100%; height: 100%; border: 3px solid #fbfbfb; border-radius: 100%; pointer-events: none; transform-origin: center center; animation: outgoing-call-pulse 2.5s ease-out infinite; }
.dmc-cross { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 50%; color: #fff; opacity: 0; transition: opacity 0.1s; }
.dmc-p.ringing:hover .dmc-cross { opacity: 1; }
@keyframes outgoing-call-avatar { 0% { opacity: 0.3; } 11.56% { opacity: 0.9; } 39.02% { opacity: 0.3; } 39.04% { opacity: 0.9; } 66.48%, 100% { opacity: 0.3; } }
@keyframes outgoing-call-pulse {
  0% { opacity: 0; transform: scale(1); } 11.56% { opacity: 1; } 39.02% { opacity: 0; transform: scale(1.1); } 39.03% { transform: scale(1); }
  39.04% { opacity: 1; } 66.48% { opacity: 0; transform: scale(1.1); } 100% { opacity: 0; transform: scale(1); }
}
@keyframes incoming-call-pulse {
  0% { opacity: 0; transform: scale(1); } 0.7% { opacity: 1; } 25.54% { opacity: 0; transform: scale(1.1); } 25.55% { transform: scale(1); }
  25.56% { opacity: 1; } 49.98% { opacity: 0; transform: scale(1.1); } 49.99% { transform: scale(1); } 50% { opacity: 1; }
  74.69% { opacity: 0; transform: scale(1.1); } 74.7% { transform: scale(1); } 74.71% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1); }
}
/* muted / deafened (from the live client): a 24px red circle with a white icon in the avatar's bottom-right corner,
   cut 4px clear of the avatar */
.dmc-badge { position: absolute; right: 0; bottom: 0; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #da3e44; color: #fff; pointer-events: none; }
.dmc-p.has-badge .dmc-av { -webkit-mask: radial-gradient(circle at 68px 68px, transparent 15.5px, #000 16.5px); mask: radial-gradient(circle at 68px 68px, transparent 15.5px, #000 16.5px); }
.dmc-join { display: inline-flex; align-items: center; gap: 8px; box-sizing: border-box; height: 50px; padding: 0 16px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 12px; background: #3d9e60; color: #fff; font-size: 14px; font-weight: 500; }
.dmc-join:hover { background: #35894f; }
.dmc-join.video { justify-content: center; width: 50px; padding: 0; }

/* ---------- someone's ringing you ---------- */
.call-incoming-layer { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; pointer-events: none; }
.call-incoming-layer[hidden] { display: none; }
.call-incoming { display: flex; flex-direction: column; align-items: center; width: 248px; padding: 24px 16px 20px; border: 1px solid rgba(151, 151, 159, 0.16); border-radius: 12px; background: #111214; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); text-align: center; pointer-events: auto; }
.ci-avatar { position: relative; width: 80px; height: 80px; margin-bottom: 12px; }
.ci-avatar img { display: block; width: 80px; height: 80px; border-radius: 50%; }
.ci-avatar::after { animation-name: incoming-call-pulse; animation-duration: 5.407s; }
.ci-name { max-width: 100%; color: #fff; font-size: 20px; font-weight: 600; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-sub { margin-top: 4px; color: #b5bac1; font-size: 14px; line-height: 18px; }
.ci-btns { display: flex; gap: 16px; margin-top: 20px; }
.ci-btn { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: #fff; }
.ci-btn.decline { background: #d22d39; }
.ci-btn.decline:hover { background: #a9232e; }
.ci-btn.accept { background: #3d9e60; }
.ci-btn.accept:hover { background: #35894f; }

/* ---------- what calls add elsewhere ---------- */
/* talking (measured): a 2px green ring inside the avatar with a 1px edge in the chat colour, and the name goes white */
.sv-voice-user .vav { transition: box-shadow 50ms ease-out; }
.sv-voice-user.speaking .vav { box-shadow: inset 0 0 0 2px #3d9e60, inset 0 0 0 3px var(--bg-base-lower); }
.sv-voice-user.speaking .nm { color: var(--text-strong); }
.sv-voice-user .vi.cam { color: inherit; }
/* LIVE (measured): a 16px red pill, 6px sides, 12/16 semibold caps */
.sv-live { display: inline-flex; align-items: center; box-sizing: border-box; height: 16px; padding: 0 6px; border-radius: 16px; background: #d22d39; color: #fff; font-size: 12px; font-weight: 600; line-height: 16px; text-transform: uppercase; }
.sv-rtc-status.connecting .sv-rtc-title, .sv-rtc-status.connecting .sv-ping { color: #f0b232; }
/* camera on / streaming (measured): the button glows green */
.sv-rtc-actions button.on { border-color: rgba(0, 133, 69, 0.12); background: rgba(0, 133, 69, 0.12); color: #62b77c; }
.sv-rtc-actions button.on:hover { background: rgba(0, 133, 69, 0.16); }
/* streaming (measured): the panel grows 57px for a row above the rest, a line under it across the panel */
.sv-rtc.rtc-streaming { height: 158px; }
.user-panel.rtc-open.rtc-streaming { height: 216px; padding-top: 158px; }
.main.rtc-open.rtc-streaming .rail, .main.rtc-open.rtc-streaming .sidebar-scroll, .main.rtc-open.rtc-streaming .sv-scroll { padding-bottom: calc(216px + 24px); }
.sv-rtc-stream { flex: none; display: flex; align-items: center; gap: 8px; height: 45px; margin: 0 -12px; padding: 0 12px 12px; border-bottom: 1px solid var(--border-muted); }
.sv-rtc-thumb { position: relative; flex: none; width: 32px; height: 32px; }
.sv-rtc-shot { position: absolute; inset: 0; overflow: hidden; border-radius: 8px; background: #000; }
.sv-rtc-shot .cs-video { object-fit: cover; }
.sv-rtc-badge { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; background: var(--bg-base-low); color: #62b77c; }
.sv-rtc-stream .sv-rtc-label { flex: 1; }
.sv-rtc-what { color: var(--text-strong); font-size: 14px; font-weight: 500; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sv-rtc-where { color: var(--text-subtle); font-size: 12px; font-weight: 500; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-meter { height: 8px; margin: 2px 0 10px; border-radius: 4px; background: var(--bg-mod-strong); overflow: hidden; }
.ctx-meter-fill { width: 0; height: 100%; border-radius: 4px; background: #3d9e60; transition: width 0.05s linear; }
.msg.system.call .sys-icon { color: #3d9e60; }
.msg.system.call.missed .sys-icon { color: #da3e44; }
/* Camera Preview (measured): the picture 430x242 on a faint grey with 4px corners, 20px above the camera select
   (40px, a dark fill, 1px edge, 8px corners); the footer has Always preview video on the left, Turn On Camera right */
.cp-body { display: flex; flex-direction: column; gap: 20px; padding: 16px 24px 8px; }
.cp-camera { position: relative; height: 242px; overflow: hidden; border-radius: 4px; background: rgba(151, 151, 159, 0.16); }
.call-preview-video { display: block; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cp-select { display: flex; align-items: center; gap: 8px; box-sizing: border-box; height: 40px; padding: 8px 8px 8px 12px; border: 1px solid rgba(151, 151, 159, 0.2); border-radius: 8px; background: rgba(0, 0, 0, 0.12); color: #f2f2f3; cursor: pointer; }
.cp-select:hover { border-color: rgba(151, 151, 159, 0.32); }
.cp-device { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 500; line-height: 20px; }
.cp-label { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 24px 8px; }
.cp-check { position: relative; display: flex; align-items: center; gap: 12px; color: var(--text-subtle); font-size: 16px; line-height: 20px; cursor: pointer; }
.cp-check input { position: absolute; opacity: 0; pointer-events: none; }
.cp-box { flex: none; display: grid; place-items: center; box-sizing: border-box; width: 20px; height: 20px; border: 1px solid rgba(151, 151, 159, 0.64); border-radius: 4px; background: rgba(0, 0, 0, 0.08); color: transparent; }
.cp-check input:checked + .cp-box { border-color: rgba(151, 151, 159, 0.12); background: #5865f2; color: #fff; }
.cp-check input:focus-visible + .cp-box { outline: 2px solid var(--focus, #00b0f4); outline-offset: 2px; }
.st-ptt { display: flex; align-items: center; gap: 12px; }
