/* ─────────────────────────────────────────────────────────
   YTGRAB — Dark Industrial Design System
   ───────────────────────────────────────────────────────── */

:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface2: #191919;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.18);
  --red: #ff3333;
  --red-dim: rgba(255,51,51,0.15);
  --red-glow: rgba(255,51,51,0.35);
  --white: #f0f0f0;
  --gray: #888;
  --gray-dim: #555;
  --font-mono: 'Space Mono', monospace;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius: 4px;
  --radius-lg: 8px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* ── BACKGROUND ──────────────────────────────────────────── */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(255,51,51,0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.header, .main, .footer { position: relative; z-index: 1; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--red);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  box-shadow: 0 0 20px var(--red-glow);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 4px;
  color: var(--white);
}

.header-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.main {
  max-width: 860px;
  margin: 0 auto;
  padding: 60px 24px 40px;
}

/* ── HERO ────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(56px, 10vw, 96px);
  line-height: 0.92;
  letter-spacing: 2px;
  color: var(--white);
  margin-bottom: 16px;
}

.hero-title em {
  font-style: normal;
  color: var(--red);
  text-shadow: 0 0 40px var(--red-glow);
}

.hero-sub {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gray);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  transition: border-color var(--transition);
}

.card:hover { border-color: var(--border-hover); }

/* ── INPUT CARD ──────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim);
}

.input-icon { font-size: 16px; flex-shrink: 0; }

.url-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 14px 0;
  min-width: 0;
}

.url-input::placeholder { color: var(--gray-dim); }

.clear-btn {
  background: none;
  border: none;
  color: var(--gray);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 2px;
  transition: color var(--transition);
  flex-shrink: 0;
}

.clear-btn:hover { color: var(--red); }

.fetch-btn {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 28px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 20px var(--red-dim);
  flex-shrink: 0;
}

.fetch-btn:hover {
  background: #e62e2e;
  box-shadow: 0 4px 28px var(--red-glow);
  transform: translateY(-1px);
}

.fetch-btn:active { transform: translateY(0); }
.fetch-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(255,51,51,0.08);
  border: 1px solid rgba(255,51,51,0.3);
  border-radius: var(--radius);
  color: #ff6666;
  font-size: 14px;
}

.error-icon { font-size: 16px; }

/* ── VIDEO INFO CARD ─────────────────────────────────────── */
.video-meta {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.thumbnail-wrap {
  position: relative;
  flex-shrink: 0;
  width: 180px;
}

.thumbnail {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

.duration-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 2px;
}

.video-details { flex: 1; min-width: 0; }

.video-title {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.4;
  margin-bottom: 12px;
  color: var(--white);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 4px 8px;
  white-space: nowrap;
}

/* ── TABS ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--gray);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 16px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}

.tab:hover { color: var(--white); }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

/* ── FORMAT GRID ─────────────────────────────────────────── */
.format-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.format-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition), transform var(--transition);
}

.format-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.format-quality {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--white);
  letter-spacing: 1px;
  line-height: 1;
}

.format-info {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.format-info span { display: flex; align-items: center; gap: 4px; }

.format-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255,51,51,0.25);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.download-btn {
  margin-top: auto;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.download-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* ── PROGRESS CARD ───────────────────────────────────────── */
.progress-card {
  border-color: rgba(255,51,51,0.3);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gray);
  letter-spacing: 1px;
}

.progress-pct {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--red);
}

.progress-track {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: var(--red);
  width: 0%;
  border-radius: 2px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px var(--red-glow);
}

.progress-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-dim);
}

/* ── HOW IT WORKS ────────────────────────────────────────── */
.how-section {
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.section-title {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 3px;
  color: var(--gray);
  margin-bottom: 28px;
  text-transform: uppercase;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.step {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.step-num {
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--red-dim);
  line-height: 1;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--red), transparent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.step-text {
  font-size: 14px;
  color: var(--gray);
  line-height: 1.6;
}

.step-text strong { color: var(--white); }

/* ── FOOTER ──────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 32px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray-dim);
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}

.footer-dot {
  margin: 0 8px;
  color: var(--red);
}

/* ── UTILITY ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── ANIMATIONS ──────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.info-card { animation: fadeSlideUp 0.4s ease forwards; }
.format-card {
  animation: fadeSlideUp 0.3s ease forwards;
}
.format-card:nth-child(1) { animation-delay: 0.05s; }
.format-card:nth-child(2) { animation-delay: 0.10s; }
.format-card:nth-child(3) { animation-delay: 0.15s; }
.format-card:nth-child(4) { animation-delay: 0.20s; }
.format-card:nth-child(5) { animation-delay: 0.25s; }

/* ── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--gray-dim); border-radius: 3px; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .header { padding: 16px 20px; }
  .header-tag { display: none; }
  .main { padding: 40px 16px 32px; }

  .input-row { flex-direction: column; gap: 10px; }
  .fetch-btn { width: 100%; justify-content: center; padding: 14px; }

  .video-meta { flex-direction: column; }
  .thumbnail-wrap { width: 100%; }
  .thumbnail { width: 100%; }

  .steps { grid-template-columns: 1fr; gap: 12px; }
  .hero-title { font-size: clamp(48px, 14vw, 72px); }
  .format-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .format-grid { grid-template-columns: 1fr; }
}


/* ── FORMAT CARD v2 ──────────────────────────────────────── */
.fcard-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.fcard-quality {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--white);
  line-height: 1;
}

.quality-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 3px 7px;
  border-radius: 2px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-4k  { background: #7c3aed22; color: #a78bfa; border: 1px solid #7c3aed55; }
.badge-2k  { background: #0ea5e922; color: #38bdf8; border: 1px solid #0ea5e955; }
.badge-hd  { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,51,51,0.35); }
.badge-sd  { background: rgba(255,255,255,0.05); color: var(--gray); border: 1px solid var(--border); }
.badge-audio { background: #10b98122; color: #34d399; border: 1px solid #10b98155; }

.fcard-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gray);
  margin-bottom: 12px;
}

.fcard-meta span { display: flex; align-items: center; gap: 5px; }

.merge-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 2px;
  background: rgba(251,191,36,0.1);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.3);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.no-formats {
  color: var(--gray);
  font-size: 14px;
  padding: 16px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}