/* Prueba 2 — hoja de prueba: papel con renglones, margen rojo, tinta azul para acciones, marcador para lo importante. */
@font-face { font-family: "Manrope"; font-weight: 200 800; font-display: swap; src: url("assets/fonts/manrope-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 100 900; font-display: swap; src: url("assets/fonts/fraunces-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("assets/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500 700; font-display: swap; src: url("assets/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --paper: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #1E1F22;
  --muted: #6C707E;
  --line: #DFE1E5;
  --rule: transparent;
  --red: #C7222D;
  --red-soft: #FBE3E4;
  --blue: #2F63D6;
  --blue-soft: #E3ECFC;
  --ok: #1F7A3A;
  --ok-soft: #DFF2E3;
  --mark: #F5E38B;
  --code-bg: #1E1F22;
  --code-ink: #DFE1E5;
  --code-dim: #868A91;
  --serif: "Manrope", system-ui, sans-serif;
  --sans: "Manrope", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --col: 780px;
  --margin: 0px;
}
html[data-theme="dark"] {
  --paper: #2B2D30;
  --surface: #313338;
  --ink: #DFE1E5;
  --muted: #9DA0A8;
  --line: #43454A;
  --rule: transparent;
  --red: #F75464;
  --red-soft: #402A2D;
  --blue: #6B9BFA;
  --blue-soft: #2E436E;
  --ok: #6AAB73;
  --ok-soft: #2B3D2F;
  --mark: #5C4E1A;
  --code-bg: #1E1F22;
  --code-ink: #DFE1E5;
  --code-dim: #868A91;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 116px; }
body {
  margin: 0; color: var(--ink); font: 17px/1.62 var(--sans);
  background: var(--paper);
}
a { color: var(--blue); text-underline-offset: 3px; }
b, strong { font-weight: 700; }
code { font: .86em var(--mono); background: color-mix(in srgb, var(--line) 60%, transparent); padding: .08em .34em; border-radius: 4px; }
kbd { font: 600 .78em var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: .08em .45em; background: var(--surface); white-space: nowrap; }
p { margin: 0 0 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }
.c-red { color: var(--red); } .c-blue { color: var(--blue); }

/* ---------- barra con progreso ---------- */
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 9px 16px; background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.back { font-weight: 700; text-decoration: none; white-space: nowrap; }
.prog { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; max-width: 360px; }
.prog-txt { font: 500 13px var(--mono); color: var(--muted); white-space: nowrap; }
.prog-txt b { color: var(--ink); font-size: 15px; }
.prog-bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.prog-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--ok)); border-radius: inherit; transition: width .4s cubic-bezier(.2,.8,.2,1); }
.bar-r { margin-left: auto; display: flex; gap: 8px; }
.pill {
  font: 700 13px var(--sans); border: 1.5px solid var(--blue); color: #fff; background: var(--blue);
  border-radius: 999px; padding: 7px 15px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .12s, background .2s;
}
.pill:active { transform: scale(.97); }
html[data-theme="dark"] .pill { color: #0B1030; }
.pill.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.pill[aria-pressed="true"] { background: var(--red); border-color: var(--red); }
html[data-theme="dark"] .pill[aria-pressed="true"] { color: #2A0905; }

.toc {
  position: sticky; top: 55px; z-index: 19; display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none;
  padding: 7px 16px; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.toc::-webkit-scrollbar { display: none; }
.toc-g { font: 700 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--red); padding: 0 6px 0 12px; white-space: nowrap; }
.toc-g:first-child { padding-left: 0; }
.toc a { font: 500 12.5px var(--mono); color: var(--muted); text-decoration: none; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--paper); background: var(--ink); }
.toc a.is-done::after { content: " ✓"; color: var(--ok); }
.toc a.on.is-done::after { color: inherit; }

/* ---------- columna con margen rojo ---------- */
main { position: relative; max-width: calc(var(--col) + var(--margin) + 32px); margin: 0 auto; padding: 0 16px 56px calc(var(--margin) + 16px); }
main::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--margin) - 4px); width: 2px;
  background: var(--red); opacity: .55;
}
@media (max-width: 720px) {
  :root { --margin: 0px; }
  main::before { display: none; }
}

/* ---------- hero ---------- */
.hero { display: grid; gap: 28px; padding: 44px 0 28px; }
.kicker { font: 700 11.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--red); margin: 0 0 12px; }
h1 { font: 650 clamp(42px, 9vw, 76px)/.98 var(--serif); letter-spacing: -.025em; margin: 0 0 18px; font-variation-settings: "SOFT" 60, "opsz" 144; }
h1 .arrow { color: var(--red); display: inline-block; }
.lead { font-size: 20px; line-height: 1.5; margin: 0 0 20px; }
.lead b { font-weight: 800; }
.facts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.facts li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 14px; }
.facts b { font: 700 19px var(--serif); margin-right: 4px; }

.shots { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 8px 4px 0; }
.big2 {
  position: absolute; right: -6px; top: -54px; font: 800 260px/1 var(--serif); color: transparent;
  -webkit-text-stroke: 2px var(--red); opacity: .22; pointer-events: none; user-select: none;
}
.shots figure { position: relative; margin: 0; flex: 1; min-width: 0; }
.shots img { width: 100%; height: auto; display: block; border-radius: 16px; border: 7px solid var(--ink); background: #fff; box-shadow: 0 18px 36px -18px rgba(0,0,0,.5); }
.shots .s1 { transform: rotate(-2deg); margin-top: 26px; }
.shots .s2 { transform: rotate(1.5deg); }
.shots figcaption { font: 600 12px var(--mono); color: var(--muted); margin-top: 10px; text-align: center; }
@media (min-width: 940px) {
  .hero { grid-template-columns: 1fr 330px; align-items: center; }
}
@media (prefers-reduced-motion: no-preference) {
  .hero-txt > * { animation: rise .6s cubic-bezier(.2,.8,.2,1) both; }
  .hero-txt > :nth-child(2) { animation-delay: .06s; }
  .hero-txt > :nth-child(3) { animation-delay: .12s; }
  .hero-txt > :nth-child(4) { animation-delay: .18s; }
  .shots .s1 { animation: drop1 .7s .2s cubic-bezier(.2,.8,.2,1) both; }
  .shots .s2 { animation: drop2 .7s .32s cubic-bezier(.2,.8,.2,1) both; }
  h1 .arrow { animation: nudge 2.4s 1s ease-in-out infinite; }
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes drop1 { from { opacity: 0; transform: translateY(24px) rotate(-6deg); } }
@keyframes drop2 { from { opacity: 0; transform: translateY(24px) rotate(5deg); } }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 80% { transform: translateX(6px); } }

/* ---------- mapa de la ruta ---------- */
.map { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 10px 0 34px; border: 1.5px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--surface); }
.map a { position: relative; display: grid; gap: 1px; padding: 12px 14px 12px 16px; text-decoration: none; color: var(--ink); border-right: 1.5px solid var(--ink); transition: background .2s; }
.map a:last-child { border-right: 0; }
.map a:hover { background: var(--blue-soft); }
.map b { font: 700 18px var(--serif); }
.map span { font: 600 11.5px var(--mono); color: var(--muted); }
.map em { font-style: normal; font-size: 13.5px; color: var(--muted); }
.map a::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; }
.m-armar::before { background: var(--blue); } .m-prog::before { background: var(--red); }
.m-entr::before { background: var(--ink); } .m-cerr::before { background: var(--ok); }
@media (max-width: 720px) {
  .map { grid-template-columns: 1fr 1fr; }
  .map a:nth-child(2) { border-right: 0; }
  .map a:nth-child(-n+2) { border-bottom: 1.5px solid var(--ink); }
}

/* ---------- secciones ---------- */
.block { position: relative; padding: 34px 0 10px; }
.block + .block { border-top: 1px dashed var(--line); }
h2 { font: 650 clamp(25px, 4.6vw, 32px)/1.15 var(--serif); margin: 0 0 12px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; letter-spacing: -.01em; }
h2 .n {
  font: 700 40px/1 var(--serif); color: var(--red); font-variation-settings: "SOFT" 100, "WONK" 1;
  position: absolute; left: calc(-1 * var(--margin) - 4px); width: calc(var(--margin) - 14px); text-align: right; top: 34px;
}
@media (max-width: 720px) {
  h2 .n { position: static; width: auto; font-size: 34px; }
}
.step.is-done h2 .n { color: var(--ok); }
.step.is-done h2 .n::after { content: "✓"; font-size: 22px; margin-left: 2px; }
h2 .t { font: 600 12px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; background: var(--surface); }
h3 { font: 700 18px/1.3 var(--sans); margin: 0 0 6px; }
h3.sub { font: 650 21px var(--serif); margin: 26px 0 10px; display: flex; align-items: center; gap: 10px; }
.ab { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--ink); font: 700 14px var(--mono); }

