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

:root {
  --red-400: #f87171;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --purple-400: #a78bfa;
  --purple-500: #a855f7;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0a0a0a;
  color: #fff;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(-45deg, #0f0f23, #1a0a2e, #16213e, #0a1628);
  background-size: 400% 400%;
  animation: gradient-shift 15s ease infinite;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Header */
header {
  width: 100%;
  padding: 1.5rem;
}

.header-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  object-fit: contain;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.accent {
  color: var(--red-400);
}

.header-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--zinc-500);
  font-size: 0.875rem;
}

/* Main */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem 5rem;
  min-height: calc(100vh - 5rem);
}

.hero {
  max-width: 42rem;
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  line-height: 1.15;
}

@media (min-width: 768px) {
  .hero h1 {
    font-size: 3rem;
  }
}

.gradient-text {
  background: linear-gradient(90deg, var(--red-400), var(--purple-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--zinc-400);
  font-size: 1.125rem;
}

/* Format Toggle */
.format-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.format-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--zinc-400);
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.format-btn:hover {
  color: #e4e4e7;
}

.format-btn.active[data-format="mp4"],
.format-btn.active:not([data-format]) {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red-400);
  border-color: rgba(239, 68, 68, 0.3);
}

.format-btn.active[data-format="mp3"] {
  background: rgba(168, 85, 247, 0.12);
  color: var(--purple-400);
  border-color: rgba(168, 85, 247, 0.3);
}

/* Input */
.input-wrapper {
  width: 100%;
  max-width: 42rem;
  margin-bottom: 1.5rem;
}

.input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  color: var(--zinc-500);
  display: flex;
}

#url-input {
  width: 100%;
  padding: 1rem 8.5rem 1rem 3rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

#url-input::placeholder {
  color: var(--zinc-500);
}

#url-input:focus {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3), 0 0 20px rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
}

.fetch-btn {
  position: absolute;
  right: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.5rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--red-500), var(--red-600));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.fetch-btn:hover {
  background: linear-gradient(135deg, var(--red-400), var(--red-500));
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

.fetch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Error */
.error-msg {
  width: 100%;
  max-width: 42rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--red-400);
  font-size: 0.875rem;
}

/* Video Card */
.video-card {
  width: 100%;
  max-width: 42rem;
  border-radius: 1rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.video-card-inner {
  display: flex;
  flex-direction: column;
}

@media (min-width: 640px) {
  .video-card-inner {
    flex-direction: row;
  }
}

.thumbnail-wrap {
  flex-shrink: 0;
  position: relative;
}

@media (min-width: 640px) {
  .thumbnail-wrap {
    width: 18rem;
  }
}

.thumbnail-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  min-height: 10rem;
  display: block;
}

.duration-badge {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.video-details {
  flex: 1;
  padding: 1.25rem;
}

.video-details h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-author {
  color: var(--zinc-400);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.quality-section {
  margin-bottom: 1rem;
}

.quality-label {
  font-size: 0.7rem;
  color: var(--zinc-500);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.quality-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quality-btn {
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--zinc-400);
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.quality-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: #e4e4e7;
  transform: translateY(-1px);
}

.quality-btn.selected {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.08);
  color: var(--red-400);
}

/* Download Button */
.download-btn {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--red-500), var(--red-600));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  font-family: inherit;
}

.download-btn:hover {
  background: linear-gradient(135deg, var(--red-400), var(--red-500));
  transform: translateY(-1px);
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hint {
  color: var(--zinc-600);
  font-size: 0.75rem;
  text-align: center;
  max-width: 28rem;
  margin-top: 2rem;
}

/* Ad Containers */
.ad-container {
  width: 100%;
  max-width: 64rem;
  margin: 1rem auto;
  padding: 0 1.5rem;
  text-align: center;
  min-height: 50px;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--zinc-600);
  font-size: 0.8rem;
}

/* Spinner */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spinner {
  animation: spin 1.5s linear infinite;
  display: inline-block;
}
