:root {
  --brand: #702079;
  --brand-dark: #54175c;
  --brand-soft: #f3eaf5;
  --text: #1f2024;
  --muted: #64666d;
  --border: #e3e3e8;
  --surface: #ffffff;
  --surface-soft: #f7f7f9;
  --viewer: #303036;
  --focus: #a85bb4;
  --shadow: 0 20px 55px rgba(20, 20, 25, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: #f2f2f4;
}

body {
  margin: 0;
  color: var(--text);
  background: #f2f2f4;
}

/* Fondo editorial de la aplicación. Se aplica al <main>, no al body,
   para que el visor pueda integrarse después dentro de otras páginas. */
.revista-main {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  overflow: hidden;
  background: #aaa4d5;
}

.revista-main::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: url("../assets/bg-revista-huella-coahuila.png");
  background-repeat: repeat;
  background-position: top center;
  background-size: 760px auto;
  opacity: 0.74;
}


button,
select,
input,
a {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 56px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
  padding: 26px 28px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 45px rgba(34, 27, 58, 0.10);
  backdrop-filter: blur(4px);
}

.app-header > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
}

h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  line-height: 1.15;
}

.intro {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.button,
.icon-button,
.small-button,
.plain-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.button {
  gap: 10px;
  min-height: 46px;
  padding: 11px 17px;
  border-radius: 10px;
  font-weight: 750;
  text-decoration: none;
}

.button-primary {
  color: #fff;
  background: var(--brand);
}

.button-secondary {
  color: var(--brand);
  border: 1px solid #cfc5d2;
  background: #fff;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #fff;
  font-size: 1.28rem;
  font-weight: 800;
}

.small-button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: #fff;
  font-size: 0.9rem;
  font-weight: 750;
}

.plain-button {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--brand);
  background: transparent;
  font-weight: 750;
}

@media (hover: hover) and (pointer: fine) {
  .button:not(:disabled):hover,
  .icon-button:not(:disabled):hover,
  .small-button:not(:disabled):hover,
  .plain-button:not(:disabled):hover {
    transform: translateY(-1px);
  }

  .button-primary:not(:disabled):hover {
    background: var(--brand-dark);
  }

  .button-secondary:not(:disabled):hover,
  .small-button:not(:disabled):hover {
    background: var(--brand-soft);
  }
}

.viewer-card,
.reader-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.viewer-toolbar {
  display: grid;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.toolbar-row-zoom {
  padding-top: 8px;
  border-top: 1px solid #eeeeef;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar-actions {
  margin-left: auto;
}

.page-status,
.zoom-status {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

.page-status {
  min-width: 82px;
  text-align: center;
}

.zoom-status {
  min-width: 58px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.zoom-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.goto-form {
  display: flex;
  align-items: center;
  gap: 7px;
}

.goto-form label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.goto-form input {
  width: 74px;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}

.search-panel {
  padding: 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.search-form {
  display: grid;
  gap: 8px;
  max-width: 780px;
}

.search-form label {
  font-weight: 800;
}

.search-input-row {
  display: flex;
  gap: 10px;
}

.search-input-row input {
  min-width: 0;
  flex: 1 1 auto;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 1rem;
}

.search-status {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.search-results {
  display: grid;
  gap: 8px;
  max-height: 280px;
  margin-top: 12px;
  overflow: auto;
}

.search-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: inherit;
  text-align: left;
  background: #fff;
  cursor: pointer;
}

.search-result-page {
  display: grid;
  place-items: center;
  min-width: 54px;
  min-height: 40px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 850;
}

.search-result-snippet {
  min-width: 0;
  color: #45474d;
  font-size: 0.9rem;
  line-height: 1.45;
}

.viewer-layout {
  display: flex;
  min-width: 0;
}

.thumbnail-panel {
  width: 250px;
  flex: 0 0 250px;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: #fafafa;
}

.thumbnail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border);
}

.thumbnail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 720px;
  padding: 12px;
  overflow: auto;
}

.thumbnail-button {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.thumbnail-button[aria-current="page"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(112, 32, 121, 0.14);
}

.thumbnail-canvas-wrap {
  aspect-ratio: 612 / 859;
  overflow: hidden;
  border-radius: 4px;
  background: #ededf0;
}

.thumbnail-button canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.thumbnail-label {
  font-size: 0.78rem;
  font-weight: 750;
  text-align: center;
}

.viewer-area {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 660px;
  padding: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.08), transparent 38%),
    var(--viewer);
}

.loading-panel,
.error-panel {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 680px;
  padding: 28px;
  border-radius: 14px;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.18);
}

