/* StepwiseChem — estilos. Sobrio y académico, con acentos de color en lo visual. */
:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #1a2332;
  --muted: #5a6475;
  --line: #e2ddd1;
  --accent: #0e6b6b;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ef;
  --copper: #b4531a;
  --chem: #a86b00;
  --copper-soft: #fbeee4;
  --ok: #1d7a46;
  --ok-soft: #e5f4ea;
  --error: #b42318;
  --error-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff5db;
  --reac: #2f6fb3;
  --prod: #c0562a;
  --shadow: 0 1px 2px rgba(26, 35, 50, .06), 0 4px 16px rgba(26, 35, 50, .06);
  --r: 14px;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  /* categorías de la tabla periódica */
  --c-am: #d9534f; --c-at: #e08a2e; --c-tr: #c9a227; --c-pt: #6c9a3b; --c-md: #2f9e8f;
  --c-nm: #2f6fb3; --c-ha: #6a5acd; --c-gn: #a14fa8; --c-la: #c45a8a; --c-ac: #8a6d5a;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f141b;
  --surface: #171e28;
  --surface-2: #1b2430;
  --ink: #e6eaf0;
  --muted: #9aa5b4;
  --line: #2a3442;
  --accent: #46b8ae;
  --accent-ink: #0b1a1a;
  --accent-soft: #15302e;
  --copper: #f0955a;
  --chem: #f6be4f;
  --copper-soft: #33241a;
  --ok: #5ccf8b;
  --ok-soft: #14301f;
  --error: #ff8a80;
  --error-soft: #3a1c1a;
  --warn: #f2c35b;
  --warn-soft: #33290f;
  --reac: #6fa8e8;
  --prod: #f08a5d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--sans);
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--copper); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: .2em 0 .3em; }
h2 { font-size: clamp(1.35rem, 3.6vw, 1.75rem); margin: 1.8em 0 .6em; }
h3 { font-size: 1.15rem; margin: 1.4em 0 .4em; }
sub, sup { font-size: .72em; line-height: 0; }
code, kbd { font-family: var(--mono); font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .05em .35em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
fieldset { min-width: 0; margin: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5em 1em; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.contenedor { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }

/* ---------- Encabezado ---------- */
.cabecera { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.cabecera .contenedor { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-family: var(--serif); font-weight: 700; font-size: 1.12rem; white-space: nowrap; }
.logo svg { width: 36px; height: 36px; flex: none; }
.logo b { color: var(--chem); font-weight: 700; }
.logo-texto { display: flex; flex-direction: column; line-height: 1.15; }
.logo-texto small { font-family: var(--sans); font-weight: 500; font-size: .7rem; color: var(--muted); letter-spacing: .01em; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav a { color: var(--ink); text-decoration: none; padding: .45em .7em; border-radius: 8px; font-size: .95rem; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.btn-icono { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn-icono:hover { border-color: var(--accent); color: var(--accent); }
.btn-icono svg { width: 20px; height: 20px; }
#menuBtn { display: none; }
.tema-sol { display: none; }
:root[data-theme="dark"] .tema-sol { display: block; }
:root[data-theme="dark"] .tema-luna { display: none; }

@media (max-width: 820px) {
  #menuBtn { display: inline-grid; margin-left: auto; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 60px; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--line); padding: 8px 16px 14px; box-shadow: var(--shadow); }
  .nav.abierto { display: flex; }
  .nav a { padding: .7em .6em; }
}

/* ---------- Portada de herramienta ---------- */
.intro { padding: 26px 0 8px; }
.migas { font-size: .88rem; color: var(--muted); }
.migas a { color: var(--muted); }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 62ch; margin: 0; }

/* ---------- Tarjetas ---------- */
.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; }
.tarjeta + .tarjeta { margin-top: 18px; }
@media (min-width: 700px) { .tarjeta { padding: 24px; } }
.tarjeta h2:first-child, .tarjeta h3:first-child { margin-top: 0; }
.etiqueta { display: block; font-weight: 600; margin-bottom: 6px; }
.ayuda { font-size: .88rem; color: var(--muted); margin: 6px 0 0; }

/* ---------- Entrada ---------- */
.campo { display: flex; gap: 8px; flex-wrap: wrap; }
.campo input {
  flex: 1 1 260px; min-width: 0; font: 500 1.15rem/1.3 var(--sans); letter-spacing: .02em; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.campo input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.vista { min-height: 2em; margin: 10px 0 0; font-family: var(--serif); font-size: 1.25rem; color: var(--muted); overflow-wrap: anywhere; }
.vista:empty::before { content: attr(data-vacio); font-size: .95rem; font-family: var(--sans); }
.teclado { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.teclado button { min-width: 42px; height: 38px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: 1rem var(--serif); cursor: pointer; }
.teclado button:hover { border-color: var(--accent); color: var(--accent); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 1rem var(--sans); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn svg { width: 18px; height: 18px; }
.btn-primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primario:hover { background: color-mix(in srgb, var(--accent) 86%, #000); color: var(--accent-ink); }
.ejemplos { margin-top: 16px; }
.ejemplos p { margin: 0 0 6px; font-size: .9rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: .35em .85em; font: .9rem var(--sans); cursor: pointer; }
.chip:hover { border-color: var(--copper); color: var(--copper); background: var(--copper-soft); }

/* ---------- Resultado ---------- */
#resultado { margin-top: 18px; scroll-margin-top: 76px; }
#resultado:empty { display: none; }
.res-principal { text-align: center; padding: 20px 10px; border-radius: 12px; background: linear-gradient(135deg, var(--accent-soft), var(--copper-soft)); }
.res-principal .rotulo { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 6px; }
.res-principal .rotulo .f { text-transform: none; letter-spacing: 0; font-family: var(--serif); font-size: 1.05rem; color: var(--ink); }
.ecuacion { font-family: var(--serif); font-size: clamp(1.25rem, 4.6vw, 1.9rem); line-height: 1.6; overflow-wrap: anywhere; }
.ecuacion .coef { color: var(--copper); font-weight: 700; }
.ecuacion .estado { font-size: .65em; color: var(--muted); margin-left: 1px; }
.res-acciones { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.aviso { border-radius: 10px; padding: 10px 14px; margin: 12px 0 0; font-size: .95rem; }
.aviso-error { background: var(--error-soft); color: var(--error); border: 1px solid color-mix(in srgb, var(--error) 30%, transparent); }
.aviso-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.aviso-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.aviso strong { display: block; margin-bottom: 2px; }

/* ---------- Pasos ---------- */
.pasos { counter-reset: paso; list-style: none; margin: 0; padding: 0; }
.pasos > li { position: relative; padding: 0 0 18px 46px; border-left: 2px solid var(--line); margin-left: 15px; }
.pasos > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.pasos > li::before {
  counter-increment: paso; content: counter(paso); position: absolute; left: -16px; top: -2px;
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 700 .9rem var(--sans);
}
.pasos h3 { margin: 0 0 6px; font-size: 1.05rem; }
.pasos p { margin: .3em 0; }
.formula-paso { font-family: var(--serif); font-size: 1.08rem; }
.desplazable { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; }
.tabla-guia th, .tabla-guia td { text-align: left; white-space: normal; vertical-align: top; }
.tabla-guia thead th { text-transform: none; letter-spacing: 0; }
.grupo-guias { margin-top: 22px; }
.ecs { font-family: var(--mono); font-size: .92rem; margin: 6px 0; padding: 0; list-style: none; }
.ecs li { padding: 2px 0; }

/* Tablas */
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tfoot td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--ink); }
.matriz { font-family: var(--mono); width: auto; margin: 0; }
.matriz th, .matriz td { text-align: center; padding: 5px 9px; }
.matriz thead th { text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--ink); }
.matriz thead small { font-family: var(--serif); font-size: .85rem; color: var(--muted); }
.matriz td.neg { color: var(--prod); }
.matriz td.pos { color: var(--reac); }
.matriz td.cero { color: var(--muted); opacity: .6; }
.matriz tr.pivote td:first-child { color: var(--accent); }
.matriz .sep { border-left: 2px dashed var(--line); }
.ok-celda { color: var(--ok); font-weight: 700; }

/* ---------- Visual: conteo de átomos ---------- */
.conteo { display: grid; gap: 10px; margin-top: 8px; }
.conteo-fila { display: grid; grid-template-columns: 58px 1fr; align-items: center; gap: 10px; }
.conteo-fila .el { font: 700 1rem var(--serif); text-align: right; }
.barras { display: grid; gap: 3px; }
.barra { height: 14px; border-radius: 7px; background: var(--surface-2); position: relative; overflow: hidden; }
.barra i { position: absolute; inset: 0 auto 0 0; border-radius: 7px; transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.barra.r i { background: var(--reac); }
.barra.p i { background: var(--prod); }
.barra span { position: absolute; right: 6px; top: -1px; font: 600 .72rem/16px var(--sans); color: var(--ink); }
.leyenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.selector-vista { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.selector-vista button { border: 0; background: var(--surface); color: var(--muted); padding: .45em .9em; font: 600 .88rem var(--sans); cursor: pointer; }
.selector-vista button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- Visual: composición porcentual ---------- */
.composicion { display: flex; height: 34px; border-radius: 9px; overflow: hidden; margin: 10px 0; box-shadow: inset 0 0 0 1px var(--line); }
.composicion div { display: grid; place-items: center; color: #fff; font: 700 .8rem var(--sans); min-width: 2px; transition: flex-grow .6s ease; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); overflow: hidden; }
.masa-grande { font-family: var(--serif); font-size: clamp(2rem, 8vw, 3rem); font-weight: 700; line-height: 1.1; }
.masa-grande small { font-size: .45em; color: var(--muted); font-weight: 400; }

/* ---------- Formularios de estequiometría ---------- */
.ec-balanceada { margin: 10px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line); font-family: var(--serif); font-size: 1.15rem; overflow-wrap: anywhere; }
.ec-balanceada:empty { display: none; }
.ec-balanceada .coef { color: var(--copper); font-weight: 700; }
.ec-balanceada.error { font-family: var(--sans); font-size: .92rem; color: var(--error); background: var(--error-soft); border-style: solid; }
.rejilla { display: grid; gap: 12px; margin-top: 14px; }
@media (min-width: 640px) { .rejilla.dos { grid-template-columns: 1fr 1fr; } }
.grupo { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.grupo legend, .grupo .titulo-grupo { font-weight: 700; padding: 0 4px; font-size: .95rem; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.fila label { font-size: .9rem; color: var(--muted); }
.fila .nombre-esp { font-family: var(--serif); font-size: 1.1rem; min-width: 84px; }
input.num, select.sel {
  font: 1rem var(--sans); padding: 10px 12px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); min-height: 44px;
}
input.num { width: 9.5em; }
select.sel { max-width: 100%; }
input.num:focus, select.sel:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select.sel.esp { font-family: var(--serif); font-size: 1.05rem; }
.opcional { font-weight: 400; color: var(--muted); font-size: .85rem; }

/* Fracciones de los factores de conversión */
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .25em; font-size: .92em; }
.frac > span { padding: 0 .35em; white-space: nowrap; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; }
.cadena { font-family: var(--serif); font-size: 1.05rem; line-height: 2.6; overflow-x: auto; white-space: nowrap; padding: 4px 0; }
.cadena .x { color: var(--muted); margin: 0 .1em; }
.cadena .res { color: var(--copper); font-weight: 700; }
.cadena-notas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cadena-notas span { font-size: .8rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; }

/* Mapa de conversión: masa ↔ moles ↔ partículas */
.mapa { display: grid; grid-template-columns: 1fr 70px 1fr; gap: 10px 0; align-items: center; margin-top: 8px; }
.mapa .col-t { text-align: center; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; }
.mapa .caja { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; text-align: center; font-size: .9rem; color: var(--muted); background: var(--surface-2); transition: .4s; }
.mapa .caja b { display: block; color: var(--ink); font-size: .95rem; }
.mapa .caja.ruta { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.mapa .caja.inicio { border-color: var(--reac); box-shadow: 0 0 0 3px color-mix(in srgb, var(--reac) 25%, transparent); }
.mapa .caja.fin { border-color: var(--prod); box-shadow: 0 0 0 3px color-mix(in srgb, var(--prod) 25%, transparent); }
.mapa .puente { text-align: center; font-size: .75rem; color: var(--muted); line-height: 1.2; }
.mapa .puente .flecha { display: block; font-size: 1.4rem; color: var(--line); }
.mapa .puente.ruta .flecha { color: var(--accent); }
.mapa .vacio { visibility: hidden; }

/* Reactivo limitante */
.alcance { display: grid; gap: 12px; margin-top: 10px; }
.alcance-fila { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: center; }
.alcance-fila .nom { font-family: var(--serif); font-size: 1.05rem; text-align: right; }
.alcance-fila .pista { height: 26px; border-radius: 8px; background: var(--surface-2); position: relative; overflow: hidden; border: 1px solid var(--line); }
.alcance-fila .pista i { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--reac) 75%, transparent); transition: width .8s cubic-bezier(.2, .8, .2, 1); }
.alcance-fila.lim .pista i { background: var(--copper); }
.alcance-fila .pista span { position: absolute; left: 8px; top: 0; font: 600 .78rem/26px var(--sans); color: var(--ink); }
.alcance-fila.lim .nom::after { content: " ★"; color: var(--copper); }
.consumo { display: flex; height: 100%; }
.uso { display: grid; gap: 10px; margin-top: 10px; }
.uso-fila { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: center; }
.uso-fila .nom { font-family: var(--serif); text-align: right; }
.uso-fila .pista { display: flex; height: 22px; border-radius: 7px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.uso-fila .pista i { display: block; height: 100%; transition: width .8s ease; }
.uso-fila .usado { background: var(--accent); }
.uso-fila .sobra { background: repeating-linear-gradient(45deg, color-mix(in srgb, var(--copper) 55%, transparent) 0 6px, color-mix(in srgb, var(--copper) 30%, transparent) 6px 12px); }
.resumen { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-top: 14px; }
.resumen div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: left; }
.resumen small { display: block; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.resumen b { font-family: var(--serif); font-size: 1.2rem; }

/* ---------- Tabla periódica ---------- */
.tp-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.tp { display: grid; grid-template-columns: repeat(18, minmax(34px, 1fr)); gap: 3px; min-width: 660px; }
.tp button {
  aspect-ratio: 1 / 1.1; border: 1px solid color-mix(in srgb, var(--cat) 45%, var(--line)); border-radius: 6px;
  background: color-mix(in srgb, var(--cat) 16%, var(--surface)); color: var(--ink); cursor: pointer; padding: 2px 0 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; font-family: var(--sans);
  transition: transform .12s ease, box-shadow .12s ease;
}
.tp button:hover, .tp button:focus-visible { transform: scale(1.18); z-index: 2; position: relative; box-shadow: var(--shadow); background: color-mix(in srgb, var(--cat) 32%, var(--surface)); }
.tp button.activo { background: var(--cat); color: #fff; border-color: var(--cat); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--cat); }
.tp .z { font-size: .55rem; opacity: .75; }
.tp .s { font-size: .95rem; font-weight: 700; }
.tp .hueco { grid-column: 3; font-size: .6rem; color: var(--muted); display: grid; place-items: center; }
.tp-sep { grid-column: 1 / -1; height: 8px; }
.tp-info { min-height: 3.2em; margin-top: 10px; font-size: .95rem; color: var(--muted); }
.tp-info b { color: var(--ink); font-family: var(--serif); font-size: 1.1rem; }
.tp-leyenda { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.tp-leyenda span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--cat); margin-right: 5px; vertical-align: -1px; }

/* ---------- Historial ---------- */
.historial ol { list-style: none; margin: 0; padding: 0; }
.historial li { border-bottom: 1px solid var(--line); }
.historial li:last-child { border-bottom: 0; }
.historial ol button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: baseline; background: none; border: 0; padding: 9px 4px; color: var(--ink); cursor: pointer; font: 1rem var(--serif); }
.historial ol button:hover { color: var(--accent); }
@media (max-width: 480px) { .res-acciones .btn { min-height: 40px; padding: 0 12px; font-size: .9rem; } }
.historial .tag { flex: none; font: 600 .7rem var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
.historial .vacio { color: var(--muted); font-size: .95rem; }
.cab-historial { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cab-historial h2 { flex: 1; }
.btn-texto { background: none; border: 0; color: var(--muted); cursor: pointer; font: .88rem var(--sans); text-decoration: underline; }

/* ---------- Contenido ---------- */
.contenido { max-width: 72ch; }
.contenido p, .contenido li { color: var(--ink); }
.nota { border-left: 4px solid var(--copper); background: var(--copper-soft); padding: 10px 14px; border-radius: 0 10px 10px 0; }
.faq details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin: 8px 0; }
.faq summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style: none; position: relative; padding-right: 40px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 16px; top: 9px; font-size: 1.3rem; color: var(--accent); }
.faq details[open] summary::after { content: "−"; }
.faq details > div { padding: 0 16px 12px; }
.guia li details { margin: 6px 0 12px; border-left: 3px solid var(--line); padding-left: 12px; }
.guia li summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .95rem; width: fit-content; }
.guia li details[open] { border-left-color: var(--accent); }
.guia li details p { margin: 6px 0 0; }
.guia li > span.formula-paso { display: block; margin-top: 4px; }
.relacionadas { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.relacionadas a { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.relacionadas a:hover { border-color: var(--accent); }
.relacionadas strong { display: block; font-family: var(--serif); color: var(--accent); margin-bottom: 2px; }
.relacionadas span { font-size: .9rem; color: var(--muted); }

/* ---------- Inicio ---------- */
.portada { display: grid; gap: 20px; align-items: center; padding: 30px 0 10px; }
@media (min-width: 820px) { .portada { grid-template-columns: 1.4fr 1fr; padding-top: 44px; } }
.portada h1 { font-size: clamp(1.9rem, 5.4vw, 2.9rem); margin-top: 0; }
.portada-arte { display: none; }
@media (min-width: 820px) { .portada-arte { display: block; } }
.balanza { width: 100%; max-width: 340px; margin: 0 auto; display: block; }
.balanza .viga { transform-origin: 160px 70px; animation: equilibrar 3.2s ease-in-out 1 forwards; }
@keyframes equilibrar { 0% { transform: rotate(-9deg); } 35% { transform: rotate(6deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(1deg); } 100% { transform: rotate(0); } }
.rapido { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); }
.buscador input { width: 100%; font: 1.05rem var(--sans); padding: 12px 14px 12px 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 13px center / 20px; color: var(--ink); }
.buscador input:focus { outline: none; border-color: var(--accent); }
.herramientas { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 14px; }
.herr { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease; }
.herr:hover { transform: translateY(-3px); border-color: var(--accent); color: var(--ink); }
.herr strong { font-family: var(--serif); font-size: 1.2rem; }
.herr span:last-child { color: var(--muted); font-size: .94rem; }
.herr-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font: 700 1.4rem var(--serif); color: #fff; background: var(--c); }
.sin-resultados { color: var(--muted); }
.tres { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tres > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tres b { font-family: var(--serif); font-size: 1.1rem; }
.tres p { margin: .4em 0 0; color: var(--muted); font-size: .95rem; }
[hidden] { display: none !important; }

/* ---------- Guías y páginas de texto ---------- */
.guia { padding-bottom: 10px; }
.guia .meta-guia { color: var(--muted); font-size: .9rem; margin: 0 0 18px; }
.guia h2 { scroll-margin-top: 76px; }
.indice { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 18px; margin: 18px 0; }
.indice ol { margin: 6px 0 0; padding-left: 20px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; background: linear-gradient(135deg, var(--accent-soft), var(--copper-soft)); border-radius: 14px; padding: 16px 18px; margin: 26px 0; }
.cta p { margin: 0; font-weight: 600; }
.glosario dt { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; margin-top: 18px; scroll-margin-top: 76px; }
.glosario dd { margin: 4px 0 0; }
.letras { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 20px; }
.letras a { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; background: var(--surface); }
.legal h2 { font-size: 1.3rem; }
.completar { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 4px; font-weight: 600; }

/* Formulario de contacto */
.form-contacto { display: grid; gap: 14px; max-width: 620px; }
.form-contacto label { font-weight: 600; display: block; margin-bottom: 4px; }
.form-contacto input:not([type="checkbox"]), .form-contacto select, .form-contacto textarea {
  width: 100%; font: 1rem var(--sans); padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.form-contacto textarea { min-height: 150px; resize: vertical; }
.form-contacto [aria-invalid="true"] { border-color: var(--error); }
.form-contacto .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.form-contacto .check input { margin-top: 5px; width: 18px; height: 18px; }
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.cf-status { border-radius: 10px; padding: 10px 14px; }
.cf-status.ok { background: var(--ok-soft); color: var(--ok); }
.cf-status.bad { background: var(--error-soft); color: var(--error); }
.contador { font-size: .82rem; color: var(--muted); text-align: right; }

/* ---------- Anuncios: el espacio solo se reserva cuando AdSense está activo ---------- */
.ad-slot { display: none; }
.ads-on .ad-slot { display: block; margin: 22px auto; width: 100%; }
.ads-on .ad-arriba { min-height: 100px; }
.ads-on .ad-resultado { min-height: 280px; }
.ads-on .ad-final { min-height: 280px; }

/* ---------- Pie ---------- */
.pie { margin-top: 48px; border-top: 1px solid var(--line); background: var(--surface); padding: 26px 0; font-size: .92rem; color: var(--muted); }
.pie nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.pie a { color: var(--muted); }
.pie p { margin: .3em 0; }

/* Aviso flotante */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 600; transition: .25s; pointer-events: none; z-index: 20; }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }

.solo-impresion { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
