:root {
  --bg: #08090c;
  --bg-soft: #0d1017;
  --card: #121620;
  --card-2: #0f131b;
  --line: #1e2536;
  --line-soft: #171d2a;
  --accent: #f59e0b;
  --accent-2: #f97316;
  --text: #ffffff;
  --muted: #8e9bae;
  --dim: #64748b;
  --ok: #10b981;
  --bad: #ef4444;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 80% -10%, #151a26 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Barra superior ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 32px);
  background: rgba(8, 9, 12, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.brand-name b {
  color: var(--accent);
}

.brand-tag {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
}

/* ---------- Estructura ---------- */

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(22px, 4vw, 44px) clamp(16px, 4vw, 32px) 88px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

h1 {
  font-size: clamp(26px, 3.6vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.lead {
  margin-top: 8px;
  max-width: 62ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.grid {
  display: grid;
  gap: 18px;
}

@media (min-width: 880px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    align-items: start;
  }
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.4vw, 22px);
}

.card > h2 {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ---------- Formularios ---------- */

.field {
  display: block;
  margin-bottom: 12px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

input[type="url"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  background: #08090c;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

input::placeholder {
  color: var(--dim);
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.form-error {
  margin: 0 0 10px;
  color: #f87171;
  font-size: 12.5px;
  line-height: 1.45;
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 16px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s, background 0.16s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  color: #08090c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.btn-ghost {
  color: var(--text);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: rgba(245, 158, 11, 0.55);
}

.btn-danger {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  border-color: rgba(239, 68, 68, 0.7);
}

.btn-small {
  padding: 8px 11px;
  font-size: 12px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.toolbar {
  margin-top: 14px;
}

/* ---------- Favoritos ---------- */

.slots {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.slot-main {
  min-width: 0;
}

.slot-title {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-host {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.empty {
  padding: 24px 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
}

/* ---------- Estado ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 11px;
  color: var(--muted);
  font-size: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.dot {
  width: 8px;
  height: 8px;
  background: var(--dim);
  border-radius: 50%;
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.dot.bad {
  background: var(--bad);
}

.meta {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.mono {
  margin-top: 4px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11.5px;
}

/* ---------- Avisos ---------- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  animation: toast-in 0.2s ease-out;
}

.toast-error {
  border-left-color: var(--bad);
}

.toast-success {
  border-left-color: var(--ok);
}

.toast.is-out {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s, transform 0.25s;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- Visor ---------- */

.viewer-body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.viewer-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  justify-content: center;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 30px);
}

.stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
}

.stage video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(21, 26, 38, 0.82), rgba(5, 6, 8, 0.96));
  backdrop-filter: blur(2px);
}

.overlay[hidden] {
  display: none;
}

.overlay-title {
  font-size: clamp(17px, 2.4vw, 21px);
  font-weight: 700;
}

.overlay-text {
  max-width: 52ch;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.big-play {
  display: grid;
  width: 76px;
  height: 76px;
  padding: 0;
  color: #08090c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  place-items: center;
  box-shadow: 0 12px 34px rgba(245, 158, 11, 0.35);
}

.play-triangle {
  width: 0;
  height: 0;
  margin-left: 5px;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  border-left: 22px solid #08090c;
}

.stage-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.stage-title {
  font-size: clamp(19px, 2.6vw, 26px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.stage-sub {
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.status-pill {
  padding: 5px 10px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* ---------- Selector del visor ---------- */

.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.picker-btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  color: var(--text);
  font: inherit;
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}

.picker-btn:hover {
  background: #151b28;
  border-color: rgba(245, 158, 11, 0.45);
  transform: translateY(-1px);
}

.picker-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

.picker-host {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

.section-title {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

@media (max-width: 620px) {
  .slot {
    align-items: flex-start;
    flex-direction: column;
  }

  .slot-actions {
    width: 100%;
  }

  .slot-actions .btn {
    flex: 1;
  }
}

/* ---------- Visor: estructura de hub (tabs + lista + reproductor) ---------- */

.hub {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px clamp(14px, 3vw, 28px) 80px;
}

.hub-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.hub-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (min-width: 1000px) {
  .hub {
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    align-items: start;
  }

  .hub-stage {
    position: sticky;
    top: 82px;
  }
}

@media (max-width: 999px) {
  .hub-stage {
    order: -1;
  }
}

.tabs-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tab-btn {
  flex: 1 0 auto;
  padding: 10px 14px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.is-active {
  color: #08090c;
  font-weight: 700;
  background: var(--accent);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.fav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, transform 0.16s;
}

.fav-item:hover {
  background: var(--card-hover, #181e2c);
  border-color: rgba(245, 158, 11, 0.45);
  transform: translateX(2px);
}

.fav-body {
  min-width: 0;
}

.fav-title {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-sub {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-kind {
  flex-shrink: 0;
  padding: 4px 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 999px;
}

.caster-card {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.caster-card .input-field,
.caster-card input {
  margin-bottom: 10px;
}

.hint {
  margin-top: 10px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.5;
}

.player-shell {
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.55);
}

.player-frame {
  position: relative;
  width: 100%;
  background: #050608;
  aspect-ratio: 16 / 9;
}

.player-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: radial-gradient(circle at center, #151a26 0%, #08090c 80%);
}

.player-placeholder svg {
  opacity: 0.4;
}

.meta-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stage-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 4px 10px;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.12);
  border-radius: 6px;
}

.tag-orange {
  color: var(--accent-2);
  background: rgba(249, 115, 22, 0.12);
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

select {
  width: 100%;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  background: #08090c;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
