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

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface-hover: #22222f;
  --border: #2a2a3a;
  --text: #e8e8ed;
  --text-dim: #8888a0;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --success: #2ed573;
  --error: #ff4757;
  --radius: 12px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px;
}

.app {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 0;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 40px;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1rem;
}

/* Platforms */
.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}

.platform-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 50px;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s;
}

.platform-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.platform-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.platform-icon {
  font-size: 1rem;
}

/* Input Section */
.input-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

#urlInput {
  flex: 1;
  padding: 16px 20px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

#urlInput::placeholder {
  color: var(--text-dim);
}

.paste-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.paste-btn:hover {
  opacity: 1;
}

/* Format toggle */
.format-toggle {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: all 0.2s;
}

.format-option:has(input:checked) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--text);
}

.format-option input {
  display: none;
}

/* Quality selector */
.quality-selector {
  display: flex;
  justify-content: center;
}

.quality-selector select {
  padding: 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}

.quality-selector select:focus {
  border-color: var(--accent);
}

.quality-selector select option {
  background: var(--surface);
  color: var(--text);
}

/* Download button */
.download-btn {
  padding: 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.download-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Downloads Section */
.downloads-section {
  margin-top: 40px;
}

.downloads-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.download-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  animation: slideIn 0.3s ease;
}

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

.download-item-content {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.download-thumb {
  width: 100px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border);
}

.download-thumb-placeholder {
  width: 100px;
  height: 56px;
}

.download-item-info {
  flex: 1;
  min-width: 0;
}

.download-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
}

.download-title {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.download-channel {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}

.download-status {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 50px;
}

.status-downloading {
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent);
}

.status-done {
  background: rgba(46, 213, 115, 0.15);
  color: var(--success);
}

.status-error {
  background: rgba(255, 71, 87, 0.15);
  color: var(--error);
}

/* Progress bar */
.progress-bar-bg {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-bar-fill.preparing {
  width: 100% !important;
  background: linear-gradient(90deg, var(--accent) 25%, var(--surface-hover) 50%, var(--accent) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.download-eta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.download-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.save-btn {
  padding: 8px 20px;
  background: var(--success);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s;
}

.save-btn:hover {
  opacity: 0.85;
}

.error-msg {
  font-size: 0.85rem;
  color: var(--error);
  margin-top: 8px;
}

/* SEO Sections */
.seo-section {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.seo-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
  color: var(--text);
}

/* Steps */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
}

.step-number {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  margin: 0 auto 12px;
}

.step h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.step p {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Features grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.feature h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}

.feature p {
  font-size: 0.83rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Platform guides */
.platform-guides {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.platform-guides article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.platform-guides h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.platform-guides p {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* FAQ */
.faq-section details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.faq-section summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-section summary::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--accent);
  font-weight: 700;
}

.faq-section details[open] summary::after {
  content: '-';
}

.faq-section summary::-webkit-details-marker {
  display: none;
}

.faq-section details p {
  padding: 0 20px 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.footer-sub {
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.6;
}

/* =====================
   Google AdSense Units
   ===================== */
.ad-container {
  width: 100%;
  max-width: 728px;
  margin: 0 auto 16px auto;
  padding: 8px 0;
  text-align: center;
  overflow: hidden;
}

.ad-container::before {
  content: 'Advertisement';
  display: block;
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0.4;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.ad-top  { margin-top: 8px; }
.ad-mid  { margin-top: 0; }
.ad-bottom { margin-bottom: 8px; }

/* Responsive */
@media (max-width: 600px) {
  .app {
    padding: 24px 0;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .platforms {
    gap: 6px;
  }

  .platform-btn {
    padding: 7px 12px;
    font-size: 0.8rem;
  }

  #urlInput {
    padding: 14px 16px;
    font-size: 0.95rem;
  }

  .download-btn {
    padding: 14px;
    font-size: 1rem;
  }

  .steps {
    grid-template-columns: 1fr;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .seo-section h2 {
    font-size: 1.2rem;
  }
}
