:root {
  --bg: #0d0e12;
  --surface: #171922;
  --surface-2: #222532;
  --line: #2e3243;
  --text: #f2f3f7;
  --muted: #9aa0b4;
  --accent: #7c5cff;
  --accent-ink: #ffffff;
  --live: #ff3d57;
  --ok: #25d366;
  --warn: #ffb020;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 20px; background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--live); color: #fff; }
.btn.ok { background: var(--ok); color: #06240f; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 8px 14px; min-height: 36px; font-size: 14px; }
.btn.block { width: 100%; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.input, .field input[type=text], .field input[type=password], .field input[type=number], .field input[type=date], .field input[type=tel], .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-height: 44px; outline: none;
}
.field textarea { min-height: 96px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.error { color: #ff8b9a; font-size: 14px; min-height: 20px; margin: 8px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .03em; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.chip.live { background: var(--live); color: #fff; }
.chip.ok { background: rgba(37, 211, 102, .16); color: #5fe494; }
.chip.warn { background: rgba(255, 176, 32, .16); color: var(--warn); }
.chip.off { background: rgba(255, 61, 87, .16); color: #ff8b9a; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } .sheet { transition: none !important; } }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: #000d; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 100; max-width: 90vw; text-align: center; pointer-events: none; }

/* ---------- escenario del live (cliente y panel) ---------- */
.live-page { background: #000; overflow: hidden; }
.stage { touch-action: manipulation; position: relative; height: var(--app-h, 100dvh); width: 100%; max-width: calc(var(--app-h, 100dvh) * 9 / 16); margin: 0 auto; background: #000; overflow: hidden; }
.stage video.main { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.stage video.main.landscape { object-fit: contain; }
.stage video.main.mirror { transform: scaleX(-1); }
.shade-top, .shade-bottom { position: absolute; left: 0; right: 0; pointer-events: none; }
.shade-top { top: 0; height: 120px; background: linear-gradient(#000a, transparent); }
.shade-bottom { bottom: 0; height: 55%; background: linear-gradient(transparent, #000b); }

.topbar { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + env(safe-area-inset-top)) 12px 0; display: flex; align-items: center; gap: 8px; z-index: 5; }
.topbar .who { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.topbar .who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; text-shadow: 0 1px 3px #000; }
.count { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; background: #0008; padding: 4px 10px; border-radius: 999px; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: #0008; color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.icon-btn svg, .btn svg, .count svg, .tool svg { width: 20px; height: 20px; flex: none; }

.cartel { position: absolute; left: 12px; right: 12px; z-index: 4; border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 6px 24px #0007; text-align: center; }
.cartel.pos-top { top: calc(64px + env(safe-area-inset-top)); }
.cartel.pos-middle { top: 34%; }
.cartel.pos-bottom { bottom: 46%; }
.cartel .c-title { font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.cartel a { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 700; padding: 3px 0; overflow-wrap: anywhere; }
.cartel a svg { width: 1.15em; height: 1.15em; flex: none; }
.cartel.size-s { font-size: 14px; }
.cartel.size-m { font-size: 17px; }
.cartel.size-l { font-size: 21px; }

.chat { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px calc(10px + env(safe-area-inset-bottom)); z-index: 6; }
.msgs { max-height: 34dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 28px 0 10px; scrollbar-width: none; -webkit-mask-image: linear-gradient(transparent, #000 28px); mask-image: linear-gradient(transparent, #000 28px); max-width: 86%; }
.msgs::-webkit-scrollbar { display: none; }
.m { align-self: flex-start; background: transparent; border-radius: 12px; padding: 2px 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; text-shadow: none; }
.m b { display: block; color: #ff4fc8; font-size: 13px; font-weight: 600; line-height: 1.2; }
.m .txt { display: block; color: #fff; }
.m.host { background: transparent; }
.m.host b { color: #fff; }
.m.mine b { cursor: pointer; }
.m.mine b::after { content: ' ✎'; }
.m.sys { background: transparent; color: #fffc; font-size: 13px; padding-left: 0; }
button.m { border: 0; text-align: left; color: inherit; cursor: pointer; }
.chat form { display: flex; gap: 8px; }
.chat input { flex: 1; min-width: 0; background: #000a; border: 1px solid #fff3; border-radius: 999px; padding: 12px 16px; min-height: 46px; outline: none; color: #fff; }
.chat input::placeholder { color: #fffa; }
.chat .send { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }

.chat form .like { width: 46px; height: 46px; border-radius: 50%; border: 0; background: #000a; color: #ff4fc8; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; touch-action: manipulation; }
.chat form .like svg { width: 24px; height: 24px; }
.chat form .like:active { transform: scale(.9); }

/* Corazones que suben por el costado derecho */
.hearts { position: absolute; right: 8px; bottom: 120px; width: 70px; height: 55%; pointer-events: none; z-index: 6; overflow: visible; }
.heart { position: absolute; right: 12px; bottom: 0; width: 34px; height: 34px; animation: heart-up var(--dur, 2.4s) ease-out forwards; filter: drop-shadow(0 2px 4px #0006); }
.heart svg { width: 100%; height: 100%; }
@keyframes heart-up {
  0% { transform: translate(0, 0) scale(.3) rotate(0); opacity: 0; }
  12% { transform: translate(0, -20px) scale(1.1) rotate(var(--rot)); opacity: 1; }
  100% { transform: translate(var(--dx), -100%) translateY(-260px) scale(.8) rotate(var(--rot)); opacity: 0; }
}
.likes svg { color: #ff4fc8; }

/* Invitado que habla: cuadradito arriba a la derecha */
.guest-box { position: absolute; top: calc(64px + env(safe-area-inset-top)); right: 12px; z-index: 6; width: 84px; padding: 8px 6px 6px; border-radius: 14px; background: #0009; border: 1px solid #fff3; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: #fff; font: inherit; cursor: default; }
button.guest-box { cursor: pointer; }
.guest-box .g-initial { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #ff4fc8, var(--accent)); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; box-shadow: 0 0 0 0 #ff4fc8aa; transition: box-shadow .15s; }
.guest-box.speaking .g-initial { box-shadow: 0 0 0 4px #ff4fc8cc; }
.guest-box .g-name { font-size: 12px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-box .g-tag { font-size: 10px; color: #fffb; display: flex; align-items: center; gap: 3px; }
.guest-box .g-tag svg { width: 12px; height: 12px; }
.guest-box .g-off { display: none; color: #ff8b9a; }
.guest-box.muted .g-off { display: inline; }
.guest-box.muted .g-on { display: none; }
.guest-box.muted .g-initial { opacity: .55; }
.stage.has-guest .cartel.pos-top { right: 108px; }
#studio .stage.has-guest .guest-box { right: 70px; }
#studio .stage.has-guest .cartel.pos-top { right: 166px; }

/* Horario de los lives (cuando no hay live) */
.schedule { background: #ffffff12; border: 1px solid #ffffff22; border-radius: var(--radius); padding: 14px 16px; max-width: 320px; width: 100%; display: flex; flex-direction: column; gap: 4px; }
.schedule .s-title { font-weight: 800; font-size: 17px; margin-bottom: 4px; }
.schedule .s-row { font-size: 15px; }
.schedule .s-next { margin-top: 6px; font-weight: 700; color: #ff9ad9; }
.schedule .s-note { font-size: 13px; color: var(--muted); }
.sched-row { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.days label { display: inline-flex; }
.days input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.days span { min-width: 40px; height: 36px; border-radius: 999px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; padding: 0 8px; cursor: pointer; }
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.days input:focus-visible + span { outline: 2px solid #fff; }
.sched-row input[type=time] { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 40px; color: var(--text); }

.guest-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; gap: 10px; background: #000d; border: 1px solid #ff4fc8; border-radius: 999px; padding: 6px 6px 6px 16px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.cover { overflow-y: auto; }

/* Hoja de filtros transparente: el vendedor se ve detrás mientras ajusta la imagen */
.sheet-back.clear { background: transparent; }
#filtersSheet { background: #0000004d; box-shadow: none; max-height: 52dvh; border-top: 1px solid #ffffff26; text-shadow: 0 1px 3px #000; }
#filtersSheet h3, #filtersSheet .hint, #filtersSheet .slider output { color: #ffffffd9; }
#filtersSheet .close { background: #0006; }
#filtersSheet .btn:not(.primary) { background: #0007; }
#filtersSheet .btn.ghost { border-color: #ffffff55; }
/* Mientras se ajustan los filtros, en el celular se oculta el chat para que no se mezcle con los controles. */
@media (max-width: 899px) {
  body.filters-open #studio .chat, body.filters-open #hearts { visibility: hidden; }
}

/* Menú de compartir */
.share-list { display: flex; flex-direction: column; gap: 10px; }
.share-list .btn { justify-content: flex-start; }

.cover { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; padding: 24px; background: radial-gradient(circle at 50% 35%, #2a2350, #0d0e12 70%); }
.cover h1 { font-size: 24px; margin: 0; text-wrap: balance; }
.cover p { margin: 0; color: var(--muted); max-width: 30ch; }
.unmute { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; background: #000c; }

/* Modo "solo video" (/embed/<canal>?mini=1): portada de una tienda. Sin sonido, sin chat;
   al tocar, la página que lo incrusta lleva al live en grande. */
body.mini .chat, body.mini #shareBtn, body.mini #soundBtn, body.mini .unmute, body.mini #coverBtn,
body.mini .sheet, body.mini .sheet-back, body.mini .guest-bar, body.mini #schedule { display: none !important; }
body.mini .stage { cursor: pointer; }
.mini-cta { display: none; }
body.mini .mini-cta { display: flex; align-items: center; justify-content: center; gap: 8px; position: absolute; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 8; padding: 12px 16px; border-radius: 999px; border: 0; background: #ffffffe6; color: #111; font: 600 15px/1.2 inherit; box-shadow: 0 6px 24px #0006; cursor: pointer; }
body.mini .mini-cta svg { width: 20px; height: 20px; flex: none; }

/* ---------- hojas y diálogos ---------- */
.sheet-back { position: fixed; inset: 0; background: #0009; z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 82dvh; overflow-y: auto; max-width: 560px; margin: 0 auto; box-shadow: 0 -10px 40px #000a; }
.sheet h2 { margin: 0 0 14px; font-size: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sheet .close { background: var(--surface-2); border: 0; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 18px; }
.slider { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.slider output { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; background: var(--surface-2); color: var(--muted); font-size: 11px; padding: 0; }
.swatch[aria-pressed=true] { border-color: #fff; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .item { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.list .item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list .item small { color: var(--muted); display: block; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; font-weight: 600; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 20px; width: min(92vw, 440px); }
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 6px; font-size: 20px; }
dialog p { color: var(--muted); margin: 0 0 14px; }

/* ---------- panel del que transmite ---------- */
.tools { position: absolute; right: 10px; top: calc(64px + env(safe-area-inset-top)); z-index: 6; display: flex; flex-direction: column; gap: 12px; }
.tool { border: 0; background: none; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; cursor: pointer; text-shadow: 0 1px 3px #000; padding: 0; }
.tool span.ic { width: 44px; height: 44px; border-radius: 50%; background: #0008; display: inline-flex; align-items: center; justify-content: center; }
.go { display: flex; gap: 8px; margin-top: 10px; }
.go .btn { flex: 1; font-size: 17px; min-height: 52px; }
.src-video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.go .btn#pauseBtn { flex: 0 0 38%; background: #000a; border: 1px solid #fff3; }
.tool.on span.ic { background: var(--accent); }
ol.guide { margin: 0 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.install-box .btn { margin-top: 4px; }

/* En pantallas anchas (PC), el chat pasa a una columna al lado del video. */
@media (min-width: 900px) {
  #studio .stage { margin: 0; }
  #studio .chat { position: fixed; top: 0; bottom: 0; left: calc(var(--app-h, 100dvh) * 9 / 16); right: 0; max-width: 640px; padding: 16px; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }
  #studio .msgs { flex: 1; max-height: none; max-width: none; padding-top: 0; -webkit-mask-image: none; mask-image: none; }
  #studio .m { background: var(--surface-2); text-shadow: none; }
  #studio .m.host { background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); }
  #studio .chat input { background: var(--surface-2); border-color: var(--line); }
}

/* ---------- páginas simples (portada, acceso, administrador) ---------- */
.wrap { max-width: 880px; margin: 0 auto; padding: 20px 16px 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), #ff5c9d); display: inline-flex; align-items: center; justify-content: center; }
.brand .logo svg { width: 18px; height: 18px; }
header.site { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
h1.page { font-size: 28px; margin: 0 0 6px; text-wrap: balance; }
p.lead { color: var(--muted); margin: 0 0 22px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
a.live-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; min-height: 150px; justify-content: space-between; background: linear-gradient(160deg, #2a2350, var(--surface)); }
a.live-card:hover { border-color: var(--accent); }
a.live-card strong { font-size: 18px; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.center-box { max-width: 400px; margin: 8vh auto 0; }
.ch-card { display: flex; flex-direction: column; gap: 10px; }
.ch-card .head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ch-card .head strong { font-size: 17px; overflow-wrap: anywhere; }
.ch-card .meta { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.ch-card .meta a { color: #b9a8ff; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
