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

:root {
  --bg:        #0d0d1a;
  --surface:   #14142b;
  --panel:     #1a1a35;
  --border:    #2a2a55;
  --accent:    #7c3aed;
  --accent2:   #06b6d4;
  --green:     #22c55e;
  --red:       #ef4444;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --msg-bg:    #1e1e3f;
  --msg-self:  #2d1b69;
  --radius:    8px;
}

body { background: var(--bg); color: var(--text); font-family: 'Exo 2', sans-serif; height: 100vh; overflow: hidden; }

.auth-page { display: flex; align-items: center; justify-content: center; }

.auth-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 10;
  box-shadow: 0 0 60px rgba(124,58,237,0.3);
}

.logo { font-family: 'Orbitron', sans-serif; font-size: 2rem; color: var(--accent2); text-align: center; }
.tagline { text-align: center; color: var(--muted); margin: 0.4rem 0 1.5rem; font-size: 0.85rem; }

.tab-switcher { display: flex; gap: 0.5rem; margin-bottom: 1.2rem; }
.tab-btn {
  flex: 1; padding: 0.5rem; border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); border-radius: var(--radius); cursor: pointer; transition: all .2s;
  font-family: 'Exo 2', sans-serif;
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-btn:hover:not(.active) { border-color: var(--accent); color: var(--text); }

.auth-form { display: none; flex-direction: column; gap: 0.8rem; }
.auth-form.active { display: flex; }

.auth-form input {
  padding: 0.75rem 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.95rem; font-family: 'Exo 2', sans-serif;
  transition: border-color .2s;
}
.auth-form input:focus { outline: none; border-color: var(--accent); }

.btn-primary {
  padding: 0.75rem; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: var(--radius); color: #fff; font-size: 1rem;
  font-family: 'Exo 2', sans-serif; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.btn-primary:hover { opacity: 0.88; }

.msg { font-size: 0.85rem; min-height: 1.2rem; text-align: center; }
.msg.error { color: var(--red); }
.msg.success { color: var(--green); }

.note { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 1rem; }

.bg-animation { position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; z-index: 0; }
.bg-animation span {
  position: absolute; display: block; width: 20px; height: 20px;
  background: rgba(124,58,237,0.15); border-radius: 50%; animation: float 25s infinite;
}
.bg-animation span:nth-child(1) { left: 10%; animation-delay: 0s; width: 80px; height: 80px; }
.bg-animation span:nth-child(2) { left: 30%; animation-delay: 5s; width: 40px; height: 40px; }
.bg-animation span:nth-child(3) { left: 60%; animation-delay: 10s; width: 60px; height: 60px; }
.bg-animation span:nth-child(4) { left: 80%; animation-delay: 3s; width: 30px; height: 30px; }
.bg-animation span:nth-child(5) { left: 50%; animation-delay: 7s; width: 100px; height: 100px; }
@keyframes float { 0%,100% { transform: translateY(110vh) rotate(0deg); opacity:0; } 10%,90% { opacity:1; } 50% { transform: translateY(-10vh) rotate(720deg); } }

.chat-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.2rem; height: 52px; flex-shrink: 0;
}
.logo-small { font-family: 'Orbitron', sans-serif; color: var(--accent2); font-size: 1rem; }
.topbar-center { font-weight: 600; color: var(--accent2); font-size: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 0.8rem; }
.user-badge {
  background: var(--accent); color: #fff; padding: 0.2rem 0.7rem;
  border-radius: 20px; font-size: 0.78rem; font-weight: 600;
}
.btn-sm {
  padding: 0.3rem 0.8rem; background: var(--panel); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); cursor: pointer; font-size: 0.8rem;
  transition: background .2s;
}
.btn-sm:hover { background: var(--red); border-color: var(--red); color:#fff; }

.layout { display: flex; flex: 1; overflow: hidden; }

.sidebar {
  width: 200px; background: var(--surface); border-color: var(--border);
  flex-shrink: 0; display: flex; flex-direction: column; overflow-y: auto;
  padding: 0.5rem;
}
.sidebar.left { border-right: 1px solid var(--border); }
.sidebar.right { border-left: 1px solid var(--border); }
.sidebar-title { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 0.5rem 0.3rem 0.3rem; }

.room-list { list-style: none; }
.room-list li {
  padding: 0.5rem 0.6rem; border-radius: var(--radius); cursor: pointer; color: var(--muted);
  font-size: 0.88rem; transition: all .2s; display: flex; align-items: center; gap: 0.4rem;
}
.room-list li:hover, .room-list li.active { background: var(--panel); color: var(--text); }
.room-list li.active { border-left: 3px solid var(--accent); color: var(--accent2); }

.user-list { list-style: none; }
.user-list li { padding: 0.4rem 0.6rem; font-size: 0.82rem; display: flex; align-items: center; gap: 0.5rem; }
.dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; flex-shrink: 0; }
.dot.guest { background: var(--muted); }

