/* tools: sistema visual. Todo color, espacio y radio sale de estos tokens: una
   herramienta nueva no define valores propios. */
:root {
  --c-fondo: #f6f5f1;
  --c-superficie: #ffffff;
  --c-texto: #1d2125;
  --c-texto-suave: #545b63;
  --c-borde: #dad6cd;
  --c-borde-fuerte: #b9b4a8;
  --c-acento: #1f6b5c;
  --c-sobre-acento: #ffffff;
  --c-acento-suave: #e2eeea;
  --c-aviso-fondo: #fcf2d4;
  --c-aviso-borde: #b98d12;
  --c-aviso-texto: #4f3c06;
  --c-error: #a3271f;
  --c-foco: #1f6b5c;

  --e-1: .25rem; --e-2: .5rem; --e-3: .75rem; --e-4: 1rem; --e-5: 1.5rem; --e-6: 2rem; --e-7: 3rem;
  --r-1: 4px; --r-2: 8px;
  --t-chico: .875rem; --t-base: 1rem; --t-medio: 1.125rem; --t-grande: 1.5rem; --t-titulo: 1.875rem;
  --ancho: 64rem;
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --c-fondo: #121416;
    --c-superficie: #1a1d20;
    --c-texto: #e8e5de;
    --c-texto-suave: #a5abb1;
    --c-borde: #2d3236;
    --c-borde-fuerte: #454b51;
    --c-acento: #6cc3ad;
    --c-sobre-acento: #0c1a16;
    --c-acento-suave: #1b2c28;
    --c-aviso-fondo: #2c2513;
    --c-aviso-borde: #c9a227;
    --c-aviso-texto: #f1dfa3;
    --c-error: #f08a80;
    --c-foco: #8fd8c5;
    color-scheme: dark;
  }
}

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--c-fondo);
  color: var(--c-texto);
  font: var(--t-base)/1.55 var(--fuente);
}
main { flex: 1; padding-block: var(--e-6) var(--e-7); }
h1 { font-size: var(--t-titulo); line-height: 1.2; margin: 0 0 var(--e-2); letter-spacing: -.01em; }
h2 { font-size: var(--t-medio); margin: 0 0 var(--e-3); }
p { margin: 0 0 var(--e-3); }
a { color: var(--c-acento); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--c-foco); outline-offset: 2px; border-radius: var(--r-1); }
[hidden] { display: none !important; }
.contenedor { width: 100%; max-width: var(--ancho); margin-inline: auto; padding-inline: var(--e-4); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icono {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.saltar { position: absolute; left: var(--e-4); top: -3rem; padding: var(--e-2) var(--e-3); background: var(--c-acento); color: var(--c-sobre-acento); border-radius: var(--r-1); z-index: 1; }
.saltar:focus { top: var(--e-2); }

/* --- Barra y pie ---------------------------------------------------------------- */
.barra { border-bottom: 1px solid var(--c-borde); background: var(--c-superficie); }
.barra-interior { display: flex; align-items: center; justify-content: space-between; gap: var(--e-4); min-height: 3.5rem; }
.marca { color: var(--c-texto); text-decoration: none; font-weight: 650; }
.marca span { color: var(--c-texto-suave); font-weight: 450; }
.sello { display: flex; align-items: center; gap: var(--e-2); margin: 0; font-size: var(--t-chico); color: var(--c-acento); }
@media (max-width: 34rem) {
  .sello span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .marca span { display: none; }
  .buscador kbd { display: none; }
}
.pie { border-top: 1px solid var(--c-borde); padding-block: var(--e-5); font-size: var(--t-chico); color: var(--c-texto-suave); }
.pie p { max-width: 42rem; }

/* --- Índice ------------------------------------------------------------------- */
.portada { max-width: 42rem; margin-bottom: var(--e-5); }
.bajada { color: var(--c-texto-suave); font-size: var(--t-medio); max-width: 42rem; }
.buscador {
  display: flex; align-items: center; gap: var(--e-2);
  max-width: 32rem; margin-bottom: var(--e-6);
  padding-inline: var(--e-3);
  background: var(--c-superficie); border: 1px solid var(--c-borde-fuerte); border-radius: var(--r-2);
  color: var(--c-texto-suave);
}
.buscador:focus-within { border-color: var(--c-acento); box-shadow: 0 0 0 1px var(--c-acento); }
.buscador input { flex: 1; min-width: 0; border: 0; padding: var(--e-3) 0; background: transparent; color: var(--c-texto); font: inherit; }
.buscador input:focus { outline: none; }
kbd { font: var(--t-chico) var(--fuente); padding: 0 var(--e-2); border: 1px solid var(--c-borde); border-radius: var(--r-1); }
.categoria { margin-bottom: var(--e-6); }
.categoria h2 { font-size: var(--t-chico); text-transform: uppercase; letter-spacing: .06em; color: var(--c-texto-suave); }
.lista-herramientas {
  list-style: none; margin: 0; padding: 0;
  background: var(--c-superficie); border: 1px solid var(--c-borde); border-radius: var(--r-2);
}
.lista-herramientas li + li { border-top: 1px solid var(--c-borde); }
.lista-herramientas a {
  display: flex; align-items: center; gap: var(--e-4);
  padding: var(--e-4); color: var(--c-texto); text-decoration: none;
}
.lista-herramientas a:hover { background: var(--c-acento-suave); }
.lista-herramientas li:first-child a { border-radius: var(--r-2) var(--r-2) 0 0; }
.lista-herramientas li:last-child a { border-radius: 0 0 var(--r-2) var(--r-2); }
.lista-icono {
  display: grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none;
  border-radius: var(--r-2); background: var(--c-acento-suave); color: var(--c-acento);
}
.lista-texto { display: flex; flex-direction: column; gap: var(--e-1); flex: 1; }
.lista-texto span { color: var(--c-texto-suave); font-size: var(--t-chico); }
.lista-flecha { color: var(--c-texto-suave); }
.lista-herramientas a:hover .lista-flecha { color: var(--c-acento); }

/* --- Página de herramienta ----------------------------------------------------- */
.migas { display: flex; gap: var(--e-2); font-size: var(--t-chico); color: var(--c-texto-suave); margin-bottom: var(--e-3); }
.herramienta { display: grid; gap: var(--e-4); margin-top: var(--e-5); align-items: start; }
@media (min-width: 52rem) {
  .herramienta { grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); gap: var(--e-5); }
  .resultado { position: sticky; top: var(--e-4); }
}
.panel { background: var(--c-superficie); border: 1px solid var(--c-borde); border-radius: var(--r-2); padding: var(--e-5); }
.resultado { border-top: 3px solid var(--c-acento); }
.nota { color: var(--c-texto-suave); font-size: var(--t-chico); max-width: 42rem; margin-top: var(--e-5); }

/* Campos */
.campo { margin-bottom: var(--e-4); }
.campo label, .segmentado legend { display: block; font-weight: 550; margin-bottom: var(--e-1); }
.ayuda { font-size: var(--t-chico); color: var(--c-texto-suave); margin: var(--e-1) 0 0; }
.campo input, .campo select {
  font: inherit; color: var(--c-texto);
  width: 100%; max-width: 20rem; min-height: 2.75rem;
  padding: var(--e-2) var(--e-3);
  background: var(--c-fondo); border: 1px solid var(--c-borde-fuerte); border-radius: var(--r-1);
}
.campo input:focus, .campo select:focus { outline: none; border-color: var(--c-acento); box-shadow: 0 0 0 1px var(--c-acento); }

/* Segmentado: radios nativos (teclado y lector de pantalla gratis) con aspecto de botones */
.segmentado { border: 0; padding: 0; margin: 0 0 var(--e-4); display: flex; flex-wrap: wrap; }
.segmentado legend { width: 100%; }
.segmentado input { position: absolute; opacity: 0; }
.segmentado label {
  padding: var(--e-2) var(--e-4); cursor: pointer;
  border: 1px solid var(--c-borde-fuerte); background: var(--c-fondo);
}
.segmentado label + input + label { border-left: 0; }
.segmentado label:first-of-type { border-radius: var(--r-1) 0 0 var(--r-1); }
.segmentado label:last-of-type { border-radius: 0 var(--r-1) var(--r-1) 0; }
.segmentado input:checked + label { background: var(--c-acento); border-color: var(--c-acento); color: var(--c-sobre-acento); }
.segmentado input:focus-visible + label { outline: 2px solid var(--c-foco); outline-offset: 2px; }

/* Resultado */
.vacio { color: var(--c-texto-suave); }
.error { color: var(--c-error); font-weight: 550; }
.destacado { font-size: var(--t-grande); font-weight: 650; line-height: 1.25; margin-bottom: var(--e-2); font-variant-numeric: tabular-nums; }
.detalle { color: var(--c-texto-suave); }
.filas { margin: var(--e-4) 0; }
.fila { display: flex; justify-content: space-between; gap: var(--e-4); padding-block: var(--e-2); border-top: 1px solid var(--c-borde); }
.fila dt { color: var(--c-texto-suave); }
.fila dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.fila.enfasis dt, .fila.enfasis dd { color: var(--c-texto); font-weight: 650; }
.nota-resultado { font-size: var(--t-chico); color: var(--c-texto-suave); }

/* Avisos */
.aviso {
  display: flex; gap: var(--e-2); align-items: flex-start;
  padding: var(--e-3); border: 1px solid var(--c-aviso-borde); border-radius: var(--r-1);
  background: var(--c-aviso-fondo); color: var(--c-aviso-texto); font-size: var(--t-chico);
}
.aviso .icono { margin-top: .1em; }

/* Botones */
.acciones { display: flex; flex-wrap: wrap; gap: var(--e-2); margin-top: var(--e-4); }
.boton {
  display: inline-flex; align-items: center; gap: var(--e-2);
  min-height: 2.5rem; padding: var(--e-2) var(--e-3);
  font: inherit; font-size: var(--t-chico); font-weight: 550; text-decoration: none; cursor: pointer;
  color: var(--c-acento); background: transparent;
  border: 1px solid var(--c-acento); border-radius: var(--r-1);
}
.boton:hover { background: var(--c-acento-suave); }
.boton:disabled { opacity: .45; cursor: not-allowed; background: transparent; }
.boton-sutil { border-color: transparent; color: var(--c-texto-suave); }
.boton-primario { background: var(--c-acento); color: var(--c-sobre-acento); }
.boton-primario:hover { background: var(--c-acento); opacity: .9; }

.solo-impresion { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .lista-herramientas a, .boton, .segmentado label { transition: background-color .12s ease, color .12s ease; }
}

/* --- Impresión: solo lo que sirve en papel ----------------------------------------- */
@media print {
  :root {
    --c-fondo: #fff; --c-superficie: #fff; --c-texto: #000; --c-texto-suave: #333;
    --c-borde: #bbb; --c-borde-fuerte: #bbb; --c-acento: #000; --c-acento-suave: #fff;
  }
  @page { margin: 2cm; }
  body { font-size: 11pt; }
  .barra, .pie, .migas, .acciones, .saltar, .segmentado, .aviso { display: none !important; }
  main { padding: 0; }
  .herramienta { display: block; }
  .panel { border: 0; padding: 0; margin-bottom: var(--e-5); }
  .resultado { border-top: 1px solid #000; padding-top: var(--e-4); }
  .solo-impresion { display: block; font-size: var(--t-chico); color: var(--c-texto-suave); }
  .campo input, .campo select { border: 0; padding: 0; min-height: 0; appearance: none; background: none; }
}
.ayuda.separada { margin: calc(-1 * var(--e-2)) 0 var(--e-4); }
