/* YPi · tema claro y oscuro */

:root {
  --bg: #101010;
  --card: #1c1c1e;
  --card-hi: #242426;
  --border: #2d2d2f;
  --border-hi: #3d3d40;
  --text: #fff;
  --muted: #8a8a8e;
  --faint: #5e5e62;
  --accent: #fff;
  --accent-text: #101010;
  --success: #28c76f;
  --danger: #ff5f6d;
  --overlay: rgba(28, 28, 30, 0.75);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 1rem;
  --font-head: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas,
    monospace;
}

html.light {
  --bg: #f0f2f5;
  --card: #fff;
  --card-hi: #f7f8fa;
  --border: #dee2e6;
  --border-hi: #c7ccd1;
  --text: #212529;
  --muted: #6c757d;
  --faint: #9aa0a6;
  --accent: #222;
  --accent-text: #fff;
  --success: #1f9d57;
  --danger: #dc3545;
  --overlay: hsla(0, 0%, 100%, 0.75);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-head);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

::selection {
  background: var(--accent);
  color: var(--accent-text);
}

/* Preloader */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  width: 150px;
}

.preloader-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: pulse-shadow 2s infinite;
}

.preloader-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes pulse-shadow {
  0% {
    box-shadow: 0 0 0 0 var(--accent);
    transform: scale(0.95);
  }
  70% {
    box-shadow: 0 0 0 10px transparent;
    transform: scale(1);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
    transform: scale(0.95);
  }
}

.line-loader {
  background: var(--border);
  border-radius: 10px;
  height: 4px;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.line-loader span {
  position: absolute;
  top: 0;
  left: -50%;
  width: 50%;
  height: 100%;
  background: var(--accent);
  border-radius: 10px;
  animation: line-load 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes line-load {
  from { left: -50%; }
  to { left: 100%; }
}

/* Header */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(16, 16, 16, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease;
}

html.light .app-header {
  background: rgba(240, 242, 245, 0.8);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 0 0 1px var(--border);
  transition: transform 0.25s ease;
}

.brand:hover .brand-logo {
  transform: rotate(-4deg) scale(1.06);
}

.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link,
.icon-btn,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--card);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.nav-link:hover {
  color: var(--text);
  border-color: var(--border-hi);
}

.icon-btn {
  height: 38px;
  justify-content: center;
  padding: 0 14px;
  font-size: 1rem;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-hi);
}

.status-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.status-chip .dot {
  color: var(--success);
  font-size: 0.5rem;
  animation: pulse 2.4s ease-in-out infinite;
}

/* Interruptor de idioma ES/EN */

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  height: 38px;
  box-sizing: border-box;
}

.lang-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 9px;
  border-radius: 0.45rem;
  cursor: pointer;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
}

.lang-btn:hover {
  color: var(--text);
}

.lang-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Layout */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* Hero */

.hero {
  text-align: center;
  padding: 72px 0 44px;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 22px;
}

.kicker::before,
.kicker::after {
  content: "—";
  color: var(--border-hi);
  margin: 0 10px;
}

.hero h1 {
  font-size: clamp(2.2rem, 6.6vw, 4.3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.hero h1 .outline {
  color: transparent;
  -webkit-text-stroke: 1.6px var(--text);
}

html.light .hero h1 .outline {
  -webkit-text-stroke: 1.6px #333;
}

.hero .sub {
  max-width: 560px;
  margin: 22px auto 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 2vw, 1.08rem);
}

/* Paneles */

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease, box-shadow 0.25s ease,
    background 0.3s ease;
}

.download-panel {
  padding: 24px;
  max-width: 760px;
  margin: 0 auto;
}

.download-panel:focus-within {
  border-color: var(--border-hi);
  box-shadow: var(--shadow-lg);
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 9px;
}

.panel-head h2 i {
  color: var(--accent);
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

/* Campo URL */

.url-row {
  display: flex;
  gap: 12px;
}

.url-input-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

html.light .url-input-wrap {
  background: #fff;
}

.url-input-wrap i {
  color: var(--faint);
  font-size: 1.1rem;
}

.url-input-wrap:focus-within {
  border-color: var(--border-hi);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

html.light .url-input-wrap:focus-within {
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

#url {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 15px 0;
  color: var(--text);
  font-size: 0.95rem;
  font-family: var(--font-mono);
  outline: none;
}

#url::placeholder {
  color: var(--faint);
}

/* Botones */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 0.75rem;
  padding: 14px 24px;
  min-height: 50px;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease,
    border-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.12);
}

html.light .btn-primary {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(255, 255, 255, 0.2);
  filter: brightness(1.06);
}

html.light .btn-primary:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--card-hi);
  border-color: var(--border-hi);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-block {
  width: 100%;
  text-decoration: none;
}

.btn:focus-visible,
.seg-btn:focus-visible,
.pill:focus-visible,
.icon-btn:focus-visible,
#url:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Opciones */

.options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 18px;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 4px;
  gap: 4px;
}

html.light .seg {
  background: #fff;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 0.6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  touch-action: manipulation;
  transition: background 0.2s ease, color 0.2s ease;
}

