:root {
  --bg: #0b0d12;
  --bg-card: #141824;
  --bg-elevated: #1b2130;
  --text: #eef2ff;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #151a28 0%, var(--bg) 55%);
  color: var(--text);
}

a {
  color: var(--accent-hover);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  text-align: center;
  margin-bottom: 40px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.03em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.card p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-sm {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 0.82rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.info-panel {
  margin-top: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: center;
}

.qr-box {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  background: #111;
  border: 1px solid var(--border);
  overflow: hidden;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.url-list {
  display: grid;
  gap: 10px;
}

.url-item {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.url-item strong {
  min-width: 90px;
  color: var(--muted);
  font-weight: 600;
}

.url-item code {
  background: var(--bg-elevated);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  word-break: break-all;
}

.copy-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-live {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.badge-live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

.badge-sync {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.video-shell {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  isolation: isolate;
}

.video-shell video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  background: #000;
  pointer-events: none;
  z-index: 1;
}

.video-shell .stream-chat-overlay {
  z-index: 12;
}

.video-shell .video-overlay-controls,
.video-shell .tap-overlay,
.video-shell .fullscreen-btn {
  pointer-events: auto;
  z-index: 20;
}

.video-shell .tap-overlay {
  z-index: 30;
}

.video-shell:fullscreen,
.video-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  aspect-ratio: unset;
  border-radius: 0;
  border: none;
  margin: 0;
}

.video-shell:fullscreen video,
.video-shell:-webkit-full-screen video {
  width: 100%;
  height: 100%;
}

.fullscreen-btn {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 20;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.15s ease;
}

.fullscreen-btn:hover {
  background: rgba(99, 102, 241, 0.85);
}

.video-shell:fullscreen.is-live .empty-state,
.video-shell:-webkit-full-screen.is-live .empty-state {
  display: none !important;
}

.video-shell:fullscreen .fullscreen-btn,
.video-shell:-webkit-full-screen .fullscreen-btn {
  bottom: 24px;
  right: 24px;
}

.video-shell .empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
  padding: 24px;
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  color: var(--muted);
  font-size: 0.95rem;
}

.video-shell .empty-state[hidden],
.video-shell.is-live .empty-state {
  display: none !important;
}

.video-shell.is-live .status-bar-inline {
  display: none;
}

.video-shell.is-live video {
  opacity: 1;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  align-items: center;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  color: var(--muted);
  font-size: 0.9rem;
}

.field input, .field select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
}

.notice {
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.notice-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #fcd34d;
}

.notice-info {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 1000;
}

.toast {
  min-width: 260px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.35);
}

.toast-success {
  border-color: rgba(34, 197, 94, 0.35);
}

@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.file-list {
  display: grid;
  gap: 10px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.file-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

input[type="range"] {
  width: 100%;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.room-code-badge {
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(56, 189, 120, 0.12);
  border: 1px solid rgba(56, 189, 120, 0.35);
  font-size: 1rem;
}

.room-code-badge strong {
  font-size: 1.35rem;
  letter-spacing: 0.08em;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.link-row code {
  flex: 1;
  min-width: 0;
  word-break: break-all;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.qr-wrap img {
  border-radius: 8px;
  background: #fff;
  padding: 6px;
}

.watch-wizard {
  margin-bottom: 16px;
}

.wizard-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.wizard-step {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.wizard-step.is-active {
  color: var(--text);
  background: rgba(99, 102, 241, 0.2);
}

.wizard-step.is-done {
  color: #86efac;
}

.resolved-code {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.resolved-code strong {
  letter-spacing: 0.06em;
}

@media (max-width: 720px) {
  .info-panel {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .url-item {
    justify-content: center;
  }
}

.watch-host-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}

.watch-host-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.watch-current-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.watch-last-stats {
  margin: 6px 0 0;
  color: var(--accent, #6ea8fe);
  font-size: 0.92rem;
}

.now-watching-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.now-watching-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.now-watching-banner strong {
  font-size: 1rem;
}
