/* ===== Variables — Light theme (default) ===== */
:root {
  --bg: #f6f6f8;
  --card: rgba(255, 255, 255, 0.78);
  --card-solid: #ffffff;
  --card-hover: #fbfbfc;
  --border: #e4e6ea;
  --border-light: #d4d7dd;
  --accent: #e80000;
  --accent-hover: #cf0000;
  --accent-dim: rgba(232, 0, 0, 0.08);
  --accent-grad: linear-gradient(135deg, #ff3d3d 0%, #e80000 55%, #c40000 100%);
  --success: #06a34f;
  --success-dim: rgba(6, 163, 79, 0.1);
  --warning: #ff9800;
  --purple: #9c27b0;
  --blue: #2196f3;
  --indigo: #5c6bc0;
  --text: #16181d;
  --text-secondary: #5a5f6a;
  --text-muted: #8a909b;
  --input-bg: #ffffff;
  --row-hover: #f6f7f9;
  --thead-bg: rgba(0,0,0,0.025);
  --shimmer-mid: #ececef;
  --logo-grad: linear-gradient(135deg, #16181d 40%, #6b7280);
  --hero-grad: linear-gradient(120deg, #16181d 20%, #3a3f49 55%, #16181d 80%);
  --glass-blur: 14px;
  --aurora-a: rgba(255, 60, 60, 0.16);
  --aurora-b: rgba(64, 120, 255, 0.12);
  --aurora-c: rgba(255, 170, 0, 0.10);
  --shadow: 0 12px 36px rgba(20,24,33,0.10);
  --shadow-sm: 0 2px 10px rgba(20,24,33,0.06);
  --shadow-accent: 0 8px 28px rgba(232,0,0,0.28);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== Dark theme override ===== */
[data-theme="dark"] {
  --bg: #0b0b0e;
  --card: rgba(24, 24, 30, 0.72);
  --card-solid: #18181e;
  --card-hover: #1e1e24;
  --border: rgba(255,255,255,0.09);
  --border-light: rgba(255,255,255,0.16);
  --accent: #ff1f1f;
  --accent-hover: #ff4040;
  --accent-dim: rgba(255, 31, 31, 0.13);
  --accent-grad: linear-gradient(135deg, #ff5a5a 0%, #ff1f1f 55%, #d40000 100%);
  --success: #00c853;
  --success-dim: rgba(0, 200, 83, 0.12);
  --text: #f4f4f6;
  --text-secondary: #a8adb8;
  --text-muted: #6d7380;
  --input-bg: rgba(10, 10, 14, 0.6);
  --row-hover: rgba(255,255,255,0.04);
  --thead-bg: rgba(255,255,255,0.03);
  --shimmer-mid: #2e2e34;
  --logo-grad: linear-gradient(135deg, #fff 40%, #aaa);
  --hero-grad: linear-gradient(120deg, #ffffff 20%, #9aa1ad 55%, #ffffff 80%);
  --aurora-a: rgba(255, 40, 40, 0.17);
  --aurora-b: rgba(70, 110, 255, 0.13);
  --aurora-c: rgba(255, 140, 0, 0.08);
  --shadow: 0 14px 44px rgba(0,0,0,0.5);
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.35);
  --shadow-accent: 0 8px 30px rgba(255,31,31,0.35);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: 40px;
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

/* ===== Ambient aurora backdrop ===== */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.aurora-blob {
  position: absolute;
  width: 60vw;
  height: 60vw;
  max-width: 820px;
  max-height: 820px;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
  animation: auroraDrift 26s ease-in-out infinite alternate;
}
.aurora-a { top: -22%; left: -12%; background: radial-gradient(circle, var(--aurora-a), transparent 65%); }
.aurora-b { top: 8%; right: -18%; background: radial-gradient(circle, var(--aurora-b), transparent 65%); animation-delay: -9s; }
.aurora-c { bottom: -28%; left: 28%; background: radial-gradient(circle, var(--aurora-c), transparent 65%); animation-delay: -17s; }
@keyframes auroraDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vw, 4vh, 0) scale(1.15); }
}

/* ===== Card glass treatment ===== */
.card {
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-sm);
}

/* ===== Focus visibility (keyboard nav) ===== */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: color var(--transition), background var(--transition),
              border-color var(--transition), transform var(--transition);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--border-light); transform: translateY(-1px); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== Layout ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 52px 0 36px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.logo-icon {
  width: 44px;
  height: 31px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(255,0,0,0.4));
}
.logo-text {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: var(--logo-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-title {
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin: 14px 0 10px;
  background: var(--hero-grad);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: heroSheen 7s ease-in-out infinite;
}
.hero-accent {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
@keyframes heroSheen {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}
.tagline {
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 400;
  max-width: 560px;
  margin: 0 auto;
}
.trust-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  list-style: none;
  margin-top: 20px;
}
.trust-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--card);
  border: 1px solid var(--border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-sm);
}
.trust-chip svg { width: 13px; height: 13px; color: var(--accent); }
.trust-chip:nth-child(3) svg, .trust-chip:nth-child(4) svg { color: var(--success); }

/* ===== Input Section ===== */
.input-section {
  padding: 24px;
  margin-bottom: 16px;
}
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 14px;
}
.input-icon {
  position: absolute;
  left: 16px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.url-input {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 13px 88px 13px 46px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.url-input::placeholder { color: var(--text-muted); }
.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.btn-paste, .btn-clear {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}
.btn-paste {
  right: 44px;
}
.btn-paste svg, .btn-clear svg { width: 16px; height: 16px; }
.btn-paste:hover, .btn-clear:hover {
  color: var(--text);
  background: var(--border);
}

/* Fetch Button */
.btn-fetch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 24px;
  border-radius: 50px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  position: relative;
  overflow: hidden;
}
.btn-fetch {
  background: var(--accent-grad);
}
.btn-fetch:hover:not(:disabled) {
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.btn-fetch:active:not(:disabled) { transform: translateY(0); }
.btn-fetch:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-fetch .btn-icon { width: 18px; height: 18px; }

/* Ripple */
.btn-fetch::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
  opacity: 0;
}
.btn-fetch.ripple::after {
  width: 300px;
  height: 300px;
  opacity: 0;
}

/* Spinner */
.btn-spinner { display: flex; align-items: center; justify-content: center; }
.spinner-ring {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* Error Box */
.error-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.3);
  border-radius: var(--radius-sm);
  color: #ff6b6b;
  font-size: 0.88rem;
  padding: 12px 16px;
  margin-top: 12px;
  animation: fadeIn 0.2s ease;
}
.error-box svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== Processing Steps ===== */
.processing-steps {
  padding: 28px 24px 20px;
  text-align: center;
}
.steps-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  max-width: 480px;
  margin: 0 auto;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.step-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--border-light);
  transition: all 0.35s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.step-check { display: none; }
