:root {
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #1e1f22;
  --bg-card: #232428;
  --bg-card-hover: #2b2d31;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green-speaking: #23a55a;
  --green-glow: rgba(35, 165, 90, 0.6);
  --red-danger: #f23f43;
  --red-hover: #da373c;
  --yellow-warn: #f0b232;
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-header: #f2f3f5;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --font-discord: 'gg sans', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 24px;
  --transition: all 0.15s ease-in-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-discord);
}

body.discord-body {
  background-color: var(--bg-tertiary);
  color: var(--text-normal);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* Custom Discord Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #1a1b1e;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #111214;
}

/* ==================== LAYOUT CONTAINER ==================== */
.discord-app {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.discord-sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border-subtle);
  position: relative;
  z-index: 100;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-header);
}
.sidebar-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.server-badge {
  font-size: 18px;
}

.channels-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-category {
  padding: 8px 8px 4px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  margin-bottom: 2px;
}
.channel-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-normal);
}
.channel-item.active {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-header);
}
.channel-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.channel-icon {
  font-size: 16px;
  opacity: 0.8;
}
.channel-count {
  font-size: 11px;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
  color: var(--text-muted);
  font-weight: 700;
}

/* Sub-list of participants inside active voice channel */
.channel-users-sublist {
  padding-left: 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}
.sublist-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-normal);
}
.sublist-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.sublist-avatar.speaking {
  box-shadow: 0 0 0 2px var(--green-speaking);
}

/* ==================== USER DOCK (BOTTOM SIDEBAR) ==================== */
.user-dock {
  height: 56px;
  background-color: var(--bg-tertiary);
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.dock-left {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex: 1;
  min-width: 0;
  transition: var(--transition);
}
.dock-left:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
.dock-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.dock-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  background: var(--blurple);
}
.status-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--green-speaking);
  border: 2px solid var(--bg-tertiary);
}

.dock-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dock-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-header);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dock-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

.dock-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.dock-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: var(--transition);
}
.dock-btn:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-header);
}
.dock-btn.active-danger {
  color: var(--red-danger);
}

/* ==================== MAIN VOICE STAGE ==================== */
.discord-main {
  flex: 1;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Header */
.stage-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  background-color: var(--bg-primary);
  flex-shrink: 0;
  z-index: 50;
}
.stage-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-normal);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}
.stage-channel-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-header);
}
.stage-channel-icon {
  font-size: 18px;
  opacity: 0.8;
}

.stage-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rtc-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(35, 165, 90, 0.12);
  border: 1px solid rgba(35, 165, 90, 0.3);
  color: var(--green-speaking);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}
.rtc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--green-speaking);
  animation: rtcPulse 1.5s infinite alternate ease-in-out;
}
@keyframes rtcPulse {
  0% { transform: scale(0.85); opacity: 0.5; }
  100% { transform: scale(1.15); opacity: 1; }
}

.ping-indicator {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Mobile Background Keep-Alive Banner */
.bg-audio-banner {
  background: linear-gradient(90deg, #4752c4 0%, #5865f2 100%);
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  z-index: 40;
}
.bg-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-install-pwa {
  background: #fff;
  color: var(--blurple);
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-install-pwa:hover {
  background: #f2f3f5;
  transform: translateY(-1px);
}

/* ==================== VOICE TILES GRID ==================== */
.voice-stage-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1000px;
  max-height: 100%;
}

/* Single User Voice Card */
.voice-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.15s ease, transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid transparent;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.voice-card:hover {
  background-color: var(--bg-card-hover);
}

/* Speaking Emerald Ring Animation */
.voice-card.speaking {
  border-color: var(--green-speaking);
  box-shadow: 0 0 20px var(--green-glow);
  animation: cardSpeakingPulse 1s infinite alternate ease-in-out;
}
@keyframes cardSpeakingPulse {
  0% { box-shadow: 0 0 10px rgba(35, 165, 90, 0.4); }
  100% { box-shadow: 0 0 24px rgba(35, 165, 90, 0.85); }
}

.voice-avatar-wrap {
  position: relative;
  margin-bottom: 12px;
}
.voice-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 32px;
  color: #fff;
  transition: transform 0.15s ease;
}
.voice-card.speaking .voice-avatar {
  transform: scale(1.05);
}

.voice-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-header);
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 85%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-badge-row {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
}
.state-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.state-icon-badge.muted {
  color: var(--red-danger);
}
.state-icon-badge.deafened {
  color: var(--red-danger);
}

