:root {
  --bg-0: #050505;
  --bg-1: #0a0a0a;
  --bg-2: #141414;
  --surface: rgba(20, 20, 20, 0.6);
  --surface-hover: rgba(40, 40, 40, 0.8);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-light: rgba(255, 255, 255, 0.15);
  --text: #ffffff;
  --muted: #888888;
  --accent: #4f46e5;
  --accent-hover: #6366f1;
  --accent-glow: rgba(79, 70, 229, 0.4);
  --danger: #e11d48;
  --danger-hover: #f43f5e;
  --success: #10b981;
  --warning: #f59e0b;
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font: 'Outfit', 'Inter', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

::selection {
  background: var(--accent-glow);
  color: white;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background: var(--bg-0);
  overflow: hidden;
}

/* Typography */
h1,
h2,
h3 {
  letter-spacing: -0.02em;
  font-weight: 700;
}

#roomView {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(-45deg, #050505, #080812, #050b09, #0c0512);
  background-size: 400% 400%;
  animation: aurora 25s ease infinite;
  position: relative;
}

@keyframes aurora {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.join-card {
  width: min(440px, 90%);
  padding: 48px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(24px);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 24px;
  text-align: center;
  z-index: 10;
}

.join-card h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.join-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

input,
select {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

input::placeholder {
  color: #555;
}

input:disabled,
#chatInput:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(0, 0, 0, 0.1);
}

input:focus,
select:focus {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--accent-hover);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--stroke);
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--stroke-light);
}

.btn-secondary:active {
  transform: scale(0.98);
}

/* Footer */
.app-footer {
  position: absolute;
  bottom: 24px;
  text-align: center;
  color: #555;
  font-size: 0.85rem;
  width: 100%;
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.app-footer a:hover {
  color: var(--text);
}

/* Telemetry Diagnostics Badge */
.stats-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  right: auto;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid #00f0ff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: #c9d1d9;
  font-family: 'Fira Code', monospace;
  pointer-events: none;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  display: none;
  transition: all 0.2s ease;
}

.stats-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 10px;
  align-items: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 500;
}

.stat-item i {
  font-size: 0.65rem;
  width: 10px;
  text-align: center;
  color: var(--muted);
}

