/* =========================================================
   Skill 17 · Preparación — estilo del temario (neo-brutalista)
   ========================================================= */
:root {
  --bg: #faf6ec;
  --surface: #ffffff;
  --surface-2: #f3ecdc;
  --ink: #141414;
  --ink-2: #3d3a33;
  --muted: #6f695d;
  --line: #141414;
  --soft-line: #d9d2c3;
  --yellow: #f2b705;
  --yellow-ink: #141414;
  --yellow-soft: #fff8db;
  --b1: #ff5a36; --b2: #00a676; --b3: #2f5bea; --b4: #b23ad6;
  --ok: #00875f; --ok-bg: #e3f7ee;
  --bad: #e0262b; --bad-bg: #fff1ee;
  --code-bg: #17171c; --code-ink: #f3ecdc;
  --shadow-c: #141414;
  --shadow: 4px 4px 0 var(--shadow-c);
  --shadow-sm: 3px 3px 0 var(--shadow-c);
  --card-line: var(--line);
  --card-shadow: 4px 4px 0 var(--shadow-c);
  --top-h: 58px;
  --top-bg: var(--yellow); --top-ink: #141414; --top-line: #141414;
  --ibtn-bg: #ffffff; --ibtn-ink: #141414; --ibtn-line: #141414;
  --badge-bg: #141414; --badge-ink: var(--yellow);
  --nav-active-bg: var(--ink); --nav-active-ink: var(--bg);
  --feature-bg: var(--ink); --feature-ink: var(--bg); --feature-line: var(--ink);
  --th-bg: var(--ink); --th-ink: var(--bg);
  --radius: 4px;
  --f-head: 'Archivo Black', 'Arial Black', system-ui, sans-serif;
  --f-body: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'Anonymous Pro', ui-monospace, 'Cascadia Code', Consolas, monospace;
  color-scheme: light;
}
/* Modo oscuro: fondos profundos, bordes de tarjeta suaves, amarillo solo como acento */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11; --surface: #17171c; --surface-2: #212128;
    --ink: #ece6d6; --ink-2: #c4bdad; --muted: #8e887b;
    --line: #d9d2c3; --soft-line: #2c2c34;
    --card-line: #34343e; --card-shadow: 4px 4px 0 #000;
    --shadow-c: #b38703;
    --yellow-soft: #221d0b;
    --ok: #2fd39d; --ok-bg: #0f241c; --bad: #ff6b6f; --bad-bg: #2a1214;
    --code-bg: #0a0a0d;
    --top-bg: #17171c; --top-ink: #ece6d6; --top-line: var(--yellow);
    --ibtn-bg: #212128; --ibtn-ink: #ece6d6; --ibtn-line: #4a4a55;
    --badge-bg: var(--yellow); --badge-ink: #141414;
    --nav-active-bg: var(--yellow); --nav-active-ink: #141414;
    --feature-bg: #1d1a10; --feature-ink: #ece6d6; --feature-line: var(--yellow);
    --th-bg: #24242c; --th-ink: var(--yellow);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e11; --surface: #17171c; --surface-2: #212128;
  --ink: #ece6d6; --ink-2: #c4bdad; --muted: #8e887b;
  --line: #d9d2c3; --soft-line: #2c2c34;
  --card-line: #34343e; --card-shadow: 4px 4px 0 #000;
  --shadow-c: #b38703;
  --yellow-soft: #221d0b;
  --ok: #2fd39d; --ok-bg: #0f241c; --bad: #ff6b6f; --bad-bg: #2a1214;
  --code-bg: #0a0a0d;
  --top-bg: #17171c; --top-ink: #ece6d6; --top-line: var(--yellow);
  --ibtn-bg: #212128; --ibtn-ink: #ece6d6; --ibtn-line: #4a4a55;
  --badge-bg: var(--yellow); --badge-ink: #141414;
  --nav-active-bg: var(--yellow); --nav-active-ink: #141414;
  --feature-bg: #1d1a10; --feature-ink: #ece6d6; --feature-line: var(--yellow);
  --th-bg: #24242c; --th-ink: var(--yellow);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--f-body);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--f-head); font-weight: 400; line-height: 1.12; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 3.4vw, 1.75rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
