/* ─────────────────────────────────────────────
   Aula Generativa · Ortografía en contexto
   ───────────────────────────────────────────── */
:root {
  --tinta: #17243b;
  --suave: #5b6679;
  --linea: #dfe4ee;
  --fondo: #f3f5fa;
  --blanco: #fff;
  --lavanda: #7164f4;
  --lavanda-osc: #5547d9;
  --lavanda-cl: #ece9ff;
  --menta: #23b890;
  --menta-cl: #dff6ee;
  --aviso: #fff4d6;
  --aviso-b: #f1d28a;
  --rojo: #d6455d;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(23,36,59,.06), 0 8px 24px rgba(23,36,59,.07);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--tinta);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, select, input { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.saltar { position: absolute; left: -999px; top: 8px; background: var(--tinta); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 50; }
.saltar:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--lavanda); outline-offset: 2px; border-radius: 6px; }

/* ── Cabecera ── */
.top {
  background: var(--tinta); color: #fff; padding: 14px clamp(14px, 3vw, 32px) 0;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px;
}
.marca { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; }
.logo { width: 42px; height: 42px; border-radius: 12px; background: var(--lavanda); display: grid; place-items: center; font: 700 22px/1 Arial, sans-serif; letter-spacing: -1px; }
.marca h1 { margin: 0; font-size: 1.15rem; line-height: 1.1; }
.marca p { margin: 2px 0 0; font-size: .8rem; opacity: .72; }
.pestanas { display: flex; gap: 4px; flex-wrap: wrap; }
.pestanas button {
  background: transparent; border: 0; color: rgba(255,255,255,.75); cursor: pointer;
  padding: 10px 16px; border-radius: 10px 10px 0 0; font-weight: 600; font-size: .92rem;
}
.pestanas button:hover { color: #fff; background: rgba(255,255,255,.08); }
.pestanas button[aria-selected="true"] { background: var(--fondo); color: var(--tinta); }

/* ── Disposición ── */
main { padding: clamp(12px, 2.4vw, 28px); }
.panel-tab { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: clamp(14px, 2.4vw, 28px); align-items: start; max-width: 1380px; margin: 0 auto; }
.panel-tab[hidden] { display: none; }
.panel-ancho { display: block; }
.controles {
  background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 18px; display: grid; gap: 16px; position: sticky; top: 12px;
  max-height: calc(100vh - 24px); overflow: auto;
}
.campo { display: grid; gap: 6px; min-width: 0; }
.etq { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--suave); }
.etq small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.nota { margin: 0; font-size: .82rem; color: var(--suave); }

