/* Learn — mobile-first, tema oscuro por defecto. Desktop = la misma columna centrada. */
:root {
  --bg: #0f1115; --panel: #171b25; --panel2: #1e2331; --line: #2a3043; --text: #eceef3; --muted: #8f97aa;
  --accent: #7c9cff; --accent2: #a3b8ff; --ok: #3fb97c; --okbg: #12301f; --bad: #e5646a; --badbg: #34171a;
  --warn: #f5a524; --warnbg: #33270f; --stage: #11151f;
  --r: 16px; --col: 640px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f5f1; --panel: #ffffff; --panel2: #efeee9; --line: #e0ded7; --text: #1b1e27; --muted: #6c7180;
  --accent: #3d5ef0; --accent2: #2a47c9; --okbg: #e3f5ea; --badbg: #fbe6e7; --warnbg: #fdf0d9; --stage: #1a1f2c;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 -apple-system, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); background: var(--panel2); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; width: 100%; resize: none; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
h1 { font-size: 26px; line-height: 1.2; margin: 12px 0 6px; }
h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }

.btn { border-radius: 14px; padding: 10px 16px; font-weight: 650; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.btn.ghost { border: 1.5px solid var(--line); color: var(--muted); }
.btn.big { padding: 14px 18px; font-size: 17px; }
.btn.wide { width: 100%; } .grow { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; color: var(--muted); display: grid; place-items: center; flex: none; }
.icon-btn:active { background: var(--panel2); }
.pill { font-size: 14px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--panel2); white-space: nowrap; }
.pill.xp { color: var(--warn); }

.screen { min-height: 100%; }
#lesson.screen, #review.screen { position: fixed; inset: 0; height: 100dvh; display: flex; flex-direction: column; }

