/* ==========================================================================
   Spaces — hoja de estilos
   Interfaz limpia, clara y sin adornos: fondo blanco, tipografia del sistema,
   un unico acento azul y superficies suaves. Soporta tema claro y oscuro.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-soft: #f8f8fb;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --surface-3: #eceef3;
  --border: #e7e8ee;
  --border-strong: #d7d9e2;
  --text: #191a20;
  --text-soft: #4f515c;
  --muted: #83858f;
  --primary: #4d6bfe;
  --primary-hover: #3d5bf0;
  --primary-soft: rgba(77, 107, 254, 0.09);
  --primary-border: rgba(77, 107, 254, 0.28);
  --danger: #dc3b40;
  --danger-soft: rgba(220, 59, 64, 0.09);
  --warn: #a8620a;
  --warn-soft: #fdf6e6;
  --warn-border: #f0dfb8;
  --ok: #12874a;
  --ok-soft: rgba(18, 135, 74, 0.1);
  --info: #2b6cb0;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(16, 17, 22, 0.05);
  --shadow: 0 10px 30px -12px rgba(16, 17, 22, 0.18), 0 2px 6px rgba(16, 17, 22, 0.04);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --topbar-h: 60px;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #17181c;
  --bg-soft: #1c1d22;
  --surface: #1f2026;
  --surface-2: #24252c;
  --surface-3: #2c2d35;
  --border: #2e2f38;
  --border-strong: #3b3d47;
  --text: #eceef4;
  --text-soft: #c2c4cf;
  --muted: #8e909c;
  --primary: #6d86ff;
  --primary-hover: #7f95ff;
  --primary-soft: rgba(109, 134, 255, 0.14);
  --primary-border: rgba(109, 134, 255, 0.36);
  --danger: #f2686c;
  --danger-soft: rgba(242, 104, 108, 0.12);
  --warn: #e0b062;
  --warn-soft: rgba(224, 176, 98, 0.1);
  --warn-border: rgba(224, 176, 98, 0.3);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.12);
  --info: #7cb0ea;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.25);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Cualquier elemento con un `display` propio en esta hoja gana al `[hidden]`
   del navegador, asi que se refuerza aqui una sola vez. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

p {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08em 0.36em;
}

a {
  color: var(--primary);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

/* ============================ barra superior ============================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--topbar-h);
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* La marca del producto es un enlace al hub del ecosistema (`/`) en todas las
   paginas. Se comporta como texto: ni azul ni subrayada. */
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: 10px;
}
.brand-link:hover .brand-text strong,
.brand-link:focus-visible .brand-text strong {
  color: var(--primary);
}
.brand-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* Blanco total en la pantalla del alumno: cuando el curso trae su propio
   logotipo (`settings.branding.logo`), la marca de la plataforma no se enseña.
   Lo decide `curso.js` con `data-marca` en el `<body>`; con el logotipo cargado
   o sin él, la barra mide lo mismo: `no-logo` y `logo` no dan saltos. */
body[data-marca='logo'] #marca-marca,
body[data-marca='logo'] #marca-texto {
  display: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.brand-mark svg {
  width: 100%;
  height: 100%;
}

/* Logotipo de marca del curso: discreto, junto al nombre y nunca un cartel.
   Cuando lo hay, sustituye a la silueta de `.brand-mark` en la barra. */
.brand-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 132px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}
.brand-text strong {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-text small {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}
.tab svg {
  width: 16px;
  height: 16px;
  opacity: 0.85;
}
.tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-3) 70%, transparent);
}
.tab[aria-selected='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.tab[aria-selected='true'] svg {
  color: var(--primary);
  opacity: 1;
}

.tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.tab-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Accion principal del visor: crear un curso con este paquete. */
.topbar-cta {
  flex: 0 0 auto;
  gap: 6px;
}
.topbar-cta svg {
  width: 15px;
  height: 15px;
}

/* Vuelta al panel del profesor. Solo se enseña si ya hay sesion iniciada, para
   no meter ruido a quien solo viene a previsualizar un paquete. */
.topbar-secondary {
  flex: 0 0 auto;
  gap: 6px;
  text-decoration: none;
}
.topbar-secondary svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
}

/* Curso de ejemplo: es la via mas corta para entender el producto, asi que se
   distingue del resto de acciones secundarias sin competir con «Crear curso»
   (que sigue siendo el boton de color pleno). */