.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-track { background: var(--bg); }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg-row { display: flex; align-items: flex-start; gap: 0.6rem; }
.msg-row.self { flex-direction: row-reverse; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 0.9rem; font-weight: 700; flex-shrink: 0; color: #fff;
}

.msg-bubble {
  max-width: 65%; background: var(--msg-bg); border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px; padding: 0.5rem 0.8rem;
}
.msg-row.self .msg-bubble { background: var(--msg-self); border-radius: 12px 12px 4px 12px; }

.msg-username { font-size: 0.72rem; color: var(--accent2); font-weight: 600; margin-bottom: 0.2rem; }
.msg-text { font-size: 0.9rem; line-height: 1.4; word-break: break-word; }
.msg-time { font-size: 0.65rem; color: var(--muted); text-align: right; margin-top: 0.2rem; }

.msg-system {
  text-align: center; color: var(--muted); font-size: 0.78rem; font-style: italic;
  padding: 0.2rem; background: none;
}

.audio-bar {
  background: var(--panel); border-top: 1px solid var(--border);
  padding: 0.5rem 1rem; display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap;
}
.audio-bar.hidden { display: none; }
#audio-status { font-size: 0.82rem; color: var(--muted); }

.btn-audio {
  padding: 0.3rem 0.9rem; border-radius: 20px; border: 1px solid var(--accent);
  background: transparent; color: var(--accent); cursor: pointer; font-size: 0.8rem;
  font-family: 'Exo 2', sans-serif; transition: all .2s;
}
.btn-audio:hover { background: var(--accent); color: #fff; }
.btn-audio.red { border-color: var(--red); color: var(--red); }
.btn-audio.red:hover { background: var(--red); color: #fff; }

.peers-list { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.peer-tag { background: var(--accent); color: #fff; border-radius: 20px; padding: 0.2rem 0.6rem; font-size: 0.75rem; }

.input-row {
  display: flex; gap: 0.5rem; padding: 0.7rem 1rem;
  background: var(--surface); border-top: 1px solid var(--border); flex-shrink: 0;
}
.input-row input {
  flex: 1; padding: 0.65rem 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 24px; color: var(--text); font-size: 0.92rem; font-family: 'Exo 2', sans-serif;
}
.input-row input:focus { outline: none; border-color: var(--accent); }

.btn-send {
  padding: 0.65rem 1.3rem; background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: 24px; color: #fff; font-weight: 600; cursor: pointer;
  font-family: 'Exo 2', sans-serif; transition: opacity .2s;
}
.btn-send:hover { opacity: 0.85; }

.hidden { display: none !important; }

hr { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }

@media (max-width: 768px) {
  .sidebar.left { width: 160px; }
  .sidebar.right { display: none; }
}
@media (max-width: 520px) {
  .sidebar.left { display: none; }
  .topbar-center { font-size: 0.85rem; }
}