:root {
  --bg: #f5f8fc;
  --card: #ffffff;
  --ink: #18263a;
  --muted: #4a5a70;
  --line: #dbe3ee;
  --accent: #2c5bd1;
  --accent-soft: #e8eefc;
  --error: #b3261e;
  --error-soft: #fbeae8;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.wrap { padding: 32px clamp(16px, 3vw, 48px) 64px; }

.masthead { margin-bottom: 20px; }
.eyebrow { margin: 0 0 6px; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.2; }
.inst { margin: 0; color: var(--muted); font-size: 15px; }
h2 { margin: 0 0 14px; font-size: 20px; }

.intro p { margin: 0 0 10px; }
.note { font-size: 14px; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 24px;
  margin: 18px 0;
}
.card.center { text-align: center; padding: clamp(40px, 6vw, 80px) 22px; margin-top: 12vh; }
.card.center h1 { font-family: "Literata", Georgia, serif; font-size: clamp(28px, 3vw, 44px); }
.card.center p { max-width: 60ch; margin: 12px auto 0; }

.field { margin-bottom: 18px; }
.field > label, .qlabel, .sub { display: block; font-weight: 600; margin-bottom: 6px; }
.sub { margin-top: 14px; font-size: 15px; }
.help { margin: 4px 0 8px; font-size: 14px; color: var(--muted); }

fieldset.q { border: 0; padding: 0; margin: 0; }
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.num { color: var(--accent); }

input[type="text"], select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #cfcac0;
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.options { display: grid; gap: 6px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-weight: 400;
}
.opt:hover { background: var(--accent-soft); }
.opt input { margin-top: 5px; accent-color: var(--accent); flex: none; width: 18px; height: 18px; }
.opt.disabled { opacity: .45; cursor: not-allowed; }
.consent { padding-left: 0; }

.enunciado { background: #faf9f6; border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 0 8px 8px 0; }
.enunciado p { margin: 0 0 10px; }
.enunciado p:last-child { margin-bottom: 0; }
.enunciado blockquote { margin: 10px 0; padding: 10px 14px; background: #fff; border: 1px dashed #cfcac0; border-radius: 8px; }
.afirmaciones { padding-left: 20px; }
.afirmaciones li { margin-bottom: 6px; }

table.datos { border-collapse: collapse; margin: 8px 0 12px; background: #fff; }
table.datos th, table.datos td { border: 1px solid var(--line); padding: 6px 16px; text-align: left; }
table.datos th { background: var(--accent-soft); }
table.datos td:last-child { text-align: right; }

.error { color: var(--error); font-size: 14px; margin: 6px 0 0; font-weight: 500; }
.alert { background: var(--error-soft); color: var(--error); border-radius: 8px; padding: 12px 16px; font-weight: 600; }

.actions { margin-top: 24px; text-align: center; }
button, .btn {
  display: inline-block; font: inherit; font-weight: 600;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 12px 28px; cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.1); }

/* Admin */
.admin-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.count { font-size: 16px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; vertical-align: middle; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { font-size: 14px; color: var(--muted); font-weight: 600; }
table.list th, table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; }
table.list tr:last-child td { border-bottom: 0; }
a { color: var(--accent); }
dl.answers dt { font-weight: 600; margin-top: 16px; }
dl.answers dd { margin: 4px 0 0; }
dl.answers ul { margin: 0; padding-left: 20px; }
.pre { white-space: pre-wrap; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  h1 { font-size: 23px; }
  .card { padding: 18px 14px; }
}

/* ================= Admin ================= */
.topnav { background: #18263a; color: #fff; }
.topnav-in { padding: 0 clamp(16px, 3vw, 48px); display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: center; min-height: 52px; }
.topnav .brand { font-weight: 700; margin-right: 12px; }
.topnav a { color: #d4d7dc; text-decoration: none; padding: 14px 0; border-bottom: 2px solid transparent; }
.topnav a:hover, .topnav a.on { color: #fff; border-bottom-color: #8fb0f5; }
.crumbs { margin: 0 0 8px; font-size: 15px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.ghost, button.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
button.small, .btn.small { padding: 6px 14px; font-size: 14px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 600; font-size: 14px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.card.compact { padding: 14px 18px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline-form select { width: auto; }
.inline-form .help { flex-basis: 100%; margin: 0; }
.tabs { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.tabs a { padding: 6px 14px; border-radius: 999px; text-decoration: none; background: #fff; border: 1px solid var(--line); font-size: 15px; }
.tabs a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; vertical-align: middle; }
.pill.inicial { background: #e8eefc; color: #1b3f99; }
.pill.final { background: #fdebd9; color: #8a4310; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.progress { display: inline-block; width: 90px; height: 8px; background: #ebe8e1; border-radius: 4px; vertical-align: middle; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.ok { background: #e3f1e6; color: #1e5b2c; border-radius: 8px; padding: 10px 14px; font-weight: 600; }

/* Calificación */
.ia-box { border-left: 4px solid #6250d6; }
.ia-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: flex-start; }
.ia-head h2 { margin-bottom: 4px; }
.status-line { display: flex; gap: 8px; align-items: center; margin: 8px 0 0; }
.spinner { width: 16px; height: 16px; border: 2px solid #d5d0f3; border-top-color: #6250d6; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.compact-dl dt { margin-top: 10px; font-size: 15px; }
.quote { margin: 6px 0 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.response { background: #fbfaf7; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 10px 0; line-height: 1.6; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; }
.chips-label { font-size: 13px; color: var(--muted); }
.chip { font-size: 13px; background: #f0eee8; border-radius: 999px; padding: 2px 10px; }
details.ideal, details.enunciado-det, details.table-view { margin: 8px 0; }
details > summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 15px; }
.ideal-body { margin-top: 8px; padding: 12px 16px; background: #f1f5fb; border-radius: 8px; font-size: 15px; }
.ideal-body p { margin: 0 0 8px; }
.act-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; }
.nota-mapeo { font-size: 14px; background: #fff7e0; border-radius: 8px; padding: 8px 12px; }
.scoring { border: 0; border-top: 1px solid var(--line); margin: 16px 0 0; padding: 16px 0 0; }
.scoring legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.options.row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.opt.done { margin-top: 10px; background: #f1f5fb; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.level { position: relative; cursor: pointer; }
.level input { position: absolute; opacity: 0; }
.level-in { display: block; height: 100%; border: 1px solid #d6d2c8; border-radius: 8px; padding: 10px; font-size: 14px; line-height: 1.4; background: #fff; }
.level-in strong { display: block; margin-bottom: 4px; font-size: 14px; }
.level-in .desc { color: var(--muted); }
.level input:checked + .level-in { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.level input:checked + .level-in .desc { color: var(--ink); }
.level input:focus-visible + .level-in { outline: 2px solid var(--accent); outline-offset: 2px; }
.level-extra { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; }
.sugerencia, .sug-general { background: #f3f1fd; border-radius: 8px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.sug-tag { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; background: #6250d6; border-radius: 4px; padding: 1px 8px; margin-right: 6px; }
.sug-just { color: #3b3a50; }
p.sug-just { margin: 6px 0; }
.sug-evid { margin: 6px 0 0; font-style: italic; color: #4a4860; }
.savebar { position: sticky; bottom: 0; background: rgba(245,248,252,.96); backdrop-filter: blur(4px); border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; z-index: 5; }
.savebar .help { margin: 0 auto 0 0; }

/* Panel / gráficos — rampa secuencial azul para niveles ordinales */
.viz-root { --lv0: #b7d3f6; --lv1: #6da7ec; --lv2: #2a78d6; --lv3: #184f95; --lvne: #d9d7d0; --s1: #2a78d6; --s2: #eb6834; --grid: #e6e3dc; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; }
.filters label { font-size: 14px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.filters select { width: auto; padding: 6px 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0 6px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-num small { font-size: 14px; color: var(--muted); font-weight: 500; }
h3.practica { font-size: 16px; margin: 20px 0 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin: 4px 0 8px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.lv0 { background: var(--lv0); } .lv1 { background: var(--lv1); } .lv2 { background: var(--lv2); } .lv3 { background: var(--lv3); } .lv4 { background: var(--lvne); }
.s1 { background: var(--s1); } .s2 { background: var(--s2); }
.stack-list, .dumbbells { display: grid; gap: 8px; }
.stack-row, .db-row, .db-axis { display: grid; grid-template-columns: minmax(180px, 2fr) 3fr 48px; gap: 12px; align-items: center; }
.stack-label { font-size: 14px; line-height: 1.3; }
.stack-track { display: flex; gap: 2px; height: 22px; }
.seg { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #0b0b0b; min-width: 3px; }
.seg:first-child { border-radius: 4px 0 0 4px; } .seg:last-child { border-radius: 0 4px 4px 0; } .seg:only-child { border-radius: 4px; }
.seg.lv2, .seg.lv3 { color: #fff; }
.seg:hover, .seg:focus { outline: 2px solid #1f2328; outline-offset: 1px; }
.empty-track { font-size: 13px; color: var(--muted); align-self: center; }
.stack-val { font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); }
.db-scale { position: relative; height: 18px; font-size: 12px; color: var(--muted); }
.db-scale span { position: absolute; transform: translateX(-50%); }
.db-track { position: relative; height: 22px; background: linear-gradient(to right, var(--grid) 1px, transparent 1px) 0 0 / 33.333% 100%; border-right: 1px solid var(--grid); }
.db-line { position: absolute; top: 10px; height: 2px; background: #9a978f; }
.db-dot { position: absolute; top: 5px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 1fr) 2fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { height: 14px; display: block; }
.bar { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
table.list.numeric td, table.list.numeric th { text-align: right; font-variant-numeric: tabular-nums; }
table.list.numeric td:first-child, table.list.numeric th:first-child, table.list.numeric td.txt { text-align: left; }
.tip { position: fixed; z-index: 50; background: #1f2328; color: #fff; font-size: 13px; padding: 6px 10px; border-radius: 6px; pointer-events: none; max-width: 280px; }

@media (max-width: 720px) {
  .levels { grid-template-columns: 1fr 1fr; }
  .stack-row, .db-row, .db-axis { grid-template-columns: 1fr 44px; }
  .stack-label { grid-column: 1 / -1; }
  .db-axis > span:first-child { display: none; }
}

/* Login y sesión */
.login-page .wrap { max-width: 440px; padding-top: 10vh; }
.login-card h1 { font-size: 24px; margin-bottom: 18px; }
.login-card .alert { margin-bottom: 16px; font-weight: 500; }
input[type="email"], input[type="password"] { width: 100%; font: inherit; color: inherit; background: #fff; border: 1px solid #cfcac0; border-radius: 8px; padding: 10px 12px; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 84px; }
.pass-wrap .toggle-pass { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
button.full { width: 100%; margin-top: 6px; }
.topnav .logout { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topnav .who { font-size: 13px; color: #aeb3ba; }
.topnav .logout button.link { color: #d4d7dc; }

/* Calificación en dos columnas en pantallas anchas */
.score-grid { display: grid; gap: 8px 40px; }
@media (min-width: 1280px) {
  .score-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .score-left { position: sticky; top: 16px; max-height: calc(100vh - 110px); overflow: auto; padding-right: 6px; }
  .score-right > .scoring:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
}
.response, .ideal-body, .enunciado p { line-height: 1.6; }

/* Adjuntos en el panel */
.adj-block { margin: 10px 0 12px; }
.adj-title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--accent); }
.adj-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.adj-item { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; min-width: 0; }
.adj-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; background: #eef2f7; }
.adj-thumb:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.adj-doc { width: 64px; height: 64px; flex: none; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; text-decoration: none; }
.adj-meta { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.adj-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox { border: 0; border-radius: 12px; padding: 0; max-width: 94vw; max-height: 94vh; background: #10161f; }
.lightbox::backdrop { background: rgba(10, 14, 20, .78); }
.lightbox img { display: block; max-width: 94vw; max-height: calc(94vh - 56px); margin: 0 auto; object-fit: contain; }
.lb-bar { display: flex; gap: 10px; align-items: center; padding: 10px 12px; color: #fff; font-size: 14px; }
.lb-bar a { color: #c9d6f5; }
.lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Sugerencias de IA en naranja; decisión del evaluador en azul ===== */
:root { --ai: #c2410c; --ai-line: #f08c4a; --ai-soft: #fff4ea; --ai-ink: #7c2d12; }
.ai-badge { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .03em; color: #fff; background: var(--ai); border-radius: 4px; padding: 1px 6px; margin-right: 6px; vertical-align: 1px; }
.ai-badge.sm { margin: 0 0 0 6px; font-size: 10px; }
.ai-box { background: var(--ai-soft); border: 1px solid #fbd3b4; border-left: 4px solid var(--ai); border-radius: 8px; padding: 10px 12px; margin: 4px 0 12px; font-size: 14px; }
.ai-head { margin: 0; color: var(--ai-ink); }
.ai-just { margin: 6px 0 0; color: #5a3b2a; line-height: 1.45; }
.ai-evid { margin: 6px 0 0; font-style: italic; color: #6b4a37; }
.accept-ai { margin-top: 8px; background: var(--ai); color: #fff; border: 0; border-radius: 8px; padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.accept-ai:hover { filter: brightness(1.08); }
.accept-all-act { background: var(--ai); }
#accept-all { color: var(--ai); border-color: var(--ai); }

/* Tarjeta de nivel sugerida por la IA: borde naranja punteado. Elegida por ti: azul. */
.level.is-ai .level-in { border: 2px dashed var(--ai-line); background: var(--ai-soft); }
.level.is-ai input:checked + .level-in { border: 2px solid var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px #fbd3b4; }
.opt.is-ai { background: var(--ai-soft); outline: 1.5px dashed var(--ai-line); outline-offset: -1.5px; }

.decision { margin: 8px 0 0; font-size: 14px; font-weight: 700; min-height: 1em; }
.decision:empty { display: none; }
.st-pending .decision { color: var(--ai); }
.st-accepted .decision { color: #1e6b3a; }
.st-changed .decision { color: var(--accent); }
.st-pending .accept-ai { box-shadow: 0 0 0 3px #fde1cb; }
.st-accepted .accept-ai, .st-changed .accept-ai { background: #fff; color: var(--ai); border: 1px solid var(--ai); }

.legend-ai { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; font-size: 14px; position: sticky; top: 0; z-index: 4; }
.legend-ai .help { margin: 0; flex-basis: 100%; }
.lg-item { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.sw-ai { width: 22px; height: 14px; border-radius: 3px; border: 2px dashed var(--ai-line); background: var(--ai-soft); }
.sw-you { width: 22px; height: 14px; border-radius: 3px; border: 2px solid var(--accent); background: var(--accent-soft); }
.pending-count { font-size: 14px; font-weight: 700; color: var(--ai); }

/* Listado: chips de nivel medio */
.lvl-chip { display: inline-block; min-width: 44px; text-align: center; font-weight: 700; font-size: 13px; border-radius: 999px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.lvl-chip.ai { color: var(--ai-ink); background: var(--ai-soft); border: 1.5px dashed var(--ai-line); }
.lvl-chip.you { color: #1b3f99; background: var(--accent-soft); border: 1.5px solid var(--accent); }
.tag-por-decidir { font-size: 12px; font-weight: 700; color: var(--ai); }
.spinner.inline { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; border-width: 2px; border-color: #fbd3b4; border-top-color: var(--ai); }
.ia-batch { border-left: 4px solid var(--ai); }
.ia-batch .inline-form > span:first-child { margin-right: 6px; }
