/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f9;
  --ink: #101828;
  --ink-soft: #475467;
  --ink-mute: #7a869a;
  --line: #e2e7f0;
  --accent: #4338ca;
  --accent-soft: #eef0ff;
  --accent-ink: #ffffff;
  --money: #0f8a5f;
  --money-soft: #e6f6ef;
  --warn: #b45309;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Manrope", var(--sans);

  --radius: 14px;
  --radius-lg: 20px;
  --gutter: clamp(1rem, 4vw, 2rem);
  --maxw: 1080px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 32px -12px rgba(16, 24, 40, .16);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Modo oscuro. El bloque se repite para `data-theme` porque algunos visores
   (previsualizaciones, incrustaciones) fijan el tema en el elemento raíz en
   lugar de delegar en el sistema. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1018;
    --surface: #141a24;
    --surface-2: #1a212d;
    --ink: #eef2f8;
    --ink-soft: #b3bccb;
    --ink-mute: #8a94a6;
    --line: #262f3d;
    --accent: #8b8bff;
    --accent-soft: #1e2340;
    --accent-ink: #0c1018;
    --money: #3ed99a;
    --money-soft: #10291f;
    --warn: #e9a33c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  --bg: #0c1018;
  --surface: #141a24;
  --surface-2: #1a212d;
  --ink: #eef2f8;
  --ink-soft: #b3bccb;
  --ink-mute: #8a94a6;
  --line: #262f3d;
  --accent: #8b8bff;
  --accent-soft: #1e2340;
  --accent-ink: #0c1018;
  --money: #3ed99a;
  --money-soft: #10291f;
  --warn: #e9a33c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .7);
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; line-height: 1.15; letter-spacing: -0.02em; }
::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* =============================================================
   3. Utilities
   ============================================================= */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.noscript-note {
  margin: 0 0 1rem; padding: .8rem 1rem; border-radius: 10px;
  background: var(--money-soft); color: var(--warn); font-weight: 500;
}

/* =============================================================
   4. Header
   ============================================================= */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; min-height: 60px;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-family: var(--display); font-weight: 800; letter-spacing: -.02em; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink);
}
.brand-text { font-size: 1.05rem; }
.header-nav { display: none; gap: 1.4rem; font-size: .92rem; color: var(--ink-soft); }
.header-nav a { transition: color .2s var(--ease-out); }
.header-nav a:hover { color: var(--accent); }
@media (min-width: 720px) { .header-nav { display: flex; } }

/* =============================================================
   5. Hero + herramienta
   ============================================================= */
.hero { padding: clamp(1rem, 4vw, 2.8rem) 0 1rem; }
.hero h1 { font-size: clamp(1.75rem, 5.2vw, 2.9rem); font-weight: 800; }
.hero-sub {
  margin: .5rem 0 1rem; max-width: 64ch;
  color: var(--ink-soft); font-size: clamp(.94rem, 2.4vw, 1.08rem);
}
.hero-sub strong { color: var(--ink); font-weight: 600; }

.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3.2vw, 1.6rem);
}

/* Selector de formato */
.format-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: .4rem;
  padding: .3rem; background: var(--surface-2);
  border-radius: 12px; margin-bottom: 1.1rem;
}
.fmt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .6rem .4rem; border-radius: 9px; font-weight: 600;
  font-size: clamp(.85rem, 3.2vw, .95rem); white-space: nowrap;
  color: var(--ink-soft); transition: background .2s var(--ease-out), color .2s var(--ease-out);
}
.fmt-btn svg { flex: none; }
.fmt-btn:hover { color: var(--ink); }
.fmt-btn.is-active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(16,24,40,.12); }

/* Campos. La plataforma va arriba junto al resultado; el resto son ajustes
   finos que viven debajo, para que en movil la respuesta se vea sin scroll. */
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem .55rem; }
.field--wide { grid-column: 1 / -1; }
.field--platform { margin-bottom: .2rem; }
@media (min-width: 720px) {
  .field-grid { grid-template-columns: repeat(3, 1fr); gap: .9rem 1rem; }
  .field--wide { grid-column: auto; }
}

.tuning {
  margin-top: 1rem; padding-top: .9rem; border-top: 1px dashed var(--line);
}
.tuning-title {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-mute); margin-bottom: .55rem;
}

.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }

.select-wrap { position: relative; display: block; }
.select-wrap::after {
  content: ""; position: absolute; right: .95rem; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--ink-mute); border-bottom: 2px solid var(--ink-mute);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  width: 100%; padding: .6rem 2rem .6rem .7rem;
  font: inherit; font-size: .9rem; color: var(--ink);
  text-overflow: ellipsis;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  cursor: pointer; transition: border-color .2s var(--ease-out), box-shadow .2s var(--ease-out);
}
.select-wrap select:hover { border-color: var(--ink-mute); }
.select-wrap select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }

