/* ---------- Tokens ---------- */
:root {
  --bg: #0b0d12;
  --bg-soft: #11141b;
  --surface: #151924;
  --surface-2: #1b202d;
  --line: #262c3b;
  --line-soft: #1e2431;
  --text: #eef1f7;
  --text-dim: #9aa4b8;
  --text-faint: #6b7488;
  --accent: #7c5cff;
  --accent-2: #ff4ecd;
  --accent-soft: rgba(124, 92, 255, .14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #fbbf24;
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .13);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, .75);
  --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --line: #e2e6ef;
  --line-soft: #eaedf4;
  --text: #131722;
  --text-dim: #5c6579;
  --text-faint: #8b93a7;
  --accent: #6a41f5;
  --accent-2: #e0339f;
  --accent-soft: rgba(106, 65, 245, .1);
  --ok: #0f9d68;
  --ok-soft: rgba(15, 157, 104, .12);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, .1);
  --shadow: 0 14px 40px -22px rgba(20, 24, 40, .4);
}

* { box-sizing: border-box; }

/* El atributo hidden lo aplica la hoja del navegador y cualquier `display` de autor
   lo pisa (.pane, .switch...). Lo forzamos para que ocultar sea siempre ocultar. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Resplandor de fondo, puramente decorativo */
body::before {
  content: "";
  position: fixed;
  inset: -30vh -10vw auto;
  height: 70vh;
  background:
    radial-gradient(45vw 40vh at 25% 40%, rgba(124, 92, 255, .22), transparent 70%),
    radial-gradient(40vw 35vh at 75% 20%, rgba(255, 78, 205, .16), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
  z-index: 0;
}
[data-theme="light"] body::before { opacity: .5; }

.sprite { display: none; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main {
  position: relative;
  z-index: 1;
  width: min(880px, 100% - 32px);
  margin: 0 auto;
  padding-bottom: 56px;
  flex: 1;
}

/* ---------- Barra superior ---------- */
.topbar {
  position: relative;
  z-index: 2;
  width: min(880px, 100% - 32px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 0 8px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  font-size: 17px;
  box-shadow: 0 6px 20px -6px var(--accent);
}
.brand-text { font-weight: 650; letter-spacing: -.02em; font-size: 16px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 550;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  background: var(--surface);
}
.pill svg { font-size: 13px; }
.pill-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: var(--ok-soft); }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  transition: .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn.subtle { border-color: transparent; background: transparent; }
.ico-light { display: none; }
[data-theme="light"] .ico-light { display: block; }
[data-theme="light"] .ico-dark { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 48px 0 28px; text-align: center; }

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 6vw, 46px);
  line-height: 1.1;
  letter-spacing: -.035em;
  font-weight: 700;
}
.hero h1 em {
  font-style: normal;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sub {
  margin: 0 auto 28px;
  max-width: 500px;
  color: var(--text-dim);
  font-size: 16px;
}

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 7px 7px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft);
}
.searchbar-ico { font-size: 17px; color: var(--text-faint); flex: none; }
.searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  padding: 9px 2px;
}
.searchbar input::placeholder { color: var(--text-faint); }

.primary-btn {
  border: 0;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 11px 22px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform .12s, filter .15s, opacity .15s;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:active { transform: scale(.975); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.primary-btn.big { padding: 13px 28px; font-size: 15.5px; border-radius: 14px; }
.primary-btn.is-loading { pointer-events: none; opacity: .75; }

.ghost-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  padding: 9px 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: .15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.ghost-btn.danger:hover { color: var(--err); border-color: var(--err); background: var(--err-soft); }

.hint { margin-top: 14px; font-size: 13px; color: var(--text-faint); }

.banner {
  margin: 16px auto 0;
  max-width: 620px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: left;
  border: 1px solid var(--err);
  background: var(--err-soft);
  color: var(--err);
}

/* ---------- Tarjetas ---------- */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 18px;
  overflow: hidden;
  animation: rise .28s cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.preview-head { display: flex; gap: 16px; padding: 16px; align-items: flex-start; }

.thumb {
  flex: none;
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 11px;
  background: var(--surface-2) center/cover no-repeat;
  border: 1px solid var(--line-soft);
}

.preview-meta { flex: 1; min-width: 0; }
.preview-meta h2 {
  margin: 2px 0 6px;
  font-size: 17px;
  line-height: 1.32;
  letter-spacing: -.015em;
  font-weight: 620;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta-row { font-size: 13px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.meta-row .dot { color: var(--text-faint); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 560;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  transition: .14s;
}
.chip small { font-size: 11.5px; font-weight: 450; color: var(--text-faint); }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.is-active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.chip.is-active small { color: inherit; opacity: .75; }
.chips-select .chip.tag-best { position: relative; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--line);
}
.badge.hi { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }

/* Pestañas vídeo / audio */
.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line-soft); }
.tab {
  border: 0; background: transparent;
  color: var(--text-dim);
  font: inherit; font-size: 14px; font-weight: 570;
  padding: 11px 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.pane { padding: 16px; display: grid; gap: 16px; }
.field label { display: block; font-size: 12px; font-weight: 620; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: 8px; }
.field .chips { margin-top: 0; }

/* Avanzadas */
.advanced { border-top: 1px solid var(--line-soft); }
.advanced summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 16px;
  font-size: 13.5px;
  font-weight: 570;
  color: var(--text-dim);
  display: flex; align-items: center; gap: 8px;
  user-select: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary:hover { color: var(--text); }
.advanced summary svg { transition: transform .2s; font-size: 15px; }
.advanced[open] summary svg { transform: rotate(180deg); }
.advanced-grid { padding: 0 16px 16px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.switch { display: flex; gap: 11px; align-items: flex-start; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span {
  flex: none;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: .18s;
  margin-top: 2px;
}
.switch > span::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: .18s;
}
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }
.switch strong { display: block; font-size: 13.5px; font-weight: 580; }
.switch small { color: var(--text-faint); font-size: 12.5px; }

.trim label { display: flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 580; margin-bottom: 7px; }
.trim-inputs { display: flex; align-items: center; gap: 8px; color: var(--text-faint); }
.trim-inputs input {
  width: 100%; min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit; font-size: 13.5px;
  padding: 8px 11px;
  outline: 0;
}
.trim-inputs input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.preview-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 16px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-soft);
}
.est { font-size: 13px; color: var(--text-faint); }