select {
  width: 100%; padding: 10px 36px 10px 12px; border: 1.5px solid var(--linea); border-radius: 10px; background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2317243b' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  appearance: none; -webkit-appearance: none; text-overflow: ellipsis;
}
select:hover { border-color: #c4cbe0; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-v { flex-direction: column; }
.seg button {
  flex: 1 1 0; min-width: 0; padding: 9px 10px; border: 1.5px solid var(--linea); background: #fff; border-radius: 10px;
  cursor: pointer; font-weight: 600; text-align: center; transition: background .12s, border-color .12s;
}
.seg-v button { text-align: left; padding-left: 14px; }
.seg button:hover { border-color: #c4cbe0; }
.seg button[aria-checked="true"] { background: var(--lavanda-cl); border-color: var(--lavanda); color: var(--lavanda-osc); }

.acciones { display: grid; gap: 8px; }
.btn {
  padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--linea); background: #fff; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: #b9c1d8; background: #fafbff; }
.btn.primario { background: var(--lavanda); border-color: var(--lavanda); color: #fff; }
.btn.primario:hover { background: var(--lavanda-osc); border-color: var(--lavanda-osc); }
.btn-pdf { display: flex; align-items: center; justify-content: center; gap: 9px; }
.ico-pdf { width: 21px; height: 24px; flex: none; }
.btn-sol { color: #0a6b50; border-color: #0a7a5b; }
.btn-sol:hover { background: var(--menta-cl); border-color: #0a7a5b; }
.btn-pdf:not(.btn-sol) { background: #fff; color: #000; border-color: #d93b32; }
.btn-pdf:not(.btn-sol):hover { background: #fdeeed; color: #d93b32; border-color: #d93b32; }
.interruptor { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; padding: 4px 2px; }
.interruptor input { width: 18px; height: 18px; accent-color: var(--menta); }

.regla-info { font-size: .86rem; color: var(--suave); background: #f7f8fc; border-radius: 10px; padding: 8px 12px; }
.regla-info summary { cursor: pointer; font-weight: 600; color: var(--tinta); }
.regla-info div { margin-top: 8px; display: grid; gap: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: #fff; border: 1px solid var(--linea); border-radius: 999px; padding: 1px 9px; font-size: .8rem; color: var(--tinta); }

.vista { min-width: 0; }
.aviso { background: var(--aviso); border: 1px solid var(--aviso-b); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-size: .92rem; }
.aviso[hidden] { display: none; }

/* ── Hojas A4 en pantalla ── */
.hoja-wrap { width: 100%; overflow: hidden; }
.hojas { width: 210mm; transform-origin: top left; display: grid; gap: 22px; }
.hoja {
  width: 210mm; min-height: 297mm; background: #fff; color: #000; padding: 11mm 18mm 10mm;
  box-shadow: var(--sombra); position: relative; overflow: hidden;
  font-family: Arial, "Liberation Sans", Helvetica, "Nimbus Sans", sans-serif; font-size: 11pt; line-height: 1.35;
  display: flex; flex-direction: column;
}
.hoja-cab { display: flex; justify-content: space-between; align-items: flex-end; font-size: 8.5pt; color: #444; margin-bottom: 10mm; gap: 8mm; }
.hoja-cab .cab-izq { white-space: nowrap; }
.hoja-cab .datos { display: flex; gap: 6mm; }
.hoja-cab .datos span { display: inline-flex; align-items: flex-end; gap: 1.5mm; }
.hoja-cab .datos i { display: inline-block; border-bottom: .3mm solid #444; height: 4mm; }
.hoja-cab .d-nom i { width: 52mm; } .hoja-cab .d-fec i { width: 24mm; }

.ovalo {
  align-self: center; border: .5mm solid #000; border-radius: 50%; padding: 2.4mm 12mm; margin: 0 0 4.5mm;
  font-weight: 700; font-size: 14pt; text-align: center; text-transform: uppercase; letter-spacing: .02em; max-width: 160mm; line-height: 1.15;
}
.ovalo.largo { font-size: 11.5pt; padding: 2.4mm 9mm; border-radius: 9mm; }

.dictado { background: #e4e4e4; border-radius: 2.5mm; padding: 2.4mm 3mm 2.6mm; margin: 0 0 4.5mm; }
.dictado-cab { display: flex; justify-content: space-between; align-items: baseline; gap: 6mm; margin-bottom: 1.2mm; }
.dictado-cab b { font-size: 10.5pt; letter-spacing: .03em; }
.dictado-cab span { font-size: 8.5pt; color: #444; font-style: italic; }
.dictado .texto {
  margin: 0; width: 168mm; font: 11pt Arial, "Liberation Sans", Helvetica, "Nimbus Sans", sans-serif; line-height: 1.5; text-align: justify; hyphens: none; -webkit-hyphens: none;
}
mark.r { background: #bff0dd; padding: 0; box-shadow: 0 0 0 .25mm #bff0dd; }

.hoja h2 { margin: 0 0 2.2mm; font-size: 12.5pt; letter-spacing: .04em; font-weight: 700; }
.hoja ol { margin: 0 0 4mm; padding: 0; list-style: none; counter-reset: n; }
.hoja ol > li { counter-increment: n; position: relative; padding-left: 7mm; margin-bottom: 2.6mm; break-inside: avoid; }
.hoja ol > li::before { content: counter(n) "."; position: absolute; left: 0; top: 0; font-weight: 700; }
.q { display: block; }
.q + .q { margin-top: 0; }
.q-comp .q { display: inline; }
.q-comp .lineas + .q { display: block; margin-top: 1.6mm; }
.lineas { --alt: 7.6mm; }
.lineas i { display: block; height: var(--alt); border-bottom: .3mm solid #333; }
.escribe-t { font-size: 11.5pt !important; letter-spacing: 0 !important; line-height: 1.35; margin-top: 6mm !important;}
.escribe-t u { text-decoration-thickness: .35mm; text-underline-offset: .8mm; }
.pal li b { font-size: 11.5pt; }
.hoja-pie { margin-top: auto; padding-top: 3mm; font-size: 7.5pt; color: #777; display: flex; justify-content: space-between; }

/* ── Ficha de palabras ── */
.hoja .titulo-pal { text-align: center; font-size: 9.5pt; letter-spacing: .12em; font-weight: 700; color: #333; margin: 0 0 3.5mm; }
.completa { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8mm; margin: 0 0 3mm; padding: 0; list-style: none; counter-reset: n; }
.hoja .completa > li { padding-left: 7mm; margin-bottom: 3.4mm; display: block; }
.completa .it { font-size: 11.5pt; }
.completa .it b { font-size: 12.5pt; letter-spacing: .03em; }
.completa .pista { display: block; font-size: 8.5pt; color: #555; font-style: italic; line-height: 1.2; }
.completa .hueco { display: block; height: 6.4mm; border-bottom: .3mm solid #333; margin-top: .6mm; }
.completa.una { grid-template-columns: 1fr; }
.dict-lista { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8mm; margin: 0 0 3mm; padding: 0; list-style: none; counter-reset: n; }
.hoja .dict-lista > li { padding-left: 7mm; margin-bottom: 1.6mm; height: 7.2mm; border-bottom: .3mm solid #333; }
.hoja .dict-lista > li::before { top: 1.4mm; }
.sub { font-size: 9pt; color: #555; font-weight: 400; letter-spacing: 0; }


.hoja h2 .sub { font-size: 9pt; font-weight: 400; letter-spacing: 0; color: #555; margin-left: 1.5mm; }
.completa .lineas { margin-top: .6mm; }
.dict-frases { margin: 0 0 3mm; padding: 0; list-style: none; counter-reset: n; }
.hoja .dict-frases > li { padding-left: 7mm; margin-bottom: 1.2mm; }
.hoja .dict-frases > li::before { top: 1.2mm; }
.hoja ol.esc > li { margin-bottom: 1.6mm; }
.sol-lista { display: grid; grid-template-columns: 1fr 1fr; column-gap: 8mm; padding: 0; margin: 0 0 3mm; list-style: none; counter-reset: n; font-size: 10.5pt; }
.sol-lista.una { grid-template-columns: 1fr; }
.hoja .sol-lista > li { padding-left: 7mm; margin-bottom: 1.4mm; }
.sol-lista .r { color: #0a6b50; font-weight: 700; }

/* ── Hoja compactada cuando el contenido no cabe en un folio ── */
.hoja.c1 { padding-top: 9mm; padding-bottom: 7mm; }
.hoja.c1 .lineas { --alt: 6.8mm; }
.hoja.c1 .ovalo { margin-bottom: 3mm; padding: 1.8mm 10mm; }
.hoja.c1 .dictado { margin-bottom: 3mm; }
.hoja.c1 ol > li { margin-bottom: 1.6mm; }
.hoja.c1 ol { margin-bottom: 2.4mm; }
.hoja.c1 .hoja-cab { margin-bottom: 6mm; }
.hoja.c2 { padding-top: 8mm; padding-bottom: 6mm; font-size: 10.5pt; }
.hoja.c2 .lineas { --alt: 6.1mm; }
.hoja.c2 .ovalo { margin-bottom: 2.4mm; padding: 1.4mm 9mm; font-size: 12.5pt; }
.hoja.c2 .dictado { margin-bottom: 2.4mm; }
.hoja.c2 ol > li { margin-bottom: 1.2mm; }
.hoja.c2 ol { margin-bottom: 1.8mm; }
.hoja.c2 .hoja-cab { margin-bottom: 4mm; }
.hoja.c2 h2 { margin-bottom: 1.4mm; }
.hoja.c2 .completa .hueco { height: 5.6mm; }
.hoja.c2 .dict-lista > li { height: 6.2mm; margin-bottom: 1mm; }

/* ── Soluciones ── */
.solucion { display: none; }
body.con-sol .solucion { display: flex; }
.solucion h2 { color: #0a7a5b; }
.solucion .sol-q { margin: 0 0 3mm; font-size: 10.5pt; }
.solucion .sol-q .p { color: #333; display: block; }
.solucion .sol-q .r { display: block; color: #0a6b50; font-weight: 700; margin-top: .4mm; }
.solucion .sol-sub { font-size: 9.5pt; color: #444; margin-bottom: 3mm; }
.solucion .sol-pal { font-size: 10.5pt; }
.sol-etq { display: inline-block; background: #0a7a5b; color: #fff; padding: .6mm 3mm; border-radius: 1.5mm; font-size: 8.5pt; letter-spacing: .08em; font-weight: 700; margin-bottom: 3mm; }
body:not(.con-sol) mark.r { background: transparent; box-shadow: none; }

/* ── Reglas ── */
.reglas-cab { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 30px; margin-bottom: 18px; }
.reglas-cab h2 { margin: 0 0 4px; font-size: 1.4rem; }
.reglas-cab p { margin: 0; color: var(--suave); max-width: 62ch; }
.reglas-cab .seg { min-width: 280px; }
.grupo-tit { font-size: .8rem; text-transform: uppercase; letter-spacing: .09em; color: var(--suave); margin: 22px 0 8px; font-weight: 700; }
.reglas-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.tarjeta { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; display: grid; gap: 10px; align-content: start; }
.tarjeta h3 { margin: 0; font-size: 1.02rem; line-height: 1.25; }
.tarjeta .cab { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--lavanda-osc); background: var(--lavanda-cl); border-radius: 999px; padding: 2px 10px; }
.tarjeta p { margin: 0; font-size: .88rem; color: #3a465c; }
.cob { display: flex; gap: 6px; flex-wrap: wrap; }
.cob span { font-size: .8rem; background: var(--menta-cl); color: #0b6e55; border-radius: 8px; padding: 2px 8px; font-weight: 600; }
.cob span.baja { background: #ffe1e6; color: #a1233a; }
.tarjeta .ir { display: flex; gap: 8px; flex-wrap: wrap; }
.tarjeta .ir button { border: 1.5px solid var(--linea); background: #fff; border-radius: 9px; padding: 6px 10px; cursor: pointer; font-weight: 600; font-size: .84rem; }
.tarjeta .ir button:hover { border-color: var(--lavanda); color: var(--lavanda-osc); }
.matriz { margin-top: 26px; background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px 18px; }
.matriz summary { cursor: pointer; font-weight: 700; }
.tabla-wrap { overflow: auto; margin-top: 12px; }
.tabla-wrap table { border-collapse: collapse; font-size: .82rem; min-width: 900px; width: 100%; }
.tabla-wrap th, .tabla-wrap td { border: 1px solid var(--linea); padding: 4px 6px; text-align: center; }
.tabla-wrap th { background: #f5f6fb; font-weight: 700; }
.tabla-wrap td:first-child, .tabla-wrap th:first-child { text-align: left; position: sticky; left: 0; background: #fff; min-width: 190px; }
.tabla-wrap th:first-child { background: #f5f6fb; }
.tabla-wrap td.na { color: #b4bbcb; background: #fafbfd; }
.tabla-wrap td.ok { background: var(--menta-cl); color: #0b6e55; font-weight: 600; }
.tabla-wrap td.bajo { background: #ffe1e6; color: #a1233a; font-weight: 700; }

.pie { text-align: center; color: var(--suave); font-size: .82rem; padding: 10px 20px 28px; }
.pie p { margin: 0 auto; max-width: 80ch; }

/* ── Pantallas pequeñas ── */
@media (max-width: 980px) {
  .panel-tab { grid-template-columns: 1fr; }
  .controles { position: static; max-height: none; }
}

/* ── Impresión: solo la(s) hoja(s) A4 ── */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #fff !important; }
  .no-print, .top, .pie, .saltar { display: none !important; }
  main { padding: 0 !important; }
  .panel-tab { display: block !important; max-width: none; }
  .panel-tab[hidden] { display: none !important; }
  .hoja-wrap { overflow: visible !important; height: auto !important; }
  .hojas { transform: none !important; width: auto !important; display: block !important; }
  body.solo-sol .hoja.ficha { display: none !important; }
  body.solo-sol .hoja.solucion { page-break-before: auto; break-before: auto; }
  .hoja { box-shadow: none !important; margin: 0 !important; width: 210mm !important; height: 297mm !important; min-height: 0 !important; overflow: hidden; break-inside: avoid; }
  .hoja.solucion { page-break-before: always; break-before: page; }
  .solucion { display: none !important; }
  body.con-sol .solucion { display: flex !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .hoja {
  box-shadow: none !important;
  margin: 0 !important;
  width: 210mm !important;
  height: 297mm !important;
  min-height: 0 !important;
  overflow: hidden;
  break-inside: avoid;
  position: relative;
  left: -27mm;
}
.dictado-cab b {
  display: none !important;
}
}

.hoja-cab .cab-izq { display: none; }

/* nombre con raya larga y fecha al final */
.hoja-cab .datos { flex: 1; gap: 10mm; }
.hoja-cab .d-nom { flex: 1; }
.hoja-cab .d-nom i { flex: 1; width: auto; }

/* ── Icono de información (cabecera) y ventana de aviso de titularidad ── */
.top-der { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 32px; }
.btn-info {
  width: 38px; height: 38px; margin-bottom: 4px; padding: 0; display: grid; place-items: center; cursor: pointer;
  color: #fff; background: rgba(255,255,255,.1); border: 1.5px solid rgba(255,255,255,.3); border-radius: 50%;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn-info:hover { background: var(--lavanda); border-color: var(--lavanda); transform: scale(1.06); }

/* Botón «Instalar app» (solo aparece si el navegador permite instalar la PWA) */
.btn-instalar {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; margin-bottom: 4px; padding: 0 16px; cursor: pointer;
  font-family: inherit; font-size: .85rem; font-weight: 600; line-height: 1; color: #fff; background: var(--lavanda); border: 1.5px solid var(--lavanda); border-radius: 999px;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn-instalar[hidden] { display: none; }
.btn-instalar:hover { background: var(--lavanda-osc); border-color: var(--lavanda-osc); transform: translateY(-1px); }
.btn-instalar:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (display-mode: standalone) { .btn-instalar { display: none; } }

.aviso-legal {
  width: min(640px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; padding: 0;
  border: 0; border-radius: 20px; background: var(--blanco); color: var(--tinta);
  box-shadow: 0 24px 60px rgba(23,36,59,.35), 0 2px 6px rgba(23,36,59,.15);
}
.aviso-legal::backdrop { background: rgba(23,36,59,.55); backdrop-filter: blur(3px); }
.aviso-legal[open] { animation: al-entra .22s ease-out; }
.aviso-legal[open]::backdrop { animation: al-fondo .22s ease-out; }
@keyframes al-entra { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes al-fondo { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .aviso-legal[open], .aviso-legal[open]::backdrop { animation: none; } }
body:has(.aviso-legal[open]) { overflow: hidden; }

.al-caja { position: relative; padding: 30px clamp(20px, 5vw, 38px) 26px; border-top: 6px solid var(--lavanda); }
.al-x { position: absolute; top: 14px; right: 14px; margin: 0; }
.al-cerrar {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: var(--fondo); color: var(--suave);
  font-size: 1.5rem; line-height: 1; cursor: pointer; transition: background .15s, color .15s;
}
.al-cerrar:hover { background: var(--lavanda-cl); color: var(--lavanda-osc); }
.al-cab { display: flex; align-items: center; gap: 14px; margin: 0 40px 18px 0; }
.al-sello {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--lavanda-cl); color: var(--lavanda-osc); font: 700 24px/1 Arial, sans-serif;
}
.al-cab h2 { margin: 0; font-size: 1.05rem; letter-spacing: .08em; line-height: 1.25; }
.aviso-legal p { margin: 0 0 13px; font-size: .94rem; line-height: 1.62; }
.aviso-legal .al-autor { font-weight: 700; font-size: 1rem; }
.aviso-legal .al-terceros { background: var(--fondo); border-left: 4px solid var(--lavanda); border-radius: 0 10px 10px 0; padding: 10px 14px; color: var(--suave); }
.al-pie { margin: 18px 0 0; display: flex; justify-content: flex-end; }
.al-pie .btn { padding-inline: 26px; }