:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --text: #333333;
  --muted: #5f5f5f;
  --line: #e2e2e2;
  --accent: #7ed214;
  --accent-hover: #6dbb0c;
  --on-accent: #16240a;      /* texto sobre el verde: contraste > 9:1 */
  --link: #3a6600;           /* verde oscuro para texto: contraste > 6:1 */
  --error: #b3261e;
  --error-bg: #fdecea;
  --error-line: #f1b9b4;
  --accent-soft: #eef8dc;
  color-scheme: light;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
}

img { max-width: 100%; height: auto; }

a { color: var(--link); }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  padding: .5rem 1rem;
  background: var(--surface);
}
.skip-link:focus { left: 0; z-index: 10; }

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Cabecera */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: .5rem 1.5rem;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}
/* Selector de idioma: desplegable (<details>) con los 13 idiomas. */
.lang-switch { position: relative; font-size: .9rem; }
.lang-switch summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  white-space: nowrap;
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary:hover { background: var(--bg); }
.lang-switch ul {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  margin: 0;
  padding: .3rem;
  list-style: none;
  min-width: 11rem;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .14);
}
.lang-switch li { margin: 0; }
.lang-switch li a, .lang-switch li span {
  display: block;
  padding: .4rem .6rem;
  border-radius: 5px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.lang-switch li a:hover { background: var(--bg); color: var(--link); }
.lang-switch li [aria-current] { background: var(--accent-soft); color: var(--link); font-weight: 600; }

/* Derecha a izquierda (árabe). */
[dir="rtl"] .lang-switch ul { right: auto; left: 0; }
[dir="rtl"] .steps li { padding: 3.6rem 1.1rem 1.1rem; }
[dir="rtl"] .steps li::before { left: auto; right: 1rem; }
[dir="rtl"] .status, [dir="rtl"] .result, [dir="rtl"] .url-form, [dir="rtl"] .prose { text-align: right; }
[dir="rtl"] .consent { text-align: right; }
[dir="rtl"] .badge, [dir="rtl"] .site-initial { margin-right: 0; margin-left: .5rem; }

/* Hero */
.hero { padding: 3.5rem 0 2.5rem; text-align: center; }
.hero h1 {
  margin: 0 0 .75rem;
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  line-height: 1.2;
  letter-spacing: -.01em;
}
.hero .lead { margin: 0 auto 2rem; max-width: 36rem; color: var(--muted); font-size: 1.08rem; }
.hero .url-form, .hero .status, .hero .result { max-width: 720px; margin-left: auto; margin-right: auto; }

.url-form { text-align: left; }
.url-row {
  display: flex;
  gap: .5rem;
  padding: .4rem;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
}
.url-row input {
  flex: 1;
  min-width: 0;
  padding: .75rem .8rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
}
.url-row input::placeholder { color: var(--muted); opacity: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .75rem 1.4rem;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-small { padding: .45rem 1rem; font-size: .92rem; }

.consent {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  margin-top: .9rem;
  color: var(--muted);
  font-size: .9rem;
}
.consent input { width: 1.1rem; height: 1.1rem; margin-top: .2rem; accent-color: var(--link); flex: none; }

.turnstile { margin-top: 1rem; min-height: 0; }

/* Estados */
.status { margin-top: 1.25rem; text-align: left; }
.status:empty { display: none; }
.status p {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 0;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.status .is-error { background: var(--error-bg); border-color: var(--error-line); color: var(--error); }

.spinner {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  border: 3px solid var(--line);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
  .btn { transition: none; }
}

/* Resultado */
.result {
  margin-top: 1.25rem;
  padding: 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}
.result[hidden] { display: none; }
.result-head { display: flex; gap: 1rem; align-items: flex-start; }
.result-head img {
  flex: none;
  width: 160px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}
.result-head h2 { margin: 0 0 .25rem; font-size: 1.1rem; line-height: 1.35; overflow-wrap: anywhere; }
.result-head p { margin: 0; color: var(--muted); font-size: .9rem; }

.format-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.format-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1rem;
  padding: .7rem 0;
  border-top: 1px solid var(--line);
}
.format-label { flex: 1; min-width: 9rem; }
.format-label strong { margin-right: .4rem; }
.format-label span { color: var(--muted); font-size: .9rem; }
.badge {
  display: inline-block;
  padding: .05rem .5rem;
  margin-right: .5rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--link);
  font-size: .78rem;
  font-weight: 700;
}
.format-state {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--muted);
  font-size: .9rem;
}
.format-state:empty { display: none; }
.format-state.is-error { color: var(--error); }
.format-state progress { flex: 1; max-width: 16rem; height: .5rem; accent-color: var(--link); }