.gist {
  font-size: 19px; line-height: 1.5; font-weight: 600; margin: 0 0 16px; max-width: 62ch;
}
.gist { background: linear-gradient(transparent 58%, color-mix(in srgb, var(--mark) 75%, transparent) 58%, color-mix(in srgb, var(--mark) 75%, transparent) 92%, transparent 92%); display: inline; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.gist + * { margin-top: 16px; }
.where { color: var(--muted); font-size: 15.5px; }

/* verbos de acción */
.v {
  display: inline-block; font: 700 11px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 7px; border-radius: 5px; margin-right: 6px; vertical-align: 2px; white-space: nowrap;
}
.v.clic { background: var(--blue); color: #fff; }
.v.arr { background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1.5px var(--blue); }
.v.esc { background: var(--ink); color: var(--paper); }
.v.ojo { background: var(--red-soft); color: var(--red); }
.v.ok { background: var(--ok-soft); color: var(--ok); }
html[data-theme="dark"] .v.clic { color: #0B1030; }

.do { list-style: none; counter-reset: d; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.do li { counter-increment: d; position: relative; padding: 10px 14px 10px 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.do li::before { content: counter(d); position: absolute; left: 12px; top: 10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 12px var(--mono); color: var(--muted); border: 1.5px solid var(--line); }
.rules, .traps { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.rules li, .traps li { padding: 2px 0; }
.why { border-left: 4px solid var(--blue); padding: 6px 0 6px 14px; font-size: 16px; max-width: 64ch; }
.expect { border-left: 4px solid var(--ok); padding: 6px 0 6px 14px; }
.proof { font-size: 14px; color: var(--muted); }
.hint-sm { font-size: 14px; color: var(--muted); }
.file { font: 700 12.5px var(--mono); margin: 18px 0 6px; letter-spacing: .02em; }

/* botón hecho */
.done {
  display: inline-flex; align-items: center; gap: 10px; margin: 8px 0 6px; padding: 10px 16px 10px 12px;
  font: 700 14px var(--sans); color: var(--ink); background: var(--surface); border: 1.5px solid var(--ink); border-radius: 10px; cursor: pointer;
  transition: background .2s, color .2s, transform .12s;
}
.done::before { content: ""; width: 20px; height: 20px; border-radius: 5px; border: 2px solid currentColor; display: grid; place-items: center; font-size: 14px; line-height: 1; }
.done:active { transform: scale(.98); }
.done[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
html[data-theme="dark"] .done[aria-pressed="true"] { color: #062213; }
.done[aria-pressed="true"]::before { content: "✓"; }
@media (prefers-reduced-motion: no-preference) {
  .done[aria-pressed="true"]::before { animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
}
@keyframes pop { from { transform: scale(.3); } }

/* ---------- código ---------- */
.code {
  position: relative; margin: 0 0 16px; background: var(--code-bg); color: var(--code-ink);
  border-radius: 10px; padding: 16px 18px; overflow-x: auto; font: 13.5px/1.65 var(--mono); tab-size: 4;
  border-left: 5px solid var(--blue);
}
.logic .code { border-left-color: var(--red); }
.code code { background: none; padding: 0; font: inherit; color: inherit; }
.code .dim { color: var(--code-dim); }
.code .add { color: #fff; }
.code.stockonly { border-left-color: var(--code-dim); font-size: 12.5px; }
.code .copy {
  position: absolute; top: 8px; right: 8px; z-index: 1; font: 600 11px var(--mono); color: var(--code-ink);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); border-radius: 5px; padding: 3px 9px; cursor: pointer;
}
.code.drill .copy { display: none; }
details.full { margin: 0 0 14px; }
details.full summary { cursor: pointer; font: 600 13px var(--mono); color: var(--blue); padding: 6px 0; }
details.full[open] summary { margin-bottom: 8px; }

/* modo memoria */
body.mem .code.mem:not(.open) { cursor: pointer; }
body.mem .code.mem:not(.open) code { filter: blur(7px); user-select: none; }
body.mem .code.mem:not(.open)::after {
  content: "Escríbelo de memoria · toca para destapar"; position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 14px var(--mono); color: #fff; text-align: center; padding: 16px;
  background: radial-gradient(closest-side, rgba(0,0,0,.35), transparent);
}
body.mem .code.mem:not(.open) .copy { display: none; }

/* ---------- tablas del editor visual ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font: 700 11px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
table.gui td:first-child { font: 700 14px var(--serif); color: var(--red); }
table.gui td:nth-child(2) { white-space: nowrap; }
table.gui td { line-height: 1.75; }
code.sw::before { content: ""; display: inline-block; width: .85em; height: .85em; border-radius: 3px; margin-right: .35em; vertical-align: -.08em; }
code.sw.r::before { background: #FF0000; } code.sw.b::before { background: #0000FF; }
@media (max-width: 560px) {
  table.gui, table.gui tbody, table.gui tr, table.gui td { display: block; }
  table.gui thead { display: none; }
  table.gui { background: transparent; border: 0; }
  table.gui tr { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: grid; grid-template-columns: 28px 1fr; column-gap: 8px; }
  table.gui td { border: 0; padding: 1px 0; white-space: normal; }
  table.gui td:first-child { grid-row: span 3; font-size: 20px; }
  table.gui td:nth-child(3) code { white-space: nowrap; }
}

/* ---------- entrenar ---------- */
.train-head {
  margin: 40px calc(-16px) 0; padding: 26px 20px 22px; border-radius: 14px;
  background: var(--code-bg); color: var(--code-ink);
}
.train-head .kicker { color: #FF8A7E; }
.train-lead { font: 650 26px/1.2 var(--serif); margin: 0 0 14px; }
.train-steps { list-style: none; counter-reset: t; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.train-steps li { counter-increment: t; }
.train-steps a {
  display: block; height: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.18);
  color: var(--code-ink); text-decoration: none; font-weight: 600; font-size: 14.5px;
}
.train-steps a::before { content: counter(t, upper-alpha); display: block; font: 700 22px var(--serif); color: #FF8A7E; }
.train-steps a:hover { background: rgba(255,255,255,.07); }
@media (max-width: 720px) { .train-steps { grid-template-columns: 1fr 1fr; } }
.train h2 .n { color: var(--ink); }

.ideas { display: grid; gap: 12px; margin-bottom: 8px; }
@media (min-width: 760px) { .ideas { grid-template-columns: 1fr 1fr; } }
.ideas article { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 8px; padding: 14px 16px; }
.ideas article + article { border-top-color: var(--red); }
.ideas p { font-size: 15.5px; margin-bottom: 6px; }
.flow, .trace { display: flex; flex-wrap: wrap; gap: 4px 0; align-items: center; }
.flow span, .trace span { display: inline-flex; align-items: center; font-size: 14px; }
.flow span { font-weight: 700; background: var(--blue-soft); color: var(--blue); padding: 3px 9px; border-radius: 6px; }
.flow span + span::before, .trace span + span::before { content: "›"; color: var(--muted); font-weight: 700; margin: 0 7px; background: none; }

.lines { list-style: none; padding: 0; margin: 0 0 18px; counter-reset: ln; }
.lines li { counter-increment: ln; position: relative; padding: 9px 0 9px calc(38px + var(--i, 0) * 16px); border-bottom: 1px dashed var(--line); }
.lines li::before { content: counter(ln); position: absolute; left: 0; top: 12px; font: 600 11px var(--mono); color: var(--muted); width: 26px; text-align: right; }
.lines li > code { display: inline-block; font-size: 13px; background: var(--code-bg); color: var(--code-ink); padding: 4px 9px; border-radius: 5px; overflow-wrap: anywhere; }
.lines li p { margin: 6px 0 0; font-size: 15.5px; }
.lines li.brace { padding-top: 1px; padding-bottom: 1px; border-bottom-style: none; }
.lines li.brace > code { background: transparent; color: var(--muted); padding: 0 2px; }

.qa { display: grid; gap: 8px; }
.qa details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; transition: border-color .2s; }
.qa details[open] { border-color: var(--ink); }
.qa summary { cursor: pointer; padding: 12px 14px 12px 50px; font-weight: 650; list-style: none; position: relative; }
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before {
  content: "?"; position: absolute; left: 14px; top: 11px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); font: 700 14px var(--mono);
}
.qa details[open] summary::before { content: "!"; background: var(--red-soft); color: var(--red); }
.qa details p { margin: 0; padding: 0 14px 10px 50px; font-size: 15.5px; }
.qa .trace { padding-top: 2px; padding-bottom: 8px; }
.qa .trace span:last-child { color: var(--red); }

.gap {
  font: inherit; color: #fff; background: rgba(255,255,255,.08); border: 0; border-bottom: 2px dashed #8EA2FF; text-align: center;
  width: calc(var(--w) * 1ch + 18px); height: 1.7em; padding: 0 6px; border-radius: 5px 5px 0 0; transition: background .15s, border-color .15s;
}
.gap:focus { outline: none; background: rgba(142,162,255,.26); border-bottom-style: solid; }
.gap.ok { border-bottom: 2px solid #5FD394; background: rgba(95,211,148,.2); color: #C9F5DA; }
.gap.bad { border-bottom: 2px solid #FF6B5E; background: rgba(255,107,94,.22); }
@media (prefers-reduced-motion: no-preference) { .gap.bad { animation: shake .3s; } }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* ejercicio de huecos: una fila por línea */
.drill-top { margin: 0 0 14px; display: grid; gap: 8px; }
.drill-meter { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; }
.drill-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--ok)); border-radius: inherit; transition: width .35s cubic-bezier(.2,.8,.2,1); }
.drill-live { margin: 0; font: 500 15px var(--mono); color: var(--muted); max-width: none; }
.drill-live b { font: 700 28px var(--serif); color: var(--ink); margin-right: 2px; }
.drill-keys { margin: 0; font-size: 14px; color: var(--muted); max-width: none; }
.drill-win { margin: 0 0 16px; background: var(--code-bg); color: var(--code-ink); border-radius: 12px; border-left: 5px solid var(--red); overflow: hidden; }
.drill-wh { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 10px; background: rgba(255,255,255,.04); }
.drill-wh h3 { margin: 0; font: 650 19px var(--serif); color: var(--code-ink); }
.drill-file { font: 500 13px var(--mono); color: var(--code-dim); }
.drill-cnt { margin-left: auto; font: 700 13px var(--mono); padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.1); }
.drill-cnt.all { background: #1E6B42; color: #E3FFEE; }
.drill-list { list-style: none; margin: 0; padding: 0; }
.drill-row { display: grid; grid-template-columns: 34px 1fr auto; column-gap: 12px; align-items: start; padding: 10px 14px 10px 12px; border-top: 1px solid rgba(255,255,255,.07); transition: background .15s, box-shadow .15s; }
.drill-row:focus-within { background: rgba(255,233,122,.08); box-shadow: inset 3px 0 0 #FFE97A; }
.drill-row.ok-row { box-shadow: inset 3px 0 0 #5FD394; }
.drill-row.bad-row { box-shadow: inset 3px 0 0 #FF6B5E; }
.dn { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 12.5px var(--mono); color: var(--code-dim); border: 1.5px solid rgba(255,255,255,.2); margin-top: .3em; }
.drill-row.ok-row .dn { background: #1E6B42; border-color: #1E6B42; color: transparent; position: relative; }
.drill-row.ok-row .dn::after { content: "✓"; position: absolute; color: #E3FFEE; font-size: 14px; }
.drill-row.bad-row .dn { border-color: #FF6B5E; color: #FF8A7E; }
.dl { display: block; padding-left: calc(var(--ind, 0) * 1ch); font: 14.5px/2.15 var(--mono); background: none; color: inherit; overflow-wrap: anywhere; white-space: pre-wrap; }
.dbtns { display: flex; gap: 6px; padding-top: .35em; }
.dbtns button { font: 600 12.5px var(--sans); color: var(--code-ink); background: transparent; border: 1px solid rgba(255,255,255,.25); border-radius: 99px; padding: 5px 12px; cursor: pointer; }
.dbtns button:hover { background: rgba(255,255,255,.1); }
.dbtns .dh[aria-expanded="true"] { background: #FFE97A; color: #1A1600; border-color: #FFE97A; }
.dnote { grid-column: 2 / -1; margin: 8px 0 2px; padding: 8px 12px; border-left: 3px solid #FFE97A; background: rgba(255,233,122,.09); font: 15px/1.5 var(--sans); color: var(--code-ink); max-width: none; }
.dnote code { background: rgba(255,255,255,.12); color: inherit; }
.dnote[hidden] { display: none; }
@media (max-width: 640px) {
  .drill-row { grid-template-columns: 30px 1fr; }
  .dbtns { grid-column: 2; padding-top: 0; margin-top: 2px; }
}
.drill-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 12px; }
.score { font: 700 13.5px var(--mono); color: var(--ink); }

.skel { display: grid; gap: 12px; margin-bottom: 16px; }
@media (min-width: 760px) { .skel { grid-template-columns: 1fr 1fr; } }
.skel > div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 2px 16px 12px; }
.skel ol { padding-left: 22px; margin: 0; }
.skel li { margin-bottom: 5px; font-size: 15.5px; }
.skel li::marker { font: 700 13px var(--mono); color: var(--red); }
.tabs { display: flex; gap: 4px; margin-bottom: -1px; }
.tabs button { font: 700 13px var(--mono); padding: 8px 15px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--code-bg); color: var(--code-ink); border-color: var(--code-bg); }
.write textarea {
  display: block; width: 100%; min-height: 320px; resize: vertical; margin: 0 0 10px;
  font: 13.5px/1.65 var(--mono); color: var(--code-ink); background: var(--code-bg); caret-color: #8EA2FF;
  border: 0; border-left: 5px solid var(--red); border-radius: 0 10px 10px 10px; padding: 16px 18px; tab-size: 4;
}
.write textarea::placeholder { color: var(--code-dim); }
.write textarea:focus { outline: 2.5px solid var(--blue); outline-offset: 2px; }
.diff { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }
.diff li { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.diff li::before { font: 700 13px var(--mono); flex: none; width: 16px; }
.diff li.ok::before { content: "✓"; color: var(--ok); }
.diff li.miss::before { content: "✗"; color: var(--red); }
.diff li.ok code { color: var(--muted); background: transparent; }
.diff li.miss code { background: var(--red-soft); color: var(--ink); overflow-wrap: anywhere; }

.checks { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.checks label { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; cursor: pointer; transition: background .2s; }
.checks input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--ok); flex: none; }
.checks label:has(input:checked) { background: var(--ok-soft); color: var(--muted); }

.foot { max-width: calc(var(--col) + var(--margin) + 32px); margin: 0 auto; padding: 20px 16px 44px calc(var(--margin) + 16px); color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }

.two > *, .hero > *, .ideas > *, .skel > * { min-width: 0; }
p code, li code, td code, summary code { overflow-wrap: anywhere; }

@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .back span { display: none; }
  .gist { font-size: 18px; }
  .lead { font-size: 18px; }
  .code { font-size: 12.5px; padding: 14px; }
  .big2 { font-size: 200px; top: -30px; }
  .train-head { margin-left: 0; margin-right: 0; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
@media (max-width: 939px) { .big2 { display: none; } }
.gist + * { margin-top: 22px; }
.flow { gap: 6px 20px; }
.flow span { position: relative; }
.flow span + span::before { position: absolute; left: -15px; margin: 0; }

/* ---------- colores del código (mismo esquema en claro y oscuro: el fondo del código siempre es oscuro) ---------- */
.code .kw, .lines code .kw { color: #FF8A7E; }
.code .st, .lines code .st { color: #F2C46B; }
.code .tp, .lines code .tp { color: #FFE9B0; font-weight: 600; }
.code .rid, .lines code .rid { color: #9FB2FF; }
.code .ty, .lines code .ty { color: #7FD8C8; }
.code .nu, .lines code .nu { color: #8EE0A6; }
.code .cm, .lines code .cm { color: var(--code-dim); font-style: italic; }
.code .dim .kw, .code .dim .st, .code .dim .ty, .code .dim .rid { color: inherit; }
.legend-code { display: flex; flex-wrap: wrap; gap: 6px 14px; font: 600 12px var(--mono); color: var(--muted); margin: -6px 0 16px; }
.legend-code i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- botones de la barra ---------- */
.pill.alt { background: transparent; color: var(--ink); border-color: var(--ink); }
.pill.alt[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.pill:disabled { opacity: .35; cursor: default; }
@media (max-width: 560px) {
  .lg { display: none; }
  .bar { gap: 8px; padding: 8px 12px; }
  .pill { padding: 6px 11px; font-size: 12.5px; }
  .prog-txt { font-size: 12px; }
}

/* ---------- esquema del editor ---------- */
.ide {
  margin: 4px 0 18px; border: 1.5px solid #2B2F38; border-radius: 10px; overflow: hidden;
  background: #1E1F22; color: #CED0D6; font: 12px/1.4 var(--sans);
}
.ide-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; background: #2B2D30; border-bottom: 1px solid #393B40; }
.ide-file { font: 600 11.5px var(--mono); color: #DFE1E5; }
.ide-modes { position: relative; display: flex; gap: 2px; font: 600 11px var(--sans); border-radius: 6px; padding: 2px; }
.ide-modes i, .ide-modes b { font-style: normal; padding: 3px 8px; border-radius: 4px; }
.ide-modes b { background: #3574F0; color: #fff; }
.ide-body { display: grid; grid-template-columns: 1.25fr .8fr 1fr; min-height: 250px; }
.ide-left { display: grid; grid-template-rows: auto 1fr; border-right: 1px solid #393B40; }
.ide-h { margin: 0 0 6px; font: 700 11px var(--sans); color: #DFE1E5; display: flex; align-items: center; gap: 6px; }
.ide-pal, .ide-tree, .ide-attrs { position: relative; padding: 9px 10px; }
.ide-pal { border-bottom: 1px solid #393B40; }
.ide-cols { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.ide ul { list-style: none; margin: 0; padding: 0; }
.ide-cat li { padding: 1px 6px; color: #9DA0A8; border-radius: 3px; }
.ide-cat li.on { background: #2E436E; color: #fff; }
.ide-items li { padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ide-items li.pick { color: #fff; font-weight: 700; }
.ide-tree ul ul { padding-left: 14px; }
.ide-tree em { color: #9DA0A8; font-style: normal; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.dot.r { background: #FF0000; } .dot.b { background: #0000FF; }
.ide-canvas { display: grid; place-items: center; padding: 12px; background: #2B2D30 radial-gradient(#3A3D42 1px, transparent 1px) 0 0 / 12px 12px; }
.ide-dev { width: 92px; height: 170px; background: #fff; border-radius: 10px; border: 4px solid #111; padding: 14px 7px; display: grid; align-content: start; gap: 6px; }
.ide-dev i { display: block; height: 14px; border-radius: 2px; }
.ide-dev i.r { background: #FF0000; } .ide-dev i.b { background: #0000FF; border-radius: 8px; }
.ide-attrs { border-left: 1px solid #393B40; }
.ide-attrs dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 8px; margin: 0; }
.ide-attrs dt { color: #9DA0A8; }
.ide-attrs dd { margin: 0; color: #fff; font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }
.ide-attrs dd.x { color: #FF8A7E; }
.ide-tag {
  position: absolute; top: -1px; right: -1px; z-index: 2; width: 20px; height: 20px; border-radius: 0 0 0 8px;
  display: grid; place-items: center; font: 700 11px var(--mono); background: #FFE97A; color: #1A1600;
}
.ide-modes .ide-tag { position: static; border-radius: 50%; width: 18px; height: 18px; margin-right: 4px; align-self: center; }
.ide [data-r] { transition: box-shadow .25s, background .25s; }
.ide [data-r].hl { box-shadow: inset 0 0 0 2.5px #FFE97A; background-color: rgba(255,233,122,.08); }
@media (prefers-reduced-motion: no-preference) { .ide [data-r].hl { animation: glow 1.4s ease-in-out infinite; } }
@keyframes glow { 50% { box-shadow: inset 0 0 0 2.5px rgba(255,233,122,.35); } }
.ide figcaption { padding: 8px 10px; font-size: 12.5px; color: #9DA0A8; border-top: 1px solid #393B40; background: #2B2D30; }
.ide figcaption b { color: #FFE97A; }
#p2 [data-hl] { cursor: pointer; }
#p2 .do li[data-hl]:hover, #p2 .do li.sel { border-color: var(--ink); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mark) 70%, transparent); }
@media (max-width: 640px) {
  .ide-body { grid-template-columns: 1.3fr 1fr; }
  .ide-canvas { display: none; }
  .ide { font-size: 11.5px; }
}

/* ---------- simulador ---------- */
.sim-try { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 12px; }
.sim-try-l { font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--red); margin-right: 4px; }
.sim-try button { font: 600 13px var(--mono); padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.sim-try button:hover { border-color: var(--ink); }

.sim-ctl { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0 0 6px; }
.sim-play { display: flex; gap: 6px; flex-wrap: wrap; }
.sim-cb { font: 700 13px var(--sans); padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; white-space: nowrap; }
.sim-cb.ghost { background: transparent; color: var(--ink); }
.sim-cb:disabled { opacity: .35; cursor: default; }
.sim-cb[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.sim-speed { display: inline-flex; align-items: center; flex-wrap: wrap; }
.sim-lbl { font: 700 12px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 8px; }
.sim-speed button { font: 700 13px var(--mono); padding: 7px 11px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; margin-left: -1.5px; }
.sim-speed button:nth-of-type(1) { border-radius: 999px 0 0 999px; margin-left: 0; }
.sim-speed button:last-of-type { border-radius: 0 999px 999px 0; }
.sim-speed button[aria-checked="true"] { background: var(--blue); color: #fff; border-color: var(--blue); position: relative; z-index: 1; }
html[data-theme="dark"] .sim-speed button[aria-checked="true"] { color: #0B1030; }
.sim-sw { font: 600 13px var(--sans); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.sim-sw span { color: var(--muted); font-weight: 500; }
.sim-keys { margin: 0 0 14px; font-size: 13px; color: var(--muted); max-width: none; }

.sim-bugs { margin: 0 0 14px; border: 1.5px dashed var(--red); border-radius: 10px; padding: 0 12px; background: color-mix(in srgb, var(--red-soft) 55%, transparent); }
.sim-bugs summary { cursor: pointer; font: 700 13px var(--mono); color: var(--red); padding: 10px 0; }
.sim-bugs-n { color: var(--ink); font-weight: 600; }
.sim-bugs-l { display: grid; gap: 8px; margin-bottom: 10px; }
.sim-bugs-l label { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 14.5px; cursor: pointer; }
.sim-bugs-l em { font-style: normal; color: var(--muted); font-size: 13.5px; }
.sim-bugs .sim-cb { margin-bottom: 12px; }

/* diseño: teléfono grande a la izquierda, explicación y código a la derecha */
.sim { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 20px; align-items: start; margin-bottom: 10px; }
.sim > * { min-width: 0; }
@media (max-width: 1000px) { .sim { grid-template-columns: 1fr; } }

.sim-say { background: var(--surface); border: 1.5px solid var(--ink); border-left: 6px solid var(--blue); border-radius: 10px; padding: 10px 14px; min-height: 5.4em; transition: border-color .2s; }
#sim.is-running .sim-say { border-left-color: var(--red); }
.sim-say-h { font: 700 12.5px var(--mono); color: var(--muted); margin: 0 0 4px; max-width: none; }
.sim-say-t { margin: 0; font-size: 16.5px; line-height: 1.5; max-width: none; }
.sim-vars { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px; margin: 10px 0; }
.sim-vars > div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; min-width: 0; }
.sim-vars-h { font: 700 12.5px var(--mono); margin: 0 0 6px; max-width: none; }
.sim-vars-h em { font-style: normal; font-weight: 500; color: var(--muted); margin-left: 4px; }
.sim-vars ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.sim-vars li { display: flex; justify-content: space-between; gap: 10px; font: 13.5px var(--mono); padding: 2px 6px; border-radius: 4px; }
.sim-vars li .vk { color: var(--muted); }
.sim-vars li .vv { font-weight: 700; overflow-wrap: anywhere; text-align: right; }
.sim-vars li.empty { color: var(--muted); font-style: italic; }
.sim-vars li.chg { animation: chg 1.1s ease-out; }
@keyframes chg { from { background: var(--mark); } }

.sim-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.sim-head .file { margin: 0; }
.sim-src { max-height: 340px; overflow: auto; font-size: 13px; line-height: 1.7; margin-bottom: 8px; scroll-behavior: smooth; white-space: pre-wrap; overflow-wrap: anywhere; }
.sim-src[hidden] { display: none; }
.sim-src .ln { display: block; padding: 0 6px; margin: 0 -6px; border-radius: 4px; opacity: .55; transition: background .2s, opacity .2s; }
.sim-src .ln.ran { opacity: 1; background: rgba(95,211,148,.10); }
.sim-src .ln.hit { opacity: 1; background: rgba(255,233,122,.22); box-shadow: inset 3px 0 0 #FFE97A; }
.sim-src .ln.boom { opacity: 1; background: rgba(255,106,92,.28); box-shadow: inset 3px 0 0 #FF6A5C; }
.sim-src .ln.bugline { box-shadow: inset 3px 0 0 #FF6A5C; }
.sim-src .val { color: #FFE97A; font-weight: 700; }
.bug { color: #FF8A7E; text-decoration: underline wavy #FF6A5C; text-underline-offset: 3px; font-weight: 700; }
.sim-leg { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font: 600 13px var(--mono); color: var(--muted); margin: 0; max-width: none; }
.sim-leg .k { display: inline-block; width: 14px; height: 10px; border-radius: 2px; background: var(--code-bg); opacity: .55; margin-right: -6px; }
.sim-leg .k.hit { background: #CDB64A; opacity: 1; }
.sim-leg .k.ran { background: #3F7F5A; opacity: 1; }
.sim-leg .k.boom { background: #D9564A; opacity: 1; }

/* ---------- OnePlus 8T en 3D ---------- */
.p3d-stage {
  --pw: 300px; --ph: calc(var(--pw) * 2.169); --pd: calc(var(--pw) * .113); --r: calc(var(--pw) * .135);
  --u: calc(var(--pw) / 100); --ui: calc(var(--pw) * .0453);
  position: relative; display: grid; place-items: center; height: calc(var(--ph) + 70px); perspective: 1500px;
  border-radius: 18px; overflow: hidden; cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  background: radial-gradient(ellipse at 50% 30%, #2b3d3b 0%, #121b1b 55%, #070a0a 100%);
  border: 1px solid #0b1010;
}
.p3d-stage::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.035) 39px 40px), repeating-linear-gradient(90deg, transparent 0 39px, rgba(255,255,255,.035) 39px 40px); pointer-events: none; }
.p3d-stage:active { cursor: grabbing; }
.p3d-stage input, .p3d-stage textarea { user-select: text; -webkit-user-select: text; }
.p3d-stage[data-color="aqua"] {
  --frame: #1c3935; --frame-hi: #34665e; --accent: #E8B34A;
  --back: linear-gradient(158deg, #7ce6c9 0%, #2bb596 36%, #12786d 72%, #0b4d49 100%); --logo: rgba(255,255,255,.88);
}
.p3d-stage[data-color="silver"] {
  --frame: #858c94; --frame-hi: #b9c0c7; --accent: #55606b;
  --back: linear-gradient(158deg, #f1f3f5 0%, #cfd4d9 40%, #aab1b8 75%, #8f979f 100%); --logo: rgba(35,42,50,.72);
}
.p3d-floor { position: absolute; left: 50%; bottom: 16px; width: calc(var(--pw) * .95); height: 30px; margin-left: calc(var(--pw) * -.475); background: radial-gradient(ellipse at center, rgba(0,0,0,.7), transparent 70%); filter: blur(5px); }
.p3d { position: relative; width: var(--pw); height: var(--ph); transform-style: preserve-3d; transition: transform .7s cubic-bezier(.2,.8,.2,1); will-change: transform; }
.p3d.drag { transition: none; }
.p3d-slices { position: absolute; inset: 0; transform-style: preserve-3d; }
.p3d-slice { position: absolute; inset: 0; border-radius: var(--r); background: var(--frame); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.p3d-slice:nth-child(8), .p3d-slice:nth-child(9) { background: var(--frame-hi); }
.p3d-face { position: absolute; inset: 0; border-radius: var(--r); backface-visibility: hidden; -webkit-backface-visibility: hidden; }

/* frente: pantalla con la app */
.p3d-front { transform: translateZ(calc(var(--pd) / 2 + .5px)); background: #040505; padding: calc(var(--u) * 1.9); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.1); }
.p3d-screen { position: relative; width: 100%; height: 100%; border-radius: calc(var(--r) - var(--u) * 1.9); overflow: hidden; background: #FFFBFE; color: #1C1B1F; font-size: var(--ui); display: grid; grid-template-rows: auto 1fr auto; text-align: left; cursor: default; }
.p3d-hole { position: absolute; left: calc(var(--u) * 7.4); top: calc(var(--u) * 3.4); width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); border-radius: 50%; background: radial-gradient(circle at 40% 35%, #38435e 0 10%, #0a0d14 40%, #000 72%); box-shadow: 0 0 0 calc(var(--u) * .5) #000; z-index: 3; }
.p3d-glare { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(118deg, rgba(255,255,255,.13) 0%, rgba(255,255,255,0) 30%); pointer-events: none; z-index: 4; }
.sim-sb { display: flex; justify-content: space-between; align-items: center; padding: .55em 1.1em .3em 3.4em; font: 600 .9em var(--sans); }
.sim-sbi { display: inline-flex; gap: .35em; align-items: center; }
.sim-sbi i { display: block; background: #1C1B1F; }
.sim-sbi .wifi { width: .8em; height: .6em; clip-path: polygon(0 20%, 50% 100%, 100% 20%, 50% 0); }
.sim-sbi .sig { width: .75em; height: .6em; clip-path: polygon(0 100%, 100% 100%, 100% 0); }
.sim-sbi .bat { width: 1.2em; height: .62em; border-radius: .15em; }
.sim-screens { padding: .8em 1em; overflow: hidden; }
.sim-screen { display: grid; gap: .7em; align-content: start; }
.sim-screen[hidden] { display: none; }
.sim-f { width: 100%; font: 1.05em var(--sans); color: #1C1B1F; background: #FF0000; border: 0; border-radius: 0; padding: .85em .7em; }
.sim-f::placeholder { color: #fff; opacity: 1; }
.sim-f:focus { outline: 2px solid #1C1B1F; outline-offset: 1px; }
.sim-b { font: 600 1.05em var(--sans); color: #fff; background: #0000FF; border: 0; border-radius: 999px; padding: .85em; cursor: pointer; }
.sim-b:active { transform: scale(.98); }
.sim-t1 { font-size: 1.45em; margin: 0; line-height: 1.25; max-width: none; }
.sim-t2 { font-size: 1.1em; margin: 0 0 .2em; max-width: none; }
.sim-r { width: 100%; font: .98em/1.45 var(--sans); color: #1C1B1F; background: transparent; border: 0; border-bottom: 1.5px solid #79747E; resize: none; padding: .4em .15em; }
.sim-nav { display: flex; justify-content: space-around; align-items: center; background: #FFFBFE; padding: .35em 0 .55em; }
.sim-nav button, .sim-nav span { background: none; border: 0; padding: .45em 1.7em; cursor: pointer; display: grid; place-items: center; }
.sim-nav i { display: block; }
.sim-nav .tri { width: 0; height: 0; border-top: .5em solid transparent; border-bottom: .5em solid transparent; border-right: .85em solid #49454F; }
.sim-nav .cir { width: .95em; height: .95em; border: .17em solid #49454F; border-radius: 50%; }
.sim-nav .sq { width: .85em; height: .85em; border: .17em solid #49454F; border-radius: .2em; }
.sim-toast {
  position: absolute; left: 50%; bottom: 3.6em; transform: translate(-50%, 10px); width: max-content; max-width: 86%;
  background: #313033; color: #F4EFF4; font: .92em/1.35 var(--sans); padding: .6em 1.1em; border-radius: 1.4em; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 2;
}
.sim-toast.show { opacity: 1; transform: translate(-50%, 0); }
.sim-crash { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5); z-index: 5; }
.sim-crash[hidden] { display: none; }
.sim-crash > div { background: #2B2930; color: #E6E0E9; border-radius: 1.6em; padding: 1.3em 1.3em 1em; width: 82%; }
.sim-crash p { margin: 0 0 1em; font-size: 1.1em; max-width: none; }
.sim-crash button { background: none; border: 0; color: #D0BCFF; font: 700 1em var(--sans); cursor: pointer; padding: .4em .2em; }
@media (prefers-reduced-motion: no-preference) {
  .sim-screen.enter { animation: slidein .22s ease-out; }
  .sim-f.rej { animation: shake .3s; }
}
@keyframes slidein { from { transform: translateX(8%); opacity: .2; } }

/* atrás: cámara, logo y brillo */
.p3d-back { transform: rotateY(180deg) translateZ(calc(var(--pd) / 2 + .5px)); background: var(--back); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2), inset 0 0 calc(var(--u) * 14) rgba(0,0,0,.28); }
.p3d-shine { position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.42) 45%, rgba(255,255,255,.08) 54%, transparent 62%); background-size: 280% 100%; background-position: var(--gl, 50%) 0; pointer-events: none; }
.cam { position: absolute; left: calc(var(--u) * 8); top: calc(var(--u) * 8); width: calc(var(--u) * 43); height: calc(var(--u) * 52); border-radius: calc(var(--u) * 9); background: #090c0c; box-shadow: 0 0 0 calc(var(--u) * 1.1) rgba(255,255,255,.16), 0 calc(var(--u) * 2) calc(var(--u) * 5) rgba(0,0,0,.45); }
.lens { position: absolute; border-radius: 50%; background: radial-gradient(circle at 36% 30%, #6a7ca6 0 7%, #1b2538 20%, #05070c 56%, #000 100%); box-shadow: 0 0 0 calc(var(--u) * 1.1) #2b3232, inset 0 0 0 calc(var(--u) * 1.5) #0f1212; }
.lens.l1 { width: calc(var(--u) * 24); height: calc(var(--u) * 24); left: calc(var(--u) * 4.5); top: calc(var(--u) * 4.5); }
.lens.l2 { width: calc(var(--u) * 16); height: calc(var(--u) * 16); left: calc(var(--u) * 4.5); top: calc(var(--u) * 30); }
.lens.l3 { width: calc(var(--u) * 11); height: calc(var(--u) * 11); left: calc(var(--u) * 24); top: calc(var(--u) * 33); }
.lens.l4 { width: calc(var(--u) * 8); height: calc(var(--u) * 8); left: calc(var(--u) * 31); top: calc(var(--u) * 20); }
.flash { position: absolute; right: calc(var(--u) * 4); top: calc(var(--u) * 5); width: calc(var(--u) * 6); height: calc(var(--u) * 6); border-radius: 50%; background: radial-gradient(circle, #fffbe0, #d8c987); box-shadow: 0 0 0 calc(var(--u) * .8) #2b3232; }
.logo { position: absolute; left: 0; right: 0; top: 66%; text-align: center; font: 800 calc(var(--u) * 6.4) var(--sans); letter-spacing: .36em; padding-left: .36em; color: var(--logo); }
.tiny { position: absolute; left: 0; right: 0; bottom: calc(var(--u) * 6); text-align: center; font: 600 calc(var(--u) * 3.4) var(--mono); letter-spacing: .2em; color: var(--logo); opacity: .7; }

/* botones laterales */
.p3d-btn { position: absolute; background: var(--frame-hi); box-shadow: inset 0 0 0 1px rgba(255,255,255,.14); border-radius: 2px; }
.p3d-btn.l { left: 0; transform-origin: 0 50%; width: calc(var(--pd) * .42); transform: rotateY(-90deg) translateX(-50%) translateZ(2.5px); }
.p3d-btn.r { left: 100%; transform-origin: 0 50%; width: calc(var(--pd) * .42); transform: rotateY(90deg) translateX(-50%) translateZ(2.5px); }
.p3d-btn.vol { top: 17%; height: 13%; }
.p3d-btn.slider { top: 13%; height: 5%; background: var(--accent); }
.p3d-btn.power { top: 24%; height: 9%; }
.p3d-btn.b { top: 100%; left: 50%; width: calc(var(--u) * 12); height: calc(var(--pd) * .34); margin-left: calc(var(--u) * -6); background: #050606; border-radius: 99px; transform-origin: 50% 0; transform: rotateX(-90deg) translateY(-50%) translateZ(1px); }

.p3d-hint { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font: 600 12.5px var(--mono); color: rgba(255,255,255,.6); pointer-events: none; transition: opacity .5s; max-width: none; }
.p3d-hint.gone { opacity: 0; }
.p3d-ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 6px; }
.p3d-ctl button[data-rot], #p3d-spin { font: 700 13px var(--mono); padding: 6px 11px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
#p3d-spin[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
html[data-theme="dark"] #p3d-spin[aria-pressed="true"] { color: #0B1030; }
.p3d-colors { display: inline-flex; gap: 6px; margin-left: 4px; }
.p3d-colors button { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--line); background: none; cursor: pointer; display: grid; place-items: center; }
.p3d-colors button[aria-checked="true"] { border-color: var(--ink); }
.p3d-colors i { width: 16px; height: 16px; border-radius: 50%; display: block; }
.p3d-colors [data-color="aqua"] i { background: linear-gradient(135deg, #7ce6c9, #12786d); }
.p3d-colors [data-color="silver"] i { background: linear-gradient(135deg, #f1f3f5, #8f979f); }
.p3d-view { font: 600 13px var(--mono); color: var(--muted); margin-left: auto; }
.p3d-note { font-size: 13px; color: var(--muted); margin: 4px 0 0; max-width: none; }
@media (max-width: 720px) {
  .p3d-stage { --pw: 250px; }
  .sim-vars { grid-template-columns: 1fr; }
}
@media (max-width: 380px) { .p3d-stage { --pw: 220px; } }
@media (prefers-reduced-motion: reduce) { .p3d { transition-duration: .01s; } }

/* ---------- modo paso a paso ---------- */
body.stepmode .hero, body.stepmode .map, body.stepmode .train-head { display: none; }
body.stepmode main > section.block:not(.cur) { display: none; }
body.stepmode main > section.block.cur { border-top: 0; min-height: calc(100vh - 230px); }
body.stepmode main { padding-bottom: 96px; }
@media (prefers-reduced-motion: no-preference) {
  body.stepmode main > section.block.cur { animation: rise .35s cubic-bezier(.2,.8,.2,1); }
}
.pager {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
}
.pager[hidden] { display: none; }
.pg-mid { font: 600 13px var(--mono); color: var(--muted); text-align: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-mid b { color: var(--ink); font-size: 15px; }
#pg-title { color: var(--ink); font-family: var(--sans); font-weight: 700; margin-left: 6px; }
.sim-toast { width: max-content; }
@media (max-width: 640px) {
  .ide-body { grid-template-columns: 1.1fr 1fr; }
  .ide-attrs dl { gap: 3px 6px; }
  .ide-attrs dd { overflow-wrap: normal; font-size: 10.5px; }
}
.back.brand { font: 700 15px var(--mono); letter-spacing: -.01em; color: var(--ink); }
.back.brand .brand-d { color: var(--red); display: inline; }
@media (max-width: 560px) { .back.brand .brand-d { display: none; } }

/* =====================================================================
   Pase de comodidad: tamaños mínimos, largo de línea, código sin scroll
   lateral en celular, índice, movimiento acotado, campos y botones táctiles.
   ===================================================================== */
:root { --bar-h: 53px; }
@media (max-width: 560px) { :root { --bar-h: 48px; } }
.bar { min-height: var(--bar-h); }
.toc { top: calc(var(--bar-h) - 1px); }

/* 1. Ninguna etiqueta bajo 12 px; los verbos de acción, que son lo principal de cada paso, a 12,5 */
.v { font-size: 12.5px; padding: 5px 8px; }
.toc-g { font-size: 12px; }
.toc a { font-size: 13px; }
.kicker { font-size: 12.5px; }
.shots figcaption { font-size: 13px; }
.map span { font-size: 12.5px; }
h2 .t { font-size: 13px; }
th { font-size: 12px; }
.code .copy { font-size: 12px; }
.sim-try-l, .sim-try button, .sim-slow, .file { font-size: 13px; }
.sim-leg, .legend-code { font-size: 13px; }
.prog-txt { font-size: 13px; }
.pill { font-size: 13px; }
.ide { font-size: 12px; }
.ide-h, .ide-file, .ide-modes, .ide-tag, .ide-attrs dd, .ide-cat li, .ide-items li, .ide-tree em, .ide-attrs dt { font-size: 12px; }
.sim-src { font-size: 13px; }
.code.stockonly { font-size: 13px; }
@media (max-width: 640px) {
  .ide, .ide-attrs dd { font-size: 12px; }
  .ide-body { grid-template-columns: 1.05fr 1fr; }
  .ide-attrs dd { overflow-wrap: anywhere; }
}

/* 2. Largo de línea: ~70 caracteres, no 90 a 110 */
main p, .do, .rules, .traps, .checks { max-width: 68ch; }
.do, .rules, .traps, .checks { max-width: 700px; }
.gist { max-width: 62ch; }
.hero-txt p.lead { max-width: 52ch; }
.qa details p { max-width: none; }

/* 3. Código legible en celular: las líneas largas se parten en vez de obligar a deslizar de lado */
@media (max-width: 720px) {
  pre.code, .sim-src .ln { white-space: pre-wrap; overflow-wrap: anywhere; }
  pre.code { font-size: 13px; line-height: 1.6; }
  .sim-src { max-height: 340px; }
}

/* 4. Índice: panel lateral en pantallas anchas, filas que se parten en intermedias */
@media (min-width: 721px) and (max-width: 1359px) {
  .toc { flex-wrap: wrap; overflow: visible; row-gap: 2px; padding-top: 6px; padding-bottom: 6px; }
  html { scroll-padding-top: 150px; }
}
@media (min-width: 1360px) {
  html { scroll-padding-top: 76px; }
  .toc {
    position: fixed; top: calc(var(--bar-h) + 22px); left: calc(50% - 654px); width: 214px; z-index: 18;
    flex-direction: column; align-items: stretch; gap: 1px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin;
    max-height: calc(100vh - var(--bar-h) - 44px); padding: 4px 6px 12px 0; background: transparent; backdrop-filter: none; border: 0;
  }
  .toc-g { padding: 16px 10px 4px; }
  .toc-g:first-child { padding-top: 2px; }
  .toc a { padding: 6px 10px; border-radius: 6px; }
}
@media (max-width: 720px) {
  .toc { transition: transform .25s ease; }
  body.toc-hide .toc { transform: translateY(-110%); }
}

/* 5. Movimiento acotado: nada se mueve para siempre mientras lees */
@media (prefers-reduced-motion: no-preference) {
  h1 .arrow { animation: nudge 2.4s 1s ease-in-out 2; }
  .ide [data-r].hl { animation: glow 1.4s ease-in-out 3; }
}

/* 6. Táctil: 16 px en campos (evita el zoom automático de iPhone) y botones más cómodos */
@media (pointer: coarse) {
  .gap { font-size: 16px; width: calc(var(--w) * 1ch + 16px); }
  .write textarea, .sim-f { font-size: 16px; }
  .pill { min-height: 38px; }
  .toc a { padding: 8px 12px; }
  details.full summary { padding: 12px 0; }
  .qa summary { padding-top: 14px; padding-bottom: 14px; }
  .qa summary::before { top: 13px; }
  .do li { padding-top: 12px; padding-bottom: 12px; }
  .checks label { padding-top: 12px; padding-bottom: 12px; }
  .done { padding-top: 12px; padding-bottom: 12px; }
}

/* 7. Contraste */
html[data-theme="dark"] { --code-dim: #928B7B; }
.ide-modes b { background: #2F66DB; }
.traps { max-width: 650px; }
.hint-sm { max-width: 60ch; }
@media (pointer: coarse) {
  .sim-try button, .tabs button { min-height: 38px; padding-top: 8px; padding-bottom: 8px; }
  .sim-slow { padding: 10px 0; }
}
.prog-bar { min-width: 44px; }
@media (max-width: 560px) { .prog { flex: 1 1 auto; } .prog-txt { flex: none; } }
.proof { max-width: 64ch; }

/* recuadro: cómo debe quedar el Component Tree */
.treebox { margin: 4px 0 16px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--surface); overflow: hidden; max-width: 560px; }
.treebox figcaption { padding: 8px 14px; font: 700 13px var(--mono); background: var(--ink); color: var(--paper); }
.treebox ul { list-style: none; margin: 0; padding: 8px 14px 4px; font-size: 15px; }
.treebox li { padding: 3px 0 3px 18px; border-left: 2px solid var(--line); margin-left: 4px; }
.treebox li.root { border-left: 0; margin-left: 0; padding-left: 0; font: 600 14px var(--mono); }
.treebox li b { font: 700 14px var(--mono); }
.treebox li em { font-style: normal; color: var(--muted); font-size: 13px; margin-left: 4px; }
.treebox .dot { width: 9px; height: 9px; margin-right: 6px; }
.treebox-n { margin: 0; padding: 8px 14px 12px; font-size: 14.5px; border-top: 1px dashed var(--line); }
.sim-keys kbd { font-size: 12px; }

/* =====================================================================
   Código cómodo de leer: líneas que se parten con sangría, letra de 14 px,
   más ancho y más alto, pendientes legibles, botón Copiar en su propia franja.
   ===================================================================== */
pre.code { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.75; letter-spacing: .005em; }
.cl { display: block; padding-left: calc((var(--ind, 0) + 4) * 1ch); text-indent: calc((var(--ind, 0) + 4) * -1ch); }
.code.has-copy { padding-top: 42px; }
.code.has-copy .copy { top: 8px; right: 10px; }

.sim-src { font-size: 14px; line-height: 1.8; max-height: min(72vh, 600px); }
.sim-src .ln { opacity: .8; padding: 1px 6px 1px calc(6px + (var(--ind, 0) + 4) * 1ch); text-indent: calc((var(--ind, 0) + 4) * -1ch); }
.sim-src .ln.ran { opacity: 1; }
.sim-leg { gap: 4px 14px; }
.sim-leg > span:not(.k) { white-space: nowrap; }
.code .cm { color: #A39B8B; }
html[data-theme="dark"] .code .cm { color: #A9A291; }

/* el panel de código aprovecha el espacio libre a la derecha desde 1001 px */
@media (min-width: 1001px) { .sim { margin-right: calc(-1 * clamp(0px, (100vw - 900px) / 2, 260px)); } }
@media (max-width: 560px) {
  pre.code, .sim-src { font-size: 13px; }
  .code.has-copy { padding-top: 40px; }
}
.sim-src .val { white-space: nowrap; display: inline-block; }

/* ---------- speedrun ---------- */
.spd { margin: 0 0 8px; }
.spd-setup { display: grid; gap: 14px; }
.spd-opt { border: 1.5px solid var(--ink); border-radius: 12px; padding: 10px 14px 14px; margin: 0; background: var(--surface); display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.spd-opt legend { font: 700 12.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--red); padding: 0 6px; }
.spd-opt label { position: relative; cursor: pointer; }
.spd-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.spd-opt label span { display: flex; flex-direction: column; gap: 1px; padding: 9px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--paper); font: 700 15px var(--sans); transition: border-color .15s, background .15s; }
.spd-opt label span em { font-style: normal; font-weight: 500; font-size: 13px; color: var(--muted); }
.spd-opt input:checked + span { border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }
.spd-opt input:focus-visible + span { outline: 2.5px solid var(--blue); outline-offset: 2px; }
.spd-opt input:disabled + span { opacity: .45; }
.spd-opt input:disabled { cursor: default; }
.spd-go { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.spd-start { font: 800 20px var(--sans); padding: 14px 26px; border-radius: 12px; border: 0; background: var(--red); color: #fff; cursor: pointer; box-shadow: 0 6px 0 rgba(0,0,0,.25); display: inline-flex; gap: 12px; align-items: center; }
html[data-theme="dark"] .spd-start { color: #2A0905; }
.spd-start:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.spd-start kbd { background: rgba(255,255,255,.2); color: inherit; border-color: rgba(255,255,255,.4); font-size: 12px; }
.spd-pb { margin: 0; font: 600 14px var(--mono); color: var(--muted); max-width: none; }

.spd-run, .spd-result { background: var(--code-bg); color: var(--code-ink); border-radius: 16px; padding: 18px 20px 20px; border-left: 6px solid var(--red); }
.spd-run[hidden], .spd-result[hidden] { display: none; }
.spd-hud { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spd-kind { font: 800 12.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: 6px; }
.spd-kind.k-design { background: #8EA2FF; color: #0B1030; }
.spd-kind.k-code { background: #FF8A7E; color: #2A0905; }
.spd-pos { font: 600 14px var(--mono); color: var(--code-dim); }
.spd-clock { margin-left: auto; font: 700 clamp(34px, 7vw, 56px)/1 var(--mono); color: #FFE97A; font-variant-numeric: tabular-nums; }
.spd-ticks { display: flex; gap: 2px; margin: 12px 0 16px; height: 8px; }
.spd-ticks i { flex: 1; border-radius: 2px; background: rgba(255,255,255,.16); }
.spd-ticks i.t-design { background: rgba(142,162,255,.45); }
.spd-ticks i.t-code { background: rgba(255,138,126,.45); }
.spd-ticks i.tk-done { background: #5FD394; }
.spd-ticks i.tk-cur { background: #FFE97A; }
.spd-card { min-height: 150px; border-radius: 12px; background: rgba(255,255,255,.05); padding: 16px 18px; display: grid; gap: 10px; align-content: center; }
.spd-where { margin: 0; font: 600 14px var(--mono); color: var(--code-dim); max-width: none; }
.spd-instr { margin: 0; font: 650 clamp(22px, 4vw, 32px)/1.3 var(--serif); max-width: none; }
.spd-instr.soft { color: #D9D3C6; }
.spd-instr.is-code code { display: block; font: 500 clamp(16px, 2.6vw, 22px)/1.5 var(--mono); background: rgba(255,233,122,.1); color: #FFF3C0; padding: 10px 14px; border-radius: 8px; overflow-wrap: anywhere; white-space: pre-wrap; }
.spd-instr code { background: rgba(255,255,255,.12); color: inherit; }
.spd-instr.count { font: 800 clamp(72px, 16vw, 120px)/1 var(--serif); text-align: center; color: #FFE97A; }
@media (prefers-reduced-motion: no-preference) {
  .spd-instr.count { animation: cnt .7s ease-out; }
  .spd-card.flash { animation: cnt2 .3s ease-out; }
  .spd-rec { animation: pulse 1s ease-in-out 3; }
}
@keyframes cnt { from { transform: scale(1.5); opacity: 0; } }
@keyframes cnt2 { from { background: rgba(95,211,148,.28); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
.spd-type input { width: 100%; font: 500 clamp(16px, 2.6vw, 20px) var(--mono); color: #fff; background: rgba(0,0,0,.35); border: 2px solid #8EA2FF; border-radius: 8px; padding: 12px 14px; }
.spd-type input:focus { outline: none; border-color: #FFE97A; }
.spd-type input.off { border-color: #FF6B5E; background: rgba(255,107,94,.12); }
.spd-ok { margin: 6px 0 0; font: 600 13.5px var(--mono); color: var(--code-dim); min-height: 1.3em; max-width: none; }
.spd-steptime { display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; margin: 12px 0; font: 600 14px var(--mono); color: var(--code-dim); }
#spd-step { color: var(--code-ink); font-size: 18px; min-width: 4.5em; }
.spd .good { color: #5FD394; font-weight: 800; }
.spd .bad { color: #FF8A7E; font-weight: 800; }
.spd-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.spd-done { font: 800 18px var(--sans); padding: 12px 24px; border-radius: 10px; border: 0; background: #5FD394; color: #062213; cursor: pointer; }
.spd-done[hidden], .spd-ghost[hidden] { display: none; }
.spd-ghost { font: 700 14px var(--sans); padding: 12px 16px; border-radius: 10px; background: transparent; color: var(--code-ink); border: 1.5px solid rgba(255,255,255,.3); cursor: pointer; }
.spd-ghost:disabled { opacity: .35; cursor: default; }
.spd-keys { margin: 12px 0 0; font-size: 13px; color: var(--code-dim); max-width: none; }
.spd-run kbd { background: rgba(255,255,255,.1); color: var(--code-ink); border-color: rgba(255,255,255,.25); }
.spd-rec { margin: 0 0 8px; display: inline-block; background: #FFE97A; color: #1A1600; font: 800 13px var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: 4px 10px; border-radius: 6px; }
.spd-rec[hidden] { display: none; }
.spd-total { margin: 0; font: 800 clamp(48px, 10vw, 84px)/1 var(--mono); color: #FFE97A; font-variant-numeric: tabular-nums; max-width: none; }
.spd-sub { color: var(--code-dim); margin: 6px 0 16px; font: 600 14px var(--mono); max-width: none; }
.spd-splits { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 2px; max-height: 420px; overflow: auto; }
.spd-splits li { display: grid; grid-template-columns: 1fr auto auto 4.6em; gap: 12px; padding: 6px 8px; border-radius: 6px; font: 14px var(--mono); align-items: baseline; }
.spd-splits li.slow { background: rgba(255,106,92,.16); box-shadow: inset 3px 0 0 #FF6B5E; }
.spd-splits .sl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--sans); font-size: 14.5px; }
.spd-splits .sb { color: var(--code-dim); }
.spd-splits li > span:last-child { text-align: right; }
.spd-hist { margin-top: 14px; }
.spd-hist summary { cursor: pointer; font: 600 13.5px var(--mono); color: var(--blue); padding: 8px 0; }
.spd-hist ul { margin: 0; padding-left: 20px; font: 13.5px/1.7 var(--mono); }
@media (max-width: 560px) {
  .spd-splits li { grid-template-columns: 1fr auto 4.4em; }
  .spd-splits .sb { display: none; }
  .spd-run, .spd-result { padding: 14px 14px 16px; }
  .spd-start { width: 100%; justify-content: center; }
}
.spd-setup[hidden] { display: none; }
.spd-run .spd-done { flex: 1 1 280px; font-size: 22px; padding: 18px 24px; }
.spd-card.paused { opacity: .45; }
.spd-card.paused .spd-instr { filter: blur(6px); }

/* speedrun: pasos terminados, historial con detalle, imports */
.spd-donel { list-style: none; margin: 0 0 4px; padding: 0; display: grid; gap: 2px; font: 13.5px var(--mono); color: var(--code-dim); }
.spd-donel li { display: flex; gap: 10px; align-items: baseline; }
.spd-donel li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--sans); }
.spd-donel b { color: var(--code-ink); }
.spd-donel i { font-style: normal; font-weight: 800; }
.spd-hsum { margin: 0 0 8px; font: 600 13.5px var(--mono); color: var(--muted); max-width: none; }
.spd-runs { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.spd-runs > li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.spd-runs .hr { width: 100%; text-align: left; font: 600 13.5px var(--mono); color: var(--ink); background: none; border: 0; padding: 9px 12px; cursor: pointer; }
.spd-runs .hs { margin: 0; padding: 4px 12px 10px 34px; font: 13.5px/1.7 var(--sans); color: var(--muted); }
.spd-bests { margin: 0 0 10px; }
.spd-bests summary { cursor: pointer; font: 600 13.5px var(--mono); color: var(--blue); padding: 6px 0; }
.spd-bests ol { margin: 0; padding-left: 28px; font: 13.5px/1.7 var(--sans); }
.spd-clear { color: var(--ink); border-color: var(--line); }
.code.imp { padding-top: 14px; }
.code.imp.has-copy { padding-top: 42px; }

.spd-ctx { margin: 0; font: 600 14px/1.5 var(--mono); color: #D9D3C6; max-width: none; }
.spd-ctx[hidden] { display: none; }
.spd-instr.is-code code { white-space: pre-wrap; }

/* speedrun: el archivo completo con la línea que te toca iluminada */
.spd-srcwrap { margin-top: 8px; }
.spd-srcwrap[hidden] { display: none; }
.spd-srcleg { display: flex; gap: 14px; align-items: center; margin: 0 0 6px; font: 600 13px var(--mono); color: var(--code-dim); max-width: none; }
.spd-srcleg .k { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: -8px; background: rgba(255,255,255,.2); }
.spd-srcleg .k.cur { background: #FFE97A; }
.spd-srcleg .k.dn { background: #3F7F5A; }
.spd-srcpre { position: relative; max-height: min(58vh, 520px); overflow: auto; margin: 0; background: rgba(0,0,0,.35); border-left-color: #FFE97A; font-size: 14px; line-height: 1.75; scroll-behavior: smooth; }
.spd-srcpre .cl { border-radius: 4px; padding-right: 8px; opacity: .8; transition: background .15s, opacity .15s; }
.spd-srcpre .cl.st-done { opacity: 1; background: rgba(95,211,148,.12); }
.spd-srcpre .cl.st-cur { opacity: 1; background: rgba(255,233,122,.28); box-shadow: inset 4px 0 0 #FFE97A; }
.spd-srcpre.mask .cl.st-fut:not(.st-closer), .spd-srcpre .cl.st-hide { filter: blur(5px); }


/* =====================================================================
   Estilo Android Studio (New UI): ventana oscura con "islas" redondeadas,
   Inter para la interfaz, JetBrains Mono y la paleta del editor para el código.
   ===================================================================== */
@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap; src: url("assets/fonts/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("assets/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("assets/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 600 800; font-display: swap; src: url("assets/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  --paper: #F7F8FA; --surface: #FFFFFF; --ink: #1E1F22; --muted: #6C707E; --line: #DFE1E5; --rule: transparent;
  --red: #C93A3A; --red-soft: #FCE9E9; --blue: #2F66DB; --blue-soft: #E1EBFF; --ok: #1E7D3B; --ok-soft: #E4F3E8; --mark: #CFE0FF;
  --code-bg: #1E1F22; --code-ink: #BCBEC4; --code-dim: #8A8D94;
  --serif: "Inter", system-ui, sans-serif; --sans: "Inter", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  --margin: 0px;
}
html[data-theme="dark"] {
  --paper: #17181A; --surface: #2B2D30; --ink: #DFE1E5; --muted: #9DA0A8; --line: #393B40; --rule: transparent;
  --red: #F75464; --red-soft: #402A2D; --blue: #548AF7; --blue-soft: #2E436E; --ok: #5FB865; --ok-soft: #243A28; --mark: #2E436E;
  --code-bg: #1E1F22; --code-ink: #BCBEC4; --code-dim: #8A8D94;
}
body { background: var(--paper); background-image: none; font-family: var(--sans); font-feature-settings: "cv11", "ss03"; }
h1, h2, h3, .train-lead, .drill-wh h3 { font-family: var(--sans); font-variation-settings: normal; letter-spacing: -.015em; }
h1 { font-weight: 800; letter-spacing: -.03em; }
h2 { font-weight: 700; align-items: center; }
main::before { display: none; }
h2 .n, .train h2 .n { position: static; width: auto; transform: none; font: 700 13px/1 var(--mono); color: #fff; background: var(--blue); border-radius: 6px; padding: 5px 9px; }
html[data-theme="dark"] h2 .n, html[data-theme="dark"] .train h2 .n { color: #0E1A33; }
.step.is-done h2 .n { background: var(--ok); color: #fff; }
.block + .block { border-top: 1px solid var(--line); }
.kicker { color: var(--blue); }
h1 .arrow { color: var(--blue); }
.gist { font-weight: 600; }

/* barra superior y pestañas */
.bar, .toc { background: var(--surface); backdrop-filter: none; border-bottom: 1px solid var(--line); }
.back.brand .brand-d { color: var(--blue); }
.prog-bar { background: var(--line); }
.prog-bar i { background: var(--blue); }
.toc-g { color: var(--muted); letter-spacing: .08em; font-weight: 600; }
.toc a { border-radius: 6px; font: 500 13px var(--sans); color: var(--muted); }
.toc a:hover { background: var(--blue-soft); color: var(--ink); }
.toc a.on { background: var(--blue-soft); color: var(--ink); box-shadow: inset 0 -2px 0 var(--blue); }
@media (min-width: 1360px) {
  .toc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 12px; }
  .toc::before { content: "Project  ·  Prueba2"; font: 600 12.5px var(--sans); color: var(--muted); padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
  .toc a.on { box-shadow: none; background: var(--blue-soft); }
}

/* botones como en el IDE */
.pill { border-radius: 6px; background: #2F66DB; border-color: #2F66DB; color: #fff; font-weight: 600; }
html[data-theme="dark"] .pill { color: #fff; }
.pill.ghost, .pill.alt { background: transparent; color: var(--ink); border-color: var(--line); }
.pill[aria-pressed="true"], .pill.alt[aria-pressed="true"] { background: var(--blue-soft); color: var(--ink); border-color: var(--blue); }
html[data-theme="dark"] .pill[aria-pressed="true"] { color: var(--ink); }
.sim-cb, .spd-ghost, .spd-done, .done, .dbtns button, .spd-start { border-radius: 6px; }
.spd-start { background: #2F66DB; color: #fff; box-shadow: none; }
html[data-theme="dark"] .spd-start { color: #fff; }
.done { border-color: var(--line); }
.done[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }

/* paneles = islas */
.do li, .ideas article, .ideas article + article, .qa details, .spd-opt, .checks label, .skel > div, .facts li, .sim-ctl, .sim-vars > div, .sim-bugs, .spd-runs > li, .treebox, .where-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.ideas article, .ideas article + article { border-top: 1px solid var(--line); }
.qa details[open] { border-color: var(--blue); }
.map { border: 1px solid var(--line); border-radius: 12px; }
.map a { border-right: 1px solid var(--line); }
.map a:last-child { border-right: 0; }
@media (max-width: 720px) { .map a:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }
.sim-say { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; }
#sim.is-running .sim-say { border-left-color: var(--ok); }
.spd-opt legend, .sim-try-l { color: var(--muted); }
.spd-opt input:checked + span, .sim-speed button[aria-checked="true"] { border-color: var(--blue); }
.sim-speed button[aria-checked="true"] { background: #2F66DB; color: #fff; }
html[data-theme="dark"] .sim-speed button[aria-checked="true"] { color: #fff; }
.sim-speed button { border-color: var(--line); }
.train-head { border: 1px solid var(--line); }
.train-head .kicker, .train-steps a::before { color: #548AF7; }
.drill-win { border-left: 1px solid var(--line); border: 1px solid var(--line); }
.spd-run, .spd-result { border: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: 12px; }
.big2 { -webkit-text-stroke-color: var(--blue); opacity: .12; }
.p3d-stage { background: radial-gradient(ellipse at 50% 30%, #34373C 0%, #1E1F22 62%, #131416 100%); border-color: var(--line); }

/* código: editor de Android Studio */
.code, .logic .code, .code.stockonly, .spd-srcpre { border: 1px solid #393B40; border-left: 1px solid #393B40; border-radius: 8px; background: var(--code-bg); }
.code .add { color: #DFE1E5; }
.code .kw, .lines code .kw { color: #CF8E6D; }
.code .st, .lines code .st { color: #6AAB73; }
.code .tp, .lines code .tp { color: #CF8E6D; font-weight: 500; }
.code .rid, .lines code .rid { color: #C77DBB; font-style: italic; }
.code .ty, .lines code .ty { color: #BCBEC4; }
.code .nu, .lines code .nu { color: #2AACB8; }
.code .fn, .lines code .fn { color: #56A8F5; }
.code .cm, .lines code .cm, html[data-theme="dark"] .code .cm { color: #7A7E85; font-style: italic; }
.code, pre.code, .sim-src, .spd-srcpre, .dl { font-family: var(--mono); }
.sim-src .ln.hit, .spd-srcpre .cl.st-cur { background: rgba(53,116,240,.28); box-shadow: inset 3px 0 0 #548AF7; }
.sim-src .val { color: #56A8F5; }

/* ajustes de contraste y tamaño */
html[data-theme="dark"] { --blue: #6E9CF8; --red: #FF6B7A; }
.code .cm, .lines code .cm, html[data-theme="dark"] .code .cm { color: #8A8D94; }
kbd { font-size: max(12px, .78em); }

/* prueba resuelta (ZIP) */
.pill.res { background: var(--ok); border-color: var(--ok); color: #fff; text-decoration: none; display: inline-flex; align-items: center; }
html[data-theme="dark"] .pill.res { color: #0F2414; }
@media (max-width: 560px) { .pill.res { display: none; } }
.toc a.toc-res { background: var(--ok); color: #fff; font-weight: 700; margin-right: 6px; }
html[data-theme="dark"] .toc a.toc-res { color: #0F2414; }
.hero-cta { display: inline-block; margin-top: 4px; padding: 12px 20px; border-radius: 8px; background: var(--ok); color: #fff; font: 700 16px var(--sans); text-decoration: none; }
html[data-theme="dark"] .hero-cta { color: #0F2414; }
.zips { display: grid; gap: 14px; margin: 0 0 8px; }
@media (min-width: 700px) { .zips { grid-template-columns: 1fr 1fr; } }
.zip { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; display: grid; gap: 6px; align-content: start; }
.zip-full { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.zip-k { margin: 0; font: 700 13px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.zip-n { margin: 0; font: 800 44px/1 var(--sans); letter-spacing: -.03em; max-width: none; }
.zip-d { margin: 0 0 6px; max-width: none; }
.zip-dl { display: inline-block; padding: 13px 18px; border-radius: 8px; background: #2F66DB; color: #fff; font: 700 15px var(--sans); text-decoration: none; text-align: center; }
.zip-dl:hover { filter: brightness(1.1); }
.zip-m { margin: 0; font: 600 13px var(--mono); color: var(--muted); max-width: none; }
table.pts td:nth-child(n+2), table.pts th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
table.pts tr.tot td { font-weight: 800; border-top: 2px solid var(--ink); }

/* Android Studio grays: flat panels, no ruled paper, no margin line, sans headings */
main::before { display: none; }
h1, h2, h3.sub, .train-lead, .facts b, .map b { font-family: var(--sans); font-variation-settings: normal; letter-spacing: -.01em; }
.code, .ide, .zip, .tbl-wrap { border-radius: 8px; }
