/* ============================================================================
   CompuClub — Dashboard (admin + portal alumno)
   Tema "Aula" (claro): índigo de marca (#2E0583) sobre blanco. Profesional,
   educativo, claro y accesible. Sin neón ni rejilla blueprint.
   Mantiene los nombres de clase/tokens que usan app.js / student.js.
   ========================================================================== */

/* Tokens compartidos (paleta, tipografía, sombras, motion). Incluye las fuentes.
   Única fuente de verdad: editar valores en tokens.css, no aquí. */
@import url('/tokens.css');

* { box-sizing: border-box; }
/* Accesibilidad (WCAG 2.4.7 — Focus Visible): anillo de foco por TECLADO en todo lo interactivo.
   Antes solo lo tenían inputs/select; botones, enlaces y nav quedaban sin indicador al tabular.
   `:focus-visible` → no aparece al hacer clic con ratón. `:where()` = especificidad 0 para no pisar
   los estilos de foco propios de inputs/select. */
:where(button, a, [role="button"], [tabindex]:not([tabindex="-1"]), summary, label.switch):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r);
}
/* El atributo [hidden] debe ganar a cualquier display de las clases (flex/inline-flex), si no
   elementos como el banner de previsualización o el chip de usuario se quedarían siempre visibles. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
/* Móvil/zoom: el navegador no infla tipografías por su cuenta (el layout ya es fluido) y el
   documento nunca desborda en horizontal (clip: sin scroller fantasma; hidden como fallback). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; overflow-x: clip; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
/* malla de plano tenue en todo el panel */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 130% 90% at 50% 0%, #000 30%, transparent 78%);
}
/* 100dvh: en móvil la barra de URL aparece/desaparece; dvh sigue al viewport real (100vh = fallback). */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; position: relative; z-index: 1; }

