:root {
  --bg-app: #1e1f22;
  --bg-panel: #2b2d31;
  --bg-panel-alt: #313338;
  --bg-input: #1e1f22;
  --bg-hover: #35373c;
  --border: #3f4147;
  --text: #f2f3f5;
  --text-muted: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #da373c;
  --danger-hover: #a12828;
  --online: #23a55a;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text);
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
}

a {
  color: var(--accent);
}

button {
  font-family: inherit;
  cursor: pointer;
}

input, button, select {
  font-size: 14px;
}

.hidden {
  display: none !important;
}

/* ---------- generic buttons ---------- */

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s ease;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
}

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

.btn-small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
}

/* ---------- auth page ---------- */

.auth-page {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.auth-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 14px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.auth-card .btn {
  width: 100%;
  margin-top: 8px;
}

.auth-switch {
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.auth-switch button {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  padding: 0;
}

.error-box {
  background: rgba(218, 55, 60, 0.15);
  border: 1px solid var(--danger);
  color: #ffb3b3;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- top bar (shared) ---------- */

.topbar {
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- rooms page ---------- */

.rooms-page main {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px;
}

.rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.rooms-header h2 {
  margin: 0;
}

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

.room-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.room-card .room-name {
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 4px;
}

.room-card .room-meta {
  color: var(--text-muted);
  font-size: 13px;
}

.room-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.room-card .room-meta .live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  margin-right: 5px;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 48px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal {
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
}

.modal h3 {
  margin-top: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- room page ---------- */

.room-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.room-topbar {
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
}

.room-topbar .room-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.room-topbar .back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
}

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

.audio-output-select {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  max-width: 180px;
}

.status-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-muted);
}

.status-pill.connected {
  background: rgba(35, 165, 90, 0.18);
  color: var(--online);
}

.status-pill.error {
  background: rgba(218, 55, 60, 0.18);
  color: #ff8686;
}

.room-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.stage {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.members-panel {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.members-panel h4 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.members-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
}

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

.member-item .member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.member-item .member-name {
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-item .member-sharing {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
}

.member-item .member-kick-btn {
  background: none;
  border: none;
  font-size: 12px;
  opacity: 0.5;
  flex-shrink: 0;
  padding: 2px;
}

.member-item .member-kick-btn:hover {
  opacity: 1;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.tile {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.tile .tile-placeholder {
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 12px;
}

.tile .tile-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.65);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tile .tile-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  padding: 22px 10px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.tile:hover .tile-controls,
.tile:focus-within .tile-controls {
  opacity: 1;
}

.tile .tile-controls button {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tile .tile-controls button:hover {
  background: rgba(255, 255, 255, 0.25);
}

.tile .tile-controls button.muted {
  color: var(--danger);
}

.tile .tile-controls input[type='range'] {
  flex: 1;
  accent-color: var(--accent);
}

.empty-stage {
  color: var(--text-muted);
  text-align: center;
  padding: 80px 20px;
}

.empty-stage .big {
  font-size: 18px;
  margin-bottom: 6px;
  color: var(--text);
}

.audio-unlock-banner {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  z-index: 90;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
