:root {
  --accent: #56e1ff;
  --accent-2: #b06bff;
  --bg: #04040a;
  --glass: rgba(16, 18, 34, 0.55);
  --stroke: rgba(255, 255, 255, 0.12);
  --text: #eaeefb;
  --muted: rgba(234, 238, 251, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* `display:flex` de .row gana al [hidden] del navegador; hay que forzarlo. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#stage { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 8%, transparent 40%, rgba(0,0,0,.55) 100%),
    radial-gradient(60% 40% at 50% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
  transition: background .8s ease;
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  left: 0; right: 0;
  padding: 22px clamp(16px, 3vw, 34px);
  display: flex;
  gap: 18px;
  pointer-events: none;
  z-index: 5;
  transition: opacity .35s ease, transform .35s ease;
}
.hud > * { pointer-events: auto; }
.hud-top { top: 0; align-items: flex-start; justify-content: space-between; }
.hud-bottom { bottom: 0; flex-direction: column; align-items: center; }

body.ui-hidden .hud { opacity: 0; transform: translateY(12px); pointer-events: none; }
body.ui-hidden .hud * { pointer-events: none; }

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: conic-gradient(from 140deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow: 0 0 26px -4px var(--accent);
  animation: spin 9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand h1 {
  margin: 0; font-size: 19px; letter-spacing: .06em; font-weight: 700;
}
.brand p { margin: 2px 0 0; font-size: 11px; letter-spacing: .08em; color: var(--muted); }

/* ---------- Rótulo de directo ---------- */
.corner {
  position: fixed;
  top: 22px;
  right: clamp(16px, 3vw, 34px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.hideable { transition: opacity .35s ease, transform .35s ease; }
body.ui-hidden .hideable { opacity: 0; transform: translateY(-8px); pointer-events: none; }

.live-card {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 15px 9px 9px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 18px 40px -26px #000, inset 0 1px 0 rgba(255,255,255,.07);
}
.live-photo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  background-size: cover;
  background-position: center 22%;
  image-rendering: pixelated; /* la foto se ve en píxeles, como el avatar */
  border: 1px solid rgba(255,255,255,.18);
  flex: none;
}
.live-text { display: flex; flex-direction: column; gap: 3px; }
.live-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 9.5px; letter-spacing: .2em; font-weight: 700;
  color: #ff6b81;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #ff2e4d;
  box-shadow: 0 0 0 0 rgba(255,46,77,.75);
  animation: live-pulse 1.7s ease-out infinite;
}
@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,46,77,.7); }
  70%  { box-shadow: 0 0 0 9px rgba(255,46,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,46,77,0); }
}
.live-name { font-size: 15px; font-weight: 700; letter-spacing: .01em; line-height: 1.1; }

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* ---------- Grabación ---------- */
.rec-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px;
  border-radius: 99px;
  background: rgba(24, 6, 8, .72);
  border: 1px solid rgba(255, 46, 77, .45);
  backdrop-filter: blur(14px);
  font-size: 12px; font-weight: 700; letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
  color: #ff8ea3;
}
.rec-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ff2e4d;
  animation: rec-blink 1.1s steps(1, end) infinite;
}
@keyframes rec-blink { 50% { opacity: .15; } }