.platform-note {
  margin-top: .7rem; padding: .55rem .75rem; border-radius: 10px;
  background: var(--accent-soft); color: var(--ink-soft);
  font-size: .83rem; line-height: 1.5;
}

/* Duo de campos bidireccional */
.duo {
  display: grid; gap: .5rem; align-items: stretch;
  margin-top: .85rem;
}
@media (min-width: 720px) { .duo { grid-template-columns: 1fr auto 1fr; gap: .8rem; } }

.duo-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px; padding: .65rem .8rem .45rem;
}
@media (min-width: 720px) { .duo-box { padding: .85rem .9rem .7rem; } }
.duo-box--money { background: var(--money-soft); border-color: color-mix(in srgb, var(--money) 22%, transparent); }
.duo-label { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .2rem; }
.duo-input {
  width: 100%; padding: .2rem 0 .35rem; border: 0; background: none;
  font-family: var(--display); font-size: clamp(1.5rem, 5.4vw, 2rem); font-weight: 800;
  letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.duo-input:focus { outline: none; }
.duo-input--money { color: var(--money); }

/* En movil las flechas solo gastan altura util: el orden vertical ya explica
   la relacion entre los dos campos. */
.duo-arrows { display: none; color: var(--ink-mute); }
@media (min-width: 720px) { .duo-arrows { display: grid; place-items: center; padding: 0 .1rem; } }

.chips { display: flex; flex-wrap: wrap; gap: .3rem; padding: .4rem 0 .2rem; }
.chips button {
  padding: .18rem .5rem; font-size: .76rem; font-weight: 600;
  color: var(--ink-soft); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px;
  transition: color .18s var(--ease-out), border-color .18s var(--ease-out);
}
.chips button:hover { color: var(--accent); border-color: var(--accent); }

.duo-hint { margin-top: .4rem; font-size: .8rem; color: var(--ink-mute); text-align: center; }

/* Resultado */
.result {
  margin-top: .8rem; padding: .85rem;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2);
}
@media (min-width: 720px) { .result { margin-top: 1.1rem; padding: 1rem; } }
.result-main { text-align: center; }
.result-label { display: block; font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); }
.result-value {
  display: block; font-family: var(--display); font-weight: 800;
  font-size: clamp(2rem, 8vw, 2.9rem); letter-spacing: -.03em; color: var(--money);
  line-height: 1.1; margin-top: .15rem;
}
.result-unit { display: block; font-size: .88rem; color: var(--ink-soft); margin-top: .25rem; }

.result-band {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem;
  margin-top: .95rem; padding-top: .85rem; border-top: 1px dashed var(--line);
  text-align: center;
}
.band-item span { display: block; font-size: .74rem; color: var(--ink-mute); }
.band-item strong { display: block; font-size: .98rem; font-weight: 700; margin-top: .1rem; }

/* Acciones */
.tool-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.1rem; border-radius: 11px; font-weight: 600; font-size: .93rem;
  border: 1px solid transparent; transition: transform .18s var(--ease-out), background .18s var(--ease-out), border-color .18s var(--ease-out);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); flex: 1 1 auto; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-block { width: 100%; }

.privacy-badge {
  margin-top: 1rem; font-size: .85rem; color: var(--ink-soft);
  background: var(--money-soft); border-radius: 10px; padding: .6rem .8rem;
}
.limits-note { margin-top: .55rem; font-size: .78rem; line-height: 1.55; color: var(--ink-mute); }

/* =============================================================
   6. Huecos de anuncios (placeholders)
   ============================================================= */
.ad-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
  border: 2px dashed var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--ink-mute);
}
.ad-tag { font-family: var(--display); font-size: .78rem; font-weight: 700; letter-spacing: .18em; }
.ad-size { font-size: .68rem; letter-spacing: .04em; }

.ad-slot--leaderboard { min-height: 100px; margin: 1.6rem 0 .4rem; }
@media (min-width: 720px) { .ad-slot--leaderboard { min-height: 110px; } }
.ad-slot--inline { min-height: 280px; max-width: 336px; margin: 2rem auto; }
.ad-slot--modal { min-height: 250px; width: 100%; }
.ad-slot--corner { min-height: 100px; width: 100%; border-width: 1px; }

