.call-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(ellipse at 40% 0%, rgba(88, 101, 242, 0.12), transparent 45%),
    linear-gradient(180deg, #0d1016 0%, #151a22 100%);
  display: flex;
  flex-direction: column;
}

.call-top {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.call-chat-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.call-stage {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(180px, 1fr);
  gap: 12px;
  padding: 8px 20px 110px;
  align-content: stretch;
  overflow: auto;
}
.call-stage:not(.solo) {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.call-stage.solo {
  grid-template-columns: 1fr;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.call-tile {
  position: relative;
  min-height: 200px;
  border-radius: 14px;
  background: linear-gradient(160deg, #1a1f2a, #12161e);
  border: 1px solid var(--border);
  overflow: hidden;
  display: grid;
  place-items: center;
}
.call-tile.speaking {
  border-color: rgba(62, 207, 142, 0.75);
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.45), 0 0 28px rgba(62, 207, 142, 0.12);
}
.call-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.call-tile .tile-avatar-wrap {
  display: grid;
  place-items: center;
  z-index: 1;
}
.call-tile .tile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 3px solid transparent;
  box-shadow: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.call-tile.tile-enter {
  animation: callTileEnter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.call-tile.tile-enter .tile-avatar-wrap {
  animation: callAvatarRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes callTileEnter {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes callAvatarRise {
  from { opacity: 0; transform: translateY(28px) scale(0.86); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.call-tile.speaking .tile-avatar {
  border-color: #3ecf8e;
  box-shadow:
    0 0 0 2px rgba(62, 207, 142, 0.85),
    0 0 18px 4px rgba(62, 207, 142, 0.55),
    0 0 36px 8px rgba(62, 207, 142, 0.28);
}
.call-tile .tile-name {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.55);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}
.call-tile .tile-net {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  backdrop-filter: blur(6px);
  pointer-events: none;
  user-select: none;
}
.call-tile .tile-net.q-good {
  color: #3ecf8e;
  border-color: rgba(62, 207, 142, 0.35);
  background: rgba(16, 40, 28, 0.75);
}
.call-tile .tile-net.q-fair {
  color: #f0c14a;
  border-color: rgba(240, 193, 74, 0.35);
  background: rgba(40, 34, 12, 0.75);
}
.call-tile .tile-net.q-poor {
  color: #ff9f43;
  border-color: rgba(255, 159, 67, 0.4);
  background: rgba(48, 28, 10, 0.78);
}
.call-tile .tile-net.q-bad {
  color: #ff6b7a;
  border-color: rgba(255, 107, 122, 0.45);
  background: rgba(48, 14, 18, 0.8);
}
.call-tile .tile-net.q-unknown {
  opacity: 0.65;
}
.call-tile.invite {
  background: linear-gradient(160deg, #1e1630, #12161e);
}
.invite-hint {
  color: var(--text-muted);
  margin: 8px 0 4px;
  font-size: 14px;
}
.call-tile .invite-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.call-tile .invite-illus {
  opacity: 0.9;
  color: var(--text-muted);
}

.call-controls {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(17, 19, 24, 0.94);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  padding: 10px 12px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.ctrl-group {
  display: flex;
  align-items: center;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
}
.ctrl-group .call-ctrl {
  border-radius: 0;
  background: transparent;
}
.call-ctrl-caret {
  width: 28px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
}
.call-ctrl-caret:hover { color: var(--text); background: var(--bg-hover); }

.call-ctrl {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-3);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.1s;
}
.call-ctrl:hover { background: var(--bg-hover); }
.call-ctrl:active { transform: scale(0.95); }
.call-ctrl.off {
  background: var(--danger-soft);
  color: var(--danger);
}
.call-ctrl.active-share {
  background: var(--accent-soft);
  color: var(--accent);
}
.call-ctrl.hangup {
  background: var(--danger);
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 14px;
}
.call-ctrl.hangup:hover { filter: brightness(1.08); }

.call-side-invite {
  position: absolute;
  left: 20px;
  bottom: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-3);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  z-index: 60;
}

.mic-device-menu {
  position: absolute;
  left: 50%;
  bottom: 96px;
  transform: translateX(-42%);
  width: min(280px, 90vw);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 70;
  max-height: 240px;
  overflow: auto;
}
.mic-device-menu .menu-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 6px 8px;
}
.mic-device-menu .menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-align: left;
  font-size: 13px;
}
.mic-device-menu .menu-item:hover,
.mic-device-menu .menu-item.active {
  background: var(--bg-hover);
}
.menu-empty {
  padding: 12px;
  color: var(--text-dim);
  font-size: 13px;
}

.screen-picker {
  position: absolute;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
}
.sp-panel {
  width: min(760px, 96vw);
  max-height: min(80vh, 640px);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.sp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.sp-head h3 {
  font-family: var(--font-display);
  font-size: 18px;
}
.sp-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px 0;
}
.sp-tab {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 600;
}
.sp-tab.active {
  background: var(--bg-active);
  color: var(--text);
}
.sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  overflow: auto;
}
.sp-card {
  background: var(--bg-2);
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s;
}
.sp-card:hover {
  border-color: var(--accent);
}
.sp-card img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  background: #000;
  display: block;
}
.sp-card span {
  display: block;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-foot {
  padding: 12px 16px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.sp-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  padding: 4px 16px 14px;
  border-top: 1px solid var(--border);
  align-items: end;
}
.sp-options-pad {
  padding-top: 16px;
  border-top: none;
}
.sp-opt {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.sp-opt select {
  appearance: none;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
}
.sp-opt.sp-check {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.sp-opt.sp-check input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.sp-opt.sp-check span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sp-opt.sp-check small {
  font-weight: 500;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.35;
}
.sp-panel-sm {
  width: min(420px, 96vw);
  max-height: none;
}

/* Compact call bar while browsing chat */
.call-dock {
  background: #1a1d24;
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.call-dock.speaking {
  box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.55);
}
.call-dock-media {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}
.call-dock-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  width: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--text);
}
.call-dock-info:hover {
  background: var(--bg-hover);
}
.call-dock-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #3ecf8e;
  font-size: 12px;
  font-weight: 700;
}
.call-dock-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.call-dock-count {
  font-size: 11px;
  color: var(--text-dim);
}
.call-dock-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.call-dock-actions .icon-btn {
  flex: 1;
  height: 32px;
  border-radius: 6px;
  background: var(--bg-3);
}
.call-dock-actions .icon-btn.off {
  background: var(--danger-soft);
  color: var(--danger);
}
.call-dock-actions .call-dock-hangup {
  background: var(--danger-soft);
  color: var(--danger);
}
.call-dock-actions .call-dock-hangup:hover {
  background: var(--danger);
  color: #fff;
}

.call-reacts {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-3);
  border-radius: 999px;
  padding: 4px;
}
.call-react {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.call-react:hover { background: var(--bg-hover); transform: scale(1.08); }
.react-burst {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translateX(-50%);
  font-size: 42px;
  z-index: 5;
  pointer-events: none;
  animation: react-pop 1.5s ease forwards;
}
@keyframes react-pop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1); }
}

