:root {
  --bg: #101418;
  --panel: #1a222c;
  --text: #e8eef4;
  --muted: #9aa8b5;
  --accent: #3d8bfd;
  --line: #2a3542;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "IBM Plex Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

header h1 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: 0.02em;
}

.sub {
  margin: 0.35rem 0 1.5rem;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.2rem;
  margin-bottom: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

input {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #121820;
  color: var(--text);
}

button {
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #243041;
  color: var(--text);
  cursor: pointer;
}

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.status {
  min-height: 1.2em;
  margin: 0.4rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.hidden { display: none !important; }

.stage {
  margin-top: 1rem;
}

.videos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.tile {
  position: relative;
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}

.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.tile audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.tile .label {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  font-size: 0.75rem;
}

.tile.screen {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.controls .count {
  color: var(--muted);
  font-size: 0.9rem;
  margin-left: auto;
}

button.on {
  border-color: #3a6b3a;
}

button.off {
  border-color: #8a3a3a;
  opacity: 0.85;
}

.chat {
  margin-top: 1rem;
}

.chat-log {
  height: 180px;
  overflow-y: auto;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #121820;
  font-size: 0.9rem;
}

.chat-line {
  margin-bottom: 0.35rem;
  line-height: 1.35;
}

.chat-line strong {
  color: var(--accent);
  font-weight: 600;
}

@media (min-width: 900px) {
  .videos {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}