.step-check svg { width: 10px; height: 10px; stroke: #fff; }
.step-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.3s ease;
}

/* Active step */
.step.active .step-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(255, 0, 0, 0.55);
  animation: pulse 1.4s ease-in-out infinite;
}
.step.active .step-label { color: var(--text); }

/* Done step */
.step.done .step-dot {
  background: var(--success);
  border-color: var(--success);
  box-shadow: 0 0 10px rgba(0, 200, 83, 0.4);
  animation: none;
}
.step.done .step-check { display: flex; }
.step.done .step-label { color: var(--success); }

/* Connector line */
.step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin-bottom: 30px;
  max-width: 100px;
  position: relative;
  overflow: hidden;
  border-radius: 2px;
}
.step-connector::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--success);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s ease;
}
.step-connector.filled::after { transform: scaleX(1); }

/* ===== Skeleton Loader ===== */
.skeleton-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  margin-bottom: 16px;
}
.skeleton-thumb {
  width: 160px;
  height: 90px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 0; padding-top: 6px; }
.skeleton-line { border-radius: 6px; }
.shimmer {
  background: linear-gradient(90deg, var(--border) 25%, var(--shimmer-mid) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ===== Video Info Card ===== */
.video-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
  margin-bottom: 24px;
  transition: border-color var(--transition);
}
.video-card:hover { border-color: var(--border-light); }
.video-thumb-wrap {
  flex-shrink: 0;
  width: 160px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--border);
}
.video-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.video-thumb.loaded { opacity: 1; }
.video-meta { flex: 1; min-width: 0; }
.video-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}
.video-channel {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  font-weight: 500;
}
.video-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.stat-badge svg { width: 13px; height: 13px; }

