:root {
  --bg: #0e0e14;
  --bg-raise: #181822;
  --bg-panel: #1b1b28;
  --border: #2c2c3d;
  --text: #f2f2f8;
  --muted: #9a9ab0;
  --accent: #9147ff;
  --accent-hover: #a66bff;
  --danger: #ff4d5e;
  --live: #ff3b3b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  background: rgba(14, 14, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.brand span { color: var(--accent); }

.nav { display: flex; gap: 0.5rem; align-items: center; }
.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); background: var(--bg-raise); }
.nav-cta { background: var(--accent); color: #fff !important; }
.nav-cta:hover { background: var(--accent-hover); }

/* ---------- layout ---------- */

.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.view { animation: fade 0.25s ease; }
.hidden { display: none !important; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; padding: 2.5rem 0 2rem; }
.hero h1 { font-size: 2.4rem; margin: 0 0 0.5rem; letter-spacing: -1px; }
.hero p { color: var(--muted); margin: 0; font-size: 1.05rem; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 1rem;
}
.section-head h2 { margin: 0; font-size: 1.3rem; }

/* ---------- stream grid ---------- */

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.2rem;
}

.stream-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.stream-card:hover { transform: translateY(-3px); border-color: var(--accent); }

.thumb {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #2a1a4d, #141428);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb::after {
  content: "";
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/24px no-repeat;
}

.live-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--live);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  letter-spacing: 1px;
}

.card-body { padding: 0.9rem 1rem 1.1rem; }
.card-body h3 { margin: 0 0 0.25rem; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body .btn { margin-top: 0.7rem; width: 100%; text-align: center; text-decoration: none; display: block; }

/* ---------- panels & forms ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  max-width: 860px;
  margin: 0 auto;
}
.panel.narrow { max-width: 460px; }
.panel h2 { margin-top: 0; }

.form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.2rem; }
.form label { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 600; font-size: 0.95rem; }
.form input, .form select {
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  font-weight: 400;
}
.form input:focus, .form select:focus { outline: none; border-color: var(--accent); }

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

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; width: 100%; margin-top: 1.2rem; }

/* ---------- studio / player ---------- */

.studio-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.studio-title { display: flex; align-items: center; gap: 0.6rem; }
.studio-title h2 { margin: 0; }
.live-text { color: var(--live); font-weight: 800; letter-spacing: 1px; font-size: 0.85rem; }

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.6); }
  50% { box-shadow: 0 0 0 7px rgba(255, 59, 59, 0); }
}

.player {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
}

/* picture-in-picture overlay stack (screen + camera overlay via CSS only) */
.player-stack {
  position: relative;
  width: 100%;
}
.player-stack .player { width: 100%; }

.pip {
  position: absolute;
  right: 2.5%;
  bottom: 6%;
  width: 22%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  z-index: 5;
  pointer-events: none;
}

.share-box { margin-top: 1.2rem; }
.copy-row { display: flex; gap: 0.5rem; }
.copy-row input {
  flex: 1;
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
}

/* ---------- chat ---------- */

.chat {
  margin-top: 1.2rem;
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-messages {
  min-height: 80px;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.chat-msg { font-size: 0.95rem; line-height: 1.35; overflow-wrap: anywhere; }
.chat-from { font-weight: 700; color: var(--accent-hover); margin-right: 0.45rem; }
.chat-msg.host .chat-from { color: var(--live); }
.chat-text { color: var(--text); }
.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.8rem;
  font-size: 0.95rem;
}
.chat-form input:focus { outline: none; border-color: var(--accent); }
.chat-form .btn { padding: 0.55rem 1rem; }

/* ---------- misc ---------- */

.pill {
  background: var(--bg-raise);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.muted { color: var(--muted); font-weight: 400; }
.center { text-align: center; }
.empty { color: var(--muted); text-align: center; padding: 2.5rem 0; }
.error { color: var(--danger); margin: 0; font-weight: 600; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raise);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.8rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  z-index: 100;
  max-width: 90vw;
}

@media (max-width: 600px) {
  .hero h1 { font-size: 1.7rem; }
  .panel { padding: 1.2rem; }
}
