:root {
  --bg: #0b0b0f;
  --bg-card: #15151d;
  --bg-input: #1d1d28;
  --border: #26263a;
  --text: #eef0f5;
  --muted: #9aa0b4;
  --accent: #ff2d6b;
  --accent-2: #25f4ee;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(255, 45, 107, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 10% 0%, rgba(37, 244, 238, 0.12), transparent 55%), var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.container {
  width: 100%;
  max-width: 760px;
  padding: 48px 20px 32px;
}

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

.logo {
  font-size: 44px;
  line-height: 1;
}

h1 {
  font-size: 34px;
  margin: 8px 0 6px;
  letter-spacing: -0.5px;
}

h1 span {
  background: linear-gradient(90deg, var(--accent), #a94dff, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.input-row {
  display: flex;
  gap: 10px;
}

#url {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#url:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 45, 107, 0.18);
}

#url::placeholder {
  color: var(--muted);
}

#submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 130px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #d61f5f);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, filter 0.2s;
}

#submit:hover {
  filter: brightness(1.1);
}

#submit:active {
  transform: scale(0.97);
}

#submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.error {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 45, 107, 0.12);
  border: 1px solid rgba(255, 45, 107, 0.4);
  color: #ff8fb0;
  font-size: 14px;
}

.result {
  margin-top: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  z-index: 0;
  isolation: isolate;
}

.video-wrap {
  position: relative;
  z-index: 1;
  background: #000;
  border-bottom: 1px solid var(--border);
}

.video-wrap video,
.video-wrap .cover {
  width: 100%;
  display: block;
  max-height: 480px;
  object-fit: contain;
  margin: 0 auto;
}

.cover {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.cover.active {
  opacity: 1;
}

video[hidden] {
  display: none;
}

.preview-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  background: rgba(0, 0, 0, 0.55);
}

.preview-loader .spinner {
  width: 34px;
  height: 34px;
  border-width: 3px;
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
}

.info {
  padding: 20px;
  position: relative;
  z-index: 3;
}

.title {
  font-size: 18px;
  line-height: 1.4;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.author {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--bg-input);
}

.author-name {
  font-weight: 600;
  font-size: 15px;
}

.author-handle {
  color: var(--muted);
  font-size: 13px;
}

.music {
  color: var(--accent-2);
  font-size: 14px;
  margin-bottom: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.stat {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}

.stat strong {
  display: block;
  font-size: 16px;
}

.stat span {
  font-size: 11px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
}

.btn-download,
.btn-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, filter 0.2s;
}

.btn-download {
  flex: 1;
  text-decoration: none;
  color: #0b0b0f;
  background: linear-gradient(135deg, var(--accent-2), #7ef6f2);
  border: none;
}

.btn-download:hover {
  filter: brightness(1.06);
}

.btn-download:active {
  transform: scale(0.98);
}

.btn-download:disabled {
  opacity: 0.7;
  cursor: wait;
}

.btn-copy {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}

.btn-copy:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.btn-copy:active {
  transform: scale(0.98);
}

.fineprint {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.footer {
  margin-top: 36px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 560px) {
  .input-row {
    flex-direction: column;
  }

  #submit {
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .actions {
    flex-direction: column;
  }
}