/* ===== Formats Section ===== */
.formats-section { margin-bottom: 28px; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}
.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}
.section-icon svg { width: 16px; height: 16px; }
.format-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 2px;
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-sm);
}
.formats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.formats-table thead tr {
  background: var(--thead-bg);
  border-bottom: 1px solid var(--border);
}
.formats-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.formats-table td {
  padding: 11px 16px;
  color: var(--text);
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.formats-table tbody tr:last-child td { border-bottom: none; }
.formats-table tbody tr {
  transition: background var(--transition);
}
.formats-table tbody tr:hover { background: var(--row-hover); }

/* Resolution Badge */
.res-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.res-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.res-4k   { background: rgba(156,39,176,0.2); color: #ce93d8; border: 1px solid rgba(156,39,176,0.35); }
.res-1440 { background: rgba(63,81,179,0.2);  color: #9fa8da; border: 1px solid rgba(63,81,179,0.35); }
.res-1080 { background: rgba(255,0,0,0.15);   color: #ff6b6b; border: 1px solid rgba(255,0,0,0.3); }
.res-720  { background: rgba(33,150,243,0.15); color: #90caf9; border: 1px solid rgba(33,150,243,0.3); }
.res-480  { background: rgba(255,152,0,0.15);  color: #ffcc80; border: 1px solid rgba(255,152,0,0.3); }
.res-low  { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }

/* BEST Badge */
.best-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-left: 4px;
  vertical-align: middle;
}
.best-video {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(255,0,0,0.25);
}
.best-audio {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(0,200,83,0.25);
}

/* Codec pill */
.codec-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-transform: uppercase;
}

/* Audio indicator tag */
.audio-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.has-audio  { background: rgba(0,200,83,0.12); color: #00c853; border: 1px solid rgba(0,200,83,0.25); }
.no-audio   { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }

/* Size / null */
.null-val { color: var(--text-muted); }

/* Action Buttons */
.action-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}
.btn-dl, .btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-dl {
  background: var(--accent-grad);
  color: #fff;
}
.btn-dl:hover {
  box-shadow: 0 2px 10px rgba(255,0,0,0.3);
  transform: translateY(-1px);
  filter: brightness(1.06);
}
/* Server-side merge: slightly darker red to distinguish from browser merge */
.btn-dl-server {
  background: #b71c1c;
}
.btn-dl-server:hover {
  background: #c62828;
  box-shadow: 0 2px 10px rgba(183,28,28,0.4);
}
.btn-copy {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-copy:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--row-hover);
}
.btn-copy.copied {
  color: var(--success);
  border-color: rgba(0,200,83,0.35);
  background: var(--success-dim);
}
.btn-dl svg, .btn-copy svg { width: 13px; height: 13px; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px;
  margin-bottom: 22px;
  max-width: 360px;
}
.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 2px 10px rgba(255,0,0,0.3);
}

/* Tab panes */
.tab-pane { display: none; animation: fadeIn 0.25s ease; }
.tab-pane.active { display: block; }

/* ===== MP3 Box ===== */
.mp3-box { padding: 24px; margin-bottom: 28px; }
.mp3-box-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.mp3-box-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}
.mp3-box-icon svg { width: 17px; height: 17px; }
.mp3-box-title { font-size: 1rem; font-weight: 600; color: var(--text); }

.bitrate-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.bitrate-pill {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  transition: all var(--transition);
}
.bitrate-pill small {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.bitrate-pill .br-size {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}
.bitrate-pill:hover { border-color: var(--border-light); transform: translateY(-1px); }
.bitrate-pill:disabled { cursor: not-allowed; opacity: 0.5; transform: none; }
.bitrate-pill:disabled:hover { border-color: var(--border); transform: none; }
.bitrate-pill.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.bitrate-pill.active small { color: var(--accent); }
.bitrate-pill.active .br-size { color: var(--accent); }
.br-tag {
  position: absolute;
  top: -8px;
  right: 6px;
  background: var(--success);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 20px;
}

.btn-mp3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 15px 24px;
  border-radius: 50px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn-mp3 {
  background: var(--accent-grad);
  position: relative;
  overflow: hidden;
}
/* Shine sweep across the main CTA */
.btn-mp3::before {
  content: '';
  position: absolute;
  top: 0;
  left: -80%;
  width: 50%;
  height: 100%;
  background: linear-gradient(105deg, transparent, rgba(255,255,255,0.28), transparent);
  transform: skewX(-20deg);
  animation: ctaShine 4.5s ease-in-out infinite;
}
@keyframes ctaShine {
  0%, 60% { left: -80%; }
  100% { left: 130%; }
}
.btn-mp3:hover:not(:disabled) {
  box-shadow: var(--shadow-accent);
  transform: translateY(-1px);
  filter: brightness(1.06);
}
.btn-mp3:active:not(:disabled) { transform: translateY(0); }
.btn-mp3:disabled { opacity: 0.75; cursor: not-allowed; transform: none; }
.btn-mp3-icon { width: 19px; height: 19px; }
.btn-mp3-spinner { display: flex; align-items: center; }
.mp3-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 14px;
}

/* ===== Inline MP3 Progress (download → convert) ===== */
.mp3-progress {
  margin-top: 18px;
  animation: fadeIn 0.25s ease;
}
.mp3-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.mp3-progress-phase {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.mp3-phase-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-dim);
  animation: dotPulse 1.3s ease-in-out infinite;
}
.mp3-progress.converting .mp3-phase-dot { background: var(--success); }
.mp3-progress-head-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.mp3-progress-pct {
  font-size: 0.92rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.mp3-progress.converting .mp3-progress-pct { color: var(--success); }
.mp3-progress-cancel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}
.mp3-progress-cancel:hover { color: var(--accent); background: var(--row-hover); }
.mp3-progress-cancel svg { width: 14px; height: 14px; }