code { font-family: var(--f-mono); font-size: .92em; background: var(--surface-2); border: 1px solid var(--soft-line); padding: 0 .3em; border-radius: 3px; white-space: break-spaces; word-break: break-word; }
.mono { font-family: var(--f-mono); }
.label { font-family: var(--f-mono); font-weight: 700; font-size: .74rem; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
/* columna flex: header y menú con su altura natural, solo <main> crece */
.shell { display: flex; flex-direction: column; min-height: 100dvh; width: 100%; }
.shell > header, .shell > .nav { flex: none; }
.shell > main { flex: 1 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: var(--top-h); box-sizing: content-box;
  padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: var(--top-bg); color: var(--top-ink);
  border-bottom: 2px solid var(--top-line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--f-head); font-size: 1.15rem; white-space: nowrap; }
.brand-badge { background: var(--badge-bg); color: var(--badge-ink); font-family: var(--f-mono); font-weight: 700; font-size: .7rem; letter-spacing: .14em; padding: 3px 7px; }
.topbar .spacer { flex: 1; }
.brand { min-width: 0; overflow: hidden; }
.sync { flex: none; }
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .sync > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.sync { font-family: var(--f-mono); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 6px; }
.sync i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--top-ink); background: #00a676; display: inline-block; }
.sync.pending i { background: var(--yellow); }
.sync.offline i { background: #e0262b; }
.sync.local i { background: #2f5bea; }
.icon-btn { flex: none; width: 38px; height: 38px; display: inline-grid; place-items: center; background: var(--ibtn-bg); color: var(--ibtn-ink); border: 2px solid var(--ibtn-line); box-shadow: 2px 2px 0 var(--ibtn-line); border-radius: var(--radius); cursor: pointer; }
.icon-btn:hover { border-color: var(--yellow); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn svg { width: 20px; height: 20px; }

.nav {
  display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 2px solid var(--line); background: var(--surface);
  position: sticky; top: calc(var(--top-h) + 2px + env(safe-area-inset-top)); z-index: 20;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: 6px 12px; border: 2px solid transparent; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: 7px;
}
.nav a svg { width: 18px; height: 18px; }
.nav a:hover { border-color: var(--soft-line); }
.nav a.active { background: var(--nav-active-bg); color: var(--nav-active-ink); border-color: var(--nav-active-bg); }

main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 22px 16px 96px; min-width: 0; }

/* bottom nav (móvil) */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 2px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a { text-decoration: none; display: grid; justify-items: center; gap: 2px; padding: 8px 2px 7px; font-size: .68rem; font-weight: 600; color: var(--muted); }
  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--ink); }
  .bottom-nav a.active svg { background: var(--yellow); color: #141414; border-radius: 6px; padding: 2px; box-shadow: 2px 2px 0 var(--line); outline: 2px solid var(--line); }
  .brand-text { display: none; }
  body.in-quiz .bottom-nav { display: none; }
}
body.in-quiz .nav { display: none; }

/* ---------- componentes ---------- */
.card {
  background: var(--surface); border: 2px solid var(--card-line); border-radius: var(--radius);
  box-shadow: var(--card-shadow); padding: 18px;
}
.card.flat { box-shadow: none; }
.card + .card { margin-top: 18px; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
@media (max-width: 420px) { .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; } .kpi { padding: 12px; } .kpi b { font-size: 1.6rem; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 18px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 34px 0 14px; }
.section-title::before { content: ''; width: 8px; height: 26px; background: var(--yellow); border: 2px solid var(--line); }
.section-title h2 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; min-height: 46px;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  font-weight: 700; cursor: pointer; text-decoration: none; text-align: center;
  transition: transform .06s, box-shadow .06s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow-c); }