::selection { background: var(--accent); color: var(--ink-950); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ink-950); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border: 2px solid var(--ink-950); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 58px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--ink-950) 72%, transparent);
  backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: 0 1px 0 rgba(20,22,40,.03), 0 6px 18px -14px rgba(20,22,40,.28);
  flex: 0 0 auto; position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.logo {
  font-size: 0; width: 32px; height: 32px; flex: 0 0 auto;
  background: linear-gradient(150deg, #ffffff, var(--indigo-50, #f3f1fb));
  border: 1px solid var(--border-strong); border-radius: 8px;
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.logo svg { width: 20px; height: 20px; }
#courseSelect {
  font: inherit; font-weight: 600; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 10px; max-width: 280px; cursor: pointer;
  transition: border-color 160ms var(--ease-out);
}
#courseSelect:hover { border-color: var(--border-strong); }
#courseSelect:focus-visible { outline: none; border-color: var(--accent); }
.tabs { display: flex; gap: 2px; margin: 0 auto; }
.tab {
  font: inherit; font-weight: 500; border: 0; background: transparent; color: var(--text-soft);
  padding: 7px 15px; border-radius: 6px; cursor: pointer;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out), transform 120ms var(--ease-out);
}
.tab:hover { background: var(--bg-soft); color: var(--text); }
.tab:active { transform: scale(0.97); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
/* Pestañas-enlace de gestión (Pagos, Página pública): abren páginas propias (no vistas SPA). */
.tablink {
  font: inherit; font-weight: 500; color: var(--text-soft); text-decoration: none;
  padding: 7px 13px; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out), transform 120ms var(--ease-out);
}
.tablink:hover { background: var(--bg-soft); color: var(--text); }
.tablink:active { transform: scale(0.97); }
.tab-sep { width: 1px; height: 20px; align-self: center; background: var(--border); margin: 0 5px; flex: 0 0 auto; }
.t-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: 0 0 auto; transition: background .3s, box-shadow .3s; }
.t-dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.t-dot.warn { background: #e0a32e; box-shadow: 0 0 0 3px color-mix(in srgb, #e0a32e 22%, transparent); }
.t-dot.off { background: var(--muted); }
.status { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.dot.off { background: var(--red); }
.muted { color: var(--muted); font-size: 12.5px; font-family: var(--mono); letter-spacing: .04em; }

/* portal del estudiante (F3) */
.progress-actions { display: flex; align-items: center; gap: 10px; margin: 24px 0 8px; padding-top: 16px; border-top: 1px solid var(--border); }

/* gestión admin (F4) — botones con feedback de presión */
.primary-btn {
  padding: 9px 16px; border: 0; border-radius: 8px; background: var(--accent); color: var(--ink-950);
  font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer;
  transition: transform 140ms var(--ease-out), box-shadow 200ms var(--ease-out), background 180ms;
}
.primary-btn:hover { background: var(--blue); box-shadow: 0 10px 22px -10px rgba(46,5,131,.55); }
.primary-btn:active { transform: scale(0.97); }
.mini-btn {
  padding: 5px 11px; border: 1px solid var(--border-strong); border-radius: 6px; background: transparent;
  color: var(--text-soft); font: inherit; font-size: 12.5px; cursor: pointer; margin-left: 4px;
  transition: transform 130ms var(--ease-out), border-color 160ms, color 160ms, background 160ms;
}
.mini-btn:hover { background: var(--bg-soft); color: var(--text); border-color: var(--accent); }
.mini-btn:active { transform: scale(0.96); }
.mini-btn.danger:hover { background: color-mix(in srgb, var(--red) 14%, transparent); border-color: var(--red); color: var(--red); }
.row-actions { white-space: nowrap; text-align: right; }
.admin-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; margin: 18px 0; background: linear-gradient(180deg, var(--ink-850), var(--ink-900)); box-shadow: var(--shadow-sm); }
.admin-card h3 { margin: 0 0 14px; font-size: 1.05rem; font-family: var(--display); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; font-weight: 600; }
.form-grid input, .form-grid select, #assignSelect {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--ink-900); color: inherit; font: inherit; font-size: .9rem; font-weight: 400;
  transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.form-grid input:focus-visible, .form-grid select:focus-visible, #assignSelect:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.assign-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; }
.chk-grid { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 4px 0; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; font-weight: 400; cursor: pointer; }
.chk accent-color { accent-color: var(--accent); }
.chk input { accent-color: var(--accent); }
.invite-link { margin-top: 16px; padding: 13px 15px; border: 1px solid color-mix(in srgb,var(--green) 45%,transparent); border-radius: 8px; background: color-mix(in srgb, var(--green) 8%, transparent); font-size: .85rem; }
.link-row { display: flex; gap: 8px; margin-top: 8px; }
.link-row input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--ink-900); color: inherit; font-size: .82rem; font-family: var(--mono); }

/* chip de usuario + cerrar sesión */
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding-left: 10px; margin-left: 4px; border-left: 1px solid var(--border); }
.user-name { font-size: 12.5px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn { font: inherit; font-size: 12px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: transparent; color: var(--text-soft); cursor: pointer; transition: transform 130ms var(--ease-out), border-color 160ms, color 160ms, background 160ms; }
.logout-btn:hover { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: var(--red); color: var(--red); }
.logout-btn:active { transform: scale(0.96); }
/* enlace a la consola de plataforma (solo superadmin) — acento distinto para separarlo de "Salir" */
.sa-link { text-decoration: none; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.sa-link:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- toggle Admin ⇄ Alumno (segmented control) ---------- */
.viewmode {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px; border-radius: 9px;
  background: var(--bg-soft); border: 1px solid var(--border);
}
.vm-label {
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); padding: 0 6px 0 4px;
}
.vm-btn {
  font: inherit; font-size: 12.5px; font-weight: 600; line-height: 1;
  border: 0; background: transparent; color: var(--text-soft);
  padding: 6px 13px; border-radius: 6px; cursor: pointer;
  transition: background 160ms var(--ease-out), color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), transform 120ms var(--ease-out);
}
.vm-btn:hover { color: var(--text); }
.vm-btn:active { transform: scale(0.96); }
.vm-btn.active {
  background: var(--panel); color: var(--accent);
  box-shadow: 0 1px 2px rgba(20,22,40,.12), inset 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent);
}
/* En la previsualización de alumno, el botón activo se marca con el índigo de marca. */
body.mode-student .vm-btn.active { color: var(--ink-950); background: var(--accent); box-shadow: 0 2px 8px -2px rgba(46,5,131,.5); }

