:root {
  --bg: #0b0d14;
  --card: rgba(255, 255, 255, 0.045);
  --card-border: rgba(255, 255, 255, 0.09);
  --text: #eef0f7;
  --muted: #9aa1b5;
  --accent-1: #6366f1;
  --accent-2: #a855f7;
  --grad: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --ok: #34d399;
  --err: #f87171;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-blob {
  position: fixed; border-radius: 50%; filter: blur(110px); opacity: 0.22;
  pointer-events: none; z-index: 0;
}
.blob-1 { width: 480px; height: 480px; background: var(--accent-1); top: -160px; left: -120px; }
.blob-2 { width: 420px; height: 420px; background: var(--accent-2); bottom: -140px; right: -100px; }

.wrap {
  position: relative; z-index: 1;
  max-width: 640px; margin: 0 auto;
  padding: 28px 20px 40px;
  display: flex; flex-direction: column; gap: 22px;
}

header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { width: 46px; height: 46px; border-radius: 13px; }
h1 { font-size: 1.55rem; letter-spacing: -0.02em; }
.tagline { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }

.platforms { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-mini {
  font-size: 0.72rem; color: var(--muted);
  border: 1px solid var(--card-border); border-radius: 999px;
  padding: 4px 11px; background: rgba(255, 255, 255, 0.02);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}
.main-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1; min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--card-border);
  border-radius: 12px; padding: 13px 15px;
  color: var(--text); font-size: 0.95rem; outline: none;
  transition: border-color 0.15s;
}
.input-row input:focus { border-color: var(--accent-1); }

.btn {
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 0.92rem; font-weight: 600; font-family: inherit;
  padding: 12px 18px; color: var(--text);
  transition: transform 0.12s, opacity 0.15s, background 0.15s;
  text-decoration: none; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--grad); box-shadow: 0 4px 22px rgba(124, 93, 250, 0.35); }
.btn.primary:hover { opacity: 0.92; }
.btn.primary:disabled { opacity: 0.5; cursor: default; }
.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.btn.big { width: 100%; padding: 14px; font-size: 1rem; }
.btn.danger:hover { background: rgba(248, 113, 113, 0.15); color: var(--err); }

.hidden { display: none !important; }

/* skeleton */
.skeleton { display: flex; gap: 14px; }
.sk-thumb { width: 150px; height: 90px; border-radius: 10px; flex-shrink: 0; }
.sk-lines { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-top: 6px; }
.sk-line { height: 13px; border-radius: 6px; }
.shimmer {
  background: linear-gradient(100deg, rgba(255,255,255,0.05) 40%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.05) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* resultado */
.result { display: flex; flex-direction: column; gap: 14px; }
.video-info { display: flex; gap: 14px; align-items: flex-start; }
.thumb {
  width: 150px; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: 10px; background: rgba(0, 0, 0, 0.4); flex-shrink: 0;
}
.meta { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.badge {
  align-self: flex-start;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--grad); border-radius: 6px; padding: 3px 8px;
}
.meta h2 {
  font-size: 0.98rem; line-height: 1.35; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sub { color: var(--muted); font-size: 0.82rem; }

.label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }

.qualities { display: flex; flex-wrap: wrap; gap: 8px; }
.q-chip {
  border: 1px solid var(--card-border); border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text); font-family: inherit; font-size: 0.85rem; font-weight: 600;
  padding: 9px 15px; cursor: pointer; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.q-chip .q-size { color: var(--muted); font-weight: 400; font-size: 0.76rem; }
.q-chip:hover { border-color: var(--accent-1); }
.q-chip.active {
  background: var(--grad); border-color: transparent;
  box-shadow: 0 2px 14px rgba(124, 93, 250, 0.4);
}
.q-chip.active .q-size { color: rgba(255, 255, 255, 0.8); }

/* progreso */
.progress-box { display: flex; flex-direction: column; gap: 9px; }
.bar {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.07);
}
.bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: var(--grad); transition: width 0.4s ease;
}
.bar-fill.indeterminate {
  width: 40% !important;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0% { margin-left: -40%; } 100% { margin-left: 100%; }
}
.progress-meta { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); }

/* completado */
.done-box {
  display: flex; align-items: center; gap: 13px;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 12px; padding: 14px;
  flex-wrap: wrap;
}
.done-check {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--ok); color: #06281c; font-weight: 800; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
}
.done-info { flex: 1; min-width: 140px; }
.done-info p:first-child {
  font-size: 0.88rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px;
}

.error-box {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 12px; padding: 13px 15px;
  color: #fca5a5; font-size: 0.87rem; line-height: 1.45;
}

/* historial */
#historySection { display: flex; flex-direction: column; gap: 12px; }
#historySection h3 { font-size: 1rem; }
.history { display: flex; flex-direction: column; gap: 8px; }
.h-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 12px;
}
.h-thumb {
  width: 58px; aspect-ratio: 16/9; object-fit: cover; border-radius: 7px;
  background: rgba(0,0,0,0.4); flex-shrink: 0;
}
.h-info { flex: 1; min-width: 0; }
.h-title {
  font-size: 0.85rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.h-sub { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.h-item .btn { padding: 8px 13px; font-size: 0.8rem; }

footer { text-align: center; color: var(--muted); font-size: 0.74rem; }

/* login */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px; padding: 32px 26px;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  text-align: center;
}
.login-card input {
  width: 100%;
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 13px 15px; color: var(--text);
  font-size: 0.95rem; outline: none;
}
.login-card .btn { width: 100%; }
.error-text { color: var(--err); font-size: 0.84rem; }

/* toasts */
.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100;
  width: min(90vw, 400px);
}
.toast {
  background: #1a1e2c; border: 1px solid var(--card-border);
  border-radius: 12px; padding: 12px 16px;
  font-size: 0.86rem; text-align: center;
  animation: toast-in 0.25s ease;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.toast.err { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }

@media (max-width: 520px) {
  .input-row { flex-wrap: wrap; }
  .input-row input { flex-basis: 100%; }
  .input-row .btn { flex: 1; }
  .video-info { flex-direction: column; }
  .thumb { width: 100%; }
  .done-info p:first-child { max-width: 100%; }
}
