/* =====================================================================
   Rubik DPF · hoja de estilos
   Misma familia visual que Docs ASIR (fondo cálido, verde azulado, radios y sombras suaves) con los colores del
   cubo como acento. Fuentes del sistema: cero descargas de fuentes, mejor LCP y sin saltos de diseño.
   ===================================================================== */

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --surface-3: #e9e6df;
  --text: #1d1c1a;
  --text-2: #4a4843;
  --muted: #6b6760;
  --border: #e4e1da;
  --border-strong: #cfcac0;
  --accent: #0f6e5a;
  --accent-hover: #0b5a49;
  --accent-soft: #e3f1ec;
  --accent-text: #0b5a49;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5d00;
  --warn-soft: #fff4d6;
  --ok: #18794e;
  --ok-soft: #e3f4ea;
  --info-soft: #e8edfb;

  --cube-y: #ffd500; --cube-w: #ffffff; --cube-g: #009b48; --cube-b: #0046ad; --cube-r: #b71234; --cube-o: #ff5800;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 20, .05);
  --shadow: 0 1px 2px rgba(28, 25, 20, .04), 0 4px 14px rgba(28, 25, 20, .05);
  --shadow-lg: 0 12px 40px rgba(20, 18, 10, .18);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  --ease: cubic-bezier(.2, .7, .3, 1);

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
  --topbar-h: 60px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121311; --surface: #1a1c19; --surface-2: #222521; --surface-3: #2b2e2a;
    --text: #ecebe6; --text-2: #c7c5be; --muted: #9c998f; --border: #2c2f2b; --border-strong: #40443e;
    --accent: #3fbf9b; --accent-hover: #5fd3b1; --accent-soft: #15302a; --accent-text: #6fdcbc; --on-accent: #06231b;
    --danger: #f2766b; --danger-soft: #3a1d1a; --warn: #e8b84a; --warn-soft: #36301b; --ok: #5fd39a; --ok-soft: #17301f;
    --info-soft: #1f2741;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121311; --surface: #1a1c19; --surface-2: #222521; --surface-3: #2b2e2a;
  --text: #ecebe6; --text-2: #c7c5be; --muted: #9c998f; --border: #2c2f2b; --border-strong: #40443e;
  --accent: #3fbf9b; --accent-hover: #5fd3b1; --accent-soft: #15302a; --accent-text: #6fdcbc; --on-accent: #06231b;
  --danger: #f2766b; --danger-soft: #3a1d1a; --warn: #e8b84a; --warn-soft: #36301b; --ok: #5fd39a; --ok-soft: #17301f;
  --info-soft: #1f2741;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3); --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6); color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 16px); }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--font-ui); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