.loading-panel span {
  color: rgba(255, 255, 255, 0.76);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-panel p {
  margin: 0;
  line-height: 1.55;
}

.error-panel code {
  padding: 2px 5px;
  border-radius: 4px;
  color: #222;
  background: #fff;
}

.book-scroll {
  width: 100%;
  height: 100%;
  max-height: 760px;
  overflow: auto;
  padding: 8px 8px 20px;
  scrollbar-gutter: stable;
}

.book-zoom-space {
  position: relative;
  margin: 0 auto;
  transform-origin: top left;
}

.book {
  width: min(1040px, 100%);
  height: min(720px, 68vw);
  min-height: 520px;
  transform-origin: top left;
  transition: transform 150ms ease;
}

.page {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.page canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.page-render-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  color: #76777d;
  background: linear-gradient(135deg, #f7f7f7, #ececef);
  font-size: 0.8rem;
  text-align: center;
}

.page.is-rendered .page-render-status {
  display: none;
}

.viewer-hint {
  margin: 0;
  padding: 12px 18px 14px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #fff;
  font-size: 0.9rem;
  text-align: center;
}

.reader-card {
  margin-top: 28px;
  padding: 26px;
}

.reader-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.reader-heading p:not(.eyebrow) {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.reader-page-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--brand-soft);
  font-size: 0.88rem;
  font-weight: 800;
}

.speech-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
}

.rate-control,
.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 6px 10px 6px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  font-weight: 700;
}

