:root {
  --fondo: #ffffff;
  --papel: #f7f6f3;
  --tinta: #111110;
  --suave: #5f5e5a;
  --linea: #d6d3ca;
  --acento: #c1d120;
  --sobre-acento: #111110;
  --error: #b3261e;
  --radio: 14px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--tinta);
  font: 400 1rem/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 3px; }
h1:focus { outline: none; }

/* Cabecera y progreso */
.cab { position: sticky; top: 0; z-index: 2; background: var(--fondo); }
.cab-in {
  display: flex; align-items: center; gap: 1rem;
  max-width: 760px; margin: 0 auto; padding: .9rem 1.25rem .7rem;
  font-size: .85rem;
}
.cab-n { font-weight: 600; }
.cab-t { margin-left: auto; font-family: var(--mono); font-size: .8rem; color: var(--suave); }
.enlace { background: none; border: 0; padding: .25rem 0; text-decoration: underline; text-underline-offset: 3px; color: var(--suave); }
.enlace:hover { color: var(--tinta); }
.progreso { display: flex; gap: 6px; max-width: 760px; margin: 0 auto; padding: 0 1.25rem; }
.seg-p { flex: 1; height: 4px; background: var(--linea); border-radius: 4px; overflow: hidden; }
.seg-p i { display: block; height: 100%; background: var(--acento); border-radius: 4px; transition: width .45s cubic-bezier(.2, .7, .2, 1); }

/* Hoja */
.hoja { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.25rem 8rem; }
.hoja.sig { animation: entra-sig .35s cubic-bezier(.2, .7, .2, 1); }
.hoja.ant { animation: entra-ant .35s cubic-bezier(.2, .7, .2, 1); }
@keyframes entra-sig { from { opacity: 0; transform: translateY(18px); } }
@keyframes entra-ant { from { opacity: 0; transform: translateY(-18px); } }

.meta { margin: 0 0 1.5rem; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--suave); }
.num { margin: 0 0 .6rem; font-family: var(--mono); font-size: .85rem; color: var(--acento); }
.num.grande { font-size: clamp(4rem, 18vw, 7rem); line-height: 1; letter-spacing: -.04em; margin-bottom: 1rem; }
h1 { margin: 0 0 .75rem; font-size: clamp(1.6rem, 5.2vw, 2.5rem); line-height: 1.12; font-weight: 500; letter-spacing: -.025em; text-wrap: balance; }
h2 { margin: 0 0 .5rem; font-size: 1.35rem; font-weight: 500; letter-spacing: -.015em; }
.ayuda { margin: 0 0 2rem; color: var(--suave); max-width: 56ch; }
.lead { margin: 0 0 1rem; font-size: 1.1rem; max-width: 58ch; }
.datos { margin: 1.25rem 0 0; font-family: var(--mono); font-size: .8rem; color: var(--suave); }
.nota { margin-top: 2.5rem; font-size: .85rem; color: var(--suave); }
.error { min-height: 1.5rem; margin: 1rem 0 0; color: var(--error); font-weight: 500; }

/* Botones */
.pri, .sec {
  min-height: 48px; padding: .7rem 1.4rem; border-radius: 999px;
  border: 1.5px solid var(--tinta); font-weight: 500;
  transition: transform .12s, background .15s, color .15s;
}
.pri { background: var(--tinta); color: var(--papel); }
.pri:hover { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); }
.sec { background: transparent; }
.sec:hover { background: var(--tinta); color: var(--papel); }
.pri:active, .sec:active, .op:active { transform: scale(.98); }
.sec:disabled { opacity: .35; cursor: default; background: transparent; color: inherit; }
.acciones { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }

/* Opciones como tarjetas */
.ops { display: grid; gap: .6rem; }
.op {
  display: flex; align-items: center; gap: .8rem; text-align: left;
  min-height: 56px; padding: .85rem 1.1rem;
  background: var(--papel); border: 1.5px solid var(--linea); border-radius: var(--radio);
  transition: border-color .15s, background .15s, color .15s, transform .12s;
}
.op:hover { border-color: var(--tinta); }
.op.on { background: var(--tinta); border-color: var(--tinta); color: var(--papel); }
.pos {
  flex: none; display: grid; place-items: center; width: 1.75rem; height: 1.75rem;
  border: 1.5px solid var(--linea); border-radius: 50%; font-family: var(--mono); font-size: .8rem;
}
.op.on .pos { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); }

/* Escala */
.escala { display: grid; gap: .4rem; }
.escala.e5 { grid-template-columns: repeat(5, 1fr); }
.escala.e10 { grid-template-columns: repeat(5, 1fr); }
.escala .op, .seg.num .op { justify-content: center; padding: .5rem; font-family: var(--mono); font-size: 1.05rem; }
.extremos { display: flex; justify-content: space-between; margin-top: .6rem; font-size: .85rem; color: var(--suave); }

