/* Guía R · QUI-004-R8 · rediseño nocturno completo sobre la base R7. Acabado A «Latón cálido» (QUI-004-R3) y componentes
 * QUI-004-R4. Tipografías locales Fraunces 600 y Nunito Sans 400/600/700 (OFL 1.1, fuentes/*-OFL.txt), sin
 * servicio externo. La raíz no se fija: tamaños en rem/em para respetar la letra del navegador (criterio F3).
 * Equivalencias a preferencia 16: lectura oral 22/32 (móvil) y 24/35 (escritorio); preparación 18/26 y 21/30;
 * título 28 y 36; controles 16/700 con alto mínimo 56 px (Opciones 44 px). Base de espaciado 4 px.
 */
@font-face { font-family: "Fraunces R"; src: url("fuentes/fraunces-600.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito Sans R"; src: url("fuentes/nunitosans-400.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito Sans R"; src: url("fuentes/nunitosans-600.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Nunito Sans R"; src: url("fuentes/nunitosans-700.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* A · R3 */
  --marfil: #FFF6E5;
  --tinta: #243F38;
  --contexto: #72604D;
  --borde-papel: #D8BC8D;
  --laton: #C6984F;
  --madera-1: #49372B;
  --madera-2: #2D2924;
  --ambar-1: #FAD895;
  --ambar-2: #EDB55D;
  --ambar-base: #A36525;
  --borde-secundario: #789182;
  --bosque: #244F46;
  --fondo-sobrio: #302820;
  /* R4 */
  --peligro: #973E32;
  --advertencia: #7E571C;
  --informacion: #365E67;
  --solicitud: #2E6150;
  --campo: #FFFCF5;
  --resumen: #F9EADF;
  --margen: clamp(0.75rem, 5vw, 1.5rem);   /* 20–24 px en móvil; con letra grande no crece más que el ancho */
  --radio-plano: 1.5rem;
  --radio-boton: 1.125rem;
  --serif: "Fraunces R", Georgia, serif;
  --sans: "Nunito Sans R", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo-sobrio); color: var(--tinta);
  font-family: var(--sans); font-size: 1.125rem; line-height: 1.45; overflow-wrap: break-word;
}
img { max-width: 100%; }

.saltar { position: absolute; left: -9999px; }
.saltar:focus { left: 1rem; top: 0.5rem; background: var(--marfil); color: var(--tinta); padding: 0.5rem 0.75rem; z-index: 10; border-radius: 0.5rem; }
.solo-lector {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Foco A: contorno exterior de 3 px separado del control; bosque sobre marfil, ámbar sobre madera/escena. */
:focus-visible { outline: 3px solid var(--bosque); outline-offset: 3px; }
.cabecera :focus-visible, .home-apertura :focus-visible, .vista-momento > .placa-titulo :focus-visible { outline-color: var(--ambar-1); }

/* ------------------------------------------------------------ Cabecera: marca y Opciones */
.cabecera { background: linear-gradient(180deg, var(--madera-1), var(--madera-2)); border-bottom: 1px solid var(--laton); }
.cabecera-interior {
  max-width: 90rem; margin: 0 auto; padding: 0.75rem var(--margen); min-height: 4.5rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem;
}
.marca { display: block; width: 100%; max-width: 160px; height: auto; flex: 0 1 160px; }
.indicador-guardado { margin: 0; font-size: 1rem; font-weight: 700; color: var(--ambar-1); }
.indicador-guardado:empty { display: none; }
.cabecera-acciones { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cabecera-acciones:empty { display: none; }

.principal { margin: 0 auto; padding: 0 0 3rem; }
.principal:focus { outline: none; }
.carga { color: var(--marfil); padding: 1rem var(--margen); }

/* ------------------------------------------------------------ Tipografía */
.antetitulo { margin: 0 0 0.25rem; font-size: 0.875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--contexto); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--tinta); }
h1 { font-size: 1.75rem; line-height: 1.18; margin: 0 0 0.5rem; }
h1:focus { outline: none; }
h2 { font-size: 1.375rem; line-height: 1.25; margin: 1.25rem 0 0.5rem; }
h3 { font-size: 1.125rem; line-height: 1.3; margin: 1rem 0 0.25rem; }
p { margin: 0 0 0.75rem; }
.rotulo {
  display: block; font-family: var(--sans); font-size: 0.875rem; line-height: 1.3; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--contexto); margin: 0 0 0.5rem;
}
.equipo-placa { margin: 0; font-size: 1rem; font-weight: 600; }

/* ------------------------------------------------------------ Escenas aceptadas (R5/R3/R2) */
/* Lienzo entero y proporcional, sin máscara, degradado, desenfoque ni tinte añadidos: las RGBA de R5 ya
 * traen su borde y las islas G04 caen directamente sobre el fondo de la interfaz (R6 TRASPASO §2). */
.escena { margin: 0; position: relative; width: 100%; aspect-ratio: var(--proporcion); background: transparent; }
.escena picture, .escena img { display: block; width: 100%; height: 100%; }
.escena img { object-fit: contain; }

/* ------------------------------------------------------------ Vista de un momento */
.vista-momento { display: grid; grid-template-columns: minmax(0, 1fr); }
.placa-titulo, .plano-lectura, .home-llamada { position: relative; z-index: 1; min-width: 0; }
.placa-titulo { overflow-wrap: anywhere; }
.plano-lectura {
  background: var(--marfil); border: 1px solid var(--borde-papel); border-radius: var(--radio-plano);
  box-shadow: 0 0 0 1px rgba(198, 152, 79, .35), 0 10px 24px rgba(0, 0, 0, .28);
  padding: 1.5rem var(--margen); margin: 0.5rem var(--margen) 0;
}
/* Placa A de madera (R3 componente placa-titulo; R6 v04/v05): antetítulo ámbar, título marfil, equipo. */
.placa-titulo {
  display: grid; grid-template-areas: "ante" "titulo" "equipo"; align-content: start;
  padding: 0.875rem 1.125rem 1rem; color: var(--marfil);
  background: linear-gradient(180deg, rgba(73, 55, 43, .96), rgba(45, 41, 36, .96));
  border: 1px solid #A87B45; border-radius: 1.25rem; box-shadow: 0 8px 20px rgba(0, 0, 0, .28);
}
.placa-titulo .antetitulo { grid-area: ante; color: var(--ambar-1); font-size: 0.75rem; margin: 0 0 0.375rem; }
.placa-titulo h1 { grid-area: titulo; color: var(--marfil); font-size: 1.75rem; line-height: 1.18; margin: 0; }
.placa-titulo .equipo-placa { grid-area: equipo; color: #EADBC0; font-size: 0.875rem; font-weight: 600; margin: 1.25rem 0 0; }
.equipo-antetitulo { display: none; }

/* Reserva (A02, A03, G04a, G02, G04b–d): escena a todo el ancho y placa sobre su reserva derecha, con la
 * x y el ancho de cada recurso (muestra 390). Si no cabe, pasa antes de la escena; la letra no se reduce. */
.encaje-reserva > .escena { grid-area: 1 / 1; }
.encaje-reserva > .placa-titulo {
  --superpuesto: 1; grid-area: 1 / 1; align-self: start; justify-self: start;
  width: var(--placa-ancho, 60%); margin: 7.2% 0 0 var(--placa-x, 36%);
}
.encaje-reserva > .plano-lectura { grid-row: 2; }
.encaje-reserva.fuera-de-reserva > .placa-titulo { --superpuesto: 0; width: auto; justify-self: stretch; margin: 1rem var(--margen); }
.encaje-reserva.fuera-de-reserva > .escena { grid-area: 2 / 1; }
.encaje-reserva.fuera-de-reserva > .plano-lectura { grid-row: 3; }

/* Grupo (G01, G04e, G03): título antes, escena completa y lectura debajo (móvil y escritorio apilado). */
.encaje-grupo > .placa-titulo { margin: 1rem var(--margen); }
.encaje-grupo > .placa-titulo .equipo-placa { display: none; }
.encaje-grupo > .escena { width: 100%; max-width: 38.5rem; justify-self: center; }
.encaje-grupo > .plano-lectura { margin-top: 1rem; }

/* Superficies sobrias: formularios, pausa, cubiertas y avisos (sin paisaje, R6-UX-01). */
.sobria > .placa-titulo { margin: 1.5rem var(--margen) 0; padding: 0 0.25rem; background: none; border: 0; box-shadow: none; }
.sobria > .placa-titulo .equipo-placa { margin-top: 0.25rem; }
.columna-lectura {
  background: var(--marfil); border: 1px solid var(--borde-papel); border-radius: var(--radio-plano);
  padding: 1.5rem var(--margen); margin: 1.5rem var(--margen) 0; max-width: 44rem;
}
/* Apilado en pantallas medianas: lectura centrada con su ancho máximo A. */
@media (min-width: 45em) {
  .vista-momento > .plano-lectura, .sobria > .placa-titulo, .columna-lectura { width: auto; max-width: 44rem; margin-left: auto; margin-right: auto; }
  .encaje-grupo > .placa-titulo { width: calc(100% - 2 * var(--margen)); max-width: 44rem; justify-self: center; margin-left: 0; margin-right: 0; }
}
@media (min-width: 56.25em) {
  .plano-lectura, .columna-lectura { padding: 1.75rem; }
  .sobria > .placa-titulo h1 { font-size: 2.25rem; }
}

/* Columnas de escritorio (las activa app.js solo si la lectura cabe; R6 TRASPASO §3). */
/* Reserva: el título entra en el plano de lectura, que empieza en la x del recurso (lecturaX/1440). */
.encaje-reserva.columnas { grid-template-columns: var(--lectura-x) minmax(0, 44rem) minmax(1.5rem, 1fr); grid-template-rows: auto auto 1fr; }
.encaje-reserva.columnas > .escena { grid-area: 1 / 1 / 4 / -1; align-self: start; }
.encaje-reserva.columnas > .placa-titulo {
  --superpuesto: 0; grid-area: 1 / 2; width: auto; justify-self: stretch; margin: 6.1vw 0 0;
  grid-template-areas: "equipo ante" "titulo titulo"; grid-template-columns: minmax(0, 1fr) auto; column-gap: 1rem;
  padding: 1.75rem 1.75rem 0.25rem; color: var(--tinta); background: var(--marfil);
  border: 1px solid var(--borde-papel); border-bottom: 0; border-radius: var(--radio-plano) var(--radio-plano) 0 0; box-shadow: none;
}
.encaje-reserva.columnas > .placa-titulo .antetitulo { color: var(--contexto); justify-self: end; text-align: right; }
.encaje-reserva.columnas > .placa-titulo h1 { color: var(--tinta); font-size: 2.25rem; margin-top: 0.75rem; }
.encaje-reserva.columnas > .placa-titulo .equipo-placa { color: var(--contexto); font-size: 0.9375rem; margin: 0; }
.encaje-reserva.columnas > .plano-lectura {
  grid-area: 2 / 2; align-self: start; width: auto; max-width: none; margin: 0;
  border-top: 0; border-radius: 0 0 var(--radio-plano) var(--radio-plano); padding: 0.5rem 1.75rem 1.75rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .28); clip-path: inset(0 -2rem -3rem -2rem);
}
.encaje-reserva.columnas::after { content: ""; grid-area: 4 / 1 / 5 / -1; height: 2rem; }
/* Grupo: escena completa limitada (≤ 616) bajo el título a la izquierda; lectura simultánea a la derecha. */
.encaje-grupo.columnas {
  grid-template-columns: minmax(30rem, 616fr) minmax(37.5rem, 696fr); grid-template-rows: auto auto 1fr;
  column-gap: 3rem; max-width: 90rem; margin: 0 auto; padding: 1.5rem 2.5rem 0;
}
.encaje-grupo.columnas > .placa-titulo { grid-area: 1 / 1; width: auto; max-width: none; margin: 0; justify-self: stretch; }
.encaje-grupo.columnas > .placa-titulo .equipo-antetitulo { display: inline; }
.encaje-grupo.columnas > .placa-titulo h1 { font-size: 2.25rem; }
.encaje-grupo.columnas > .escena { grid-area: 2 / 1; max-width: none; margin-top: 1rem; align-self: start; }
.encaje-grupo.columnas > .plano-lectura { grid-area: 1 / 2 / 4 / 3; align-self: start; width: auto; max-width: none; margin: 0; }

/* ------------------------------------------------------------ Bloques de lectura */
.bloque { overflow-wrap: break-word; min-width: 0; margin: 1rem 0; }
.bloque > :last-child { margin-bottom: 0; }
.bloque > h2:first-child, .bloque > h3:first-child { margin-top: 0; }
.oral { font-size: 1.375rem; line-height: 1.4545; }          /* 22/32 */
.oral > .rotulo::before, .fin > .rotulo::before { content: ""; display: inline-block; width: 1rem; margin-right: 0.5rem; vertical-align: 0.3em; border-top: 2px solid var(--laton); }
.oral:focus { outline: 3px solid var(--bosque); outline-offset: 6px; border-radius: 0.5rem; }
.oral .subrotulo { font-family: var(--sans); font-size: 1rem; font-weight: 700; color: var(--contexto); margin: 1rem 0 0.25rem; text-transform: uppercase; letter-spacing: .06em; }
@media (min-width: 56.25em) { .oral { font-size: 1.5rem; line-height: 1.4583; } }   /* 24/35 */
.preparacion { font-size: 1.125rem; line-height: 1.444; }    /* 18/26 */
@media (min-width: 56.25em) { .preparacion, .plano-lectura > p { font-size: 1.3125rem; line-height: 1.43; } }  /* 21/30 */
.preparacion .rotulo { margin-bottom: 0.375rem; }
/* Títulos de sección de preparación como encabezados A (R6 v01 03/04: «Lo que necesitas», «Para imprimir»). */
.preparacion > h2.rotulo { font-family: var(--serif); font-weight: 600; font-size: 1.375rem; line-height: 1.25; letter-spacing: 0; text-transform: none; color: var(--tinta); margin-bottom: 0.5rem; }
.ayuda, .consulta { background: var(--campo); border: 1px solid var(--borde-papel); border-left: 4px solid var(--laton); border-radius: 1rem; padding: 1rem 1.125rem; }
.consulta:focus { outline: 3px solid var(--bosque); outline-offset: 3px; }
.privado { background: var(--campo); border: 1px dashed var(--advertencia); border-left: 4px solid var(--advertencia); border-radius: 1rem; padding: 1rem 1.125rem; }
.privado .rotulo { color: var(--advertencia); }
.privado .rotulo::before { content: ""; display: inline-block; width: 0.75em; height: 0.85em; margin-right: 0.4em; vertical-align: -0.05em;
  background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M3 6V4a3 3 0 0 1 6 0v2h1a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1.5 0h3V4a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M3 6V4a3 3 0 0 1 6 0v2h1a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm1.5 0h3V4a1.5 1.5 0 0 0-3 0z'/%3E%3C/svg%3E") center/contain no-repeat; }
.advertencia { background: #FBF1DF; border: 1px solid var(--advertencia); border-left: 4px solid var(--advertencia); border-radius: 1rem; padding: 1rem 1.125rem; margin: 0; }
.advertencia .rotulo { color: var(--advertencia); }
.confirmar-sustitucion .boton.peligro { background: var(--marfil); }
/* M03 · acento secundario al abrir Ayuda 1: canto cálido 8 % → 4 % → 0 en 180 ms, una vez. No mueve texto,
 * botones ni geometría; no bloquea; el contenido y el foco están desde el inicio. */
.ayuda { position: relative; }
.acento-m03::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 4px var(--ambar-2); opacity: 0; animation: m03-acento 180ms linear 1;
}
@keyframes m03-acento { 0% { opacity: .08; } 44% { opacity: .04; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .acento-m03::after { animation: none; } }
.nota { background: var(--campo); border: 1px solid var(--borde-papel); border-radius: 1rem; padding: 1rem 1.125rem; }
.revision { background: #EEF3EE; border: 1px solid var(--borde-secundario); border-left: 4px solid var(--bosque); border-radius: 1rem; padding: 1rem 1.125rem; }
.revision .rotulo { color: var(--bosque); }

/* Mensajes R4: color + símbolo + título + texto */
.error, .resumen-errores {
  background: var(--resumen); border: 1px solid var(--peligro); border-left: 4px solid var(--peligro); border-radius: 1rem; padding: 1rem 1.125rem; color: var(--tinta);
}
.error .rotulo, .resumen-errores .rotulo, .error > strong:first-child { color: var(--peligro); }
.error .rotulo::before, .resumen-errores .rotulo::before { content: "! "; font-weight: 800; }
.error a, .resumen-errores a { color: var(--peligro); font-weight: 700; }
.lugar { font-weight: 700; overflow-wrap: anywhere; }
.lugar-vacio { color: var(--peligro); }

ul.lista { margin: 0 0 0.75rem; padding-left: 1.2em; }
ul.lista li { margin-bottom: 0.375rem; }
dl.resumen { margin: 0; }
dl.resumen dt { font-weight: 700; }
dl.resumen dd { margin: 0 0 0.5rem; overflow-wrap: anywhere; min-width: 0; }
dl.resumen dd:last-child { margin-bottom: 0; }

details.sobre-guardado { font-size: 1rem; color: var(--contexto); margin: 0.75rem 0; }
details.sobre-guardado summary { cursor: pointer; font-weight: 700; color: var(--bosque); min-height: 2.75rem; padding: 0.625rem 0; overflow-wrap: anywhere; }
details.sobre-guardado p { margin: 0.25rem 0 0; }

/* ------------------------------------------------------------ Botones A (R3) */
.acciones { display: flex; flex-direction: column; gap: 1.5rem; margin: 1.5rem 0 0; }
.boton {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; min-height: 3.5rem; padding: 0.75rem min(1.25rem, 4vw);
  font: inherit; font-family: var(--sans); font-size: 1rem; font-weight: 700; text-align: left; line-height: 1.3;
  color: var(--tinta); background: var(--marfil);
  border: 2px solid var(--borde-secundario); border-radius: var(--radio-boton); cursor: pointer;
  text-decoration: none; overflow-wrap: break-word; hyphens: auto; position: relative;
}
.boton:hover { background: #FBEFD8; }
.boton:active { transform: translateY(2px); }
.boton.primario {
  color: var(--tinta); border: 1px solid var(--ambar-base);
  background: linear-gradient(180deg, var(--ambar-1), var(--ambar-2));
  box-shadow: 0 3px 0 var(--ambar-base);
  justify-content: space-between;
}
.boton.primario::after { content: "→"; font-size: 1.25rem; line-height: 1; flex: none; }
.boton.primario:hover { background: linear-gradient(180deg, #FCE2AE, #F0BF70); }
.boton.primario:active { box-shadow: 0 1px 0 var(--ambar-base); }
.boton.anterior::before { content: "←"; font-size: 1.25rem; line-height: 1; flex: none; }
.boton.secundario { background: transparent; color: var(--marfil); border-color: var(--ambar-1); }
.boton[aria-expanded="true"] { background: #F2E6CF; }
/* Deshabilitado: sin relieve, borde discontinuo, flecha sustituida por raya y tono apagado (R3). */
.boton[disabled], .boton[aria-disabled="true"] {
  color: #7C746A; background: #F1E9DA; border: 2px dashed #A99C88; box-shadow: none; cursor: not-allowed; transform: none;
}
.boton.primario[disabled]::after { content: "—"; }
.boton.peligro { color: var(--peligro); border-color: var(--peligro); }
.boton.discreto { min-height: 2.75rem; border-width: 1px; font-weight: 600; }
.boton.opciones {
  width: auto; min-height: 2.75rem; padding: 0.5rem 0.875rem; border-radius: 0.875rem; font-size: 0.875rem;
  color: var(--marfil); background: rgba(255, 246, 229, .08); border: 1px solid var(--laton);
}
.boton.opciones:hover { background: rgba(255, 246, 229, .16); }
.icono-menu { display: inline-block; width: 1.125rem; height: 0.75rem; border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; position: relative; }
.icono-menu::after { content: ""; position: absolute; left: 0; right: 0; top: calc(50% - 1px); border-top: 2px solid currentColor; }
@media (min-width: 56.25em) {
  /* Navegación de escritorio en una fila: Anterior a la izquierda, avance a la derecha; se apila si no cabe. */
  .navegacion-paso { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .navegacion-paso > .contexto-accion, .navegacion-paso > .bloque, .navegacion-paso > span { flex: 1 1 100%; order: -2; }
  .navegacion-paso > .boton { width: auto; flex: 0 1 auto; }
  .navegacion-paso > .anterior { order: -1; margin-right: auto; }
}

/* ------------------------------------------------------------ Campos R4 */
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; margin-bottom: 0.5rem; padding: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.casilla { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.625rem 0; border-top: 1px solid #EADBC0; cursor: pointer; }
.casilla:first-of-type { border-top: 0; }
.casilla > span { min-width: 0; overflow-wrap: anywhere; }
.casilla input { width: 1.625rem; height: 1.625rem; margin: 0.125rem 0 0; flex: none; accent-color: var(--bosque); }
.campo { margin: 1.5rem 0 0; }
.campo label { display: block; font-weight: 700; font-size: 1rem; }
.ayuda-campo { font-size: 1rem; color: var(--contexto); margin: 0.125rem 0 0.375rem; }
.campo input[type="text"] {
  display: block; width: 100%; min-height: 3.5rem; padding: 0.625rem 0.875rem;
  font: inherit; font-size: 1.125rem; color: var(--tinta); background: var(--campo);
  border: 1px solid var(--borde-papel); border-radius: 0.875rem; box-shadow: inset 0 1px 0 rgba(198, 152, 79, .25);
}
.campo input[type="text"]:focus-visible { border-color: var(--bosque); }
.campo input[aria-invalid="true"] { border: 2px solid var(--peligro); }
.error-campo { color: var(--peligro); font-weight: 700; font-size: 1rem; margin: 0.375rem 0 0; }
.error-campo:not([hidden])::before { content: "! "; font-weight: 800; }
.contador { font-size: 0.875rem; color: var(--contexto); }
.vista-previa { font-size: 1rem; color: var(--contexto); margin: 0.375rem 0 0; }
.vista-previa:empty { display: none; }
select { font: inherit; max-width: 100%; min-height: 3rem; }

/* ------------------------------------------------------------ Diálogos y menú R4 */
.dialogo {
  width: min(36.25rem, calc(100vw - 2rem)); max-width: calc(100vw - 2rem); max-height: calc(100dvh - 2rem);
  border: 1px solid var(--borde-papel); border-radius: var(--radio-plano); padding: 0;
  background: var(--marfil); color: var(--tinta); overflow: auto; overscroll-behavior: contain;
  box-shadow: 0 0 0 1px rgba(198, 152, 79, .4), 0 18px 40px rgba(0, 0, 0, .4);
}
.dialogo[open] { display: flex; flex-direction: column; }
.dialogo::backdrop { background: rgba(28, 22, 18, .72); }
.dialogo > * { margin-left: var(--margen); margin-right: var(--margen); }
/* Cabecera y acciones quedan fuera del desplazamiento del cuerpo (área baja, R4 §2). */
.dialogo-cabecera {
  position: sticky; top: 0; z-index: 1; margin: 0; padding: 1rem var(--margen) 0.75rem;
  display: flex; align-items: flex-start; gap: 0.75rem; background: var(--marfil); border-bottom: 1px solid #EADBC0;
}
.dialogo-cabecera h2 { flex: 1 1 auto; min-width: 0; margin: 0.25rem 0 0; font-size: 1.5rem; }
/* R9 (QA-I-01): con letra ampliada el título no se parte por letras. «Cerrar» pasa a su propia línea cuando el
   título no cabe a su lado (base 10 rem); una palabra que no cabe ni sola se divide por sílabas (guion). */
.dialogo-cabecera { flex-wrap: wrap; }
.dialogo-cabecera h2 { flex-basis: 10rem; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.dialogo-cabecera .boton.cerrar { margin-left: auto; }
/* R9 (excepción adaptativa a R4 §2 autorizada por PM): si cabecera y acciones fijas dejan al cuerpo menos del
   40 % del alto del diálogo, pasan al flujo desplazable. Con espacio suficiente siguen fijas. */
.dialogo.en-flujo > .dialogo-cabecera, .dialogo.en-flujo > .acciones:last-child { position: static; }
.dialogo-cabecera h2:focus { outline: none; }
.dialogo > .acciones:last-child {
  position: sticky; bottom: 0; margin: 1rem 0 0; padding: 1rem var(--margen); background: var(--marfil); border-top: 1px solid #EADBC0;
}
.dialogo-cuerpo { padding: 0.5rem 0 1.5rem; }
/* R9-v02 (QA-J-01): «Cerrar» del plan es el último control desplazable; deja sitio a su indicador de foco (6 px). */
#plan-cuerpo > .acciones:last-child { padding-bottom: 0.75rem; }
.boton.cerrar { width: auto; flex: none; min-height: 2.75rem; padding: 0.375rem 0.75rem; border-width: 1px; font-size: 0.875rem; gap: 0.375rem; }
.aspa { display: inline-block; width: 0.75rem; height: 0.75rem; position: relative; }
.aspa::before, .aspa::after { content: ""; position: absolute; left: 50%; top: -15%; height: 130%; border-left: 2px solid currentColor; }
.aspa::before { transform: rotate(45deg); }
.aspa::after { transform: rotate(-45deg); }

.menu-opciones { width: min(30rem, calc(100vw - 1rem)); margin-top: 0.5rem; }
.grupo-menu { margin: 1rem 0 0; }
.grupo-menu h3.rotulo { margin: 0 0 0.375rem; }
.lista-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.boton.item-menu { min-height: 3rem; border-width: 1px; border-color: var(--borde-papel); background: var(--campo); }
.boton.item-menu.peligro { border-color: var(--peligro); }
.boton.desplegable::after { content: "+"; margin-left: auto; font-size: 1.25rem; line-height: 1; }
.boton.desplegable[aria-expanded="true"]::after { content: "−"; }
.ayuda-item { display: block; font-size: 0.875rem; color: var(--contexto); margin: 0.25rem 0 0 0.25rem; }
.submenu { margin: 0.5rem 0 0 1rem; }
.plegable > summary {
  cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; padding: 0.5rem 0;
  font-size: 0.875rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--contexto);
}
.plegable > .lista-menu, .plegable > .inventario { margin-top: 0.25rem; }

/* ------------------------------------------------------------ Home (R6 v01 01/02) */
.home-apertura { display: grid; grid-template-columns: minmax(0, 1fr); }
.home-apertura > .escena { grid-area: 1 / 1; }
.escena-home { --proporcion: 941 / 1672; }
/* Bloque de llamada: placa de madera A en el cielo (móvil x20 y114 w350) o a la derecha (escritorio x866 w510). */
.home-llamada {
  min-width: 0; overflow-wrap: anywhere; color: var(--marfil); padding: 1rem 1.25rem 1.25rem;
  background: linear-gradient(180deg, rgba(73, 55, 43, .94), rgba(45, 41, 36, .94));
  border: 1px solid #A87B45; border-radius: 1.25rem; box-shadow: 0 8px 20px rgba(0, 0, 0, .3);
}
.home-llamada h1 { color: var(--marfil); font-size: 2.25rem; line-height: 1.12; margin: 0 0 0.25rem; }
.home-llamada .antetitulo { color: var(--ambar-1); font-size: 0.75rem; }
.home-llamada .requisito { font-size: 1rem; margin: 1rem 0 0; }
.home-llamada .acciones { margin-top: 1rem; }
.con-escena > .home-llamada { --superpuesto: 1; grid-area: 1 / 1; align-self: start; margin: 1rem var(--margen) 0; }
.fuera-de-reserva > .home-llamada { --superpuesto: 0; grid-area: 1 / 1; }
.home-apertura.fuera-de-reserva > .escena { grid-area: 2 / 1; }
@media (min-width: 45em) {
  .escena-home { --proporcion: 1672 / 941; }
  .con-escena > .home-llamada { justify-self: end; width: min(35.4%, 32rem); min-width: 20rem; margin: 2.1% 4.4% 0 0; }
  .home-llamada h1 { font-size: 3rem; }
}
/* M01: una sola capa de halos con el mismo rectángulo y escala que la pintura; reposo = opacidad 0. */
.escena-home .m01 { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.escena-home .m01.activa { animation: m01-entrada 1s ease-out both, m01-ciclo 12s ease-in-out 1s infinite; }
@keyframes m01-entrada { from { opacity: 0; } to { opacity: .02; } }
@keyframes m01-ciclo { 0%, 100% { opacity: .02; } 50% { opacity: .04; } }
@media (prefers-reduced-motion: reduce) { .escena-home .m01, .escena-home .m01.activa { animation: none; opacity: 0; } }
/* Control de ambiente en la cabecera de home: espacio reservado 148×44 (R5/R6 v01-08). */
.boton.ambiente, .estado-ambiente { min-width: 9.25rem; min-height: 2.75rem; width: auto; font-size: 0.875rem; }
.boton.ambiente { padding: 0.5rem 0.875rem; border-width: 1px; border-color: var(--borde-papel); justify-content: center; }
.estado-ambiente { margin: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--marfil); }

.home-modulos { max-width: 70rem; margin: 0 auto; padding: 0 var(--margen); display: grid; gap: 1.25rem; }
.modulo { background: var(--marfil); border: 1px solid var(--borde-papel); border-radius: var(--radio-plano); padding: 1.5rem var(--margen); }
.modulo h2 { margin-top: 0; }
.modulo .entrada { font-size: 1.25rem; line-height: 1.45; }
.modulo .nota-modulo { font-size: 1rem; color: var(--contexto); margin: 0; }
.modulo-beta { border-color: var(--informacion); border-left: 4px solid var(--informacion); }
.distintivos { font-size: 0.875rem; font-weight: 700; letter-spacing: .04em; color: var(--contexto); }
.pasos-juego { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.pasos-juego h3 { margin: 0.25rem 0; }
.pasos-juego .numero { font-family: var(--serif); font-weight: 600; color: var(--ambar-base); font-size: 1.25rem; }
@media (min-width: 45em) { .pasos-juego { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.home-pie { max-width: 70rem; margin: 2rem auto 0; padding: 1rem var(--margen) 0; border-top: 1px solid rgba(216, 188, 141, .35); color: #EADBC0; }
.pie-marca { font-weight: 700; margin: 0 0 0.5rem; }
.home-pie .boton { width: auto; color: var(--marfil); background: transparent; border: 0; border-bottom: 1px solid var(--laton); border-radius: 0; padding: 0.5rem 0; min-height: 2.75rem; }
.home > .home-modulos { margin-top: 1.25rem; }
/* R10 hito 2: enlace a la informativa de privacidad; área pulsable de 44 px como el resto del pie. */
.pie-enlaces { margin: 0.5rem 0 0; }
.pie-enlaces a { display: inline-flex; align-items: center; min-height: 2.75rem; color: var(--marfil); text-decoration-color: var(--laton); text-underline-offset: 0.2em; }
.home-pie :focus-visible { outline-color: var(--ambar-1); }

/* ------------------------------------------------------------ Piezas, inventario, materiales, carrusel */
.requisitos { margin: 0 0 0.75rem; padding: 0; list-style: none; }
.requisitos li { margin: 0 0 0.375rem; font-weight: 700; }
.pieza { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; min-width: 0; }
.pieza > span { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.pieza img { width: 4rem; height: 4rem; flex: none; border: 1px solid var(--borde-papel); background: #FFFFFF; border-radius: 0.5rem; }
.casilla .pieza img, .inventario .pieza img { width: 3rem; height: 3rem; }
.inventario { margin: 0; padding: 0; list-style: none; font-size: 1rem; }
.inventario li { margin: 0 0 0.5rem; }
.pendiente { color: var(--contexto); }
.contexto-accion { font-size: 1rem; font-weight: 700; color: var(--contexto); margin: 0; }
.estado-descarga { font-size: 1rem; font-weight: 700; margin: 0.5rem 0; }
.estado-descarga:empty { display: none; }
.acciones-campo { margin: 0.5rem 0 0; }
.grupo-lugar .preparacion { margin-bottom: 0; }
.resumen-materiales { font-weight: 700; margin: 0 0 0.5rem; }
.ayuda-visor { font-size: 1rem; color: var(--contexto); margin: 0 0 0.5rem; }
.vistas-pdf { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr)); gap: 1rem; margin-top: 1rem; }
.vista-pdf { min-width: 0; margin: 0; }
.vista-pdf img { display: block; width: 100%; height: auto; border: 1px solid var(--borde-papel); background: #FFFFFF; }
.vista-pdf figcaption { margin-top: 0.375rem; font-weight: 700; overflow-wrap: anywhere; }
.visor { overflow: auto; max-width: 100%; max-height: 60vh; border: 1px solid var(--borde-papel); background: #FFFFFF; border-radius: 0.5rem; }
.visor img { display: block; max-width: none; }
.visor-controles { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.visor-controles .boton { width: auto; flex: 1 1 auto; }
.limite { font-size: 1rem; color: var(--contexto); }

.carrusel { background: var(--campo); border: 1px solid var(--borde-papel); border-radius: 1rem; padding: var(--margen); margin: 1rem 0; }
.carrusel:focus-within { outline: 3px solid var(--bosque); outline-offset: 3px; }
.tarjeta-personaje { margin: 0; text-align: center; }
.tarjeta-personaje img { display: block; width: min(16rem, 70vw); height: auto; aspect-ratio: 1; margin: 0 auto; }
.tarjeta-personaje figcaption { font-family: var(--serif); font-size: 1.75rem; font-weight: 600; line-height: 1.25; margin: 0.5rem 0 0; }
.contador-carrusel { text-align: center; font-weight: 700; margin: 0.5rem 0 0; }
.controles-carrusel { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0 0; }
@media (min-width: 37.5em) {
  .controles-carrusel { flex-direction: row; }
  .controles-carrusel .boton { flex: 1 1 0; justify-content: center; }
}

/* Avisos de guardado (fallo real) */
.aviso-guardado { margin: 0; padding: 0.75rem var(--margen); background: var(--resumen); border-bottom: 2px solid var(--peligro); }
.aviso-guardado .boton { width: auto; display: inline-flex; margin: 0.5rem 0.5rem 0 0; }

/* F3 conservado: espacios del nombre visibles (OBS-E-02) y valores aislados (QA-G-02). */
.equipo { white-space: break-spaces; overflow-wrap: anywhere; }
.lugar { white-space: break-spaces; }
.equipo, .lugar { unicode-bidi: isolate; }
.vista-previa-habitacion { overflow-wrap: anywhere; }

@media print {
  .cabecera, .acciones, .escena, .home-pie { display: none; }
  .vista-previa-habitacion, #aviso-datos-guardados { display: none; }
}
@media (prefers-reduced-motion: reduce) { .boton:active { transform: none; } }
/* En diálogos el primario es la acción segura (p. ej., Cancelar): sin flecha de avance. */
.dialogo .boton.primario::after { content: none; }
