/* Lector del libro en la web */
html, body.rd-body { height: 100%; margin: 0; overflow: hidden; background: #3A3A44; }
.rd { position: fixed; inset: 0; display: flex; flex-direction: column; font-family: 'Lexend', system-ui, sans-serif; color: #1A1A1F; background: #3A3A44; }
.rd button { font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Barra de arriba */
.rd-top { position: relative; z-index: 40; display: flex; align-items: center; gap: 10px; background: #BFE6FA; border-bottom: 3px solid #1A1A1F; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.rd-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rd-t b { font: 400 18px/1.15 'Bagel Fat One', 'Arial Rounded MT Bold', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-t small { font-size: 12px; font-weight: 600; color: #4A4A55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-ib { width: 40px; height: 40px; flex: none; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 0; background: #FFFFFF; border: 3px solid #1A1A1F; border-radius: 12px; box-shadow: 2px 2px 0 #1A1A1F; color: #1A1A1F; text-decoration: none; }
.rd-ib[hidden] { display: none; }
.rd-dl { display: flex; align-items: center; gap: 8px; height: 40px; box-sizing: border-box; padding: 0 14px; background: #FFD23F; border: 3px solid #1A1A1F; border-radius: 12px; box-shadow: 2px 2px 0 #1A1A1F; font-weight: 800; font-size: 15px; color: #1A1A1F; }
.rd-ib:active, .rd-dl:active, .rd-nb:active, .rd-side:active { transform: translate(2px, 2px); box-shadow: none; }
.rd-zoom { display: flex; align-items: stretch; height: 40px; box-sizing: border-box; background: #FFFFFF; border: 3px solid #1A1A1F; border-radius: 12px; box-shadow: 2px 2px 0 #1A1A1F; overflow: hidden; }
.rd-zoom button { width: 36px; display: flex; align-items: center; justify-content: center; background: none; border: 0; padding: 0; }
.rd-zoom button:disabled { opacity: .35; cursor: default; }
.rd-zoom span { display: flex; align-items: center; padding: 0 8px; font-size: 13px; font-weight: 700; border-left: 2px solid #1A1A1F; border-right: 2px solid #1A1A1F; min-width: 38px; justify-content: center; }

/* Escenario con las páginas */
.rd-stage { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; touch-action: pan-x pan-y pinch-zoom; }
.rd-pages { box-sizing: border-box; height: 100%; min-width: 100%; width: max-content; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 14px 70px; margin: 0 auto; }
.rd-pages img { display: block; height: 100%; width: auto; max-width: none; aspect-ratio: 1099 / 1500; border-radius: 4px; background: #FFFCF3; box-shadow: 0 6px 18px rgba(0, 0, 0, .45); user-select: none; -webkit-user-drag: none; }
.rd-fit .rd-pages { width: 100%; }
.rd-fit .rd-pages img { height: auto; max-height: 100%; max-width: 100%; min-width: 0; }
.rd-fit.rd-two .rd-pages img { max-width: calc(50% - 2px); }
.rd-zoomed .rd-pages { align-items: flex-start; }
.rd-side { position: absolute; top: 50%; z-index: 5; width: 46px; height: 46px; margin-top: -23px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 0; background: #FFFFFF; border: 3px solid #1A1A1F; border-radius: 50%; box-shadow: 3px 3px 0 #1A1A1F; }
.rd-side.prev { left: 14px; } .rd-side.next { right: 14px; }
.rd-side:disabled, .rd-nb:disabled { opacity: .35; cursor: default; }
.rd-load { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; color: #FFFCF3; font-weight: 700; font-size: 16px; pointer-events: none; }
.rd-load[hidden] { display: none; }

/* Barra de abajo */
.rd-bot { position: relative; z-index: 10; display: flex; align-items: center; gap: 12px; background: #FFFCF3; border-top: 3px solid #1A1A1F; padding: 10px 18px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.rd-nb { width: 40px; height: 40px; flex: none; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 0; background: #FFFFFF; border: 3px solid #1A1A1F; border-radius: 50%; box-shadow: 2px 2px 0 #1A1A1F; }
.rd-sl { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.rd-sl span { text-align: center; font-size: 13px; font-weight: 700; }
.rd-sl input { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; --pct: 0%; }
.rd-sl input::-webkit-slider-runnable-track { height: 8px; border: 2px solid #1A1A1F; border-radius: 99px; background: linear-gradient(#FFD23F, #FFD23F) 0 0 / var(--pct) 100% no-repeat, #FFFFFF; }
.rd-sl input::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: #FFD23F; border: 3px solid #1A1A1F; box-sizing: border-box; }
.rd-sl input::-moz-range-track { height: 4px; border: 2px solid #1A1A1F; border-radius: 99px; background: #FFFFFF; }
.rd-sl input::-moz-range-progress { height: 4px; border: 2px solid #1A1A1F; border-radius: 99px; background: #FFD23F; }
.rd-sl input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #FFD23F; border: 3px solid #1A1A1F; }
.rd-saved { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #1A6B45; white-space: nowrap; opacity: 0; transition: opacity .3s; }
.rd-saved.on { opacity: 1; }

/* Aviso de «seguimos donde lo dejaste» */
.rd-toast { position: absolute; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 15; width: min(440px, calc(100% - 24px)); box-sizing: border-box; display: flex; align-items: center; gap: 10px; background: #1A1A1F; color: #FFFFFF; border-radius: 14px; padding: 11px 14px; font-size: 14px; line-height: 1.35; box-shadow: 3px 3px 0 rgba(0, 0, 0, .3); }
.rd-toast[hidden] { display: none; }
.rd-toast svg { flex: none; }
.rd-toast b { color: #FFD23F; }
.rd-toast button { margin-left: auto; flex: none; background: none; border: 0; padding: 4px 0; color: #FFFFFF; font-weight: 800; font-size: 13px; text-decoration: underline; }

/* Descargar: menú en el ordenador, panel desde abajo en el móvil */
.rd-dim { position: fixed; inset: 0; z-index: 30; background: rgba(26, 26, 31, .45); }
.rd-dim[hidden] { display: none; }
.rd-sheet { position: absolute; z-index: 40; top: calc(100% + 10px); right: 16px; width: 330px; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; background: #FFFFFF; border: 3px solid #1A1A1F; border-radius: 20px; box-shadow: 6px 6px 0 #1A1A1F; padding: 16px; }
.rd-sheet[hidden] { display: none; }
.rd-sh-t { font: 400 19px 'Bagel Fat One', 'Arial Rounded MT Bold', sans-serif; }
.rd-sheet p { margin: 0; font-size: 13px; line-height: 1.45; color: #4A4A55; }
.rd-sheet a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #1A1A1F; background: #FFFFFF; border: 3px solid #1A1A1F; border-radius: 14px; padding: 11px 12px; box-shadow: 3px 3px 0 #1A1A1F; font-weight: 800; font-size: 15px; }
.rd-sheet a.y { background: #FFD23F; }
.rd-sheet a small { margin-left: auto; font-size: 12px; font-weight: 600; color: #4A4A55; white-space: nowrap; }
.rd-sh-x { align-self: center; background: none; border: 0; padding: 6px; font-weight: 700; font-size: 14px; text-decoration: underline; color: #1A1A1F; }

/* Pantalla completa */
.rd:fullscreen { background: #3A3A44; }

/* Móvil y pantallas estrechas */
@media (max-width: 899px) {
  .rd-top { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .rd-t b { font-size: 16px; }
  .rd-zoom, .rd-fs, .rd-side, .rd-saved { display: none !important; }
  .rd-dl { width: 40px; padding: 0; justify-content: center; }
  .rd-dl span { display: none; }
  .rd-pages { padding: 12px; }
  .rd-bot { padding-left: 12px; padding-right: 12px; }
  .rd-sheet { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; border-radius: 22px 22px 0 0; border-bottom: 0; box-shadow: 0 -4px 0 rgba(0, 0, 0, .2); padding: 18px 16px; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { .rd-saved { transition: none; } }

/* Narración: el botón de escuchar, encendido mientras suena la voz */
.rd-voz.on { background: #FFD23F; }
.rd-voz svg { display: block; }
