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

body {
  background: #f8f9fb;
  color: #1a202c;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  z-index: 1000;
}

.header-container {
  width: 100%;
  max-width: 1100px;
  padding: 0 52px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 20px;
  color: #1a202c;
}

button {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.2s ease;
  padding: 10px 20px;
  font-size: 14px;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: #f3f4f6;
  color: #6b7280;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.popup {
  position: absolute;
  top: 60px;
  right: 32px;
  background: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  min-width: 240px;
  max-width: 280px;
  z-index: 1001;
  border: 1px solid #e5e7eb;
}

.popup h3 {
  margin-bottom: 12px;
  color: #1a202c;
  font-size: 15px;
  font-weight: 600;
}

.popup input {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.popup input:focus {
  outline: none;
  border-color: #3b82f6;
}

.popup button {
  width: 100%;
  margin-top: 4px;
  padding: 8px 16px;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

main {
  flex: 1;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 180px 20px 32px 20px;
}

.page {
  width: 100%;
  max-width: 1000px;
}

#dashboardPage h1 {
  text-align: center;
  margin-bottom: 40px;
  color: #1a202c;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.card {
  background: white;
  padding: 28px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-color: #d1d5db;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.card h2 {
  margin-bottom: 20px;
  color: #1a202c;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card button {
  margin-top: auto;
}

.card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.card input:focus {
  outline: none;
  border-color: #3b82f6;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #6b7280;
  font-size: 14px;
}

.form-group input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.session-info {
  background: white;
  padding: 32px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.session-info h3 {
  color: #1a202c;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 10px;
  gap: 12px;
}

.info-row span {
  color: #6b7280;
  font-size: 14px;
  flex: 1;
  text-align: left;
  word-break: break-all;
}

.info-row code {
  background: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', monospace;
  display: block;
  margin-top: 4px;
}

.info-row strong {
  color: #1a202c;
  font-weight: 600;
  font-size: 16px;
}

.session-info button {
  margin: 8px 4px;
}

.session-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  height: 70vh;
  max-height: 700px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  margin: 0 auto;
}

.cloud {
  display: none;
}

#avatarsContainer {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 20px;
  display: grid;
  gap: 16px;
  align-content: stretch;
  justify-content: stretch;
}

/* Динамические grid layouts в зависимости от количества участников */
#avatarsContainer[data-count="1"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

#avatarsContainer[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

#avatarsContainer[data-count="3"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;
}

#avatarsContainer[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

#avatarsContainer[data-count="5"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

#avatarsContainer[data-count="5"] .avatar:nth-child(1),
#avatarsContainer[data-count="5"] .avatar:nth-child(2) {
  grid-column: span 1;
}

#avatarsContainer[data-count="5"] .avatar:nth-child(3) {
  grid-column: 1 / 2;
}

#avatarsContainer[data-count="5"] .avatar:nth-child(4),
#avatarsContainer[data-count="5"] .avatar:nth-child(5) {
  grid-column: span 1;
}

#avatarsContainer[data-count="6"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

#avatarsContainer[data-count="7"],
#avatarsContainer[data-count="8"],
#avatarsContainer[data-count="9"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: repeat(auto-fill, 1fr);
}

.avatar {
  width: 100%;
  height: 100%;
  min-height: 150px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #1a202c;
  font-weight: 600;
  font-size: 24px;
  position: relative;
  background: #f3f4f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid #000000;
  overflow: hidden;
}