/* Texto */
.texto {
  width: 100%; min-height: 56px; padding: .9rem 1.1rem;
  background: var(--papel); border: 1.5px solid var(--linea); border-radius: var(--radio);
}
.texto:hover { border-color: var(--suave); }
.texto:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acento) 20%, transparent); }
textarea.texto { resize: vertical; line-height: 1.5; }
.otra { margin-top: .6rem; }

/* Números y porcentajes */
.numeros { display: grid; gap: .6rem; }
.numeros label {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .5rem .6rem .5rem 1.1rem; background: var(--papel);
  border: 1.5px solid var(--linea); border-radius: var(--radio);
}
.numeros input {
  width: 5.5rem; min-height: 44px; padding: .4rem .6rem; text-align: right;
  font-family: var(--mono); background: var(--fondo); border: 1.5px solid transparent; border-radius: 10px;
}
.numeros input:focus { outline: none; border-color: var(--acento); }
.suma { margin: .9rem 0 0; font-family: var(--mono); font-size: .9rem; color: var(--suave); }

/* Matriz y herramientas */
.fila { padding: 1.1rem 0; border-top: 1px solid var(--linea); }
.fila:first-child { border-top: 0; padding-top: 0; }
.t-herramientas .fila { margin-top: 1.25rem; padding-bottom: 0; }
.t-herramientas .fila:first-child { border-top: 1px solid var(--linea); padding-top: 1.1rem; }
.fila-t { margin: 0 0 .6rem; font-weight: 600; }
.mini { margin: .8rem 0 .4rem; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--suave); }
.seg, .chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg .op, .chips .op { min-height: 44px; padding: .5rem .95rem; border-radius: 999px; font-size: .95rem; }
.seg.num .op { min-width: 44px; padding: .4rem; }
.nueva { display: flex; gap: .5rem; margin-top: .8rem; }
.nueva .texto { min-height: 48px; }

/* Lista de filas */
.lfila { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.lfila > .texto { flex: 1; min-width: 0; }
.lfila > .seg, .lfila > .mini { flex-basis: 100%; }
.lfila > .mini { margin: .5rem 0 0; }
.lfila + .lfila { padding-top: 1.5rem; border-top: 1px solid var(--linea); }
select.texto { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--tinta) 50%), linear-gradient(135deg, var(--tinta) 50%, transparent 50%); background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2.5rem; }

/* Pie de navegación */
.pie { position: fixed; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, var(--fondo) 70%, transparent); padding-top: 1.5rem; }
.pie-in { display: flex; justify-content: space-between; gap: .75rem; max-width: 760px; margin: 0 auto; padding: 0 1.25rem 1.1rem; }
.pie .pri { min-width: 9.5rem; }

/* Inicio */
.inicio { padding-top: 4rem; padding-bottom: 3rem; }
.inicio h1 { font-size: clamp(2.4rem, 9vw, 4.2rem); margin-bottom: 1.25rem; }
.tarjetas { display: grid; gap: 1rem; margin-top: 2.5rem; }
.tarjeta { padding: 1.5rem; background: var(--papel); border: 1.5px solid var(--linea); border-radius: 20px; transition: border-color .2s, transform .2s; }
.tarjeta:hover { border-color: var(--tinta); transform: translateY(-2px); }
.tarjeta .meta { margin-bottom: .8rem; }
.tarjeta p { margin: 0; color: var(--suave); }

/* Resumen final */
.res { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1.5px solid var(--tinta); }
.res dl { margin: 1rem 0 0; }
.res dt { margin-top: 1.1rem; font-size: .9rem; color: var(--suave); }
.res dd { margin: .2rem 0 0; overflow-wrap: anywhere; }