/* ---------- banner de previsualización de alumno ---------- */
.preview-banner {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px 20px; flex: 0 0 auto; position: relative; z-index: 4;
  background: color-mix(in srgb, var(--accent) 9%, var(--panel));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  color: var(--accent); font-size: 13px;
  animation: fade-rise 260ms var(--ease-out) both;
}
.preview-banner svg { flex: 0 0 auto; opacity: .9; }
.preview-banner span { color: var(--text-soft); }
.preview-banner b { color: var(--accent); font-weight: 700; }
.preview-exit {
  margin-left: auto; flex: 0 0 auto; font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
  background: var(--accent); color: var(--ink-950); border: 0;
  transition: transform 130ms var(--ease-out), background 160ms;
}
.preview-exit:hover { background: var(--blue); }
.preview-exit:active { transform: scale(.96); }

/* ---------- migas de pan ---------- */
.breadcrumb {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin: 0 0 14px; font-size: 12.5px; color: var(--muted);
}
.crumb { font-weight: 500; color: var(--text-soft); }
.crumb.current { color: var(--accent); font-weight: 600; }
.crumb-sep { color: var(--border-strong); user-select: none; }

/* Ruta local (solo visible en modo Admin); se resalta como dato técnico/sensible. */
code.loc {
  font-family: var(--mono); font-size: 12px; color: var(--text-soft);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 6px; word-break: break-all;
}
.pill-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 2px 0 4px; }