/* ---------- auth ---------- */
#auth { display: grid; place-items: center; padding: 24px 20px; }
.auth-wrap { width: min(400px, 100%); text-align: center; }
.auth-wrap .muted { margin: 0 0 22px; }
.seg { display: flex; background: var(--panel2); border-radius: 14px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px #0004; }
#authForm { display: grid; gap: 10px; }
#auth:not(.signup) .signup-only { display: none; }
.err { color: var(--bad); min-height: 1.3em; font-size: 14px; margin: 0; }

/* ---------- home ---------- */
.home-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; }
.stats { display: flex; align-items: center; gap: 6px; }
.menu { position: fixed; top: 58px; right: 12px; z-index: 30; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 6px; min-width: 220px; box-shadow: 0 10px 30px #0008; }
.menu button { text-align: left; padding: 8px; border-radius: 8px; } .menu button:active { background: var(--panel2); }
.home-body { max-width: var(--col); margin: 0 auto; padding: 6px 16px calc(40px + var(--safe-b)); }




/* ---------- bars ---------- */
.bar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 10px 8px; border-bottom: 1px solid var(--line); background: var(--bg); flex: none; }
.bar-title { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-wrap { flex: 1; min-width: 0; }
.progress { height: 10px; background: var(--panel2); border-radius: 999px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), #8fe0b5); border-radius: 999px; transition: width .5s; }
.progress.calib div { width: 30% !important; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: shimmer 1.6s infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.phase { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-pill { color: var(--accent2); }

.tutor-row { display: flex; align-items: flex-end; gap: 10px; }
.bubble { border-radius: 18px; padding: 10px 14px; max-width: 86%; }
.bubble.tutor { background: var(--panel); border: 1.5px solid var(--line); border-bottom-left-radius: 6px; }

/* ---------- lesson stream ---------- */
#stream { flex: 1; overflow-y: auto; padding: 16px 12px 24px; scroll-behavior: smooth; }
#items { max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
#typing { max-width: var(--col); margin: 10px auto 0; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row.tutor .mascot-slot { visibility: hidden; }
.row.tutor.last .mascot-slot { visibility: visible; }
.row.me { justify-content: flex-end; }
.bubble.me { background: var(--accent); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.bubble.me.ok { background: var(--ok); } .bubble.me.bad { background: var(--bad); } .bubble.me.dk { background: var(--panel2); color: var(--text); }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .5em 0; }
.md code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.md pre { background: var(--bg); padding: 10px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 14px; } .md td, .md th { border: 1px solid var(--line); padding: 4px 8px; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; margin: .4em 0; }
.md ul, .md ol { padding-left: 1.2em; margin: .4em 0; }
.md h1, .md h2, .md h3 { font-size: 17px; text-transform: none; letter-spacing: 0; color: var(--text); margin: .6em 0 .3em; }
.bubble.tutor.streaming::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dots { display: flex; gap: 5px; padding: 14px 16px; }
.dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bob 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .15s; } .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }
.sys { align-self: center; font-size: 13px; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }
.sys.err { color: var(--bad); border-color: var(--bad); }

/* the stage: big visual, protagonist of the step */
.stage { margin: 6px 0 4px; background: var(--stage); border: 2px solid color-mix(in srgb, var(--ok) 55%, var(--line)); border-radius: 20px; padding: 14px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 10%, transparent); color: #e7e9ee; }
.stage .canvas { display: grid; place-items: center; min-height: 160px; }
.stage .canvas svg { width: 100%; height: auto; max-height: 56vh; }
.stage .canvas .katex { font-size: 1.9em; color: #fff; }
.stage .cap { text-align: center; font-size: 13px; color: #9aa3b8; margin-top: 8px; }
.stage [data-hot] { cursor: pointer; }
.stage svg [data-hot] { animation: hotpulse 2.2s ease-in-out infinite; }
.stage svg [data-hot].seen { animation: none; }
@keyframes hotpulse { 50% { opacity: .55; } }
.stage .hot-hint { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.stage .hot-hint button { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: #1f2636; color: #cfd6ea; border: 1.5px dashed #4d5876; }
.stage .hot-hint button.seen { border-style: solid; border-color: var(--ok); color: #bfeccf; }
.stage .hot-hint button:active { transform: scale(.96); }
.stage .mermaid-out svg { max-width: 100%; }

/* quiz inside the lesson chat */
.qopts { display: grid; gap: 8px; margin: 2px 0 2px 38px; }
.qopts.tiles2 { grid-template-columns: 1fr 1fr; }
.qopt { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 12px; box-shadow: 0 3px 0 var(--line); font-size: 15px; min-height: 52px; }
.tiles2 .qopt { flex-direction: column; justify-content: center; text-align: center; min-height: 92px; gap: 6px; }
.qopt .v { font-size: 22px; } .qopt .v .katex { font-size: 1em; }
.qopt .d { display: block; font-size: 12px; color: var(--muted); }
.qopt:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--line); }
.qopt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--panel)); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.qopt.right { border-color: var(--ok); background: var(--okbg); box-shadow: none; }
.qopt.wrong { border-color: var(--bad); background: var(--badbg); box-shadow: none; }
.qopt:disabled { cursor: default; transform: none; }
.qopt:disabled:not(.right):not(.wrong):not(.sel) { opacity: .55; box-shadow: none; }
.qtag { font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--accent2); text-transform: uppercase; display: block; margin-bottom: 2px; }
.freeask { margin-left: 38px; display: flex; gap: 8px; }
.freeask .btn { flex: none; }

/* ---------- bottom dock ---------- */
.dock { flex: none; border-top: 1px solid var(--line); background: var(--bg); padding: 10px 12px calc(10px + var(--safe-b)); }
.dock > * { max-width: var(--col); margin-left: auto; margin-right: auto; }
#quizBar { display: flex; gap: 8px; align-items: center; }
#qNoteBox { margin-bottom: 8px; font-size: 15px; }
#feedback { border-radius: 16px; padding: 12px; margin: -2px auto 0; animation: slideup .22s ease-out; }
#feedback.ok { background: var(--okbg); } #feedback.bad { background: var(--badbg); } #feedback.dk { background: var(--warnbg); }
.fb-row { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 18px; margin: 2px 4px 10px; }
#feedback.ok .fb-row { color: var(--ok); } #feedback.bad .fb-row { color: var(--bad); } #feedback.dk .fb-row { color: var(--warn); }
#feedback.ok #fbGo { background: var(--ok); color: #fff; } #feedback.bad #fbGo { background: var(--bad); color: #fff; } #feedback.dk #fbGo { background: var(--warn); color: #1b1e27; }
@keyframes slideup { from { transform: translateY(30px); opacity: 0; } }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 8px; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); color: var(--muted); }
.chips button:first-child { color: var(--accent2); border-color: var(--accent); }
#msgForm { display: flex; gap: 8px; align-items: flex-end; }
#msg { max-height: 140px; border-radius: 22px; padding: 10px 16px; }
.send { width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 20px; flex: none; }