.stat-latency-green { color: #10b981 !important; }
.stat-latency-green i { color: #10b981 !important; }

.stat-latency-warn { color: #fbbf24 !important; }
.stat-latency-warn i { color: #fbbf24 !important; }

.stat-latency-danger { color: #f43f5e !important; }
.stat-latency-danger i { color: #f43f5e !important; }

.stat-loss-bad { color: #f43f5e !important; font-weight: 700 !important; }
.stat-loss-bad i { color: #f43f5e !important; }

/* Collaborative Workspace Overlay (Whiteboard & Notepad) */
#whiteboardContainer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-0);
  border: none;
  border-radius: 0;
  box-shadow: none;
  z-index: 80;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#whiteboardContainer .tab-btn {
  padding: 8px 18px;
  font-size: 0.85rem;
  border: none;
  flex: none;
  border-radius: 99px;
  color: var(--muted);
  background: transparent;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#whiteboardContainer .tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

#whiteboardContainer .tab-btn.active {
  color: white;
  background: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.wb-color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.wb-color-btn:hover {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.6);
}

.wb-color-btn.active {
  transform: scale(1.25);
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wb-color-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}

.wb-color-btn:hover {
  transform: scale(1.2);
}

.wb-color-btn.active {
  border-color: white !important;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* Closed Captions Overlay */
#ccOverlay {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  background: rgba(10, 10, 10, 0.8);
  backdrop-filter: blur(12px);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  color: white;
  text-align: center;
  font-size: 1.05rem;
  pointer-events: none;
  z-index: 70;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: none;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-1);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  width: min(500px, 90%);
  max-height: 85vh;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.modal-overlay.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 4px;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 24px;
  padding-right: 12px;
  overflow-y: auto;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-body h3 {
  color: var(--text);
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 24px;
}

.modal-body li {
  margin-bottom: 8px;
}

.modal-body p {
  margin-bottom: 16px;
}

/* Call View overrides */
#callView {
  display: none;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  flex-direction: row;
  background: linear-gradient(-45deg, #050505, #070710, #050807, #090510);
  background-size: 400% 400%;
  animation: aurora 25s ease infinite;
  position: relative;
  overflow: hidden;
}

.main-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 16px;
  gap: 16px;
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(20, 20, 20, 0.4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0px rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0px rgba(245, 158, 11, 0); }
}

#video-grid {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 80px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#video-grid::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#video-grid::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-sm);
}

#video-grid::-webkit-scrollbar-thumb {
  background: var(--stroke);
  border-radius: var(--radius-sm);
  transition: background-color 0.2s ease;
}

#video-grid::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.video-wrapper {
  position: absolute;
  margin: 0;
  background: var(--bg-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  will-change: left, top, width, height;
  contain: layout style paint;
  backface-visibility: hidden;
  transition: left 0.35s cubic-bezier(0.25, 1, 0.5, 1),
              top 0.35s cubic-bezier(0.25, 1, 0.5, 1),
              width 0.35s cubic-bezier(0.25, 1, 0.5, 1),
              height 0.35s cubic-bezier(0.25, 1, 0.5, 1),
              outline 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-wrapper.active-speaker {
  outline: 2px solid #00f0ff;
  outline-offset: -1px;
  border-color: #00f0ff !important;
  animation: cyberSpeakerGlow 1.8s infinite alternate cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes cyberSpeakerGlow {
  0% {
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.6), 0 0 30px rgba(79, 70, 229, 0.4), inset 0 0 15px rgba(0, 240, 255, 0.3);
  }
  100% {
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.9), 0 0 50px rgba(244, 63, 94, 0.6), inset 0 0 25px rgba(0, 240, 255, 0.5);
  }
}

/* =========================================
   MODE 2: FOCUS MODE (Algorithmic 60/40 Split) 
   ========================================= */
.video-wrapper.focused {
  z-index: 50 !important;
  border-color: var(--accent);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--accent-glow);
}

.video-wrapper.focused video {
  object-fit: contain;
  background: var(--bg-1);
  border-radius: var(--radius-lg);
}

/* =========================================
   MODE 3: FULLSCREEN (OS-Level native) 
   ========================================= */
.fullscreen-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--stroke-light);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 60;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.fullscreen-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.05);
}

.fullscreen-btn .fs-compress,
.fullscreen-btn.is-fullscreen .fs-expand {
  display: none;
}

.fullscreen-btn.is-fullscreen .fs-compress {
  display: block;
}

/* Show the button only when hovering over the card */
.video-wrapper:hover .fullscreen-btn {
  display: flex;
}

/* Natively strip borders when full-screen is active */
.video-wrapper:fullscreen {
  max-width: none !important;
  border-radius: 0 !important;
  border: none !important;
  aspect-ratio: auto !important;
  background: #000 !important;
}

.video-wrapper:fullscreen video {
  object-fit: contain !important;
}

.unpin-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--stroke-light);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 60;
  transition: all 0.2s;
}

.unpin-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  transform: scale(1.05);
}

.video-wrapper.focused .unpin-btn {
  display: flex;
}

.floating-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(15, 15, 15, 0.75);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  z-index: 99999;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: all 0.3s ease;
}

.floating-controls:hover {
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(79, 70, 229, 0.15), inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.control-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.control-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.control-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.92);
}

.control-btn.active {
  background: white;
  color: black;
}

.control-btn.danger {
  background: var(--danger);
}

.control-btn.danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.sidebar {
  width: clamp(300px, 28vw, 380px);
  background: rgba(15, 15, 15, 0.8);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
  transition: width 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed {
  width: 0;
  border: none;
}

.sidebar-tabs,
.sidebar-content {
  width: clamp(300px, 28vw, 380px);
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-tabs,
.sidebar.collapsed .sidebar-content {
  opacity: 0;
  pointer-events: none;
}

.sidebar-tabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.2);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s;
}

.tab-btn.active {
  color: var(--text);
  border-bottom: 2px solid var(--accent);
}