/* ---------- layout cuerpo ---------- */
.body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 290px; flex: 0 0 auto; border-right: 1px solid var(--border);
  background: var(--bg-sidebar); overflow-y: auto; padding: 12px 10px 40px;
}
.sidebar-head { padding: 8px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.tree-course { font-family: var(--mono); font-weight: 600; font-size: 11.5px; letter-spacing: .14em; color: var(--accent); text-transform: uppercase; }
.main { flex: 1; overflow-y: auto; padding: 34px 46px 96px; min-width: 0; scroll-behavior: smooth; }
.main-wrap { max-width: 900px; margin: 0 auto; animation: fade-rise 320ms var(--ease-out) both; }
@keyframes fade-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- árbol ---------- */
.tree { font-size: 13.5px; }
.tnode { user-select: none; }
.trow {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 6px; cursor: pointer; color: var(--text-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background 140ms var(--ease-out), color 140ms var(--ease-out);
}
.trow:hover { background: var(--bg-soft); color: var(--text); }
.trow.sel { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.tcaret { width: 14px; display: inline-block; text-align: center; color: var(--muted); font-size: 10px; flex: 0 0 auto; transition: transform 160ms var(--ease-out); }
.ticon { width: 16px; text-align: center; flex: 0 0 auto; }
.tlabel { overflow: hidden; text-overflow: ellipsis; }
.tchildren { margin-left: 14px; border-left: 1px solid var(--border); padding-left: 2px; }
.tbadge { margin-left: auto; font-size: 10px; font-family: var(--mono); padding: 1px 7px; border-radius: 10px; flex: 0 0 auto; }
.tbadge.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.tbadge.pend { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.tsection { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 14px 10px 5px; font-weight: 600; }

/* ---------- tarjetas / resumen ---------- */
h1.page-title { font-family: var(--display); font-weight: 700; font-size: 31px; margin: 0 0 7px; letter-spacing: -.02em; line-height: 1.15; }
.page-sub { color: var(--text-soft); margin: 0 0 26px; font-size: 15px; max-width: 64ch; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 14px; margin-bottom: 30px; }
.card {
  position: relative; background: linear-gradient(180deg, var(--panel), var(--ink-900));
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 17px 19px; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 220ms var(--ease-out), transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}
.card:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card::before { content: ''; position: absolute; top: 0; left: 0; width: 34px; height: 2px; background: linear-gradient(90deg, var(--accent), transparent); border-radius: 0 0 2px 0; }
.card .num { font-family: var(--display); font-size: 29px; font-weight: 700; line-height: 1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.card .num.green { color: var(--green); } .card .num.amber { color: var(--amber); }
.card .lbl { color: var(--text-soft); font-size: 12px; font-family: var(--mono); letter-spacing: .04em; margin-top: 7px; text-transform: uppercase; }
.card .lbl.green { color: var(--green); }
.card .lbl.amber { color: var(--amber); }

.meta-grid {
  display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px;
  margin: 10px 0 26px; padding: 16px 20px;
  background: var(--bg-sidebar); border: 1px solid var(--border); border-radius: 12px;
  align-items: center;
}
.meta-grid dt { color: var(--muted); font-size: 11.5px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; align-self: center; }
.meta-grid dd { margin: 0; font-size: 13.5px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 11px; font-size: 11.5px; font-weight: 600; font-family: var(--mono); letter-spacing: .01em; white-space: nowrap; }
.pill.green { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.pill.amber { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); }
.pill.blue { background: var(--accent-soft); color: var(--accent); }
.pill.gray { background: var(--bg-soft); color: var(--text-soft); border: 1px solid var(--border); }

/* ---------- secciones modulo en resumen ---------- */
.mod-block { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out); }
.mod-block:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.mod-head { background: linear-gradient(180deg, var(--bg-soft), var(--bg-sidebar)); padding: 12px 16px; font-weight: 600; font-family: var(--display); display: flex; align-items: center; gap: 10px; }
.mod-head .ord { color: var(--accent); font-family: var(--mono); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 9px; border-radius: 20px; background: var(--accent-soft); }
.mod-lessons { display: flex; flex-direction: column; }
.mod-lesson { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); cursor: pointer; transition: background 140ms var(--ease-out), padding-left 140ms var(--ease-out); }
.mod-lesson:hover { background: var(--accent-soft); padding-left: 20px; }
.mod-lesson .lt { flex: 1; }
.mod-lesson .lid { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 34px; }
.mod-lesson .lt { flex: 1; }
.dfam { font-size: 12.5px; color: var(--text-soft); padding: 9px 15px; background: var(--bg-sidebar); border-top: 1px dashed var(--border); font-family: var(--mono); }

/* ---------- tabla temario ---------- */
table.temario { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); font-variant-numeric: tabular-nums; }
table.temario th, table.temario td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--border); }
table.temario tbody tr:last-child td { border-bottom: 0; }
table.temario thead th { color: var(--muted); font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; background: var(--bg-sidebar); }
table.temario tr.modrow td { background: var(--bg-soft); font-weight: 700; font-family: var(--display); color: var(--text); }
table.temario td.lid { font-family: var(--mono); font-size: 12px; color: var(--muted); }
table.temario tr.lessonrow { transition: background 140ms var(--ease-out); }
table.temario tr.lessonrow:hover td { background: var(--accent-soft); cursor: pointer; }
.stars { color: var(--amber); letter-spacing: 1px; }

/* ---------- contenido (markdown) ---------- */
.content h1 { font-family: var(--display); font-weight: 700; font-size: 26px; margin: .2em 0 .4em; letter-spacing: -.01em; }
.content h2 { font-family: var(--display); font-weight: 600; font-size: 20px; margin: 1.3em 0 .5em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.content h3 { font-family: var(--display); font-weight: 600; font-size: 16.5px; margin: 1.1em 0 .4em; }
.content p { margin: .55em 0; }
.content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb,var(--accent) 35%,transparent); }
.content a:hover { border-bottom-color: var(--accent); }
/* Imágenes de lección (renders/planos de ambos cursos): centradas y con tamaño legible recomendado
   — tope de ancho y de alto para que las verticales (p. ej. la torre) no dominen la columna. */
