:root {
  --bg: #050507;
  --bg-alt: #0b0a10;
  --card: rgba(20, 18, 27, 0.72);
  --card-solid: #14121b;
  --card-border: rgba(255, 255, 255, 0.08);
  --border: #221f2e;
  --text: #f4f2fb;
  --text-dim: #9b96b3;
  --accent: #8b5cf6;
  --accent-2: #c084fc;
  --accent-hover: #7c3aed;
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --danger: #f6607c;
  --danger-hover: #e14d69;
  --success: #4fd6a8;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(700px 480px at 100% 0%, rgba(192, 132, 252, 0.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

.hidden { display: none !important; }

button, input, select {
  font-family: inherit;
  font-size: 0.95rem;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 0.6em 1.2em;
  background: var(--accent-gradient);
  color: white;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 18px -8px rgba(139, 92, 246, 0.7);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.15s ease;
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(139, 92, 246, 0.85); }
button:active { transform: translateY(0) scale(0.98); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

button.secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--card-border);
}
button.secondary:hover { background: rgba(255, 255, 255, 0.1); box-shadow: none; }

button.danger { background: var(--danger); box-shadow: 0 6px 18px -8px rgba(246, 96, 124, 0.7); }
button.danger:hover { background: var(--danger-hover); box-shadow: 0 10px 22px -8px rgba(246, 96, 124, 0.85); }

button.icon { padding: 0.5em 0.7em; }

input[type="text"], input[type="password"] {
  background: #0a090f;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0.65em 0.85em;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 20px 40px -24px rgba(0, 0, 0, 0.6);
}

.muted { color: var(--text-dim); }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  position: relative;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: -60px -60px auto -60px;
  height: 220px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.35), transparent 70%);
  filter: blur(10px);
  z-index: -1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}
.brand-logo { height: 30px; width: auto; display: block; filter: drop-shadow(0 0 14px rgba(139, 92, 246, 0.55)); }
.brand-name {
  font-size: 1.4rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #ffffff, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-card .brand { justify-content: center; margin-bottom: 0.4rem; }
.auth-card .brand-logo { height: 46px; }
.auth-card .brand-name { font-size: 1.7rem; }
.auth-tagline { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin: 0 0 1.6rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--text-dim); }

.form-actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1.2rem; }

.error-msg { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin-top: 0.5rem; }
.success-msg { color: var(--success); font-size: 0.85rem; min-height: 1.2em; margin-top: 0.5rem; }

.link-btn { background: none; color: var(--accent-2); padding: 0; font-weight: 500; box-shadow: none; }
.link-btn:hover { background: none; text-decoration: underline; transform: none; box-shadow: none; }

/* ---------- Dashboard ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(8, 7, 12, 0.72);
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 5;
}

.uuid-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #0a090f;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3em 0.8em;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}
.section-title h2 { margin: 0; font-size: 1.05rem; }

.list { display: flex; flex-direction: column; gap: 0.6rem; }

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  gap: 0.75rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.list-item:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(139, 92, 246, 0.35); }
.list-item .info { display: flex; flex-direction: column; min-width: 0; }
.list-item .info strong { font-size: 0.95rem; }
.list-item .info span { font-size: 0.75rem; color: var(--text-dim); font-family: monospace; overflow: hidden; text-overflow: ellipsis; }
.list-item .actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

.empty-hint { color: var(--text-dim); font-size: 0.88rem; padding: 0.5rem 0; }

.add-friend-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.add-friend-row input { flex: 1; }

.friend-picker {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
  margin-bottom: 1rem;
}
.friend-picker label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 2, 6, 0.72);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  z-index: 20;
}
.modal { width: 100%; max-width: 420px; }

/* ---------- Room ---------- */

.room-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(8, 7, 12, 0.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-wrap: wrap;
  gap: 0.6rem;
}
.room-topbar .brand-name { font-size: 1.15rem; }

.controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.02);
}

.controls label.checkbox {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.85rem; color: var(--text-dim);
}

.toggle-active { background: var(--success) !important; color: #06231a !important; box-shadow: 0 6px 18px -8px rgba(79, 214, 168, 0.7) !important; }

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  padding: 1.25rem;
}

.tile {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--card-border);
  aspect-ratio: 16 / 9;
  box-shadow: 0 16px 32px -20px rgba(0, 0, 0, 0.8);
}
.tile video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.tile .label {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(0,0,0,0.55);
  padding: 0.2em 0.6em;
  border-radius: 999px;
  font-size: 0.78rem;
}
.tile .kind-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--accent-gradient);
  padding: 0.15em 0.55em;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-line { padding: 0 1.25rem; color: var(--text-dim); font-size: 0.85rem; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-solid);
  border: 1px solid var(--card-border);
  padding: 0.7em 1.1em;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 50;
}
