/* =============================================================
   Cronolector — hoja de estilos única
   1 Tokens · 2 Reset · 3 Utilidades · 4 Tipografía · 5 Componentes
   6 Secciones · 7 Anuncios · 8 Responsive · 9 Reduced motion
   ============================================================= */

/* ================= 1. Tokens ================= */
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --ink: #17171f;
  --muted: #66667a;
  --line: #e5e1d9;
  --accent: #5b4bdb;
  --accent-soft: #ece9ff;
  --accent-ink: #ffffff;
  --ok: #12855f;
  --ok-soft: #dff5ec;
  --warn: #b4530c;
  --warn-soft: #fdecd9;

  --hl-relleno: #fde68a;
  --hl-redundancia: #fecdd3;
  --hl-sinonimo: #c9dcff;
  --hl-secundaria: #ebe8e3;
  --hl-ink: #2a2a33;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 12px 32px -12px rgba(20, 20, 40, .14);
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131318;
    --surface: #1c1c24;
    --surface-2: #23232d;
    --ink: #edecf3;
    --muted: #a0a0b4;
    --line: #2f2f3c;
    --accent: #8f83ff;
    --accent-soft: #262046;
    --accent-ink: #14121f;
    --ok: #4ade9f;
    --ok-soft: #14312a;
    --warn: #f0a868;
    --warn-soft: #35240f;

    --hl-relleno: #6b5410;
    --hl-redundancia: #6d2233;
    --hl-sinonimo: #1f3d75;
    --hl-secundaria: #2c2c37;
    --hl-ink: #f2f1f7;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -16px rgba(0, 0, 0, .7);
  }
}

/* ================= 2. Reset ================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; letter-spacing: -.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }

/* ================= 3. Utilidades ================= */
.wrap { width: min(1080px, 100%); margin-inline: auto; padding-inline: var(--gutter); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -100px; left: 1rem; z-index: 999;
  padding: .6rem 1rem; background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-sm); font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* ================= 4. Tipografía ================= */
h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.75rem, 5vw, 2.9rem);
  letter-spacing: -.03em;
}
h2 { font-family: var(--display); font-weight: 600; font-size: clamp(1.35rem, 3.2vw, 2rem); }
h3 { font-size: 1.06rem; font-weight: 650; letter-spacing: -.01em; }

/* ================= 5. Componentes ================= */
.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; height: 60px; }
.logo { display: flex; align-items: center; gap: .5rem; font-weight: 500; letter-spacing: -.02em; }
.logo strong { font-weight: 750; }
.logo svg { color: var(--accent); }
.header-nav { display: none; gap: 1.4rem; font-size: .92rem; color: var(--muted); }
.header-nav a:hover { color: var(--ink); }

.hero { padding: clamp(1.75rem, 5vw, 3.25rem) var(--gutter) 1.4rem; text-align: center; }
.hero .sub {
  max-width: 62ch; margin: .9rem auto 0; color: var(--muted);
  font-size: clamp(.98rem, 2.2vw, 1.08rem);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .68rem 1.15rem; border-radius: 999px; font-weight: 600; font-size: .93rem;
  border: 1px solid transparent; transition: transform .18s var(--ease-out), background .18s, border-color .18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .38rem .8rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn.is-ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn-ghost.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---- tarjeta de la herramienta ---- */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.75rem);
  display: grid;
  gap: 1.5rem;
}
.tool-step { display: grid; gap: .75rem; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.step-title { font-family: var(--sans); font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: .55rem; }
.step-n {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: .8rem; font-weight: 700;
}
.step-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.entrada {
  width: 100%; min-height: 190px; resize: vertical;
  padding: 1rem; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface-2);
  line-height: 1.65; font-size: 1rem;
}
.entrada:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.entrada::placeholder { color: var(--muted); }
.entrada-meta { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.entrada-meta strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.tiempos { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.tiempo {
  display: grid; gap: .1rem; padding: .85rem 1rem;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  grid-template-areas: "ico val" "ico lab" "ico ppm";
  grid-template-columns: auto 1fr; align-items: center; column-gap: .8rem;
}
.t-ico { grid-area: ico; font-size: 1.4rem; }
.t-val {
  grid-area: val; font-family: var(--display); font-size: 1.45rem; font-weight: 700;
  letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.t-lab { grid-area: lab; font-size: .88rem; font-weight: 600; }
.t-ppm { grid-area: ppm; font-size: .76rem; color: var(--muted); }

.modos { display: flex; flex-wrap: wrap; gap: .45rem; border: 0; padding: 0; }
.modo input { position: absolute; opacity: 0; pointer-events: none; }
.modo span {
  display: inline-block; padding: .45rem .85rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: .86rem; font-weight: 550; transition: all .18s var(--ease-out);
}
.modo input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.modo input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.objetivo { display: flex; align-items: center; gap: 1rem; }
.obj-num {
  display: inline-flex; align-items: baseline; gap: .3rem; flex: none;
  padding: .45rem .7rem; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2);
}
.obj-num input {
  width: 4.2rem; border: 0; background: none; font-size: 1.15rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.obj-num input:focus { outline: none; }
.obj-unidad { font-size: .85rem; color: var(--muted); }

.slider { flex: 1; min-width: 0; height: 28px; -webkit-appearance: none; appearance: none; background: none; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--line); }
.slider::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -8px;
  border-radius: 50%; background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .22); cursor: grab;
}
.slider::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .22); cursor: grab;
}

