@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --papel: #ffffff;        /* fondo */
  --hoja: #ffffff;         /* la hoja */
  --tinta: #18202c;        /* texto */
  --grafito: #5b6576;      /* texto secundario */
  --linea: #d5dbe3;
  --fluor: rgba(250, 214, 0, .55);   /* respuesta detectada */
  --fluor-solido: #f2cf00;
  --correccion: rgba(44, 115, 235, .38); /* corregida por el usuario */
  --correccion-solido: #2c73eb;
  --revisar: #d6336c;      /* aviso */
  --ok: #1d7f55;
  --boton: #18202c;
  --boton-texto: #ffffff;
  --radio: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Atkinson", system-ui, -apple-system, sans-serif;
  font-size: 17px; line-height: 1.45; color: var(--tinta); background: var(--papel);
  -webkit-text-size-adjust: 100%; font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--correccion-solido); outline-offset: 2px; }

body { min-height: 100vh; display: flex; flex-direction: column; }
.app { width: 100%; max-width: 620px; margin: 0 auto; padding: 0 16px 24px; flex: 1; }

/* pie */
.foot { width: 100%; max-width: 620px; margin: 0 auto; padding: 16px 16px 24px; border-top: 1px solid var(--linea); font-size: 14px; color: var(--grafito); }
.foot p { margin: 0 0 6px; }
.foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.foot a, .link { color: var(--tinta); text-decoration: underline; text-underline-offset: 3px; }
body.has-bar .foot { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.link { display: inline-block; margin-top: 18px; font-size: 16px; }
.top .link { margin: 0; }

/* inicio */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; border-radius: 12px; background: #f1f3f6; margin: 18px 0 14px; }
.seg button { appearance: none; border: 0; border-radius: 9px; padding: 12px 6px; background: transparent; font-weight: 700; font-size: 16px; color: var(--grafito); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--hoja); color: var(--tinta); box-shadow: 0 1px 3px rgba(24, 32, 44, .18); }
.btn.big { padding: 20px 18px; font-size: 19px; border-radius: 12px; }
.list-title { font-size: 15px; font-weight: 700; color: var(--grafito); margin: 36px 0 0; }
.list .state .gap { width: 6px; }
.tip { margin-top: 22px; }

/* textos legales */
.legal { font-size: 16px; }
.legal .lead { font-size: 18px; }
.legal h2 { font-size: 18px; margin: 26px 0 8px; }
.legal p, .legal li { color: var(--tinta); }
.legal ul { padding-left: 20px; }
.legal li { margin-bottom: 6px; }
.legal a { color: var(--tinta); }

/* cabecera */
.top { display: flex; align-items: center; gap: 12px; padding: 14px 0 10px; min-height: 56px; }
.top h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; flex: 1; display: flex; align-items: center; gap: 10px; }
.top h1 .logo { width: 26px; height: 26px; }
.back { text-decoration: none; background: none; border: 0; padding: 8px 10px 8px 0; font-size: 17px; color: var(--grafito); cursor: pointer; }
.top .sub { color: var(--grafito); font-size: 15px; }

.engine { font-size: 14px; color: var(--grafito); display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.engine .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fluor-solido); }
.engine.ready .dot { background: var(--ok); }
.engine.error .dot { background: var(--revisar); }

/* botones */
.btn { appearance: none; border: 0; border-radius: var(--radio); padding: 14px 18px; font-weight: 700; font-size: 17px;
  background: var(--boton); color: var(--boton-texto); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--tinta); box-shadow: inset 0 0 0 1.5px var(--linea); }