.mp3-progress-track {
  height: 12px;
  background: var(--border);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}
.mp3-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 7px;
  background: linear-gradient(90deg, #ff5252, #ff0000);
  transition: width 0.3s ease;
}
/* Converting phase: animated green stripes, visually distinct from download */
.mp3-progress.converting .mp3-progress-fill {
  background-image: linear-gradient(
    -45deg,
    rgba(255,255,255,0.25) 25%, transparent 25%,
    transparent 50%, rgba(255,255,255,0.25) 50%,
    rgba(255,255,255,0.25) 75%, transparent 75%, transparent
  ), linear-gradient(90deg, #06a34f, #0bd968);
  background-size: 28px 28px, 100% 100%;
  animation: stripeMove 0.7s linear infinite;
}
/* Indeterminate (e.g. server transcoding, no % yet) */
.mp3-progress-fill.indeterminate {
  width: 35% !important;
  transition: none;
  animation: barSlide 1.3s ease-in-out infinite;
}
.mp3-progress.converting .mp3-progress-fill.indeterminate {
  animation: barSlide 1.3s ease-in-out infinite, stripeMove 0.7s linear infinite;
}

.mp3-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-dim); }
  50% { opacity: 0.5; box-shadow: 0 0 0 5px transparent; }
}
@keyframes stripeMove {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 28px 0, 0 0; }
}
@keyframes barSlide {
  0%   { margin-left: -35%; }
  100% { margin-left: 100%; }
}

/* ===== Results Reveal Animation ===== */
.results {
  animation: slideUp 0.4s ease forwards;
}