.close-sidebar-btn {
  display: none;
  flex: 0 0 60px;
  color: var(--muted);
  background: transparent;
  border-left: 1px solid var(--stroke);
  font-size: 1.25rem;
  cursor: pointer;
}

.close-sidebar-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-content {
  flex: 1;
  min-height: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#participantList {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--stroke);
  transition: all 0.2s;
}

.participant-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.participant-item.active-speaker {
  border-color: var(--accent);
  background: rgba(79, 70, 229, 0.1);
}

.participant-meta {
  display: flex;
  flex-direction: column;
}

.participant-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.participant-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.mic-icon {
  color: var(--muted);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.mic-icon .mic-on,
.mic-icon .mic-off {
  display: none;
}

.mic-icon:not(.muted) {
  color: var(--success);
}

.mic-icon:not(.muted) .mic-on {
  display: block;
}

.mic-icon.muted {
  color: var(--danger);
}

.mic-icon.muted .mic-off {
  display: block;
}

#chatBox {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 10px;
}

.chat-msg {
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  max-width: 90%;
  word-wrap: break-word;
  font-size: 0.95rem;
  border: 1px solid var(--stroke);
  animation: fadeIn 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.chat-msg.self {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-empty {
  text-align: center;
  color: #555;
  font-size: 0.95rem;
  margin: auto;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--stroke);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s;
}

.btn-icon:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-icon:disabled {
  opacity: 0.5;
}

#chatInput {
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

#toastContainer {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 150;
  display: grid;
  gap: 12px;
  width: min(380px, calc(100vw - 48px));
  pointer-events: none;
  transition: top 0.4s, bottom 0.4s;
}

.toast {
  pointer-events: auto;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--stroke);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
  animation: popIn 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.warning,
.toast.info {
  border-left: 4px solid var(--accent);
}

@keyframes popIn {
  from {
    transform: translateX(-20px) scale(0.95);
    opacity: 0;
  }

  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.video-mute-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  left: auto;
  background: rgba(225, 29, 72, 0.9);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.video-nametag {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 10;
  pointer-events: none;
  border: 1px solid var(--stroke);
}

.typing-indicator {
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: -4px;
  margin-bottom: 8px;
  display: none;
}

.unread-badge {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--danger);
  border-radius: 50%;
  margin-left: 6px;
  box-shadow: 0 0 6px var(--danger);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background-color: var(--accent);
  transition: width 0.1s linear;
}

@media (max-width: 992px) {
  #toastContainer {
    bottom: 90px; /* Clear mobile controls */
  }
  .join-card {
    padding: 32px 24px;
    width: 100%;
    border-radius: 0;
    border: none;
    flex: 1;
    justify-content: center;
    background: var(--bg-0);
  }

  .app-footer {
    position: relative;
    margin-top: auto;
    padding-bottom: 24px;
  }

  .header-bar {
    flex-wrap: wrap;
    padding: 12px;
    gap: 10px;
    margin: 8px;
    border-radius: var(--radius-md);
  }

  #copyLinkBtn {
    padding: 8px 12px;
    font-size: 0.85rem;
  }

  .sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 100%;
    z-index: 200;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(24px);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.8);
    border-left: 1px solid var(--stroke);
  }

  .sidebar-tabs,
  .sidebar-content {
    width: 360px;
    max-width: 100%;
  }

  .close-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-stage {
    padding: 0;
    gap: 0;
  }

  .floating-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    padding: 16px;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--stroke);
    background: rgba(10, 10, 10, 0.9);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
    z-index: 90;
  }

  .control-btn {
    width: 38px;
    height: 38px;
  }
  .control-btn svg {
    width: 16px;
    height: 16px;
  }

  #video-grid {
    padding: 12px;
    padding-bottom: 100px;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  /* Aspect Ratio Adaptability at Runtime based on viewport orientation */
  @media (orientation: portrait) {
    .video-wrapper {
      width: 100%;
      max-width: max(240px, calc((100vh - 160px) * 3 / 4));
      margin: 0 auto;
      aspect-ratio: 3 / 4;
    }
  }

  @media (orientation: landscape) {
    .video-wrapper {
      width: 100%;
      max-width: max(240px, calc((100vh - 140px) * 16 / 9));
      margin: 0 auto;
      aspect-ratio: 16 / 9;
    }
  }

  .video-wrapper video {
    object-fit: contain;
    background: var(--bg-1);
  }
}

