:root {
  --bg: #07080c;
  --bg-2: #0c0e15;
  --surface: rgba(22, 25, 36, 0.72);
  --surface-2: rgba(30, 34, 48, 0.8);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --fg: #f2f4f8;
  --muted: #9aa3b5;
  --faint: #636b7e;
  --accent: #ff3d57;
  --accent-2: #ff8a3d;
  --violet: #8b5cf6;
  --blue: #3b82f6;
  --green: #22c55e;
  --danger: #ff6b6b;
  --grad: linear-gradient(100deg, var(--accent) 0%, var(--accent-2) 100%);
  --radius: 18px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: radial-gradient(1200px 600px at 50% -10%, #1a1030 0%, transparent 60%), var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font: inherit; }
[hidden] { display: none !important; }

/* ---------- Animated background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; animation: float 18s ease-in-out infinite; }
.b1 { width: 520px; height: 520px; background: var(--accent); top: -180px; left: -160px; }
.b2 { width: 460px; height: 460px; background: var(--violet); top: 10%; right: -180px; animation-delay: -6s; opacity: .28; }
.b3 { width: 380px; height: 380px; background: var(--accent-2); bottom: -200px; left: 30%; animation-delay: -12s; opacity: .18; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
}
.bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 70%);
}

/* ---------- Header ---------- */
.top {
  max-width: 960px; margin: 0 auto; padding: 22px 20px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-name span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--grad); color: #fff; box-shadow: 0 8px 24px -6px rgba(255, 61, 87, .6);
}
.logo svg { width: 20px; height: 20px; }
.pill-badge {
  font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.03);
}

main { max-width: 960px; margin: 0 auto; padding: 0 20px 64px; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 56px 0 18px; }
.hero h1 {
  margin: 0; font-size: clamp(28px, 5vw, 46px); line-height: 1.12; font-weight: 800; letter-spacing: -.035em;
}
.grad { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--muted); margin: 14px 0 0; font-size: 16px; }

.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  max-width: 720px; margin: 34px auto 0; padding: 8px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow), 0 0 0 0 rgba(255, 61, 87, 0);
  transition: border-color .2s, box-shadow .25s;
}
.search:focus-within { border-color: rgba(255, 61, 87, .6); box-shadow: var(--shadow), 0 0 0 5px rgba(255, 61, 87, .14); }
.search-ico { width: 20px; height: 20px; color: var(--faint); margin-left: 12px; flex: none; }
.search input {
  flex: 1; min-width: 0; height: 46px; border: 0; outline: 0; background: transparent;
  color: var(--fg); font: inherit; font-size: 15px; padding: 0 4px;
}
.search input::placeholder { color: var(--faint); }