.content img {
  display: block; margin: 16px auto 34px;
  max-width: min(100%, 640px); max-height: 60vh;
  width: auto; height: auto;
  border-radius: var(--radius); border: 1px solid var(--border);
}
.content code { font-family: var(--mono); font-size: 12.5px; background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; color: var(--accent); }
.content pre { background: var(--bg-soft); padding: 14px 16px; border-radius: var(--radius); overflow-x: auto; border: 1px solid var(--border); }
.content pre code { background: none; padding: 0; color: var(--text); }
.content blockquote { margin: .6em 0; padding: 8px 16px; border-left: 3px solid var(--accent); color: var(--text-soft); background: var(--bg-sidebar); border-radius: 0 6px 6px 0; }
.content table { border-collapse: collapse; width: 100%; margin: .6em 0; font-size: 13.5px; }
.content th, .content td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.content th { background: var(--bg-soft); font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.content ul, .content ol { padding-left: 1.4em; }
.rawtext { white-space: pre-wrap; font-family: var(--mono); font-size: 12.5px; }

/* ---------- panel recursos en leccion ---------- */
.lesson-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 6px; }
.lesson-plano { margin: 8px 0 20px; text-align: center; }
.lesson-plano img {
  display: inline-block;
  max-width: min(100%, 640px); max-height: 60vh; width: auto; height: auto;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--ink-850);
}
.res-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 22px; }
.res-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-family: var(--mono);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 13px; color: var(--text); text-decoration: none;
  transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out), transform 130ms var(--ease-out);
}
.res-chip:hover { border-color: var(--accent); color: var(--accent); }
.res-chip:active { transform: scale(0.97); }
.res-chip.missing { color: var(--red); border-style: dashed; opacity: .85; }
.res-chip.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.res-chip.primary:hover { color: #fff; filter: brightness(1.06); }

/* ---------- portal alumno: nav de temario + barra de documentos ---------- */
.sp-navlinks { margin-top: 12px; }
.sp-syllabus-btn {
  width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
  border-radius: var(--radius-lg); transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.sp-syllabus-btn:hover { border-color: var(--accent); }
.sp-docsbar { margin: 4px 0 18px; padding: 14px 16px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.sp-docsbar-title { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 9px; }
.doc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; text-decoration: none;
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 5px 13px; color: var(--text);
  transition: border-color 150ms var(--ease-out), color 150ms var(--ease-out);
}
.doc-chip:hover { border-color: var(--accent); color: var(--accent); }
.tlesson { background: none; border: 0; padding: 0; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.tlesson:hover { color: var(--accent); text-decoration: underline; }
.tlink { font-family: var(--mono); font-size: 12px; color: var(--accent); text-decoration: none; white-space: nowrap; }
.tlink:hover { text-decoration: underline; }

/* ---------- explorador / faltantes ---------- */
.explorer-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 26px; align-items: start; }
.filetree { font-family: var(--mono); font-size: 12.5px; }
.filetree .fdir { color: var(--text); font-weight: 600; }
.filetree .ffile { color: var(--text-soft); }
.filetree .frow { display: flex; gap: 6px; padding: 1px 0; }
.filetree .fsize { margin-left: auto; color: var(--muted); }
.filetree .findent { padding-left: 18px; border-left: 1px solid var(--border); margin-left: 7px; }
.missing-item { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.missing-item .mrole { margin-left: auto; }
.section-title { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }

.meta-long { font-size: 13px; color: var(--text-soft); margin: 8px 0 0; }
/* ---------- estados: cargando / vacío ---------- */
.spinner {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--muted); padding: 44px 30px; font-family: var(--mono); font-size: 13px; letter-spacing: .02em;
}
.spinner::before {
  content: ''; width: 18px; height: 18px; flex: 0 0 auto; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 720ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--muted); padding: 48px 32px; text-align: center; font-family: var(--mono);
  font-size: 13px; line-height: 1.65;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--bg-soft);
  animation: fade-rise 320ms var(--ease-out) both;
}
.empty::before {
  content: ''; width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232e0583' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7l9-4 9 4-9 4-9-4z'/%3E%3Cpath d='M3 7v10l9 4 9-4V7'/%3E%3Cpath d='M12 11v10'/%3E%3C/svg%3E") center / 24px no-repeat;
}
.empty code { font-family: var(--mono); font-size: 12px; background: var(--panel); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; color: var(--accent); }