.avatar.active {
  border-color: #3b82f6;
  border-width: 3px;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.avatar.muted::after {
  content: '';
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: #ef4444;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  border: 3px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Звуковая волна */
.sound-wave {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 5;
}

.avatar.speaking .sound-wave {
  opacity: 1;
}

.sound-wave-bar {
  width: 4px;
  background: linear-gradient(to right, #667eea, #764ba2, #f093fb, #43e97b, #feca57, #fa709a);
  border-radius: 2px;
  animation: soundWave 0.5s ease-in-out infinite;
}

.sound-wave-bar:nth-child(1) { height: 20px; animation-delay: 0s; }
.sound-wave-bar:nth-child(2) { height: 35px; animation-delay: 0.1s; }
.sound-wave-bar:nth-child(3) { height: 50px; animation-delay: 0.2s; }
.sound-wave-bar:nth-child(4) { height: 45px; animation-delay: 0.3s; }
.sound-wave-bar:nth-child(5) { height: 60px; animation-delay: 0.1s; }
.sound-wave-bar:nth-child(6) { height: 40px; animation-delay: 0.2s; }
.sound-wave-bar:nth-child(7) { height: 55px; animation-delay: 0.3s; }
.sound-wave-bar:nth-child(8) { height: 45px; animation-delay: 0s; }
.sound-wave-bar:nth-child(9) { height: 35px; animation-delay: 0.1s; }
.sound-wave-bar:nth-child(10) { height: 25px; animation-delay: 0.2s; }

@keyframes soundWave {
  0%, 100% { 
    transform: scaleY(0.5);
    opacity: 0.6;
  }
  50% { 
    transform: scaleY(1);
    opacity: 1;
  }
}

/* Индикатор поднятой руки */
.hand-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  border: 2px solid #e5e7eb;
  z-index: 10;
}

.hand-indicator.hidden {
  display: none;
}

.hand-indicator svg {
  width: 28px;
  height: 28px;
  color: #1a202c;
}

@keyframes handWave {
  0%, 100% { 
    transform: rotate(0deg);
  }
  25% { 
    transform: rotate(-15deg);
  }
  75% { 
    transform: rotate(15deg);
  }
}

.avatar-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar:hover .avatar-controls {
  opacity: 1;
}

.avatar-controls button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.avatar-controls button:hover {
  background: white;
  transform: scale(1.1);
}

.name-tag {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: #1a202c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 1;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding: 16px;
  background: white;
  border-radius: 50px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  background: transparent;
  border-radius: 50%;
  transition: all 0.2s ease;
  border: none;
}

.control-btn:hover {
  background: #f3f4f6;
}

.control-btn.leave:hover {
  background: #fee2e2;
}

.control-btn.muted {
  background: #fee2e2;
}

.control-btn .icon {
  font-size: 20px;
  filter: grayscale(100%);
  opacity: 0.7;
}

.control-btn:hover .icon {
  opacity: 1;
}

.control-btn svg {
  width: 24px;
  height: 24px;
  color: #6b7280;
}

.control-btn:hover svg {
  color: #1a202c;
}

.control-btn.leave svg {
  color: #ef4444;
}

.control-btn.muted svg {
  color: #ef4444;
}

.control-btn .label {
  display: none;
}

@media (max-width: 768px) {
  header {
    padding: 12px 16px;
  }

  .logo {
    font-size: 18px;
  }

  .session-container {
    height: 60vh;
  }

  #avatarsContainer {
    padding: 40px;
  }

  .avatar {
    width: 64px;
    height: 64px;
    font-size: 14px;
  }

  .controls {
    gap: 8px;
  }

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

  .control-btn .icon {
    font-size: 18px;
  }
}

/* Дополнительные стили для визуального feedback */
.avatar.speaking {
  animation: speaking 0.5s ease-in-out;
}

@keyframes speaking {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* Меню выхода */
.logout-menu {
  position: absolute;
  top: 60px;
  right: 32px;
  background: white;
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
  z-index: 1001;
  min-width: 200px;
}

.logout-menu-content p {
  margin: 0 0 12px 0;
  color: #6b7280;
  font-size: 14px;
}

.logout-menu-content strong {
  color: #1a202c;
}

.logout-menu button {
  width: 100%;
}

/* Попап приглашения */
.invite-popup {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid #e5e7eb;
  z-index: 1002;
  min-width: 400px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.invite-popup-content h3 {
  margin: 0 0 16px 0;
  color: #1a202c;
  font-size: 18px;
  font-weight: 700;
}

.invite-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 8px;
}

.invite-item span {
  color: #6b7280;
  font-size: 14px;
  font-weight: 500;
}

.invite-item button {
  padding: 6px 14px;
  font-size: 13px;
}

/* Система уведомлений */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border-left: 4px solid #3b82f6;
  z-index: 10000;
  font-size: 14px;
  font-weight: 500;
  color: #1a202c;
  max-width: 400px;
  opacity: 0;
  transform: translateX(100px);
  transition: all 0.3s ease;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification-success {
  border-left-color: #10b981;
  background: #f0fdf4;
  color: #065f46;
}

.notification-error {
  border-left-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

.notification-info {
  border-left-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
}