/* Pop-up de descarga */
.ad-modal {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 0; background: var(--surface); color: var(--ink);
  width: min(92vw, 360px); box-shadow: var(--shadow);
}
.ad-modal::backdrop { background: rgba(9, 12, 20, .55); backdrop-filter: blur(2px); }
.ad-modal-inner { position: relative; padding: 1.2rem 1.1rem 1.1rem; display: grid; gap: .8rem; }
.ad-modal-head { font-family: var(--display); font-weight: 700; font-size: .98rem; padding-right: 1.6rem; }
.ad-modal-close {
  position: absolute; top: .5rem; right: .6rem;
  width: 32px; height: 32px; border-radius: 50%; font-size: 1.3rem; line-height: 1;
  color: var(--ink-mute); background: var(--surface-2);
}
.ad-modal-close:hover { color: var(--ink); }

/* Notificación de esquina */
.ad-corner {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  width: min(88vw, 320px); padding: .55rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  animation: cornerIn .45s var(--ease-out) both;
}
.ad-corner[hidden] { display: none; }
.ad-corner-close {
  position: absolute; top: -10px; right: -10px;
  width: 26px; height: 26px; border-radius: 50%; font-size: 1rem; line-height: 1;
  color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line);
}
.ad-corner-close:hover { color: var(--ink); }
@keyframes cornerIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* =============================================================
   7. Secciones de contenido
   ============================================================= */
.section { padding: clamp(2rem, 6vw, 3.4rem) 0; }
.section--alt { background: var(--surface); border-block: 1px solid var(--line); }
.section h2 { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 800; }
.section-lead { margin-top: .5rem; color: var(--ink-soft); font-size: .95rem; }

/* Tabla de referencia */
.table-wrap { overflow-x: auto; margin-top: 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.ref-table { width: 100%; border-collapse: collapse; min-width: 480px; font-size: .93rem; font-variant-numeric: tabular-nums; }
.ref-table th, .ref-table td { padding: .7rem .9rem; text-align: right; border-bottom: 1px solid var(--line); }
.ref-table th:first-child, .ref-table td:first-child { text-align: left; font-weight: 600; }
.ref-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-mute); background: var(--surface-2); }
.ref-table tbody tr:last-child td { border-bottom: 0; }
.ref-table td[data-mid] { font-weight: 700; color: var(--money); }

/* Cómo funciona */
.steps { list-style: none; padding: 0; display: grid; gap: 1rem; margin-top: 1.4rem; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 1.2rem; } }
.step {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.1rem 1.2rem;
}
.step-num {
  display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: .7rem;
  border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  font-family: var(--display); font-weight: 800;
}
.step h3 { font-size: 1.05rem; font-weight: 700; }
.step p { margin-top: .4rem; font-size: .93rem; color: var(--ink-soft); }
.step strong { color: var(--ink); }

/* Prosa SEO */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 2.2rem; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 1.6rem; font-size: 1.1rem; font-weight: 700; }
.prose p { margin-top: .8rem; color: var(--ink-soft); }
.prose strong { color: var(--ink); font-weight: 600; }
.prose-note {
  margin-top: 1.6rem; padding: .9rem 1rem; border-left: 3px solid var(--accent);
  background: var(--surface); border-radius: 0 10px 10px 0; font-size: .9rem;
}

/* FAQ */
.faq { margin-top: 1.3rem; display: grid; gap: .6rem; }
.faq details {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .85rem 1rem;
}
.faq summary {
  cursor: pointer; font-weight: 600; font-size: .98rem; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; font-family: var(--display); font-size: 1.3rem; font-weight: 700;
  color: var(--accent); line-height: 1; flex: none;
}
.faq details[open] summary::after { content: "–"; }
.faq details p { margin-top: .6rem; font-size: .93rem; color: var(--ink-soft); }

/* =============================================================
   8. Footer
   ============================================================= */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0 2.6rem; background: var(--surface); }
.footer-inner { display: grid; gap: .7rem; }
.footer-brand { font-family: var(--display); font-weight: 700; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .9rem; color: var(--ink-soft); }
.footer-nav a:hover { color: var(--accent); }
.footer-note { font-size: .78rem; color: var(--ink-mute); max-width: 70ch; line-height: 1.6; }

/* =============================================================
   9. Toast
   ============================================================= */
.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  z-index: 80; padding: .6rem 1rem; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: .88rem; font-weight: 600;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* =============================================================
   10. Reduced motion (solo efectos intrusivos)
   ============================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-corner { animation: none; }
}

/* =============================================================
   11. Impresión
   ============================================================= */
@media print {
  .site-header, .ad-slot, .ad-corner, .tool-actions, .site-footer, .skip-link { display: none !important; }
  body { background: #fff; color: #000; }
}
