/* Identidad: «cartografía de campaña» · BCG Brigada «Aragón» I
   Verde campaña, caqui, papel de mapa y los colores de la Señal Real de Aragón. */
:root {
  --campana: #26301D;      /* verde campaña: cabecera, botones principales */
  --campana-2: #34422A;
  --caqui: #C9B88A;
  --rojo: #C8102E;         /* rojo Aragón */
  --oro: #F2C230;          /* oro Aragón */
  --olive: #3E5A25;        /* acento de interfaz (enlaces, barras) */
  --olive-2: #4D6C30;
  --olive-soft: #E1E7D3;
  --gold: var(--oro);
  --bg: #ECEFE6;           /* papel de mapa */
  --surface: #FAFBF7;
  --surface-2: #F3F5EE;
  --text: #1B1F16;
  --muted: #5B6250;
  --line: #D3D8C8;
  --ok: #2E7034;
  --ok-soft: #DFEED9;
  --bad: #B01E2E;
  --bad-soft: #F7E1E2;
  --warn: #8A6500;
  --warn-soft: #F8EDC9;
  --hl-amarillo: #FFEB8F;
  --hl-verde: #CBE8B5;
  --hl-azul: #C9DFF5;
  --hl-rosa: #F6CFDC;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(27,31,22,.06), 0 6px 18px -10px rgba(27,31,22,.25);
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Saira Stencil One", "Barlow Condensed", Impact, sans-serif;
  --read: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --cinta: linear-gradient(90deg, var(--oro) 0 11.1%, var(--rojo) 11.1% 22.2%, var(--oro) 22.2% 33.3%, var(--rojo) 33.3% 44.4%,
    var(--oro) 44.4% 55.5%, var(--rojo) 55.5% 66.6%, var(--oro) 66.6% 77.7%, var(--rojo) 77.7% 88.8%, var(--oro) 88.8%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --olive: #9DBB6E; --olive-2: #B3CF85; --olive-soft: #26301D; --caqui: #B9A876;
    --bg: #12160D; --surface: #1A1F14; --surface-2: #20271A; --text: #E8EBDF; --muted: #A2A894; --line: #313A26;
    --ok: #86CB8D; --ok-soft: #1C2E1D; --bad: #F08A8F; --bad-soft: #3A1B1E; --warn: #E9C75A; --warn-soft: #382F14;
    --hl-amarillo: #6A5A0E; --hl-verde: #2E5524; --hl-azul: #22445F; --hl-rosa: #5A2A3D;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 20px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --olive: #9DBB6E; --olive-2: #B3CF85; --olive-soft: #26301D; --caqui: #B9A876;
  --bg: #12160D; --surface: #1A1F14; --surface-2: #20271A; --text: #E8EBDF; --muted: #A2A894; --line: #313A26;
  --ok: #86CB8D; --ok-soft: #1C2E1D; --bad: #F08A8F; --bad-soft: #3A1B1E; --warn: #E9C75A; --warn-soft: #382F14;
  --hl-amarillo: #6A5A0E; --hl-verde: #2E5524; --hl-azul: #22445F; --hl-rosa: #5A2A3D;
  --shadow: 0 1px 0 rgba(0,0,0,.3), 0 8px 20px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg) url("/img/curvas-claro.svg") center top / 1400px auto fixed; color: var(--text); font: 16.5px/1.5 var(--font); }
:root[data-theme="dark"] body { background-image: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body { background-image: none; } }
a { color: var(--olive); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.005em; }
h1 { font-family: var(--display); font-weight: 400; font-size: clamp(1.7rem, 3.2vw, 2.3rem); letter-spacing: .01em; }
h2 { font-size: 1.22rem; }
main { max-width: 1120px; margin: 0 auto; padding: 28px 16px 64px; outline: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--oro); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 10px 18px 13px;
  background: var(--campana); color: #ECEFE6; box-shadow: 0 2px 12px rgba(0,0,0,.18); }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--cinta); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; white-space: nowrap; }
