/* ── Variables ── */
:root {
  --bg: #0a0a0f;
  --card-bg: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e8e8ed;
  --text-dim: #888;
  --accent: linear-gradient(135deg, #8b5cf6, #ec4899, #f97316);
  --accent-solid: #a855f7;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: .15;
  z-index: -1;
  pointer-events: none;
}
body::before { width: 500px; height: 500px; background: #8b5cf6; top: -100px; left: -100px; }
body::after  { width: 400px; height: 400px; background: #ec4899; bottom: -80px; right: -80px; }

.container { width: 100%; max-width: 540px; padding: 24px 16px; }

header { text-align: center; margin-bottom: 32px; }

h1 {
  font-size: 2.6rem;
  font-weight: 800;
  background: var(--accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
h1 .accent {
  background: var(--accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline { color: var(--text-dim); margin-top: 6px; font-size: .95rem; }

/* ── Card ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Steps ── */
.steps { display: flex; flex-direction: column; gap: 8px; }

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .82rem;
  color: var(--text-dim);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: var(--accent-solid);
  flex-shrink: 0;
}

/* ── Input row ── */
.input-row { display: flex; gap: 8px; }

#url-input {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  min-width: 0; /* prevent flex overflow */
}
#url-input::placeholder { color: var(--text-dim); }
#url-input:focus {
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, .15);
}

.icon-btn {
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  transition: background .2s, color .2s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.hidden { display: none; }

/* ── Hint ── */
.hint {
  font-size: .8rem;
  text-align: center;
  animation: slideIn .2s ease;
  color: var(--error);
}
.hint.hidden { display: none; }

/* ── Download button ── */
#download-btn {
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .15s;
  position: relative;
  overflow: hidden;
}
#download-btn:hover:not(:disabled) { transform: scale(1.02); }
#download-btn:active:not(:disabled) { transform: scale(.98); }
#download-btn:disabled { opacity: .35; cursor: not-allowed; }

#download-btn .btn-loading { display: none; align-items: center; justify-content: center; gap: 8px; }
#download-btn .btn-cooldown { display: none; }

#download-btn.loading .btn-text { display: none; }
#download-btn.loading .btn-loading { display: flex; }
#download-btn.loading { pointer-events: none; }

#download-btn.cooldown .btn-text { display: none; }
#download-btn.cooldown .btn-loading { display: none; }
#download-btn.cooldown .btn-cooldown { display: inline; }

.elapsed {
  font-size: .85rem;
  opacity: .7;
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Result ── */
.result {
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.5;
  animation: slideIn .25s ease;
  overflow: hidden;
}
.result.hidden { display: none; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result.error {
  padding: 14px 16px;
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .25);
  color: var(--error);
}

/* ── Video preview ── */
.preview {
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
}

.preview video {
  width: 100%;
  max-height: 400px;
  display: block;
  background: #000;
  object-fit: contain;
}

.preview-note {
  padding: 16px;
  text-align: center;
  font-size: .85rem;
  color: var(--text-dim);
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
}

.preview-info {
  font-size: .82rem;
  color: var(--text-dim);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

.save-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform .15s;
  flex-shrink: 0;
  text-decoration: none;
}
.save-btn:hover { transform: scale(1.1); }
.save-btn:active { transform: scale(.95); }
.save-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* ── Footer ── */
footer { text-align: center; margin-top: 20px; color: var(--text-dim); font-size: .8rem; }

/* ── SEO text ── */
.seo-text {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  h1 { font-size: 2rem; }
  .card { padding: 20px 14px; }
  .preview video { max-height: 280px; }
  #url-input { font-size: .9rem; padding: 12px 14px; }
}