.btn.danger { background: transparent; color: var(--revisar); box-shadow: inset 0 0 0 1.5px var(--revisar); }
.btn.danger.wide { margin-top: 28px; }
.btn:disabled { opacity: .4; cursor: default; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns .btn { flex: 1 1 0; min-width: 140px; }

/* lista de evaluaciones */
.list { list-style: none; margin: 8px 0 0; padding: 0; }
.list li { border-top: 1px solid var(--linea); }
.list li:last-child { border-bottom: 1px solid var(--linea); }
.list a { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 2px; text-decoration: none; color: inherit; }
.list .pid { font-weight: 700; font-size: 19px; }
.list .meta { color: var(--grafito); font-size: 15px; grid-column: 1; }
.list .state { grid-row: 1 / span 2; grid-column: 2; align-self: center; display: flex; gap: 6px; }
.empty { padding: 36px 4px; color: var(--grafito); }
.empty strong { color: var(--tinta); display: block; font-size: 19px; margin-bottom: 4px; }

/* miniaturas de hoja: el estado de cada página */
.sheet-mini { width: 22px; height: 31px; border-radius: 2px; background: var(--hoja); box-shadow: inset 0 0 0 1.5px var(--linea); position: relative; }
.sheet-mini.ok { box-shadow: inset 0 0 0 1.5px var(--ok); }
.sheet-mini.ok::after { content: ""; position: absolute; left: 4px; right: 4px; top: 12px; height: 6px; background: var(--fluor); transform: skewX(-12deg); }
.sheet-mini.rev { box-shadow: inset 0 0 0 2px var(--revisar); }

/* formulario */
.field { display: block; margin: 0 0 16px; }
.field span { display: block; font-size: 15px; color: var(--grafito); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 13px 14px; border-radius: var(--radio); border: 1.5px solid var(--linea); background: var(--hoja); color: #18202c; font-size: 18px; }
.field input:focus { border-color: var(--correccion-solido); outline: none; }
.hint { font-size: 14px; color: var(--grafito); margin: -8px 0 16px; }

/* evaluación: páginas */
.instrument { margin: 22px 0 8px; }
.instrument h2 { font-size: 17px; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.instrument h2 small { font-weight: 400; color: var(--grafito); font-size: 15px; }
.capture-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--papel) 70%, transparent); }
.capture-bar .inner { max-width: 620px; margin: 0 auto; display: flex; gap: 10px; }
.capture-bar .btn { flex: 1; }
.capture-bar .btn.ghost { flex: 0 0 auto; background: var(--papel); }

/* revisión */
.sheet-wrap { position: relative; margin: 4px -16px 0; background: var(--hoja); }
.sheet-wrap canvas { width: 100%; display: block; touch-action: manipulation; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--grafito); margin: 10px 0 4px; }
.legend i { display: inline-block; width: 18px; height: 10px; vertical-align: -1px; margin-right: 5px; transform: skewX(-12deg); }
.legend .d { background: var(--fluor); } .legend .c { background: var(--correccion); } .legend .r { background: none; box-shadow: inset 0 0 0 2px var(--revisar); }

