:root {
  --bg: #0a0a0f; --bg-elevated: #12121a; --bg-card: #16161f;
  --fg: #f0f0f5; --fg-muted: #8a8a9a;
  --accent-cyan: #00f0e4; --accent-magenta: #fe2c55;
  --accent-gradient: linear-gradient(135deg, #00f0e4, #25f4ee, #fe2c55);
  --border: rgba(255,255,255,0.06);
  --glow-cyan: 0 0 30px rgba(0,240,228,0.15);
  --radius: 16px; --radius-sm: 10px;
  --font-display: 'Space Grotesk', sans-serif; --font-body: 'Inter', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background: var(--bg); color: var(--fg); min-height: 100vh; overflow-x: hidden; position: relative; }

/* Fondos y Partículas */
.bg-layer { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-blob { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.35; animation: blobFloat 12s ease-in-out infinite alternate; }
.bg-blob--cyan { width: 500px; height: 500px; background: radial-gradient(circle, rgba(0,240,228,0.5), transparent 70%); top: -10%; left: -5%; }
.bg-blob--magenta { width: 450px; height: 450px; background: radial-gradient(circle, rgba(254,44,85,0.45), transparent 70%); bottom: -10%; right: -5%; animation-delay: -4s; }
@keyframes blobFloat { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(-20px, 20px) scale(0.95); } }
.bg-grid { position: fixed; inset: 0; z-index: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px); background-size: 60px 60px; mask-image: radial-gradient(ellipse 60% 50% at 50% 40%, black 20%, transparent 100%); }
.particles-container { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.particle { position: absolute; border-radius: 50%; animation: particleDrift linear infinite; opacity: 0; }
@keyframes particleDrift { 0% { transform: translateY(100vh) scale(0); opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { transform: translateY(-10vh) scale(1); opacity: 0; } }

/* Layout General */
.app-wrapper { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 2rem 1.25rem; }
.top-nav { width: 100%; max-width: 720px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 3rem; }
.logo { display: flex; align-items: center; gap: 0.6rem; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--fg); text-decoration: none; }
.logo-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-gradient); display: grid; place-items: center; font-size: 1rem; color: #fff; box-shadow: var(--glow-cyan); }

