:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a24;
  --bg-card: rgba(18, 18, 26, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(254, 147, 140, 0.3);
  --text-primary: #f4f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #fe938c;
  --accent-glow: rgba(254, 147, 140, 0.15);
  --accent-bright: #ffb3ae;
  --success: #34d399;
  --success-glow: rgba(52, 211, 153, 0.2);
  --danger: #f87171;
  --danger-glow: rgba(248, 113, 113, 0.15);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-glow: 0 0 40px rgba(254, 147, 140, 0.08);
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  --header-height: 56px;
  --control-bar-height: 64px;
  --sidebar-width: 240px;

  /* Safe area insets for mobile devices */
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

body.light-mode {
  --bg-primary: #f5f6fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eef0f5;
  --bg-card: rgba(255, 255, 255, 0.98);
  --bg-glass: rgba(0, 0, 0, 0.02);
  --bg-hover: rgba(0, 0, 0, 0.04);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(229, 115, 108, 0.4);
  --text-primary: #1a1a2e;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent: #e5736c;
  --accent-glow: rgba(229, 115, 108, 0.12);
  --accent-bright: #d85d56;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.12);
  --shadow-glow: 0 0 40px rgba(229, 115, 108, 0.06);
}

/* Theme transition - smooth toggle between light/dark */
body,
.login-screen,
.login-card,
.app-container,
.app-header,
.sidebar,
.sidebar-header,
.chat-area,
.chat-header,
.chat-messages,
.chat-input-wrapper,
.chat-bubble,
.control-bar,
.settings-content,
.settings-body,
.log-panel,
.log-container,
.screenshare-viewer,
.screenshare-header,
.toast,
.user-item,
.status-badge {
  transition: background 300ms ease,
    background-color 300ms ease,
    border-color 250ms ease,
    color 200ms ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  height: 100%;
  overflow: hidden;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Prevent overscroll/bounce on iOS */
  overscroll-behavior: none;
  /* Ensure the body fills the viewport properly */
  position: fixed;
  inset: 0;
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  animation: toastIn 0.3s ease-out;
  max-width: 360px;
}

.toast.toast-error {
  border-color: rgba(248, 113, 113, 0.4);
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.1), var(--bg-card));
}

.toast.toast-error .toast-icon {
  color: var(--danger);
}

.toast.toast-success {
  border-color: rgba(52, 211, 153, 0.4);
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.1), var(--bg-card));
}

.toast.toast-success .toast-icon {
  color: var(--success);
}

.toast-icon {
  flex-shrink: 0;
}

.toast-icon svg {
  width: 20px;
  height: 20px;
}

.toast-message {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

.toast.hiding {
  animation: toastOut 0.2s ease-in forwards;
}

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

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

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-area-bottom));
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(254, 147, 140, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(229, 115, 108, 0.06) 0%, transparent 50%),
    var(--bg-primary);
}

body.light-mode .login-screen {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(229, 115, 108, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(254, 147, 140, 0.04) 0%, transparent 50%),
    var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  position: relative;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-glow);
}

/* ===== LOADING STATE ===== */
.login-card.loading .login-form {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.3s ease-out;
}

.login-card.loading .login-logo {
  transform: translateY(40px);
  transition: transform 0.4s ease-out;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out;
  padding-top: 80px;
  overflow: hidden;
}

.login-card.loading .loading-overlay {
  opacity: 1;
  pointer-events: auto;
}

.loading-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 16px;
  animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

/* Animated cat logo */
.logo-icon.animated {
  animation: logoGrow 8s cubic-bezier(0.1, 0.8, 0.2, 1) forwards;
}

.logo-icon.animated svg {
  overflow: visible;
}

/* Whisker wiggle animation */
.logo-icon.animated .whiskers-left {
  transform-origin: 8.5px 14.8px;
  animation: whiskerWiggleLeft 0.3s ease-in-out infinite alternate;
}

.logo-icon.animated .whiskers-right {
  transform-origin: 15.5px 14.8px;
  animation: whiskerWiggleRight 0.3s ease-in-out infinite alternate;
}

/* Ear twitch animation */
.logo-icon.animated .ears {
  transform-origin: 12px 7px;
  animation: earTwitch 0.8s ease-in-out infinite;
}

/* Eye blink animation */
.logo-icon.animated .eyes {
  transform-origin: center 12.2px;
  animation: eyeBlink 2.5s ease-in-out infinite;
}

@keyframes logoGrow {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(1.2);
  }
}

@keyframes whiskerWiggleLeft {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(-3deg);
  }
}

@keyframes whiskerWiggleRight {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(3deg);
  }
}