.rate-control select {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.switch-control input {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
}

.reader-text-wrap {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.reader-loading {
  margin: 0;
  color: var(--muted);
}

.reader-text {
  display: grid;
  gap: 22px;
  max-height: 420px;
  overflow: auto;
}

.reader-page-section {
  display: grid;
  gap: 10px;
}

.reader-page-section + .reader-page-section {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.reader-page-title {
  margin: 0;
  color: var(--brand);
  font-size: 1rem;
}

.reader-page-content {
  white-space: pre-wrap;
  color: #303137;
  line-height: 1.7;
}

.reader-note {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.app-footer {
  margin-top: 22px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  color: #474250;
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.86rem;
  text-align: center;
  backdrop-filter: blur(3px);
}

.app-footer p {
  margin: 0;
}

@media (max-width: 900px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  .toolbar-actions {
    margin-left: 0;
  }

  .thumbnail-panel {
    position: absolute;
    z-index: 20;
    width: min(320px, 88%);
    height: 100%;
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.22);
  }

  .viewer-layout {
    position: relative;
  }

  .thumbnail-list {
    max-height: 720px;
  }

  .reader-heading {
    flex-direction: column;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 28px;
  }

  .revista-main::before {
    background-size: 560px auto;
    opacity: 0.68;
  }

  .viewer-toolbar {
    padding: 10px;
  }

  .toolbar-row {
    align-items: stretch;
  }

  .toolbar-nav,
  .toolbar-actions,
  .goto-form {
    justify-content: center;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .small-button {
    flex: 1 1 0;
  }

  .toolbar-row-zoom {
    align-items: center;
    justify-content: center;
  }

  .zoom-help {
    width: 100%;
    text-align: center;
  }

  .search-input-row {
    flex-direction: column;
  }

  .viewer-area {
    min-height: 610px;
    padding: 10px;
  }

  .book-scroll {
    max-height: 720px;
    padding-inline: 2px;
  }

  .book {
    width: min(94vw, 610px);
    height: min(132vw, 858px);
    min-height: 470px;
  }

  .reader-card {
    padding: 20px 16px;
  }

  .speech-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .speech-controls > * {
    width: 100%;
  }

  .rate-control,
  .switch-control {
    justify-content: space-between;
  }
}

@media (max-width: 430px) {
  .goto-form {
    width: 100%;
  }

  .goto-form input {
    flex: 1 1 auto;
    width: auto;
  }

  .viewer-area {
    min-height: 540px;
  }

  .book {
    min-height: 430px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}


/* ==========================================
   V5 · MODO DE LECTURA ACCESIBLE
========================================== */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: #1c1c1f;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.mode-switch {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 18px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 14px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 12px 28px rgba(34,27,58,.08);
  backdrop-filter: blur(4px);
}

.mode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.mode-button.is-active,
.mode-button[aria-pressed="true"] {
  color: #fff;
  background: var(--brand);
}

.accessible-reader {
  margin-top: 0;
  overflow: visible;
}

.accessible-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.accessible-nav,
.text-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.control-label {
  color: var(--muted);
  font-weight: 800;
}

.text-size-status {
  min-width: 58px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.voice-control,
.rate-control,
.switch-control {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 6px 10px 6px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  font-weight: 700;
}

.voice-control select,
.rate-control select {
  min-height: 34px;
  max-width: 260px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
}

.accessible-reader .reader-text-wrap {
  background: #fff;
  transition: background-color 150ms ease, color 150ms ease;
}

.accessible-reader .reader-text {
  max-height: none;
  overflow: visible;
  font-size: 100%;
  line-height: 1.85;
}

.accessible-reader .reader-page-section {
  max-width: 920px;
  margin: 0 auto;
}

.accessible-reader .reader-page-title {
  font-size: 1.1em;
}

.accessible-reader .reader-page-content {
  font-size: 1em;
  line-height: 1.85;
}

.accessible-reader .reader-page-content p {
  margin: 0 0 1em;
  white-space: pre-line;
}

.accessible-reader .reader-page-content p:last-child {
  margin-bottom: 0;
}

.accessible-reader.is-high-contrast {
  --text: #fff;
  --muted: #f1f1f1;
  --border: #fff;
  --surface: #000;
  --surface-soft: #0b0b0b;
  --brand: #fff;
  --brand-soft: #181818;
  color: #fff;
  background: #000;
  border-color: #fff;
}

.accessible-reader.is-high-contrast .reader-heading p,
.accessible-reader.is-high-contrast .reader-page-content,
.accessible-reader.is-high-contrast .reader-page-title,
.accessible-reader.is-high-contrast .reader-note,
.accessible-reader.is-high-contrast .control-label,
.accessible-reader.is-high-contrast .text-size-status {
  color: #fff;
}

.accessible-reader.is-high-contrast .reader-text-wrap,
.accessible-reader.is-high-contrast .accessible-toolbar,
.accessible-reader.is-high-contrast .voice-control,
.accessible-reader.is-high-contrast .rate-control,
.accessible-reader.is-high-contrast .switch-control,
.accessible-reader.is-high-contrast .small-button,
.accessible-reader.is-high-contrast .icon-button,
.accessible-reader.is-high-contrast select,
.accessible-reader.is-high-contrast input {
  color: #fff;
  border-color: #fff;
  background: #000;
}

.accessible-reader.is-high-contrast .button-primary {
  color: #000;
  background: #fff;
}

.accessible-reader.is-high-contrast .button-secondary {
  color: #fff;
  border-color: #fff;
  background: #000;
}

@media (max-width: 700px) {
  .mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .accessible-toolbar,
  .accessible-nav,
  .text-controls {
    width: 100%;
  }

  .accessible-nav,
  .text-controls {
    justify-content: center;
  }

  .voice-control,
  .rate-control,
  .switch-control {
    width: 100%;
    justify-content: space-between;
  }

  .voice-control select,
  .rate-control select {
    min-width: 0;
    max-width: 58%;
  }
}


/* =========================================
   V6 · ACCESIBILIDAD INTEGRADA
   El flipbook y la lectura accesible conviven
   dentro de la misma experiencia.
========================================= */

.reader-card.accessible-reader {
  display: block;
  scroll-margin-top: 24px;
}

.reader-card.accessible-reader::before {
  content: "";
  display: block;
  width: 56px;
  height: 4px;
  margin: -6px 0 20px;
  border-radius: 999px;
  background: var(--brand);
}

.reader-page-badge {
  white-space: nowrap;
}

.reader-text {
  max-height: 520px;
  overflow: auto;
  scroll-behavior: smooth;
}

.accessible-reader .reader-text {
  max-height: 520px;
  overflow: auto;
}

.accessible-reader .reader-page-section {
  max-width: 920px;
  width: 100%;
}

.accessible-reader .reader-page-section + .reader-page-section {
  margin-top: 28px;
}

@media (max-width: 760px) {
  .reader-page-badge {
    white-space: normal;
  }
}


/* ==========================================
   V8 · Publicación / integración WordPress
========================================== */

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.button-on-dark {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.8);
  background: transparent;
}

.button-on-dark:hover {
  color: #222;
  background: #fff;
}

html.is-embedded body {
  background: transparent;
}

html.is-embedded .revista-main {
  min-height: 0;
}

html.is-embedded .app-shell {
  padding-top: 18px;
  padding-bottom: 18px;
}

html.is-embedded .app-footer {
  margin-bottom: 0;
}

@media (max-width: 700px) {
  html.is-embedded .app-shell {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}


/* ==========================================
   V9 · Gestos de zoom y navegación móvil
========================================== */

/*
 * A más de 100% el libro deja de capturar el gesto de un dedo.
 * El contenedor desplazable recibe el gesto para recorrer la página.
 * La hoja se cambia con los botones anterior/siguiente.
 */
.book-scroll.is-pan-mode {
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.book-scroll.is-pan-mode.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.book-scroll.is-pan-mode .book {
  pointer-events: none;
}

/* Lector móvil: el área desplazable coincide con la hoja, sin el espacio
   de una doble página ni la captura de gestos del flipbook. */
html.is-mobile-reader .viewer-area {
  display: block;
  min-height: 0;
  padding: 0;
}

html.is-mobile-reader .book-scroll {
  height: min(141vw, 75svh);
  min-height: 240px;
  max-height: none;
  padding: 0;
  scrollbar-gutter: auto;
  overscroll-behavior: contain;
  overflow: auto;
}

html.is-mobile-reader .book {
  position: relative;
  min-height: 0;
  transition: none;
}

html.is-mobile-reader .book-zoom-space {
  overflow: hidden;
}

html.is-mobile-reader .book .page {
  width: 100%;
  height: 100%;
}

.zoom-help.is-pan-mode {
  font-weight: 750;
}

/* V13 · Entrada al lector y opciones de voz */
.reading-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  padding: 24px;
  margin-bottom: 24px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.reading-launch p { margin: 6px 0 0; line-height: 1.6; }
.reading-launch-actions, .reading-mode-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.voice-options { flex: 1 1 260px; }
.voice-options summary { cursor: pointer; padding: 12px; min-height: 44px; font-weight: 700; }
.voice-options-fields { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 0; }
.reading-topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: #fff;
  color: #24212c;
  border-bottom: 1px solid #ddd;
}
.reading-mode-controls [aria-pressed="true"] { background: #e5def8; color: #392251; border-color: #735887; }
html.reading-is-open { overflow: hidden; }
.reading-experience.is-reading-open {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #27252d;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior: contain;
}
.reading-experience:fullscreen { width: 100%; height: 100%; }
.reading-experience:-webkit-full-screen { width: 100%; height: 100%; }
.is-reading-open .viewer-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  margin: 0;
}
.is-reading-open .viewer-toolbar { flex: 0 0 auto; gap: 6px; padding: 8px 12px; }
.is-reading-open .viewer-layout { position: relative; flex: 1 1 0; min-height: 0; }
.is-reading-open .viewer-area { display: block; min-height: 0; padding: 0; }
.is-reading-open .book-scroll,
html.is-mobile-reader .is-reading-open .book-scroll {
  height: 100%;
  min-height: 0;
  max-height: none;
  padding: 0;
  scrollbar-gutter: auto;
  overscroll-behavior: contain;
}
.is-reading-open .book { transition: none; }
.is-reading-open .viewer-hint, .is-reading-open .zoom-help { display: none; }
.is-reading-open .toolbar-row-zoom { padding-top: 6px; }
.is-reading-open .search-panel { flex: 0 1 auto; overflow: auto; max-height: 40%; }
.is-reading-open .search-results { max-height: 150px; }
.is-reading-open .thumbnail-panel { position: absolute; inset: 0 auto 0 0; z-index: 10; width: 220px; overflow: auto; box-shadow: 4px 0 15px #0004; }
.is-reading-open .thumbnail-list { max-height: none; }
.is-reading-open .reader-card {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 16px clamp(16px, 5vw, 80px);
  border-radius: 0;
  overflow: auto;
  overscroll-behavior: contain;
}
.is-reading-open .reader-heading { margin-bottom: 12px; }
.is-reading-open .reader-card::before { display: none; }
.is-reading-open .reader-heading p { display: none; }
.is-reading-open .reader-heading h2 { font-size: 1.3rem; }
.is-reading-open .accessible-toolbar { position: sticky; top: -16px; z-index: 5; background: var(--surface); padding-block: 10px; }
.is-reading-open .reader-text,
.is-reading-open .accessible-reader .reader-text { max-height: none; overflow: visible; }
.is-reading-open .speech-controls { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
.is-reading-open .speech-controls > .button { width: auto; flex: 0 1 auto; }
.is-reading-open .speech-controls > .voice-options { flex: 1 1 100%; }
@media (max-width: 700px) {
  .reading-launch { padding: 18px; }
  .reading-launch-actions { width: 100%; }
  .reading-launch-actions > button { flex: 1 1 180px; }
  .reading-topbar > strong { display: none; }
  .reading-topbar { flex-wrap: nowrap; padding-inline: 8px; }
  .reading-topbar .small-button { font-size: .78rem; padding: 8px; min-height: 44px; }
  .is-reading-open .viewer-toolbar { padding: 6px 8px; }
  .is-reading-open .toolbar-row { justify-content: space-between; gap: 6px; }
  .is-reading-open .toolbar-nav { flex: 0 0 auto; }
  .is-reading-open #goto-form { flex: 0 0 auto; width: auto; gap: 4px; }
  .is-reading-open #goto-page { width: 48px; }
  .is-reading-open .toolbar-actions { width: auto; flex: 1 1 auto; justify-content: flex-end; }
  .is-reading-open .toolbar-row-zoom .toolbar-group { flex-wrap: wrap; gap: 5px; }
  .is-reading-open .small-button { min-height: 44px; }
  .is-reading-open .reader-card { padding: 12px; }
  .is-reading-open .accessible-toolbar { top: -12px; }
  .is-reading-open .accessible-nav { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; width: 100%; align-items: center; gap: 6px; }
  .is-reading-open #reader-goto-form { display: flex; flex-direction: row; justify-content: center; width: auto; min-width: 0; gap: 5px; }
  .is-reading-open #reader-goto-page { width: 55px; flex: 0 1 55px; }
  .is-reading-open .text-controls { justify-content: center; }
}

@media (max-width: 700px) {
  .book-scroll.is-pan-mode {
    scrollbar-width: thin;
  }
}

/* V14 · Controles junto a la lectura, sin ocupar la cabecera */
.edge-navigation { display: none; }
.immersive-search-close { float: right; margin-bottom: 8px; }
.is-reading-open { --dock-height: 64px; }
.is-reading-open .viewer-toolbar { display: none; }
.is-reading-open .viewer-card, .is-reading-open .reader-card { order: 1; }
.is-reading-open .reading-topbar {
  order: 2;
  position: relative;
  z-index: 40;
  min-height: var(--dock-height);
  flex-wrap: nowrap;
  gap: 12px;
  padding: 8px 16px;
  background: #29272e;
  color: #fff;
  border: 0;
}
.reading-topbar > strong { flex: 1 1 0; font-size: .9rem; }
.dock-navigation, .dock-tools { display: flex; align-items: center; gap: 5px; }
.dock-tools { flex: 1 1 0; justify-content: flex-end; }
.dock-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  color: #fff;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.dock-button:hover, .dock-button[aria-expanded="true"] { background: #48414f; border-color: #8c799d; }
.dock-button:disabled { opacity: .35; cursor: default; }
.dock-button:focus-visible, .edge-navigation:focus-visible { outline: 3px solid #e6bcff; outline-offset: -3px; }
.dock-access { font-size: .85rem; font-weight: 700; }
#dock-page-status { min-width: 90px; text-align: center; font-size: .9rem; white-space: nowrap; }
.dock-more { position: relative; }
.dock-more > summary { list-style: none; }
.dock-more > summary::-webkit-details-marker { display: none; }
.dock-more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: grid;
  gap: 8px;
  width: min(290px, calc(100vw - 24px));
  max-height: calc(100dvh - 140px);
  overflow: auto;
  padding: 14px;
  color: #24212c;
  background: #fff;
  border: 1px solid #d8d2df;
  border-radius: 12px;
  box-shadow: 0 -8px 30px #0004;
}
.dock-more-menu .small-button { min-height: 44px; text-align: left; }
.dock-more-menu .goto-form { display: flex; flex-wrap: wrap; width: auto; }
.dock-more-menu input { width: 62px; }
.is-reading-open .edge-navigation {
  display: flex;
  position: absolute;
  top: calc((100% - var(--dock-height)) / 2 - 30px);
  z-index: 12;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 60px;
  border: 0;
  border-radius: 10px;
  font-size: 3rem;
  line-height: 1;
  color: #fff;
  background: #24212cba;
  cursor: pointer;
}
.edge-prev { left: 8px; }
.edge-next { right: 8px; }
.edge-navigation:disabled { opacity: .25; cursor: default; }
.is-reading-open .viewer-area { padding-inline: 64px; }
html.is-mobile-reader .is-reading-open .book-scroll { display: flex; }
.is-reading-open .book-zoom-space { flex: 0 0 auto; margin: auto; }
.is-reading-open .thumbnail-panel { bottom: 0; }
.is-reading-open .search-panel { position: absolute; top: 12px; right: 64px; left: 64px; z-index: 18; max-height: 65%; border-radius: 12px; box-shadow: 0 10px 30px #0005; }
.is-reading-open .reader-card.is-access-panel {
  position: absolute;
  inset: 0 0 var(--dock-height) auto;
  z-index: 25;
  width: min(480px, 100%);
  padding: 16px;
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px #0004;
}
.access-panel-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.is-access-panel .accessible-toolbar { position: static; }
.is-access-panel .accessible-nav { display: flex; flex-wrap: wrap; width: 100%; gap: 6px; }
.is-access-panel #reader-goto-form { display: flex; flex-direction: row; justify-content: center; width: auto; gap: 5px; }
.is-access-panel #reader-goto-page { width: 55px; flex: 0 1 55px; }
.is-access-panel .reader-heading { display: block; }
.is-access-panel .reader-page-badge { margin-top: 8px; display: inline-block; }
@media (max-width: 700px) {
  .is-reading-open { --dock-height: 108px; }
  .is-reading-open .reading-topbar { flex-wrap: wrap; justify-content: center; gap: 0; padding: 4px 8px; }
  .reading-topbar > strong { display: none; }
  .dock-navigation { justify-content: center; flex: 1 1 100%; }
  .dock-tools { flex: 1 1 100%; justify-content: center; gap: 2px; }
  .dock-button { padding-inline: 8px; }
  .dock-access { font-size: .8rem; }
  .is-reading-open .edge-navigation { display: none; }
  .is-reading-open .viewer-area { padding: 0; }
  .is-reading-open .reader-card.is-access-panel { inset: 8% 0 var(--dock-height); width: 100%; border-radius: 16px 16px 0 0; }
  .is-reading-open .search-panel { top: 8px; left: 8px; right: 8px; }
}

/* V14.1 · Tamaño base independiente del zoom y centrado en ambos ejes. */
.viewer-area { display: block; height: clamp(280px, 60svh, 580px); min-height: 0; }
.book-scroll { display: flex; height: 100%; min-height: 0; max-height: none; padding: 8px; scrollbar-gutter: auto; }
.book-zoom-space { flex: 0 0 auto; margin: auto; overflow: hidden; }
.book-base-frame { position: relative; }
/* Permite pulsaciones rápidas en controles sin zoom por doble toque.
   Conserva el desplazamiento y el zoom de pellizco del navegador. */
.reading-experience button,
.reading-experience summary {
  touch-action: manipulation;
}
.reader-view-switch { display: flex; justify-content: center; gap: 8px; margin: 16px 0; }
.reader-view-switch button { min-width: 110px; min-height: 46px; }
.reader-view-switch [aria-pressed="true"] { color: #fff; background: #702079; border-color: #702079; }
.is-read-only .audio-only, .is-audio-only .read-only, .is-audio-only .text-controls { display: none !important; }
.is-read-only .simple-reader-controls { grid-template-columns: 1fr 1fr; }
.speech-caption { max-width: 850px; margin: 24px auto; padding: clamp(18px, 4vw, 36px); background: #211c2a; color: #fff; border-radius: 14px; }
.caption-heading { font-size: .8rem; color: #e1d3ec; }
.speech-caption p { min-height: 4.5em; margin: 12px 0 0; font-size: clamp(1.1rem, 2.6vw, 1.65rem); line-height: 1.65; }
.audio-progress { max-width: 760px; margin: 16px auto; text-align: center; }
.audio-progress progress { display: block; width: 100%; height: 12px; accent-color: #702079; }
.audio-progress p { color: var(--muted); font-size: .9rem; }
.simple-reader-controls { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 10px; max-width: 760px; margin: 16px auto; }
.simple-reader-controls .button { min-height: 52px; justify-content: center; padding: 10px; }
.reader-speed { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; margin: 14px auto; }
.reader-speed select { min-height: 46px; max-width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--surface); }
.reading-options { max-width: 920px; margin: 16px auto; }
.reading-options > summary { cursor: pointer; min-height: 46px; padding: 12px; font-weight: 700; border: 1px solid var(--border); border-radius: 8px; }
.reading-options .accessible-toolbar { position: static; }
.has-control-icon { gap: 8px; align-items: center; }
button.has-control-icon { display: inline-flex; justify-content: center; }
.has-control-icon::before {
  content: "";
  display: inline-block;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  background: currentColor;
  -webkit-mask: var(--control-icon) center / contain no-repeat;
  mask: var(--control-icon) center / contain no-repeat;
}
summary.has-control-icon::before { margin-right: 8px; }
#speak-page[aria-pressed="true"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 4h4v16H6zM14 4h4v16h-4z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 4h4v16H6zM14 4h4v16h-4z'/%3E%3C/svg%3E");
}
.is-reading-open .edge-navigation { width: 52px; height: 68px; background: #16121fe8; border: 1px solid #a896ba; }
.edge-navigation.has-control-icon::before { width: 34px; height: 34px; flex-basis: 34px; }
.dock-navigation .dock-button { background: #48414f; border-color: #83718f; }
.dock-navigation .has-control-icon::before { width: 26px; height: 26px; flex-basis: 26px; }
.voice-player { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 12px; box-shadow: 0 -8px 25px #00000012; }
.voice-player .speech-caption { margin: 0 0 10px; padding: 12px 16px; border-radius: 8px; }
.voice-player .speech-caption p { font-size: 1.1rem; min-height: 3.3em; margin-top: 6px; line-height: 1.5; }
.voice-player .simple-reader-controls { margin: 8px 0; max-width: none; }
.voice-player .audio-progress { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px; margin: 8px 0; }
.voice-player progress { grid-column: 1 / -1; }
.voice-player .audio-progress p { margin: 0; text-align: left; }
.voice-player .reader-speed { margin: 8px 0 0; }
.is-reading-open .reader-card.is-audio-only { display: flex; flex-direction: column; }
.is-audio-only .reader-note { display: none; }
.is-audio-only .voice-player { margin-top: auto; }
.is-reading-open .voice-player { position: sticky; bottom: -16px; z-index: 6; flex-shrink: 0; }
.is-audio-only .reading-options { width: 100%; margin-block: 8px 14px; }
.is-audio-only .reader-view-switch { margin-block: 8px; }
@media (max-width: 700px) {
  .is-reading-open .voice-player { bottom: -12px; }
  .voice-player { padding: 8px; }
  .voice-player .simple-reader-controls { gap: 4px; }
  .voice-player .simple-reader-controls .button { flex-direction: column; gap: 4px; font-size: .8rem; }
  .voice-player .reader-speed { gap: 6px; font-size: .85rem; }
  .voice-player .reader-speed select { min-width: 0; width: 160px; }
}
@media (max-height: 650px) {
  .is-reading-open .voice-player { position: static; }
}

/* La narración ocupa una franja propia, encima de la barra de herramientas. */
.is-reading-open .reading-topbar { order: 3; }
.is-reading-open .voice-player.is-global-player {
  position: relative;
  order: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  width: 100%;
  margin: 0;
  padding: 10px 18px 14px;
  border: 0;
  border-top: 1px solid #63586f;
  border-radius: 0;
  bottom: auto;
  color: #fff;
  background: #211c2a;
}
.is-global-player .speech-caption { padding: 0; margin: 0; background: transparent; }
.is-global-player .caption-heading { display: none; }
.is-global-player .speech-caption p { margin: 0; min-height: 0; max-height: 4.5em; overflow: auto; font-size: 1rem; line-height: 1.5; }
.is-global-player #voice-player-controls { grid-column: 2; }
.is-global-player .simple-reader-controls { display: grid; grid-template-columns: 44px auto 44px; gap: 5px; margin: 0; }
.is-global-player .simple-reader-controls .button { min-height: 44px; padding: 8px; white-space: nowrap; }
.is-global-player #reader-prev, .is-global-player #reader-next { font-size: 0; }
.is-global-player .audio-progress { display: contents; }
.is-global-player #speech-progress { position: absolute; inset: auto 0 0; width: 100%; height: 4px; }
.is-global-player #speech-progress-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.is-global-player #stop-speech { grid-column: 3; grid-row: 1; min-height: 44px; }
.is-global-player .reader-speed { grid-column: 4; margin: 0; color: #fff; }
.is-global-player .reader-speed select { background: #fff; color: #24212c; }
.has-voice-player .reader-card.is-access-panel { bottom: calc(var(--dock-height) + var(--voice-player-height, 0px)); }
.has-voice-player .edge-navigation { top: calc((100% - var(--dock-height) - var(--voice-player-height, 0px)) / 2 - 34px); }
@media (max-width: 900px) {
  .is-reading-open .voice-player.is-global-player { grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; padding: 8px 8px 12px; }
  .is-global-player .speech-caption { grid-column: 1 / -1; }
  .is-global-player #voice-player-controls { grid-column: 1; grid-row: 2; }
  .is-global-player .simple-reader-controls { grid-template-columns: 44px 44px 44px; justify-content: start; gap: 3px; }
  .is-global-player #speak-page-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .is-global-player #stop-speech { grid-column: 3; grid-row: 2; width: 44px; padding: 8px; font-size: 0; }
  .is-global-player .reader-speed { grid-column: 2; grid-row: 2; font-size: 0; }
  .is-global-player .reader-speed select { width: 98px; font-size: .8rem; }
  .is-global-player .speech-caption p { font-size: .95rem; max-height: none; overflow: visible; }
}
.is-text-reading .dock-navigation,
.is-text-reading #dock-thumbnails,
.is-text-reading #dock-zoom-out,
.is-text-reading #dock-zoom-in,
.is-text-reading #dock-more { display: none; }
.is-text-reading .reading-topbar { min-height: 64px; }
.is-text-reading .reader-text-wrap { max-width: 920px; margin-inline: auto; }
@media (max-width: 700px) {
  .simple-reader-controls { gap: 5px; }
  .simple-reader-controls .button { font-size: .85rem; padding: 8px 5px; }
  .is-text-reading .dock-tools { flex-basis: auto; }
}
.book { min-height: 0; transition: none; }
html.is-mobile-reader .viewer-area { height: clamp(260px, 58svh, 520px); min-height: 0; }
html.is-mobile-reader .book-scroll { height: 100%; min-height: 0; max-height: none; padding: 8px; }
.is-reading-open .viewer-area,
html.is-mobile-reader .is-reading-open .viewer-area { height: auto; min-height: 0; padding: 0 64px; }
.is-reading-open .book-scroll,
html.is-mobile-reader .is-reading-open .book-scroll { display: flex; padding: 12px 0; }
@media (max-width: 700px) {
  .is-reading-open .viewer-area,
  html.is-mobile-reader .is-reading-open .viewer-area { padding: 0 8px; }
}
/* V17.2: reproductor permanente, independiente del panel de accesibilidad. */
.is-global-player .audio-only { display: revert !important; }
.is-global-player .audio-progress { display: contents !important; }
.is-reading-open .voice-player.is-global-player { grid-template-columns: minmax(160px, 1fr) auto auto minmax(120px, 180px) minmax(140px, 220px); }
.is-global-player .voice-control { grid-column: 5; grid-row: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; color: #fff; font-size: .85rem; }
.is-global-player .voice-control select { width: 100%; min-width: 0; min-height: 44px; background: #fff; color: #24212c; }
.is-global-player .reader-speed select { min-width: 0; width: 100%; }
.is-reading-open .voice-player.is-global-player { align-items: end; }
.is-global-player .speech-caption { align-self: center; }
.is-global-player .reader-speed {
  display: flex !important; flex-direction: column; align-items: stretch;
  justify-content: flex-end; gap: 4px; line-height: 20px;
}
.is-global-player .voice-control { line-height: 20px; }
.is-global-player .reader-speed select,
.is-global-player .voice-control select,
.is-global-player .simple-reader-controls .button,
.is-global-player #stop-speech { box-sizing: border-box; height: 44px; min-height: 44px; }
@media (max-width: 1100px) {
  .is-reading-open .voice-player.is-global-player { grid-template-columns: minmax(0, 1fr) auto auto; }
  .is-global-player .speech-caption { grid-column: 1 / -1; grid-row: 1; }
  .is-global-player #voice-player-controls { grid-column: 1; grid-row: 2; }
  .is-global-player #stop-speech { grid-column: 3; grid-row: 2; }
  .is-global-player .reader-speed { grid-column: 2; grid-row: 2; }
  .is-global-player .voice-control { grid-column: 1 / -1; grid-row: 3; flex-direction: row; align-items: center; }
  .is-global-player .voice-control select { flex: 1; width: 0; }
}
.is-global-player .voice-control { background: transparent; border: 0; padding: 0; }
.is-global-player .voice-control select { max-width: none; }
@media (max-width: 900px) {
  .is-global-player .reader-speed { line-height: 0; gap: 0; }
  .is-global-player .reader-speed select { width: 98px; }
}
/* El formulario ocupa su ancho real; ya no comparte fila con flechas retiradas. */
.is-reading-open .accessible-nav { display: flex; flex-wrap: wrap; width: 100%; min-width: 0; }
.is-reading-open #reader-goto-form { flex-wrap: wrap; justify-content: flex-start; max-width: 100%; }
.is-reading-open #reader-goto-form label { flex-shrink: 0; }
/* Los nombres de las hojas sin numerar pueden ocupar varias líneas. */
#dock-page-status { white-space: normal; max-width: 340px; line-height: 1.35; }
.page-status { white-space: normal; }
@media (max-width: 700px) {
  #dock-page-status { max-width: calc(100vw - 150px); font-size: .85rem; }
}