/* Hero */
.hero { text-align: center; max-width: 640px; margin-bottom: 2.5rem; }
.hero-badge { display: inline-flex; align-items: center; gap: 0.5rem; background: rgba(0,240,228,0.07); border: 1px solid rgba(0,240,228,0.15); border-radius: 999px; padding: 0.4rem 1rem; font-size: 0.78rem; font-weight: 600; color: var(--accent-cyan); margin-bottom: 1.5rem; text-transform: uppercase; }
.pulse-dot { width: 7px; height: 7px; background: var(--accent-cyan); border-radius: 50%; animation: pulseDot 2s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.7); } }
.hero h1 { font-family: var(--font-display); font-size: clamp(2.2rem, 6vw, 3.4rem); font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; margin-bottom: 1rem; }
.gradient-text { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero p { color: var(--fg-muted); font-size: 1.05rem; line-height: 1.6; max-width: 480px; margin: 0 auto; }

/* Formulario */
.download-card { width: 100%; max-width: 620px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; position: relative; overflow: hidden; transition: border-color 0.4s, box-shadow 0.4s; }
.download-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--accent-gradient); opacity: 0.6; transition: opacity 0.3s; }
.download-card:focus-within { border-color: rgba(0,240,228,0.2); box-shadow: var(--glow-cyan); }
.download-card:focus-within::before { opacity: 1; }
.input-group { display: flex; gap: 0.75rem; align-items: stretch; }
.input-wrapper { flex: 1; position: relative; }
.input-wrapper i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--fg-muted); font-size: 0.9rem; transition: color 0.3s; }
.url-input { width: 100%; height: 52px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 1rem 0 2.75rem; font-family: var(--font-body); font-size: 0.95rem; color: var(--fg); outline: none; transition: border-color 0.3s; }
.url-input::placeholder { color: rgba(138,138,154,0.6); }
.url-input:focus { border-color: rgba(0,240,228,0.4); box-shadow: 0 0 0 3px rgba(0,240,228,0.08); }
.input-wrapper:focus-within i { color: var(--accent-cyan); }
.download-btn { height: 52px; padding: 0 1.8rem; border: none; border-radius: var(--radius-sm); background: var(--accent-gradient); color: #0a0a0f; font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; transition: transform 0.2s, box-shadow 0.3s; }
.download-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(0,240,228,0.25); }
.download-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(10,10,15,0.25); border-top-color: #0a0a0f; border-radius: 50%; animation: spin 0.7s linear infinite; display: none; }
.download-btn.loading .spinner { display: block; }
.download-btn.loading .btn-text { display: none; }
.download-btn.loading .btn-loading-text { display: inline; }
.btn-loading-text { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg { margin-top: 0.75rem; font-size: 0.82rem; color: var(--accent-magenta); display: flex; align-items: center; gap: 0.4rem; opacity: 0; max-height: 0; overflow: hidden; transition: opacity 0.3s, max-height 0.3s; }
.error-msg.visible { opacity: 1; max-height: 40px; }

/* Tarjeta Resultado */
.result-card { width: 100%; max-width: 620px; margin-top: 1.5rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; opacity: 0; transform: translateY(20px) scale(0.97); max-height: 0; transition: all 0.5s ease; pointer-events: none; }
.result-card.visible { opacity: 1; transform: translateY(0) scale(1); max-height: 600px; pointer-events: all; border-color: rgba(0,240,228,0.15); }
.result-inner { padding: 1.75rem 2rem; }
.result-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.result-success-icon { width: 42px; height: 42px; border-radius: 50%; background: rgba(0,240,228,0.1); border: 1.5px solid rgba(0,240,228,0.25); display: grid; place-items: center; color: var(--accent-cyan); font-size: 1.1rem; animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes popIn { 0% { transform: scale(0); } 100% { transform: scale(1); } }
.result-header-text h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 700; }
.result-header-text p { font-size: 0.82rem; color: var(--fg-muted); margin-top: 0.15rem; }
.result-video-preview { display: flex; gap: 1.25rem; margin-bottom: 1.5rem; align-items: flex-start; }
.video-thumbnail { width: 110px; height: 150px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; background: var(--bg-elevated); border: 1px solid var(--border); }
.video-info { flex: 1; min-width: 0; }
.video-title { font-weight: 600; font-size: 0.92rem; line-height: 1.45; margin-bottom: 0.6rem; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.video-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.75rem; }
.meta-tag { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; color: var(--fg-muted); background: var(--bg-elevated); padding: 0.3rem 0.65rem; border-radius: 6px; border: 1px solid var(--border); }
.video-author { font-size: 0.82rem; color: var(--fg-muted); }
.video-author strong { color: var(--accent-cyan); font-weight: 600; }
.result-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.save-btn { flex: 1; min-width: 180px; height: 48px; border: none; border-radius: var(--radius-sm); background: var(--accent-gradient); color: #0a0a0f; font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; transition: transform 0.2s; }
.save-btn:hover { transform: translateY(-1px); }
.audio-btn { height: 48px; padding: 0 1.2rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); color: var(--fg); font-family: var(--font-display); font-weight: 600; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; transition: border-color 0.3s; }
.audio-btn:hover { border-color: rgba(254,44,85,0.3); background: rgba(254,44,85,0.06); }

/* Historial */
.history-section { width: 100%; max-width: 620px; margin-top: 2.5rem; }
.history-title { font-family: var(--font-display); font-size: 0.85rem; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.history-list { display: flex; flex-direction: column; gap: 0.5rem; }
.history-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); animation: slideIn 0.4s ease both; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
.history-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--bg-elevated); flex-shrink: 0; }
.history-info { flex: 1; min-width: 0; }
.h-title { font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-author { font-size: 0.72rem; color: var(--fg-muted); }
.history-status { font-size: 0.72rem; color: var(--accent-cyan); display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }

/* Funciones */
.features { width: 100%; max-width: 720px; margin-top: 4rem; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.feature-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; text-align: center; transition: border-color 0.3s, transform 0.3s; }
.feature-card:hover { border-color: rgba(255,255,255,0.1); transform: translateY(-3px); }
.feature-icon { width: 44px; height: 44px; margin: 0 auto 1rem; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem; }
.feature-icon--cyan { background: rgba(0,240,228,0.08); color: var(--accent-cyan); border: 1px solid rgba(0,240,228,0.15); }
.feature-icon--magenta { background: rgba(254,44,85,0.08); color: var(--accent-magenta); border: 1px solid rgba(254,44,85,0.15); }
.feature-icon--white { background: rgba(255,255,255,0.05); color: var(--fg); border: 1px solid rgba(255,255,255,0.1); }
.feature-card h4 { font-family: var(--font-display); font-size: 0.92rem; font-weight: 700; margin-bottom: 0.4rem; }
.feature-card p { font-size: 0.78rem; color: var(--fg-muted); line-height: 1.5; }

/* Toasts */
.toast-container { position: fixed; top: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 1.25rem; font-size: 0.85rem; color: var(--fg); display: flex; align-items: center; gap: 0.6rem; box-shadow: 0 8px 32px rgba(0,0,0,0.4); animation: toastIn 0.35s ease; max-width: 340px; }
.toast--error { border-color: rgba(254,44,85,0.3); }
.toast--error i { color: var(--accent-magenta); }
.toast--success { border-color: rgba(0,240,228,0.3); }
.toast--success i { color: var(--accent-cyan); }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

.app-footer { margin-top: 4rem; text-align: center; padding: 1.5rem; color: var(--fg-muted); font-size: 0.75rem; border-top: 1px solid var(--border); width: 100%; max-width: 720px; }

/* Responsive */
@media (max-width: 640px) { 
  .input-group { flex-direction: column; } 
  .download-btn { width: 100%; justify-content: center; } 
  .features { grid-template-columns: 1fr; }
  .result-video-preview { flex-direction: column; align-items: center; text-align: center; }
  .video-thumbnail { width: 100%; height: 200px; }
  .result-actions { flex-direction: column; }
  .save-btn, .audio-btn { width: 100%; justify-content: center; }
}
:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }

/* Barra de Progreso */
.progress-container { margin-top: 1.25rem; animation: fadeIn 0.3s ease; }
.progress-info { display: flex; justify-content: space-between; margin-bottom: 0.4rem; font-size: 0.78rem; color: var(--fg-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.progress-bar-bg { width: 100%; height: 6px; background: var(--bg-elevated); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar-fill { height: 100%; width: 0%; background: var(--accent-gradient); border-radius: 999px; transition: width 0.3s ease; box-shadow: 0 0 10px rgba(0,240,228,0.4); }