.presets { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  padding: .35rem .75rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: .8rem; font-weight: 550; color: var(--muted);
  transition: all .18s var(--ease-out);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.medidor { border: 1px solid var(--line); border-radius: var(--r-md); padding: .9rem 1rem; background: var(--surface-2); }
.med-top { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .9rem; }
.med-actual strong { font-family: var(--display); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.med-pal { color: var(--muted); font-variant-numeric: tabular-nums; }
.med-pista { height: 9px; border-radius: 999px; background: var(--line); margin: .6rem 0 .55rem; overflow: hidden; }
.med-barra { height: 100%; border-radius: 999px; background: var(--accent); transition: width .35s var(--ease-out), background .25s; }
.med-msg { font-size: .88rem; color: var(--muted); }
.medidor[data-estado="ok"] .med-barra { background: var(--ok); }
.medidor[data-estado="ok"] { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.medidor[data-estado="ok"] .med-msg { color: var(--ok); }
.medidor[data-estado="sobra"] .med-barra { background: var(--warn); }
.medidor[data-estado="sobra"] { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.medidor[data-estado="sobra"] .med-msg { color: var(--warn); }

.acciones { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.recortes-info { font-size: .84rem; color: var(--muted); }
.recortes-info strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.leyenda { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; list-style: none; padding: 0; font-size: .8rem; color: var(--muted); }
.leyenda li { display: flex; align-items: center; gap: .4rem; }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; flex: none; }
.sw.t-relleno { background: var(--hl-relleno); }
.sw.t-redundancia { background: var(--hl-redundancia); }
.sw.t-sinonimo { background: var(--hl-sinonimo); }
.sw.t-secundaria { background: var(--hl-secundaria); border: 1px solid var(--line); }

.analisis {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  padding: 1rem; max-height: 380px; overflow-y: auto; line-height: 1.9; font-size: .98rem;
}
.analisis .an-p + .an-p { margin-top: .7rem; }
.an-vacio, .an-aviso { color: var(--muted); font-size: .9rem; line-height: 1.6; }
.hl {
  border-radius: 4px; padding: .05em .18em; cursor: pointer; color: var(--hl-ink);
  border-bottom: 2px solid transparent; transition: filter .15s;
}
.hl:hover { filter: brightness(.94); }
.hl.t-relleno { background: var(--hl-relleno); }
.hl.t-redundancia, .hl.t-vacia, .hl.t-adverbio { background: var(--hl-redundancia); }
.hl.t-sinonimo { background: var(--hl-sinonimo); }
.hl.is-cut { text-decoration: line-through; opacity: .48; }
.sent.sec { background: var(--hl-secundaria); border-radius: 4px; padding: .05em 0; }
.sent.is-cut { text-decoration: line-through; opacity: .42; }
.cut-sent {
  display: inline-block; margin-left: .25em; padding: 0 .28em; border-radius: 4px;
  background: var(--surface); border: 1px solid var(--line); font-size: .78em; line-height: 1.5;
  vertical-align: middle;
}
.cut-sent:hover { border-color: var(--accent); color: var(--accent); }
.tip { font-size: .8rem; color: var(--muted); }

.salida {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  padding: 1rem; min-height: 110px; max-height: 340px; overflow-y: auto;
  line-height: 1.75; font-size: 1rem;
}
.salida p + p { margin-top: .75rem; }
.salida.bionic { line-height: 1.95; letter-spacing: .005em; }
.salida.bionic b { font-weight: 700; }
.out-vacio { color: var(--muted); font-size: .9rem; }
.nota-bionic {
  font-size: .82rem; color: var(--accent); background: var(--accent-soft);
  padding: .55rem .8rem; border-radius: var(--r-sm);
}
.out-bar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.out-meta { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.out-btns { display: flex; gap: .5rem; flex-wrap: wrap; }

.privacidad-badge {
  font-size: .85rem; color: var(--ok); background: var(--ok-soft);
  padding: .6rem .9rem; border-radius: var(--r-sm); text-align: center;
}
.limites { font-size: .78rem; color: var(--muted); text-align: center; }
.noscript {
  background: var(--warn-soft); color: var(--warn); padding: .8rem 1rem;
  border-radius: var(--r-sm); font-size: .9rem;
}

/* ================= 6. Secciones ================= */
.seccion { padding: clamp(2.25rem, 6vw, 3.75rem) var(--gutter); }
.seccion > h2 { margin-bottom: .5rem; }
.seccion-sub { color: var(--muted); margin-bottom: 1.5rem; font-size: .96rem; }

.pasos { list-style: none; padding: 0; display: grid; gap: 1rem; margin-top: 1.5rem; }
.paso {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.25rem; display: grid; gap: .45rem;
}
.paso-ico { width: 34px; height: 34px; color: var(--accent); }
.paso-ico svg { width: 100%; height: 100%; }
.paso p { font-size: .93rem; color: var(--muted); }

.usos { display: grid; gap: .9rem; }
.uso {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.1rem 1.2rem;
}
.uso h3 { margin-bottom: .3rem; }
.uso p { font-size: .92rem; color: var(--muted); }

.prosa { max-width: 74ch; }
.prosa h2 { margin-bottom: 1rem; }
.prosa h3 { margin: 1.75rem 0 .5rem; font-size: 1.12rem; }
.prosa p, .prosa li { color: var(--muted); font-size: .98rem; }
.prosa p + p { margin-top: .85rem; }
.prosa ul { margin: .75rem 0 0; padding-left: 1.15rem; display: grid; gap: .5rem; }
.prosa strong { color: var(--ink); }

.faq { display: grid; gap: .55rem; margin-top: 1.25rem; }
.faq details {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: .9rem 1.1rem;
}
.faq summary { cursor: pointer; font-weight: 600; font-size: .96rem; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--accent); font-weight: 700; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin-top: .6rem; font-size: .93rem; color: var(--muted); }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); margin-top: 2rem; }
.footer-inner { padding-block: 2rem; display: grid; gap: .7rem; text-align: center; }
.foot-brand { font-size: .92rem; }
.foot-nav { display: flex; gap: 1.2rem; justify-content: center; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.foot-nav a:hover { color: var(--accent); }
.foot-copy { font-size: .8rem; color: var(--muted); }

/* ================= 7. Anuncios (solo huecos) ================= */
.ad-slot {
  position: relative; display: grid; place-items: center;
  border: 1px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: var(--r-md); background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.ad-label {
  font-size: .68rem; letter-spacing: .18em; font-weight: 700; color: var(--muted);
}
.ad-leaderboard { min-height: 100px; margin-block: .5rem 1rem; }
.ad-incontent { min-height: 260px; margin-block: 1rem; }

.ad-modal {
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  color: var(--ink); padding: 1.4rem; width: min(360px, calc(100vw - 2rem));
  box-shadow: var(--shadow);
}
.ad-modal::backdrop { background: rgba(10, 10, 20, .55); backdrop-filter: blur(2px); }
.ad-modal-title { font-weight: 650; font-size: .95rem; color: var(--ok); margin-bottom: .8rem; }
.ad-modal-slot { min-height: 250px; margin-bottom: 1rem; }
.ad-x {
  position: absolute; top: .5rem; right: .6rem; width: 30px; height: 30px;
  border-radius: 50%; font-size: 1.25rem; line-height: 1; color: var(--muted);
  display: grid; place-items: center;
}
.ad-x:hover { background: var(--surface-2); color: var(--ink); }

.ad-toast {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 60;
  width: min(320px, calc(100vw - 2rem)); padding: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: opacity .25s var(--ease-out), transform .25s var(--ease-out);
}
.ad-toast.is-in { opacity: 1; transform: translateY(0); }
.ad-toast-slot { min-height: 100px; }

/* ================= 8. Responsive ================= */
@media (min-width: 540px) {
  .tiempos { grid-template-columns: repeat(3, 1fr); }
  .tiempo { grid-template-areas: "ico val" "lab lab" "ppm ppm"; row-gap: .12rem; }
}
@media (min-width: 720px) {
  .pasos, .usos { grid-template-columns: repeat(2, 1fr); }
  .header-nav { display: flex; }
}
@media (min-width: 960px) {
  .pasos { grid-template-columns: repeat(3, 1fr); }
  .usos { grid-template-columns: repeat(3, 1fr); }
  .entrada { min-height: 210px; }
}

/* ================= 9. Reduced motion ================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ad-toast { transition: none; }
  .med-barra { transition: none; }
}

/* Impresión: el texto ajustado, sin adornos */
@media print {
  .site-header, .ad-slot, .ad-toast, .ad-modal, .acciones, .presets, .objetivo,
  .modos, .leyenda, .analisis, .entrada, .site-footer, .seccion { display: none !important; }
  .salida { border: 0; max-height: none; }
}