.voice-profile-tag {
  position: absolute;
  bottom: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Empty State / Standby */
.voice-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
  padding: 40px 20px;
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.empty-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-header);
}

/* ==================== FLOATING DISCORD CALL BAR ==================== */
.call-controls-bar {
  height: 68px;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 60;
}

.call-ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--bg-secondary);
  border: none;
  color: var(--text-header);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.call-ctrl-btn:hover {
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}
.call-ctrl-btn:active {
  transform: translateY(0);
}

/* Muted / Deafened States */
.call-ctrl-btn.active-muted,
.call-ctrl-btn.active-deafened {
  background-color: var(--red-danger) !important;
  color: #fff !important;
}

/* Noise Cancelling Badge Button */
.call-ctrl-btn.dsp-active {
  background-color: rgba(88, 101, 242, 0.25);
  color: #818cf8;
  border: 1px solid var(--blurple);
}

/* Disconnect Call Button */
.call-ctrl-btn.btn-disconnect {
  background-color: var(--red-danger);
  color: #fff;
}
.call-ctrl-btn.btn-disconnect:hover {
  background-color: var(--red-hover);
  box-shadow: 0 4px 14px rgba(242, 63, 67, 0.45);
}

/* Tooltip on Control Button */
.call-ctrl-btn[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 58px;
  background-color: #111214;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* ==================== MODALS ==================== */
.discord-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.discord-modal {
  width: 90%;
  max-width: 440px;
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}
.discord-modal-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
.discord-modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-header);
}
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.modal-close-btn:hover {
  color: var(--text-header);
}
.discord-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.discord-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.discord-input-group label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.discord-input-group input {
  background-color: var(--bg-tertiary);
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
}
.discord-input-group input:focus {
  border-color: var(--blurple);
}
.discord-modal-footer {
  padding: 14px 20px;
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn-discord-primary {
  background-color: var(--blurple);
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-discord-primary:hover {
  background-color: var(--blurple-hover);
}
.btn-discord-ghost {
  background: transparent;
  color: var(--text-normal);
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}
.btn-discord-ghost:hover {
  text-decoration: underline;
}

/* ==================== MOBILE RESPONSIVE (<= 768px) ==================== */
@media (max-width: 768px) {
  .discord-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.6);
  }
  .discord-sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .mobile-menu-btn {
    display: block;
  }
  .voice-stage-content {
    padding: 14px;
  }
  .voice-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
  .voice-card {
    height: 150px;
  }
  .voice-avatar {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
  .call-controls-bar {
    height: 62px;
    gap: 12px;
  }
  .call-ctrl-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
  .bg-audio-banner {
    font-size: 12px;
    padding: 6px 12px;
  }
}

/* Header PWA Install Button */
.btn-pwa-install-header {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #5865f2 0%, #4752c4 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(88, 101, 242, 0.35);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-pwa-install-header:hover {
  background: #4752c4;
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.55);
  transform: translateY(-1px);
}
.install-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #23a55a;
  box-shadow: 0 0 8px #23a55a;
  animation: pulseDot 1.4s infinite ease-in-out;
}
@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* PWA Install Modal */
.pwa-install-modal {
  max-width: 440px;
}
.pwa-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.pwa-pitch-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(88, 101, 242, 0.12);
  border: 1px solid rgba(88, 101, 242, 0.35);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}
.pwa-pitch-icon {
  font-size: 24px;
  line-height: 1;
}
.pwa-pitch-text strong {
  display: block;
  color: #fff;
  font-size: 14px;
  margin-bottom: 3px;
}
.pwa-pitch-text p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0;
}
.pwa-guide-box {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.pwa-os-tag {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
}
.pwa-os-tag.android {
  background: rgba(35, 165, 90, 0.2);
  color: #57f287;
}
.pwa-os-tag.ios {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.pwa-step-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-normal);
  font-size: 13px;
  line-height: 1.7;
}
.pwa-step-list strong {
  color: #fff;
}
.pwa-action-wrap {
  margin-top: 14px;
  text-align: center;
}
.btn-pwa-direct {
  width: 100%;
  padding: 11px;
  font-size: 14px;
}