/* ---------- map sheet ---------- */
#sheetBg { position: fixed; inset: 0; background: #0009; z-index: 40; }
#mapSheet, .sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 80dvh; background: var(--panel); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line); transform: translateY(105%); transition: transform .25s ease; display: flex; flex-direction: column; padding-bottom: var(--safe-b); max-width: var(--col); margin: 0 auto; }
#mapSheet.open, .sheet.open { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 12px 6px 18px; }
#mapBody { overflow-y: auto; padding: 4px 16px 20px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.steps li { display: flex; gap: 12px; align-items: flex-start; position: relative; padding-bottom: 14px; }
.steps li::before { content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line); }
.steps li:last-child::before { display: none; }
.steps .dot { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 14px; font-weight: 800; background: var(--panel2); color: var(--muted); border: 2px solid var(--line); }
.steps li.done .dot { background: var(--ok); color: #fff; border-color: var(--ok); }
.steps li.cur .dot { background: var(--accent); color: #fff; border-color: var(--accent2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.steps .lb { padding-top: 5px; } .steps .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.steps li.cur .lb b { color: var(--accent2); }
details.graph { margin-top: 10px; } details.graph summary { color: var(--muted); font-size: 13px; cursor: pointer; }
details.graph .mermaid-out { background: var(--bg); border-radius: 12px; padding: 8px; margin-top: 8px; overflow-x: auto; }

#toast { position: fixed; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%); z-index: 50; background: var(--panel); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px #0008; max-width: 90vw; }

@media (min-width: 760px) {
  #stream { padding: 24px 16px 32px; }
}

/* ---------- Nodo (mascota) ---------- */
.mascot-slot { flex: none; width: 34px; height: 34px; }
.mascot-slot.xs { width: 30px; height: 30px; } .mascot-slot.sm { width: 32px; height: 32px; }
.mascot-slot.mid { width: 56px; height: 56px; } .mascot-slot.big { width: 96px; height: 96px; margin: 0 auto; }
.mascot-slot.fb { width: 38px; height: 38px; }
.mascot { width: 100%; height: 100%; overflow: visible; display: block; }
.mascot * { transform-box: fill-box; transform-origin: center; }
.mascot .eye-happy, .mascot .mouth-happy, .mascot .mouth-oops { display: none; }
.m-happy .eye-open, .m-happy .mouth-idle { display: none; }
.m-happy .eye-happy, .m-happy .mouth-happy { display: inline; }
.m-oops .mouth-idle { display: none; } .m-oops .mouth-oops { display: inline; }
.m-think .pupils { transform: translate(1.6px, -2.6px); }
.mascot .pupils { transition: transform .3s; }
/* motion (only where it matters, so a long chat isn't a zoo) */
.row.tutor.last .mascot .eyes, .m-think .mascot .body { animation: bob 1.4s ease-in-out infinite; }
.m-think .mascot .ant-node { animation: glow 1s ease-in-out infinite; }
.m-happy .mascot { animation: hop .6s cubic-bezier(.3,1.6,.5,1) 2; }
.m-oops .mascot { animation: tilt .5s ease-in-out; }
.m-wave .mascot .antenna { animation: wiggle 1.6s ease-in-out infinite; transform-origin: bottom left; }
.m-wave .mascot .ant-node, @keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes hop { 40% { transform: translateY(-9px) scale(1.04, .96); } }
@keyframes tilt { 30% { transform: rotate(-8deg); } 70% { transform: rotate(5deg); } }
@keyframes wiggle { 50% { transform: rotate(-10deg); } }
@keyframes glow { 50% { filter: drop-shadow(0 0 4px #ffd36b) brightness(1.25); } }

/* ---------- home extras ---------- */
.link-btn { align-self: flex-start; font-size: 13px; color: var(--muted); padding: 8px 2px 0; }
.pill.hot { animation: flame 2.4s ease-in-out infinite; }
@keyframes flame { 50% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 30%, transparent); } }

/* ---------- delight fx ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
#fx i { position: absolute; width: 8px; height: 12px; border-radius: 2px; animation: burst 1s cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes burst { to { transform: translate(var(--dx), calc(var(--dy) + 140px)) rotate(var(--r)); opacity: 0; } }
.xp-float { position: absolute; transform: translateX(-50%); color: var(--warn); font-weight: 900; font-size: 18px; animation: xpf .65s ease-out forwards; }
@keyframes xpf { from { opacity: 0; transform: translate(-50%, 20px) scale(.7); } 40% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -18px) scale(1.2); } }
.pill.pop { animation: pop .4s cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { 50% { transform: scale(1.25); } }
.qopt.shake { animation: shake .42s ease-in-out; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.qopt.right { animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
.progress.shine div { background: linear-gradient(90deg, var(--ok), #fff, #8fe0b5); background-size: 200% 100%; animation: shinebar 1.2s linear; }
@keyframes shinebar { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.reveal .bubble, .stage, .row .bubble { animation: popin .28s ease-out; }
@keyframes popin { from { opacity: 0; transform: translateY(8px) scale(.98); } }
#feedback .fb-row { justify-content: flex-start; gap: 10px; }
#feedback #fbXp { margin-left: auto; }
#celebrate { position: fixed; inset: 0; z-index: 55; background: #0b0d12cc; display: grid; place-items: center; padding: 20px; backdrop-filter: blur(4px); }
.cele-card { width: min(360px, 100%); background: var(--panel); border: 1.5px solid var(--line); border-radius: 24px; padding: 26px 20px 20px; text-align: center; animation: popin .35s ease-out; }
.cele-card h2 { font-size: 22px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 12px 0 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- verification badge ---------- */
.verify { margin: 0 0 2px 40px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel); font-size: 13.5px; overflow: hidden; animation: popin .28s ease-out; }
.ver-head { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; }
.ver-ico { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 900; }
.ver-lbl { flex: none; font-weight: 800; }
.ver-claim { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verify.open .ver-claim { white-space: normal; }
.ver-more { color: var(--muted); transition: transform .2s; } .verify.open .ver-more { transform: rotate(180deg); }
.ver-body { padding: 0 12px 6px 40px; } .ver-body p { margin: 4px 0 8px; }
.ver-body blockquote { margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--line); background: var(--panel2); border-radius: 0 8px 8px 0; font-style: italic; }
.ver-body cite { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 3px; }
.ver-src { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 9px 40px; }
.ver-src a, .ver-body a { color: var(--accent2); text-decoration: none; font-size: 12px; font-weight: 600; }
.ver-src a { border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.ver-ok { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); } .ver-ok .ver-ico { background: var(--ok); color: #fff; } .ver-ok .ver-lbl { color: var(--ok); }
.ver-fix { border-color: color-mix(in srgb, var(--warn) 55%, var(--line)); } .ver-fix .ver-ico { background: var(--warn); color: #1b1e27; } .ver-fix .ver-lbl { color: var(--warn); }
.ver-unk .ver-ico { background: var(--panel2); color: var(--muted); } .ver-unk .ver-lbl { color: var(--muted); }
.ver-pend .ver-ico { animation: spinpulse 1s ease-in-out infinite; background: var(--panel2); }
.ver-pend .ver-lbl { color: var(--accent2); }
.ver-corr { color: var(--text); }
.verify.pop .ver-ico { animation: pop .45s cubic-bezier(.3,1.8,.5,1); }
@keyframes spinpulse { 50% { transform: scale(1.2) rotate(12deg); } }

/* ---------- invites sheet ---------- */
.sheet-body { overflow-y: auto; padding: 4px 16px 22px; }
.inv-hero { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; } .inv-hero p { margin: 0; }
.inv-list { display: grid; gap: 8px; margin-top: 16px; }
.inv-row { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 12px; padding: 8px 8px 8px 12px; }
.inv-row code { font-size: 16px; font-weight: 700; letter-spacing: .06em; flex: 1; }
.inv-row.used { opacity: .6; } .inv-row .btn { padding: 6px 12px; }

/* ---------- profile + review ---------- */
.pill.brain { font-size: 16px; padding: 4px 9px; }
.rc-text { flex: 1; display: grid; gap: 2px; } .prof-body { max-width: var(--col); margin: 0 auto; padding: 16px 16px calc(40px + var(--safe-b)); }
.prof-hero { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; } .prof-hero .bubble { margin: 0; font-size: 14px; }
.prof-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.prof-stats div { background: var(--panel); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; }
.prof-stats b { display: block; font-size: 22px; } .prof-stats span { font-size: 12px; color: var(--muted); }
.prof-sec h2 { display: flex; align-items: center; gap: 6px; }
.prof-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 8px 10px 12px; margin-bottom: 8px; }
.prof-row .pi { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 13px; background: var(--panel2); }
.prof-row .pt { flex: 1; min-width: 0; } .prof-row .pt b { display: block; font-weight: 650; } .prof-row .pt span { font-size: 12px; color: var(--muted); }
.prof-row .del { color: var(--muted); padding: 6px 8px; }
.st-verified .pi { background: var(--ok); color: #fff; } .st-learned .pi, .st-learning .pi { background: color-mix(in srgb, var(--accent) 30%, var(--panel2)); color: var(--accent2); }
.st-shaky .pi, .st-misconception .pi { background: var(--warn); color: #1b1e27; } .st-gap .pi { color: var(--muted); } .st-known .pi { background: color-mix(in srgb, var(--ok) 25%, var(--panel2)); color: var(--ok); }
.boxes { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; } .boxes i { width: 7px; height: 7px; border-radius: 2px; background: var(--line); } .boxes i.on { background: var(--ok); }
.link-btn.danger { color: var(--bad); margin-top: 24px; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
#revStream { flex: 1; overflow-y: auto; padding: 18px 12px 24px; }
#revItems { max-width: var(--col); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.concept-chip { align-self: flex-start; margin-left: 40px; font-size: 12px; font-weight: 700; color: #cbbfff; background: color-mix(in srgb, #6c5ce7 25%, var(--panel)); border: 1px solid color-mix(in srgb, #6c5ce7 55%, var(--line)); border-radius: 999px; padding: 3px 10px; }
#revFeedback { border-radius: 16px; padding: 12px; animation: slideup .22s ease-out; }
#revFeedback.ok { background: var(--okbg); } #revFeedback.bad { background: var(--badbg); } #revFeedback.dk { background: var(--warnbg); }
#revFeedback.ok .fb-row { color: var(--ok); } #revFeedback.bad .fb-row { color: var(--bad); } #revFeedback.dk .fb-row { color: var(--warn); }
#revFeedback .fb-row { justify-content: flex-start; gap: 10px; } #revFeedback #revFbXp { margin-left: auto; }
.fb-actions { display: flex; gap: 8px; }
#revFeedback.ok #revNext { background: var(--ok); color: #fff; } #revFeedback.bad #revNext { background: var(--bad); color: #fff; } #revFeedback.dk #revNext { background: var(--warn); color: #1b1e27; }
#revBar { display: flex; gap: 8px; }
.verified-badge { align-self: center; font-weight: 800; color: var(--ok); background: var(--okbg); border: 1.5px solid var(--ok); border-radius: 999px; padding: 6px 14px; animation: pop .5s cubic-bezier(.3,1.8,.5,1); }
.summary-card { background: var(--panel); border: 1.5px solid var(--line); border-radius: 20px; padding: 22px 18px; text-align: center; animation: popin .35s ease-out; }
.summary-card h2 { font-size: 22px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 10px 0 4px; }
.summary-card ul { list-style: none; padding: 0; text-align: left; margin: 14px 0; display: grid; gap: 6px; }
/* profile notes inside a lesson */
.prof-note { align-self: stretch; margin-left: 40px; font-size: 13px; border: 1.5px dashed color-mix(in srgb, #6c5ce7 55%, var(--line)); border-radius: 14px; padding: 8px 12px; color: var(--muted); animation: popin .3s ease-out; }
.prof-note b { color: #cbbfff; } .prof-note ul { margin: 4px 0 0; padding-left: 1.1em; } .prof-note li { margin: 2px 0; }

/* ---------- voice notes ---------- */
.mic-slot { display: contents; }
.mic { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; position: relative; color: var(--muted); }
.mic svg { width: 20px; height: 20px; fill: currentColor; stroke: currentColor; }
.mic.recording { background: var(--bad); border-color: var(--bad); color: #fff; animation: recpulse 1.2s ease-in-out infinite; }
.mic.recording .rec-t { position: absolute; top: -22px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 800; color: var(--bad); background: var(--bg); padding: 1px 6px; border-radius: 999px; }
.mic.busy { pointer-events: none; }
.mic.busy svg { animation: spinpulse .8s ease-in-out infinite; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--bad) 25%, transparent); } }
.note-wrap { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; } .note-wrap textarea { margin: 0; font-size: 15px; }
.freeask input { flex: 1; }
.send.nudge { animation: pop .5s cubic-bezier(.3,1.8,.5,1) 2; }

/* ---------- lesson sheet ---------- */
.pref { display: grid; gap: 6px; margin-bottom: 12px; } .pref > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.segs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--panel2); border-radius: 12px; padding: 4px; }
.segs button { padding: 9px 4px; border-radius: 9px; font-size: 13px; font-weight: 650; color: var(--muted); }
.segs button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px #0005; }
.toggle { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; font-weight: 600; cursor: pointer; }
.toggle input { display: none; }
.toggle .tg { width: 46px; height: 28px; border-radius: 999px; background: var(--panel2); border: 1.5px solid var(--line); position: relative; transition: background .2s; flex: none; }
.toggle .tg::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.toggle input:checked + .tg { background: color-mix(in srgb, var(--accent) 35%, var(--panel2)); border-color: var(--accent); }
.toggle input:checked + .tg::after { transform: translateX(18px); background: #fff; }
.save-row { display: flex; gap: 8px; }
#lessonMenuBtn { width: 36px; }

/* ---------- visuals / map extras ---------- */
.stage { position: relative; }
.checked-badge { position: absolute; top: 8px; right: 10px; font-size: 11px; font-weight: 800; color: #9fe3bd; background: #12301fcc; border: 1px solid #3fb97c88; border-radius: 999px; padding: 2px 8px; }
.mapmark { height: 0; margin: -5px 0; }
.flash { animation: flash 1.6s ease-out; border-radius: 16px; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.steps li[data-node] { cursor: pointer; border-radius: 12px; }
.steps li[data-node]:active { background: var(--panel2); }
.node-acts { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px 44px; animation: popin .2s ease-out; }
.steps li { flex-wrap: wrap; }
.node-acts button { font-size: 13px; font-weight: 650; padding: 7px 11px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel2); }
.node-acts button:disabled { opacity: .45; }

/* ---------- intro (how it works) ---------- */
#intro { position: fixed; inset: 0; z-index: 70; background: radial-gradient(120% 80% at 50% 0%, #211a4a 0%, var(--bg) 60%); display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top)) 20px calc(16px + var(--safe-b)); color: var(--text); }
.intro-skip { align-self: flex-end; color: var(--muted); padding: 6px 10px; font-weight: 600; }
.intro-track { flex: 1; position: relative; overflow: hidden; }
.slide { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 6px; opacity: 0; transform: translateX(40px); transition: opacity .35s, transform .35s; pointer-events: none; }
.slide.left { transform: translateX(-40px); }
.slide.on { opacity: 1; transform: none; pointer-events: auto; }
.slide h1 { font-size: 26px; margin: 22px 0 8px; } .slide p { color: var(--muted); max-width: 340px; margin: 0 auto; line-height: 1.5; }
.art { height: 230px; width: min(320px, 100%); display: grid; place-items: center; position: relative; }
.intro-foot { display: grid; gap: 14px; max-width: 420px; width: 100%; margin: 0 auto; }
.dots { display: flex; gap: 8px; justify-content: center; } .dots i { width: 8px; height: 8px; border-radius: 99px; background: var(--line); cursor: pointer; transition: width .25s, background .25s; }
.dots i.on { width: 24px; background: var(--accent); }
/* slide 0: hello */
.hello-bubble { position: absolute; top: 18px; right: 34px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 6px 14px; font-weight: 800; opacity: 0; }
.play .hello-bubble { animation: popin .4s .5s ease-out forwards; }
.play .mascot-slot.big { animation: hop .7s cubic-bezier(.3,1.6,.5,1) .2s 2; }
/* slide 1: edge search */
.edge-bar { position: relative; width: 280px; height: 44px; border-radius: 12px; overflow: hidden; display: flex; font-size: 12px; font-weight: 700; }
.edge-bar span { flex: 1; display: grid; place-items: center; } .edge-bar .known { background: color-mix(in srgb, var(--ok) 35%, var(--panel)); color: #bfeccf; } .edge-bar .new { background: var(--panel2); color: var(--muted); }
.edge-marker { position: absolute; top: -4px; bottom: -4px; width: 4px; border-radius: 4px; background: var(--warn); box-shadow: 0 0 12px var(--warn); left: 10%; }
.play .edge-marker { animation: bsearch 2.6s cubic-bezier(.5,0,.3,1) forwards; }
@keyframes bsearch { 0% { left: 10%; } 25% { left: 85%; } 45% { left: 30%; } 62% { left: 62%; } 78% { left: 44%; } 100% { left: 50%; } }
.mini-tiles { display: flex; gap: 8px; margin-top: 18px; } .mini-tiles b { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--panel); border: 2px solid var(--line); opacity: 0; transform: scale(.6); }
.mini-tiles .t1, .mini-tiles .t2 { border-color: var(--ok); color: var(--ok); } .mini-tiles .t3 { border-color: var(--bad); color: var(--bad); } .mini-tiles .t4 { border-color: var(--warn); color: var(--warn); }
.play .mini-tiles b { animation: tilein .35s cubic-bezier(.3,1.6,.5,1) forwards; }
.play .mini-tiles .t2 { animation-delay: .5s; } .play .mini-tiles .t3 { animation-delay: 1s; } .play .mini-tiles .t4 { animation-delay: 1.5s; }
@keyframes tilein { to { opacity: 1; transform: none; } }
/* slide 2: DAG builds itself */
.dag { width: 280px; } .dag rect { fill: var(--panel); stroke: var(--accent); stroke-width: 2; } .dag .goal rect { stroke: var(--warn); }
.dag text { fill: var(--text); font: 700 13px sans-serif; text-anchor: middle; }
.dag .edges path { stroke: var(--muted); stroke-width: 2; fill: none; stroke-dasharray: 80; stroke-dashoffset: 80; }
.dag .n { opacity: 0; transform: translateY(8px); transform-box: fill-box; }
.play .dag .n { animation: tilein .4s ease-out forwards; }
.play .dag .n1 { animation-delay: .1s; } .play .dag .n2 { animation-delay: .35s; } .play .dag .n3 { animation-delay: 1.1s; } .play .dag .n4 { animation-delay: 1.8s; }
.play .dag .edges path { animation: draw .6s ease-out forwards; } .play .dag .edges path:nth-child(1) { animation-delay: .6s; } .play .dag .edges path:nth-child(2) { animation-delay: .75s; } .play .dag .edges path:nth-child(3) { animation-delay: 1.4s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
/* slide 3: one step at a time */
.art-step { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; place-items: unset; justify-content: center; }
.art-step .b { background: var(--panel); border: 1.5px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 8px 14px; font-weight: 600; opacity: 0; }
.art-step .tile-ok { align-self: stretch; text-align: center; padding: 12px; border-radius: 14px; border: 2px solid var(--ok); background: var(--okbg); color: var(--ok); font-weight: 800; opacity: 0; }
.art-step .xpf { position: absolute; right: 18px; bottom: 30px; color: var(--warn); font-weight: 900; opacity: 0; }
.play .art-step .b1 { animation: popin .35s .2s ease-out forwards; } .play .art-step .b2 { animation: popin .35s .8s ease-out forwards; }
.play .art-step .tile-ok { animation: tilein .4s 1.5s cubic-bezier(.3,1.6,.5,1) forwards; } .play .art-step .xpf { animation: xpup 1s 1.9s ease-out forwards; }
@keyframes xpup { 0% { opacity: 0; transform: translateY(10px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }
/* slide 4: verification */
.art-verify { gap: 12px; align-content: center; }
.vcard { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; border: 2px solid var(--line); background: var(--panel); font-weight: 800; width: 250px; }
.vi { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); }
.vsrc { border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 13px; color: var(--accent2); font-weight: 700; opacity: 0; }
.play .vcard { animation: verifyflip 2.2s steps(1) forwards; } .play .vi { animation: spinpulse .5s ease-in-out 3; } .play .vsrc { animation: popin .4s 1.7s ease-out forwards; }
@keyframes verifyflip { 0%, 60% { border-color: var(--line); } 61%, 100% { border-color: var(--ok); } }
.play .vl::after { content: ""; animation: vtext 2.2s steps(1) forwards; }
@keyframes vtext { 0%, 60% { content: ""; } 61%, 100% { content: " ✓"; } }
/* slide 5: spaced review */
.art-review { gap: 18px; align-content: center; }
.days { display: flex; gap: 10px; } .days .d { padding: 8px 12px; border-radius: 12px; background: var(--panel); border: 2px solid var(--line); font-weight: 700; font-size: 13px; }
.play .days .d { animation: dayok .4s ease-out forwards; } .play .days .d2 { animation-delay: .6s; } .play .days .d3 { animation-delay: 1.2s; }
@keyframes dayok { to { border-color: var(--ok); background: var(--okbg); color: var(--ok); } }
.stamp { font-size: 20px; font-weight: 900; color: var(--ok); border: 3px solid var(--ok); border-radius: 14px; padding: 8px 16px; opacity: 0; transform: rotate(-8deg) scale(1.6); }
.play .stamp { animation: stamp .45s 1.8s cubic-bezier(.3,1.6,.5,1) forwards; }
@keyframes stamp { to { opacity: 1; transform: rotate(-8deg) scale(1); } }

/* ---------- print / PDF ---------- */
@media print {
  :root { --bg: #fff; --panel: #fff; --panel2: #f3f3f3; --line: #ddd; --text: #111; --muted: #555; }
  body { background: #fff; color: #111; }
  #home, #auth, #review, #profile, .bar, .dock, .sheet, #mapSheet, #sheetBg, #toast, #fx, #celebrate, #intro, #typing, .hot-hint, .ver-more, .mascot-slot { display: none !important; }
  #lesson.screen { position: static; height: auto; display: block; }
  #stream { overflow: visible; padding: 0; }
  .row, .stage, .verify, .qopts { break-inside: avoid; }
  .stage { background: #11151f; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .bubble { border: 1px solid #ddd !important; max-width: 100%; } .bubble.me { background: #eef1ff !important; color: #111 !important; }
  * { animation: none !important; }
}

/* ---------- home: "Quiero entender…" ---------- */
#home { background: radial-gradient(90% 50% at 50% 26%, #1d1840 0%, var(--bg) 70%); }
#home .home-top { background: transparent; backdrop-filter: none; }
.home-hero { min-height: calc(100dvh - 190px); display: flex; flex-direction: column; justify-content: center; padding: 8px 6px 18px; }
.hero-nodo { width: 64px; height: 64px; margin-bottom: 16px; }
.hero-nodo .mascot { animation: herohop 3s ease-in-out infinite; }
@keyframes herohop { 0%, 72%, 100% { transform: none; } 82% { transform: translateY(-7px); } }
.want { font-size: clamp(30px, 8.6vw, 44px); line-height: 1.12; letter-spacing: -.02em; margin: 0 0 20px; font-weight: 800; }
.want .rot { display: block; text-align: left; padding: 0; font: inherit; color: var(--accent2); min-height: 1.15em; cursor: pointer; }
.want .rot::after { content: ""; display: inline-block; width: 3px; height: .85em; margin-left: 5px; vertical-align: -.08em; border-radius: 2px; background: var(--warn); animation: blink 1s steps(2) infinite; }
.big-box { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 24px; padding: 7px 7px 7px 18px; box-shadow: 0 12px 40px #0008; transition: border-color .2s, box-shadow .2s; }
.big-box:focus-within { border-color: var(--accent); box-shadow: 0 12px 40px #0008, 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.big-box input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 18px; padding: 10px 0; }
.big-box input:focus { outline: 0; }
.big-box .go { flex: none; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 20px; font-weight: 800; box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 55%, #000); }
.big-box .go:active { transform: scale(.94); }
#askForm textarea { margin-top: 10px; font-size: 15px; }
.hint { color: var(--muted); font-size: 14px; margin: 14px 2px 0; line-height: 1.5; }
.link-btn.inline { display: inline; padding: 0; font-size: 14px; color: var(--accent2); text-decoration: none; font-weight: 650; }
.review-pill { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; margin: 0 0 18px; padding: 12px 14px; border-radius: 16px; background: linear-gradient(135deg, #2b2461, var(--panel)); border: 1.5px solid #6c5ce7aa; animation: popin .35s ease-out; }
.review-pill b { flex: 1; font-weight: 700; } .review-pill .muted { font-size: 14px; }
#continueWrap h2 { margin-top: 4px; }
.cont-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cont-chip { display: flex; align-items: center; gap: 8px; max-width: 100%; background: var(--panel); border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 14px 7px 8px; font-size: 14px; font-weight: 600; }
.cont-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cont-chip:active { transform: scale(.97); }
.ring { flex: none; width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--ok) var(--p), var(--panel2) 0); display: grid; place-items: center; }
.ring::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--panel); }
#allChatsBtn { margin-top: 12px; }
.all-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.all-row .t { flex: 1; min-width: 0; font-weight: 650; } .all-row small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.all-row .del { color: var(--muted); padding: 6px 8px; }
#home.has-chats .home-hero { min-height: 0; padding-top: 7dvh; padding-bottom: 26px; }

/* ---------- listen (TTS) button: small, in the bubble's corner, never over the text ---------- */
.bubble.tutor { position: relative; }
.row.tutor .bubble.tutor:has(.speak) { padding-bottom: 12px; }
.speak { position: absolute; right: -12px; bottom: -12px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel2); border: 1.5px solid var(--line); color: var(--muted); box-shadow: 0 2px 8px #0006; z-index: 2; }
.speak svg { width: 16px; height: 16px; fill: currentColor; stroke: currentColor; }
.speak:active { transform: scale(.92); }
.speak[data-st="playing"], .speak[data-st="paused"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.speak[data-st="playing"] { width: auto; padding: 0 9px 0 7px; border-radius: 999px; gap: 5px; display: flex; align-items: center; }
.speak .eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.speak .eq b { width: 3px; background: #fff; border-radius: 2px; animation: eq 0.9s ease-in-out infinite; }
.speak .eq b:nth-child(2) { animation-delay: .2s; } .speak .eq b:nth-child(3) { animation-delay: .4s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
.speak .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media print { .speak { display: none !important; } }

/* ---------- video card ---------- */
.video-card { margin: 4px 0 4px 40px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 18px; padding: 12px; animation: popin .3s ease-out; }
.vc-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; } .vc-head b { flex: 1; min-width: 0; }
.video-card video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 16 / 9; display: block; }
.vc-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.vc-steps li { display: flex; align-items: center; gap: 8px; } .vc-steps li.done { color: var(--ok); } .vc-steps li.cur { color: var(--text); font-weight: 650; }
.vc-steps .spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent2); animation: spin .8s linear infinite; display: inline-block; }
@media print { .video-card video { display: none; } }
.vc-sub { margin: -4px 0 10px 30px; }