@media (max-width: 600px) {
  #video-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

/* Split Pane Coding Layout styling overrides */
#wbSplitWorkspaceContainer {
  display: flex;
  width: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
}

#wbTerminalContainer {
  display: none;
  flex: 1;
  flex-direction: column;
  background: #080808;
  border-left: 1px solid var(--stroke);
  min-height: 0;
  box-shadow: inset 10px 0 30px rgba(0,0,0,0.5);
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #0c0c0c;
  border-bottom: 1px solid var(--stroke);
  flex-shrink: 0;
}

#wbTerminal {
  flex: 1;
  margin: 0;
  padding: 16px;
  overflow-y: auto;
  font-family: 'Fira Code', Consolas, Monaco, monospace;
  font-size: 0.85rem;
  color: #39ff14;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  outline: none;
}

/* Tablet / Mobile stacked layout rules */
@media (max-width: 992px) {
  #wbSplitWorkspaceContainer {
    flex-direction: column !important;
  }
  
  #wbTerminalContainer {
    border-left: none !important;
    border-top: 1px solid var(--stroke);
    flex: 1 !important;
  }
  
  #wbTextarea {
    flex: 1 !important;
    height: 50% !important;
  }
}

/* VS Code Dark Modern Theme Style Overrides for CodeMirror */
#wbCodeEditorWrapper {
  flex: 2;
  min-height: 0;
  display: none;
  flex-direction: column;
}

.CodeMirror {
  flex: 1;
  height: 100% !important;
  width: 100% !important;
  background: #0a0a0a !important;
  font-family: 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 1.05rem !important;
  line-height: 1.6;
  color: #d4d4d4 !important;
  border: none !important;
  outline: none !important;
  border-radius: 8px;
  padding-top: 8px;
}

.CodeMirror-scroll {
  height: 100% !important;
  min-height: 100% !important;
}

.CodeMirror-gutters {
  background: #050505 !important;
  border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
  width: 48px;
}

.CodeMirror-linenumber {
  color: #666 !important;
  padding-right: 8px;
}

.CodeMirror-activeline-background {
  background: rgba(255, 255, 255, 0.03) !important;
}

.CodeMirror-selected {
  background: rgba(38, 79, 120, 0.4) !important;
}
.CodeMirror-focused .CodeMirror-selected {
  background: rgba(38, 79, 120, 0.55) !important;
}

.CodeMirror-cursor {
  border-left: 2px solid #569cd6 !important;
}

.cm-s-monokai span.cm-keyword,
.CodeMirror span.cm-keyword {
  color: #569cd6 !important;
}

.cm-s-monokai span.cm-def,
.CodeMirror span.cm-def {
  color: #9cdcfe !important;
}

.cm-s-monokai span.cm-variable,
.CodeMirror span.cm-variable,
.cm-s-monokai span.cm-variable-2,
.CodeMirror span.cm-variable-2 {
  color: #9cdcfe !important;
}

.cm-s-monokai span.cm-property,
.CodeMirror span.cm-property {
  color: #9cdcfe !important;
}

.cm-s-monokai span.cm-string,
.CodeMirror span.cm-string {
  color: #ce9178 !important;
}

.cm-s-monokai span.cm-number,
.CodeMirror span.cm-number {
  color: #b5cea8 !important;
}

.cm-s-monokai span.cm-comment,
.CodeMirror span.cm-comment {
  color: #6a9955 !important;
  font-style: italic;
}

.cm-s-monokai span.cm-type,
.CodeMirror span.cm-type,
.cm-s-monokai span.cm-builtin,
.CodeMirror span.cm-builtin {
  color: #4ec9b0 !important;
}

.cm-s-monokai span.cm-atom,
.CodeMirror span.cm-atom {
  color: #569cd6 !important;
}

.cm-s-monokai span.cm-operator,
.CodeMirror span.cm-operator {
  color: #d4d4d4 !important;
}