/* skeleton shimmer — utilidad para placeholders de carga (CSS puro, opt-in) */
.skel {
  position: relative; overflow: hidden; border-radius: 8px;
  background: var(--bg-soft); min-height: 14px;
}
.skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--panel) 70%, transparent), transparent);
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }

/* ---------- vista Salud ---------- */
.health-top { display: flex; align-items: center; gap: 22px; margin: 8px 0 4px; }
.score-ring {
  flex: 0 0 auto; width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(closest-side, var(--bg) 79%, transparent 80% 100%),
    conic-gradient(var(--c) calc(var(--c-pct, 0) * 1%), var(--border) 0);
  border: 6px solid var(--c); color: var(--c);
}
.score-num { font-family: var(--display); font-size: 34px; font-weight: 800; line-height: 1; }
.score-lbl { font-size: 10.5px; color: var(--text-soft); text-align: center; margin-top: 3px; font-family: var(--mono); }
.score-mini { font-weight: 700; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.gov-matrix td:first-child { font-weight: 600; }
.gov-matrix th:not(:first-child), .gov-matrix td:not(:first-child) { text-align: center; }

.finding-group { font-family: var(--display); font-size: 16px; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.finding { border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: var(--radius); padding: 13px 15px; margin-bottom: 10px; background: var(--bg-soft); }
.finding-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.finding-title { font-weight: 600; }
.finding-link { margin-left: auto; color: var(--accent); text-decoration: none; font-size: 16px; }
.finding p { margin: 3px 0; font-size: 13px; color: var(--text-soft); }
.finding p b { color: var(--text); font-weight: 600; }

/* ---------- responsive (la dashboard era de ancho fijo) ---------- */
@media (max-width: 1024px) {
  .main { padding: 26px 28px 80px; }
  .sidebar { width: 248px; }
  .explorer-cols { grid-template-columns: 1fr; gap: var(--sp-5); }
}
@media (max-width: 760px) {
  /* topbar: deja envolver y centra; la barra de pestañas se desplaza en horizontal */
  .topbar { flex-wrap: wrap; height: auto; min-height: 58px; padding: 8px 14px; gap: 10px; row-gap: 8px; }
  .brand { min-width: 0; flex: 1 1 auto; }
  #courseSelect { max-width: 100%; flex: 1 1 auto; }
  .tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tabs::-webkit-scrollbar { height: 0; }
  .tab { flex: 0 0 auto; }
  .status { gap: 6px; }
  .muted, .vm-label { display: none; }
  /* cuerpo en columna: el árbol pasa arriba como panel desplazable */
  .body { flex-direction: column; }
  .sidebar { width: 100%; max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 10px 14px; }
  .main { padding: 22px 18px 72px; }
  .form-grid { grid-template-columns: 1fr; }
  .health-top { flex-wrap: wrap; }
  .preview-banner { padding: 8px 14px; font-size: 12.5px; }
  h1.page-title { font-size: 25px; }
}
@media (max-width: 760px) and (min-width: 521px) {
  .muted { display: inline; }
}

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

/* ---------- visor 3D interactivo ---------- */
.model3d { position: relative; display: block; width: fit-content; margin: 16px auto 34px; max-width: min(100%, 640px); line-height: 0; }
.model3d > img { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; border-radius: 10px; }
.badge-3d {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px 5px 8px; border: 0; border-radius: 999px; cursor: pointer;
  background: #2e0583; color: #fff; font: 600 12px/1 Poppins, system-ui, sans-serif;
  box-shadow: 0 2px 8px rgba(46, 5, 131, .35); transition: background .12s, transform .12s;
}
.badge-3d:hover { background: #3d11a3; transform: translateY(-1px); }
.badge-3d svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 1.6; stroke-linejoin: round; }
.model3d.on .badge-3d { display: none; }
.viewer3d { position: absolute; inset: 0; background: #f3f1fb; border-radius: 10px; overflow: hidden; }
.viewer3d canvas { display: block; touch-action: none; }
.viewer3d-load, .viewer3d-err { display: grid; place-items: center; height: 100%; color: #6e7280; font-size: 13px; line-height: 1.4; }
.viewer3d-close {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 30px; height: 30px;
  border: 0; border-radius: 50%; cursor: pointer; font-size: 13px;
  background: rgba(20, 18, 40, .6); color: #fff;
}
.viewer3d-close:hover { background: rgba(20, 18, 40, .85); }

/* ============================================================================
   PORTAL DEL ALUMNO — refresh UI/UX (scope: .student-portal)
   Solo afecta a app.html (vista de alumno). El panel de admin (index.html) NO
   lleva esta clase, así que nada de lo de aquí lo toca.
   ========================================================================== */

/* saludo en la barra superior */
.student-portal .user-name { font-weight: 600; color: var(--text); }
.student-portal .user-name::before { content: "Hola, "; color: var(--muted); font-weight: 500; }

/* lente más cálida y ancho de lectura más cómodo */
.student-portal .main { background:
  radial-gradient(1200px 380px at 100% -8%, var(--indigo-50), transparent 60%), var(--bg); }
.student-portal .main-wrap { max-width: 820px; }

/* ----- tarjeta de progreso del curso (cabecera de la barra lateral) ----- */
.student-portal .sp-progress-host { margin-top: 12px; }
.student-portal .sp-progress {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px; box-shadow: var(--shadow-sm);
}
.student-portal .sp-progress-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px; }
.student-portal .sp-progress-pct { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--accent); line-height: 1; }
.student-portal .sp-progress-frac { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }

/* barra de progreso reutilizable */
.student-portal .sp-bar { height: 8px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.student-portal .sp-bar.mini { height: 6px; width: 92px; }
.student-portal .sp-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 520ms var(--ease-out);
}

/* ----- árbol de contenido más legible ----- */
.student-portal .tmod { font-weight: 700; color: var(--text); }
.student-portal .tcount { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted); flex: 0 0 auto; }
.student-portal .tchildren .trow { padding-left: 4px; }
.student-portal .tdot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; border: 1.5px solid var(--line-strong); background: transparent; transition: background .15s, border-color .15s; }
.student-portal .trow.is-in_progress .tdot { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 35%, transparent); }
.student-portal .trow.is-completed .tdot { border-color: var(--green); background: var(--green); }
.student-portal .trow.is-completed .tlabel { color: var(--muted); }