@media (min-width: 640px) {
  .hoja { padding-top: 4rem; }
  .ops { grid-template-columns: 1fr 1fr; }
  .escala.e10 { grid-template-columns: repeat(10, 1fr); }
  .numeros { grid-template-columns: 1fr 1fr; }
  .tarjetas { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

/* Móvil: estructura de app (barra fija arriba, contenido con scroll propio, barra de acción abajo) */
@media (max-width: 639px) {
  html.app, html.app body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  body { -webkit-tap-highlight-color: transparent; }
  button { -webkit-user-select: none; user-select: none; touch-action: manipulation; }
  #app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

  .cab { position: static; flex: none; padding: env(safe-area-inset-top) 0 .7rem; border-bottom: 1px solid var(--linea); }
  .cab-in { display: grid; grid-template-columns: 1fr auto 1fr; padding: .8rem 1rem .65rem; }
  .cab-in .enlace { justify-self: start; text-decoration: none; min-height: 32px; }
  .cab-t { justify-self: end; margin: 0; }
  .progreso { padding: 0 1rem; gap: 4px; }

  .hoja { flex: 1; width: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 1.5rem 1rem 2rem; }
  .hoja.sig { animation: empuja-sig .28s cubic-bezier(.2, .7, .2, 1); }
  .hoja.ant { animation: empuja-ant .28s cubic-bezier(.2, .7, .2, 1); }
  .meta { margin-bottom: 1rem; }
  .ayuda { margin-bottom: 1.5rem; }

  .pie { position: static; flex: none; padding: .7rem 0 0; background: var(--papel); border-top: 1px solid var(--linea); }
  .pie-in { padding: 0 1rem calc(.7rem + env(safe-area-inset-bottom)); }
  .pie .pri { flex: 1; min-height: 52px; }
  .pie .sec { flex: none; min-height: 52px; }

  .inicio { padding-top: calc(2.5rem + env(safe-area-inset-top)); padding-bottom: calc(2rem + env(safe-area-inset-bottom)); }
  .tarjetas { margin-top: 1.75rem; }
  .tarjeta .acciones, .hoja > .acciones { flex-direction: column; }
  .acciones > button { width: 100%; min-height: 52px; }
  .hoja > .acciones { margin-top: 2rem; padding-bottom: env(safe-area-inset-bottom); }
}
@keyframes empuja-sig { from { opacity: 0; transform: translateX(32px); } }
@keyframes empuja-ant { from { opacity: 0; transform: translateX(-32px); } }

/* Pantallas táctiles: el hover no debe quedarse pegado tras tocar */
@media (hover: none) {
  .op:hover { border-color: var(--linea); }
  .op.on:hover { border-color: var(--tinta); }
  .pri:hover { background: var(--tinta); border-color: var(--tinta); color: var(--papel); }
  .sec:hover { background: transparent; color: inherit; }
  .tarjeta:hover { border-color: var(--linea); transform: none; }
  .texto:hover { border-color: var(--linea); }
}

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

@media print {
  .cab, .pie, .acciones { display: none; }
  body { background: #fff; }
  html.app, html.app body, #app, .hoja { height: auto; overflow: visible; display: block; }
}

/* Sistema: logo, portada, estado de guardado y enlace personal */
.logo { display: block; max-height: 48px; max-width: 200px; margin-bottom: 1.75rem; }
.cab .logo { max-height: 24px; max-width: 110px; margin: 0; }
.cab-m { display: flex; align-items: center; min-height: 32px; font-size: .8rem; color: var(--suave); }
.estado { font-family: var(--mono); font-size: .72rem; color: var(--suave); }
.estado.mal { color: var(--error); }
.portada .texto { margin-top: 1.5rem; }
.portada .acciones { margin-top: 1rem; }
.personal { margin-top: 2rem; padding: 1rem 1.1rem; border: 1.5px dashed var(--linea); border-radius: var(--radio); font-size: .9rem; color: var(--suave); }
.personal .sec { min-height: 40px; padding: .4rem 1rem; margin-top: .6rem; font-size: .9rem; }
a.boton { display: inline-flex; align-items: center; text-decoration: none; }

/* Icono de cada tarjeta de respuesta */
.ico { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
.op.on .ico { opacity: 1; }
.ops .op .pos { margin-left: auto; }

/* Marca Casupo: lima de acento (como el punto del logo) y el texto en negro para que siempre se lea */
:focus-visible { outline-color: var(--tinta); }
.texto:focus { border-color: var(--tinta); }
.num { color: var(--suave); }
.num::before { content: ""; display: inline-block; width: .55em; height: .55em; margin-right: .5em; border-radius: 50%; background: var(--acento); }
.num.grande { color: var(--tinta); }
.num.grande::before { display: none; }
.num.grande::after { content: "."; color: var(--acento); }
.hoja > .meta::before { content: ""; display: inline-block; width: 18px; height: 3px; margin-right: .6rem; vertical-align: middle; background: var(--acento); }
.animo { margin: 1.25rem 0 0; font-weight: 500; }
.animo::before { content: ""; display: inline-block; width: .5em; height: .5em; margin-right: .5em; border-radius: 50%; background: var(--acento); }
.inicio .logo { max-height: 56px; }

/* Los botones son siempre planos: sin sombras ni relieves */
.pri, .sec, .pri:hover, .sec:hover, .pri:active, .sec:active { box-shadow: none; background-image: none; }

/* Pantalla de bienvenida: recomendaciones antes de empezar */
.puntos { margin: 1.5rem 0 0; padding: 0; list-style: none; max-width: 58ch; display: grid; gap: .9rem; }
.puntos li { position: relative; padding-left: 1.4rem; }
.puntos li::before { content: ""; position: absolute; left: 0; top: .55em; width: .5em; height: .5em; border-radius: 50%; background: var(--acento); }

/* Escritorio: el formulario ocupa un poco más de ancho */
@media (min-width: 1000px) {
  .cab-in, .progreso, .hoja, .pie-in { max-width: 960px; }
  .ayuda, .lead, .puntos { max-width: 66ch; }
}