/* Galería de imágenes (motor gallery-dl) */
.img-all {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .6rem 1rem;
  margin: 1rem 0 .25rem;
}
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .9rem;
  margin-top: 1rem;
}
.img-cell { margin: 0; display: flex; flex-direction: column; gap: .45rem; }
.img-cell img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.img-cell .format-state { flex-basis: auto; font-size: .82rem; }
.img-cell .btn { width: 100%; }

/* Contenido */
.section { padding: 2.5rem 0; border-top: 1px solid var(--line); }
.section h2 { margin: 0 0 1.25rem; font-size: 1.45rem; line-height: 1.3; }
.section h3 { margin: 0 0 .3rem; font-size: 1.05rem; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  counter-reset: step;
}
.steps li {
  position: relative;
  padding: 3.6rem 1.1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 1rem;
  top: 1.1rem;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  display: grid;
  place-items: center;
}
.steps p { margin: 0; color: var(--muted); font-size: .95rem; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .6rem;
}
.faq summary { padding: .9rem 1rem; font-weight: 600; cursor: pointer; }
.faq details p { margin: 0; padding: 0 1rem 1rem; color: var(--muted); }

.prose { padding-top: 2.5rem; padding-bottom: 3rem; max-width: 760px; }
.prose h1 { font-size: clamp(1.6rem, 4.5vw, 2.1rem); line-height: 1.25; margin: 0 0 .5rem; }
.prose h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
.prose .updated { color: var(--muted); font-size: .9rem; }
.prose li { margin-bottom: .35rem; }

/* Pie */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1.5rem 0;
  font-size: .9rem;
  color: var(--muted);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .75rem 1.5rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.site-footer p { margin: 0; }

@media (max-width: 560px) {
  .hero { padding: 2.25rem 0 1.75rem; }
  .url-row { flex-direction: column; }
  .url-row .btn { width: 100%; }
  .result-head { flex-direction: column; }
  .result-head img { width: 100%; }
  .format-item .btn { width: 100%; }
}

/* Navegación principal */
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-left: auto;
  font-size: .95rem;
}
.main-nav a {
  padding: .4rem .7rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
.main-nav a:hover { background: var(--bg); color: var(--link); }

/* Sitios compatibles */
.site-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: .6rem;
}
.site-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.site-initial {
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--link);
  font-weight: 700;
  font-size: .9rem;
  display: grid;
  place-items: center;
  text-transform: uppercase;
}

/* Anuncios: el espacio se reserva antes de cargar para evitar saltos. */
.ad-slot { margin-top: 1.5rem; margin-bottom: 1.5rem; text-align: center; }
.ad-slot[hidden] { display: none; }
.ad-label {
  display: block;
  margin-bottom: .3rem;
  color: var(--muted);
  font-size: .72rem;
}
.ad-slot ins { display: block; min-height: 100px; }

@media (max-width: 700px) {
  .site-header .container { padding-top: .5rem; padding-bottom: .5rem; }
  .main-nav { order: 3; width: 100%; margin-left: -.7rem; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .lang-switch { margin-left: auto; }
}
/* Modo oscuro: por preferencia del sistema o por el botón de la cabecera. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #141613;
  --surface: #1d201b;
  --text: #e7e9e4;
  --muted: #a8ada2;
  --line: #32372e;
  --accent-hover: #8fe02a;
  --link: #a3e84b;
  --error: #ff9388;
  --error-bg: #3a1d1a;
  --error-line: #6b302a;
  --accent-soft: #263317;
  color-scheme: dark;  }
}
:root[data-theme="dark"] {
  --bg: #141613;
  --surface: #1d201b;
  --text: #e7e9e4;
  --muted: #a8ada2;
  --line: #32372e;
  --accent-hover: #8fe02a;
  --link: #a3e84b;
  --error: #ff9388;
  --error-bg: #3a1d1a;
  --error-line: #6b302a;
  --accent-soft: #263317;
  color-scheme: dark;}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--bg); }

.site-logo { flex: none; width: 1.7rem; height: 1.7rem; object-fit: contain; border-radius: 4px; }

/* Blog */
.post-list { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 1rem; }
.post-card {
  padding: 1.2rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.post-card h2 { margin: 0 0 .35rem; font-size: 1.2rem; line-height: 1.35; }
.post-card h2 a { color: var(--text); text-decoration: none; }
.post-card h2 a:hover { color: var(--link); text-decoration: underline; }
.post-card p { margin: 0; color: var(--muted); }
.post-meta { color: var(--muted); font-size: .88rem; }
.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted); }
.post-cta {
  margin-top: 2rem;
  padding: 1.2rem 1.3rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.post-cta p { margin: 0 0 .8rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: .95rem; }
.prose th, .prose td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.badge-direct { margin-left: .5rem; margin-right: 0; }

.site-note { margin-top: .9rem; color: var(--muted); font-size: .9rem; }
