:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1c2130;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #ff3b5c;
  --accent-2: #4f8cff;
  --radius: 14px;
  --maxw: 1100px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2030 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.titles { min-width: 0; }

.topbar h1 {
  font-size: clamp(1.05rem, 2.5vw, 1.5rem);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #555c6e;
  flex: 0 0 auto;
  transition: background .3s, box-shadow .3s;
}
.live-dot.on {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(255, 59, 92, .6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,59,92,.55); }
  70%  { box-shadow: 0 0 0 9px rgba(255,59,92,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,59,92,0); }
}

.actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #2a3142;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s, transform .05s;
}
.share-btn:hover { background: #232a3b; }
.share-btn:active { transform: scale(.97); }

/* ---------- Player ---------- */
.player-wrap {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 6px 18px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  object-fit: contain;
}

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 8, 12, .72);
  backdrop-filter: blur(4px);
  transition: opacity .25s;
}
.overlay[hidden] { display: none; }

.overlay-box {
  text-align: center;
  padding: 24px;
  max-width: 90%;
}
.overlay-box p {
  margin: 16px 0 0;
  color: var(--text);
  font-size: 0.98rem;
}

.spinner {
  width: 42px; height: 42px;
  margin: 0 auto;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.retry-btn {
  margin-top: 18px;
  background: var(--accent-2);
  color: #fff;
  border: 0;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.retry-btn:hover { filter: brightness(1.08); }

/* ---------- Manual input ---------- */
.manual {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid #232a3b;
  border-radius: var(--radius);
  padding: 18px;
}
.manual p { margin: 0 0 12px; color: var(--muted); }
.manual-hint { margin: 12px 0 0 !important; font-size: 0.8rem; opacity: .8; }
.manual code { color: var(--accent-2); background: #0e1320; padding: 2px 6px; border-radius: 5px; }
#manualForm { display: flex; gap: 10px; flex-wrap: wrap; }
#manualInput {
  flex: 1;
  min-width: 220px;
  background: #0e1320;
  border: 1px solid #2a3142;
  color: var(--text);
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 0.95rem;
}
#manualForm button {
  background: var(--accent-2);
  color: #fff; border: 0;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- Footer ---------- */
.foot {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px 18px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}
.status {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: #232a3b;
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .share-btn span { display: none; }
  .share-btn { padding: 9px; }
  .player-wrap { padding: 6px 10px 12px; }
  .topbar { padding: 12px 12px; }
}

/* Plein écran paysage mobile : la vidéo prend tout l'espace */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar, .foot { display: none; }
  .player-wrap { padding: 0; }
  .player { aspect-ratio: auto; height: 100dvh; border-radius: 0; }
}