.btn:active { transform: translate(3px, 3px); box-shadow: none; }
.btn.primary { background: var(--yellow); color: #141414; }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border: 2px solid var(--line); border-radius: var(--radius);
  font-family: var(--f-mono); font-weight: 700; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase;
  background: var(--surface);
}
.chip.b1 { background: var(--b1); color: #141414; }
.chip.b2 { background: var(--b2); color: #141414; }
.chip.b3 { background: var(--b3); color: #fff; }
.chip.b4 { background: var(--b4); color: #fff; }
.chip.yellow { background: var(--yellow); color: #141414; }
.chip.ink { background: var(--ink); color: var(--bg); }

/* selector de opciones (segmented / toggles) */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  cursor: pointer; padding: 8px 14px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-weight: 600; user-select: none; display: inline-flex; align-items: center; gap: 6px;
}
.seg input:checked + label { background: var(--nav-active-bg); color: var(--nav-active-ink); border-color: var(--nav-active-bg); box-shadow: 3px 3px 0 var(--shadow-c); }
.seg input:focus-visible + label { outline: 3px solid var(--yellow); outline-offset: 2px; }
.seg label small { font-weight: 400; opacity: .8; }
.field { margin-bottom: 20px; }
.field > .label { display: block; margin-bottom: 8px; }
.field .hint { font-size: .88rem; color: var(--muted); margin-top: 6px; }
input[type=range] { width: 100%; accent-color: var(--yellow); height: 28px; }
input[type=text], input[type=password], input[type=search], input[type=number] {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: inset 2px 2px 0 var(--soft-line);
}

/* barras de progreso */
.bar { height: 12px; border: 2px solid var(--line); border-radius: 3px; background: var(--surface-2); overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; background: var(--yellow); border-right: 2px solid var(--line); }
.bar > span[style*="width: 0"] { border-right: 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--yellow); color: #141414; }
.login { width: 100%; max-width: 420px; }
.login h1 { font-size: clamp(3rem, 14vw, 5.2rem); line-height: .9; margin-bottom: 14px; }
.login .sticker { display: inline-block; background: #fff; border: 2px solid #141414; box-shadow: 4px 4px 0 #141414; padding: 6px 12px; font-family: var(--f-head); transform: rotate(-3deg); margin-bottom: 20px; }
.login .card { background: #fff; color: #141414; border-color: #141414; box-shadow: 6px 6px 0 #141414; }
.login .card input { background: #fff; color: #141414; border-color: #141414; box-shadow: inset 2px 2px 0 #e7e2d6; }
.login .err { color: #b3121a; font-weight: 600; min-height: 1.4em; margin: 8px 0 0; }
.login .btn { background: #141414; color: var(--yellow); box-shadow: 3px 3px 0 #ff5a36; border-color: #141414; }
.login .blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.login .blocks span { border: 2px solid #141414; box-shadow: 3px 3px 0 #141414; padding: 6px 8px; font-weight: 700; font-size: .78rem; font-family: var(--f-head); }

/* ---------- hero / inicio ---------- */
.hero {
  background: var(--yellow); color: #141414; border: 2px solid #141414; box-shadow: var(--shadow);
  padding: 22px; position: relative; overflow: hidden;
}
.hero h1 { font-size: clamp(2.4rem, 8vw, 4.2rem); line-height: .92; margin-bottom: 8px; }
.hero .strip { display: inline-block; background: #141414; color: var(--yellow); font-family: var(--f-mono); font-weight: 700; font-size: .72rem; letter-spacing: .14em; padding: 4px 9px; margin-bottom: 12px; }
.hero .count { position: absolute; right: 18px; top: 18px; background: #fff; border: 2px solid #141414; box-shadow: 4px 4px 0 #141414; padding: 8px 12px; transform: rotate(3deg); text-align: center; }
.hero .count b { display: block; font-family: var(--f-head); font-size: 1.5rem; line-height: 1; }
.hero .count small { font-family: var(--f-mono); font-weight: 700; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
@media (max-width: 560px) { .hero .count { position: static; display: inline-block; margin: 6px 0 12px; } }
.hero-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border: 2px solid #141414; background: #fff; margin-top: 14px; }
.hero-facts div { padding: 10px 12px; border-right: 1px solid #d9d2c3; }
.hero-facts div:last-child { border-right: 0; }
.hero-facts .label { display: block; margin-bottom: 2px; color: #141414; }
.hero-facts p { margin: 0; font-size: .9rem; }

.kpi { padding: 14px 16px; }
.kpi .label { color: var(--muted); }
.kpi b { display: block; font-family: var(--f-head); font-size: 2rem; line-height: 1.1; margin-top: 4px; font-weight: 400; }
.kpi small { color: var(--muted); }

.mode-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; cursor: pointer; position: relative; min-height: 150px; }
.mode-card:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow-c); }
.mode-card .ico { width: 44px; height: 44px; display: grid; place-items: center; border: 2px solid var(--line); background: var(--yellow); color: #141414; border-radius: var(--radius); }
.mode-card .ico svg { width: 24px; height: 24px; }
.mode-card h3 { margin: 6px 0 0; }
.mode-card p { margin: 0; color: var(--ink-2); font-size: .94rem; }
.mode-card .tag { position: absolute; right: 12px; top: 12px; }
.mode-card.feature { background: var(--feature-bg); color: var(--feature-ink); border-color: var(--feature-line); }
.mode-card.feature p { color: var(--feature-ink); opacity: .85; }

.block-card { border-left-width: 12px; }
.block-card.b1 { border-left-color: var(--b1); }
.block-card.b2 { border-left-color: var(--b2); }
.block-card.b3 { border-left-color: var(--b3); }
.block-card.b4 { border-left-color: var(--b4); }
.block-card h3 { margin-bottom: 4px; }
.block-card .meta { display: flex; justify-content: space-between; font-size: .88rem; color: var(--muted); margin: 10px 0 4px; }

/* ---------- quiz ---------- */
.quiz { max-width: 860px; margin: 0 auto; }
.quiz-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.quiz-head .grow { flex: 1; }
.quiz-progress { font-family: var(--f-head); font-size: 1.1rem; }
.timer {
  height: 14px; border: 2px solid var(--line); background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-bottom: 16px;
}
.timer > span { display: block; height: 100%; background: var(--b2); transition: width .25s linear, background .3s; }
.timer.warn > span { background: var(--yellow); }
.timer.danger > span { background: var(--bad); }
.timer-num { font-family: var(--f-mono); font-weight: 700; min-width: 3.2em; text-align: right; font-size: 1.1rem; }
.qcard { padding: 20px; }
.qcard .qtext { font-size: clamp(1.05rem, 2.6vw, 1.25rem); font-weight: 600; line-height: 1.45; margin: 10px 0 14px; }
.options { display: grid; gap: 12px; margin-top: 16px; }
@media (min-width: 760px) { .options.two-col { grid-template-columns: 1fr 1fr; } }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; min-height: 58px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow-sm); cursor: pointer; font-size: 1rem; line-height: 1.4;
  transition: transform .06s, box-shadow .06s, background .15s;
}
.opt:hover:not([disabled]) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow-c); }
.opt:active:not([disabled]) { transform: translate(3px, 3px); box-shadow: none; }
.opt .k {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border: 2px solid var(--line); font-family: var(--f-head); font-size: 1rem; border-radius: 3px; color: #141414;
}
.opt:nth-child(1) .k { background: var(--b1); }
.opt:nth-child(2) .k { background: var(--b2); }
.opt:nth-child(3) .k { background: var(--b3); color: #fff; }
.opt:nth-child(4) .k { background: var(--b4); color: #fff; }
.opt .t { padding-top: 5px; min-width: 0; overflow-wrap: anywhere; }
.opt .t code { background: transparent; border: 0; padding: 0; font-size: 1em; font-weight: 700; }
.opt[disabled] { cursor: default; }
.opt.chosen { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.opt.correct { background: var(--ok-bg); border-color: var(--ok); box-shadow: 3px 3px 0 var(--ok); }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); box-shadow: 3px 3px 0 var(--bad); }
.opt.dim { opacity: .55; }
.opt .mark { margin-left: auto; flex: none; font-weight: 700; padding-top: 5px; }
.opt.correct .mark { color: var(--ok); }
.opt.wrong .mark { color: var(--bad); }

.feedback { margin-top: 18px; border: 2px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.feedback .fb-head { padding: 10px 14px; display: flex; align-items: center; gap: 10px; font-family: var(--f-head); font-size: 1.1rem; border-bottom: 2px solid var(--line); }
.feedback.ok .fb-head { background: var(--ok); color: #fff; }
.feedback.bad .fb-head { background: var(--bad); color: #fff; }
.feedback.blank .fb-head { background: var(--muted); color: #fff; }
.feedback .fb-body { padding: 14px; background: var(--surface); }
.feedback .fb-body p:last-child { margin-bottom: 0; }
.feedback .fb-answer { font-size: .94rem; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--soft-line); margin-bottom: 10px; }
.quiz-foot { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.kbd { font-family: var(--f-mono); font-size: .78rem; color: var(--muted); }
@media (max-width: 760px) { .kbd { display: none; } }
.flag-btn.on { background: var(--yellow); color: #141414; }

/* bloque de código */
pre.code {
  margin: 12px 0; padding: 0; background: var(--code-bg); color: var(--code-ink);
  border: 2px solid var(--card-line); border-radius: var(--radius); overflow: auto; position: relative;
  font: 14.5px/1.55 var(--f-mono); max-width: 100%;
}
pre.code::before { content: '● ● ●'; display: block; padding: 6px 12px; font-size: 10px; letter-spacing: 2px; color: #7a7468; border-bottom: 1px solid #2a2a31; }
pre.code[data-lang]::after { content: attr(data-lang); position: absolute; top: 4px; right: 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #7a7468; }
pre.code code { display: block; padding: 12px 14px 14px; background: none; border: 0; color: inherit; white-space: pre; font-size: inherit; word-break: normal; }
@media (max-width: 560px) { pre.code { font-size: 13px; } }
.tk-c { color: #8b8578; font-style: italic; }
.tk-s { color: #a5e07c; }
.tk-k { color: #ff8a65; font-weight: 700; }
.tk-n { color: #f2b705; }
.tk-v { color: #7cc4ff; }
.tk-t { color: #ff8fd8; }
.tk-a { color: #ffd27a; }

/* resultados */
.score-hero { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
@media (max-width: 560px) { .score-hero { grid-template-columns: 1fr; } }
.score-ring { width: 150px; height: 150px; position: relative; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .v { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring .v b { font-family: var(--f-head); font-size: 2.3rem; line-height: 1; display: block; font-weight: 400; }
.review-item { border: 2px solid var(--card-line); border-radius: var(--radius); background: var(--surface); margin-bottom: 10px; }
.review-item > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; }
.review-item > summary::-webkit-details-marker { display: none; }
.review-item > summary .st { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border: 2px solid var(--line); font-weight: 700; border-radius: 3px; }
.review-item.ok .st { background: var(--ok); color: #fff; }
.review-item.bad .st { background: var(--bad); color: #fff; }
.review-item.blank .st { background: var(--muted); color: #fff; }
.review-item .rb { padding: 0 14px 14px; }
.review-item .q-mini { flex: 1; min-width: 0; }
.review-item .q-mini small { display: block; color: var(--muted); }
.answer-line { padding: 8px 10px; border: 2px solid var(--line); border-radius: 3px; margin: 6px 0; font-size: .95rem; }
.answer-line.ok { background: var(--ok-bg); border-color: var(--ok); }
.answer-line.bad { background: var(--bad-bg); border-color: var(--bad); }

/* teoría */
.theory { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .theory { grid-template-columns: 1fr; } }
.toc { position: sticky; top: 124px; max-height: calc(100dvh - 140px); overflow: auto; padding: 14px; }
@media (max-width: 900px) { .toc { position: static; max-height: none; } }
.toc h4 { font-size: .95rem; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.toc h4:first-child { margin-top: 0; }
.toc h4 i { width: 12px; height: 12px; border: 2px solid var(--line); display: inline-block; }
.toc a { display: block; text-decoration: none; padding: 5px 8px; border-radius: 3px; font-size: .92rem; }
.toc a:hover { background: var(--surface-2); }
.toc a.active { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.toc-select { display: none; }
@media (max-width: 900px) { .toc { display: none; } .toc-select { display: block; } }
.toc-select select { width: 100%; padding: 12px; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius); font-weight: 600; }
.th-article { min-width: 0; }
.th-article h2 { padding-bottom: 10px; border-bottom: 3px solid var(--line); }
.th-h { display: flex; align-items: center; gap: 10px; margin: 28px 0 12px; font-size: 1.12rem; text-transform: uppercase; letter-spacing: .01em; }
.th-h::before { content: ''; width: 6px; height: 22px; background: var(--yellow); flex: none; border: 2px solid var(--line); }
.tag-amp { font-family: var(--f-mono); font-size: .66rem; letter-spacing: .12em; background: var(--surface-2); border: 2px dashed var(--muted); padding: 2px 6px; color: var(--muted); }
.th-article ul, .th-article ol { padding-left: 1.3em; }
.th-article li { margin-bottom: .4em; }
.tbl { overflow-x: auto; margin: 14px 0; border: 2px solid var(--card-line); border-radius: var(--radius); }
.tbl table { width: 100%; border-collapse: collapse; font-size: .93rem; min-width: 480px; }
.tbl th { background: var(--th-bg); color: var(--th-ink); text-align: left; font-family: var(--f-mono); font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; padding: 9px 10px; font-weight: 700; }
.tbl th code { background: transparent; border: 0; color: inherit; }
.tbl td { padding: 9px 10px; border-top: 1px solid var(--soft-line); vertical-align: top; }
.tbl tr:nth-child(odd) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.box { border: 2px solid var(--card-line); border-radius: var(--radius); margin: 16px 0; background: var(--surface); }
.box .box-t { font-family: var(--f-mono); font-weight: 700; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; padding: 6px 12px; border-bottom: 2px solid var(--line); }
.box > p, .box > ul, .box > ol, .box > pre, .box > details { margin-left: 14px; margin-right: 14px; }
.box > p:first-of-type { margin-top: 12px; }
.box > :last-child { margin-bottom: 14px; }
.box.trap { border-color: var(--bad); background: var(--bad-bg); }
.box.trap .box-t { background: var(--bad); color: #fff; border-color: var(--bad); }
.box.tip { background: var(--yellow-soft); }
.box.tip .box-t { background: var(--yellow); color: #141414; }
.box.note .box-t { background: var(--b2); color: #141414; }
.box.remember { background: var(--feature-bg); color: var(--feature-ink); border-color: var(--feature-line); }
.box.remember .box-t { background: var(--yellow); color: #141414; border-color: var(--feature-line); }
.box.remember code { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: inherit; }
.box.remember ul { list-style: none; padding: 0; margin-top: 12px; }
.box.remember li { padding-left: 1.6em; position: relative; }
.box.remember li::before { content: '→'; position: absolute; left: 0; color: var(--yellow); font-weight: 700; }
.box.model .box-t { background: var(--surface-2); }
.box.model ol { padding-left: 2em; }
.box.model details summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.boxmodel { margin: 14px 0; font-family: var(--f-mono); font-size: .8rem; text-align: center; max-width: 420px; }
.boxmodel div { border: 2px dashed var(--line); padding: 8px 14px 14px; }
.bm-m { background: #fff1ee; color: #141414; }
.bm-b { background: #f2b705; border-style: solid !important; }
.bm-p { background: #d8f5e8; }
.bm-c { background: #dfe7ff; border-style: solid !important; padding: 14px !important; }
.svg-demo { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.svg-demo svg { border: 2px solid var(--line); background: var(--surface-2); }
mark { background: var(--yellow); color: #141414; padding: 0 2px; }

/* estadísticas */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--ink); color: var(--bg);
  padding: 6px 9px; border-radius: 3px; font-size: .82rem; white-space: nowrap; transform: translate(-50%, -115%);
  opacity: 0; transition: opacity .1s;
}
.chart-tip.on { opacity: 1; }
.hbar { display: grid; grid-template-columns: minmax(0, 190px) minmax(60px, 1fr) 54px; gap: 10px; align-items: center; margin: 10px 0; font-size: .92rem; }
.hbar .track { height: 18px; background: var(--surface-2); border: 2px solid var(--line); border-radius: 3px; position: relative; overflow: hidden; }
.hbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-right: 2px solid var(--line); }
.hbar .val { text-align: right; font-family: var(--f-mono); font-weight: 700; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-dot { width: 12px; height: 12px; display: inline-block; border: 2px solid var(--line); vertical-align: -1px; margin-right: 6px; }
.topic-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--soft-line); }
.topic-row:first-child { border-top: 0; }
.topic-row > div { min-width: 0; }
@media (max-width: 400px) { .topic-row { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; } .topic-row .btn.small { padding: 6px 9px; } }
.topic-row .num { font-family: var(--f-head); font-size: 1.05rem; }
.topic-row .bar { margin-top: 6px; }
.topic-row small { color: var(--muted); }
.list-plain { list-style: none; padding: 0; margin: 0; }
table.hist { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.hist th { text-align: left; font-family: var(--f-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--line); }
table.hist td { padding: 8px; border-bottom: 1px solid var(--soft-line); }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-family: var(--f-head); font-size: 1.2rem; font-weight: 400; margin-bottom: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); z-index: 100;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border: 2px solid var(--yellow);
  font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: grid; place-items: center; padding: 16px; }
.modal { max-width: 440px; width: 100%; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- barra de descarga PDF ---------- */
.pdf-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; padding: 12px 16px; background: var(--yellow-soft); }
.pdf-bar select { padding: 8px 10px; min-height: 36px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); font-weight: 600; max-width: 100%; }
@media (max-width: 560px) { .pdf-bar .row { width: 100%; } .pdf-bar select, .pdf-bar .btn { width: 100%; } }
#printArea { display: none; }

/* ---------- impresión / PDF de la teoría ---------- */
@page { size: A4; margin: 14mm 13mm 16mm; }
@media print {
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing { background: #fff !important; }
  body.printing #printArea {
    display: block;
    /* siempre en claro, aunque la app esté en modo oscuro */
    --bg: #fff; --surface: #fff; --surface-2: #f3ecdc; --ink: #141414; --ink-2: #3d3a33; --muted: #6f695d;
    --line: #141414; --soft-line: #d9d2c3; --card-line: #141414; --yellow-soft: #fff8db;
    --ok: #00875f; --ok-bg: #e3f7ee; --bad: #e0262b; --bad-bg: #fff1ee;
    --feature-bg: #141414; --feature-ink: #fff; --feature-line: #141414; --th-bg: #141414; --th-ink: #fff;
    color: #141414; background: #fff; font-size: 10.5pt; line-height: 1.45;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  #printArea .p-cover { break-after: page; }
  #printArea .p-strip { display: inline-block; background: #141414; color: #f2b705; font: 700 8pt var(--f-mono); letter-spacing: .14em; padding: 4px 8px; }
  #printArea .p-cover h1 { font-size: 64pt; line-height: .9; margin: 18px 0 6px; }
  #printArea .p-sub { font-family: var(--f-head); font-size: 20pt; margin: 0 0 18px; }
  #printArea .p-facts { display: grid; grid-template-columns: 1fr 1fr 1fr; border: 2px solid #141414; margin-bottom: 22px; }
  #printArea .p-facts div { padding: 8px 10px; border-right: 1px solid #d9d2c3; font-size: 9pt; }
  #printArea .p-facts div:last-child { border-right: 0; }
  #printArea .p-facts b { display: block; font: 700 7.5pt var(--f-mono); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 2px; }
  #printArea .p-toc h2 { font-size: 14pt; border-bottom: 3px solid #141414; padding-bottom: 6px; }
  #printArea .p-toc ol { columns: 2; column-gap: 24px; padding-left: 2.2em; margin: 0; }
  #printArea .p-toc li { margin-bottom: 4px; break-inside: avoid; }
  #printArea .p-sec { break-before: page; }
  #printArea .p-sec > h2 { font-size: 17pt; padding: 0 0 8px 12px; border-bottom: 3px solid #141414; border-left: 10px solid #f2b705; margin-bottom: 12px; }
  #printArea .p-sec.pb1 > h2 { border-left-color: #ff5a36; }
  #printArea .p-sec.pb2 > h2 { border-left-color: #00a676; }
  #printArea .p-sec.pb3 > h2 { border-left-color: #2f5bea; }
  #printArea .p-sec.pb4 > h2 { border-left-color: #b23ad6; }
  #printArea .th-h { font-size: 11.5pt; margin: 16px 0 8px; break-after: avoid; }
  #printArea p, #printArea li { orphans: 3; widows: 3; }
  #printArea .tbl { overflow: visible; }
  #printArea .tbl table { min-width: 0; font-size: 9pt; }
  #printArea tr, #printArea .box, #printArea pre.code, #printArea .boxmodel, #printArea .svg-demo { break-inside: avoid; }
  #printArea .box.remember { break-inside: auto; }
  #printArea code { background: #f3ecdc; border-color: #d9d2c3; color: #141414; }
  #printArea pre.code { background: #f7f4ec; color: #141414; border: 1.5px solid #141414; font-size: 8.6pt; overflow: visible; }
  #printArea pre.code code { white-space: pre-wrap; word-break: break-word; background: none; border: 0; }
  #printArea pre.code::before, #printArea pre.code::after { color: #8b8578; }
  #printArea .tk-c { color: #7a7468; } #printArea .tk-s { color: #1d7a2e; } #printArea .tk-k { color: #b3261e; }
  #printArea .tk-n { color: #9a6a00; } #printArea .tk-v { color: #1f4fd1; } #printArea .tk-t { color: #a0227f; } #printArea .tk-a { color: #8a5a00; }
  #printArea .box.remember code { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.3); }
  #printArea details summary { display: none; }
  #printArea details > p::before { content: 'Respuesta: '; font-weight: 700; }
  #printArea .tag-amp { border-color: #6f695d; }
  #printArea a { text-decoration: none; }
}
