/* ============ QuantLab SPA — vistas de plataforma ============
 * Reutiliza los tokens de base.css (light lavanda + IDE Catppuccin).
 * Mobile-first: base 320px, breakpoints 768 y 1200.
 */

/* ---------- Header ---------- */
.pf-header { position: sticky; top: 0; z-index: 30; }
.pf-header .brand { text-decoration: none; }
.pf-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pf-nav a[data-nav] {
  text-decoration: none; font-size: 13px; font-weight: 600;
  color: var(--text-2); padding: 7px 12px; border-radius: 9px;
  transition: all .15s;
}
.pf-nav a[data-nav]:hover { background: rgba(124,58,237,0.07); color: var(--text-1); }
.pf-nav a[data-nav].active { background: rgba(124,58,237,0.10); color: var(--accent-violet); }
.pf-user { font-size: 12.5px; font-weight: 700; color: var(--text-1); padding: 0 6px; }
.pf-btn-in, .pf-btn-out {
  font-family: var(--ui); font-size: 12.5px; font-weight: 700; cursor: pointer;
  padding: 7px 16px; border-radius: 999px; text-decoration: none;
  border: none; transition: all .15s;
}
.pf-btn-in {
  background: var(--accent-gradient); color: #fff;
  box-shadow: 0 3px 12px rgba(124,58,237,0.3);
}
.pf-btn-in:hover { transform: translateY(-1px); box-shadow: 0 5px 18px rgba(124,58,237,0.45); }
.pf-btn-out {
  background: #fff; color: var(--text-2);
  border: 1.5px solid #e2dff4;
}
.pf-btn-out:hover { color: var(--error); border-color: rgba(225,29,72,0.3); }

/* ---------- Layout ---------- */
.pf-main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; min-height: 60vh; }
.pf-footer {
  max-width: 1080px; margin: 0 auto; padding: 16px 20px 28px;
  font-size: 12px; color: var(--text-3); text-align: center;
}
.pf-footer a { color: var(--accent-violet); }

.pf-offline {
  max-width: 1080px; margin: 10px auto 0; padding: 10px 18px;
  background: #fffbeb; border: 1px solid #fcd34d; border-radius: 12px;
  font-size: 13px; color: #92400e;
}

.pf-loading { color: var(--text-3); text-align: center; padding: 48px 0; }

.pf-hero { margin: 8px 0 24px; }
.pf-hero h1 {
  margin: 0 0 6px; font-size: clamp(22px, 4.5vw, 30px); font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--heading-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.pf-sub { color: var(--text-2); font-size: 14.5px; line-height: 1.65; margin: 0 0 8px; }
.pf-sub a { color: var(--accent-violet); font-weight: 600; }

.pf-back {
  display: inline-block; margin-bottom: 14px;
  text-decoration: none; font-size: 12.5px; font-weight: 700;
  color: var(--accent-violet); padding: 6px 12px;
  border: 1.5px solid rgba(124,58,237,0.22); border-radius: 999px; background: #fff;
}
.pf-back:hover { background: #faf5ff; }

/* ---------- Cards ---------- */
.pf-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--r-lg); box-shadow: var(--card-shadow);
  padding: 24px;
}

.pf-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .pf-grid { grid-template-columns: 1fr 1fr; } }

.pf-course {
  display: flex; flex-direction: column; gap: 6px;
  text-decoration: none; color: inherit;
  transition: transform .18s, box-shadow .18s;
  position: relative; overflow: hidden;
}
.pf-course::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
}
.pf-course:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 42px rgba(109,40,217,0.16);
}
.pf-course-icon { font-size: 30px; line-height: 1; }
.pf-course h2 { margin: 4px 0 0; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-0); }
.pf-course p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.pf-course .pf-meta { margin-top: 6px; font-size: 11.5px; font-weight: 700; color: var(--accent-violet); }

/* ---------- Arte Canva ---------- */
.pf-course-cover {
  display: block; width: calc(100% + 48px); margin: -24px -24px 10px;
  aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 1px solid var(--card-border);
}
.pf-course.has-cover .pf-course-icon { display: none; }
.pf-hero-art {
  display: block; width: min(100%, 520px); margin: 0 auto 14px;
  aspect-ratio: 16 / 9; object-fit: contain;
  border-radius: var(--r-lg);
}
.pf-auth-art {
  display: block; width: min(100%, 380px); margin: 0 auto 14px;
  aspect-ratio: 16 / 9; object-fit: contain; border-radius: 12px;
}
.ql-figure {
  display: block; width: 100%; max-width: 640px; margin: 18px auto;
  border-radius: 14px; border: 1px solid var(--card-border);
  background: #fff;
}

/* ---------- Curso: módulos y lecciones ---------- */
.pf-module { margin: 22px 0; }
.pf-module h2 { font-size: 15px; font-weight: 800; color: var(--text-1); letter-spacing: -0.01em; margin: 0 0 10px; }
.pf-lessons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pf-lesson {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--card-border); border-radius: 14px;
  padding: 13px 16px; text-decoration: none; color: var(--text-1);
  font-size: 14px; font-weight: 600;
  transition: all .15s; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
a.pf-lesson:hover { border-color: rgba(124,58,237,0.35); box-shadow: 0 4px 16px rgba(109,40,217,0.12); }
.pf-lesson.gen { border-style: dashed; border-color: rgba(124,58,237,0.3); }
.pf-lesson.soon { opacity: .55; }
.pf-lesson-kind {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--accent-violet);
  background: #f5f3ff; border-radius: 6px; padding: 3px 8px;
}
.pf-lesson-go { margin-left: auto; color: var(--accent-violet); font-weight: 800; }

