/* TuAula.lat — Página del curso (unidades plegables), reproductor de lecciones por secciones,
   ejercicios v2 y simulaciones. Usa los tokens de app.css (--paper, --card, --ink, --teal…)
   y el color de cada curso en --c. Movimiento: curvas suaves y cortas; app.css las apaga si el
   sistema pide reducir animaciones. */

:root { --e-out: cubic-bezier(.2, .8, .2, 1); --e-spring: cubic-bezier(.34, 1.56, .64, 1); }
.units-acc [hidden], .reader [hidden], .r-foot[hidden], .sim-overlay [hidden] { display: none !important; }
.options[hidden], .flash-choices[hidden] { display: none !important; }

/* ---------- Página del curso ---------- */
.course-hero { margin: 12px 0 18px; border-top: 6px solid var(--c, var(--teal)); }
.ch-top { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.course-hero .ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; color: #fff; flex: none; background: var(--c, var(--teal)); box-shadow: 0 8px 20px -10px var(--c, var(--teal)); animation: r-icon-in .7s var(--e-spring) both; }
.course-hero .ico svg { width: 30px; height: 30px; }
.course-hero h1 { font-size: clamp(1.4rem, 5vw, 1.8rem); margin: 4px 0 0; text-wrap: balance; }
.course-hero .bar > i { background: linear-gradient(90deg, var(--c, var(--teal)), color-mix(in srgb, var(--c, var(--teal)) 60%, #fff)); }
.ch-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: .82rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ch-meta b { font-weight: 600; color: var(--ink-2); }
.ch-cta { position: relative; overflow: hidden; margin-top: 16px; justify-content: space-between; text-align: left; }
.ch-cta .cta-txt { display: flex; flex-direction: column; min-width: 0; }
.ch-cta .cta-txt small { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.ch-cta svg { transition: transform .3s var(--e-out); }
.ch-cta:hover svg { transform: translateX(4px); }
/* Brillo que cruza los botones principales */
.ch-cta::after, .r-simcard .btn::after, .r-finish.ready::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  transform: translateX(-120%); animation: r-shine 3.2s 1s ease-in-out infinite;
}
@keyframes r-shine { 0%, 60% { transform: translateX(-120%); } 100% { transform: translateX(120%); } }
@keyframes r-icon-in { from { transform: scale(.4) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Barras de avance que crecen al aparecer */
.course-hero .bar > i, .u-head .bar > i, .lr-bar > i, .r-prog > i { transform-origin: left center; }
.course-hero .bar > i, .u-head .bar > i, .lr-bar > i { animation: r-grow 1s .15s var(--e-out) both; }
@keyframes r-grow { from { transform: scaleX(0); } to { transform: none; } }

.units-acc { display: grid; gap: 12px; margin-bottom: 8px; }
.u-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: box-shadow .3s ease, border-color .3s ease, transform .3s var(--e-out); }
.u-card:hover { border-color: color-mix(in srgb, var(--c, var(--teal)) 40%, var(--line)); }
.u-card.open { box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px color-mix(in srgb, var(--c, var(--teal)) 70%, transparent); }
.u-head { width: 100%; display: grid; grid-template-columns: 42px 1fr 22px; gap: 12px; align-items: center; padding: 14px; border: 0; background: none; color: var(--ink); text-align: left; }
.u-head:hover .u-title { color: var(--teal-ink); }
.u-head:active .u-ico { transform: scale(.92); }
.u-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--paper-2); color: var(--c, var(--teal-ink)); transition: background .3s ease, color .3s ease, transform .2s ease; }
.u-ico svg { width: 22px; height: 22px; }
.u-card.open:not(.locked):not(.soon) .u-ico { background: var(--c, var(--teal)); color: #fff; }
.u-card.locked .u-ico, .u-card.soon .u-ico { color: var(--ink-3); }
.u-txt { min-width: 0; }
.u-title { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.02rem; line-height: 1.25; transition: color .2s ease; }
.u-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 6px 0 9px; font-size: .8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.u-card.soon .u-meta { margin-bottom: 0; }
.u-head .bar { height: 5px; }
.u-head .bar > i { background: var(--c, var(--teal)); }
.u-chev svg { width: 22px; height: 22px; color: var(--ink-3); transition: transform .4s var(--e-spring); display: block; }
.u-card.open .u-chev svg { transform: rotate(180deg); }
/* Acordeón con altura animada */
.u-collapse { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--e-out); }
.u-card.open .u-collapse { grid-template-rows: 1fr; }
.u-body { min-height: 0; overflow: hidden; }
.u-body > .lessons { padding: 0 12px 12px; }
.u-body .lesson-row { background: var(--paper); transition: border-color .2s ease, transform .25s var(--e-out), box-shadow .25s ease; }
.u-body a.lesson-row:hover { transform: translateX(3px); box-shadow: 0 6px 18px -12px rgba(0, 0, 0, .35); }
.u-body a.lesson-row:hover > svg { color: var(--c, var(--teal)); }
.lesson-row .lr-bar { display: block; height: 3px; margin-top: 7px; border-radius: 99px; background: var(--paper-2); overflow: hidden; max-width: 220px; }
.lesson-row .lr-bar > i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--teal)); }

/* ---------- Lector: modo lectura (sin barra superior ni pestañas) ---------- */
body.reading .tabbar { display: none; }
body.reading main { padding-top: 0; padding-bottom: 130px; }
body.sim-open { overflow: hidden; }

.reader { --rs: 18px; max-width: 680px; margin: 0 auto; }
.r-bar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 8px;
  margin: 0 -16px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.r-bar .iconbtn { color: var(--ink); flex: none; text-decoration: none; transition: border-color .2s ease, transform .2s ease; }
.r-bar .iconbtn:hover { border-color: var(--teal); }
.r-bar .iconbtn:active { transform: scale(.92); }
.r-crumb { flex: 1; min-width: 0; font-family: var(--font-head); font-weight: 600; font-size: .9rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-size { font-family: var(--font-head); font-weight: 700; font-size: 1rem; letter-spacing: -.02em; }
.r-size sup { font-size: .65em; margin-left: 1px; }
/* Barra fina de avance de la lección */
.r-prog { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: transparent; overflow: hidden; }
.r-prog > i { display: block; height: 100%; width: 0; border-radius: 0 99px 99px 0; background: linear-gradient(90deg, var(--c, var(--teal)), var(--aqua)); transition: width .6s var(--e-out); }

.r-band { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-top: 6px solid var(--c, var(--teal)); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px 18px; }
.r-band h1 { font-size: clamp(1.2rem, 4.6vw, 1.45rem); margin: 6px 0 14px; text-wrap: balance; }
.r-steps { position: relative; display: flex; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 6px 4px; }
.r-steps::-webkit-scrollbar { display: none; }
.r-step { position: relative; width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; padding: 0; border: 2px solid var(--line); background: var(--card); color: var(--ink-3); font-family: var(--font-head); font-weight: 700; font-size: .85rem; transition: background .35s ease, border-color .35s ease, color .35s ease, transform .2s ease; }
.r-step svg { width: 16px; height: 16px; }
.r-step:hover { border-color: var(--c, var(--teal)); transform: translateY(-1px); }
.r-step.done { border-color: var(--green); color: var(--green); }
.r-step.cur { background: var(--c, var(--teal)); border-color: var(--c, var(--teal)); color: #fff; }
.r-step.cur::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--c, var(--teal)); opacity: 0; animation: r-pulse 2.2s ease-out infinite; }
@keyframes r-pulse { 0% { transform: scale(.8); opacity: .55; } 100% { transform: scale(1.25); opacity: 0; } }
.r-line { position: relative; flex: 1 1 14px; min-width: 8px; max-width: 52px; height: 2px; background: var(--line); overflow: hidden; border-radius: 2px; }
.r-line::after { content: ""; position: absolute; inset: 0; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .55s var(--e-out); }
.r-line.fill::after { transform: none; }

