/* Experimentar — estilos base compartidos (página de prueba, editor y visor). Móvil primero. */

:root {
  --color-fondo: #f4f6fb;
  --color-tarjeta: #ffffff;
  --color-texto: #1d2333;
  --color-suave: #5b6478;
  --color-borde: #dde2ec;
  --color-principal: #1f5fbf;
  --color-principal-oscuro: #174a96;
  --color-exito: #2b8a3e;
  --color-medio: #e8a100;
  --color-error: #c92a2a;
  --color-tipo-audio: #f08c00;
  --color-tipo-video: #d6336c;
  --color-tipo-whatsapp: #25d366;
  --color-tipo-enlace: #1f5fbf;
  --color-tipo-texto: #7048e8;
  --color-tipo-imagenes: #1098ad;
  --color-tipo-presentacion: #c92a2a;
  --color-tipo-incrustado: #495057;
  --color-tipo-pregunta: #2f9e44;
  --color-tipo-escena: #f76707;
  --color-tipo-modelo: #9c36b5;
  --color-tipo-mapa: #0ca678;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--color-texto);
  line-height: 1.5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-fondo);
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.contenedor {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Cabecera ----------------------------------------------------------------------- */
.cabecera {
  background: linear-gradient(135deg, var(--color-principal), #4c3bb5);
  color: #fff;
  padding: 24px 0 28px;
}
.marca {
  margin: 0;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .85rem;
  opacity: .85;
}
.cabecera h1 { margin: 4px 0 6px; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.2; }
.subtitulo { margin: 0; opacity: .9; max-width: 60ch; }

main { padding-top: 16px; padding-bottom: 48px; }

/* Avisos ------------------------------------------------------------------------- */
.aviso {
  border-radius: var(--radio);
  padding: 12px 16px;
  margin: 0 0 12px;
  font-size: .95rem;
}
.aviso--privacidad { background: #e7f5ee; color: #1e5e36; border: 1px solid #b7e1c7; }
.aviso--privacidad::before { content: "🔒 "; }
.aviso--alerta { background: #fff4e0; color: #7a4b00; border: 1px solid #f3d19a; }

/* Tarjetas ----------------------------------------------------------------------- */
.tarjeta {
  background: var(--color-tarjeta);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 20px 16px;
  margin-bottom: 16px;
}
@media (min-width: 640px) { .tarjeta { padding: 24px 28px; } }
.tarjeta h2 { margin: 0 0 4px; font-size: 1.25rem; }
.tarjeta > p { margin-top: 0; color: var(--color-suave); }

.ayuda { font-size: .85rem; color: var(--color-suave); margin: 6px 0; }
.estado { min-height: 1.5em; margin: 8px 0 0; font-weight: 600; }
.estado:empty { min-height: 0; margin: 0; }
.estado--ok { color: var(--color-exito); }
.estado--error { color: var(--color-error); }

/* Botones ------------------------------------------------------------------------ */
.acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 4px; }
.acciones--compactas { margin: 8px 0; }

.boton {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;                /* tamaño cómodo para tocar */
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--color-principal);
  background: #fff;
  color: var(--color-principal);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s, transform .05s;
}
.boton:hover { background: #eef3fc; }
.boton:active { transform: scale(.98); }
.boton:focus-visible { outline: 3px solid #9cc0ff; outline-offset: 2px; }
.boton:disabled { opacity: .5; cursor: not-allowed; }
.boton--principal { background: var(--color-principal); color: #fff; }
.boton--principal:hover { background: var(--color-principal-oscuro); }
.boton--suave { border-color: var(--color-borde); color: var(--color-texto); }
.boton--grande { width: 100%; min-height: 56px; font-size: 1.1rem; margin-top: 8px; }
@media (min-width: 640px) { .boton--grande { width: auto; padding: 12px 40px; } }

/* Marcador ----------------------------------------------------------------------- */
.marcador-grid { display: grid; gap: 16px; margin-top: 12px; }
@media (min-width: 760px) { .marcador-grid { grid-template-columns: 1.2fr 1fr; align-items: start; } }

.vista-previa {
  position: relative;
  border: 2px dashed var(--color-borde);
  border-radius: var(--radio);
  min-height: 160px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fafbfd;
  line-height: 0;
}
.vista-previa.con-imagen { border-style: solid; cursor: crosshair; touch-action: pan-y; }
.vista-previa__vacia { line-height: 1.5; color: var(--color-suave); padding: 24px; text-align: center; }
.vista-previa img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.vista-previa__capa { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.pin {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: grab;
  touch-action: none;              /* permite arrastrar con el dedo sin mover la página */
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .4));
  transition: transform .12s;
}
.pin img { display: block; width: 100%; height: auto; pointer-events: none; }
.pin:active { cursor: grabbing; }
.pin.activo { transform: scale(1.25); z-index: 2; }
.pin.activo::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 3px solid #1d2333;
  border-radius: 50%;
}

.interruptor { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; margin-top: 8px; color: var(--color-suave); }

/* Rastreabilidad ----------------------------------------------------------------- */
.rastreo { border: 1px solid var(--color-borde); border-radius: var(--radio); padding: 16px; }
.rastreo h3 { margin: 0 0 8px; font-size: 1.05rem; }
.rastreo h4 { margin: 16px 0 4px; font-size: .95rem; }
.rastreo__puntuacion { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.rastreo__numero { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.rastreo__de { color: var(--color-suave); margin-right: 8px; }
.insignia { border-radius: 999px; padding: 2px 12px; font-weight: 700; font-size: .9rem; color: #fff; }
.insignia--buena { background: var(--color-exito); }
.insignia--media { background: var(--color-medio); }
.insignia--baja { background: var(--color-error); }

.metricas { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0 0; font-size: .9rem; align-items: center; }
.metricas dt { color: var(--color-suave); }
.metricas dd { margin: 0; height: 10px; background: #edf0f6; border-radius: 99px; overflow: hidden; }
.metricas--texto dd { height: auto; background: none; border-radius: 0; overflow: visible; word-break: break-word; }
.diagnostico { margin-top: 16px; border-top: 1px solid var(--color-borde); padding-top: 12px; }
.diagnostico summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.diagnostico__vivo { margin-top: 12px; }
.ra__depuracion { position: absolute; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 10; margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(0, 0, 0, .75); color: #fff; font: 600 .85rem/1.35 ui-monospace, Consolas, monospace; text-align: center; pointer-events: none; }
.ra__depuracion.coincide { background: rgba(43, 138, 62, .9); }
.diagnostico__veredicto { margin: 12px 0 0; padding: 10px 12px; border-radius: 8px; background: #edf0f6; line-height: 1.45; }
.diagnostico__veredicto.ok { background: #e6f6ec; }
.diagnostico__veredicto.falla { background: #fdeceb; }
.metricas .barra { height: 100%; border-radius: 99px; }

.consejos { margin: 0; padding-left: 20px; font-size: .92rem; }
.consejos li { margin-bottom: 4px; }

.compilar { margin-top: 12px; border-top: 1px solid var(--color-borde); padding-top: 8px; }
.progreso { display: flex; align-items: center; gap: 12px; margin: 8px 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.progreso__barra { flex: 1; height: 12px; background: #edf0f6; border-radius: 99px; overflow: hidden; }
.progreso__relleno { height: 100%; width: 0; background: var(--color-principal); transition: width .2s; }

/* Puntos ------------------------------------------------------------------------- */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 6px; }

.agregar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.agregar > span { font-weight: 600; margin-right: 4px; }
.boton--tipo { gap: 6px; padding: 6px 14px 6px 6px; }
.boton--tipo img { width: 30px; height: auto; }
.boton--mini { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.boton--icono { min-width: 36px; padding: 4px 8px; }
.boton--peligro { border-color: #f1c4c4; color: var(--color-error); background: #fff; }
.boton--peligro:hover { background: #fff1f1; }

.vacio { color: var(--color-suave); text-align: center; padding: 16px; border: 2px dashed var(--color-borde); border-radius: var(--radio); }
.elementos { display: grid; gap: 12px; margin-top: 12px; }
@media (min-width: 760px) { .elementos { grid-template-columns: 1fr 1fr; align-items: start; } }

.elemento {
  border: 1.5px solid var(--color-borde);
  border-left: 6px solid var(--color-elemento, var(--color-borde));
  border-radius: var(--radio);
  padding: 12px 14px;
  background: #fff;
  transition: box-shadow .15s, border-color .15s;
}
.elemento[data-tipo="audio"] { --color-elemento: var(--color-tipo-audio); }
.elemento[data-tipo="video"] { --color-elemento: var(--color-tipo-video); }
.elemento[data-tipo="whatsapp"] { --color-elemento: var(--color-tipo-whatsapp); }
.elemento[data-tipo="enlace"] { --color-elemento: var(--color-tipo-enlace); }
.elemento[data-tipo="texto"] { --color-elemento: var(--color-tipo-texto); }
.elemento[data-tipo="imagenes"] { --color-elemento: var(--color-tipo-imagenes); }
.elemento[data-tipo="presentacion"] { --color-elemento: var(--color-tipo-presentacion); }
.elemento[data-tipo="incrustado"] { --color-elemento: var(--color-tipo-incrustado); }
.elemento[data-tipo="pregunta"] { --color-elemento: var(--color-tipo-pregunta); }
.elemento[data-tipo="escena"] { --color-elemento: var(--color-tipo-escena); }
.elemento[data-tipo="modelo"] { --color-elemento: var(--color-tipo-modelo); }
.elemento[data-tipo="mapa"] { --color-elemento: var(--color-tipo-mapa); }
.elemento.activo { box-shadow: 0 0 0 3px #9cc0ff; }
.elemento.con-errores { border-color: var(--color-error); border-left-color: var(--color-error); }
.elemento__cabecera { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.elemento__icono { width: 34px; height: auto; flex: none; }
.elemento__titulo { margin: 0; font-size: 1rem; flex: 1; min-width: 100px; }
.elemento__numero { color: var(--color-suave); font-weight: 500; }
.elemento__acciones { display: flex; flex-wrap: wrap; gap: 4px; }
.elemento__campos { display: grid; gap: 8px; }
.elemento__campos .ayuda { margin: 0; }

.campo { display: grid; gap: 2px; font-size: .85rem; color: var(--color-suave); }
.errores { margin: 0; padding-left: 18px; color: var(--color-error); font-size: .88rem; font-weight: 600; }
.errores:empty { display: none; }

.posicion { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.posicion label { display: grid; gap: 2px; font-size: .85rem; color: var(--color-suave); }

input[type="number"], input[type="url"], input[type="text"], input[type="tel"], textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--color-borde);
  font: inherit;
  color: var(--color-texto);
  background: #fff;
}
input:focus-visible { outline: 3px solid #9cc0ff; outline-offset: 1px; border-color: var(--color-principal); }
input[aria-invalid="true"] { border-color: var(--color-error); }
textarea { resize: vertical; min-height: 0; line-height: 1.4; }

.opcion { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.opcion small { color: var(--color-suave); }
input[type="radio"], input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--color-principal); flex: none; }
.nombre-archivo { font-size: .85rem; color: var(--color-suave); word-break: break-all; }

.origenes { margin-bottom: 4px; }
.codigos-qr { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0 4px; }
.codigo-qr { margin: 0; display: grid; gap: 6px; justify-items: center; max-width: 100%; }
.codigo-qr canvas { width: 220px; max-width: 100%; height: auto; image-rendering: pixelated; border: 1px solid var(--color-borde); border-radius: 8px; }
.codigo-qr figcaption { font-size: .85rem; text-align: center; word-break: break-all; }
.direccion { display: inline-block; margin-top: 4px; padding: 6px 10px; background: #edf0f6; border-radius: 8px; word-break: break-all; font-size: .95rem; }

/* Vista RA a pantalla completa --------------------------------------------------- */
.ra { position: fixed; inset: 0; z-index: 100; background: #000; }
.ra__escena { position: absolute; inset: 0; overflow: hidden; }
.ra__escena a-scene { width: 100%; height: 100%; }
.ra__barra {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  z-index: 10;
  pointer-events: none;
}
.ra__estado {
  flex: 1;
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-weight: 600;
  text-align: center;
  backdrop-filter: blur(4px);
}
.ra__estado.encontrado { background: rgba(43, 138, 62, .9); }
.ra__estado.error { background: rgba(201, 42, 42, .92); }
.boton--cerrar { pointer-events: auto; background: rgba(255, 255, 255, .95); border-color: #fff; color: var(--color-texto); }

/* Marco guía mientras se busca la hoja */
.ra__guia {
  position: absolute;
  left: 50%; top: 50%;
  width: min(70vw, 70vh);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, .8);
  border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .18);
  pointer-events: none;
  z-index: 5;
  transition: opacity .3s;
}
.ra__guia.oculta { opacity: 0; }


/* Mira central («al pasar») y burbuja con la descripción ----------------------------- */
.ra__mira {
  position: absolute;
  left: 50%; top: 50%;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .25), inset 0 0 0 2px rgba(0, 0, 0, .25);
  pointer-events: none;
  z-index: 6;
  transition: transform .2s, border-color .2s;
}
.ra__mira::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #fff;
}
.ra__mira.sobre { transform: scale(.7); border-color: #ffd43b; }
@media (hover: hover) and (pointer: fine) { .ra__mira { opacity: .6; } }

.ra__burbuja {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, calc(-100% - 64px));
  width: max-content;
  max-width: min(300px, calc(100vw - 16px));
  padding: 10px 14px;
  border: 0;
  border-top: 5px solid var(--color-elemento, var(--color-principal));
  border-radius: 14px;
  background: rgba(255, 255, 255, .97);
  color: var(--color-texto);
  font: inherit;
  text-align: left;
  display: grid;
  gap: 2px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  cursor: pointer;
  animation: burbuja-entra .2s ease-out;
}
.ra__burbuja strong { font-size: 1.05rem; }
.ra__burbuja span { font-size: .95rem; line-height: 1.35; }
.ra__burbuja small { color: var(--color-suave); font-weight: 600; }
@keyframes burbuja-entra { from { opacity: 0; margin-top: 8px; } to { opacity: 1; margin-top: 0; } }

.modal .modal__caja--tarjeta {
  width: min(100%, 460px);
  background: #fff;
  color: var(--color-texto);
  padding: 20px;
  border-top: 8px solid var(--color-elemento, var(--color-principal));
}
.modal .modal__caja--tarjeta h2 { margin: 0 0 8px; font-size: 1.3rem; }
.tarjeta-texto { white-space: pre-line; font-size: 1.05rem; margin: 0 0 8px; }
.modal .modal__caja--tarjeta .boton--suave { background: #fff; color: var(--color-texto); border-color: var(--color-borde); }
/* Video -------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 14, 25, .8);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal__caja { width: min(100%, 860px); background: #111; border-radius: var(--radio); padding: 8px; }
.modal__video { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; overflow: hidden; }
.modal__video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.modal__video p { color: #fff; padding: 16px; line-height: 1.5; }
.modal .acciones { justify-content: flex-end; }
.modal .boton--suave { background: transparent; color: #fff; border-color: #555; }

/* Hoja en pantalla completa (probar sin impresora, D-020) ---------------------------- */
/* Fondo blanco y margen: MindAR necesita ver los bordes de la imagen, como en el papel. */
.pantalla-marcador { position: fixed; inset: 0; z-index: 1000; background: #fff; display: grid; place-items: center; padding: 4vmin; cursor: pointer; }
.pantalla-marcador[hidden] { display: none; }
.pantalla-marcador img { display: block; max-width: 100%; max-height: calc(100vh - 8vmin); object-fit: contain; }
.pantalla-marcador__ayuda { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.7); color: #fff; font-size: 0.9rem; text-align: center; animation: ocultar-ayuda 0.4s ease 5s forwards; }
.pantalla-marcador__ayuda.alerta { background: rgba(201, 42, 42, .92); animation: none; }
@keyframes ocultar-ayuda { to { opacity: 0; visibility: hidden; } }

/* Impresión: solo la imagen del marcador, a toda la hoja ---------------------------- */
.hoja-impresion { display: none; }
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  /* Solo en las páginas que tienen hoja para imprimir (prueba, editor); la guía se imprime entera */
  body:has(> .hoja-impresion) > *:not(.hoja-impresion) { display: none !important; }
  .hoja-impresion { display: block; }
  .hoja-impresion img { display: block; max-width: 100%; max-height: 270mm; margin: 0 auto; }
  .hoja-impresion img.hoja-extra { break-before: page; page-break-before: always; }   /* varias hojas (D-040) */
}

/* Paso 1: miniatura con el análisis · Paso 2: imagen editable fija junto a la lista ------ */
.miniatura { position: relative; border-radius: var(--radio); overflow: hidden; border: 2px dashed var(--color-borde); background: #fafbfd; line-height: 0; min-height: 120px; display: grid; place-items: center; }
.miniatura img { display: block; width: 100%; height: auto; }
.miniatura:has(img:not([hidden])) { border-style: solid; }

.editor-grid { display: grid; gap: 16px; margin-top: 12px; }
/* min-width: 0 → una fila larga (miniaturas de un carrusel) no ensancha la columna en el celular */
.editor-grid > *, .elemento, .elemento__campos, .elemento__campos > *, .campo > * { min-width: 0; }
.editor-lienzo .vista-previa { min-height: 120px; }
@media (min-width: 900px) {
  .editor-grid { grid-template-columns: minmax(280px, 0.9fr) 1.1fr; align-items: start; }
  .editor-lienzo { position: sticky; top: 12px; }
  .editor-grid .elementos { grid-template-columns: 1fr; margin-top: 0; }
}

/* Arrastrar y soltar la imagen en el paso 1 */
.zona-soltar { position: relative; }
.zona-soltar.arrastrando { outline: 3px dashed var(--color-principal); outline-offset: -6px; background: #eef3fc; }

/* Elementos con contenido propio (D-036): editor --------------------------------------- */
.visualmente-oculto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.miniaturas { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; }
.miniaturas:empty { display: none; }
.miniaturas img { height: 64px; width: auto; border-radius: 6px; border: 1px solid var(--color-borde); background: #fff; flex: none; }
label.ocupado { opacity: .6; pointer-events: none; }
.opciones-pregunta { border: 0; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
.opciones-pregunta legend { font-weight: 600; font-size: .9rem; margin-bottom: 4px; padding: 0; }
.opcion-pregunta { display: flex; gap: 6px; align-items: center; }
.opcion-pregunta input[type="text"] { flex: 1; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--color-borde); border-radius: 10px; font: inherit; }
.opcion-pregunta__correcta { display: grid; place-items: center; min-width: 44px; min-height: 44px; cursor: pointer; }
.opcion-pregunta__correcta input { width: 22px; height: 22px; accent-color: var(--color-tipo-pregunta); margin: 0; }

/* Ventanas del estudiante: carrusel, incrustado y pregunta ------------------------------ */
.modal--contenido .modal__caja { background: #fff; color: var(--color-texto); padding: 14px; border-top: 8px solid var(--color-elemento, var(--color-principal)); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal--contenido h2 { margin: 0 0 10px; font-size: 1.2rem; }
.modal--contenido .boton--suave { background: #fff; color: var(--color-texto); border-color: var(--color-borde); }
.modal--contenido .acciones { margin-top: 10px; flex-wrap: wrap; }

.galeria { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; background: #f1f3f5; border-radius: 10px; overflow: hidden; touch-action: pan-y; user-select: none; }
.galeria__imagen { display: block; max-width: 100%; max-height: calc(100dvh - 210px); object-fit: contain; }
.galeria:fullscreen { background: #000; }
.galeria:fullscreen .galeria__imagen { max-height: 100vh; }
.galeria__vacia { padding: 24px; color: var(--color-suave); }
.galeria__flecha { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px; border: 0; border-radius: 12px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 2.2rem; line-height: 1; cursor: pointer; }
.galeria__flecha:disabled { opacity: .25; cursor: default; }
.galeria__flecha--anterior { left: 6px; }
.galeria__flecha--siguiente { right: 6px; }
.galeria__contador { margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--color-suave); }

.modal--grande .modal__caja { width: min(100%, 1100px); height: calc(100dvh - 32px); }
.incrustado { flex: 1; min-height: 0; border-radius: 10px; overflow: hidden; background: #f1f3f5; }
.incrustado iframe { width: 100%; height: 100%; border: 0; display: block; }

.modal__caja--pregunta { width: min(100%, 480px); }
.pregunta__etiqueta { margin: 0; font-weight: 700; color: var(--color-elemento); text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }
.pregunta__texto { white-space: pre-line; }
.pregunta__opciones { display: grid; gap: 8px; }
.pregunta__opcion { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border: 2px solid var(--color-borde); border-radius: 12px; background: #fff; color: var(--color-texto); font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer; }
.pregunta__opcion:hover:not(:disabled) { border-color: var(--color-elemento); }
.pregunta__letra { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; background: #f1f3f5; font-weight: 700; }
.pregunta__opcion.correcta { border-color: var(--color-exito); background: #ebfbee; }
.pregunta__opcion.correcta .pregunta__letra { background: var(--color-exito); color: #fff; }
.pregunta__opcion.incorrecta { border-color: var(--color-error); background: #fff5f5; opacity: .75; }
.pregunta__opcion:disabled { cursor: default; }
.pregunta__resultado { min-height: 1.5em; margin: 10px 0 0; font-weight: 700; font-size: 1.1rem; }
.pregunta__resultado--bien { color: var(--color-exito); }
.pregunta__resultado--mal { color: var(--color-error); }

/* Modelo 3D y mapa (D-043) */
.modal__caja--modelo, .modal__caja--mapa { width: min(100%, 560px); }
.visor3d { position: relative; height: min(56dvh, 440px); min-height: 220px; border-radius: 12px; overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #ffffff 0%, #eef0f8 60%, #dfe3f0 100%); }
.visor3d__lienzo { display: block; width: 100%; height: 100%; cursor: grab; }
.visor3d__lienzo:active { cursor: grabbing; }
.visor3d__estado { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 16px; text-align: center; color: var(--color-suave); }
.visor3d__ayuda { text-align: center; }
.mapa { margin: 0; position: relative; border-radius: 12px; overflow: hidden; background: #e6eaf0; }
.mapa__imagen { display: block; width: 100%; height: auto; aspect-ratio: 640 / 400; object-fit: cover; }
.mapa__creditos { padding: 4px 8px; font-size: .75rem; color: var(--color-suave); text-align: right; }
.mapa__lugar { margin: 10px 0 0; font-weight: 700; }
.modal__caja--mapa .tarjeta-texto { margin-top: 6px; }

/* Recorridos 360° (D-037) ---------------------------------------------------------------- */
.recorrido { position: fixed; inset: 0; z-index: 150; background: #000; }
.recorrido__escena, .recorrido__escena a-scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.recorrido__barra { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: max(10px, env(safe-area-inset-top)) 12px 10px; background: linear-gradient(rgba(0, 0, 0, .65), transparent); pointer-events: none; }
.recorrido__barra > * { pointer-events: auto; }
.recorrido__titulo { margin: 0; color: #fff; font-weight: 700; font-size: 1.05rem; text-shadow: 0 1px 3px #000; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recorrido__ayuda, .recorrido__cargando { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 5; margin: 0; padding: 8px 14px; max-width: calc(100% - 32px); border-radius: 999px; background: rgba(0, 0, 0, .7); color: #fff; font-size: .95rem; text-align: center; pointer-events: none; }
.recorrido__cargando { top: 50%; bottom: auto; transform: translate(-50%, -50%); }
/* El botón de gafas de A-Frame: arriba a la derecha (abajo van los controles) y más grande */
.recorrido .a-enter-vr, .recorrido .a-enter-vr.embedded { top: calc(50% + 130px) !important; bottom: auto !important; right: 12px !important; }
.recorrido .a-enter-vr-button { width: 72px; height: 48px; background-size: 60% auto; }

/* Controles del recorrido (D-039) */
.recorrido__grupo { display: flex; gap: 8px; align-items: center; }
.recorrido__boton, .recorrido__contador { min-width: 48px; min-height: 48px; border: 2px solid rgba(255, 255, 255, .85); border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font: inherit; font-size: 1.6rem; font-weight: 700; line-height: 1; cursor: pointer; display: inline-grid; place-items: center; padding: 0 12px; backdrop-filter: blur(4px); }
.recorrido__boton:disabled { opacity: .3; cursor: default; }
.recorrido__boton:not(:disabled):hover, .recorrido__contador:hover { background: rgba(31, 95, 191, .85); }
.recorrido__boton--texto { font-size: 1rem; gap: 4px; display: inline-flex; }
.recorrido__contador { font-size: 1rem; padding: 0 16px; min-width: 84px; white-space: nowrap; display: inline-flex; }
.recorrido__contador::after { content: " ☰"; margin-left: 6px; }
.recorrido__controles { position: absolute; z-index: 5; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 10px; align-items: center; max-width: calc(100% - 24px); }
.recorrido__zoom { position: absolute; z-index: 5; right: 12px; top: 50%; transform: translateY(-50%); display: grid; gap: 10px; }
.recorrido__menu { position: absolute; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; }
.recorrido__menu-caja { width: min(100%, 560px); max-height: calc(100dvh - 32px); overflow: auto; background: #fff; color: var(--color-texto); border-radius: var(--radio); padding: 16px; border-top: 8px solid var(--color-tipo-escena); }
.recorrido__menu-caja h2 { margin: 0 0 10px; font-size: 1.2rem; }
.recorrido__fotos { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.recorrido__foto { width: 100%; display: grid; gap: 4px; padding: 6px; border: 2px solid var(--color-borde); border-radius: 12px; background: #fff; font: inherit; text-align: left; cursor: pointer; color: var(--color-texto); }
.recorrido__foto img { width: 100%; aspect-ratio: 2 / 1; object-fit: cover; border-radius: 8px; background: #eee; }
.recorrido__foto span { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recorrido__foto[aria-current="true"] { border-color: var(--color-tipo-escena); background: #fff4e6; }

/* Varias hojas en la RA (D-040): avance y «ahora busca la hoja…» --------------------------- */
.ra__hojas { position: absolute; z-index: 6; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 58px); transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; max-width: calc(100% - 24px); pointer-events: none; }
.ra__hojas-texto { margin: 0; padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; font-weight: 700; font-size: .95rem; text-align: center; }
.ra__puntos-hojas { display: flex; gap: 6px; }
.ra__punto-hoja { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .45); border: 2px solid rgba(0, 0, 0, .35); }
.ra__punto-hoja.vista { background: #69db7c; }
.ra__punto-hoja.actual { background: #ffd43b; transform: scale(1.3); }
.ra__siguiente { position: absolute; z-index: 6; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 12px; align-items: center; width: max-content; max-width: calc(100% - 24px); padding: 10px 14px 10px 10px; border-radius: 16px; background: rgba(255, 255, 255, .96); color: var(--color-texto); box-shadow: 0 6px 24px rgba(0, 0, 0, .35); animation: burbuja-entra .25s ease-out; pointer-events: none; }
.ra__siguiente img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; background: #f1f3f5; flex: none; }
.ra__siguiente p { margin: 0; display: grid; }
.ra__siguiente small { color: var(--color-suave); font-weight: 600; }
.ra__siguiente strong { font-size: 1.05rem; }