.btn.rec { color: #ff6b81; }
.btn.rec.active {
  background: color-mix(in srgb, #ff2e4d 26%, transparent);
  border-color: rgba(255, 46, 77, .6);
  color: #fff;
}

/* ---------- Subtítulos ---------- */
.captions {
  position: fixed;
  left: 50%;
  bottom: var(--captions-bottom, 120px);
  transform: translateX(-50%) translateY(10px);
  margin: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: min(880px, 88vw);
  padding: 14px 28px;
  border-radius: 14px;
  background: rgba(8, 7, 10, .88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--stroke);
  font-size: clamp(17px, 2.1vw, 25px);
  font-weight: 500;
  line-height: 1.32;
  text-align: center;
  text-wrap: balance;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease, bottom .35s ease;
}
.captions.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.captions.listening { color: var(--muted); font-style: italic; }
.captions-source, .captions-translation { display: block; }
.captions-translation {
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
}
.captions.has-translation .captions-source {
  font-size: 0.62em;
  font-weight: 500;
  color: var(--muted);
  font-style: normal;
}
body.ui-hidden .captions { --captions-bottom: 64px; }

/* ---------- Meter ---------- */
.meter {
  width: 100%;
  min-width: 210px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.meter-label {
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
.meter-track {
  margin: 8px 0 10px;
  height: 5px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,.08);
}
.meter-fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 14px var(--accent);
  transition: width .06s linear;
}
.bands { display: flex; gap: 6px; }
.band {
  flex: 1; text-align: center;
  font-size: 9px; letter-spacing: .12em;
  padding: 4px 0; border-radius: 7px;
  color: rgba(234,238,251,.45);
  background: rgba(255,255,255,.05);
  border: 1px solid transparent;
  transition: color .1s linear, background .1s linear, border-color .1s linear, box-shadow .1s linear;
}

/* ---------- Panel ---------- */
.panel {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 100%; /* sin esto las filas no envuelven y el panel se desborda */
  padding: 6px 16px 12px;
  border-radius: 22px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 24px 60px -30px #000, inset 0 1px 0 rgba(255,255,255,.07);
  transition: padding .28s ease, border-radius .28s ease, gap .28s ease;
}
.panel-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 34px; margin: 0; padding: 0;
  border: 0; background: transparent;
  color: var(--text);
  font: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  cursor: pointer;
  transition: color .18s;
}
.panel-toggle:hover { color: var(--text); }
.panel-toggle svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform .28s ease;
}
.panel-body {
  display: flex; flex-direction: column; gap: 10px;
  overflow: hidden;
  max-height: 280px;
  transition: max-height .3s ease, opacity .22s ease, margin .28s ease;
}
body.panel-collapsed .panel {
  padding: 4px 22px 8px;
  border-radius: 16px;
  gap: 0;
}
body.panel-collapsed .panel-toggle svg { transform: rotate(180deg); }
body.panel-collapsed .panel-body {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}
body.panel-collapsed .hint { display: none; }
.row {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; justify-content: center;
}
.group { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.divider { width: 1px; align-self: stretch; background: var(--stroke); }

/* Selector de modo */
.segmented {
  display: flex; gap: 3px; padding: 3px;
  border-radius: 13px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--stroke);
}
.seg {
  height: 32px; padding: 0 14px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 500; letter-spacing: .04em;
  cursor: pointer; transition: background .18s, color .18s, box-shadow .18s;
}
.seg:hover { color: var(--text); }
.seg[aria-pressed="true"] {
  color: #fff;
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  box-shadow: 0 0 18px -6px var(--accent), inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Progreso del episodio */
.progress-row { width: 100%; gap: 10px; flex-wrap: nowrap; }
.time {
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--muted); min-width: 38px; text-align: center;
}
.track {
  flex: 1; height: 6px; border-radius: 99px; cursor: pointer;
  background: rgba(255,255,255,.1);
  outline: none;
}
.track:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.track-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px -2px var(--accent);
}

/* Carga por URL */
.url-row { position: relative; width: 100%; gap: 8px; flex-wrap: nowrap; }
.url-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; fill: none; stroke: var(--muted);
  stroke-width: 1.7; stroke-linecap: round; pointer-events: none;
}
.url-row input {
  flex: 1; min-width: 0; height: 38px;
  padding: 0 14px 0 34px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.28);
  color: var(--text); font: inherit; font-size: 12.5px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.url-row input::placeholder { color: rgba(234,238,251,.34); }
.url-row input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
.url-row .btn { height: 38px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 15px;
  border-radius: 13px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.04);
  color: var(--text);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .12s, box-shadow .18s, color .18s;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.24); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-icon { width: 40px; padding: 0; justify-content: center; }
.btn-primary, .btn.active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: #fff;
  box-shadow: 0 0 24px -6px var(--accent);
}
.btn.recording {
  background: color-mix(in srgb, #ff4d6d 24%, transparent);
  border-color: rgba(255,77,109,.6);
  box-shadow: 0 0 26px -6px #ff4d6d;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 34px 0 rgba(255,77,109,.35); } }
.btn.danger:hover:not(:disabled) { border-color: rgba(255,77,109,.6); color: #ff8ea3; }

.sliders { gap: 14px; }
.slider { display: flex; flex-direction: column; gap: 5px; width: 104px; }
.slider span { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 99px;
  background: rgba(255,255,255,.14);
  outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  border: 2px solid #0b0c16;
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: 2px solid #0b0c16; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}

.swatches { display: flex; gap: 6px; }
.swatch {
  width: 26px; height: 26px; border-radius: 9px;
  border: 1.5px solid transparent;
  cursor: pointer; padding: 0;
  transition: transform .15s, border-color .15s;
}
.swatch:hover { transform: translateY(-2px) scale(1.06); }
.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 16px -2px currentColor; }

.hint { margin: 12px 0 0; font-size: 11px; color: rgba(234,238,251,.38); letter-spacing: .04em; }
kbd {
  font: inherit; font-size: 10px;
  padding: 1px 5px; border-radius: 5px;
  background: rgba(255,255,255,.08); border: 1px solid var(--stroke);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.94);
  padding: 14px 22px; border-radius: 14px;
  background: rgba(10, 11, 22, .82);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(16px);
  font-size: 13.5px; letter-spacing: .02em;
  opacity: 0; pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 20; max-width: min(420px, 84vw); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- Drop ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(4,4,12,.78);
  backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.drop-overlay.show { opacity: 1; }
.drop-overlay div {
  padding: 40px 56px; border-radius: 22px;
  border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  font-size: 17px; letter-spacing: .06em;
}

@media (max-width: 780px) {
  .meter { display: none; }
  .live-name { font-size: 13px; }
  .live-photo { width: 38px; height: 38px; }
  .sliders { width: 100%; justify-content: space-between; }
  .slider { width: 30%; }
  .divider { display: none; }
  .hint { display: none; }
}