.brand img { width: 30px; height: 34px; }
.brand .bt { display: flex; flex-direction: column; line-height: 1.05; }
.brand .bt b { font-family: var(--display); font-weight: 400; font-size: 1.15rem; letter-spacing: .03em; }
.brand .bt small { font-family: var(--mono); font-size: .64rem; letter-spacing: .08em; color: var(--caqui); text-transform: uppercase; }
.mainnav { display: flex; gap: 2px; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
.mainnav a { position: relative; padding: 8px 12px; text-decoration: none; color: rgba(236,239,230,.78); font-weight: 600; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .06em; font-size: .86rem; border-radius: 4px; }
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.mainnav a.active { color: #fff; }
.mainnav a.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; background: var(--oro); }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 4px; padding: 8px 12px 10px; }
  .mainnav { width: 100%; margin: 0; }
  .mainnav a { padding: 6px 9px; font-size: .78rem; }
}

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px;
  border: 1px solid var(--olive); background: var(--olive); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--olive-2); border-color: var(--olive-2); }
.btn.secondary { background: transparent; color: var(--olive); }
.btn.secondary:hover { background: var(--olive-soft); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--olive-soft); color: var(--olive); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--olive); border-radius: 99px; }
.stat .num { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.stat .lbl { color: var(--muted); font-size: .9rem; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.section-title { margin: 32px 0 12px; }

/* ---------- Formularios ---------- */
.auth-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; padding: 16px; }
.auth { width: 100%; max-width: 420px; }
.auth .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth .logo svg { width: 48px; height: 48px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tabs button { flex: 1; padding: 8px; border: 0; background: transparent; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--olive); outline-offset: 1px; }
.error { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

/* ---------- Temario ---------- */
.capitulo { margin-top: 28px; }
.capitulo > h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.bloque { margin-bottom: 16px; }
.bloque h3 { font-size: 1.05rem; margin-bottom: 8px; }
.tema-list { display: grid; gap: 8px; }
.tema-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.tema-item .t { font-weight: 600; }
.tema-item .meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: .85rem; color: var(--muted); }
.tema-item .acts { display: flex; gap: 8px; grid-row: span 2; }
.tema-item .bar { width: 120px; }
@media (max-width: 640px) {
  .tema-item { grid-template-columns: 1fr; }
  .tema-item .acts { grid-row: auto; }
}

/* ---------- Lector ---------- */
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.reader { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px 40px; box-shadow: var(--shadow);
  font-family: var(--read); font-size: var(--reader-size, 1.08rem); line-height: 1.7; }
.reader .p { margin: 0 0 .8em; position: relative; scroll-margin-top: 90px; border-radius: 4px; transition: background .4s; }
.reader .h1 { font-family: var(--font); font-size: 1.5rem; font-weight: 800; margin: 0 0 1em; }
.reader .h2 { font-family: var(--font); font-size: 1.15rem; font-weight: 700; margin: 1.6em 0 .6em; }
.reader .h3 { font-family: var(--font); font-size: 1.02rem; font-weight: 700; margin: 1.3em 0 .4em; }
.reader .li { padding-left: 1.2em; }
.reader .pagecode { font-family: var(--font); display: flex; align-items: center; gap: 8px; margin: 1.6em 0 1em; color: var(--muted); font-size: .78rem; }
.reader .pagecode::before, .reader .pagecode::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
.reader .fig { font-family: var(--font); margin: 1em 0 1.4em; }
.reader .fig button { font-size: .85rem; }
.reader .fig img { display: block; width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.reader .p.flash { background: var(--warn-soft); box-shadow: 0 0 0 6px var(--warn-soft); }
mark.hl { color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; }
mark.hl.amarillo { background: var(--hl-amarillo); }
mark.hl.verde { background: var(--hl-verde); }
mark.hl.azul { background: var(--hl-azul); }
mark.hl.rosa { background: var(--hl-rosa); }
mark.hl.has-note { border-bottom: 2px solid var(--olive); }
mark.hl.has-note::after { content: "✎"; font-size: .7em; vertical-align: super; color: var(--olive); margin-left: 1px; }
.side { position: sticky; top: 76px; display: grid; gap: 16px; max-height: calc(100vh - 96px); overflow: auto; }
.side .card { padding: 16px; }
.note-list { display: grid; gap: 8px; }
.note-item { padding: 10px 12px; border-radius: 8px; border-left: 4px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: .9rem; }
.note-item.amarillo { border-left-color: #e3c300; } .note-item.verde { border-left-color: #4fa83d; }
.note-item.azul { border-left-color: #3b82c4; } .note-item.rosa { border-left-color: #d04f86; }
.note-item .q { font-style: italic; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note-item .n { margin-top: 4px; white-space: pre-wrap; }
.readbar { position: fixed; left: 0; top: 0; height: 3px; background: var(--gold); z-index: 40; width: 0; }
@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .reader { padding: 20px 18px; }
}

/* Barra flotante de subrayado */
.hl-toolbar { position: absolute; z-index: 50; display: flex; gap: 6px; align-items: center; padding: 6px; background: var(--text); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.hl-toolbar button { border: 0; cursor: pointer; }
.hl-toolbar .sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.hl-toolbar .sw.amarillo { background: #ffe45c; } .hl-toolbar .sw.verde { background: #8fd67a; }
.hl-toolbar .sw.azul { background: #8cc0f5; } .hl-toolbar .sw.rosa { background: #f29cbf; }
.hl-toolbar .tb { background: transparent; color: var(--bg); font-weight: 600; font-size: .85rem; padding: 4px 8px; border-radius: 6px; }
.hl-toolbar .tb:hover { background: rgba(255,255,255,.15); }

/* Ventana modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal blockquote { margin: 0 0 12px; padding: 8px 12px; border-left: 4px solid var(--gold); background: var(--surface-2); font-family: var(--read); font-style: italic; max-height: 140px; overflow: auto; }
.colors { display: flex; gap: 8px; margin-bottom: 12px; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.colors button.on { border-color: var(--text); }
.colors .amarillo { background: #ffe45c; } .colors .verde { background: #8fd67a; } .colors .azul { background: #8cc0f5; } .colors .rosa { background: #f29cbf; }

/* ---------- Tests ---------- */
.test-head { position: sticky; top: 58px; z-index: 20; background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.2rem; }
.timer.low { color: var(--bad); }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; scroll-margin-top: 120px; }
@media (max-width: 640px) { .test-head { top: 84px; } .q-card { padding: 14px; scroll-margin-top: 150px; } .score .big { font-size: 2.4rem; } }
.q-card .qn { font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.q-card .qt { font-weight: 600; margin: 4px 0 12px; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface-2); }
.opt:hover { border-color: var(--olive); }
.opt input { margin-top: 4px; accent-color: var(--olive); }
.opt .l { font-weight: 700; min-width: 1.2em; }
.opt.sel { border-color: var(--olive); background: var(--olive-soft); }
.q-card.r-error { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.q-card.r-acierto { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.q-card.r-blanco { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.opt.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.opt.is-bad { border-color: var(--bad); background: var(--bad-soft); text-decoration: line-through; text-decoration-color: var(--bad); }
.opt.locked { cursor: default; }
.explain { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line); }
.explain .row { margin-top: 10px; }
.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: .85rem; font-weight: 600; background: var(--surface); }
.qnav a.done { background: var(--olive-soft); border-color: var(--olive); }
.qnav a.acierto { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.qnav a.error { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.qnav a.blanco { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.score { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; }
.score .big { font-size: 3rem; font-weight: 800; line-height: 1; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.filters button { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 99px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.filters button.on { background: var(--olive); color: #fff; border-color: var(--olive); }
.test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.test-tile { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--text); }
.test-tile:hover { border-color: var(--olive); }
.test-tile .n { font-weight: 800; font-size: 1.1rem; }
.test-tile.done { background: var(--olive-soft); }
table.hist { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.hist th, table.hist td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table-scroll { overflow-x: auto; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 10px; font-weight: 600; transition: .25s; z-index: 80; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media print { .topbar, .side, .btn, #toast { display: none !important; } .reader { border: 0; box-shadow: none; } }

/* ---------- Foro ---------- */
.forum-filters { margin: 16px 0; padding: 16px; }
.thread-list { display: grid; gap: 8px; }
.thread-item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; }
.thread-item:hover { border-color: var(--olive); }
.thread-item .ttl { font-weight: 700; }
.thread-item .exc { color: var(--muted); font-size: .92rem; margin: 2px 0 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thread-item .meta { font-size: .82rem; color: var(--muted); }
.thread-item .count { text-align: center; min-width: 52px; padding: 6px; border-radius: 8px; background: var(--olive-soft); color: var(--olive); }
.thread-item .count.zero { background: var(--warn-soft); color: var(--warn); }
.thread-item .count strong { display: block; font-size: 1.2rem; line-height: 1; }
.thread-item .count span { font-size: .72rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--olive); color: #fff; font-weight: 700; font-size: .85rem; flex: none; }
.post { margin-bottom: 12px; }
.post h1 { font-size: 1.35rem; }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.post.is-solution { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.solution-tag { color: var(--ok); font-weight: 700; font-size: .85rem; margin-bottom: 8px; }
@media (max-width: 640px) {
  .thread-item { grid-template-columns: 1fr auto; }
  .thread-item .avatar { display: none; }
}

/* ---------- Contacto ---------- */
.msg { padding: 12px 0; border-bottom: 1px solid var(--line); }
.msg:last-child { border-bottom: 0; }
.reply-box { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--ok-soft); }
.mod-reply { margin-top: 10px; }
.qnav a.flag { box-shadow: inset 0 -3px 0 var(--warn); }
[data-flag].on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
#flagged { cursor: pointer; }
.tema-picker { display: grid; gap: 6px; max-height: 340px; overflow: auto; padding: 4px; border: 1px solid var(--line); border-radius: 10px; }
.tema-picker details { padding: 4px 6px; }
.tema-picker summary { cursor: pointer; font-weight: 600; }
.tema-picker .pick { display: block; padding: 4px 0 4px 26px; font-size: .92rem; }
.tabs button { white-space: nowrap; }

/* ---------- Cuaderno de apuntes ---------- */
.notebook { position: fixed; z-index: 45; top: 58px; right: 0; bottom: 0; width: min(420px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgba(0,0,0,.08); }
.nb-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.nb-tools { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.notebook textarea { flex: 1; border: 0; border-radius: 0; resize: none; padding: 14px 16px; font: 1rem/1.6 var(--read); background: var(--surface-2); }
.notebook textarea:focus { outline: none; }
body.nb-open main { max-width: none; margin-right: 420px; }
.nb-preview { max-height: 220px; overflow: auto; margin-top: 8px; font-family: var(--read); background: var(--surface-2); padding: 10px 12px; border-radius: 8px; }
.tabs { overflow-x: auto; }
@media (max-width: 1000px) { body.nb-open main { margin-right: 0; } }
@media (max-width: 640px) {
  .notebook { top: auto; height: 62vh; width: 100vw; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; }
  body.nb-open main { padding-bottom: 64vh; }
}

/* ---------- Estadísticas ---------- */
.statlist { display: grid; gap: 12px; }
.statrow { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.statrow:last-child { border-bottom: 0; }
.bar > i.ok { background: var(--ok); } .bar > i.warn { background: var(--warn); } .bar > i.bad { background: var(--bad); }
.spark { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 110px; padding: 6px; border: 1px solid var(--line); border-radius: 8px;
  background: linear-gradient(to top, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) 50%, transparent 50%); margin-bottom: 6px; }
.spark i { flex: 1; max-width: 26px; border-radius: 4px 4px 0 0; background: var(--olive); }
.spark i.ok { background: var(--ok); } .spark i.warn { background: var(--warn); } .spark i.bad { background: var(--bad); }
@media (max-width: 1400px) { body.nb-open .reader-layout { grid-template-columns: 1fr; } body.nb-open .side { display: none; } }

/* =====================================================================
   Identidad «cartografía de campaña» · BCG Brigada «Aragón» I
   ===================================================================== */
.eyebrow { font-family: var(--mono); font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; color: var(--caqui); margin: 0 0 10px; }

/* Botones: rotulado militar */
.btn { border-radius: 4px; background: var(--campana); border-color: var(--campana); text-transform: uppercase; letter-spacing: .06em;
  font-size: .86rem; font-weight: 700; padding: 10px 18px; transition: background .15s, transform .05s; }
.btn:hover { background: var(--campana-2); border-color: var(--campana-2); }
.btn:active { transform: translateY(1px); }
.btn.small { font-size: .74rem; padding: 6px 11px; }
.btn.secondary { color: var(--campana); border-color: var(--campana); background: transparent; }
.btn.secondary:hover { background: var(--olive-soft); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--campana); background: var(--surface); }
:root[data-theme="dark"] .btn:not(.ghost):not(.secondary) { background: #3E5A25; border-color: #3E5A25; }
:root[data-theme="dark"] .btn.secondary { color: var(--olive); border-color: var(--olive); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn:not(.ghost):not(.secondary) { background: #3E5A25; border-color: #3E5A25; }
  :root:not([data-theme="light"]) .btn.secondary { color: var(--olive); border-color: var(--olive); }
}

.card { border-radius: var(--radius); }
.pill { border-radius: 3px; font-family: var(--mono); font-weight: 500; font-size: .74rem; letter-spacing: .02em; }
.tabs { border-radius: 6px; }
.tabs button { border-radius: 4px; text-transform: uppercase; letter-spacing: .05em; font-size: .8rem; }
.section-title { font-family: var(--font); text-transform: uppercase; letter-spacing: .08em; font-size: .95rem; color: var(--muted);
  display: flex; align-items: center; gap: 12px; }
.section-title::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.capitulo > h2 { font-family: var(--mono); font-weight: 500; font-size: .8rem; letter-spacing: .14em; display: flex; align-items: center; gap: 12px; }
.capitulo > h2::after { content: ""; flex: 1; height: 3px; background: var(--cinta); opacity: .85; border-radius: 2px; }
.bloque h3 { font-size: 1.08rem; }
.tema-item, .test-tile, .thread-item { border-radius: 5px; }
.test-tile .n, .stat .num { font-family: var(--display); font-weight: 400; letter-spacing: .02em; }
.stat .num { font-size: 2.2rem; }
.test-tile.done { border-left: 4px solid var(--olive); }
.timer, .reader .pagecode, .qnav a, table.hist td:nth-child(n+3) { font-family: var(--mono); }
.reader .pagecode { letter-spacing: .1em; }
.q-card .qn { font-family: var(--mono); font-weight: 500; letter-spacing: .12em; }
.reader .h1 { font-family: var(--display); font-weight: 400; font-size: 1.7rem; letter-spacing: .01em; }
.reader { border-top: 4px solid var(--campana); }
.readbar { background: var(--cinta); height: 4px; }
.avatar { background: var(--campana); color: var(--oro); font-family: var(--mono); }
mark.hl.has-note { border-bottom-color: var(--rojo); }
.crumbs { font-family: var(--mono); font-size: .76rem; letter-spacing: .04em; }

/* Portada de acceso */
body.is-auth { background: var(--campana); }
body.is-auth main { max-width: none; padding: 0; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, .9fr); place-items: stretch; padding: 0; }
.auth-hero { position: relative; overflow: hidden; color: #ECEFE6; display: flex; align-items: center; padding: 56px clamp(24px, 6vw, 88px);
  background: var(--campana) url("/img/curvas-oscuro.svg") center / cover; }
.auth-hero::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: linear-gradient(180deg,
  var(--oro) 0 11.1%, var(--rojo) 11.1% 22.2%, var(--oro) 22.2% 33.3%, var(--rojo) 33.3% 44.4%, var(--oro) 44.4% 55.5%,
  var(--rojo) 55.5% 66.6%, var(--oro) 66.6% 77.7%, var(--rojo) 77.7% 88.8%, var(--oro) 88.8%); }
.auth-hero-in { position: relative; max-width: 560px; }
.auth-insignia { width: 64px; height: 72px; margin-bottom: 22px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.auth-title { font-family: var(--display); font-weight: 400; font-size: clamp(3rem, 8vw, 5.6rem); line-height: .92; margin: 0 0 22px;
  letter-spacing: .01em; color: #F6F3E4; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.auth-lead { font-size: 1.12rem; max-width: 46ch; color: rgba(236,239,230,.85); margin: 0 0 28px; }
.auth-facts { list-style: none; padding: 0; margin: 0 0 32px; display: flex; gap: 28px; flex-wrap: wrap; }
.auth-facts li { display: flex; flex-direction: column; border-left: 3px solid var(--oro); padding-left: 12px; }
.auth-facts b { font-family: var(--display); font-weight: 400; font-size: 1.9rem; line-height: 1; color: var(--oro); }
.auth-facts span { font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--caqui); margin-top: 4px; }
.auth-quote { margin: 0; padding: 14px 18px; max-width: 48ch; background: rgba(0,0,0,.22); border-left: 3px solid var(--rojo);
  font-family: var(--read); font-style: italic; font-size: 1.02rem; color: rgba(246,243,228,.92); }
.auth-quote cite { display: block; margin-top: 6px; font-family: var(--mono); font-style: normal; font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--caqui); }
.coord { position: absolute; right: 18px; bottom: 14px; font-family: var(--mono); font-size: .7rem; letter-spacing: .16em; color: rgba(201,184,138,.6); }
.auth-panel { background: var(--bg); display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; gap: 14px; }
.auth { width: 100%; max-width: 400px; border-top: 4px solid var(--campana); }
.auth-h { font-family: var(--display); font-weight: 400; font-size: 1.6rem; letter-spacing: .02em; }
.auth-note { font-family: var(--mono); font-size: .7rem; color: var(--muted); text-align: center; letter-spacing: .03em; margin: 0; }
@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { padding: 40px 22px 48px; }
  .auth-quote { display: none; }
  .auth-panel { padding: 28px 16px 40px; }
}

/* Cabecera de Inicio */
.hero { position: relative; overflow: hidden; display: flex; align-items: center; gap: 24px; padding: 34px clamp(20px, 4vw, 44px);
  margin-bottom: 20px; border-radius: 8px; color: #ECEFE6; background: var(--campana) url("/img/curvas-oscuro.svg") 62% 58% / 1300px auto; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--cinta); }
.hero-in { position: relative; flex: 1; }
.hero h1 { color: #F6F3E4; font-size: clamp(1.9rem, 4.2vw, 2.9rem); margin-bottom: 10px; }
.hero p:not(.eyebrow) { margin: 0; max-width: 62ch; color: rgba(236,239,230,.82); }
.hero .eyebrow::first-letter { text-transform: uppercase; }
.hero-insignia { position: relative; width: 92px; height: 104px; flex: none; filter: drop-shadow(0 8px 18px rgba(0,0,0,.4)); }
@media (max-width: 640px) { .hero-insignia { display: none; } .hero { padding: 26px 18px 30px; } }

/* Pie de página */
.sitefoot { margin-top: 40px; background: var(--campana); color: rgba(236,239,230,.78); }
.sitefoot .cinta { height: 5px; background: var(--cinta); }
.foot-in { max-width: 1120px; margin: 0 auto; padding: 18px 16px 22px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .86rem; }
.foot-in strong { display: block; color: #F6F3E4; font-family: var(--mono); font-weight: 500; letter-spacing: .06em; text-transform: uppercase; font-size: .78rem; }
.foot-note { margin-left: auto; font-family: var(--mono); font-size: .7rem; color: var(--caqui); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 640px) { .grid.cols-4 { grid-template-columns: 1fr 1fr; } .stat .num { font-size: 1.8rem; } }

/* ---------- Exámenes anteriores ---------- */
.oficiales { display: grid; gap: 12px; }
.oficial-card { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--campana); border-radius: 5px;
  text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.oficial-card:hover { border-color: var(--campana); }
.oficial-card.done { border-left-color: var(--olive); }
.oficial-anio { font-family: var(--display); font-size: 2.4rem; line-height: 1; color: var(--campana); letter-spacing: .02em; }
:root[data-theme="dark"] .oficial-anio { color: var(--oro); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .oficial-anio { color: var(--oro); } }
.oficial-body { display: flex; flex-direction: column; gap: 3px; }
.qcab { font-family: var(--mono); font-size: .74rem; letter-spacing: .03em; color: var(--muted); margin-top: 4px; }
.aviso { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: .92rem; }
@media (max-width: 640px) { .oficial-card { grid-template-columns: auto 1fr; } .oficial-card > .btn { grid-column: 1 / -1; } }

/* =====================================================================
   Material extra
   ===================================================================== */
.hero-sm { padding: 26px clamp(20px, 4vw, 40px); }
.hero-sm h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.mat-tabs { max-width: 900px; margin: 4px 0 8px; }
.mono { font-family: var(--mono); font-size: .86rem; white-space: nowrap; }
.tlink { font-family: var(--mono); font-size: .74rem; letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
.tlink:hover { text-decoration: underline; }
.fix { margin-top: 14px; padding: 10px 14px; border-left: 4px solid var(--oro); background: var(--warn-soft); border-radius: 4px; font-size: .92rem; }

/* tarjetas */
.mat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 16px; }
.mcard { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--campana); border-radius: 6px; padding: 16px 18px; box-shadow: var(--shadow); }
.mcard.warn { border-top-color: var(--rojo); }
.mcard h3 { margin: 0 0 8px; font-size: 1.05rem; }
.mcard ul { margin: 0; padding-left: 18px; }
.mcard li { margin: 4px 0; }

/* pasos */
.steps { counter-reset: paso; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: paso; position: relative; padding: 12px 14px 12px 58px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.steps li::before { content: counter(paso); position: absolute; left: 12px; top: 10px; width: 32px; height: 32px; display: grid; place-items: center;
  font-family: var(--display); font-size: 1.15rem; color: var(--oro); background: var(--campana); border-radius: 4px; }

/* simulador de la hoja de respuestas */
.sim-ex { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .9rem; margin-bottom: 14px; }
.sim-sheet { display: grid; gap: 10px; background: #F6E3C8; border: 2px solid #E2B98A; border-radius: 6px; padding: 14px; }
.sim-row { display: grid; grid-template-columns: 34px auto 1fr; gap: 14px; align-items: center; background: #FFF9F0; border: 1px solid #E2B98A; border-radius: 4px; padding: 10px 12px; color: #3A2A18; }
.sim-n { font-family: var(--mono); font-weight: 500; font-size: 1.2rem; color: #9A5B1E; }
.sim-grid { display: grid; grid-template-columns: repeat(5, 40px); grid-template-rows: auto auto; gap: 6px 8px; align-items: center; position: relative; }
.bub { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #C98A4E; background: #fff; color: #9A5B1E; font-weight: 700; cursor: pointer; font-family: var(--font); }
.bub:hover { background: #FCEBD7; }
.bub.on { background: #1E2A4A; border-color: #1E2A4A; color: #fff; }
.bub.dead { background: repeating-linear-gradient(45deg, #fff 0 4px, #E9D3B8 4px 7px); color: #B7A089; cursor: not-allowed; }
.bub.on.dead { background: repeating-linear-gradient(45deg, #9CA3B8 0 4px, #6B7280 4px 7px); color: #fff; }
.bub.e { border-style: dashed; }
.sim-anular { position: absolute; left: -66px; bottom: 6px; font-family: var(--mono); font-size: .64rem; color: #B07A45; letter-spacing: .06em; }
.anu { width: 36px; height: 14px; border-radius: 8px; border: 1.5px solid #C98A4E; background: #F3DCC0; cursor: pointer; }
.anu.on { background: #1E2A4A; border-color: #1E2A4A; }
.sim-res { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.sim-res b { font-family: var(--mono); font-size: 1.05rem; }
.sim-res b.ok { color: #2E7034; } .sim-res b.warn { color: #8A6500; } .sim-res b.bad { color: #B01E2E; }
@media (max-width: 640px) {
  .sim-row { grid-template-columns: 26px 1fr; }
  .sim-res { grid-column: 1 / -1; text-align: left; flex-direction: row; gap: 8px; align-items: baseline; }
  .sim-grid { grid-template-columns: repeat(5, 34px); gap: 6px; }
  .bub, .anu { width: 32px; } .bub { height: 32px; }
  .sim-anular { display: none; }
}

/* diapositivas */
.slides { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.slide { padding: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); cursor: zoom-in; text-align: left; box-shadow: var(--shadow); }
.slide img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #fff; }
.slide span { display: block; padding: 8px 10px; font-size: .82rem; font-weight: 600; }
.slide:hover { border-color: var(--campana); }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(10,12,8,.9); display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; padding: 20px 8px; }
.lightbox figure { margin: 0; text-align: center; }
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 6px; background: #fff; }
.lightbox figcaption { color: #ECEFE6; font-family: var(--mono); font-size: .8rem; margin-top: 10px; }
.lightbox button { background: transparent; border: 0; color: #fff; font-size: 2.6rem; cursor: pointer; }
.lb-x { position: absolute; top: 10px; right: 16px; font-size: 1.6rem !important; }

/* faltas */
.faltas-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.faltas { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.faltas header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; color: #fff; }
.faltas header h3 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.3rem; letter-spacing: .02em; }
.faltas header .pill { background: rgba(255,255,255,.18); color: #fff; }
.faltas.leves header { background: #5B7A2E; } .faltas.graves header { background: #B9770E; } .faltas.muygraves header { background: var(--rojo); }
.faltas details { border-top: 1px solid var(--line); }
.faltas summary { cursor: pointer; padding: 9px 14px; font-weight: 600; font-size: .95rem; }
.faltas summary:hover { background: var(--surface-2); }
.faltas details ul { margin: 0 0 10px; padding: 0 14px 0 32px; font-size: .92rem; }
.faltas details li { margin: 4px 0; }
.faltas footer { padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* tablas */
table.mtable { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.mtable th, table.mtable td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mtable thead th { font-family: var(--mono); font-weight: 500; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
table.mtable tr.grp td { font-family: var(--mono); font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: #fff; padding: 6px 10px; }
tr.grp.leves td { background: #5B7A2E; } tr.grp.graves td { background: #B9770E; } tr.grp.muygraves td { background: var(--rojo); }
table.sanc tr.leves td:first-child { border-left: 4px solid #5B7A2E; } table.sanc tr.graves td:first-child { border-left: 4px solid #B9770E; } table.sanc tr.muygraves td:first-child { border-left: 4px solid var(--rojo); }
table.armas th:first-child { font-family: var(--mono); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
table.armas thead th { color: var(--text); font-family: var(--font); font-weight: 700; font-size: .9rem; letter-spacing: 0; text-transform: none; }
table.armas thead th.nt { color: var(--muted); }
.cell-link { color: inherit; text-decoration: underline; text-decoration-color: var(--oro); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.cell-link:hover { color: var(--olive); }
td .nt { color: var(--muted); font-style: italic; }

/* escalera de potestad */
.ladder { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.ladder li { width: var(--w); min-width: min(100%, 320px); display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--campana); border-radius: 4px; }
.ladder li div { display: flex; flex-direction: column; }
.ladder li span { color: var(--muted); font-size: .92rem; }
.ladder li:first-child { border-left-color: var(--oro); }
@media (max-width: 640px) { .ladder li { width: 100%; } }

/* cuerpos */
.cuerpos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cuerpo:last-child { border-top-color: var(--oro); }

/* ---------- Solicitud de acceso y administración ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
label.check { display: flex; gap: 8px; align-items: flex-start; font-size: .84rem; color: var(--muted); margin: 4px 0 12px; }
label.check input { margin-top: 3px; accent-color: var(--campana); }
.auth { max-height: none; }
.sol-ok { text-align: center; padding: 10px 0; }
.sol-ok-ico { width: 56px; height: 56px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 1.6rem; }
.auth-wrap.single { grid-template-columns: 1fr; }
.auth-wrap.single .auth-panel { min-height: 100vh; background: var(--campana) url("/img/curvas-oscuro.svg") center / cover; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--rojo); color: #fff; font-size: .72rem; margin-left: 4px; }
.tabs-link { flex: 1; text-align: center; padding: 8px; text-decoration: none; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: .8rem; }
.sol-list { display: grid; gap: 12px; }
.sol { border-left: 6px solid var(--line); }
.sol.pendiente { border-left-color: var(--oro); } .sol.aprobada { border-left-color: var(--ok); } .sol.rechazada { border-left-color: var(--bad); opacity: .85; }
.sol-datos { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.sol-datos .wide { grid-column: 1 / -1; }
.sol-datos dt { font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sol-datos dd { margin: 2px 0 0; }
.alta summary { cursor: pointer; }
td.acc { white-space: nowrap; text-align: right; }
dl.cred { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; background: var(--surface-2); padding: 12px; border-radius: 6px; }
dl.cred dt { color: var(--muted); font-size: .85rem; } dl.cred dd { margin: 0; }
dl.cred .big { font-size: 1.2rem; font-weight: 600; color: var(--campana); }
:root[data-theme="dark"] dl.cred .big { color: var(--oro); }
p.aviso { background: var(--warn-soft); color: var(--warn); padding: 8px 10px; border-radius: 6px; }