.r-sec { padding: 24px 2px 8px; outline: none; }
.r-count { font-family: var(--font-head); font-weight: 600; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.r-sec > h2 { font-size: calc(var(--rs) * 1.38); line-height: 1.2; margin: 6px 0 16px; text-wrap: balance; }
.r-p { font-size: var(--rs); line-height: 1.66; color: var(--ink); margin: 0 0 .95em; text-wrap: pretty; transition: font-size .25s ease; }
.r-lead { color: var(--ink-2); }
.term { border: 0; background: none; padding: 0; font: inherit; font-weight: 600; color: var(--teal-ink); text-decoration: underline dotted 2px; text-underline-offset: 4px; cursor: pointer; transition: background .2s ease; border-radius: 4px; }
.term:hover { background: var(--mint); }

.r-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); animation: r-foot-in .45s var(--e-out) both;
}
@keyframes r-foot-in { from { transform: translateY(100%); } to { transform: none; } }
.r-foot .inner { max-width: 680px; margin: 0 auto; }
.r-read { gap: 10px; }
.r-read.is-read span { flex: 1; text-align: center; }
.r-read.pop svg:first-child { animation: r-pop .5s var(--e-spring); }
@keyframes r-pop { 0% { transform: scale(.3) rotate(-30deg); } 70% { transform: scale(1.3); } 100% { transform: none; } }
.r-finish { position: relative; overflow: hidden; }
.r-finish .r-meter { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; pointer-events: none; }
.r-finish .r-meter i { display: block; height: 100%; background: rgba(255, 255, 255, .16); transition: width .5s var(--e-out); }
.r-finish .r-label { position: relative; }
.r-finish.ready { box-shadow: 0 3px 0 #087575, 0 10px 26px -10px var(--teal); }

/* Práctica */
.r-exlist { display: grid; gap: 16px; }
.r-ex { padding: 18px; transition: box-shadow .4s ease, border-color .4s ease; }
.r-ex.is-ok { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); animation: r-ok-ring .9s ease-out; }
.r-ex.is-bad { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
@keyframes r-ok-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 45%, transparent), var(--shadow); } 100% { box-shadow: 0 0 0 14px transparent, var(--shadow); } }
.r-exnum { display: flex; align-items: center; gap: 8px; font-family: var(--font-head); font-weight: 600; font-size: .78rem; color: var(--ink-3); margin-bottom: 8px; }
.r-exdot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-2); font-size: .72rem; }
.r-ex.is-ok .r-exdot { background: var(--green); color: #fff; }
.r-ex .q-prompt { font-size: 1.18rem; }
.r-exact { display: flex; gap: 8px; margin-top: 14px; }
.r-exnote { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-weight: 600; color: var(--teal-ink); }
.r-fb { margin-top: 14px; padding: 14px; border-radius: 14px; border: 2px solid; animation: r-fb-in .45s var(--e-out) both; transform-origin: top center; }
@keyframes r-fb-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }
.r-fb.ok { background: var(--green-bg); border-color: var(--green); }
.r-fb.bad { background: var(--red-bg); border-color: var(--red); }
.r-fb h3 { display: flex; align-items: center; gap: 8px; font-size: 1.08rem; margin: 0 0 6px; }
.r-fbi { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; animation: r-pop .55s .1s var(--e-spring) both; }
.r-fb.ok .r-fbi { background: var(--green); }
.r-fb.bad .r-fbi { background: var(--red); }
:root[data-theme="dark"] .r-fbi { color: #04223a; }
.r-fb.ok h3 { color: var(--green); }
.r-fb.bad h3 { color: var(--red); }
.r-fb .explain { color: var(--ink); margin: 0 0 8px; }
.r-fb .tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.r-fb .tutor { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 6px 0 10px; }
.r-fb .tutor .who { display: flex; gap: 6px; align-items: center; font-family: var(--font-head); font-weight: 700; font-size: .8rem; color: var(--teal-ink); }
.r-typing { display: flex; gap: 5px; padding: 10px 2px 2px; }
.r-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); animation: r-dot 1s ease-in-out infinite; }
.r-typing i:nth-child(2) { animation-delay: .15s; } .r-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes r-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