@keyframes earTwitch {

  0%,
  80%,
  100% {
    transform: rotate(0deg);
  }

  85% {
    transform: rotate(-2deg);
  }

  90% {
    transform: rotate(2deg);
  }

  95% {
    transform: rotate(-1deg);
  }
}

@keyframes eyeBlink {

  0%,
  40%,
  44%,
  48%,
  100% {
    transform: scaleY(1);
  }

  42% {
    transform: scaleY(0.1);
  }

  46% {
    transform: scaleY(0.1);
  }
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), #e5736c);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(254, 147, 140, 0.3);
  transition: transform 0.3s ease-out;
}

.login-logo .logo-icon svg {
  width: 54px;
  height: 54px;
  color: white;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 14px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.3s ease-out;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  /* Prevent iOS zoom on focus */
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

input::placeholder {
  color: var(--text-muted);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-hover);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Buttons */
button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e5736c);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(254, 147, 140, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(254, 147, 140, 0.4);
}

.btn-large {
  padding: 14px 28px;
  font-size: 15px;
  margin-top: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.icon-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-glow);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Theme Toggle on Login */
.login-card>.theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

body.light-mode .theme-toggle .icon-moon {
  display: none;
}

body.light-mode .theme-toggle .icon-sun {
  display: block;
}

/* ===== MAIN APP CONTAINER ===== */
.app-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

/* ===== APP HEADER ===== */
.app-header {
  height: var(--header-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mini {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #e5736c);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-mini svg {
  width: 32px;
  height: 32px;
  color: white;
}

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

.room-name {
  font-weight: 600;
  font-size: 15px;
}

.status-badge {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.status-badge.connected {
  background: var(--success-glow);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--success);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-disconnect {
  background: var(--danger-glow);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--danger);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.btn-disconnect:hover {
  background: rgba(248, 113, 113, 0.25);
}

.btn-disconnect span {
  display: none;
}

@media (min-width: 640px) {
  .btn-disconnect span {
    display: inline;
  }
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-smooth), transform var(--transition-smooth),
    background-color 300ms ease, border-color 250ms ease;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sidebar-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.participant-count {
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.collapse-btn {
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0;
  border-radius: var(--radius-sm);
}

.collapse-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* Users List */
.users-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-glass);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.user-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
}

.user-item.speaking {
  border-color: var(--success);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.25);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(254, 147, 140, 0.2), rgba(229, 115, 108, 0.1));
  border: 1px solid rgba(254, 147, 140, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.gain-control-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.gain-toggle.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-glow);
}

.gain-control {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 6px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.gain-control.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.gain-slider {
  width: 4px;
  height: 60px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
}

.gain-slider::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gain-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(254, 147, 140, 0.4);
}

.gain-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.gain-slider::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(254, 147, 140, 0.4);
}

.gain-slider::-moz-range-track {
  width: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  border: none;
}

.user-control-btn {
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 0;
}

.user-control-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.user-control-btn.muted {
  background: var(--danger-glow);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}

.user-control-btn.screenshare {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-glow);
}

.user-control-btn svg {
  width: 14px;
  height: 14px;
}

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}

.chat-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.mobile-only {
  display: none;
}

/* Show sidebar toggle when collapsed on desktop */
.sidebar.collapsed+.chat-area #sidebarToggleMobile {
  display: flex;
  position: relative;
}

.participant-count-mobile {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 600;
}

#chatSoundToggle {
  position: relative;
}

#chatSoundToggle .sound-off {
  display: none;
}

#chatSoundToggle.muted .sound-on {
  display: none;
}

#chatSoundToggle.muted .sound-off {
  display: block;
}

#chatSoundToggle.muted {
  color: var(--danger);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeIn 0.2s ease-out;
}

.chat-message.own {
  align-items: flex-end;
}

.chat-username {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 10px;
}

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
}

.chat-message.own .chat-bubble {
  background: linear-gradient(135deg, rgba(254, 147, 140, 0.15), rgba(229, 115, 108, 0.1));
  border-color: rgba(254, 147, 140, 0.2);
}

.chat-input-wrapper {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.chat-input-wrapper input {
  flex: 1;
}

.btn-send {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent), #e5736c);
  color: white;
  border-radius: var(--radius-md);
  padding: 0;
  flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.05);
}

.btn-send svg {
  width: 18px;
  height: 18px;
}

/* ===== CONTROL BAR ===== */
.control-bar {
  height: var(--control-bar-height);
  padding: 0 16px;
  padding-bottom: var(--safe-area-bottom);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* When safe area is present, increase control bar height to accommodate */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .control-bar {
    height: calc(var(--control-bar-height) + var(--safe-area-bottom));
  }
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group-left {
  flex: 1;
  justify-content: flex-start;
}

.control-group-center {
  flex: 0;
}

.control-group-right {
  flex: 1;
  justify-content: flex-end;
}

.control-btn {
  width: 48px;
  height: 48px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  color: var(--text-primary);
  padding: 0;
}

.control-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-glow);
}

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

