:root {
  --bg: #121212;
  --panel: #1f1f1f;
  --player: #000000;
  --text: #ffffff;
  --muted: #b3b3b3;
  --live: #e50914;
  --offline: #6c757d;
  --btn: #007bff;
  --btn-hover: #0056b3;
  --danger: #e50914;
  --radius: 8px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

a {
  color: #8ab4ff;
}

.header {
  width: 90%;
  max-width: 960px;
  margin: 24px 0 16px;
  text-align: center;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 8px;
}

.header-meta {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
}

.status-badge {
  display: inline-block;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: var(--offline);
}

.status-badge.is-live {
  background: var(--live);
}

.player-container {
  width: 90%;
  max-width: 960px;
  background: var(--player);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  overflow: hidden;
}

.video-stage {
  position: relative;
}

.video-stage video {
  width: 100%;
  height: auto;
  display: block;
  background: #000;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.capture-layout .player-container {
  width: 100%;
}

video {
  width: 100%;
  height: auto;
  display: block;
  background: #000;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

.placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.72);
  text-align: center;
  padding: 24px;
}

.placeholder[hidden] {
  display: none;
}

.placeholder p {
  margin: 0;
  color: var(--muted);
}

#frameView {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

#liveAudio {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #333;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.controls {
  padding: 15px;
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.controls .hint {
  color: var(--muted);
  font-size: 14px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button,
.button {
  background: var(--btn);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
}

button:hover,
.button:hover {
  background: var(--btn-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: #b20710;
}

button.ghost {
  background: transparent;
  border: 1px solid #444;
}

button.ghost:hover {
  background: #2a2a2a;
}

.footer {
  width: 90%;
  max-width: 960px;
  margin: 20px 0 28px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}

.toast.show {
  opacity: 1;
}

.capture-layout {
  width: 90%;
  max-width: 960px;
  display: grid;
  gap: 16px;
}

.capture-panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.field select {
  background: #2a2a2a;
  color: var(--text);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 8px;
  font-size: 14px;
}

.url-list {
  display: grid;
  gap: 8px;
}

.url-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.url-item code {
  flex: 1;
  background: #2a2a2a;
  padding: 8px;
  border-radius: 4px;
  font-size: 13px;
  word-break: break-all;
}

.banner {
  width: 90%;
  max-width: 960px;
  background: #3a2208;
  color: #ffd7a8;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
}

.banner[hidden] {
  display: none;
}

@media (min-width: 768px) {
  .capture-layout {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }

  .capture-layout .player-container {
    width: 100%;
  }
}

@media (max-width: 767px) {
  .header h1 {
    font-size: 1.25rem;
  }

  button,
  .button {
    padding: 10px 16px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-row {
    justify-content: stretch;
  }

  .btn-row button {
    flex: 1;
  }
}
