/* ===== ТОКЕНЫ ===== */
:root {
  --bg:        #0e0f13;
  --bg-2:      #16181f;
  --bg-3:      #1e2029;
  --bg-4:      #252833;
  --border:    #2a2d3a;
  --accent:    #5865F2;
  --accent-h:  #4752c4;
  --danger:    #ed4245;
  --danger-h:  #c03537;
  --muted:     #72767d;
  --text:      #dcddde;
  --text-dim:  #8e9297;
  --text-head: #ffffff;
  --green:     #3ba55d;
  --speaking:  #23a559;

  --radius:    10px;
  --radius-sm: 6px;
  --sidebar-w: 240px;
  --transition: 0.15s ease;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== ЭКРАНЫ ===== */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ===== ВХОД ===== */
#screen-login {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #1a1d2e 0%, var(--bg) 70%);
}

.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.login-title {
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-head);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 28px;
}

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

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-head);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.2);
}

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

.form-error {
  color: #f87171;
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 4px;
  text-align: center;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.btn-primary:hover { background: var(--accent-h); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== КОМНАТА ===== */
#screen-room { align-items: stretch; }

.room-layout {
  display: flex;
  width: 100%;
  height: 100vh;
}

/* --- Сайдбар --- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
}

.room-icon { font-size: 20px; }

.room-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-head);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-status {
  font-size: 11px;
  color: var(--text-dim);
}

.room-status.connected { color: var(--green); }

.participants-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 14px 14px 6px;
}

.participants-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: 0 6px;
}

.participants-list::-webkit-scrollbar { width: 4px; }
.participants-list::-webkit-scrollbar-track { background: transparent; }
.participants-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.participant-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  cursor: default;
}

.participant-item:hover { background: var(--bg-3); }

.participant-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  position: relative;
  transition: box-shadow var(--transition);
}

.participant-avatar.speaking {
  box-shadow: 0 0 0 2px var(--speaking);
}

.participant-name {
  font-size: 13px;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-name.is-you { color: var(--text-head); }

.participant-mute-icon {
  color: var(--danger);
  font-size: 12px;
  opacity: 0;
  transition: opacity var(--transition);
}

.participant-mute-icon.visible { opacity: 1; }

/* --- Footer сайдбара --- */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-3);
}

.my-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.my-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.my-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-head);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-controls { display: flex; gap: 4px; }

.ctrl-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
}

.ctrl-btn:hover { background: var(--bg-4); color: var(--text-head); }

.ctrl-btn.muted {
  background: var(--danger);
  color: white;
}

.ctrl-btn.muted:hover { background: var(--danger-h); }

.ctrl-btn--leave:hover { background: var(--danger); color: white; }

/* --- Основная зона --- */
.room-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

/* Сетка голосовых карточек */
.voice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 24px;
  justify-content: center;
  align-content: center;
  width: 100%;
  height: 100%;
}

.voice-card {
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 140px;
  transition: border-color var(--transition), transform var(--transition);
}

.voice-card.speaking {
  border-color: var(--speaking);
}

.voice-card-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: white;
  position: relative;
  transition: box-shadow var(--transition);
}

.voice-card.speaking .voice-card-avatar {
  box-shadow: 0 0 0 3px var(--speaking), 0 0 16px rgba(35, 165, 89, 0.3);
}

.voice-card-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-head);
  text-align: center;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-card-mute {
  font-size: 16px;
  opacity: 0;
  transition: opacity var(--transition);
}

.voice-card-mute.visible { opacity: 1; }

/* --- Overlay подключения --- */
.connecting-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 14px;
  transition: opacity 0.3s ease;
}

.connecting-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.connecting-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== УТИЛИТЫ ===== */
.hidden { display: none !important; }

/* ===== МОБИЛКА ===== */
@media (max-width: 600px) {
  .sidebar {
    width: 200px;
  }
  .voice-card { width: 110px; padding: 18px 14px; }
  .voice-card-avatar { width: 48px; height: 48px; font-size: 20px; }
}

@media (max-width: 440px) {
  .room-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .participants-list { max-height: 80px; }
}

/* ===== МОДАЛКА ВЫХОДА ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-icon { font-size: 36px; }

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-head);
}

.modal-text {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.modal-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.modal-btn--cancel {
  background: var(--bg-4);
  color: var(--text);
}
.modal-btn--cancel:hover { background: var(--border); }

.modal-btn--confirm {
  background: var(--danger);
  color: white;
}
.modal-btn--confirm:hover { background: var(--danger-h); }

/* ===== КНОПКА ГРОМКОСТИ В СПИСКЕ ===== */
.vol-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition), color var(--transition);
}

.participant-item:hover .vol-btn { opacity: 1; }
.vol-btn:hover { background: var(--bg-4); color: var(--text-head); }

/* ===== ПОПАП ГРОМКОСТИ ===== */
.volume-popup {
  position: fixed;
  z-index: 999;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.volume-popup.hidden { display: none; }

.volume-popup-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.volume-val {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
}

.volume-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 4px;
}