.cm-s-monokai span.cm-meta,
.CodeMirror span.cm-meta {
  color: #c586c0 !important;
}

.cm-s-monokai span.cm-qualifier,
.CodeMirror span.cm-qualifier {
  color: #dcdcaa !important;
}

.cm-s-monokai span.cm-tag,
.CodeMirror span.cm-tag {
  color: #569cd6 !important;
}

.cm-s-monokai span.cm-attribute,
.CodeMirror span.cm-attribute {
  color: #9cdcfe !important;
}

.CodeMirror-hints {
  background: #1a1a1a !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 6px;
  color: #c9d1d9 !important;
  font-family: 'Fira Code', monospace;
  box-shadow: 0 8px 24px rgba(0,0,0,0.8);
}

.CodeMirror-hint {
  color: #cccccc !important;
  padding: 4px 12px !important;
}

li.CodeMirror-hint-active {
  background: #4f46e5 !important;
  color: #ffffff !important;
}

#wbSplitResizer:hover,
#wbSplitResizer.dragging,
#wbTerminalResizer:hover,
#wbTerminalResizer.dragging {
  background: #4f46e5 !important;
}

@media (max-width: 992px) {
  #wbSplitWorkspaceContainer {
    flex-direction: column !important;
  }
  #wbCodeEditorWrapper {
    height: 100% !important;
  }
  #wbTerminalContainer {
    border-left: none !important;
    border-top: 1px solid var(--stroke) !important;
    height: 100% !important;
  }
}

@media (max-width: 576px) {
  #wbEditorToolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 8px 12px !important;
  }
  .mode-toggles,
  #wbCodeControls {
    width: 100% !important;
    justify-content: space-between !important;
  }
  #wbLanguageSelect {
    flex: 1 !important;
    max-width: 60% !important;
  }
  #wbRunBtn {
    flex: 1 !important;
    justify-content: center !important;
  }
}

/* Sidebar collapsed state for overlay sidebar under 992px */
.sidebar.collapsed {
  width: 0 !important;
  border-left: none !important;
  box-shadow: none !important;
  pointer-events: none !important;
}

/* Landscape and Short Display Sizing Optimizations (max-height: 520px) */
@media (max-height: 520px) {
  .header-bar {
    padding: 6px 16px !important;
    margin: 4px !important;
    border-radius: var(--radius-sm) !important;
  }
  
  .header-bar h2,
  .room-info {
    font-size: 0.8rem !important;
  }
  
  #copyLinkBtn {
    padding: 4px 10px !important;
    font-size: 0.75rem !important;
  }
  
  .floating-controls {
    bottom: 6px !important;
    padding: 6px 12px !important;
  }
  
  .control-btn {
    width: 34px !important;
    height: 34px !important;
  }
  
  .control-btn svg {
    width: 14px !important;
    height: 14px !important;
  }
  
  #video-grid {
    padding: 6px !important;
    padding-bottom: 65px !important;
    gap: 8px !important;
  }
  
  .video-wrapper {
    max-width: max(180px, calc((100vh - 100px) * 16 / 9)) !important;
    aspect-ratio: 16 / 9 !important;
  }
}

@media (max-width: 576px) {
  .header-bar {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: stretch !important;
    text-align: center !important;
    padding: 12px 16px !important;
  }
  
  .room-info {
    justify-content: center !important;
  }
}

@media (max-width: 768px) {
  #video-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    gap: 12px !important;
  }
}

@media (max-width: 480px) {
  .join-card {
    padding: 24px !important;
  }

  .floating-controls {
    bottom: 16px !important;
    gap: 8px !important;
    padding: 8px 12px !important;
  }

  .control-btn {
    width: 40px !important;
    height: 40px !important;
    font-size: 0.85rem !important;
  }
  
  #video-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
    gap: 8px !important;
    padding-bottom: 115px !important;
  }
}

/* =======================================================
   FUTURISTIC CYBER-MODERN EXTENSIONS (ZERO CPU OVERHEAD)
   ======================================================= */

