:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #5f6368;
  --border: #dcdad5;
  --accent: #2f5d62;
  --accent-text: #ffffff;
  --accent-soft: #e3eeee;
  --warn: #9a3412;
  --warn-soft: #fdecde;
  --ok: #166534;
  --ok-soft: #e2f3e6;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151617;
    --surface: #1f2123;
    --text: #ececec;
    --muted: #a3a7ab;
    --border: #383b3e;
    --accent: #7fb7bd;
    --accent-text: #0f1a1b;
    --accent-soft: #23393b;
    --warn: #fdba8c;
    --warn-soft: #3b2418;
    --ok: #86efac;
    --ok-soft: #173222;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 820px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.sub { color: var(--muted); margin-bottom: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
label.field { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="number"], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { min-height: 70px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin-top: 6px; }
button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Ítems */
.item { border-top: 1px solid var(--border); padding: 14px 0; }
.item:first-of-type { border-top: 0; padding-top: 0; }
.item.missing .item-text { color: var(--warn); }
.item-text { font-weight: 600; margin-bottom: 2px; }
.item-text .num { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; }
.item-help { color: var(--muted); font-size: 0.875rem; margin-bottom: 8px; }
.opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.opts label {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 6px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.85rem; line-height: 1.2; cursor: pointer; background: var(--bg);
}
.opts input { position: absolute; opacity: 0; pointer-events: none; }
.opts input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.opts input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 520px) {
  .opts { grid-template-columns: repeat(2, 1fr); }
}

.progress { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
.bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.progress small { color: var(--muted); }

.notice { border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 0.925rem; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.info { background: var(--accent-soft); color: var(--text); }

/* Corrector */
.drop {
  display: block; margin-bottom: 16px;
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 16px;
  text-align: center; color: var(--muted); cursor: pointer; background: var(--surface);
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.n, th.n { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.tag.hi { background: var(--warn-soft); color: var(--warn); }
.tag.lo { background: var(--ok-soft); color: var(--ok); }
.tag.eq { background: var(--accent-soft); color: var(--text); }
.result-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 12px; }
.ref { font-size: 1.3rem; font-weight: 700; }
.meter { height: 8px; background: var(--border); border-radius: 4px; position: relative; min-width: 80px; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 4px; }
.meter > i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin: 8px 0; }
.manual-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; }
.manual-grid label { font-size: 0.8rem; color: var(--muted); display: block; }
.manual-grid input { padding: 6px 8px; text-align: center; }
.medians { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
footer { color: var(--muted); font-size: 0.8rem; margin-top: 24px; }

@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
  .card { border: 0; padding: 0; break-inside: avoid; }
  details { display: block; }
  details > * { display: block; }
}

/* STAI */
.two { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-top: 14px; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
span.field { display: block; font-weight: 600; margin-bottom: 6px; }
.opts.opts-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 520px) { .opts.opts-3 { grid-template-columns: repeat(3, 1fr); } }
.instr { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 0.95rem; }
.big { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.manual-grid input.blank { border-style: dashed; }