/* ---------- Listas (cola e historial) ---------- */
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.list-head h3 { margin: 0; font-size: 14px; font-weight: 620; display: flex; align-items: center; gap: 8px; }
.list-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.count { color: var(--text-faint); font-weight: 450; }

.rows { display: flex; flex-direction: column; }

.row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 14px;
  padding: 13px 16px;
  align-items: center;
  border-bottom: 1px solid var(--line-soft);
  animation: rise .22s ease;
}
.row:last-child { border-bottom: 0; }
.row-thumb {
  width: 92px; aspect-ratio: 16/9;
  border-radius: 8px;
  background: var(--surface-2) center/cover no-repeat;
  border: 1px solid var(--line-soft);
}
.row-main { min-width: 0; }
.row-title {
  font-size: 14px; font-weight: 560;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.row-sub { font-size: 12.5px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 3px 9px; align-items: center; }
.row-sub .err { color: var(--err); }
.row-sub .ok { color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }
.row-actions { display: flex; gap: 6px; align-items: center; }

.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 7px 0 6px;
}
.bar > i {
  display: block; height: 100%;
  border-radius: 999px;
  background: var(--grad);
  transition: width .3s cubic-bezier(.3, .8, .3, 1);
}
.bar.indeterminate > i {
  width: 35% !important;
  animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.row.is-done .bar > i { background: var(--ok); }
.row.is-error .bar > i { background: var(--err); }

.mini-btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  cursor: pointer; font-size: 14px;
  transition: .14s;
}
.mini-btn:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.mini-btn.save { width: auto; padding: 0 13px; gap: 7px; display: inline-flex; align-items: center; font: inherit; font-size: 13px; font-weight: 570; color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.mini-btn.save:hover { filter: brightness(1.12); border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.mini-btn.danger:hover { color: var(--err); border-color: var(--err); background: var(--err-soft); }

/* ---------- Por qué ---------- */
.why {
  margin-top: 34px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.why-item {
  padding: 15px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.why-item strong { display: block; font-size: 13.5px; margin-bottom: 4px; }
.why-item span { font-size: 12.5px; color: var(--text-dim); }

/* ---------- Pie ---------- */
footer {
  position: relative; z-index: 1;
  width: min(880px, 100% - 32px);
  margin: 0 auto;
  padding: 22px 0 30px;
  border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px;
}
.muted { color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 30px 70px -25px rgba(0, 0, 0, .8);
}
.modal::backdrop { background: rgba(5, 7, 12, .6); backdrop-filter: blur(3px); }
.modal-inner { display: flex; flex-direction: column; }
.modal header, .modal footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px;
}
.modal header { border-bottom: 1px solid var(--line-soft); }
.modal header h3 { margin: 0; font-size: 15px; }
.modal footer { border-top: 1px solid var(--line-soft); justify-content: flex-end; border-bottom: 0; }
.modal-body { padding: 16px; display: grid; gap: 14px; }
.field-block { display: grid; gap: 6px; }
.field-block > span { font-size: 13px; font-weight: 580; }
.field-block small { color: var(--text-faint); font-size: 12px; }
.field-block input, .field-block select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit; font-size: 13.5px;
  padding: 9px 11px;
  outline: 0;
  width: 100%;
}
.field-block input:focus, .field-block select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Avisos ---------- */
.toasts {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: var(--shadow);
  animation: pop .25s cubic-bezier(.2, .9, .3, 1);
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.toast.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }

.spin { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .hero { padding: 32px 0 20px; }
  .pill { display: none; }
  .searchbar { flex-wrap: wrap; border-radius: var(--radius); padding: 10px; gap: 8px; }
  .searchbar-ico { display: none; }
  .searchbar input { flex: 1 1 100%; padding: 6px 6px 2px; }
  .searchbar .ghost-btn, .searchbar .primary-btn { flex: 1; justify-content: center; }
  .preview-head { flex-wrap: wrap; }
  .thumb { width: 100%; }
  .row { grid-template-columns: 1fr; gap: 10px; }
  .row-thumb { width: 100%; max-width: 160px; }
  .row-actions { justify-content: flex-end; }
  .preview-actions { flex-direction: column; align-items: stretch; }
  .preview-actions .primary-btn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