/* 1. Picture-in-Picture Button on Video Cards */
.pip-btn {
  position: absolute;
  bottom: 16px;
  right: 60px; /* Placed cleanly to the left of fullscreen-btn (right: 16px) */
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--stroke-light);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: none; /* Hidden by default, shown on hover */
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 60;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.pip-btn:hover {
  background: #00f0ff;
  color: #000;
  border-color: #00f0ff;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
  transform: scale(1.05);
}

.video-wrapper:hover .pip-btn {
  display: flex;
}

/* 2. Real-time Network Latency Quality HUD Badge */
.latency-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  right: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(10, 10, 15, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  color: #a3e635;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 55;
  pointer-events: none;
  transition: color 0.3s ease, border-color 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.latency-badge .optic-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulseOptic 2s infinite ease-in-out;
}

@keyframes pulseOptic {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.latency-badge.med {
  color: #facc15; /* Yellow/Amber for medium ping */
  border-color: rgba(250, 204, 21, 0.3);
}

.latency-badge.high {
  color: #f43f5e; /* Rose/Red for high ping */
  border-color: rgba(244, 63, 94, 0.3);
}

/* 3. Audio Waveform Visi-Bars (Canvas equalizer ring around avatar) */
.audio-visi-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate3d(-50%, -50%, 0);
  width: 140px;
  height: 140px;
  pointer-events: none;
  z-index: 10;
  will-change: transform;
  backface-visibility: hidden;
}

/* 4. P2P Reaction Bursting Particles */
.reaction-particle {
  position: absolute;
  bottom: 20px;
  left: 50%;
  font-size: 2.2rem;
  pointer-events: none;
  z-index: 99;
  transform: translateX(-50%) translateY(0) scale(0.5);
  animation: floatUpFade 2.2s cubic-bezier(0.25, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

@keyframes floatUpFade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(10px) scale(0.5) rotate(-10deg);
  }
  15% {
    opacity: 1;
    transform: translateX(-50%) translateY(-20px) scale(1.2) rotate(10deg);
  }
  100% {
    opacity: 0;
    transform: translateX(calc(-50% + var(--drift, 0px))) translateY(-160px) scale(0.9) rotate(var(--rot, 0deg));
  }
}

/* 5. Reaction Bar in Cyber-Dock */
.reaction-bar-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.reaction-menu {
  position: absolute;
  bottom: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  display: flex;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(20, 20, 30, 0.9);
  border: 1px solid #00f0ff;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0, 240, 255, 0.25), 0 15px 35px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2147483647 !important;
}

.reaction-menu.open {
  transform: translateX(-50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.emoji-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  padding: 6px;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-btn:hover {
  transform: scale(1.4) translateY(-4px);
  text-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

/* 6. AI Auto-Director Toggle & Badge */
.director-btn.active {
  background: linear-gradient(135deg, #4f46e5, #00f0ff) !important;
  color: white !important;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
}

/* 7. Fullscreen Button on Video Cards */
.fullscreen-btn {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--stroke-light);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 60;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.fullscreen-btn:hover {
  background: #00f0ff;
  color: #000;
  border-color: #00f0ff;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
  transform: scale(1.05);
}

.video-wrapper:hover .fullscreen-btn {
  display: flex;
}

.fullscreen-btn .fs-compress {
  display: none;
}

.fullscreen-btn.is-fullscreen .fs-expand,
:fullscreen .fullscreen-btn .fs-expand,
:-webkit-full-screen .fullscreen-btn .fs-expand {
  display: none;
}

.fullscreen-btn.is-fullscreen .fs-compress,
:fullscreen .fullscreen-btn .fs-compress,
:-webkit-full-screen .fullscreen-btn .fs-compress {
  display: block;
}

/* 8. Unpin Button on Focused Video Cards */
.unpin-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  left: auto;
  background: rgba(239, 68, 68, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  z-index: 65;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.unpin-btn:hover {
  background: rgb(239, 68, 68);
  transform: scale(1.15) rotate(90deg);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
}

.video-wrapper.focused .unpin-btn {
  display: flex;
}

.video-wrapper.focused .video-mute-icon {
  top: 60px;
  right: 16px;
}