/* Resultado de la lección */
.r-result { overflow: hidden; }
.r-ring { position: relative; width: 150px; height: 150px; margin: 10px auto 4px; }
.r-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.r-ring circle { fill: none; stroke-width: 10; }
.r-ring .trk { stroke: var(--paper-2); }
.r-ring .val { stroke: var(--c, var(--teal)); stroke-linecap: round; stroke-dasharray: 100; filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--c, var(--teal)) 45%, transparent)); }
.r-ring-num { position: absolute; inset: 0; display: grid; place-content: center; grid-auto-flow: column; align-items: baseline; font-family: var(--font-head); color: var(--ink); }
.r-ring-num b { font-size: 3rem; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
.r-ring-num small { font-size: 1.2rem; font-weight: 700; color: var(--ink-3); margin-left: 2px; }
.r-burst { position: fixed; z-index: 90; width: 0; height: 0; pointer-events: none; }
.r-burst i { position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%; }

/* Tarjeta para abrir una simulación (oscura, como la simulación) */
.r-simcard { position: relative; display: grid; grid-template-columns: 92px 1fr; gap: 14px; align-items: center; margin: 8px 0 18px; padding: 14px; border-radius: 18px; background: radial-gradient(120% 140% at 0% 0%, #163657 0%, #0b1a2c 60%); color: #eef4fa; border: 1px solid rgba(255, 255, 255, .1); box-shadow: 0 18px 40px -26px rgba(4, 18, 34, .9); transition: transform .35s var(--e-out), box-shadow .35s ease; }
.r-simcard:hover { transform: translateY(-3px); box-shadow: 0 26px 50px -26px rgba(4, 18, 34, .95); }
.r-thumb { width: 92px; height: 92px; display: block; border-radius: 14px; background: #132a44; }
/* Solo se mueven las piezas marcadas: barras verticales (.b), horizontales (.bx, .bc) y puntos (.bp) */
.r-thumb .b, .r-thumb .bx, .r-thumb .bc, .r-thumb .bp { transform-box: fill-box; animation: r-thumb 2.6s ease-in-out infinite; }
.r-thumb .b { transform-origin: bottom; }
.r-thumb .bx { transform-origin: left; animation-name: r-thumbx; }
.r-thumb .bc { transform-origin: center; animation-name: r-thumbx; }
.r-thumb .bp { transform-origin: center; animation-name: r-thumbp; animation-duration: 2.4s; }
@keyframes r-thumb { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.72); } }
@keyframes r-thumbx { 0%, 100% { transform: scaleX(1); } 50% { transform: scaleX(.78); } }
@keyframes r-thumbp { 0%, 100% { transform: scale(1); } 50% { transform: scale(.7); } }
.r-tag { font-family: var(--font-head); font-weight: 600; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: #5eead4; }
.r-simcard h3 { margin: 4px 0; font-size: 1.05rem; color: #fff; }
.r-simcard p { margin: 0 0 10px; font-size: .88rem; line-height: 1.45; color: #b9c7d8; }
.r-simcard .btn { position: relative; overflow: hidden; background: #2dd4bf; color: #04223a; box-shadow: 0 3px 0 #0a7c7c; }

/* Hoja inferior (glosario) */
.r-sheet-layer { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.r-scrim { position: absolute; inset: 0; border: 0; background: rgba(4, 18, 34, .45); cursor: default; animation: r-fade .25s ease both; backdrop-filter: blur(2px); }
@keyframes r-fade { from { opacity: 0; } to { opacity: 1; } }
.r-sheet { position: relative; width: 100%; max-width: 560px; max-height: 85vh; overflow: auto; background: var(--card); color: var(--ink); border-radius: 22px 22px 0 0; padding: 10px 20px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 40px rgba(0, 0, 0, .2); animation: r-sheet-in .45s var(--e-out) both; }
@keyframes r-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.r-grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 0 auto 14px; }
.r-sheet .eyebrow { display: flex; align-items: center; gap: 6px; }
.r-sheet h3 { font-size: 1.35rem; margin: 8px 0 2px; }
.r-sheet .r-en { font-size: .85rem; color: var(--ink-3); margin: 0 0 10px; }
.r-sheet p { line-height: 1.6; }

/* ======================================================================
   Ejercicios v2 (exercises.js?v=2): se ven igual en la lección y en el repaso
   ====================================================================== */
.q-hint { font-size: .85rem; color: var(--ink-3); margin: -6px 0 12px; }
.opt { transition: border-color .2s ease, background .25s ease, box-shadow .25s ease, transform .2s var(--e-out), opacity .3s ease; }
.opt:active:not(:disabled) { transform: scale(.98); }
.opt.sel { box-shadow: 0 2px 0 var(--teal), 0 10px 22px -14px var(--teal); }
.opt.dim { opacity: .55; }
.opt.opt-k { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: center; }
.opt .key { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--line); font-family: var(--font-head); font-weight: 700; font-size: .82rem; color: var(--ink-3); transition: background .25s ease, border-color .25s ease, color .25s ease; }
.opt .key svg { width: 15px; height: 15px; }
.opt.sel .key { background: var(--teal); border-color: var(--teal); color: #fff; }
.opt.ok .key { background: var(--green); border-color: var(--green); color: #fff; }
.opt.bad .key { background: var(--red); border-color: var(--red); color: #fff; }
:root[data-theme="dark"] .opt.sel .key, :root[data-theme="dark"] .opt.ok .key, :root[data-theme="dark"] .opt.bad .key { color: #04223a; }
.tf .opt { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tf .tf-i { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-3); transition: background .25s ease, color .25s ease, transform .3s var(--e-spring); }
.tf .tf-i svg { width: 18px; height: 18px; }
.tf .opt.sel .tf-i { background: var(--teal); color: #fff; transform: scale(1.08); }
.tf .opt.ok .tf-i { background: var(--green); color: #fff; }
.tf .opt.bad .tf-i { background: var(--red); color: #fff; }
.flash-choices .opt { flex-direction: row; justify-content: center; padding: 14px 10px; font-size: 1rem; }

/* Completar */
.slot { transition: border-color .25s ease, color .25s ease, background .25s ease; border-radius: 6px 6px 0 0; }
.slot:not(.filled) { animation: r-caret 1.2s ease-in-out infinite; }
@keyframes r-caret { 0%, 100% { border-bottom-color: var(--teal); } 50% { border-bottom-color: transparent; } }
.slot.filled { background: var(--mint); }
.slot.ok { background: var(--green-bg); } .slot.bad { background: var(--red-bg); }
.word { transition: transform .2s var(--e-out), border-color .2s ease, box-shadow .2s ease; }
.word:hover:not(:disabled) { border-color: var(--teal); transform: translateY(-2px); }

/* Ordenar */
.order-answer { position: relative; transition: border-color .3s ease, background .3s ease; }
.order-answer.has { border-style: solid; border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: color-mix(in srgb, var(--mint) 35%, transparent); }
.order-empty { align-self: center; justify-self: center; font-size: .85rem; color: var(--ink-3); }
.order-answer.has .order-empty { display: none; }

/* Unir parejas: cada pareja con su color y un lazo que las une */
.match.match-v2 { position: relative; column-gap: clamp(30px, 10vw, 64px); row-gap: 10px; }
.match-v2 .col { position: relative; z-index: 1; }
.match-v2 .opt { position: relative; }
.match-v2 .opt.sel { border-color: var(--teal); background: var(--mint); transform: translateY(-2px); }
.match.match-v2 .opt.paired {
  opacity: 1; color: var(--ink); border-color: var(--pc);
  background: color-mix(in srgb, var(--pc) 15%, var(--card));
  box-shadow: 0 2px 0 color-mix(in srgb, var(--pc) 55%, transparent), 0 10px 22px -16px var(--pc);
}
.match.match-v2 .opt.paired::before {
  content: attr(data-n); position: absolute; top: -9px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--pc); color: #fff;
  font-family: var(--font-head); font-size: .7rem; font-weight: 700; animation: r-pop .45s var(--e-spring) both;
}
.match-v2 .opt.paired[data-side="l"]::before { left: -8px; }
.match-v2 .opt.paired[data-side="r"]::before { right: -8px; }
.match-v2 .opt.bad { border-color: var(--red); background: var(--red-bg); }
.match-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 2; }
.mline { fill: none; stroke: var(--pc); stroke-width: 3.5; stroke-linecap: round; }
.mlink:not(.bad) .mline { stroke-dasharray: 1; stroke-dashoffset: 1; animation: m-draw .6s var(--e-out) forwards; filter: drop-shadow(0 3px 5px color-mix(in srgb, var(--pc) 45%, transparent)); }
.mlink.bad .mline { stroke-width: 2.5; stroke-dasharray: 5 6; animation: m-bad .56s ease forwards; }
.mknot { fill: var(--pc); stroke: var(--card); stroke-width: 2.5; transform-box: fill-box; transform-origin: center; animation: m-knot .45s .25s var(--e-spring) both; }
.match-v2.done .mline { animation: m-draw .6s var(--e-out) forwards, m-glow 1.2s .5s ease-in-out; }
@keyframes m-draw { to { stroke-dashoffset: 0; } }
@keyframes m-knot { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes m-bad { 0% { opacity: 0; } 25% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes m-glow { 50% { stroke-width: 5.5; } }

/* Tarjeta de repaso: se voltea en cada toque */
.flash { perspective: 1200px; outline-offset: 4px; border-radius: 20px; }
.flash-inner { min-height: 230px; transition: transform .75s cubic-bezier(.2, .85, .25, 1.06); }
.flash-face { -webkit-backface-visibility: hidden; backface-visibility: hidden; overflow: hidden; gap: 8px; }
.flash-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%); transform: translateX(-130%); }
.flash.glare .flash-face::after { animation: r-glare .9s .15s ease; }
@keyframes r-glare { to { transform: translateX(130%); } }
.flash-face.front { background: linear-gradient(160deg, var(--card), color-mix(in srgb, var(--mint) 45%, var(--card))); }
.flash-face.back { background: linear-gradient(150deg, var(--ink), color-mix(in srgb, var(--ink) 74%, var(--teal))); }
.flash-face.front h2 { margin: 0; }
.flash-tag { font-family: var(--font-head); font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; padding: 3px 10px; border-radius: 99px; background: var(--mint); color: var(--teal-ink); }
.flash-face.back .flash-tag { background: rgba(255, 255, 255, .16); color: inherit; }
:root[data-theme="dark"] .flash-face.back .flash-tag { background: rgba(4, 34, 58, .12); }
.flash-a { font-size: 1.1rem; line-height: 1.5; }
.flash-face.back .flash-hint { color: inherit; opacity: .7; }
.flash:hover .flash-face { box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .45); }

/* ======================================================================
   Simulaciones: un solo aspecto oscuro, a propósito
   ====================================================================== */
.sim-overlay {
  position: fixed; inset: 0; z-index: 70; overflow: hidden; color: #eef4fa; color-scheme: dark;
  background: radial-gradient(120% 90% at 50% -10%, #17385b 0%, #0b1a2c 55%, #08131f 100%);
  --s-card: rgba(19, 42, 68, .82); --s-rim: rgba(255, 255, 255, .1); --s-muted: #8597ad; --s-teal: #2dd4bf; --s-blue: #7aa2f7;
  --s-gold: #f2a516; --s-green: #34d399; --s-red: #f87171; --s-track: rgba(255, 255, 255, .07);
  animation: r-fade .3s ease both;
}
.sim-overlay.closing { animation: sim-out .26s ease forwards; }
.sim-frame { position: absolute; inset: 0; display: flex; flex-direction: column; animation: sim-rise .55s var(--e-out) backwards; }
.sim-overlay.closing .sim-frame { animation: sim-sink .26s ease forwards; }
@keyframes sim-rise { from { opacity: 0; transform: translateY(28px) scale(.98); } }
@keyframes sim-out { to { opacity: 0; } }
@keyframes sim-sink { to { transform: translateY(18px) scale(.985); } }
.sim-overlay.rotated .sim-frame { inset: auto; top: 0; left: 0; width: var(--h); height: var(--w); transform-origin: 0 0; transform: translateX(var(--w)) rotate(90deg); }
.sim-top { flex: none; text-align: center; padding: calc(16px + env(safe-area-inset-top)) 16px 10px; }
.sim-kick { font-family: var(--font-head); font-weight: 600; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--s-muted); }
.sim-top h2 { margin: 6px 0 4px; font-size: 1.35rem; background: linear-gradient(90deg, #2dd4bf, #7aa2f7, #2dd4bf); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: s-sheen 6s linear infinite; }
@keyframes s-sheen { to { background-position: 200% 0; } }
.sim-top p { margin: 0 auto; max-width: 46ch; font-size: .85rem; line-height: 1.5; color: var(--s-muted); }
.sim-body { flex: 1; min-height: 0; overflow-y: auto; container-type: inline-size; }
.sim-mount { max-width: 1080px; margin: 0 auto; padding: 6px 16px 20px; }
.s-grid { display: grid; gap: 12px; }
.s-col { display: grid; gap: 12px; align-content: start; }
@container (min-width: 640px) { .s-grid { grid-template-columns: 1.2fr 1fr; align-items: start; } }
.s-card { background: var(--s-card); border: 1px solid var(--s-rim); border-radius: 18px; padding: 14px; display: grid; gap: 10px; min-width: 0; backdrop-filter: blur(8px); box-shadow: 0 20px 40px -30px rgba(0, 0, 0, .9); }
.s-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0; font-family: var(--font-head); font-weight: 600; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--s-muted); }
.s-label output { font-size: .95rem; letter-spacing: 0; color: #fff; font-variant-numeric: tabular-nums; transition: color .3s ease; }
.s-prompt { margin: 0; font-size: .98rem; line-height: 1.45; color: #fff; }
.s-prompt em { font-style: normal; color: var(--s-teal); border-bottom: 1.5px dashed var(--s-teal); display: inline-block; }
.s-prompt em.live { border-bottom-style: solid; text-shadow: 0 0 14px rgba(45, 212, 191, .55); }
.s-bars { display: grid; gap: 7px; }
.s-trow { display: grid; grid-template-columns: 80px 1fr 50px; gap: 8px; align-items: center; font-size: .85rem; }
.s-trow .tok { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-trow .track { position: relative; height: 16px; border-radius: 6px; background: var(--s-track); }
.s-trow .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px; background: linear-gradient(90deg, #5b7fd6, var(--s-blue)); transition: width .55s var(--e-out); }
.s-trow.top .fill { background: linear-gradient(90deg, #14b8a6, var(--s-teal)); box-shadow: 0 0 16px -2px rgba(45, 212, 191, .55); }
.s-trow .base { position: absolute; top: -3px; bottom: -3px; left: 0; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--s-gold); transition: left .55s var(--e-out); }
.s-trow .pct { text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.s-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .76rem; color: var(--s-muted); }
.s-legend i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.lg-fill { width: 12px; height: 8px; border-radius: 2px; background: var(--s-blue); }
.lg-base { width: 2px; height: 12px; background: var(--s-gold); }

/* Deslizadores con relleno; el de temperatura es un termómetro */
.s-range { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; margin: 10px 0 6px; border-radius: 99px; background: linear-gradient(var(--s-teal), var(--s-teal)) 0 / var(--p, 50%) 100% no-repeat, rgba(255, 255, 255, .1); outline: none; cursor: pointer; }
.s-range.thermo { background: linear-gradient(90deg, #7aa2f7, #2dd4bf 35%, #f2a516 68%, #f87171); }
.s-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px var(--tc, var(--s-teal)), 0 4px 14px rgba(0, 0, 0, .45); transition: transform .2s var(--e-spring), box-shadow .2s ease; }
.s-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 0 0 4px var(--tc, var(--s-teal)), 0 4px 14px rgba(0, 0, 0, .45); }
.s-range:active::-webkit-slider-thumb { transform: scale(1.18); }
.s-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--tc, var(--s-teal)), 0 0 0 9px rgba(94, 234, 212, .3); }
.s-scale { display: flex; justify-content: space-between; margin-top: -4px; font-size: .72rem; color: var(--s-muted); }
.s-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 10px; }
.s-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.s-stat { background: rgba(8, 19, 31, .55); border: 1px solid rgba(255, 255, 255, .05); border-radius: 12px; padding: 12px 10px; text-align: center; }
.s-stat b { display: block; font-family: var(--font-head); font-size: 1.25rem; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.s-stat span { display: block; margin-top: 5px; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--s-muted); }
.s-pill { font-family: var(--font-head); font-weight: 600; font-size: .78rem; padding: 4px 10px; border-radius: 99px; border: 1px solid currentColor; max-width: 100%; line-height: 1.25; background: color-mix(in srgb, currentColor 10%, transparent); transition: color .3s ease; }
.s-pill.lo { color: var(--s-teal); } .s-pill.mid { color: var(--s-gold); } .s-pill.hi { color: var(--s-blue); }
.s-pill.good { color: var(--s-green); } .s-pill.badp { color: var(--s-red); }
.s-select { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--s-rim); background: #0e2138; color: #fff; }
.s-btn { position: relative; overflow: hidden; padding: 12px 14px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #2dd4bf, #5eead4); color: #04223a; font-family: var(--font-head); font-weight: 600; box-shadow: 0 10px 24px -14px #2dd4bf; transition: transform .2s var(--e-out), filter .2s ease; }
.s-btn:hover { filter: brightness(1.06); }
.s-btn:active { transform: scale(.98); }
.s-btn.busy { cursor: progress; }
.s-btn.busy::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); animation: r-shine 1s linear infinite; }
.s-samples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 30px; }
.s-chip { font-size: .8rem; padding: 5px 9px; border-radius: 8px; background: #0e2138; border: 1px solid var(--s-rim); }
.s-chip.top { border-color: var(--s-teal); color: var(--s-teal); box-shadow: 0 0 12px -4px rgba(45, 212, 191, .7); }
.s-caret { width: 8px; height: 18px; border-radius: 2px; background: var(--s-teal); animation: s-blink .8s steps(1) infinite; }
@keyframes s-blink { 50% { opacity: 0; } }
.s-empty { font-size: .8rem; color: var(--s-muted); }
.s-sum { margin: 0; font-size: .75rem; color: var(--s-muted); }
.s-field { display: grid; gap: 2px; }

/* Gráfico mensual (barras que crecen desde la línea del cero) */
.s-chart2 { display: grid; gap: 6px; }
.s-plot { position: relative; height: 170px; margin-left: 70px; }
.s-zero { position: absolute; left: 0; right: 0; height: 1px; background: #8597ad; transition: top .5s var(--e-out); }
.s-yl { position: absolute; right: calc(100% + 8px); font-size: .7rem; color: var(--s-muted); white-space: nowrap; transform: translateY(-50%); font-variant-numeric: tabular-nums; transition: top .5s var(--e-out); }
.s-yl[data-s="ymax"] { top: 0; } .s-yl[data-s="ymin"] { top: 100%; }
.s-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.s-mbar { position: relative; }
.s-mbar i { position: absolute; left: 10%; right: 10%; top: 50%; height: 0; border-radius: 4px; background: linear-gradient(180deg, #5eead4, #34d399); box-shadow: 0 0 12px -4px rgba(52, 211, 153, .6); transition: top .55s var(--e-out), height .55s var(--e-out), background .3s ease; }
.s-mbar.neg i { background: linear-gradient(0deg, #fca5a5, #f87171); box-shadow: 0 0 12px -4px rgba(248, 113, 113, .6); }
.s-mbar:hover i { filter: brightness(1.15); }
.s-xl { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin-left: 70px; font-size: .7rem; color: var(--s-muted); }
.s-xl span { justify-self: center; white-space: nowrap; }

.sim-foot { flex: none; display: flex; justify-content: space-between; gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--s-rim); background: rgba(8, 19, 31, .7); backdrop-filter: blur(10px); }
.sim-foot button { display: flex; align-items: center; gap: 7px; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: #eef4fa; font-weight: 600; transition: background .2s ease, transform .2s ease; }
.sim-foot button:hover { background: rgba(255, 255, 255, .07); }
.sim-foot button:active { transform: scale(.96); }
.sim-foot svg { width: 20px; height: 20px; }

/* ---------- Piezas comunes de las simulaciones ---------- */
.s-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.s-btn.alt { background: rgba(255, 255, 255, .08); color: #eef4fa; box-shadow: inset 0 0 0 1px var(--s-rim); }
.s-btn.ghost { padding: 8px; background: transparent; color: var(--s-teal); box-shadow: none; }
.s-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--s-blue); }
.lg-fit { width: 14px; height: 3px; border-radius: 2px; background: var(--s-teal); }
.lg-res { width: 2px; height: 12px; background: var(--s-red); }

/* Embudo y barras horizontales */
.c-funnel, .c-bars { display: grid; gap: 12px; }
.c-fl { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; font-size: .82rem; }
.c-fl span { color: #cfd9e6; }
.c-fl b { font-family: var(--font-head); color: #fff; font-variant-numeric: tabular-nums; }
.c-ft { display: flex; justify-content: center; height: 24px; border-radius: 8px; background: var(--s-track); overflow: hidden; }
.c-ft i { display: block; width: 0; height: 100%; border-radius: 8px; background: linear-gradient(90deg, #14b8a6, #2dd4bf 50%, #5eead4); box-shadow: 0 0 18px -6px rgba(45, 212, 191, .8); filter: hue-rotate(calc(var(--k, 0) * 26deg)); transition: width .7s var(--e-out); }
.c-fs small { display: block; margin-top: 4px; text-align: center; font-size: .7rem; color: var(--s-muted); font-variant-numeric: tabular-nums; }
.c-fs small:empty { display: none; }
.c-bt { height: 20px; border-radius: 7px; background: var(--s-track); overflow: hidden; }
.c-bt i { display: block; width: 0; height: 100%; border-radius: 7px; background: linear-gradient(90deg, #14b8a6, #5eead4); transition: width .7s var(--e-out), background .3s ease; }
.c-bt i.b { background: linear-gradient(90deg, #5b7fd6, var(--s-blue)); }
.c-bt i.neg { background: linear-gradient(90deg, #ef4444, var(--s-red)); }

/* Anillo con leyenda */
.c-donut { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; }
@container (max-width: 400px) { .c-donut { grid-template-columns: 1fr; justify-items: center; } .c-donut .c-leg { width: 100%; } }
.c-dw { position: relative; width: 150px; aspect-ratio: 1; }
.c-dw svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.c-dtrk { fill: none; stroke: var(--s-track); stroke-width: 14; }
.c-seg { fill: none; stroke-width: 14; stroke-dasharray: 0 100; transition: stroke-dasharray .8s var(--e-out), stroke-dashoffset .8s var(--e-out); }
.c-dc { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.c-dc b { font-family: var(--font-head); font-size: 1.6rem; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.c-dc span { margin-top: 4px; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--s-muted); }
.c-leg { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; font-size: .82rem; }
.c-leg li { display: grid; grid-template-columns: 10px 1fr auto; gap: 2px 8px; align-items: baseline; }
.c-leg i { width: 10px; height: 10px; border-radius: 3px; align-self: center; }
.c-leg span { color: #cfd9e6; }
.c-leg b { font-family: var(--font-head); color: #fff; font-variant-numeric: tabular-nums; }
.c-leg small { grid-column: 2 / -1; font-size: .72rem; color: var(--s-muted); }
.c-leg small:empty { display: none; }

/* Línea de tiempo por partes */
.c-tl { display: grid; gap: 14px; }
.c-tlbar { display: flex; gap: 3px; height: 42px; padding: 4px; border-radius: 12px; background: var(--s-track); }
.c-tseg { flex: 0 1 0; min-width: 0; display: grid; place-items: center; overflow: hidden; container-type: inline-size; border-radius: 8px; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); transition: flex-grow .7s var(--e-out); }
.c-tseg em { max-width: 100%; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; font-style: normal; font-size: .72rem; font-weight: 600; color: #04223a; white-space: nowrap; }
@container (max-width: 64px) { .c-tseg em { display: none; } }

/* ---------- Matriz impacto vs. esfuerzo ---------- */
.mx { position: relative; aspect-ratio: 1 / .8; margin: 6px 0 20px 20px; border-left: 1px solid rgba(255, 255, 255, .22); border-bottom: 1px solid rgba(255, 255, 255, .22);
  background: linear-gradient(rgba(52, 211, 153, .09), rgba(52, 211, 153, .09)) 0 0 / 50% 50% no-repeat, linear-gradient(rgba(248, 113, 113, .07), rgba(248, 113, 113, .07)) 100% 100% / 50% 50% no-repeat; }
.mx::before, .mx::after { content: ""; position: absolute; background: rgba(255, 255, 255, .1); }
.mx::before { left: 50%; top: 0; bottom: 0; width: 1px; }
.mx::after { top: 50%; left: 0; right: 0; height: 1px; }
.mx-q { position: absolute; font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--s-muted); pointer-events: none; }
.mx-q.q1 { left: 8px; top: 7px; color: var(--s-green); } .mx-q.q2 { right: 8px; top: 7px; }
.mx-q.q3 { left: 8px; bottom: 7px; } .mx-q.q4 { right: 8px; bottom: 7px; color: var(--s-red); }
.mx-ax { position: absolute; font-size: .68rem; color: var(--s-muted); white-space: nowrap; }
.mx-ax.y { left: -11px; top: 50%; transform: translate(-50%, -50%) rotate(-90deg); }
.mx-ax.x { right: 0; top: calc(100% + 4px); }
.mx-dot { position: absolute; z-index: 1; width: 28px; height: 28px; margin: 0; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); background: #1d3b5c; color: #dce6f2; font: 600 .76rem/1 var(--font-head); transform: translate(-50%, 50%); cursor: pointer; transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .3s ease; }
.mx-dot.quick { border-color: rgba(52, 211, 153, .65); }
.mx-dot.on { z-index: 2; background: var(--s-teal); border-color: #fff; color: #04223a; box-shadow: 0 0 0 4px rgba(45, 212, 191, .25), 0 6px 16px -6px rgba(45, 212, 191, .9); }
.mx-meter { height: 8px; border-radius: 99px; background: var(--s-track); overflow: hidden; }
.mx-meter i { display: block; width: 0; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #14b8a6, #5eead4); transition: width .5s var(--e-out), background .3s ease; }
.mx-meter i.over { background: linear-gradient(90deg, #ef4444, #f87171); }
.mx-list { display: grid; gap: 6px; }
.mx-item { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--s-rim); background: rgba(8, 19, 31, .45); color: #dce6f2; font: inherit; font-size: .84rem; text-align: left; cursor: pointer; transition: background .25s ease, border-color .25s ease, transform .2s var(--e-out); }
.mx-item:active { transform: scale(.985); }
.mx-n { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #1d3b5c; font: 600 .74rem/1 var(--font-head); transition: background .25s ease, color .25s ease; }
.mx-item small { color: var(--s-muted); font-variant-numeric: tabular-nums; }
.mx-item.on { border-color: rgba(45, 212, 191, .6); background: rgba(45, 212, 191, .1); }
.mx-item.on .mx-n { background: var(--s-teal); color: #04223a; }

/* ---------- Encuentra los riesgos ---------- */
.sp-code { display: grid; padding: 8px 0; border-radius: 12px; border: 1px solid var(--s-rim); background: #07111c; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
.sp-line { display: grid; grid-template-columns: 26px 1fr; gap: 8px; align-items: start; width: 100%; padding: 3px 10px 3px 0; border: 0; border-left: 3px solid transparent; background: transparent; color: #cfe0f2; font: inherit; text-align: left; cursor: pointer; transition: background .2s ease, border-color .2s ease, opacity .2s ease; }
.sp-line .ln { text-align: right; font-size: .7rem; line-height: 1.6; color: #4f6680; }
.sp-line code { font: inherit; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.sp-line:hover { background: rgba(255, 255, 255, .04); }
.sp-line.blank { cursor: default; }
.sp-line.flag { background: rgba(242, 165, 22, .12); border-left-color: var(--s-gold); }
.sp-line.found { background: rgba(52, 211, 153, .12); border-left-color: var(--s-green); }
.sp-line.missed { background: rgba(248, 113, 113, .13); border-left-color: var(--s-red); }
.sp-line.wrong { border-left-color: #64748b; opacity: .6; }
.sp-phone { padding: 12px; border-radius: 22px; border: 1px solid var(--s-rim); background: linear-gradient(180deg, #0e2138, #0a1828); }
.sp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--s-rim); }
.sp-av { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #1d3b5c; color: #9fb3c8; }
.sp-av svg { width: 18px; height: 18px; }
.sp-head small { margin-left: auto; font-size: .7rem; color: var(--s-muted); white-space: nowrap; }
.sp-bubble { max-width: 94%; padding: 10px 12px; border-radius: 16px 16px 16px 4px; background: #1b3350; font-size: .9rem; line-height: 1.75; }
.sp-seg { margin: 0; padding: 1px 4px; border: 0; border-radius: 5px; background: transparent; color: #eef4fa; font: inherit; text-align: left; cursor: pointer; transition: background .2s ease, box-shadow .2s ease, opacity .2s ease; }
.sp-seg:hover { background: rgba(255, 255, 255, .07); }
.sp-from { font-weight: 600; }
.sp-seg.flag { background: rgba(242, 165, 22, .22); box-shadow: inset 0 -2px 0 var(--s-gold); }
.sp-seg.found { background: rgba(52, 211, 153, .2); box-shadow: inset 0 -2px 0 var(--s-green); }
.sp-seg.missed { background: rgba(248, 113, 113, .22); box-shadow: inset 0 -2px 0 var(--s-red); }
.sp-seg.wrong { opacity: .55; text-decoration: line-through; }
.sp-notes ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.sp-notes li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.sp-ic { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(248, 113, 113, .18); color: var(--s-red); font: 700 .8rem/1 var(--font-head); }
.sp-notes li.found .sp-ic { background: rgba(52, 211, 153, .18); color: var(--s-green); }
.sp-notes b { font-size: .88rem; color: #fff; }
.sp-notes p { margin: 2px 0 0; font-size: .8rem; line-height: 1.45; color: #b9c7d8; }

/* ---------- Constructor de prompts ---------- */
.pb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 99px; border: 1px solid var(--s-rim); background: rgba(8, 19, 31, .5); color: #cfd9e6; font: 600 .8rem/1.1 var(--font-head); cursor: pointer; transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .3s ease; }
.pb-chip i { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--pc); transition: background .25s ease, transform .3s var(--e-spring); }
.pb-chip.on { border-color: color-mix(in srgb, var(--pc) 70%, transparent); background: color-mix(in srgb, var(--pc) 16%, transparent); color: #fff; box-shadow: 0 0 16px -6px var(--pc); }
.pb-chip.on i { background: var(--pc); transform: scale(1.15); }
.pb-chip:disabled { cursor: default; }
.pb-out { padding: 8px 12px; border-radius: 14px; border: 1px solid var(--s-rim); background: #07111c; font-size: .88rem; line-height: 1.5; }
.pb-seg { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .45s var(--e-out), opacity .35s ease; }
.pb-seg > div { min-height: 0; overflow: hidden; }
.pb-seg p { margin: 4px 0; padding: 5px 8px 5px 12px; border-left: 3px solid var(--pc); border-radius: 0 8px 8px 0; color: #e6eef7; }
.pb-seg p span { display: block; margin-bottom: 2px; font: 600 .64rem/1.2 var(--font-head); letter-spacing: .1em; text-transform: uppercase; color: var(--pc); }
.pb-seg.off { grid-template-rows: 0fr; opacity: 0; }
.pb-seg.new p { animation: pb-new 1.2s ease; }
@keyframes pb-new { 0% { background: color-mix(in srgb, var(--pc) 30%, transparent); } 100% { background: transparent; } }
.pb-score { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; }
.pb-ring { position: relative; width: 120px; height: 120px; --rc: #f87171; }
.pb-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.pb-ring .trk { fill: none; stroke: var(--s-track); stroke-width: 10; }
.pb-ring .val { fill: none; stroke: var(--rc); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 0 100; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--rc) 60%, transparent)); transition: stroke-dasharray .8s var(--e-out), stroke .4s ease; }
.pb-num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.pb-num b { font: 600 2rem/1 var(--font-head); color: #fff; font-variant-numeric: tabular-nums; }
.pb-num small { margin-top: 3px; font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--s-muted); }
.pb-mini { display: grid; gap: 8px; }
.pb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pb-list li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.pb-ic { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(242, 165, 22, .16); color: var(--s-gold); font: 700 .78rem/1 var(--font-head); transition: background .3s ease, color .3s ease; }
.pb-list li.on .pb-ic { background: color-mix(in srgb, var(--pc) 22%, transparent); color: var(--pc); }
.pb-list b { font-size: .84rem; color: #fff; }
.pb-list p { margin: 1px 0 0; font-size: .78rem; line-height: 1.4; color: #b9c7d8; }

/* ---------- Entrena un modelo ---------- */
.en-plot, .en-loss { display: block; width: 100%; height: auto; overflow: visible; }
.en-grid line { stroke: rgba(255, 255, 255, .06); }
.en-ax { fill: none; stroke: rgba(255, 255, 255, .22); }
.en-res line { stroke: var(--s-red); stroke-width: 1.4; stroke-dasharray: 2 2; opacity: .75; }
.en-fit { stroke: var(--s-teal); stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(45, 212, 191, .7)); }
.en-pts circle { fill: var(--s-blue); stroke: #0b1a2c; stroke-width: 1.5; transform-box: fill-box; transform-origin: center; }
.en-min { stroke: var(--s-green); stroke-dasharray: 4 4; opacity: .7; }
.en-mint { fill: var(--s-green); font-size: 9px; opacity: .9; }
.en-yt { fill: var(--s-muted); font-size: 8px; }
.en-curve { fill: none; stroke: var(--s-gold); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.en-head { fill: var(--s-gold); stroke: #0b1a2c; stroke-width: 2; transition: fill .3s ease; }
.en-head.bad { fill: var(--s-red); }

/* ---------- Así trabaja un agente ---------- */
.ag-svg { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; overflow: visible; }
.ag-edge { stroke: rgba(255, 255, 255, .14); stroke-width: 2; transition: stroke .3s ease; }
.ag-edge.on { stroke: var(--s-teal); stroke-dasharray: 5 5; animation: ag-flow .7s linear infinite; }
@keyframes ag-flow { to { stroke-dashoffset: -10; } }
.ag-in { transform-box: fill-box; transform-origin: center; }
.ag-node rect { fill: #122a45; stroke: rgba(255, 255, 255, .14); stroke-width: 1.2; transition: fill .3s ease, stroke .3s ease; }
.ag-node.core rect { fill: #173a5e; stroke: rgba(45, 212, 191, .45); }
.ag-node text { text-anchor: middle; }
.ag-node .t { fill: #fff; font-family: var(--font-head); font-weight: 600; font-size: 11.5px; }
.ag-node .s { fill: var(--s-muted); font-size: 8.5px; }
.ag-node.act rect { fill: #16406a; stroke: var(--s-teal); }
.ag-node.act .ag-in { filter: drop-shadow(0 0 8px rgba(45, 212, 191, .55)); animation: ag-pop .5s var(--e-spring); }
@keyframes ag-pop { 40% { transform: scale(1.07); } }
.ag-pulse { fill: #5eead4; opacity: 0; filter: drop-shadow(0 0 6px #2dd4bf); transition: opacity .2s ease; }
.ag-pulse.on { opacity: 1; }
.ag-cap { min-height: 66px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--s-rim); background: rgba(8, 19, 31, .55); }
.ag-cap b { display: block; font-family: var(--font-head); font-size: .92rem; color: #fff; }
.ag-cap p { margin: 3px 0 0; font-size: .82rem; line-height: 1.45; color: #b9c7d8; }
.ag-ask { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.ag-sw { position: relative; display: flex; align-items: center; gap: 10px; font-size: .85rem; color: #dce6f2; cursor: pointer; }
.ag-sw input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ag-tr { position: relative; flex: none; width: 42px; height: 24px; border-radius: 99px; background: rgba(255, 255, 255, .14); transition: background .25s ease; }
.ag-tr i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: transform .3s var(--e-spring); }
.ag-sw input:checked + .ag-tr { background: var(--s-teal); }
.ag-sw input:checked + .ag-tr i { transform: translateX(18px); }
.ag-sw input:focus-visible + .ag-tr { box-shadow: 0 0 0 3px rgba(94, 234, 212, .4); }
.ag-sw input:disabled + .ag-tr { opacity: .5; }
.ag-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ag-empty { font-size: .8rem; color: var(--s-muted); }
.ag-li { position: relative; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.ag-li:not(:last-child)::before { content: ""; position: absolute; left: 12.5px; top: 30px; bottom: -10px; width: 1px; background: var(--s-rim); }
.ag-n { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #1d3b5c; color: #dce6f2; font: 600 .76rem/1 var(--font-head); transition: background .3s ease, color .3s ease; }
.ag-li.cur .ag-n { background: var(--s-blue); color: #04223a; box-shadow: 0 0 0 4px rgba(122, 162, 247, .2); }
.ag-li.done .ag-n { background: var(--s-teal); color: #04223a; }
.ag-li.stop .ag-n { background: var(--s-red); color: #2a0b0b; }
.ag-body b { font-size: .86rem; color: #fff; }
.ag-body p { margin: 2px 0 0; font-size: .78rem; line-height: 1.45; color: #b9c7d8; }
.ag-res { display: inline-block; margin-top: 4px; font-style: normal; font-size: .74rem; font-weight: 600; color: var(--s-green); }
.ag-li.stop .ag-res { color: var(--s-red); }

/* ---------- Hoja de cálculo ---------- */
.hj-fx { display: grid; grid-template-columns: auto auto 1fr; align-items: center; border-radius: 10px; border: 1px solid var(--s-rim); background: #07111c; overflow: hidden; font-size: .85rem; }
.hj-ref { padding: 9px 10px; border-right: 1px solid var(--s-rim); font: 600 .78rem/1 var(--font-head); color: #9fb3c8; }
.hj-fxi { padding: 9px 10px; border-right: 1px solid var(--s-rim); font-family: Georgia, serif; font-style: italic; color: var(--s-teal); }
.hj-fx code { min-width: 0; padding: 9px 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hj-fx code::after { content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 1px; vertical-align: -2px; background: var(--s-teal); animation: s-blink .9s steps(1) infinite; }
.hj-sheet { position: relative; display: grid; grid-template-columns: 30px 1fr 1fr; border-radius: 10px; border: 1px solid var(--s-rim); background: #0b1a2c; overflow: hidden; font-size: .86rem; }
.hj-sheet > * { border-right: 1px solid rgba(255, 255, 255, .06); border-bottom: 1px solid rgba(255, 255, 255, .06); }
.hj-corner, .hj-ch, .hj-rh { display: grid; place-items: center; padding: 6px 0; background: #10233a; color: var(--s-muted); font: 600 .7rem/1 var(--font-head); }
.hj-c { min-width: 0; padding: 9px 10px; color: #dce6f2; transition: background .25s ease, color .25s ease; }
button.hj-c { -webkit-appearance: none; appearance: none; border-width: 0 1px 1px 0; border-style: solid; border-color: rgba(255, 255, 255, .06); border-radius: 0; background: transparent; font: inherit; cursor: pointer; }
button.hj-c:hover { background: rgba(255, 255, 255, .05); }
.hj-c.hd { background: rgba(255, 255, 255, .03); color: #fff; font-weight: 600; }
.hj-c.num { text-align: right; font-variant-numeric: tabular-nums; }
.hj-c.in { background: rgba(45, 212, 191, .1); color: #fff; }
.hj-c.hit { background: rgba(242, 165, 22, .2); color: #ffd58a; font-weight: 600; }
.hj-c.lbl { color: var(--s-muted); font-size: .78rem; }
.hj-c.res { background: rgba(45, 212, 191, .08); }
.hj-c.res b { font-family: var(--font-head); color: var(--s-teal); }
.hj-sheet > .hj-sel { position: absolute; z-index: 1; border: 0; border-radius: 2px; pointer-events: none; --ant: var(--s-teal);
  background: linear-gradient(90deg, var(--ant) 50%, transparent 0) 0 0 / 10px 2px repeat-x, linear-gradient(90deg, var(--ant) 50%, transparent 0) 0 100% / 10px 2px repeat-x,
    linear-gradient(0deg, var(--ant) 50%, transparent 0) 0 0 / 2px 10px repeat-y, linear-gradient(0deg, var(--ant) 50%, transparent 0) 100% 0 / 2px 10px repeat-y;
  box-shadow: 0 0 18px -6px rgba(45, 212, 191, .7);
  animation: hj-ants .6s linear infinite; transition: top .35s var(--e-out), height .35s var(--e-out), left .35s var(--e-out), width .35s var(--e-out); }
.hj-sheet > .hj-sel.picking { --ant: var(--s-gold); box-shadow: 0 0 18px -6px rgba(242, 165, 22, .8); }
@keyframes hj-ants { to { background-position: 10px 0, -10px 100%, 0 -10px, 100% 10px; } }
.hj-fns { display: flex; flex-wrap: wrap; gap: 6px; }
.hj-fn { padding: 8px 11px; border-radius: 9px; border: 1px solid var(--s-rim); background: rgba(8, 19, 31, .5); color: #cfd9e6; font: 600 .78rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .3s ease; }
.hj-fn.on { border-color: var(--s-teal); background: var(--s-teal); color: #04223a; box-shadow: 0 6px 16px -8px #2dd4bf; }
.hj-desc { margin: 0; font-size: .84rem; line-height: 1.45; color: #dce6f2; }
.hj-how { margin: 0; padding: 10px 12px; border-radius: 10px; background: rgba(8, 19, 31, .55); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; line-height: 1.5; color: #e6eef7; overflow-wrap: anywhere; }

/* ---------- Fuerza de una contraseña ---------- */
.ck-in input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--s-rim); background: #07111c; color: #fff; font: 500 1.05rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; outline: none; transition: border-color .2s ease, box-shadow .2s ease; }
.ck-in input:focus { border-color: var(--s-teal); box-shadow: 0 0 0 3px rgba(45, 212, 191, .2); }
.ck-in input::placeholder { color: #5b7088; font-family: var(--font-body); font-size: .9rem; }
.ck-meter { height: 10px; border-radius: 99px; background: var(--s-track); overflow: hidden; }
.ck-meter i { display: block; width: 0; height: 100%; border-radius: 99px; background: var(--mc, var(--s-red)); box-shadow: 0 0 14px -4px var(--mc, var(--s-red)); transition: width .45s var(--e-out), background .35s ease; }
.ck-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ck-tags:empty { display: none; }
.ck-tag { padding: 4px 8px; border-radius: 7px; border: 1px solid rgba(248, 113, 113, .3); background: rgba(248, 113, 113, .14); color: #fecaca; font-size: .74rem; }
.ck-tag b { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; color: #fff; }
.ck-ex { display: flex; flex-wrap: wrap; gap: 6px; }
.ck-chip { padding: 8px 10px; border-radius: 9px; border: 1px solid var(--s-rim); background: rgba(8, 19, 31, .5); color: #cfd9e6; font: .8rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; cursor: pointer; transition: border-color .2s ease, background .2s ease; }
.ck-chip:hover { border-color: var(--s-teal); background: rgba(45, 212, 191, .08); }
.ck-time { grid-column: 1 / -1; }
.ck-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.ck-list li { display: flex; align-items: center; gap: 10px; font-size: .84rem; color: #9fb3c8; transition: color .25s ease; }
.ck-ic { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .2); color: #04223a; transition: background .25s ease, border-color .25s ease; }
.ck-list li.ok { color: #eef4fa; }
.ck-list li.ok .ck-ic { border-color: var(--s-green); background: var(--s-green); }

/* Sin animaciones si el sistema lo pide */
@media (prefers-reduced-motion: reduce) {
  .r-thumb *, .sim-overlay, .sim-overlay *, .r-simcard .btn::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}

/* Imagen principal de la lección (arriba de la primera sección) */
.r-fig { margin: 0 0 18px; border-radius: 18px; overflow: hidden; aspect-ratio: 3 / 2; background: var(--paper-2); border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; transform: translateY(10px) scale(.985); transition: opacity .6s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.r-fig.on { opacity: 1; transform: none; }
.r-fig img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (prefers-reduced-motion: reduce) { .r-fig { transition: none; transform: none; } }
@media (min-width: 760px) { .r-fig { aspect-ratio: 2 / 1; } } /* en computador, que el texto no quede muy abajo */

/* ---------- Header global (v6): el lector y las simulaciones quedan debajo del header ---------- */
.r-bar { top: var(--hdr-h, 57px); padding-top: 10px; }
.sim-overlay { top: var(--hdr-h, 57px); }
