/* Academia: portada y lecciones. Usa los colores y piezas de styles.css. */

/* Las páginas de la academia se leen bajando (el permutador, en cambio, cabe en la pantalla). */
@media (min-width: 900px) {
  body.academy { overflow: auto; }
  body.academy .app { height: auto; min-height: 100dvh; }
}

.ac-top-link {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.ac-top-link:hover { border-color: var(--border-strong); }

/* Los textos de cada modo solo se ven en su modo */
.mode-physical [data-for="digital"],
.mode-digital [data-for="physical"],
.mode-physical .ac-practice-box { display: none !important; }

/* ---------- Lección ---------- */

.ac-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px var(--gutter) 72px;
}
.ac-article { max-width: 680px; min-width: 0; }

.ac-crumbs { display: flex; flex-wrap: wrap; gap: 6px; color: var(--text-3); font-size: 13px; }
.ac-crumbs a { color: var(--text-2); text-decoration: none; }
.ac-crumbs a:hover { color: var(--text); }
.ac-article h1 { margin: 10px 0 8px; font-size: clamp(28px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.ac-goal { margin: 0 0 20px; color: var(--text-2); font-size: 15.5px; }
.ac-goal b { color: var(--text); }

.ac-modes {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.ac-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.ac-mode svg { width: 15px; height: 15px; }
.ac-mode { white-space: nowrap; }
.ac-mode:hover { color: var(--text); }
.ac-mode[aria-checked="true"] { background: var(--raised-hover); color: var(--text); }
.ac-mode-note { margin: 10px 0 0; color: var(--text-3); font-size: 13px; }

.ac-content { margin-top: 26px; }
.ac-content p { margin: 0 0 14px; color: #c9c9c9; font-size: 15.5px; line-height: 1.7; }
.ac-content h2 { margin: 30px 0 10px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.ac-content b { color: var(--text); }
.ac-content code, .ac-practice code, .ac-hint-text code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--raised);
  color: var(--text);
  font-family: var(--mono);
  font-size: .88em;
  white-space: nowrap;
}
.ac-list { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.ac-list li { position: relative; padding-left: 36px; color: #c9c9c9; font-size: 15.5px; line-height: 1.65; counter-increment: step; }
.ac-list li::before {
  content: counter(step);
  position: absolute;
  top: 1px;
  left: 0;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}
.ac-tip {
  padding: 12px 16px;
  border-left: 3px solid var(--warn);
  border-radius: 0 12px 12px 0;
  background: rgba(251, 191, 36, .06);
  font-size: 14.5px !important;
}

/* Casos: botones que lo enseñan en el cubo */
.ac-demos { display: grid; gap: 8px; margin: 6px 0 18px; }
.ac-demos.compact { display: flex; flex-wrap: wrap; gap: 6px; }
.ac-demo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ac-demos.compact .ac-demo { padding: 6px 12px 6px 6px; gap: 8px; border-radius: 999px; }
.ac-demo:hover { border-color: rgba(255, 255, 255, .3); background: var(--raised); }
.ac-demo.active { border-color: #fff; }
.ac-demo-play {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: #111;
}
.ac-demos.compact .ac-demo-play { width: 24px; height: 24px; }
.ac-demo-play svg { width: 11px; height: 11px; margin-left: 2px; }
.ac-demo-text { display: grid; gap: 3px; min-width: 0; }
.ac-demo-title { font-size: 14px; font-weight: 600; }
.ac-demo code { color: var(--text-2); font-family: var(--mono); font-size: 13px; font-weight: 600; }
.ac-demos.compact .ac-demo code { color: var(--text); font-size: 14px; }

.ac-done {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.ac-done div { display: grid; gap: 2px; }
.ac-done span { color: var(--text-2); font-size: 13.5px; }
.ac-done-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.ac-done-btn svg { width: 15px; height: 15px; }
.ac-done-btn.is-done { border-color: var(--ok); color: var(--ok); }
.ac-done-note { margin: 30px 0 0; color: var(--text-3); font-size: 13.5px; }

.ac-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.ac-pager a {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}
.ac-pager a:hover { border-color: var(--border-strong); }
.ac-pager span { color: var(--text-3); font-size: 12.5px; font-weight: 500; }
.ac-next { text-align: right; }

/* ---------- Cubo de la lección ---------- */

.ac-cube { position: sticky; top: 16px; display: grid; gap: 12px; min-width: 0; }
.ac-stage { position: relative; height: min(400px, 48vh); }
.ac-stage .viewport { position: absolute; inset: 0; }
.ac-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.ac-caption { margin: 0; font-size: 14px; font-weight: 600; }
.ac-caption.muted { color: var(--text-3); font-weight: 500; }
.ac-moves { display: flex; flex-wrap: wrap; gap: 4px; }
.ac-moves .mv { min-width: 30px; padding: 3px 6px; border-radius: 8px; font-size: 14px; }
.ac-panel .player { gap: 5px; }
.ac-panel .ctrl { width: 32px; height: 32px; }
.ac-panel .ctrl.play { min-width: 104px; height: 32px; font-size: 13px; }

.ac-practice-box:empty { display: none; }
.ac-practice { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.ac-practice-text { margin: 0; color: var(--text-2); font-size: 13.5px; }
.ac-practice-text b { color: var(--text); }
.ac-practice-text .ok { color: var(--ok); font-size: 15px; }
.ac-practice-text .muted { margin-left: 6px; color: var(--text-3); }
.ac-practice-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ac-practice-btns .btn-primary { height: 36px; margin: 0; padding: 0 18px; font-size: 13.5px; display: inline-flex; align-items: center; text-decoration: none; }
.ac-practice-btns .tool-btn { height: 36px; }
.ac-hint { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--raised); }
.ac-hint-text { margin: 0; color: var(--text-2); font-size: 13.5px; }
.ac-hint-alg { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.ac-hint .tool-btn { justify-self: start; }
.ac-hint .tool-btn svg { width: 11px; height: 11px; }

/* ---------- Portada ---------- */

.ac-index { width: 100%; max-width: 1140px; margin: 0 auto; padding: 24px var(--gutter) 72px; }

/* Arriba: título y la tarjeta "sigue donde lo dejaste" */
.ac-hero { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; align-items: center; margin: 8px 0 44px; }
.ac-kicker { margin: 0; color: var(--text-3); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.ac-hero h1 { margin: 10px 0 14px; font-size: clamp(32px, 4.6vw, 50px); font-weight: 800; letter-spacing: -.03em; line-height: 1.06; }
.ac-hero p { max-width: 560px; margin: 0; color: var(--text-2); font-size: 16.5px; line-height: 1.6; }
.ac-continue {
  display: grid;
  gap: 6px;
  padding: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(74, 222, 128, .1), transparent 55%), var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, transform .15s var(--ease);
}
.ac-continue:hover { border-color: rgba(255, 255, 255, .3); transform: translateY(-2px); }
.ac-continue-label { color: var(--ok); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ac-continue-where { margin-top: 6px; color: var(--text-3); font-size: 13px; font-weight: 600; }
.ac-continue-title { font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.ac-continue .ac-progress { margin-top: 10px; }
.ac-continue-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 13px; }
.ac-continue-go { padding: 8px 16px; border-radius: 999px; background: #fff; color: #111; font-size: 14px; font-weight: 700; white-space: nowrap; }

/* Barra de progreso */
.ac-progress { display: flex; align-items: center; gap: 10px; }
.ac-bar { flex: 1; height: 6px; overflow: hidden; border-radius: 999px; background: var(--raised-hover); }
.ac-bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent, var(--ok)); transition: width .4s var(--ease); }
.ac-progress-n { color: var(--text-3); font-family: var(--mono); font-size: 12px; font-weight: 600; }

/* Niveles */
.ac-section-title { margin: 0 0 14px; font-size: 22px; font-weight: 800; }
.ac-levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; margin-bottom: 44px; }
.ac-level-aprendiz { --accent: #4ADE80; }
.ac-level-speedcuber { --accent: #60A5FA; }
.ac-level-maestro { --accent: #C084FC; }
.ac-level {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 9%, transparent), transparent 140px), var(--surface);
}
.ac-level.locked { border-color: var(--border); opacity: .6; }
.ac-level-top { display: flex; align-items: center; gap: 16px; }
.ac-art { flex: none; width: 74px; height: auto; }
.ac-level-name { display: grid; justify-items: start; gap: 4px; }
.ac-level-n { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ac-level h2 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.ac-tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
}
.ac-tag[hidden] { display: none; }
.ac-tag.paid:not(.owned) { background: rgba(251, 191, 36, .14); color: var(--warn); }
.ac-tagline { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.ac-soon { color: var(--text-3) !important; font-weight: 600; }
.ac-lessons { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.ac-lessons a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}
.ac-lessons a:hover { background: var(--raised); }
.ac-lessons a.next { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.ac-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
}
.ac-lessons a.next .ac-num { border-color: var(--accent); background: var(--accent); color: #111; }
.ac-lessons a.done .ac-num { border-color: transparent; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.ac-lessons a.done .ac-title { color: var(--text-2); }
.ac-check { display: none; margin-left: auto; color: var(--ok); }
.ac-check svg { width: 15px; height: 15px; }
.ac-lessons a.done .ac-check { display: inline-flex; }
.ac-lessons a.done .ac-lock { display: none; }
.ac-level-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ac-start { display: inline-flex; flex: 1; align-items: center; justify-content: center; margin: 0; text-decoration: none; }
.ac-level-actions .ac-buy { flex: 1 0 100%; justify-content: center; }
.ac-level.complete .ac-start { background: var(--raised); color: var(--text); }
.ac-level.complete .ac-start:hover { background: var(--raised-hover); }

/* ---------- Móvil / tablet ---------- */

@media (max-width: 899px) {
  .ac-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; padding-top: 12px; }
  /* El cubo arriba y fijo mientras se lee la lección */
  .ac-cube {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 8px;
    padding-bottom: 10px;
    background: var(--bg);
    box-shadow: 0 10px 14px -12px rgba(0, 0, 0, .6);
  }
  .ac-stage { height: min(300px, 32svh); }
  .ac-panel { gap: 8px; padding: 10px 12px; border-radius: 16px; }
  .ac-moves { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ac-moves .mv { flex: none; }
  .ac-caption { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
  .ac-practice { padding-top: 8px; gap: 8px; }
  .ac-levels { grid-template-columns: minmax(0, 1fr); }
  .ac-hero { grid-template-columns: minmax(0, 1fr); gap: 24px; margin-bottom: 34px; }
}

@media (max-width: 640px) {
  .ac-top-link { height: 36px; padding: 0 12px; font-size: 13px; }
  .ac-modes { display: flex; justify-self: stretch; }
  .ac-mode { flex: 1; justify-content: center; padding: 0 10px; }
  .ac-done { flex-direction: column; align-items: stretch; }
  .ac-pager { grid-template-columns: minmax(0, 1fr); }
  .ac-next { text-align: left; }
  .ac-panel .ctrl.play { min-width: 0; flex: 1; }
  .ac-panel .player-status { flex-basis: auto; }
}

/* ---------- Herramientas (portada) ---------- */

.ac-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.ac-tool {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.ac-tool:hover { border-color: rgba(255, 255, 255, .3); background: var(--raised); }
.ac-tool-icon { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px; background: var(--raised-hover); }
.ac-tool-icon svg { width: 22px; height: 22px; }
.ac-tool-text { display: grid; gap: 3px; }
.ac-tool b { font-size: 16px; }
.ac-tool-text span { color: var(--text-2); font-size: 13.5px; }
.ac-tool-text .ac-tool-stat { margin-top: 3px; color: var(--ok); font-size: 12.5px; font-weight: 600; }
.ac-tool-stat[hidden] { display: none; }

/* ---------- Cronómetro ---------- */

.tm, .tr { width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px var(--gutter) 60px; }
.tm-top { display: grid; gap: 10px; justify-items: start; margin-bottom: 18px; }
.tm-top h1 { margin: 0; font-size: clamp(26px, 4vw, 34px); font-weight: 800; letter-spacing: -.02em; }
.tm { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "top top" "scramble side" "main side"; column-gap: 32px; align-items: start; }
.tm-top { grid-area: top; }
.tm-scramble { grid-area: scramble; display: grid; gap: 8px; justify-items: start; padding: 16px 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.tm-label { margin: 0; color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.tm-moves { margin: 0; font-family: var(--mono); font-size: clamp(16px, 2.2vw, 21px); font-weight: 600; line-height: 1.5; word-spacing: 4px; }
.tm-main { grid-area: main; display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 20px; align-items: center; margin-top: 16px; }
.tm-preview { position: relative; height: 240px; }
.tm-preview .viewport { position: absolute; inset: 0; }
.tm-clock-box { display: grid; justify-items: center; gap: 10px; }
.tm-clock {
  width: 100%;
  padding: 18px 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: clamp(64px, 11vw, 120px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color .1s;
}
[data-phase="holding"] .tm-clock { color: #f87171; }
[data-phase="ready"] .tm-clock { color: var(--ok); }
[data-phase="inspecting"] .tm-clock { color: var(--warn); }
.tm-hint { margin: 0; color: var(--text-3); font-size: 13.5px; text-align: center; }
/* Mientras se resuelve, solo el tiempo */
[data-phase="running"] .tm-scramble, [data-phase="running"] .tm-side, [data-phase="running"] .tm-preview, [data-phase="running"] .topbar, [data-phase="running"] .tm-top, [data-phase="running"] .ad-slot { visibility: hidden; }

.tm-side-wrap { grid-area: side; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.tm-side { display: grid; gap: 14px; }
.tm-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tm-stat { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.tm-stat span { color: var(--text-3); font-size: 12px; font-weight: 600; }
.tm-stat b { font-family: var(--mono); font-size: 20px; }
.tm-option { display: flex; gap: 10px; align-items: flex-start; color: var(--text-2); font-size: 13px; line-height: 1.5; cursor: pointer; }
.tm-option input { margin-top: 1px; }
.tm-list-head { display: flex; align-items: center; justify-content: space-between; }
.tm-list-head .tool-btn { height: 28px; font-size: 12px; }
.tm-list { display: grid; gap: 2px; max-height: 360px; margin: 0; padding: 0; overflow-y: auto; list-style: none; scrollbar-width: thin; }
.tm-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.tm-list li:hover { background: var(--raised); }
.tm-n { width: 28px; color: var(--text-3); font-size: 12px; text-align: right; }
.tm-list b { font-family: var(--mono); font-size: 15px; }
.tm-list b.pen { color: var(--warn); }
.tm-actions { display: flex; gap: 4px; margin-left: auto; }
.tm-actions button {
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.tm-actions button:hover { color: var(--text); }
.tm-actions button[aria-pressed="true"] { border-color: var(--warn); color: var(--warn); }

/* ---------- Entrenador ---------- */

.tr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 32px; align-items: start; }
.tr-cube { display: grid; gap: 12px; }
.tr-cube .ac-stage { height: min(380px, 46vh); }
.tr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tr-time { font-family: var(--mono); font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tr-time.ok { color: var(--ok); }
.tr-side-wrap { display: grid; gap: 14px; align-content: start; min-width: 0; }
.tr-side { display: grid; gap: 14px; }
.tr-side-intro { margin: 0; color: var(--text-2); font-size: 13.5px; }
.tr-group { padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.tr-group-head { display: flex; gap: 8px; align-items: center; font-weight: 700; cursor: pointer; }
.tr-cases { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.tr-cases li { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; align-items: baseline; }
.tr-cases label { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 600; cursor: pointer; }
.tr-cases code { color: var(--text-2); font-family: var(--mono); font-size: 12px; }
.tr-stat { grid-column: 1 / -1; padding-left: 24px; color: var(--text-3); font-size: 12px; }
.tr-side > .tool-btn { justify-self: start; }

@media (max-width: 899px) {
  .ac-tools { grid-template-columns: minmax(0, 1fr); }
  .tm { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "scramble" "main" "side"; }
  .tm-main { grid-template-columns: 1fr; }
  .tm-preview { height: 170px; order: 2; }
  .tm-side-wrap { margin-top: 18px; }
  .tr-layout { grid-template-columns: minmax(0, 1fr); }
  .tr-cube { position: sticky; top: 0; z-index: 5; padding-bottom: 10px; background: var(--bg); }
  .tr-cube .ac-stage { height: min(280px, 32svh); }
}

/* ---------- Tablas de casos (OLL y PLL completas) ---------- */

.ac-cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 6px 0 18px; }
.ac-case { align-items: center; padding: 8px 12px 8px 8px; }
.ac-case .ll-diagram { flex: none; width: 58px; height: 58px; }
.ac-case code { font-size: 11.5px; line-height: 1.45; white-space: normal; word-break: break-word; }
.ll-diagram rect[fill="transparent"] { display: none; }

/* Entrenador: grupos plegables y dibujos pequeños */
.tr-group summary { list-style: none; cursor: pointer; }
.tr-group summary::-webkit-details-marker { display: none; }
.tr-group summary .tr-count { margin-left: auto; color: var(--text-3); font-size: 12px; font-weight: 600; }
.tr-cases li.has-diagram { grid-template-columns: 40px auto 1fr; }
.tr-cases .ll-diagram { grid-row: span 2; width: 40px; height: 40px; }
.tr-cases li.has-diagram .tr-stat { grid-column: 2 / -1; padding-left: 24px; }
.tr-bulk { display: flex; gap: 6px; margin-top: 8px; }
.tr-bulk button { height: 26px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: transparent; color: var(--text-2); font-size: 12px; cursor: pointer; }
.tr-bulk button:hover { color: var(--text); }

/* ---------- Academia de pago ---------- */

/* Candados de la portada: solo si el cobro está activo y no se ha comprado */
.ac-lock { display: none; margin-left: auto; color: var(--text-3); }
.ac-lock svg { width: 13px; height: 13px; }
.paywall-locked .ac-lock, .ac-locked-page .ac-lock { display: inline-flex; }
.paywall-locked .ac-lock + .ac-check { margin-left: 8px; }
.ac-free { margin-left: auto; color: var(--ok); font-size: 12px; font-weight: 600; }
.ac-level-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.ac-level-actions .ac-start { margin: 0; }
.ac-buy svg { width: 13px; height: 13px; }

/* Vista previa de una lección de pago */
.ac-locked { width: 100%; max-width: 720px; margin: 0 auto; padding: 22px var(--gutter) 72px; }
.ac-locked h1 { margin: 10px 0 8px; font-size: clamp(28px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.ac-locked .ac-content { margin-top: 18px; }
.lock-card {
  display: grid;
  gap: 12px;
  margin-top: 22px;
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 60%), var(--surface);
}
.lock-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--raised-hover); }
.lock-icon svg { width: 20px; height: 20px; }
.lock-card h2 { margin: 0; font-size: 21px; font-weight: 800; }
.lock-card > p { margin: 0; color: var(--text-2); }
.lock-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 4px; }
.lock-actions .btn-primary { margin: 0; }
.lock-actions span { color: var(--text-3); font-size: 13px; }
.lock-have { margin: 0; color: var(--text-3); font-size: 13px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.lock-lessons { margin-top: 30px; }
.lock-lessons h2 { margin: 0 0 8px; font-size: 16px; }

/* Cronómetro en ordenador: la herramienta cabe en la pantalla (solo baja la lista de resoluciones);
   debajo, la explicación y el pie de página. */
@media (min-width: 900px) {
  body.timer-page .app { height: 100dvh; min-height: 0; }
  .timer-page .tm { flex: 1; min-height: 0; grid-template-rows: auto auto minmax(0, 1fr); padding-bottom: 24px; }
  /* contain: size -> la columna ocupa el hueco que le toca y no crece con la lista (la lista baja por dentro). */
  .timer-page .tm-side-wrap { align-self: stretch; min-height: 0; contain: size; }
  .timer-page .tm-side { flex: 1; min-height: 0; grid-template-rows: auto auto auto minmax(0, 1fr); }
  .timer-page .tm-list { align-content: start; max-height: none; min-height: 0; padding-right: 4px; }
}

/* ---------- Algoritmos y patrones (páginas gratis) ---------- */
.lib-learn { display: grid; gap: 10px; margin-top: 30px; padding: 20px; border: 1px solid var(--border-strong); border-radius: 20px; background: linear-gradient(160deg, rgba(192, 132, 252, .1), transparent 60%), var(--surface); }
.lib-learn h2 { margin: 0 !important; font-size: 19px; }
.lib-learn p { margin: 0; }
.lib-links { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-links a { display: inline-flex; align-items: center; margin: 0; text-decoration: none; }
.lib-more { color: var(--text-3); font-size: 14px; }
.lib-more a { color: var(--text-2); font-weight: 600; text-decoration: none; }
.lib-more a:hover { color: var(--text); }
.pat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 6px 0 4px; }
.pat-card { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); }
.pat-card-link { display: flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; }
.pat-card-link:hover b { text-decoration: underline; }
.pat-art { flex: none; width: 74px; height: auto; }
.pat-art.big { width: 160px; }
.pat-card-text { display: grid; gap: 3px; }
.pat-card-text b { font-size: 15.5px; }
.pat-card-text span { color: var(--text-2); font-size: 13px; line-height: 1.45; }
.pat-card-text .pat-card-n { color: var(--text-3); font-size: 12px; }
.pat-card .ac-demo { width: 100%; }
.pat-hero { display: grid; place-items: center; padding: 18px 0 6px; }
.pat-card { min-width: 0; }
.pat-card .ac-demo-text { min-width: 0; }
.pat-card .ac-demo code { white-space: normal; overflow-wrap: anywhere; }
.pat-sizes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 6px; }
.pat-size { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-2); font-size: 13.5px; font-weight: 700; text-decoration: none; }
a.pat-size:hover { border-color: rgba(255, 255, 255, .35); color: var(--text); }
.pat-size[aria-current="page"] { border-color: #fff; background: var(--raised); color: var(--text); }
.pat-also { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--text-3); font-size: 13.5px; }
.tm-side-wrap .ad-slot, .tr-side-wrap .ad-slot { margin: 0; }

/* Patrones de cubos grandes: un apartado por patrón en la página de su tamaño */
.pat-big { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); scroll-margin-top: 20px; }
.pat-big .pat-art.mid { width: 150px; }
.pat-big-text h2 { margin: 0 0 6px !important; }
.pat-big-text p { margin: 0 0 10px; }
.pat-big-links { font-weight: 600; }
.pat-big .muted { color: var(--text-3); }
@media (max-width: 640px) {
  .pat-big { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
  .pat-big .pat-art.mid { width: 96px; }
}
/* En las páginas de algoritmos y patrones los algoritmos largos pasan a la línea siguiente. */
.ac-free-page .ac-demo, .ac-free-page .ac-demo-text, .pat-big-text { min-width: 0; }
.ac-free-page .ac-demo code { white-space: normal; overflow-wrap: anywhere; }
.pat-big-links a { color: var(--text); text-decoration: none; }
.pat-big-links a:hover { text-decoration: underline; }
.ac-free-page .ac-content code { white-space: normal; overflow-wrap: anywhere; }
.ac-free-page .ac-tip a { color: var(--text); }

/* ---------- Récords ---------- */
.rec-main h1 { margin: 10px 0 12px; font-size: clamp(30px, 4.4vw, 44px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.rec-lead { max-width: 760px; margin: 0; color: var(--text-2); font-size: 17px; line-height: 1.6; }
.rec-lead b { color: var(--text); }
.rec-updated { margin: 8px 0 0; color: var(--text-3); font-size: 13px; }
.rec-section { margin-top: 40px; }
.rec-section h2 { margin: 0 0 8px; font-size: 24px; font-weight: 800; }
.rec-section > p { max-width: 760px; color: var(--text-2); font-size: 15px; line-height: 1.65; }
.rec-section a, .rec-source a { color: var(--text); }
.rec-group { margin: 26px 0 10px; color: var(--text-3); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.rec-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.rec-card { display: grid; gap: 10px; padding: 16px 18px; border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); }
.rec-card h3 { margin: 0; font-size: 16px; }
.rec-row { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; align-items: baseline; }
.rec-type { color: var(--text-3); font-size: 12px; font-weight: 700; }
.rec-value { font-family: var(--mono); font-size: 20px; }
.rec-who, .rec-where { grid-column: 2; font-size: 13px; }
.rec-who { color: var(--text); }
.rec-who a { color: var(--text); text-decoration: none; }
.rec-who a:hover { text-decoration: underline; }
.rec-where { color: var(--text-3); }
.rec-source { margin-top: 34px; color: var(--text-3); font-size: 13px; line-height: 1.6; }
.rec-cc { color: var(--text-3); }

/* ---------- Guías ---------- */
.guide-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 28px; }
.guide-card { display: grid; gap: 8px; align-content: start; padding: 20px; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s var(--ease); }
.guide-card:hover { border-color: rgba(255, 255, 255, .3); transform: translateY(-2px); }
.guide-card b { font-size: 17px; line-height: 1.35; }
.guide-card span { color: var(--text-2); font-size: 14px; line-height: 1.55; }
.guide-card .guide-go { color: var(--text); font-weight: 700; }
.guide-more { display: grid; gap: 8px; padding-left: 20px; }
.guide-more a { color: var(--text); }
.ac-free-page .ac-content a { color: var(--text); }
.rec-lead a { color: var(--text); }