.topbar-demo {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.topbar-demo svg {
  color: var(--primary);
}
.topbar-demo:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.topbar-demo:hover svg {
  color: #fff;
}

.instance-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 400px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.instance-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.instance-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.instance-dot.is-running {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
  animation: pulse 2s ease-in-out infinite;
}
.instance-dot.is-warn {
  background: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-soft);
}
.instance-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.chip-divider {
  width: 1px;
  height: 14px;
  background: var(--border);
  flex: 0 0 auto;
}
.chip-live {
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip-live.is-ok {
  color: var(--ok);
}
.chip-live.is-warn {
  color: var(--warn);
}
.chip-live.is-muted {
  color: var(--muted);
}
.chip-score {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-button:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.icon-button svg {
  width: 18px;
  height: 18px;
}
.icon-moon {
  display: none;
}
html[data-theme='dark'] .icon-sun {
  display: none;
}
html[data-theme='dark'] .icon-moon {
  display: block;
}

/* ============================== estructura ============================== */

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 96px;
}

.view[hidden] {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-primary {
  border-color: var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
}
.badge-ok {
  border-color: transparent;
  background: var(--ok-soft);
  color: var(--ok);
}
.badge-warn {
  border-color: var(--warn-border);
  background: var(--warn-soft);
  color: var(--warn);
}

/* Despliegue condicionado: la actividad espera a otra. */
.badge-lock {
  border-color: var(--line, rgba(127, 127, 127, 0.3));
  background: var(--surface-2, rgba(127, 127, 127, 0.08));
  color: var(--text, inherit);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

/* ================================ subir ================================ */

.hero {
  text-align: center;
  max-width: 660px;
  margin: 12px auto 30px;
}
.hero h1 {
  font-size: 32px;
  letter-spacing: -0.028em;
  margin-bottom: 12px;
}
.hero p {
  color: var(--text-soft);
  font-size: 15.5px;
}

.feature-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
}
.feature-chips li {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12.5px;
}

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 46px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
  outline: none;
}
.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone.is-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: scale(1.005);
}
.dropzone.is-busy {
  pointer-events: none;
  opacity: 0.6;
}
.dropzone-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}
.dropzone-icon svg {
  width: 26px;
  height: 26px;
}
.dropzone-title {
  font-size: 16px;
  font-weight: 600;
}
.dropzone-sub {
  color: var(--text-soft);
  font-size: 13.5px;
}
.dropzone-sub .link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dropzone-limit {
  color: var(--muted);
}
.dropzone-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.upload-progress {
  max-width: 640px;
  margin: 22px auto 0;
}
.upload-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.progress-track {
  height: 7px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.2s ease;
}

.alert {
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
}
.alert-error {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}
.alert-warn {
  border-color: var(--warn-border);
  background: var(--warn-soft);
  color: var(--warn);
}
.alert-warn strong {
  display: block;
  margin-bottom: 6px;
}
.alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.alert li + li {
  margin-top: 4px;
}