.seg-btn em {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  opacity: 0.7;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: var(--shadow);
}

.seg-btn.active em {
  border-color: currentColor;
  opacity: 0.85;
}

.quality {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.q-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.pills {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  min-width: 48px;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 0.6rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.18s ease;
}

.pill:hover {
  color: var(--text);
  border-color: var(--border-hi);
}

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

.pill-unit {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--faint);
  margin-left: 2px;
}

/* Progreso */

.progress {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 0.75rem;
  background: var(--bg);
  border: 1px dashed var(--border-hi);
  color: var(--muted);
  font-size: 0.88rem;
}

.progress[hidden] {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-label {
  flex: 1;
  min-width: 0;
}

.progress-track {
  flex: 1 1 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

.progress-pct {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  min-width: 40px;
  text-align: right;
}

/* Resultado */

.result {
  max-width: 760px;
  margin: 24px auto 0;
  animation: rise 0.4s ease both;
}

.result[hidden] {
  display: none;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  padding: 20px;
}

.thumb-wrap {
  overflow: hidden;
  border-radius: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  aspect-ratio: 16 / 9;
}

.thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.r-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

#rTitle {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.r-meta {
  color: var(--muted);
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.r-meta i {
  color: var(--success);
}

.r-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
}

.chip.ok {
  color: var(--success);
  border-color: rgba(40, 199, 111, 0.35);
  background: rgba(40, 199, 111, 0.07);
}

.r-link-row {
  display: flex;
  gap: 10px;
}

.r-link-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0 14px;
  transition: border-color 0.2s ease;
}

.r-link-wrap:focus-within {
  border-color: var(--border-hi);
}

.r-link-wrap i {
  color: var(--faint);
}

.r-link {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 12px 0;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
}

.r-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--faint);
}

/* Features */

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 760px;
  margin: 48px auto 0;
}

.feature {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.feature:hover {
  border-color: var(--border-hi);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 1.15rem;
}

html.light .feature-icon {
  background: #fff;
}

.feature h3 {
  margin: 14px 0 6px;
  font-size: 1rem;
  font-weight: 700;
}

.feature p {
  color: var(--muted);
  font-size: 0.86rem;
}

/* Footer */

.site-footer {
  text-align: center;
  padding: 44px 20px 48px;
  color: var(--muted);
  font-size: 0.92rem;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

.site-footer strong {
  color: var(--text);
}

.heart {
  color: var(--danger);
  display: inline-block;
  animation: beat 1.6s ease-in-out infinite;
}

@keyframes beat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.25); }
}

.footer-sub {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--faint);
}

/* Toasts */

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  width: min(92vw, 420px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border-hi);
  border-radius: 0.75rem;
  padding: 13px 16px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: rise 0.3s ease both;
}

.toast.ok {
  border-color: rgba(40, 199, 111, 0.4);
}

.toast.err {
  border-color: rgba(255, 95, 109, 0.45);
}

.toast .t-icon {
  font-weight: 800;
}

.toast.ok .t-icon { color: var(--success); }
.toast.err .t-icon { color: var(--danger); }

/* Responsive */

@media (max-width: 860px) {
  .result-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 12px 16px;
  }

  .brand-tag,
  .nav-link span {
    display: none;
  }

  .nav-link {
    padding: 8px 10px;
  }

  .status-chip {
    display: none;
  }

  .hero {
    padding: 46px 0 34px;
  }

  .hero h1 .outline {
    -webkit-text-stroke-width: 1.2px;
  }

  .url-row {
    flex-direction: column;
  }

  #url {
    width: 100%;
    font-size: 0.88rem;
  }

  .btn {
    width: 100%;
    min-height: 52px;
  }

  .options {
    flex-direction: column;
    align-items: stretch;
  }

  .seg,
  .quality {
    justify-content: center;
  }

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

  .download-panel {
    padding: 18px;
  }

  .r-link-row {
    flex-direction: column;
  }

  .result-card {
    padding: 16px;
  }
}

@media (max-width: 480px) {
  .brand-name {
    font-size: 1.15rem;
  }

  .header-nav {
    gap: 6px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
  }

  .theme-label {
    display: none;
  }

  .lang-switch {
    height: 36px;
  }

  .lang-btn {
    padding: 4px 7px;
  }

  .hero {
    padding: 38px 0 28px;
  }

  .hero h1 {
    font-size: clamp(1.9rem, 8.4vw, 2.6rem);
  }

  .kicker {
    letter-spacing: 0.18em;
  }

  .panel-head h2 {
    font-size: 1.05rem;
  }

  .seg {
    width: 100%;
  }

  .seg-btn {
    flex: 1;
    justify-content: center;
  }

  .quality {
    width: 100%;
    justify-content: space-between;
  }

  .pills {
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .pills::-webkit-scrollbar {
    display: none;
  }

  .progress {
    gap: 10px;
  }

  .progress-track {
    flex-basis: 100%;
  }

  .progress-pct {
    min-width: auto;
  }

  .feature {
    padding: 20px;
  }

  .site-footer {
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