/* ===== Feature Strip ===== */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 36px 0 8px;
}
.feature-card {
  padding: 22px 20px;
  transition: transform 0.25s var(--ease-spring), border-color var(--transition), box-shadow var(--transition);
}
.feature-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-light);
  box-shadow: var(--shadow);
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  margin-bottom: 14px;
}
.feature-icon svg { width: 19px; height: 19px; }
.feature-icon-red   { background: var(--accent-dim); color: var(--accent); }
.feature-icon-green { background: var(--success-dim); color: var(--success); }
.feature-icon-blue  { background: rgba(33,150,243,0.12); color: var(--blue); }
.feature-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.feature-text {
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

/* ===== SEO Content Sections ===== */
.seo-content {
  margin-top: 48px;
}
.content-section {
  max-width: 720px;
  margin: 0 auto 44px;
  scroll-margin-top: 24px;
}
.content-section h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}
.content-section p {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.content-section strong { color: var(--text); font-weight: 600; }
.steps-list, .quality-list {
  margin: 4px 0 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.steps-list li, .quality-list li {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
}
.steps-list li::marker { color: var(--accent); font-weight: 700; }
.quality-list { list-style: none; margin-left: 0; }
.quality-list li {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
}

/* FAQ accordion (native details/summary — accessible, no JS) */
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--border-light); }
.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}
.faq-item[open] summary::after { transform: rotate(45deg); color: var(--accent); }
.faq-item p {
  padding: 0 18px 16px;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 28px 0 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-bottom: 14px;
}
.footer-nav a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.footer-nav a:hover { color: var(--accent); }

/* ===== Client-side Merge Download Panel ===== */
.dl-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 9998;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}
.dl-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.dl-panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  flex-shrink: 0;
}
.dl-panel-icon svg { width: 15px; height: 15px; }
.dl-panel-info { flex: 1; min-width: 0; }
.dl-panel-filename {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dl-panel-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.dl-panel-cancel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.dl-panel-cancel:hover { color: var(--text); background: var(--border); }
.dl-panel-cancel svg { width: 14px; height: 14px; }

.dl-tracks {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dl-track {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 8px;
}
.dl-track-label { font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }
.dl-bar-wrap {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.dl-bar {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.dl-bar-video  { background: var(--accent); }
.dl-bar-audio  { background: var(--blue); }
.dl-bar-merge  { background: var(--success); }
.dl-bar.indeterminate {
  width: 40% !important;
  animation: indeterminate 1.4s ease-in-out infinite;
}
.dl-track-pct {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow);
  min-width: 220px;
  max-width: 320px;
  pointer-events: auto;
  animation: toastIn 0.3s ease forwards;
}
.toast.hiding { animation: toastOut 0.25s ease forwards; }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--accent); }
.toast.info svg { color: var(--blue); }

/* ===== Keyframes ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,0,0,0.5); }
  50% { box-shadow: 0 0 20px rgba(255,0,0,0.8), 0 0 30px rgba(255,0,0,0.3); }
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(30px); }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header { padding: 36px 0 24px; }
  .logo-text { font-size: 1.4rem; }
  .input-section { padding: 18px; }
  .video-card { flex-direction: column; }
  .video-thumb-wrap { width: 100%; }
  .steps-wrapper { gap: 0; }
  .step-connector { max-width: 50px; }
  .step-label { font-size: 0.68rem; }
  .formats-table th,
  .formats-table td { padding: 10px 12px; }
  .action-btns { flex-direction: column; gap: 4px; }
  .btn-dl, .btn-copy { justify-content: center; }
  .skeleton-card { flex-direction: column; }
  .skeleton-thumb { width: 100%; height: 160px; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: unset; max-width: unset; }
  .tabs { max-width: unset; }
  .bitrate-grid { grid-template-columns: repeat(2, 1fr); }
  .theme-toggle { top: 12px; right: 12px; width: 38px; height: 38px; }
}
@media (max-width: 800px) {
  .features { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .hero-title { margin-top: 10px; }
  .trust-chips { gap: 6px; }
  .trust-chip { padding: 6px 11px; font-size: 0.74rem; }
  .dl-panel { left: 16px; right: 16px; width: auto; bottom: 16px; }
}
@media (max-width: 400px) {
  .processing-steps { padding: 20px 8px 14px; }
  .step-connector { max-width: 30px; }
}

/* ===== Data alignment ===== */
.formats-table td, .br-size, .format-count { font-variant-numeric: tabular-nums; }

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .aurora-blob { animation: none; }
  .btn-mp3::before { animation: none; display: none; }
  .hero-title { animation: none; }
  html { scroll-behavior: auto; }
}
