:root {
  --bg-darkest: #1a1a2e;
  --bg-dark: #16213e;
  --bg-medium: #1e2a47;
  --bg-light: #253559;
  --bg-lighter: #2d4070;
  --surface: #1e2a47;
  --surface-hover: #283a5c;
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.1);
  --text: #e8eaf0;
  --text-dim: #8892a8;
  --text-muted: #5a6480;
  --accent: #7c5cfc;
  --accent-glow: rgba(124,92,252,0.25);
  --accent-hover: #6a4ce8;
  --green: #43b581;
  --green-glow: rgba(67,181,129,0.2);
  --red: #f04747;
  --red-glow: rgba(240,71,71,0.2);
  --yellow: #faa61a;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-darkest);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-lighter); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── Inputs ─── */
.input {
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-sm { padding: 6px 10px; font-size: 0.8rem; width: auto; }
.input::placeholder { color: var(--text-muted); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #9b7cfc);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
}
.btn-secondary {
  background: var(--bg-light);
  color: var(--text);
}
.btn-secondary:hover { background: var(--bg-lighter); }
.btn-ghost {
  background: transparent; color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #d63e3e; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { font-size: 1.1rem; }
.btn-icon-only {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 1.2rem; cursor: pointer; padding: 6px; border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-icon-only:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.btn-close {
  background: none; border: none; color: var(--text-dim);
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
}
.btn-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

/* ─── Utility ─── */
.hidden { display: none !important; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  background: var(--accent-glow); color: var(--accent); letter-spacing: 0.5px;
}

.error-text { color: var(--red); font-size: 0.8rem; margin-top: 6px; }

/* ═══════════════════════════════════════════
   LOBBY PAGE (index.html)
   ═══════════════════════════════════════════ */

.lobby-container {
  max-width: 680px; margin: 0 auto; padding: 60px 24px 40px;
  min-height: 100vh; display: flex; flex-direction: column;
}

.lobby-header { text-align: center; margin-bottom: 40px; }

.logo {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-bottom: 8px;
}
.logo-icon {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.logo h1 {
  font-size: 2rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #b794f6);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline { color: var(--text-dim); font-size: 0.95rem; }

/* Actions */
.lobby-actions {
  display: flex; gap: 12px; margin-bottom: 32px; flex-wrap: wrap;
}
.join-code-bar {
  display: flex; gap: 8px; flex: 1; min-width: 200px;
}
.join-code-bar .input { flex: 1; }

/* Room List */
.section-title {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 12px;
}

.room-list { display: flex; flex-direction: column; gap: 8px; }

.room-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all var(--transition);
}
.room-card:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
  transform: translateX(4px);
  box-shadow: var(--shadow);
}
.room-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--bg-lighter), var(--accent-glow));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.room-card.private .room-icon {
  background: linear-gradient(135deg, var(--bg-lighter), var(--red-glow));
}
.room-info { flex: 1; min-width: 0; }
.room-info h3 {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-meta {
  display: flex; gap: 10px; font-size: 0.75rem; color: var(--text-dim);
}

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 8px; opacity: 0.5; }

/* Footer */
.lobby-footer {
  margin-top: auto; padding-top: 24px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-dim);
}
.lobby-footer .input { max-width: 160px; }

/* ═══════════════════════════════════════════
   AUTH & PROFILE
   ═══════════════════════════════════════════ */

.auth-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.auth-tabs {
  display: flex; background: var(--bg-dark); border-radius: var(--radius); padding: 4px;
  margin-bottom: 24px;
}
.tab-btn {
  flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-muted);
  font-weight: 600; font-size: 0.85rem; border-radius: var(--radius-sm); cursor: pointer;
  transition: all var(--transition); text-align: center;
}
.tab-btn.active {
  background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.w-100 { width: 100%; justify-content: center; }

/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-dark); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 0; width: 90%; max-width: 420px;
  box-shadow: var(--shadow-lg); animation: slideUp 0.2s ease;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 600; }
.modal-body {
  padding: 20px 24px; display: flex; flex-direction: column; gap: 10px;
}
.modal-body label {
  font-size: 0.8rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.label-hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.modal-footer {
  padding: 16px 24px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border);
}

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

/* ═══════════════════════════════════════════
   ROOM PAGE (room.html)
   ═══════════════════════════════════════════ */