.flags { margin: 18px 0; }
.flags h3 { font-size: 17px; margin: 0 0 4px; }
.flags p { margin: 0 0 12px; color: var(--grafito); font-size: 15px; }
.flag { padding: 12px 0; border-top: 1px solid var(--linea); }
.flag .q { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.flag .q b { font-size: 17px; }
.flag .q span { color: var(--revisar); font-size: 14px; }
.flag.done .q span { color: var(--ok); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-width: 46px; padding: 10px 12px; border-radius: 8px; border: 1.5px solid var(--linea); background: var(--hoja); color: #18202c; font-weight: 700; cursor: pointer; }
.chip.on { background: var(--correccion-solido); border-color: var(--correccion-solido); color: #fff; }
.chip.blank { font-weight: 400; }

.vas-box { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; margin: 18px 0; }
.vas-box img { width: 120px; border-radius: 6px; box-shadow: 0 0 0 1.5px var(--linea); background: #fff; }
.vas-box input { font-size: 28px; font-weight: 700; width: 100%; padding: 10px 12px; border-radius: var(--radio); border: 1.5px solid var(--linea); background: var(--hoja); color: #18202c; }
.vas-box .note { font-size: 14px; color: var(--grafito); grid-column: 1 / -1; margin-top: -6px; }

.answers { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 15px; }
.answers td { padding: 6px 4px; border-top: 1px solid var(--linea); }
.answers td:last-child { text-align: right; font-weight: 700; }
.answers tr.edited td:last-child { color: var(--correccion-solido); }
.answers tr.blank td:last-child { color: var(--grafito); font-weight: 400; }

.scores { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 2px 16px; margin: 6px 0 0; font-size: 15px; }
.scores div { display: flex; justify-content: space-between; border-top: 1px solid var(--linea); padding: 6px 0; }
.scores b { font-weight: 700; }

.section { margin-top: 28px; }
.section h2 { font-size: 19px; margin: 0 0 8px; }
.section p { color: var(--grafito); font-size: 15px; margin: 0 0 12px; }

/* overlay de procesamiento */
.busy { position: fixed; inset: 0; background: rgba(19, 24, 32, .72); display: grid; place-items: center; z-index: 20; color: #fff; text-align: center; padding: 24px; }
.busy .sheet-anim { width: 70px; height: 99px; background: #fff; border-radius: 3px; margin: 0 auto 18px; position: relative; overflow: hidden; }
.busy .sheet-anim::after { content: ""; position: absolute; left: -10%; right: -10%; height: 14px; background: var(--fluor); top: 0; animation: scan 1.4s ease-in-out infinite alternate; }
@keyframes scan { from { top: 6%; } to { top: 84%; } }
@media (prefers-reduced-motion: reduce) { .busy .sheet-anim::after { animation: none; top: 42%; } }

/* formulario: hojas leídas */
.sheet-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 10px 2px; border-top: 1px solid var(--linea); text-decoration: none; color: inherit; }
.sheet-row:last-of-type { border-bottom: 1px solid var(--linea); }
.sheet-row .thumb { width: 44px; aspect-ratio: 1 / 1.414; border-radius: 3px; overflow: hidden; background: var(--hoja); box-shadow: 0 0 0 1.5px var(--linea); }
.sheet-row .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sheet-row.ok .thumb { box-shadow: 0 0 0 2px var(--ok); }
.sheet-row.rev .thumb { box-shadow: 0 0 0 2.5px var(--revisar); }
.sheet-row .cap b { display: block; }
.sheet-row .cap em { font-style: normal; font-size: 15px; color: var(--grafito); }
.sheet-row.rev .cap em { color: var(--revisar); font-weight: 700; }
.sheet-row.ok .cap em { color: var(--ok); }
.sheet-row .chev { font-size: 24px; color: var(--grafito); }
.missing { font-size: 15px; color: var(--grafito); margin: 8px 0 0; }
.empty-hint { color: var(--grafito); margin: 28px 0; }

/* cámara en la app */
.cam { position: fixed; inset: 0; z-index: 25; background: #000; color: #fff; display: flex; flex-direction: column; }
.cam video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.cam-top { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.cam-pages { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-pages span { font-size: 14px; font-weight: 700; padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.18); }
.cam-pages span.ok { background: var(--ok); }
.cam-pages span.ok::before { content: "✓ "; }
.cam-done { appearance: none; border: 0; border-radius: 999px; padding: 9px 16px; font: inherit; font-weight: 700; background: #fff; color: #18202c; cursor: pointer; flex: none; }
.cam-bottom { padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.cam-msg { min-height: 1.45em; font-size: 16px; text-align: center; }
.cam-shutter { appearance: none; width: 76px; height: 76px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.cam-shutter:active { background: #fff; }
.cam-shutter:disabled { opacity: .4; }
.cam.flash video { animation: flash .25s ease-out; }
@keyframes flash { from { filter: brightness(2.2); } to { filter: none; } }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--tinta); color: var(--papel);
  padding: 12px 18px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); font-size: 15px; }
.error-box { border-left: 4px solid var(--revisar); padding: 10px 14px; background: var(--hoja); color: #18202c; margin: 12px 0; border-radius: 0 8px 8px 0; font-size: 15px; }
.muted { color: var(--grafito); font-size: 14px; }
.hidden { display: none !important; }
