:root {
  --bg: #101214;
  --panel: #1a1e22;
  --text: #e6e9eb;
  --muted: #8b949c;
  --accent: #4da3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid #2a2f34;
}

.brand { font-weight: 700; letter-spacing: 0.04em; }
#status { color: var(--muted); font-size: 0.9rem; }

#you {
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
}
#you::after { content: ' ✏'; color: var(--muted); font-size: 0.75em; }
#you[hidden] { display: none; }

#copyLinkBtn {
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.joinRow {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

#joinInput {
  flex: 1;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid #3a4048;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}
#joinInput:focus { outline: none; border-color: var(--accent); }

#renameInput {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  width: 12rem;
}

#nudge {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  max-width: 1200px;
  padding: 0.6rem 1rem;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
}
#nudge[hidden] { display: none; }
#nudgeText { flex: 1; }

button.ghost {
  background: transparent;
  border: 1px solid #3a4048;
  color: var(--text);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem;
}

#stage {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-content: flex-start;
  width: 100%;
  max-width: 1200px;
  min-height: 200px;
}

#placeholder {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  background: #000;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.1rem;
}
#placeholder[hidden] { display: none; }

.tile {
  position: relative;
  flex: 1 1 420px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

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

.tile .label {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.15rem 0.5rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--text);
}

.tile .playOverlay {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.tile .playOverlay[hidden] { display: none; }

/* per-stream playback controls: mute + volume, on hover (or focus/touch) */
.tile .tileCtl {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.55rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tile:hover .tileCtl,
.tile:focus-within .tileCtl { opacity: 1; }
@media (hover: none) {
  .tile .tileCtl { opacity: 1; } /* no hover on touch — always show */
}

.tile .tileMute {
  padding: 0.05rem 0.3rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
}

.tile .tileFs {
  padding: 0.05rem 0.3rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
}

.tile .tileVol {
  width: 90px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* fullscreen: the tile fills the screen (label + controls ride along) */
.tile:fullscreen {
  border-radius: 0;
  aspect-ratio: auto;
  max-width: none;
}
.tile:fullscreen .tileCtl { opacity: 1; } /* controls stay reachable without hover */

.landingCard {
  background: var(--panel);
  border: 1px solid #2a2f34;
  border-radius: 10px;
  padding: 2rem 2.5rem;
  max-width: 420px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.landingCard p { margin: 0; }
.landingCard .hint { color: var(--muted); font-size: 0.85rem; }

#toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(500px, 90vw);
  z-index: 100;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: 6px;
  border: 1px solid #ff6b6b;
  background: #2a1215;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.35;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  white-space: pre-wrap;
}

.toast.info {
  border-color: var(--accent);
  background: var(--panel);
}

#controls { display: flex; gap: 0.8rem; }

/* ---- share setup (your outgoing stream profile) ---- */

#shareSetup {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 10, 0.72);
}
#shareSetup[hidden] { display: none; }

.shareSetupCard {
  background: var(--panel);
  border: 1px solid #2a2f34;
  border-radius: 10px;
  padding: 1.2rem 1.4rem;
  width: min(430px, calc(100vw - 2.5rem));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.shareSetupTitle { font-weight: 700; font-size: 1.05rem; margin-bottom: 0.2rem; }
.shareSetupSub { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.9rem; }

.shareSetupRow { display: flex; gap: 0.8rem; }
.shareSetupRow label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.shareSetupCard select {
  padding: 0.5rem 0.6rem;
  border: 1px solid #2a2f34;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.shareSetupHint { color: var(--muted); font-size: 0.78rem; margin: 0.9rem 0 0; }
.shareSetupActions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }

button {
  padding: 0.65rem 1.3rem;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #08121d;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

#stopBtn { background: #ff6b6b; color: #210505; }
button:hover { filter: brightness(1.08); }

/* ---- admin pane ---- */

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, monospace; font-size: 0.85em; }

.adminMain {
  width: 100%;
  max-width: 960px;
  align-items: stretch;
}

.card {
  background: var(--panel);
  border: 1px solid #2a2f34;
  border-radius: 10px;
  padding: 1rem 1.4rem;
}

.card h2 {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

#serverInfo {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1.2rem;
  margin: 0;
}
#serverInfo dt { color: var(--muted); }
#serverInfo dd { margin: 0; }

.roomCard { margin-bottom: 0.9rem; }
.roomCard:last-child { margin-bottom: 0; }

.roomHead {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
}

.roomId { color: var(--accent); font-family: ui-monospace, monospace; font-size: 0.9rem; }

.badge {
  padding: 0.1rem 0.5rem;
  border: 1px solid #3a4048;
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--muted);
}
.badge.ok { border-color: #3f9e6b; color: #6fd39a; }
.badge.warn { border-color: #b0883a; color: #e6c26a; }

.peerList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.peerList li { display: flex; align-items: center; gap: 0.8rem; }
.peerName { font-weight: 600; }

#usersTable { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
#usersTable th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem 0.5rem 0;
  border-bottom: 1px solid #2a2f34;
}
#usersTable td { padding: 0.35rem 0.6rem 0.35rem 0; border-bottom: 1px solid #22272c; vertical-align: top; }

.history span[title] { cursor: help; border-bottom: 1px dotted #3a4048; }