/* ---------- Progreso en cards (dashboard) ---------- */
.pf-progress { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pf-progress-bar {
  flex: 1; height: 8px; border-radius: 999px; overflow: hidden;
  background: #ece9f8; border: 1px solid rgba(124,58,237,0.10);
}
.pf-progress-bar i {
  display: block; height: 100%; border-radius: 999px;
  background: var(--success-grad);
  transition: width .5s cubic-bezier(.2,.8,.4,1);
}
.pf-progress-num {
  font-size: 11px; font-weight: 800; color: var(--accent-emerald);
  font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.duo-continue-chip {
  align-self: flex-start; margin-top: 8px;
  font-size: 12px; font-weight: 800; color: #fff;
  background: var(--accent-gradient); border-radius: 999px; padding: 6px 14px;
  box-shadow: 0 3px 12px rgba(124,58,237,0.35);
}

/* ---------- Path Duolingo (vista curso) ---------- */
.duo-course { max-width: 480px; margin: 0 auto; }
.duo-course .duo-summary { max-width: 320px; }

.duo-path {
  position: relative; display: flex; flex-direction: column; align-items: center;
  gap: 20px; padding: 14px 0 96px;
}
.duo-path::before {
  content: ''; position: absolute; top: 0; bottom: 60px; left: 50%; width: 4px;
  transform: translateX(-50%); border-radius: 2px;
  background: repeating-linear-gradient(180deg,
    rgba(124,58,237,0.16) 0 10px, transparent 10px 20px);
}

.duo-step {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  width: 170px; text-align: center;
}
.duo-step.l { transform: translateX(-58px); }
.duo-step.r { transform: translateX(58px); }

.duo-node {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; text-decoration: none; color: var(--text-1);
  background: #fff; border: 3px solid #e2dff4;
  box-shadow: 0 4px 0 #e2dff4, 0 8px 20px rgba(109,40,217,0.10);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
a.duo-node:hover { transform: translateY(-3px); box-shadow: 0 7px 0 #e2dff4, 0 12px 26px rgba(109,40,217,0.18); }
a.duo-node:active { transform: translateY(1px); box-shadow: 0 2px 0 #e2dff4; }

.duo-node.done {
  background: var(--success-grad); border-color: #047857; color: #fff;
  font-weight: 800; box-shadow: 0 4px 0 #047857, 0 8px 20px rgba(5,150,105,0.28);
}
a.duo-node.done:hover { box-shadow: 0 7px 0 #047857, 0 12px 26px rgba(5,150,105,0.35); }

.duo-node.current {
  background: var(--accent-gradient); border-color: #6d28d9; color: #fff;
  box-shadow: 0 4px 0 #6d28d9, 0 8px 24px rgba(124,58,237,0.4);
  animation: duoPulse 1.8s ease-in-out infinite;
}
.duo-node.locked {
  background: #eceaf5; border-color: #dcd9ec; color: var(--text-3);
  box-shadow: 0 3px 0 #dcd9ec; filter: grayscale(1); opacity: .8;
  cursor: not-allowed; font-size: 19px;
}
@keyframes duoPulse {
  0%, 100% { box-shadow: 0 4px 0 #6d28d9, 0 0 0 0 rgba(124,58,237,0.40); }
  55%      { box-shadow: 0 4px 0 #6d28d9, 0 0 0 14px rgba(124,58,237,0); }
}
@media (prefers-reduced-motion: reduce) {
  .duo-node.current { animation: none; }
}

.duo-node-title {
  font-size: 11.5px; font-weight: 700; color: var(--text-2); line-height: 1.35;
  max-width: 170px;
}
.duo-step:has(.duo-node.locked) .duo-node-title { color: var(--text-3); }
.duo-step:has(.duo-node.current) .duo-node-title { color: var(--accent-violet); }

.duo-module-label { position: relative; z-index: 1; margin: 12px 0 2px; }
.duo-module-label span {
  display: inline-block; background: #fff; color: #5b21b6;
  border: 1.5px solid rgba(124,58,237,0.25); border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: .01em;
  padding: 7px 18px; box-shadow: var(--card-shadow);
}

/* CTA Continuar: arriba del path en desktop, sticky abajo en mobile */
.duo-continue {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin: 0 0 20px; z-index: 25;
}
.duo-continue-btn {
  display: block; width: 100%; max-width: 420px; text-align: center;
  text-decoration: none; font-size: 15px; padding: 14px 22px;
  border-radius: var(--r-md);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.duo-continue-msg { font-size: 17px; font-weight: 800; color: var(--text-0); }
.duo-login-cta {
  margin: 0 0 20px; padding: 13px 18px; text-align: center;
  background: #faf5ff; border: 1.5px dashed rgba(124,58,237,0.3);
  border-radius: var(--r-md); font-size: 13.5px; color: var(--text-1); font-weight: 600;
}
.duo-login-cta a { color: var(--accent-violet); font-weight: 800; }

@media (max-width: 599px) {
  .duo-step.l { transform: translateX(-44px); }
  .duo-step.r { transform: translateX(44px); }
  .duo-node { width: 50px; height: 50px; font-size: 20px; }
  .duo-continue {
    position: fixed; left: 0; right: 0; bottom: 0; margin: 0;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(245,243,255,0.94);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(124,58,237,0.15);
    box-shadow: 0 -6px 24px rgba(109,40,217,0.10);
  }
  .duo-path { padding-bottom: 130px; }
}

/* ---------- Auth ---------- */
.pf-auth { max-width: 420px; margin: 24px auto; }
.pf-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.pf-tabs button {
  flex: 1; font-family: var(--ui); font-size: 13.5px; font-weight: 700;
  padding: 9px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid #e2dff4; background: #fff; color: var(--text-2);
}
.pf-tabs button.on {
  background: var(--accent-gradient); color: #fff; border-color: transparent;
  box-shadow: 0 3px 12px rgba(124,58,237,0.3);
}
.pf-auth h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.pf-auth form { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; }
.pf-auth label { font-size: 12.5px; font-weight: 700; color: var(--text-1); margin-top: 10px; }
.pf-auth input {
  font-family: var(--ui); font-size: 15px; color: var(--text-0);
  padding: 10px 14px; border-radius: 10px;
  border: 1.5px solid #e2dff4; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.pf-auth input:focus {
  outline: none; border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.pf-help { font-size: 11.5px; color: var(--text-3); }
.pf-error {
  margin-top: 10px; padding: 10px 14px; border-radius: 10px;
  background: #fff1f2; border: 1px solid #fda4af; color: #9f1239;
  font-size: 13.5px; font-weight: 600;
}
.pf-full { width: 100%; margin-top: 16px; }

/* ---------- Config de práctica ---------- */
.pf-practice-cfg { max-width: 560px; margin: 12px auto; }
.pf-practice-cfg h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.pf-practice-cfg fieldset { border: none; margin: 16px 0 0; padding: 0; }
.pf-practice-cfg legend { font-size: 13px; font-weight: 800; color: var(--text-1); margin-bottom: 10px; }
.pf-diff-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 480px) { .pf-diff-grid { grid-template-columns: 1fr 1fr; } }
.pf-diff {
  display: flex; flex-direction: column; gap: 2px; cursor: pointer;
  border: 1.5px solid #e2dff4; border-radius: 12px; padding: 10px 14px;
  transition: all .15s; background: #fff;
}
.pf-diff:hover { border-color: rgba(124,58,237,0.35); }
.pf-diff.on {
  border-color: var(--accent-violet);
  background: #faf5ff;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.pf-diff input { position: absolute; opacity: 0; pointer-events: none; }
.pf-diff-label { font-size: 14px; font-weight: 700; color: var(--text-0); }
.pf-diff-desc { font-size: 11.5px; color: var(--text-3); }
.pf-diff:focus-within { outline: 2px solid var(--accent-indigo); outline-offset: 2px; }
.pf-toggle {
  display: flex; align-items: center; gap: 10px; margin-top: 18px;
  font-size: 13.5px; font-weight: 600; color: var(--text-1); cursor: pointer;
}
.pf-toggle input { width: 18px; height: 18px; accent-color: var(--accent-violet); }

/* ---------- Runner ---------- */
.pf-runner { max-width: 760px; margin: 0 auto; }
.pf-runner-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.pf-runner-head h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.pf-diff-badge {
  font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: #fff; background: var(--accent-gradient);
  padding: 4px 12px; border-radius: 999px;
}
.pf-statement { font-size: 14.5px; line-height: 1.7; color: var(--text-2); }
.pf-statement code {
  font-family: var(--mono); font-size: .88em; color: var(--accent-violet);
  background: #f5f3ff; border: 1px solid rgba(124,58,237,0.18);
  border-radius: 5px; padding: 1px 6px;
}

.pf-criteria {
  margin: 10px 0; font-size: 13px; color: var(--text-2);
  background: #f5f3ff; border: 1px solid rgba(124,58,237,0.15);
  border-radius: 12px; padding: 10px 16px;
}
.pf-criteria summary { font-weight: 700; cursor: pointer; color: var(--text-1); }
.pf-criteria ul { margin: 8px 0 2px; padding-left: 20px; }
.pf-criteria li { margin-bottom: 3px; }

/* Código: siempre IDE oscuro (tokens Catppuccin de base.css) */
.pf-code {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.9;
  background: var(--ed-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 20px; overflow-x: auto; margin: 14px 0;
  white-space: pre;
}
.pf-code.dim { opacity: .8; margin-bottom: 0; border-radius: 12px 12px 0 0; }
.pf-code .blank-input {
  font-family: var(--mono); font-size: 13.5px;
  background: rgba(54,58,79,0.8); color: #cad3f5;
  border: none; border-bottom: 2px dashed #494d64;
  border-radius: 4px 4px 0 0; padding: 1px 6px; margin: 0 2px;
  caret-color: var(--meth);
}
.pf-code .blank-input:focus {
  outline: none; border-bottom-color: var(--accent-indigo);
  background: rgba(99,102,241,0.2);
}
.pf-code-editor { margin: 14px 0; }
.pf-code-input {
  width: 100%; box-sizing: border-box; resize: vertical;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.8;
  background: var(--ed-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 20px; caret-color: var(--meth);
}
.pf-code-editor .pf-code.dim + .pf-code-input { border-radius: 0 0 12px 12px; border-top: none; }
.pf-code-input:focus { outline: none; border-color: var(--accent-indigo); box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }

.pf-feedback {
  padding: 12px 18px; border-radius: 12px; margin: 12px 0 0;
  font-size: 14px; font-weight: 600; line-height: 1.55;
}
.pf-feedback.ok { background: #f0fdf4; border: 1px solid #86efac; color: #14532d; }
.pf-feedback.err { background: #fff1f2; border: 1px solid #fda4af; color: #9f1239; }
.pf-feedback ul { margin: 6px 0 0; padding-left: 20px; font-weight: 500; }

.pf-hint-box {
  margin-top: 10px; padding: 10px 16px; border-radius: 12px;
  background: #f5f3ff; border: 1px solid rgba(124,58,237,0.2);
  font-size: 13.5px; color: var(--text-1); line-height: 1.6;
}
.pf-hint-box p { margin: 4px 0; }

.pf-runner-controls { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.pf-spacer { flex: 1; }

/* ---------- Vista de lección (capítulos de los libros) ---------- */
.pf-lesson-view { max-width: 760px; margin: 0 auto; }
.pf-lesson-content {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--r-lg); box-shadow: var(--card-shadow);
  padding: 28px clamp(18px, 4vw, 40px) 36px;
  font-size: 15px; line-height: 1.75; color: var(--text-1);
  overflow-wrap: break-word;
}
.pf-lesson-content h1 {
  font-size: clamp(21px, 4vw, 27px); font-weight: 800; letter-spacing: -0.03em;
  background: var(--heading-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 10px 0 14px; line-height: 1.3;
}
.pf-lesson-content h2 {
  font-size: 19px; font-weight: 800; color: var(--text-0);
  margin: 30px 0 10px; letter-spacing: -0.02em;
  padding-bottom: 6px; border-bottom: 2px solid rgba(124,58,237,0.15);
}
.pf-lesson-content h3 { font-size: 16px; font-weight: 700; color: #5b21b6; margin: 22px 0 8px; }
.pf-lesson-content h4 { font-size: 14px; font-weight: 700; color: var(--text-2); margin: 18px 0 6px; }
.pf-lesson-content p { margin: 0 0 12px; }
.pf-lesson-content ul, .pf-lesson-content ol { margin: 0 0 12px; padding-left: 24px; }
.pf-lesson-content li { margin-bottom: 5px; }
.pf-lesson-content a { color: var(--accent-violet); }
.pf-lesson-content hr { border: none; border-top: 1.5px solid rgba(124,58,237,0.14); margin: 26px 0; }
.pf-lesson-content blockquote {
  margin: 14px 0; padding: 10px 18px;
  border-left: 4px solid var(--accent-violet);
  background: #faf5ff; border-radius: 0 10px 10px 0;
  color: var(--text-1); font-style: italic;
}
.pf-lesson-content blockquote p { margin: 0; }
.pf-lesson-content code {
  font-family: var(--mono); font-size: .87em;
  color: var(--accent-violet); background: #f5f3ff;
  border: 1px solid rgba(124,58,237,0.15);
  border-radius: 5px; padding: 1px 6px;
}
.pf-lesson-content pre {
  background: var(--ed-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px 20px; overflow-x: auto; margin: 14px 0;
  font-size: 13px; line-height: 1.8;
}
.pf-lesson-content pre code {
  background: none; border: none; color: inherit; padding: 0; font-size: inherit;
}
.pf-lesson-content table {
  border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 13.5px;
  display: block; overflow-x: auto;
}
.pf-lesson-content th {
  background: linear-gradient(135deg, #7c3aed, #6366f1); color: #fff;
  padding: 8px 14px; text-align: left; font-weight: 700;
}
.pf-lesson-content td { border: 1px solid #e9e6f7; padding: 8px 14px; }
.pf-lesson-content tr:nth-child(even) td { background: #faf9fe; }
.pf-lesson-content img { max-width: 100%; border-radius: 10px; }

/* Clases propias de los libros → design system */
.pf-lesson-content .clave {
  background: #eff6ff; border-left: 4px solid #3b82f6;
  padding: 12px 18px; border-radius: 0 10px 10px 0; margin: 16px 0;
}
.pf-lesson-content .analogia {
  background: #fffbeb; border: 1px solid #fcd34d;
  border-radius: 12px; padding: 14px 18px; margin: 16px 0;
}
.pf-lesson-content .ejercicio {
  background: #f0fdf4; border: 2px solid #6ee7b7;
  border-radius: 12px; padding: 14px 18px; margin: 20px 0;
}
.pf-lesson-content .ejercicio h4 { margin-top: 0; color: #047857; }
.pf-lesson-content .resumen {
  background: #faf5ff; border-left: 4px solid #a855f7;
  padding: 12px 18px; border-radius: 0 10px 10px 0; margin: 20px 0;
}
.pf-lesson-content .meme { text-align: center; margin: 18px 0; }
.pf-lesson-content .meme p { font-size: .85em; color: var(--text-3); margin-top: 6px; }
.pf-lesson-content .tag {
  display: inline-block; background: var(--accent-gradient); color: #fff;
  padding: 2px 10px; border-radius: 999px; font-size: .78em; font-weight: 700; margin: 2px;
}
.pf-lesson-content .tag-ref { background: linear-gradient(135deg, #f59e0b, #d97706); }
.pf-lesson-content .uml {
  background: var(--ed-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  white-space: pre; overflow-x: auto; margin: 16px 0;
}

.pf-lesson-nav {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-top: 18px; flex-wrap: wrap;
}
.pf-lesson-nav .btn { text-decoration: none; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) {
  .pf-lesson-nav { flex-direction: column; align-items: stretch; }
  .pf-lesson-nav .btn { max-width: 100%; text-align: center; }
}

/* ---------- Perfil ---------- */
.pf-stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 18px 0; }
@media (min-width: 768px) { .pf-stats-grid { grid-template-columns: repeat(4, 1fr); } }
.pf-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 18px 10px; }
.pf-stat .n {
  font-size: 26px; font-weight: 800; letter-spacing: -0.03em;
  background: var(--heading-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.pf-stat .l { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }

/* ---------- Accesibilidad / util ---------- */
.pf-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}
.pf-nav a:focus-visible, .pf-lesson:focus-visible, .pf-course:focus-visible,
.pf-btn-in:focus-visible, .pf-btn-out:focus-visible, .pf-back:focus-visible {
  outline: 2px solid var(--accent-indigo); outline-offset: 2px;
}

/* Botones base (si base.css no los define acá) */
.btn {
  font-family: var(--ui); font-size: 13.5px; font-weight: 700;
  padding: 10px 22px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid #e2dff4; background: #fff; color: var(--text-1);
  transition: all .2s cubic-bezier(.2,.8,.4,1);
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary {
  background: var(--accent-gradient); border-color: transparent; color: #fff;
  box-shadow: 0 4px 16px rgba(124,58,237,0.38);
}
.btn.primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,58,237,0.48); }
.btn.success {
  background: linear-gradient(135deg, #16a34a, #22c55e); border-color: transparent; color: #fff;
  box-shadow: 0 4px 16px rgba(5,150,105,0.32);
}
.btn.success:hover:not(:disabled) { transform: translateY(-2px); }
.btn.outline-accent {
  background: #fff; border-color: rgba(124,58,237,0.32); color: #5b21b6;
}
.btn.outline-accent:hover:not(:disabled) { background: #faf5ff; }
.btn:focus-visible { outline: 2px solid var(--accent-indigo); outline-offset: 2px; }

/* ---------- Mini-frame IDE (runner/examen: BLANKS y OUTPUT) ---------- */
.pf-ide {
  background: var(--ed-bg); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; margin: 14px 0;
  box-shadow: 0 10px 30px rgba(15,10,30,0.22);
}
.pf-ide-titlebar {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: linear-gradient(180deg, #2a2d40, #1e2030);
  border-bottom: 1px solid var(--border);
}
.pf-ide-dots { display: flex; gap: 6px; }
.pf-ide-dots i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.pf-ide-dots i:nth-child(1) { background: #f38ba8; }
.pf-ide-dots i:nth-child(2) { background: #f9e2af; }
.pf-ide-dots i:nth-child(3) { background: #a6e3a1; }
.pf-ide-file { font-family: var(--mono); font-size: 11.5px; color: var(--gutter-fg); }
.pf-ide .pf-code { margin: 0; border: none; border-radius: 0; }
.pf-ide-code { display: grid; grid-template-columns: auto 1fr; }
.pf-ide-gutter {
  margin: 0; padding: 16px 10px 16px 14px; text-align: right;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.9;
  background: var(--gutter-bg); color: var(--gutter-fg);
  border-right: 1px solid var(--border);
  user-select: none; -webkit-user-select: none;
}
.pf-ide-code .pf-code { overflow-x: auto; min-width: 0; }

/* OUTPUT: bloque "¿Qué imprime este programa?" */
.pf-output-q { margin: 14px 0; }
.pf-output-label {
  display: block; font-size: 13.5px; font-weight: 800;
  color: var(--text-1); margin-bottom: 8px;
}
.pf-output-input { line-height: 1.7; }

/* ---------- Feedback: meta (dificultad sugerida + racha + repaso) ---------- */
.pf-feedback-meta { margin-top: 8px; font-size: 12.5px; font-weight: 600; opacity: .92; }
.pf-streak-chip {
  display: inline-block; font-size: 12px; font-weight: 800;
  background: #fff7ed; border: 1px solid #fdba74; color: #c2410c;
  border-radius: 999px; padding: 2px 10px; margin-left: 4px;
  vertical-align: middle;
}

/* ---------- Acceso total (usuario demo) ---------- */
.pf-fullaccess-chip {
  display: inline-block; font-size: 11.5px; font-weight: 800;
  background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7;
  border-radius: 999px; padding: 3px 10px; margin-left: 8px;
  vertical-align: middle; letter-spacing: 0;
  -webkit-text-fill-color: #047857; /* dentro de h1 con gradiente de texto */
}

/* ---------- Perfil: tarjetas por familia ---------- */
.pf-family-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 768px) { .pf-family-grid { grid-template-columns: 1fr 1fr; } }
.pf-family-card { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; }
.pf-family-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-family-card h3 { margin: 0; font-size: 14.5px; font-weight: 800; color: var(--text-0); }
.pf-family-card .pf-progress { margin-top: 2px; }
.pf-family-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.pf-avg-time { color: var(--accent-sky); font-weight: 700; }
.pf-due-chip {
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 3px 10px;
  background: #f5f3ff; color: var(--accent-violet);
  border: 1px solid rgba(124,58,237,0.22);
}
.pf-due-chip.now {
  background: #fffbeb; color: #92400e; border-color: #fcd34d;
  animation: none;
}

/* ---------- Examen test-out ---------- */
a.duo-node.locked { cursor: pointer; }
a.duo-node.locked:hover { filter: grayscale(.4); opacity: 1; }

.pf-exam-progress { display: flex; gap: 6px; margin: 4px 0 12px; }
.pf-exam-progress i {
  width: 30px; height: 8px; border-radius: 999px; display: block;
  background: #ece9f8; border: 1px solid rgba(124,58,237,0.10);
}
.pf-exam-progress i.done { background: var(--success-grad); border-color: transparent; }
.pf-exam-progress i.on { background: var(--accent-gradient); border-color: transparent; }
.pf-exam-extitle { margin: 6px 0 4px; font-size: 16px; font-weight: 800; color: var(--text-0); }

.pf-exam-result { max-width: 480px; margin: 32px auto; text-align: center; }
.pf-exam-result h1 { margin: 8px 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.pf-exam-celebrate { font-size: 34px; line-height: 1.2; }
.pf-exam-score {
  font-size: 38px; font-weight: 800; letter-spacing: -0.03em; margin: 8px 0;
  font-variant-numeric: tabular-nums;
}
.pf-exam-score.ok { color: var(--accent-emerald); }
.pf-exam-score.err { color: var(--accent-rose); }
.pf-exam-actions {
  display: flex; flex-direction: column; gap: 10px; margin-top: 16px;
}
.pf-exam-actions .btn { text-decoration: none; text-align: center; }

/* ---------- MCQ: opciones estilo Duolingo ---------- */
.pf-mcq { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.pf-mcq-opt {
  position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer;
  background: #fff; border: 2px solid #e2dff4; border-radius: 14px;
  padding: 12px 16px; box-shadow: 0 2px 0 #e2dff4;
  transition: all .15s;
}
.pf-mcq-opt:hover { border-color: rgba(124,58,237,0.4); transform: translateY(-1px); }
.pf-mcq-opt:active { transform: translateY(1px); box-shadow: 0 0 0 #e2dff4; }
.pf-mcq-opt.on {
  border-color: var(--accent-violet); background: #faf5ff;
  box-shadow: 0 2px 0 var(--accent-violet), 0 0 0 3px rgba(124,58,237,0.12);
}
.pf-mcq-opt input { position: absolute; opacity: 0; pointer-events: none; }
.pf-mcq-opt:focus-within { outline: 2px solid var(--accent-indigo); outline-offset: 2px; }
.pf-mcq-key {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 800; color: var(--text-3);
  border: 1.5px solid #e2dff4; background: #faf9fe;
}
.pf-mcq-opt.on .pf-mcq-key {
  background: var(--accent-gradient); color: #fff; border-color: transparent;
}
.pf-mcq-text {
  font-family: var(--mono); font-size: 13px; color: var(--text-0);
  white-space: pre-wrap; word-break: break-word;
}

/* MCQ: explicación didáctica ("Por qué") revelada tras responder */
.pf-explain {
  margin-top: 10px; padding: 12px 16px; border-radius: 12px;
  background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a8a;
  font-size: 13.5px; line-height: 1.6;
}

/* ---------- Teoría-gate (y estados vacíos) ---------- */
.pf-gate { max-width: 460px; margin: 32px auto; text-align: center; }
.pf-gate-lock { font-size: 44px; line-height: 1; margin-bottom: 6px; }
.pf-gate h1 { margin: 8px 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.pf-gate .btn { text-decoration: none; display: block; }
.pf-gate .pf-back { margin-top: 14px; margin-bottom: 0; }

/* ---------- ¿Te quedó claro? (flags de comprensión) ---------- */
.pf-und[hidden] { display: none; } /* el display:flex de la clase pisaba el atributo hidden */
.pf-und {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 10px; padding: 10px 16px; border-radius: 12px;
  background: #faf9fe; border: 1.5px dashed rgba(124,58,237,0.25);
  font-size: 13px; font-weight: 700; color: var(--text-1);
}
.pf-und .btn { padding: 7px 14px; font-size: 12.5px; }
.pf-und-done { color: var(--accent-emerald); font-weight: 700; }

/* ---------- Tutor: drawer de chat ---------- */
.tutor-drawer { position: fixed; inset: 0; z-index: 60; }
.tutor-backdrop {
  position: absolute; inset: 0; background: rgba(30,20,60,0.35);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.tutor-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(420px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg-0); border-left: 1px solid var(--card-border);
  box-shadow: -18px 0 48px rgba(30,20,60,0.25);
  animation: tutorIn .22s ease-out;
}
@keyframes tutorIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .tutor-panel { animation: none; } }
.tutor-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: #fff; border-bottom: 1px solid var(--card-border);
}
.tutor-avatar { font-size: 26px; line-height: 1; }
.tutor-head-txt { display: flex; flex-direction: column; min-width: 0; }
.tutor-head h2 { margin: 0; font-size: 15px; font-weight: 800; color: var(--text-0); }
.tutor-topic {
  font-size: 11.5px; font-weight: 700; color: var(--accent-violet);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tutor-close {
  margin-left: auto; flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  border: 1.5px solid #e2dff4; background: #fff; color: var(--text-2);
  font-size: 14px; cursor: pointer;
}
.tutor-close:hover { color: var(--error); border-color: rgba(225,29,72,0.3); }
.tutor-msgs {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.tutor-msg {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.tutor-msg.me {
  align-self: flex-end; background: var(--accent-gradient); color: #fff;
  border-bottom-right-radius: 4px;
}
.tutor-msg.bot {
  align-self: flex-start; background: #fff; color: var(--text-1);
  border: 1px solid var(--card-border); border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.tutor-msg.bot.off { background: #fffbeb; border-color: #fcd34d; color: #92400e; }
.tutor-msg-when {
  display: block; margin-top: 4px; font-size: 10.5px; font-weight: 600; opacity: .65;
}
.tutor-notice {
  align-self: center; text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-3); background: #faf9fe;
  border: 1px dashed rgba(124,58,237,0.2); border-radius: 999px; padding: 6px 14px;
}
.tutor-loading { color: var(--text-3); font-size: 13px; text-align: center; }
.tutor-typing { display: flex; gap: 4px; align-items: center; min-height: 20px; }
.tutor-typing i {
  width: 7px; height: 7px; border-radius: 50%; display: block;
  background: var(--accent-violet); opacity: .4;
  animation: tutorDot 1s infinite;
}
.tutor-typing i:nth-child(2) { animation-delay: .18s; }
.tutor-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes tutorDot {
  0%, 100% { opacity: .25; transform: translateY(0); }
  45%      { opacity: 1; transform: translateY(-3px); }
}
.tutor-form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff; border-top: 1px solid var(--card-border);
}
.tutor-form textarea {
  flex: 1; min-width: 0; resize: none;
  font-family: var(--ui); font-size: 14px; color: var(--text-0);
  padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid #e2dff4; background: #fff;
}
.tutor-form textarea:focus {
  outline: none; border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.tutor-form .btn { flex: 0 0 auto; }

/* ---------- Tutor: historial por tema ---------- */
.tutor-hist-topic { margin-bottom: 14px; padding: 0; overflow: hidden; }
.tutor-hist-topic summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 16px 20px; font-size: 14.5px; font-weight: 800; color: var(--text-0);
}
.tutor-hist-topic summary::-webkit-details-marker { display: none; }
.tutor-hist-topic summary:hover { background: #faf9fe; }
.tutor-hist-count {
  margin-left: auto; font-size: 11px; font-weight: 800;
  background: #f5f3ff; color: var(--accent-violet);
  border: 1px solid rgba(124,58,237,0.22); border-radius: 999px; padding: 3px 10px;
}
.tutor-hist-msgs {
  display: flex; flex-direction: column; gap: 8px; padding: 4px 20px 12px;
}
.tutor-hist-more { padding: 0 20px 16px; }
.tutor-hist-more .btn { font-size: 12.5px; }

/* ---------- Métricas de aprendizaje ---------- */
.pf-profile-links { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 14px; }
.pf-profile-links .btn { text-decoration: none; }
.pf-mastery {
  font-size: 11px; font-weight: 800; border-radius: 999px;
  padding: 3px 10px; border: 1px solid;
}
.pf-mastery.novato { background: #faf9fe; color: var(--text-2); border-color: #e2dff4; }
.pf-mastery.en-progreso { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.pf-mastery.dominado { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }
.pf-theory-chip {
  font-size: 11px; font-weight: 800; border-radius: 999px;
  padding: 3px 10px; border: 1px solid;
}
.pf-theory-chip.ok { background: #ecfdf5; color: #047857; border-color: #6ee7b7; }
.pf-theory-chip.pending { background: #fffbeb; color: #92400e; border-color: #fcd34d; }

/* ---------- Lectura activa: marks estilo notes-web ---------- */
.pf-lesson-content mark.study-mark {
  background: rgba(250, 204, 21, 0.32);          /* pregunta pendiente: amarillo */
  border-bottom: 2px solid #eab308;
  color: inherit; padding: 0 1px; border-radius: 3px;
  cursor: help;
  transition: background .15s;
}
.pf-lesson-content mark.study-mark:hover { background: rgba(250, 204, 21, 0.55); }
.pf-lesson-content mark.study-mark.k-question.s-answered {
  background: rgba(96, 165, 250, 0.26); border-bottom-color: #3b82f6;
}
.pf-lesson-content mark.study-mark.k-question.s-answered:hover { background: rgba(96,165,250,0.45); }
.pf-lesson-content mark.study-mark.k-note {
  background: rgba(52, 211, 153, 0.24); border-bottom-color: #10b981;
}
.pf-lesson-content mark.study-mark.k-note:hover { background: rgba(52,211,153,0.42); }
.pf-lesson-content mark.study-mark.k-refine {
  background: rgba(167, 139, 250, 0.26); border-bottom-color: #8b5cf6;
}
.pf-lesson-content mark.study-mark.k-refine:hover { background: rgba(167,139,250,0.45); }
/* dentro de <pre> oscuro el texto del mark debe seguir legible */
.pf-lesson-content pre mark.study-mark { color: #1e1e2e; }
.pf-lesson-content mark.study-mark.flash { animation: studyFlash 1.2s ease-out; }
@keyframes studyFlash {
  0% { box-shadow: 0 0 0 6px rgba(124,58,237,0.35); }
  100% { box-shadow: 0 0 0 0 rgba(124,58,237,0); }
}

/* ---------- Lectura activa: popup de selección ---------- */
.study-pop {
  position: absolute; z-index: 70;
  display: flex; gap: 4px; padding: 5px;
  background: #fff; border: 1px solid var(--card-border);
  border-radius: 12px; box-shadow: 0 10px 32px rgba(30,20,60,0.22);
  animation: studyPopIn .14s ease-out;
}
@keyframes studyPopIn {
  from { transform: translateY(4px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.study-pop button {
  font-family: var(--ui); font-size: 12.5px; font-weight: 700;
  color: var(--text-1); background: none; border: none; cursor: pointer;
  padding: 7px 10px; border-radius: 8px; white-space: nowrap;
}
.study-pop button:hover { background: #f5f3ff; color: var(--accent-violet); }

/* ---------- Lectura activa: FAB + panel ---------- */
.study-fab {
  position: fixed; right: 16px; bottom: 16px; z-index: 54;
  display: flex; align-items: center; gap: 7px;
  font-family: var(--ui); font-size: 14px; font-weight: 800; cursor: pointer;
  color: #5b21b6; background: #fff;
  border: 1.5px solid rgba(124,58,237,0.32); border-radius: 999px;
  padding: 10px 16px; box-shadow: 0 8px 24px rgba(109,40,217,0.22);
}
.study-fab:hover { background: #faf5ff; transform: translateY(-1px); }
.study-fab b {
  font-size: 11.5px; background: var(--accent-gradient); color: #fff;
  border-radius: 999px; padding: 1px 8px;
}
body.study-open .study-fab { display: none; }

.study-panel {
  position: fixed; z-index: 55;
  display: flex; flex-direction: column;
  background: var(--bg-0); border: 1px solid var(--card-border);
  box-shadow: 0 -12px 40px rgba(30,20,60,0.22);
  /* mobile-first: bottom sheet */
  left: 0; right: 0; bottom: 0; max-height: 62vh;
  border-radius: 18px 18px 0 0;
  animation: studySheetIn .2s ease-out;
}
@keyframes studySheetIn {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@media (min-width: 1100px) {
  /* desktop: panel lateral estilo notes-web (~340px) */
  .study-panel {
    left: auto; top: 0; bottom: 0; right: 0;
    width: 348px; max-height: none;
    border-radius: 0; border-left: 1px solid var(--card-border);
    box-shadow: -18px 0 48px rgba(30,20,60,0.18);
    animation: tutorIn .22s ease-out;
  }
  body.study-open .pf-main { padding-right: 372px; }
}
@media (prefers-reduced-motion: reduce) {
  .study-panel, .study-pop { animation: none; }
  .pf-lesson-content mark.study-mark.flash { animation: none; }
}
.study-panel-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  background: #fff; border-bottom: 1px solid var(--card-border);
  border-radius: inherit; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.study-panel-title { font-size: 14.5px; font-weight: 800; color: var(--text-0); white-space: nowrap; }
.study-panel-lesson {
  font-size: 11.5px; font-weight: 700; color: var(--accent-violet);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.study-close {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid #e2dff4; background: #fff; color: var(--text-2);
  font-size: 13px; cursor: pointer;
}
.study-close:hover { color: var(--error); border-color: rgba(225,29,72,0.3); }
.study-notice {
  margin: 10px 14px 0; padding: 8px 14px; border-radius: 10px;
  background: #fffbeb; border: 1px solid #fcd34d; color: #92400e;
  font-size: 12.5px; font-weight: 600; line-height: 1.5;
}
.study-list { flex: 1; overflow-y: auto; padding: 12px 14px 18px; }
.study-empty {
  color: var(--text-3); font-size: 13px; line-height: 1.65; text-align: center;
  padding: 18px 8px; margin: 0;
}
.study-empty strong { color: var(--text-2); }

/* items del panel */
.study-item {
  background: #fff; border: 1px solid var(--card-border);
  border-left: 4px solid #eab308;
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.study-item.k-question.s-answered { border-left-color: #3b82f6; }
.study-item.k-note { border-left-color: #10b981; }
.study-item.k-refine { border-left-color: #8b5cf6; }
.study-item.flash { animation: studyFlash 1.2s ease-out; }
.study-item-head {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px;
}
.study-item-kind { font-size: 12px; font-weight: 800; color: var(--text-1); }
.study-when { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--text-3); }
.study-chip {
  font-size: 10.5px; font-weight: 800; border-radius: 999px;
  padding: 2px 8px; border: 1px solid;
}
.study-chip.pending { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.study-chip.answered { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }
.study-chip.lost { background: #fff1f2; color: #be123c; border-color: #fda4af; }
.study-anchor-quote {
  margin: 0 0 8px; padding: 6px 10px; font-size: 12px; line-height: 1.55;
  color: var(--text-2); font-style: italic;
  background: #faf9fe; border-left: 3px solid #dcd9ec; border-radius: 0 8px 8px 0;
}
.study-item .study-anchor-quote[data-act="jump"] { cursor: pointer; }
.study-item .study-anchor-quote[data-act="jump"]:hover { border-left-color: var(--accent-violet); }
.study-item-body { font-size: 13px; line-height: 1.6; color: var(--text-1); white-space: pre-wrap; word-break: break-word; }
.study-answer { margin-top: 8px; }
.study-answer summary {
  cursor: pointer; font-size: 12px; font-weight: 800; color: #1d4ed8;
  list-style: none;
}
.study-answer summary::-webkit-details-marker { display: none; }
.study-answer summary::before { content: '▸ '; }
.study-answer[open] summary::before { content: '▾ '; }
.study-answer-body {
  margin-top: 6px; padding: 10px 12px; border-radius: 10px;
  background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a8a;
  font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
}
.study-answer-wait {
  margin: 8px 0 0; font-size: 12px; font-weight: 600; color: #92400e;
  background: #fffbeb; border: 1px dashed #fcd34d; border-radius: 8px; padding: 6px 10px;
}
.study-refine-mine, .study-refine-orig {
  font-size: 13px; line-height: 1.6; color: var(--text-1);
  white-space: pre-wrap; word-break: break-word;
}
.study-refine-orig { color: var(--text-2); font-style: italic; }
.study-refine-tag {
  display: block; font-size: 10.5px; font-weight: 800; font-style: normal;
  color: #6d28d9; margin-bottom: 2px;
}
.study-item-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.study-linkbtn {
  background: none; border: none; cursor: pointer; padding: 2px 0;
  font-family: var(--ui); font-size: 12px; font-weight: 700; color: var(--accent-violet);
}
.study-linkbtn:hover { text-decoration: underline; }
.study-iconbtn {
  background: none; border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; font-size: 13px; padding: 3px 7px; opacity: .7;
}
.study-iconbtn:hover { opacity: 1; background: #faf9fe; border-color: #e2dff4; }

/* compose (nueva anotación) */
.study-compose {
  background: #fff; border: 1.5px solid rgba(124,58,237,0.3);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(109,40,217,0.12);
}
.study-compose-head { font-size: 13px; font-weight: 800; color: var(--text-0); margin-bottom: 6px; }
.study-compose textarea, .study-item textarea {
  width: 100%; resize: vertical; min-height: 60px;
  font-family: var(--ui); font-size: 13.5px; color: var(--text-0);
  padding: 9px 12px; border-radius: 10px;
  border: 1.5px solid #e2dff4; background: #fff;
}
.study-compose textarea:focus, .study-item textarea:focus {
  outline: none; border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.study-compose-wait { margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--text-3); }
.study-compose-err {
  margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--error);
}
.study-compose-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px;
}
.study-compose-actions .btn { padding: 7px 14px; font-size: 12.5px; }
.study-spin {
  display: inline-block; width: 12px; height: 12px; vertical-align: -2px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  border-radius: 50%; animation: studySpin .7s linear infinite;
}
@keyframes studySpin { to { transform: rotate(360deg); } }

/* ---------- Lectura activa: badge "pasala a papel" ---------- */
.study-paper-badge {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 10.5px; font-weight: 800; font-style: normal;
  color: #92400e; background: #fffbeb;
  border: 1px dashed #fcd34d; border-radius: 999px; padding: 2px 9px;
  cursor: help; white-space: nowrap;
}

/* ---------- Mermaid: diagramas de la teoría ---------- */
.study-mermaid {
  margin: 16px 0; padding: 14px; text-align: center;
  background: #fff; border: 1px solid var(--card-border);
  border-radius: 12px; overflow-x: auto;
}
.study-mermaid svg { max-width: 100%; height: auto; }
/* degradado: si mermaid falla, el fuente queda como bloque legible */
.pf-lesson-content pre.study-mermaid-src { border-style: dashed; }

/* 320px: apretar paddings */
@media (max-width: 360px) {
  .pf-main { padding: 16px 10px 48px; }
  .pf-card { padding: 16px; }
  .pf-code { font-size: 12px; padding: 12px 14px; }
  .tutor-msg { max-width: 94%; }
  .study-pop button { padding: 6px 7px; font-size: 12px; }
}