button { cursor: pointer; border: 0; transition: transform .12s ease, background .2s, border-color .2s, opacity .2s, box-shadow .2s; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary {
  display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 22px; border-radius: 999px;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 14.5px;
  box-shadow: 0 10px 26px -10px rgba(255, 61, 87, .8);
}
.primary:hover:not(:disabled) { box-shadow: 0 14px 30px -8px rgba(255, 61, 87, .9); }
.primary svg { width: 18px; height: 18px; }
.primary.loading .btn-label::after { content: "…"; }
.primary.loading svg { animation: spin 1s linear infinite; }
.ghost {
  height: 38px; padding: 0 14px; border-radius: 999px; background: rgba(255,255,255,.05);
  border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px;
}
.ghost:hover:not(:disabled) { color: var(--fg); border-color: var(--border-strong); background: rgba(255,255,255,.08); }
.ghost.small { height: 32px; font-size: 12.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

.status { min-height: 24px; margin: 14px auto 0; max-width: 720px; font-size: 14px; color: var(--muted); }
.status .err {
  display: inline-flex; align-items: flex-start; gap: 8px; text-align: left;
  padding: 10px 14px; border-radius: 12px; color: #ffd1d1;
  background: rgba(255, 107, 107, .1); border: 1px solid rgba(255, 107, 107, .3);
  word-break: break-word;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
#info, #skeleton { animation: rise .45s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.video { display: flex; gap: 20px; padding: 16px; margin-top: 18px; }
.thumb-wrap { position: relative; flex: none; width: 300px; max-width: 42%; }
.thumb-wrap img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; background: #000; }
.duration {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0,0,0,.78); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.meta { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.meta h2 { margin: 0 0 12px; font-size: 20px; line-height: 1.3; font-weight: 700; letter-spacing: -.015em; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border); color: var(--muted); font-size: 13px;
  max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; flex: none; }

/* Skeleton */
.skeleton { display: flex; gap: 20px; padding: 16px; margin-top: 18px; }
.sk-thumb { width: 300px; max-width: 42%; aspect-ratio: 16/9; border-radius: 12px; }
.sk-lines { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.sk-line { height: 14px; border-radius: 7px; }
.w80 { width: 80%; height: 20px; } .w60 { width: 60%; } .w40 { width: 40%; }
.shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,.05) 25%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Job / progress ---------- */
.job { margin-top: 16px; padding: 18px 20px 16px; border-color: rgba(255, 61, 87, .35); animation: rise .35s cubic-bezier(.2,.8,.2,1); }
.job-head { display: flex; align-items: center; gap: 14px; }
.job-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: rgba(255, 61, 87, .14); color: var(--accent);
}
.job-icon svg { width: 22px; height: 22px; }
.job-icon .spin { animation: spin 1.1s linear infinite; }
.job.is-done .job-icon { background: rgba(34, 197, 94, .14); color: var(--green); }
.job.is-error .job-icon { background: rgba(255, 107, 107, .14); color: var(--danger); }
.job-text { flex: 1; min-width: 0; }
.job-title { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-sub { color: var(--muted); font-size: 13px; margin-top: 2px; word-break: break-word; }
.job-pct { font-weight: 800; font-size: 22px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.job.is-done .job-pct { color: var(--green); }

.progress {
  position: relative; height: 12px; margin: 16px 0 12px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,.07); box-shadow: inset 0 1px 2px rgba(0,0,0,.4);
}
.progress-fill {
  position: relative; height: 100%; width: 0%; border-radius: inherit; background: var(--grad);
  box-shadow: 0 0 18px rgba(255, 61, 87, .55); transition: width .35s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.progress-fill::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%);
  background-size: 22px 22px; animation: stripes .8s linear infinite;
}
@keyframes stripes { to { background-position: 22px 0; } }
/* Không xác định được % (lấy thông tin / xử lý) */
.progress.indeterminate .progress-fill { width: 35% !important; transition: none; animation: indet 1.25s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-110%); } to { transform: translateX(300%); } }
.job.is-done .progress-fill { background: linear-gradient(90deg, #16a34a, var(--green)); box-shadow: 0 0 18px rgba(34,197,94,.5); }
.job.is-done .progress-fill::after, .job.is-error .progress-fill::after { display: none; }
.job.is-error .progress-fill { background: var(--danger); box-shadow: none; }

.job-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.steps li {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--faint);
  padding: 4px 10px 4px 8px; border-radius: 999px; border: 1px solid var(--border);
}
.steps li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .6; }
.steps li.active { color: #ffd0d6; border-color: rgba(255, 61, 87, .45); background: rgba(255, 61, 87, .1); }
.steps li.active::before { background: var(--accent); opacity: 1; box-shadow: 0 0 0 0 rgba(255,61,87,.6); animation: pulse 1.4s infinite; }
.steps li.done { color: #a7f3c0; border-color: rgba(34, 197, 94, .3); }
.steps li.done::before { background: var(--green); opacity: 1; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(255,61,87,0); } 100% { box-shadow: 0 0 0 0 rgba(255,61,87,0); } }
.job-stats { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.job-actions { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ---------- Format options ---------- */
.section-head { display: flex; align-items: center; gap: 12px; margin: 30px 0 12px; }
.section-head h3 { margin: 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.section-head::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border-strong), transparent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--fg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.opt:hover:not(:disabled) { border-color: rgba(255, 61, 87, .5); background: var(--surface-2); transform: translateY(-2px); box-shadow: 0 12px 28px -14px rgba(255, 61, 87, .6); }
.opt.running { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 61, 87, .18); }
.opt-ico {
  width: 42px; height: 42px; border-radius: 11px; flex: none; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: -.02em;
}
.opt-ico.audio { background: rgba(34, 197, 94, .14); color: #6ee7a0; font-size: 19px; }
.opt-ico.video { background: rgba(59, 130, 246, .15); color: #8ab8ff; }
.opt-ico.best { background: var(--grad); color: #fff; font-size: 18px; }
.opt-body { display: flex; flex-direction: column; min-width: 0; }
.opt-body b { font-size: 14.5px; font-weight: 700; }
.opt-body small { color: var(--muted); font-size: 12.5px; }
.opt.featured { border-color: rgba(255, 138, 61, .4); background: linear-gradient(135deg, rgba(255,61,87,.12), rgba(255,138,61,.06)), var(--surface); }

/* ---------- All formats ---------- */
.all-formats { margin-top: 30px; padding: 0; overflow: hidden; }
.all-formats summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; font-weight: 600;
}
.all-formats summary::-webkit-details-marker { display: none; }
.all-formats summary:hover { background: rgba(255,255,255,.03); }
.count { color: var(--faint); font-weight: 500; margin-left: 4px; }
.chev { width: 20px; height: 20px; color: var(--muted); transition: transform .25s; }
.all-formats[open] .chev { transform: rotate(180deg); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 20px 14px; }
.filter {
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
}
.filter:hover { color: var(--fg); border-color: var(--border-strong); }
.filter.active { color: #fff; background: rgba(255, 61, 87, .16); border-color: rgba(255, 61, 87, .5); }
.formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; padding: 0 20px 20px; max-height: 520px; overflow-y: auto; }
.fmt {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: rgba(0,0,0,.22); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 13px;
}
.fmt:hover { border-color: var(--border-strong); }
.fmt .left { display: flex; flex-direction: column; min-width: 0; }
.fmt .line1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fmt small { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmt .dl { flex: none; padding: 7px 12px; border-radius: 9px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(255, 61, 87, .85); }
.fmt .dl:hover:not(:disabled) { background: var(--accent); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag.av { background: rgba(59,130,246,.18); color: #8ab8ff; }
.tag.video { background: rgba(139,92,246,.2); color: #c4b0ff; }
.tag.audio { background: rgba(34,197,94,.16); color: #6ee7a0; }
.empty { color: var(--faint); font-size: 13px; padding: 8px 2px; }

footer { text-align: center; color: var(--faint); padding: 10px 20px 36px; }

@media (max-width: 640px) {
  .hero { padding-top: 36px; }
  .search { border-radius: 18px; flex-wrap: wrap; padding: 10px; }
  .search-ico { display: none; }
  .search input { flex-basis: 100%; height: 42px; padding: 0 8px; }
  #paste { flex: 1; }
  .primary { flex: 2; justify-content: center; }
  .video, .skeleton { flex-direction: column; gap: 14px; }
  .thumb-wrap, .sk-thumb { width: 100%; max-width: 100%; }
  .grid { grid-template-columns: 1fr 1fr; }
  .opt { flex-direction: column; align-items: flex-start; gap: 8px; }
  .job-pct { font-size: 18px; }
  .formats { grid-template-columns: 1fr; padding: 0 14px 14px; }
  .filters { padding: 0 14px 12px; }
}

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