.call-ctrl.ptt-live,
.icon-btn.ptt-live {
  background: rgba(62, 207, 142, 0.25) !important;
  color: #3ecf8e !important;
}

/* Floating PIP while chatting in a call */
.call-pip {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  width: 220px;
  background: rgba(17, 19, 24, 0.96);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  overflow: hidden;
  user-select: none;
}
.call-pip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  cursor: grab;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.call-pip-head:active { cursor: grabbing; }
.call-pip-head-actions { display: flex; gap: 4px; }
.call-pip-head-actions button {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-muted);
  display: grid;
  place-items: center;
}
.call-pip-head-actions button:hover { background: var(--bg-hover); color: var(--text); }
.call-pip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  justify-content: center;
}
.call-pip-tile {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
.call-pip-tile .pip-avatar,
.call-pip-tile .avatar {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50%;
  border: 2px solid transparent;
}
.call-pip-tile.speaking .avatar,
.call-pip-tile.speaking .pip-avatar {
  border-color: #3ecf8e;
  box-shadow: 0 0 12px rgba(62, 207, 142, 0.55);
}
.call-pip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--border);
}
.call-pip-actions .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-3);
}
.call-pip-actions .icon-btn.off {
  background: var(--danger-soft);
  color: var(--danger);
}
.call-pip-actions .call-react {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

/* DM ring (Discord-style incoming/outgoing) */
.dm-ring-embed {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #0b0b0b;
}
.dm-incoming-root {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: #0b0b0b;
}
.dm-ring-overlay {
  background: #0b0b0b;
}
.dm-ring-overlay.dm-ring-embedded {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.dm-ring-top {
  justify-content: center;
  color: var(--text-muted);
}
.dm-ring-stage {
  flex: 1;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 24px;
  padding-bottom: 100px;
}
.dm-ring-hero {
  position: relative;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
}
.dm-ring-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(35, 165, 89, 0.55);
  animation: dm-ring-pulse 2.2s ease-out infinite;
  pointer-events: none;
}
.dm-ring-pulse-2 {
  animation-delay: 0.75s;
}
.dm-ring-hero-out .dm-ring-pulse {
  border-color: rgba(88, 101, 242, 0.45);
  animation: dm-ring-pulse-out 2.4s ease-out infinite;
}
@keyframes dm-ring-pulse-out {
  0% { transform: scale(0.92); opacity: 0.45; }
  100% { transform: scale(1.4); opacity: 0; }
}
.dm-call-banner-outgoing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(88, 101, 242, 0.15);
  color: #a5b4fc;
  font-size: 13px;
  font-weight: 600;
}
@keyframes dm-ring-pulse {
  0% {
    transform: scale(0.92);
    opacity: 0.65;
  }
  70% {
    opacity: 0.15;
  }
  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}
.dm-ring-avatar-wrap {
  position: relative;
  z-index: 1;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
.dm-ring-avatar {
  width: 180px !important;
  height: 180px !important;
  border-radius: 50%;
  display: block;
}
.dm-ring-status {
  color: #b5bac1;
  font-size: 15px;
  font-weight: 500;
  margin: 0;
}
.dm-ring-controls {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
}
.dm-ring-btn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  transition: transform 0.12s, filter 0.12s;
}
.dm-ring-btn:active { transform: scale(0.94); }
.dm-ring-btn.cam {
  background: #1a2e24;
  color: #6ee7a8;
  opacity: 0.55;
  cursor: not-allowed;
}
.dm-ring-btn.accept {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: #23a559;
  color: #fff;
  box-shadow: 0 8px 28px rgba(35, 165, 89, 0.4);
}
.dm-ring-btn.accept:hover { filter: brightness(1.08); }
.dm-ring-btn.dm-ring-pulse-btn {
  animation: dm-ring-btn-glow 1.8s ease-in-out infinite;
}
@keyframes dm-ring-btn-glow {
  0%, 100% { box-shadow: 0 8px 28px rgba(35, 165, 89, 0.35); }
  50% { box-shadow: 0 8px 36px rgba(35, 165, 89, 0.65); }
}
.dm-ring-btn.decline {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: #da373c;
  color: #fff;
  box-shadow: 0 8px 24px rgba(218, 55, 60, 0.35);
}
.dm-ring-btn.decline:hover { filter: brightness(1.08); }