.panel {
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2,
.panel-head h3 {
  font-size: 15px;
  font-weight: 600;
}
.panel-head-wrap {
  flex-wrap: wrap;
}
.panel-head > .badge {
  margin-left: auto;
}
.panel-tools {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex-wrap: wrap;
}
.panel-tools input[type='search'] {
  width: 220px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.panel-tools input[type='search']:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Buscador de cursos por nombre («Mis cursos» del alumno y del panel). */
.course-search {
  width: 240px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.course-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.course-search-empty {
  margin-top: 18px;
  color: var(--muted);
}
@media (max-width: 640px) {
  .results-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .course-search {
    flex: 1 1 100%;
    width: 100%;
  }
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.panel-footnote {
  padding: 12px 20px 18px;
  color: var(--muted);
  font-size: 12.5px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--border);
}
.meta-grid > div {
  background: var(--surface);
  padding: 14px 20px;
}
.meta-grid dt {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.meta-grid dd {
  margin: 0;
  font-size: 14px;
  word-break: break-word;
}

.instance-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.instance-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
}
.instance-list li:first-child {
  border-top: 0;
}
.instance-list-main {
  min-width: 0;
  flex: 1;
}
.instance-list-name {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.instance-list-sub {
  color: var(--muted);
  font-size: 12px;
}
.instance-list-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* ============================== botones ============================== */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.button svg {
  width: 16px;
  height: 16px;
}
.button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.button:active {
  transform: translateY(1px);
}
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.button-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.button-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.button-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}
.button-ghost:hover {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text);
}
.button-danger-ghost {
  color: var(--danger);
}
.button-danger-ghost:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.button-small {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-soft);
  cursor: pointer;
  user-select: none;
}
.switch input {
  appearance: none;
  width: 32px;
  height: 18px;
  margin: 0;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch input::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease;
}
.switch input:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.switch input:checked::after {
  transform: translateX(14px);
  background: #fff;
}

/* =========================== estado vacio =========================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 80px 24px;
  text-align: center;
}
.empty-art {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  margin-bottom: 6px;
}
.empty-art svg {
  width: 30px;
  height: 30px;
}
.empty-state h2 {
  font-size: 19px;
}
.empty-state p {
  color: var(--text-soft);
  max-width: 420px;
  font-size: 14px;
  margin-bottom: 8px;
}

/* ============================ reproductor ============================ */
/* La pestana «Reproducir» solo muestra el SCORM: sin barras, sin chips y sin
   registro. Todo lo informativo vive en la barra superior y en «Resultados». */

.player {
  display: flex;
  flex-direction: column;
}
.player[hidden] {
  display: none;
}

/* La pestana del reproductor aprovecha todo el ancho disponible. */
body[data-tab='play'] main {
  max-width: 1560px;
}

.player-frame-wrap {
  position: relative;
  height: min(75vh, 870px);
  min-height: 460px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.player-frame-wrap iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.player-frame-wrap.zoom-100 iframe {
  width: 100%;
  height: 100%;
}
.player-frame-wrap[data-zoom='100'] {
  overflow: auto;
}
.player-frame-wrap[data-zoom='100'] iframe {
  width: 100%;
  min-width: 1000px;
  height: 100%;
  min-height: 100%;
}
.player-frame-wrap[data-zoom='75'] iframe,
.player-frame-wrap[data-zoom='50'] iframe {
  transform-origin: top left;
}
.player-frame-wrap[data-zoom='75'] iframe {
  width: 133.3333%;
  height: 133.3333%;
  transform: scale(0.75);
}
.player-frame-wrap[data-zoom='50'] iframe {
  width: 200%;
  height: 200%;
  transform: scale(0.5);
}

/* ===================== barra discreta sobre el SCORM ===================== */
/* Una tira minima encima del contenido: iconos apagados que se avivan al
   pasar por encima. No compite con el paquete, pero esta siempre a mano. */

.player-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 32px;
  margin-bottom: 4px;
  padding: 0 2px;
  opacity: 0.5;
  transition: opacity 0.18s ease;
}
.player-bar:hover,
.player-bar:focus-within {
  opacity: 1;
}

.player-bar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.player-bar-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.player-bar-button:hover {
  background: var(--surface-2);
  color: var(--text);
}
.player-bar-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.player-bar-button svg {
  width: 16px;
  height: 16px;
}
.player-bar-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
}
.zoom-control select {
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}
.zoom-control select:hover {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
.zoom-control select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ============================ registro de la API ============================ */
.log-list {
  max-height: 260px;
  overflow: auto;
  padding: 6px 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--surface);
}
.log-list-static {
  max-height: 340px;
}
.log-line {
  display: flex;
  gap: 10px;
  padding: 3px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-line:hover {
  background: var(--bg-soft);
}
.log-time {
  color: var(--muted);
  flex: 0 0 auto;
}
.log-kind {
  flex: 0 0 auto;
  min-width: 62px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  padding-top: 1px;
}
.log-text {
  min-width: 0;
  color: var(--text-soft);
}
.log-elem {
  color: var(--text);
}
.log-value {
  color: var(--ok);
}
.log-arrow {
  color: var(--muted);
}
.log-note {
  color: var(--muted);
  font-style: italic;
}
.k-init .log-kind,
.k-finish .log-kind {
  color: var(--primary);
}
.k-set .log-kind {
  color: var(--ok);
}
.k-get .log-kind {
  color: var(--muted);
}
.k-commit .log-kind {
  color: #8b5cf6;
}
.k-error .log-kind {
  color: var(--danger);
}
.k-info .log-kind {
  color: var(--warn);
}
.k-info .log-text {
  color: var(--warn);
}
.k-nav .log-kind {
  color: var(--info);
}
.log-empty {
  padding: 18px 14px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  text-align: center;
}

/* ============================= resultados ============================= */

.results {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.results[hidden] {
  display: none;
}
.results-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.results-head h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
}
.results-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.results-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px;
}
.card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card-label {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  margin-bottom: 5px;
}
.card-value {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
  word-break: break-word;
}
.card-value.is-small {
  font-size: 15px;
}
.card-hint {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}