/* Mute button states */
#mute .mic-off {
  display: none;
}

#mute.muted {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

#mute.muted .mic-on {
  display: none;
}

#mute.muted .mic-off {
  display: block;
}

/* Share button states */
#share .share-on {
  display: none;
}

#share.sharing {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

#share.sharing .share-off {
  display: none;
}

#share.sharing .share-on {
  display: block;
}

.loopback-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.loopback-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.loopback-toggle:has(input:checked) {
  background: var(--accent-glow);
  border-color: var(--border-glow);
  color: var(--accent);
}

.loopback-toggle input {
  display: none;
}

.loopback-toggle svg {
  width: 18px;
  height: 18px;
}

.device-select {
  max-width: 180px;
  font-size: 12px;
  padding: 8px 32px 8px 10px;
}

/* ===== SETTINGS PANEL ===== */
.settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.settings-content {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.25s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.settings-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  padding-bottom: calc(16px + var(--safe-area-bottom));
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.settings-section h3 svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.setting-item {
  margin-bottom: 12px;
}

.setting-item label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.setting-item select {
  width: 100%;
}

.setting-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Toggle Setting */
.toggle-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  margin-bottom: 8px;
  transition: all var(--transition-fast);
}

.toggle-setting:hover {
  background: var(--bg-hover);
}

.toggle-setting:has(input:checked) {
  background: var(--accent-glow);
  border-color: var(--border-glow);
}

.toggle-setting span:first-child {
  font-size: 13px;
  font-weight: 500;
}

.toggle-setting input {
  display: none;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background: var(--bg-tertiary);
  border-radius: 11px;
  position: relative;
  transition: background var(--transition-fast);
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.toggle-setting:has(input:checked) .toggle-slider {
  background: var(--accent);
}

.toggle-setting:has(input:checked) .toggle-slider::after {
  transform: translateX(18px);
  background: white;
}

/* Preview Sections in Settings */
.preview-section {
  display: none;
}

.preview-section.visible {
  display: block;
}

.preview-section audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-sm);
}

.preview-section video {
  width: 100%;
  max-height: 180px;
  border-radius: var(--radius-md);
  background: #000;
  border: 1px solid var(--border-subtle);
}

/* ===== LOG PANEL ===== */
.log-panel {
  position: fixed;
  bottom: calc(var(--control-bar-height) + var(--safe-area-bottom));
  right: 0;
  width: 360px;
  max-height: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

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

.log-panel-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.log-panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.log-container {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-muted);
  max-height: 240px;
}

.log-container::-webkit-scrollbar {
  width: 4px;
}

.log-container::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

.log-entry {
  padding: 2px 0;
}

.log-entry::before {
  content: '›';
  margin-right: 6px;
  color: var(--accent);
}

/* ===== SCREENSHARE VIEWER ===== */
.screenshare-viewer {
  position: fixed;
  top: calc(var(--header-height) + 16px);
  right: 16px;
  width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  z-index: 500;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  resize: both;
}

.screenshare-viewer.fullscreen {
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  z-index: 2000;
  resize: none;
}

.screenshare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
}

.screenshare-header span {
  font-size: 13px;
  font-weight: 500;
}

.screenshare-controls {
  display: flex;
  gap: 6px;
}

#screenshareVideo {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  object-fit: contain;
}

.screenshare-viewer.fullscreen #screenshareVideo {
  height: calc(100% - 45px);
  aspect-ratio: auto;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --header-height: 52px;
    --control-bar-height: 72px;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: calc(var(--control-bar-height) + var(--safe-area-bottom));
    z-index: 100;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--transition-smooth);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed {
    width: 280px;
  }

  .mobile-only {
    display: flex;
    position: relative;
  }

  .participant-count-mobile {
    display: flex;
  }

  .device-select {
    display: none;
  }

  .control-btn {
    width: 52px;
    height: 52px;
  }

  .screenshare-viewer {
    top: auto;
    bottom: calc(var(--control-bar-height) + var(--safe-area-bottom) + 16px);
    right: 16px;
    left: 16px;
    width: auto;
  }

  .log-panel {
    width: 100%;
    left: 0;
  }

  .settings-content {
    max-width: 100%;
  }

  .btn-disconnect span {
    display: none;
  }
}

/* Large screens */
@media (min-width: 1200px) {
  :root {
    --sidebar-width: 280px;
  }
}