.app-layout {
  display: flex; height: 100vh; overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 64px; background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0; gap: 4px; flex-shrink: 0;
  transition: transform var(--transition);
}
.sidebar-header { margin-bottom: 8px; }
.sidebar-logo {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #9b7cfc);
  font-size: 1.3rem; text-decoration: none;
  transition: border-radius var(--transition);
}
.sidebar-logo:hover { border-radius: var(--radius); }
.sidebar-rooms {
  flex: 1; width: 100%; overflow-y: auto; display: flex;
  flex-direction: column; align-items: center; gap: 4px;
  padding: 0 8px;
}
.sidebar-room-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface); border: none; color: var(--text);
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); position: relative;
  overflow: hidden; text-overflow: ellipsis;
}
.sidebar-room-btn:hover, .sidebar-room-btn.active {
  border-radius: var(--radius); background: var(--accent);
}
.sidebar-foot { margin-top: auto; padding-top: 8px; }

/* Main */
.main-area {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--bg-dark); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-info h2 {
  font-size: 1rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room-code {
  font-family: monospace; font-size: 0.75rem; padding: 2px 8px;
  background: var(--bg-lighter); border-radius: var(--radius-sm);
  color: var(--yellow); letter-spacing: 1px;
}
.topbar-actions { display: flex; gap: 8px; }

/* Voice button */
.btn-voice {
  background: var(--bg-light); color: var(--text);
  border-radius: 99px; padding: 6px 16px;
}
.btn-voice:hover { background: var(--green); }
.btn-voice.active {
  background: var(--green); box-shadow: 0 0 12px var(--green-glow);
}
.btn-voice.active .voice-label::after { content: ''; }

/* Content */
.content-area {
  flex: 1; display: flex; overflow: hidden;
}

/* Chat */
.chat-area {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
}
.chat-feed {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.chat-welcome {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.chat-welcome h3 { font-size: 1.2rem; margin-bottom: 4px; color: var(--text-dim); }

/* Messages */
.msg {
  display: flex; gap: 10px; padding: 6px 0;
  animation: msgIn 0.15s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff;
}
.msg-body { flex: 1; min-width: 0; }
.msg-header {
  display: flex; align-items: baseline; gap: 8px;
}
.msg-author { font-size: 0.85rem; font-weight: 600; }
.msg-time { font-size: 0.7rem; color: var(--text-muted); }
.msg-text {
  font-size: 0.9rem; color: var(--text); word-break: break-word;
  margin-top: 2px;
}

.system-msg {
  text-align: center; font-size: 0.75rem; color: var(--text-muted);
  padding: 4px 0;
}

/* Chat Input */
.chat-input-bar {
  display: flex; gap: 8px; padding: 12px 20px;
  background: var(--bg-dark); border-top: 1px solid var(--border);
}
.chat-input-bar .input { flex: 1; }

/* Users Panel */
.users-panel {
  width: 220px; background: var(--bg-dark);
  border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto; flex-shrink: 0;
  transition: transform var(--transition), width var(--transition);
}
.users-panel.collapsed { width: 0; padding: 0; overflow: hidden; border: none; }
.panel-title {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px;
}
.panel-section { margin-bottom: 20px; }
.user-list { list-style: none; }
.user-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius-sm);
  font-size: 0.85rem; transition: background var(--transition);
}
.user-item:hover { background: rgba(255,255,255,0.04); }
.user-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0;
}
.user-dot.muted { background: var(--red); }

/* Mic Controls */
.mic-controls {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; padding: 10px 16px;
  background: var(--bg-dark); border: 1px solid var(--border-light);
  border-radius: 99px; box-shadow: var(--shadow-lg); z-index: 50;
  animation: slideUp 0.2s ease;
}
.btn-mic {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; border: none; cursor: pointer;
  transition: all var(--transition);
}
.btn-mic.muted { background: var(--red); color: #fff; }
.btn-mic.unmuted { background: var(--green); color: #fff; box-shadow: 0 0 16px var(--green-glow); }

/* ─── Mobile Responsive ─── */
.mobile-only { display: none; }

@media (max-width: 768px) {
  .mobile-only { display: block; }

  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .users-panel { 
    position: fixed; right: 0; top: 0; bottom: 0; z-index: 40;
    width: 240px; transform: translateX(100%);
  }
  .users-panel.open { transform: translateX(0); }

  .lobby-actions { flex-direction: column; }

  .topbar-actions .voice-label { display: none; }
}