main { flex: 1; width: 100%; outline: none; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
a:hover { text-decoration-color: currentColor; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; letter-spacing: -.012em; text-wrap: balance; }
h1 { font-size: clamp(28px, 5vw, 40px); }
h2 { font-size: clamp(22px, 3.4vw, 27px); }
h3, .h3 { font-size: 19px; }
.h4 { font-size: 16px; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.3em; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.sr-only, .sprite { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--on-accent); padding: 8px 14px; border-radius: var(--radius-sm); }
.skip:focus { top: 8px; }
code, kbd, .mono { font-family: var(--font-mono); }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 20px var(--gutter) 56px; }
.narrow-container { max-width: 820px; }
.narrow-section { max-width: 780px; }
.section { padding-top: 24px; padding-bottom: 24px; }
.section-sm { margin-top: 32px; }
.section-head { margin-bottom: 18px; }
.section-head h2 { margin-bottom: 4px; }
.section-head p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 650; }
.lead { font-size: 18px; line-height: 1.55; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.spacer { flex: 1; }
.eyebrow { margin: 0 0 6px; font-size: 12.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-text); }
.error-text { color: var(--danger); }
.pad { padding: 18px; }
.pad-lg { padding: 24px; }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1160px; margin: 0 auto; height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 var(--gutter); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 750; font-size: 19px; letter-spacing: -.02em; }
.brand-logo { width: 30px; height: 30px; flex: none; }
.brand-word span { color: var(--accent-text); margin-left: 1px; }
.nav { display: none; gap: 2px; margin-left: 12px; }
.nav a { padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 550; font-size: 15px; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { color: var(--accent-text); background: var(--accent-soft); }
.topbar-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; background: none; color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.mobile-nav { display: grid; padding: 8px var(--gutter) 14px; border-top: 1px solid var(--border); background: var(--bg); }
.mobile-nav a { padding: 12px 8px; color: var(--text); text-decoration: none; font-weight: 550; border-bottom: 1px solid var(--border); }
.mobile-nav a.active { color: var(--accent-text); }
@media (min-width: 900px) {
  .nav { display: flex; }
  .nav-toggle { display: none; }
  .mobile-nav { display: none !important; }
}

/* ---------------------------------------------------------------- botones y formularios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: 600 15px/1.2 var(--font-ui); text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 16.5px; border-radius: var(--radius); }
.btn-danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: 15.5px/1.4 var(--font-ui); }
.input.mono { font-family: var(--font-mono); font-size: 15px; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.field { display: grid; gap: 6px; }
.field > span:not(.sr-only) { font-weight: 600; font-size: 14px; }
.grow { flex: 1; min-width: 220px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------------------------------------------------------------- tarjetas y etiquetas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.badge-d1 { background: var(--ok-soft); color: var(--ok); }
.badge-d2 { background: var(--warn-soft); color: var(--warn); }
.badge-d3 { background: var(--danger-soft); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 14px; text-decoration: none; }
.chip:hover, .chip.active { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
code.alg { display: inline-block; padding: 1px 7px; border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--border);
  font-size: .92em; font-weight: 600; color: var(--text); white-space: normal; word-spacing: .12em; }
code.alg-lg { display: block; font-size: 19px; padding: 12px 14px; margin: 10px 0; letter-spacing: .01em; word-spacing: .22em; line-height: 1.6; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent-text); }

.page-head { margin: 4px 0 26px; }
.page-head h1 { margin-bottom: 10px; }
.page-head .lead { margin: 0; }

/* ---------------------------------------------------------------- diagramas del cubo */
.cube-svg { display: block; width: 100%; height: auto; }
.cube-svg .hl { stroke: var(--text); stroke-width: 3px; paint-order: stroke; }
.cube-iso, .cube-below { max-width: 220px; }
.cube-top { max-width: 170px; }
.cube-net { max-width: 260px; }
.diagram { margin: 0; display: grid; justify-items: center; gap: 8px; padding: 16px; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }
.diagram figcaption { font-size: 13.5px; color: var(--muted); text-align: center; max-width: 34ch; }
.diagram-sm { padding: 12px; }
.diagram-sm .cube-svg { max-width: 150px; }

/* ---------------------------------------------------------------- inicio */
.hero { background: radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%); border-bottom: 1px solid var(--border); }
.hero-inner { display: grid; gap: 24px; align-items: center; padding-top: 34px; padding-bottom: 40px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); letter-spacing: -.025em; }
.hero-cta { margin: 22px 0 8px; }
.hero-art { display: none; justify-self: center; }
.hero-cube { max-width: 300px; filter: drop-shadow(0 18px 30px rgba(0,0,0,.18)); }
.resume { margin-top: 10px; }
@media (min-width: 860px) { .hero-inner { grid-template-columns: 1.35fr 1fr; } .hero-art { display: block; } }
.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.tile { display: block; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s var(--ease), box-shadow .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.tile-icon { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); font: 700 15px var(--font-mono); margin-bottom: 12px; }
.tile-title { font-size: 18px; margin-bottom: 6px; }
.tile p { margin: 0; font-size: 15px; }
.path { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.path-level { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.path-head { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.path-head .badge { grid-column: 2; justify-self: start; }
.path-head h3 { margin: 2px 0 4px; }
.path-head h3 a { color: var(--text); text-decoration: none; }
.path-head h3 a:hover { color: var(--accent-text); }
.path-head p { margin: 0; font-size: 15px; }
.path-num { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 750; }
.path-lessons { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.path-lessons li { display: inline-flex; align-items: center; gap: 4px; }
.path-lessons a { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 14px; text-decoration: none; }
.path-lessons a:hover { color: var(--accent-text); background: var(--accent-soft); }
@media (min-width: 720px) { .path-head { grid-template-columns: auto 1fr auto; } .path-head .badge { grid-column: auto; } }
.split { display: grid; gap: 24px; }
@media (min-width: 860px) { .split { grid-template-columns: 1.3fr 1fr; align-items: start; } }
.checks { list-style: none; padding: 0; display: grid; gap: 12px; }
.checks li { padding-left: 30px; position: relative; }
.checks li::before { content: ""; position: absolute; left: 0; top: 4px; width: 20px; height: 20px; border-radius: 6px; background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m5 10.5 3 3 7-7' fill='none' stroke='%230f6e5a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/16px no-repeat; }
.link-list { padding-left: 1.1em; display: grid; gap: 6px; }
.faq { display: grid; gap: 10px; }
.faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 18px; }
.faq-item summary { cursor: pointer; list-style: none; padding: 16px 0; display: flex; justify-content: space-between; gap: 12px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 22px; line-height: 1; color: var(--muted); }
.faq-item[open] summary::after { content: "–"; }
.faq-item summary h3 { font-size: 17px; margin: 0; }
.faq-item p { color: var(--text-2); }

/* ---------------------------------------------------------------- ruta y panel */
.panel { display: grid; gap: 16px; padding: 20px; margin-bottom: 30px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.panel-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.mini-card { display: grid; gap: 4px; padding: 12px 14px; background: var(--surface-2); border-radius: var(--radius-sm); }
.mini-card a { font-weight: 650; }
.progress { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin: 6px 0 8px; }
.progress-bar { height: 100%; width: calc(var(--p, 0) * 1%); background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--cube-y))); border-radius: inherit; transition: width .4s var(--ease); }
.level-block { margin-bottom: 30px; }
.level-head { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; margin-bottom: 12px; }
.level-head h2 { font-size: 21px; margin: 2px 0 4px; }
.level-head h2 a { color: var(--text); text-decoration: none; }
.level-head p { margin: 0; }
.level-meta { grid-column: 2; display: flex; gap: 10px; align-items: center; }
@media (min-width: 720px) { .level-head { grid-template-columns: auto 1fr auto; } .level-meta { grid-column: auto; } }
.lesson-list { display: grid; gap: 8px; }
.lesson-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; transition: border-color .15s, background .15s; }
.lesson-row:hover { border-color: var(--accent); }
.lesson-row.is-done { background: color-mix(in srgb, var(--ok-soft) 60%, var(--surface)); }
.lesson-row-body { display: grid; gap: 2px; }
.lesson-num { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 14px; color: var(--text-2); }
.lesson-row.is-done .lesson-num { background: var(--ok); color: #fff; }
.lesson-check { color: var(--ok); font-weight: 800; }
.lesson-list.compact .lesson-row-body .small { display: none; }
@media (max-width: 520px) { .lesson-meta { display: none; } .lesson-row { grid-template-columns: auto 1fr auto; } }

/* ---------------------------------------------------------------- lección */
.lesson-layout { display: grid; gap: 30px; }
@media (min-width: 1040px) { .lesson-layout { grid-template-columns: minmax(0, 1fr) 270px; } .lesson-aside { position: sticky; top: calc(var(--topbar-h) + 20px); align-self: start; } }
.lesson { min-width: 0; max-width: 780px; }
.lesson-aside { display: grid; gap: 14px; align-content: start; }
.toc, .related { padding: 16px 18px; }
.toc ul, .related ul { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 14.5px; }
.toc a { color: var(--text-2); text-decoration: none; }
.toc a:hover { color: var(--accent-text); }
@media (max-width: 1039px) { .toc { display: none; } }
.prose { font-size: 16.5px; line-height: 1.7; color: var(--text); }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li { margin-bottom: .35em; }
.prose h3 { margin-top: 1.2em; }
.prose img { border-radius: var(--radius); }
.lesson-section { margin-top: 38px; }
.lesson-section > h2 { padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.step { display: grid; gap: 16px; padding: 18px 0; border-bottom: 1px dashed var(--border); }
.step:last-child { border-bottom: 0; }
.step h3 { margin-bottom: 8px; }
.step .prose { margin-bottom: 0; }
.step-alg { margin-top: 6px; }
.step-alg code.alg-lg { margin: 0; flex: 1 1 260px; }
@media (min-width: 720px) { .step-has-figure { grid-template-columns: minmax(0, 1fr) 240px; align-items: start; } }
.alg-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.alg-card { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color .15s; }
.alg-card:hover { border-color: var(--accent); }
.alg-card-img { display: grid; place-items: center; background: var(--surface-2); border-radius: var(--radius-sm); padding: 6px; align-self: start; }
.alg-card-img .cube-svg { max-width: 84px; }
.alg-card-body { min-width: 0; display: grid; gap: 6px; align-content: start; }
.alg-card-title { font-size: 16px; margin: 0; }
.alg-card-title a { color: var(--text); text-decoration: none; }
.alg-card-title a:hover { color: var(--accent-text); }
.alg-card p { margin: 0; }
.alg-card .icon-btn { width: 34px; height: 34px; }
.fav svg path { fill: transparent; }
.fav[aria-pressed="true"] { color: #d99a00; }
.fav[aria-pressed="true"] svg path { fill: currentColor; }
.examples { display: grid; gap: 14px; }
.example { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 16px; align-items: start; }
.example h3 { font-size: 17px; }
.example .example-svg { max-width: 110px; }
.example p { margin: 0 0 8px; }
.callout-list { list-style: none; padding: 0; display: grid; gap: 10px; }
.callout-list li { padding: 12px 14px 12px 44px; border-radius: var(--radius-sm); position: relative; }
.callout-list li::before { position: absolute; left: 14px; top: 11px; font-weight: 800; }
.callout-warn li { background: var(--warn-soft); }
.callout-warn li::before { content: "!"; color: var(--warn); width: 20px; height: 20px; border: 2px solid currentColor; border-radius: 50%; display: grid; place-items: center; font-size: 12px; top: 13px; }
.callout-tip li { background: var(--accent-soft); }
.callout-tip li::before { content: "→"; color: var(--accent-text); }
.callout-list p { margin: 0; }
.complete { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 20px; margin-top: 40px; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); }
.complete h2 { margin: 0 0 4px; }
.complete p { margin: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.pager-link { display: grid; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); text-decoration: none; }
.pager-link:hover { border-color: var(--accent); }
.pager-next { text-align: right; grid-column: 2; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager-next { grid-column: auto; } }

/* guía */
.guide-level { margin-top: 36px; }
.guide-step { display: grid; gap: 16px; padding: 16px 0; border-top: 1px solid var(--border); }
@media (min-width: 640px) { .guide-step { grid-template-columns: 170px 1fr; } }
.guide-step h3 a { color: var(--text); }
.guide-step p { margin: 0 0 6px; }
.guide-algs { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; gap: 4px; font-size: 14.5px; }

/* ---------------------------------------------------------------- algoritmos */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.filters .field:not(.grow) { min-width: 180px; }
.alg-group { margin-top: 30px; }
.alg-group h2 a { color: var(--text); text-decoration: none; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.alg-hero { display: grid; gap: 22px; align-items: start; }
@media (min-width: 680px) { .alg-hero { grid-template-columns: 250px 1fr; } }
.alg-detail .page-head { align-items: center; }

/* ---------------------------------------------------------------- ejercicios */
.exercise-list { display: grid; gap: 14px; }
.ex-lesson { font-size: 17px; margin: 22px 0 10px; }
.ex-lesson a { color: var(--text); }
.exercise { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.exercise.is-ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.exercise.is-fail { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.exercise-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.exercise-status.ok { color: var(--ok); font-weight: 700; }
.exercise-prompt { font-weight: 600; margin: 4px 0 12px; }
.exercise-prompt p { margin: 0; }
.exercise .diagram { justify-items: start; background: none; border: 0; padding: 0 0 12px; }
.choices { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.choice:hover { border-color: var(--accent); }
.choice input { margin-top: 4px; accent-color: var(--accent); width: 17px; height: 17px; flex: none; }
.choice.is-right { border-color: var(--ok); background: var(--ok-soft); }
.choice.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.sequence { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.seq-blank { width: 58px; min-height: 36px; text-align: center; border: 2px dashed var(--border-strong); border-radius: var(--radius-xs); background: var(--surface-2); color: var(--text); font: 600 15px var(--font-mono); }
.seq-blank:focus { border-style: solid; border-color: var(--accent); }
.seq-blank.is-right { border: 2px solid var(--ok); }
.seq-blank.is-wrong { border: 2px solid var(--danger); }
.exercise-actions { margin-top: 12px; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 15px; }
.feedback.ok { background: var(--ok-soft); }
.feedback.fail { background: var(--danger-soft); }
.feedback p { margin: 0 0 6px; }
.feedback p:last-child { margin: 0; }

/* ---------------------------------------------------------------- simulador */
.sim { display: grid; gap: 18px; }
@media (min-width: 960px) { .sim { grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); align-items: start; } }
.sim-stage { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.sim-viewport { position: relative; aspect-ratio: 1 / 1; max-height: 72vh; width: 100%; display: grid; place-items: center; touch-action: none; cursor: grab; user-select: none;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent) 8%, var(--surface)), var(--surface-2)); }
.sim-viewport:active { cursor: grabbing; }
.sim-fallback { width: 55%; max-width: 280px; }
.sim-status { padding: 10px 16px; border-top: 1px solid var(--border); }
.sim-panel { display: grid; gap: 14px; }
.move-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
@media (max-width: 420px) { .move-pad { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.move-btn { min-height: 38px; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-xs); color: var(--text); font: 650 14px var(--font-mono); cursor: pointer; padding: 0; }
.move-btn:hover { border-color: var(--accent); color: var(--accent-text); }
.move-btn:active { background: var(--accent-soft); }
.more-moves { margin-top: 10px; }
.more-moves summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.sim-tools { margin-top: 12px; }
.player-moves { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; min-height: 30px; }
.player-moves span { padding: 3px 7px; border-radius: var(--radius-xs); background: var(--surface-2); font: 600 14px var(--font-mono); color: var(--muted); }
.player-moves span.done { color: var(--text); }
.player-moves span.current { background: var(--accent); color: var(--on-accent); }
.player-controls { margin-bottom: 10px; }
.sim-net { margin-top: 18px; }
.sim-net svg { max-width: 300px; }
input[type="range"] { accent-color: var(--accent); }

/* cubo 3D con CSS (sin WebGL): 26 cubitos con sus caras */
.cube3d-scene { width: 100%; height: 100%; display: grid; place-items: center; perspective: 1100px; }
.cube3d { --s: min(15vw, 82px); position: relative; width: calc(var(--s) * 3); height: calc(var(--s) * 3); transform-style: preserve-3d; }
@media (min-width: 960px) { .cube3d { --s: min(6vw, 86px); } }
.cube3d-layer { position: absolute; inset: 0; transform-style: preserve-3d; }
.cubie { position: absolute; left: 50%; top: 50%; width: var(--s); height: var(--s); margin: calc(var(--s) / -2) 0 0 calc(var(--s) / -2); transform-style: preserve-3d; }
.cubie-face { position: absolute; inset: 0; background: #151617; border-radius: 6%; backface-visibility: hidden; }
.cubie-face::after { content: ""; position: absolute; inset: 6%; border-radius: 12%; background: var(--c, transparent); box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
@media (prefers-reduced-motion: reduce) { .cube3d-layer { transition: none !important; } }

.scramble-net svg { width: 150px; }

/* ---------------------------------------------------------------- cronómetro */
.timer { display: grid; gap: 16px; }
@media (min-width: 960px) { .timer { grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); } .timer-main { grid-row: span 2; } }
.timer-main { padding: 18px; display: grid; gap: 14px; align-content: start; }
.scramble { font-size: clamp(17px, 2.6vw, 22px); font-weight: 600; line-height: 1.55; margin: 4px 0 10px; word-spacing: .2em; }
.timer-display { width: 100%; border: 0; background: var(--surface-2); border-radius: var(--radius-lg); padding: clamp(28px, 7vw, 64px) 10px;
  font: 700 clamp(64px, 16vw, 140px)/1 var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text); cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; transition: color .1s, background .2s; }
.timer-display.is-holding { color: var(--danger); }
.timer-display.is-ready { color: var(--ok); }
.timer-display.is-inspecting { color: var(--warn); }
.timer-display.is-running { background: var(--surface); }
.page-timer.timer-running .topbar, .page-timer.timer-running .footer, .page-timer.timer-running .breadcrumbs { visibility: hidden; }
.timer-hint { text-align: center; margin: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 14px; }
.stats-grid div { background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); }
.stats-grid dt { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stats-grid dd { margin: 2px 0 0; font: 700 19px var(--font-mono); font-variant-numeric: tabular-nums; }
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .line-time { fill: none; stroke: var(--muted); stroke-width: 1.5; }
.chart .line-ao5 { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font: 11px var(--font-ui); }
.chart-legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.chart-legend span::before { content: ""; display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 6px; background: var(--muted); }
.chart-legend .ao5::before { background: var(--accent); height: 4px; }
.times { list-style: none; padding: 0; margin: 10px 0 0; max-height: 420px; overflow: auto; display: grid; gap: 4px; }
.times li { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: var(--radius-xs); font-variant-numeric: tabular-nums; }
.times li:nth-child(odd) { background: var(--surface-2); }
.times .t { font: 650 15px var(--font-mono); }
.times .n { color: var(--muted); font-size: 13px; }
.times .act { display: flex; gap: 2px; }
.times .act button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: var(--radius-xs); font-size: 12.5px; }
.times .act button:hover { background: var(--surface-3); color: var(--text); }
.times .act button[aria-pressed="true"] { color: var(--danger); font-weight: 700; }
@media (max-width: 959px) { .sr-only-mobile { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
@media (min-width: 960px) { .sr-only-mobile { font-size: 26px; } }

/* ---------------------------------------------------------------- perfil */
.profile-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat-card { display: grid; gap: 4px; }
.stat-card strong { font-size: 24px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- errores, avisos */
.error-page { text-align: center; padding-top: 60px; }
.error-page .link-list { display: inline-grid; text-align: left; }
.error-code { font: 800 88px/1 var(--font-mono); color: var(--accent); margin: 0 0 10px; opacity: .85; }
.toast-area { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(94vw, 440px); }
.toast { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px 12px 16px; background: var(--text); color: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 15px; }
.toast .btn { min-height: 32px; padding: 4px 12px; font-size: 14px; background: var(--bg); color: var(--text); border-color: transparent; }
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 55; max-width: 520px; margin: 0 auto; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 15px; }
.consent p { margin: 0 0 10px; }

/* ---------------------------------------------------------------- pie */
.footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.footer-inner { max-width: 1160px; margin: 0 auto; padding: 28px var(--gutter) 36px; display: grid; gap: 20px; }
@media (min-width: 760px) { .footer-inner { grid-template-columns: 1fr 1.4fr; } }
.footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 750; margin-bottom: 6px; }
.footer-brand .brand-logo { width: 24px; height: 24px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; align-content: start; font-size: 14.5px; }
.footer-links a { color: var(--text-2); text-decoration: none; }
.footer-links a:hover { color: var(--accent-text); text-decoration: underline; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print { .topbar, .footer, .lesson-aside, .complete, .pager, .exercise-actions { display: none !important; } body { background: #fff; } }