.results-groups {
  padding: 6px 0 10px;
}
.var-group + .var-group {
  border-top: 1px solid var(--border);
}
.var-group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 12px 20px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.var-group-head:hover {
  background: var(--bg-soft);
}
.var-group-head .chevron {
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform 0.18s ease;
}
.var-group-head[aria-expanded='true'] .chevron {
  transform: rotate(90deg);
}
.var-group-count {
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}
.var-rows {
  padding: 2px 0 12px;
}
.var-interaction-head {
  padding: 8px 20px 4px;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.var-row {
  display: grid;
  grid-template-columns: minmax(200px, 1.05fr) minmax(0, 1.6fr);
  gap: 16px;
  padding: 9px 20px;
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  align-items: start;
}
.var-row:hover {
  background: var(--bg-soft);
}
.var-key {
  min-width: 0;
}
.var-name {
  font-size: 13px;
  font-weight: 500;
}
.var-path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
  margin-top: 1px;
}
.var-flags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;
}
.var-flag {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.var-flag-written {
  background: var(--ok-soft);
  color: var(--ok);
}
.var-flag-default {
  background: var(--surface-2);
  color: var(--muted);
}
.var-flag-nonstandard {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
}
.var-value {
  min-width: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
.var-value.is-empty {
  color: var(--muted);
  font-style: italic;
}
.var-value-more {
  margin-top: 6px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 12px;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.var-value-full {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12px;
}
.var-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ============================ barra de salida ============================ */

.export-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}
.export-bar-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 220px;
  flex: 1;
}
.export-bar-text strong {
  font-size: 14px;
}
.export-bar-text span {
  color: var(--muted);
  font-size: 12.5px;
}
.export-bar-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

/* ============================== avisos ============================== */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease;
  max-width: 380px;
  pointer-events: auto;
}
.toast.is-error {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================ responsive ============================ */

@media (max-width: 860px) {
  .topbar {
    gap: 10px;
    padding: 0 12px;
    height: auto;
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .brand-text small {
    display: none;
  }
  .tabs {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
  .tab {
    flex: 1;
    justify-content: center;
  }
  .tab span:not(.tab-count):not(.tab-dot) {
    font-size: 13px;
  }
  main {
    padding: 22px 14px 72px;
  }
  .hero h1 {
    font-size: 25px;
  }
  .var-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }
  .player-frame-wrap {
    height: 62vh;
    min-height: 340px;
  }
  .panel-tools input[type='search'] {
    width: 100%;
  }
  .instance-chip {
    max-width: 160px;
  }
  .topbar-cta span {
    display: none;
  }
  .topbar-cta {
    padding: 7px 10px;
  }
  .topbar-secondary span {
    display: none;
  }
  .topbar-secondary {
    padding: 7px 10px;
  }
}

@media print {
  .topbar,
  .export-bar,
  .results-actions,
  .panel-tools,
  .toast-stack {
    display: none !important;
  }
}

/* Acceso al panel de quien es Profesor de un curso: un botón claro, no una etiqueta. */
.button-panel,
a.button-panel {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.button-panel:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Despliegue condicionado: los tres campos del bloque, con aire entre ellos. */
.config-unlock {
  display: grid;
  gap: 14px;
}

/* ------------------------- texto enriquecido ------------------------- */

.rich-text {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  overflow-wrap: anywhere;
}
.rich-text > :first-child {
  margin-top: 0;
}
.rich-text > :last-child {
  margin-bottom: 0;
}
.rich-text p,
.rich-text ul,
.rich-text ol,
.rich-text blockquote,
.rich-text pre,
.rich-text table,
.rich-text figure {
  margin: 0 0 0.8em;
}
.rich-text h2 {
  margin: 1.1em 0 0.45em;
  font-size: 1.45em;
  line-height: 1.25;
}
.rich-text h3 {
  margin: 1em 0 0.4em;
  font-size: 1.2em;
  line-height: 1.3;
}
.rich-text h4 {
  margin: 0.9em 0 0.35em;
  font-size: 1.05em;
}
.rich-text ul,
.rich-text ol {
  padding-left: 1.4em;
}
.rich-text li + li {
  margin-top: 0.25em;
}
.rich-text a {
  color: var(--primary);
  text-decoration: underline;
}
.rich-text img {
  display: inline-block;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  vertical-align: middle;
}
.rich-text blockquote {
  padding: 0.6em 1em;
  border-left: 3px solid var(--primary);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
}
.rich-text hr {
  margin: 1.2em 0;
  border: 0;
  border-top: 1px solid var(--border);
}
.rich-text code,
.rich-text pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  border-radius: 6px;
}
.rich-text code {
  padding: 0.1em 0.35em;
}
.rich-text pre {
  padding: 0.8em 1em;
  overflow-x: auto;
}
.rich-text table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}
.rich-text th,
.rich-text td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.rich-text figcaption {
  margin-top: 0.3em;
  color: var(--muted);
  font-size: 0.85em;
}
.rich-text iframe,
.rich-video iframe {
  display: block;
  width: 100%;
  border: 0;
}
.rich-video,
.rte-area iframe {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 720px;
  margin: 0 0 0.8em;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.rich-video iframe {
  height: 100%;
}

/* Editor */
.rte {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.rte-button {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.rte-button:hover {
  background: var(--surface, #fff);
  border-color: var(--border);
}
.rte-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.rte-b {
  font-weight: 800;
}
.rte-i {
  font-style: italic;
}
.rte-u {
  text-decoration: underline;
}
.rte-html[aria-pressed='true'] {
  background: var(--primary);
  color: #fff;
}
.rte-toolbar.is-html .rte-button:not(.rte-html) {
  opacity: 0.4;
  pointer-events: none;
}
.rte-sep {
  width: 1px;
  height: 20px;
  margin: 0 3px;
  background: var(--border);
}
.rte-area {
  min-height: 180px;
  max-height: 520px;
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface, #fff);
  outline: none;
}
.rte-area:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.rte-area:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}
.rte-area iframe {
  height: auto;
  pointer-events: none;
}
.rte-source {
  width: 100%;
  min-height: 220px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}
.rte-url {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.rte-url-label {
  font-size: 13px;
  color: var(--muted);
}
.rte-url-input {
  flex: 1 1 220px;
  min-width: 0;
}
.rte-status:empty {
  display: none;
}
.rte-status.is-error {
  color: var(--danger, #c0392b);
}
/* Un enlace al que se le quitó la dirección (no válida) se lee como texto normal. */
.rich-text a:not([href]) {
  color: inherit;
  text-decoration: none;
}

/* Editor de vídeo (profesor) */
.video-archivo {
  display: grid;
  gap: 10px;
}
.video-progreso {
  width: 100%;
  height: 10px;
  accent-color: var(--primary);
}
.video-estado.is-error {
  color: var(--danger);
}

/* Editor de encuestas (panel) y resultados */
.survey-editor-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.survey-editor-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.survey-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.survey-editor-actions,
.survey-editor-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.survey-editor-req {
  align-self: end;
}
.survey-results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-bottom: 12px;
}
.survey-q {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.survey-q h4 {
  margin: 0 0 6px;
}
.survey-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.survey-bar {
  display: grid;
  grid-template-columns: 28px 1fr 36px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.survey-bar:has(.is-wide) {
  grid-template-columns: minmax(70px, 140px) 1fr 36px;
}
.survey-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2, #eef0f4);
  overflow: hidden;
}
.survey-bar-fill {
  display: block;
  height: 100%;
  background: var(--primary);
}
.survey-bar-count {
  text-align: right;
}
.survey-texts {
  margin: 0;
  padding-left: 18px;
}
.survey-texts li + li {
  margin-top: 6px;
}

/* Conversación (panel y alumno) */
.chat {
  list-style: none;
  margin: 0 0 12px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  overflow: auto;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  max-width: 80%;
}
.chat-msg.is-propio {
  align-self: flex-end;
  align-items: flex-end;
}
.chat-burbuja {
  padding: 10px 14px;
  border-radius: 14px 14px 14px 4px;
  background: var(--surface-2, #f1f3f7);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-msg.is-propio .chat-burbuja {
  border-radius: 14px 14px 4px 14px;
  background: var(--primary);
  color: #fff;
}
.chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-form textarea {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg, #fff);
  color: inherit;
  resize: vertical;
}
