:root {
  --bg: #0f0f17;
  --panel: #181826;
  --panel2: #212134;
  --line: #2e2e46;
  --text: #ececf4;
  --muted: #9a9ab5;
  --brand: #7c5cff;
  --brand2: #ff4fa3;
  --ok: #2ecc8f;
  --warn: #f5b041;
  --err: #ff5d6c;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: #b9a8ff; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1.25rem 0 .5rem; }
small { color: var(--muted); display: block; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.muted { color: var(--muted); }
.errtxt { color: var(--err); }
.pos { color: var(--ok); }
.neg { color: var(--err); }

/* ---------- cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: rgba(15, 15, 23, .9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; font-size: .8rem;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
}
.tabs { display: flex; gap: .25rem; flex: 1; }
.tabs a { padding: .45rem .8rem; border-radius: 10px; color: var(--muted); text-decoration: none; display: flex; gap: .4rem; align-items: center; }
.tabs a.on, .tabs a:hover { background: var(--panel2); color: var(--text); }
.right { display: flex; gap: .5rem; align-items: center; margin-left: auto; }
.pill { background: var(--panel2); border: 1px solid var(--line); padding: .3rem .75rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }

/* ---------- layout ---------- */
.view { max-width: 980px; margin: 0 auto; padding: 1.25rem 1rem 6rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 440px; margin: 2rem auto; }
.card.empty { text-align: center; padding: 2.5rem 1rem; }
.hero { font-size: 1.1rem; font-weight: 700; background: linear-gradient(90deg, var(--brand), var(--brand2)); -webkit-background-clip: text; background-clip: text; color: transparent; margin: 0 0 .5rem; }
.links { text-align: center; margin-top: 1rem; line-height: 2; }
.splash { min-height: 100vh; display: grid; place-items: center; }

/* ---------- formularios ---------- */
form { display: flex; flex-direction: column; gap: .9rem; }
form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; margin: 1rem 0; }
form.inline label { flex: 1 1 180px; }
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .92rem; }
label.big { font-size: 1.05rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem; font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .92rem; margin-bottom: .4rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.toggles { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.switch { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--brand); }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: .65rem 1.1rem;
}
button:hover, .btn:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); border: 0; color: #fff; }
.primary.big { padding: .9rem 1.6rem; font-size: 1.05rem; }
.danger { border-color: var(--err); color: var(--err); background: transparent; }
button.link { background: none; border: 0; padding: 0; color: #b9a8ff; text-decoration: underline; font-weight: 600; }
.stack { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }

/* chips de formato/duración */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip, .qcard { position: relative; }
.chip input, .qcard input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .8rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel2); font-weight: 500; cursor: pointer; font-size: .9rem;
}
.chip input:checked + span, .qcard input:checked + span { border-color: var(--brand); background: rgba(124, 92, 255, .18); }
.chip input:focus-visible + span, .qcard input:focus-visible + span { outline: 2px solid var(--brand); }
.ar { display: inline-block; border: 2px solid currentColor; border-radius: 3px; opacity: .8; }
.ar-16x9 { width: 20px; height: 12px; }
.ar-9x16 { width: 11px; height: 18px; }
.ar-4x5 { width: 13px; height: 16px; }
.ar-1x1 { width: 14px; height: 14px; }
.quality { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.qcard span { display: block; padding: .8rem 1rem; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; height: 100%; }
.qcard b { display: block; }

.costbar {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: var(--panel); padding: 1rem 0 .25rem; border-top: 1px solid var(--line); margin-top: .5rem;
}
.free { color: var(--ok); }

/* banners y avisos */
.banner { border-radius: 12px; padding: .8rem 1rem; margin-bottom: 1rem; background: var(--panel2); border: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.banner.warn { border-color: var(--warn); }
.banner.err { border-color: var(--err); }
.banner.gift { border-color: var(--ok); background: rgba(46, 204, 143, .1); }
.gbtn { min-height: 44px; display: flex; justify-content: center; margin-top: .5rem; }
.banner .gbtn { justify-content: flex-start; }
.banner.gift p { margin: 0; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1rem 0 .25rem; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.badge-gift { background: rgba(46, 204, 143, .12); border: 1px solid var(--ok); border-radius: 10px; padding: .5rem .8rem; margin-bottom: 1rem; font-weight: 600; font-size: .92rem; }
.toast {
  position: fixed; left: 50%; bottom: calc(5.5rem + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--panel2); border: 1px solid var(--ok); padding: .75rem 1.1rem; border-radius: 12px; max-width: min(92vw, 520px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: pop .2s ease-out;
}
.toast.err { border-color: var(--err); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- vídeos ---------- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.vcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none; display: flex; flex-direction: column; }
.vcard:hover { border-color: var(--brand); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.thumb .ph { display: grid; place-items: center; height: 100%; font-size: 2rem; }
.thumb .bar { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 0; }
.vmeta { padding: .75rem; display: flex; flex-direction: column; gap: .25rem; }
.st { display: inline-block; width: fit-content; font-size: .8rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--panel2); }
.st-done { color: var(--ok); }
.st-failed { color: var(--err); }
.st-queued, .st-scripting, .st-generating, .st-assembling { color: var(--warn); }
.bar { height: 6px; background: var(--panel2); border-radius: 99px; overflow: hidden; }
.bar.big { height: 10px; margin: 1rem 0; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); transition: width .6s; }
.player { width: 100%; max-height: 70vh; background: #000; border-radius: 12px; margin-top: 1rem; }
.player.vertical { max-width: 380px; display: block; margin-inline: auto; }
.chars { padding-left: 1.1rem; color: var(--muted); }

/* ---------- créditos ---------- */
.balance { font-size: 1.15rem; }
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin: 1rem 0; }
.pack { background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.pc { font-size: 1.3rem; font-weight: 800; }
.pp { font-size: 1.1rem; }
.pack { position: relative; }
.pack.popular { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.pack .tag { position: absolute; top: -10px; right: 12px; font-size: .72rem; font-weight: 700; padding: .15rem .55rem;
  border-radius: 999px; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.pname { font-weight: 800; font-size: 1.05rem; }
.bonus { color: var(--ok); font-weight: 700; font-size: .9rem; }
small.inl { display: inline; margin-left: .25rem; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.banned td { opacity: .55; }

/* ---------- admin ---------- */
.subtabs { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1rem; }
.subtabs a { padding: .4rem .8rem; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: .9rem; }
.subtabs a.on { color: var(--text); border-color: var(--brand); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; }
.tile { background: var(--panel2); border-radius: 12px; padding: .9rem; }
.tile b { font-size: 1.4rem; }

/* pie con enlaces legales */
footer.site { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; justify-content: center; margin: 2.5rem 0 1rem;
  padding-top: 1rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
footer.site a { color: var(--muted); }
.legalnote { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 1rem; }
.card.consent .switch { align-items: flex-start; font-size: .9rem; }
.card.consent .switch input { flex: 0 0 auto; margin-top: .2rem; }
.card.consent.attention { border-color: var(--warn); box-shadow: 0 0 0 2px var(--warn) inset; }

.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--panel2); border-top-color: var(--brand); animation: spin 1s linear infinite; margin: 1rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- móvil y tablet: barra de pestañas abajo ---------- */
@media (max-width: 760px) {
  /* backdrop-filter haría que la barra "fixed" se pegue a la cabecera en vez de a la pantalla */
  .top { backdrop-filter: none; background: var(--bg); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; justify-content: space-around; gap: 0;
    background: rgba(15, 15, 23, .97); border-top: 1px solid var(--line);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom));
  }
  .tabs a { flex-direction: column; gap: 0; font-size: .7rem; padding: .3rem .4rem; }
  .tabs .ico { font-size: 1.25rem; }
  .grid2, .quality { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .card { padding: 1rem; }
  .costbar { flex-direction: column; align-items: stretch; }
  .costbar .primary { width: 100%; }
  #langSel { width: auto; padding: .35rem .5rem; }
}