/* ----- tira superior de lección: breadcrumb + avance global ----- */
.student-portal .sp-lesson-strip { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.student-portal .sp-strip-prog { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--accent); font-family: var(--mono); }
.student-portal .sp-lesson-num { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; }

/* ----- navegación anterior / siguiente ----- */
.student-portal .sp-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 26px 0 8px; }
.student-portal .sp-nav-btn {
  display: flex; flex-direction: column; gap: 3px; text-align: left;
  padding: 12px 15px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--panel); cursor: pointer; color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.student-portal .sp-nav-btn:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.student-portal .sp-nav-btn.next { text-align: right; align-items: flex-end; }
.student-portal .sp-nav-btn span { font-size: 11px; font-weight: 600; color: var(--accent); font-family: var(--mono); }
.student-portal .sp-nav-btn b { font-size: 13.5px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.student-portal .sp-nav-btn.ghost { border: 0; background: transparent; cursor: default; }

/* ----- estados vacíos amables ----- */
.student-portal .sp-blank { text-align: center; padding: 64px 24px; color: var(--text-soft); }
.student-portal .sp-blank-ico { font-size: 40px; margin-bottom: 12px; }
.student-portal .sp-blank h2 { font-family: var(--display); font-size: 21px; color: var(--text); margin: 0 0 6px; }
.student-portal .sp-blank p { margin: 0 auto; max-width: 42ch; font-size: 14px; }

@media (max-width: 760px) {
  .student-portal .sp-nav { grid-template-columns: 1fr; }
  .student-portal .main-wrap { max-width: 100%; }
}

/* ---------- portal alumno: progresión secuencial + árbol plegable ---------- */
.trow.tmod { cursor: pointer; user-select: none; }
.trow.tmod:hover { background: rgba(255,255,255,.05); }
.tnode.collapsed .tcaret { transform: none; }
.trow.is-locked { opacity: .5; cursor: not-allowed; }
.trow.is-locked .tlabel { text-decoration: none; }
.tbadge.lock { font-size: 11px; margin-left: auto; }
.temario tr.is-locked td { opacity: .55; }
.temario tr.is-locked .tlesson { cursor: not-allowed; }
.sp-nav-btn.is-locked { opacity: .55; }
.sp-mintime { font-size: 12.5px; color: var(--muted, #8a93a6); margin-left: 10px; }

/* ---------- Panel de contenido colapsable (botón en la barra superior) ---------- */
.sidebar-toggle {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft);
  color: var(--text); cursor: pointer; font-size: 15px; line-height: 1;
  transition: border-color 150ms var(--ease-out), background 150ms var(--ease-out);
}
.sidebar-toggle:hover { border-color: var(--accent); background: var(--bg); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#app.nav-collapsed .sidebar { display: none; }

/* ---------- Enlaces internos entre lecciones (reescritos desde .md, #5) ---------- */
a.lesson-link { color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
a.lesson-link.missing { color: var(--muted); text-decoration: line-through; cursor: default; }

/* ---------- Responsividad general: contenido visible sin desbordes ni scroll manual ---------- */
.main img, .content img, .lesson-plano img { max-width: 100%; height: auto; }
/* nada dentro de la columna de lectura puede provocar scroll horizontal de página */
.main-wrap, .content { overflow-wrap: break-word; min-width: 0; }
.content iframe { max-width: 100%; }
.res-chip { max-width: 100%; }
.res-chip, .doc-chip { min-width: 0; }
.res-chip { overflow: hidden; }
@media (max-width: 900px) {
  table.temario, .content table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .form-grid, .chk-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .row-actions { white-space: normal; }
  .row-actions .mini-btn { margin: 2px 4px 2px 0; }
}

/* ---------- Celular vertical (≤ 480px): lectura cómoda, todo apilable, cero desbordes ---------- */
@media (max-width: 480px) {
  .main { padding: 18px 14px 64px; }
  h1.page-title { font-size: 22px; }
  .page-sub { font-size: 14px; margin-bottom: 18px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { gap: 8px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); gap: 10px; }
  .card { padding: 13px 14px; }
  .card .num { font-size: 24px; }
  .meta-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .meta-grid dt { margin-top: 8px; }
  /* acciones de progreso y navegación entre lecciones: en columna, botón cómodo al pulgar */
  .progress-actions { flex-wrap: wrap; row-gap: 8px; }
  .progress-actions .primary-btn { flex: 1 1 100%; }
  .sp-mintime { margin-left: 0; flex-basis: 100%; }
  .sp-lesson-strip { flex-direction: column; align-items: flex-start; gap: 8px; }
  .assign-row, .form-actions, .link-row { flex-wrap: wrap; }
  .admin-card { padding: 14px; }
  .student-portal .sp-nav-btn b { font-size: 12.5px; }
  .sidebar { max-height: 45vh; max-height: 45dvh; }
  .viewer3d-close, .badge-3d { top: 6px; right: 6px; }
}
