:root {
  --bg: #0e0e10; --panel: #18181b; --line: #2f2f35; --text: #efeff1; --muted: #adadb8;
  --accent: #9147ff; --ok: #00c08b; --warn: #ffb020; --err: #ff4f4f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { background: #2a2a2e; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { background: #35353b; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
input[type=text], input[type=password], input[type=number], select { background: #0e0e10; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.muted { color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 99px; background: #26262c; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }

/* ---- Espectadores ---- */
.room { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 100vh; }
.screen { position: relative; min-width: 0; background: #000; }
.stage { position: relative; height: 100%; background: #000; display: flex; align-items: center; justify-content: center; }
.stage video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage .idle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; padding: 16px; }
.stage .idle strong { color: var(--text); font-size: 20px; }
.bar { position: absolute; z-index: 2; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: linear-gradient(transparent, rgba(0,0,0,.85)); opacity: 0; transition: opacity .2s; }
.screen:hover .bar, .bar:focus-within { opacity: 1; }
.bar .grow { flex: 1; }
.bar > * { flex: none; }
#time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar input[type=range] { width: 110px; accent-color: var(--accent); }
/* Su directo de Twitch encima del vídeo: 16:9 al tamaño mínimo que permite Twitch (400×300 de alto mínimo) */
.cam { position: absolute; z-index: 4; top: 12px; left: 12px; width: 534px; height: 300px; background: #000; box-shadow: 0 10px 30px rgba(0,0,0,.65); outline: 1px solid rgba(255,255,255,.1); }
.cam[data-corner=tr] { left: auto; right: 12px; }
.cam[data-corner=bl] { top: auto; bottom: 64px; }
.cam[data-corner=br] { top: auto; left: auto; right: 12px; bottom: 64px; }
#twitch-player { width: 100%; height: 100%; }
#twitch-player iframe { display: block; }
.cam-move { position: absolute; left: 0; top: calc(100% + 6px); font-size: 12px; padding: 3px 10px; opacity: 0; transition: opacity .2s; background: rgba(24,24,27,.92); }
.cam[data-corner=bl] .cam-move, .cam[data-corner=br] .cam-move { top: auto; bottom: calc(100% + 6px); }
.cam:hover .cam-move, .cam-move:focus-visible { opacity: 1; }
.side { display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--panel); min-height: 0; min-width: 0; }
#twitch-chat { flex: 1; width: 100%; border: 0; min-height: 0; display: block; }
.tune { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 12px; flex-wrap: wrap; }
.tune button { padding: 2px 8px; }
.gate { position: fixed; inset: 0; background: rgba(14,14,16,.92); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.gate .card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; max-width: 420px; text-align: center; }
.gate h1 { margin: 0 0 8px; font-size: 22px; }
.gate p { margin: 0 0 20px; color: var(--muted); }
/* Pantalla completa: vídeo + su cámara encima */
.screen:fullscreen { display: block; background: #000; }
.screen:fullscreen .stage { height: 100%; width: 100%; aspect-ratio: auto; }
.screen:fullscreen .cam { position: absolute; margin: 0; width: 534px; height: 300px; }
.screen:fullscreen .cam-move { display: block; }
/* Pantallas medianas y móviles: no hay sitio para ponerla encima; va debajo del vídeo */
@media (max-width: 1299px) {
  .room { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100vh; }
  .screen:not(:fullscreen) { display: flex; flex-direction: column; align-items: center; background: var(--bg); }
  .screen:not(:fullscreen) .stage { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .screen:not(:fullscreen) .cam { position: static; margin-top: 12px; width: min(534px, 100%); }
  .screen:not(:fullscreen) .cam-move { display: none; }
  .bar { opacity: 1; }
  .side { border-left: 0; border-top: 1px solid var(--line); margin-top: 12px; }
  #twitch-chat { height: 70vh; flex: none; }
}
@media (max-width: 600px) {
  .bar { gap: 6px; padding: 8px; }
  .bar input[type=range] { width: 70px; }
  .bar #status span:last-child { display: none; }
}

/* ---- App de la streamer ---- */
.app { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(14,14,16,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; margin-right: 6px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-size: 12px; color: #fff; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: #1f1f23; border: 1px solid var(--line); font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip.live { background: rgba(235, 4, 0, .15); border-color: rgba(235, 4, 0, .5); color: #ff8a8a; }
.chip.live .dot { background: #eb0400; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 260px; box-shadow: 0 12px 32px rgba(0,0,0,.5); display: flex; flex-direction: column; gap: 2px; }
.menu button { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px; }
.menu button:hover { background: #2a2a2e; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; padding: 16px; max-width: 1500px; margin: 0 auto; }
.player { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
.player video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.player .empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 16px; border: 2px dashed #3a3a42; border-radius: 12px; }
.player .empty .big { font-size: 20px; font-weight: 600; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: #26262c; color: var(--muted); white-space: nowrap; }
.badge.local { background: rgba(0,192,139,.15); color: #4be3b5; }
.badge.server { background: rgba(145,71,255,.18); color: #c7a6ff; }
.player .big-btn { font-size: 16px; padding: 10px 22px; }
.preview-tag { position: absolute; left: 10px; top: 10px; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(0,0,0,.6); color: var(--muted); }
.sharebar { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #141417; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.sharebar .row { margin: 0; }
.sharebar.ok { border-color: rgba(0,192,139,.45); }
.sharebar.warn { border-color: rgba(255,176,32,.6); }
.sharebar.err { border-color: rgba(255,79,79,.6); }
button.danger { border-color: rgba(255,79,79,.5); color: #ff9a9a; }
button.danger:hover { background: rgba(255,79,79,.12); }
.vol { display: inline-flex; align-items: center; gap: 6px; }
.vol input { width: 90px; accent-color: var(--accent); }
.meter { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: #2a2a2e; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s; }
.warn-msg { margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(255,176,32,.1); color: #ffd28a; font-size: 13px; }
.guide ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.guide details summary { cursor: pointer; color: var(--text); }
.side-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.card h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.small { font-size: 12px; }
.guide ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.guide li::marker { color: var(--accent); font-weight: 700; }
.guide .tip { margin: 12px 0 0; padding: 8px 10px; border-radius: 8px; background: #1f1f23; color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2a2a2e; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 20; max-width: min(560px, calc(100vw - 32px)); }
.login { max-width: 400px; margin: 14vh auto; padding: 0 16px; }
.login .card p { color: var(--muted); }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .topbar .chip#viewers-chip, .topbar #preview-room { display: none; }
}
