#reader.rr-active {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  inline-size: 100%;
  max-inline-size: 100dvw;
  overflow: clip;
  color: var(--rr-ink);
  background: var(--rr-paper);
  font: 16px/1.45 var(--type-ui, "Atkinson Hyperlegible", system-ui, sans-serif);
  isolation: isolate;
}
#reader[hidden], #reader [hidden] {
  display: none !important;
}
#reader .rr-theme-favorites summary {
  padding-block: 10px;
  cursor: pointer;
  font-weight: 700;
}
#reader .rr-theme-favorites button {
  white-space: normal;
}
#reader :is(button, select, input, textarea) {
  font: inherit;
  color: inherit;
}
#reader :is(button, select, input) {
  min-height: 44px;
}
#reader button {
  cursor: pointer;
  border: 1px solid rgba(122, 92, 62, 0.55);
  background: #f6efe0;
  color: #1f2a17;
  padding: 0.36em 0.72em;
  border-radius: 10px;
  line-height: 1.15;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 120ms var(--ease-out-snappy, cubic-bezier(0.23, 1, 0.32, 1)),
              background-color 160ms var(--ease-out-snappy, cubic-bezier(0.23, 1, 0.32, 1));
}
#reader button:active:not(:disabled) {
  transform: scale(0.97);
}
#reader button:focus-visible,
#reader :is(select, input, textarea):focus-visible {
  outline: 3px solid #e8f26b;
  outline-offset: 2px;
}

#reader .rr-head,
#reader .rr-foot {
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background:
    linear-gradient(180deg, rgba(24, 34, 17, 0.7), rgba(18, 26, 13, 0.78)),
    url("art/wood-plank.webp") center / cover no-repeat;
  color: #faf5e9;
  padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  border-color: rgba(197, 161, 92, 0.48);
}
#reader .rr-head {
  padding-top: max(6px, env(safe-area-inset-top));
  border-bottom: 1px solid rgba(197, 161, 92, 0.48);
}
#reader .rr-head strong {
  min-inline-size: 0;
  flex: 1 1 auto;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--type-display, "Crimson Text", Georgia, serif);
  font-size: 1.15rem;
  font-weight: 700;
}
#reader .rr-head button,
#reader .rr-foot button {
  min-width: 44px;
  background: rgba(38, 54, 28, 0.88);
  color: #faf5e9;
  border-color: rgba(197, 161, 92, 0.45);
  flex-shrink: 0;
}
#reader .rr-head button[aria-pressed="true"],
#reader .rr-foot button[aria-pressed="true"] {
  background: #8ba43a;
  color: #141c0e;
  border-color: #e8f26b;
}

#reader .rr-foot {
  flex-direction: column;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  gap: 4px;
  border-top: 1px solid rgba(197, 161, 92, 0.48);
}
#reader .rr-foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  inline-size: min(100%, 740px);
  min-inline-size: 0;
}
#reader .rr-foot-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  inline-size: min(100%, 740px);
}
#reader .rr-loc {
  min-inline-size: 0;
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#reader .rr-slider {
  inline-size: min(100%, 740px);
  min-height: 24px;
  accent-color: #c5a15c;
}
#reader .rr-msg {
  color: #e8f26b;
  text-align: center;
  font-size: 0.84rem;
}
#reader .rr-msg:empty {
  display: none;
}

#reader.rr-quiet {
  grid-template-rows: minmax(0, 1fr);
}
#reader.rr-quiet .rr-head,
#reader.rr-quiet .rr-foot {
  display: none;
}

#reader .rr-scroll {
  position: relative;
  overflow: auto;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
  min-block-size: 0;
  scroll-behavior: auto;
  background: var(--rr-paper);
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
}
#reader .rr-scroll::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--rr-texture-opacity, 0);
  background: url("art/parchment-texture.webp") center / cover no-repeat;
}
#reader .rr-warmth {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background: rgba(233, 166, 107, var(--rr-warmth-alpha, 0));
  mix-blend-mode: multiply;
}
#reader .rr-sheet {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  inline-size: 100%;
  max-inline-size: 100%;
  min-height: 1px;
  box-sizing: border-box;
}
#reader .rr-sheet.rr-page-turn {
  animation: rr-turn 190ms var(--ease-out-snappy, cubic-bezier(0.23, 1, 0.32, 1));
}
@keyframes rr-turn {
  from { opacity: 0.78; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* Cinta marcadora carmesí de Fiona */
#reader .rr-ribbon {
  position: absolute;
  top: 0;
  right: clamp(14px, 4vw, 36px);
  width: 24px;
  height: 54px;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(180deg, #b54545, #7d2525);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.32);
}
#reader .rr-ribbon.rr-ribbon-drop {
  animation: ribbon-drop 460ms var(--spring-bouncy, cubic-bezier(0.34, 1.56, 0.64, 1));
  transform-origin: top center;
}
@keyframes ribbon-drop {
  from { transform: translateY(-38px) scaleY(0.8); opacity: 0; }
  to { transform: translateY(0) scaleY(1); opacity: 1; }
}

#reader .rr-chapter {
  box-sizing: border-box;
  inline-size: 100%;
  max-inline-size: 48rem;
  min-inline-size: 0;
  margin: auto;
  padding: var(--rr-vertical) var(--rr-margin);
  font-family: var(--rr-font);
  font-size: var(--rr-size);
  font-weight: var(--rr-weight);
  line-height: var(--rr-line);
  word-spacing: var(--rr-words);
  text-align: var(--rr-align);
  color: var(--rr-ink);
  overflow-wrap: anywhere;
}
#reader .rr-chapter p {
  margin: 0 0 var(--rr-gap);
  font: inherit;
  color: inherit;
}
#reader .rr-chapter :is(h1, h2, h3, h4) {
  color: inherit;
  font-family: inherit;
  line-height: 1.25;
  letter-spacing: normal;
  overflow-wrap: anywhere;
}
#reader .rr-chapter img {
  max-inline-size: 100%;
  height: auto;
  display: block;
  margin: 0.8em auto;
  border-radius: 6px;
}
#reader .rr-chapter [role=link] {
  text-decoration: underline;
  cursor: pointer;
}
#reader .rr-chapter table {
  display: block;
  overflow-x: auto;
  max-inline-size: 100%;
  border-collapse: collapse;
}
#reader .rr-chapter :is(td, th) {
  border: 1px solid currentColor;
  padding: 0.25em 0.4em;
}
#reader .rr-chapter pre {
  white-space: pre-wrap;
  overflow-x: auto;
  max-inline-size: 100%;
}

#reader .rr-exlibris {
  margin: 0 0 1.4em;
  padding: 14px 16px;
  border: 1.5px solid #c5a15c;
  border-radius: 12px;
  background: rgba(197, 161, 92, 0.14);
  font-size: 0.92em;
}
#reader .rr-exlibris strong {
  display: block;
  font-family: var(--type-display, "Crimson Text", Georgia, serif);
  color: inherit;
  margin-bottom: 4px;
}

#reader .rr-pdf-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px 0 24px;
}
#reader .rr-pdf-page {
  position: relative;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 6px 20px rgba(15, 20, 12, 0.25);
}
#reader .rr-pdf,
#reader .rr-pdf canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#reader .rr-text {
  position: absolute;
  inset: 0;
  text-align: initial;
  overflow: clip;
  line-height: 1;
  text-size-adjust: none;
  -webkit-text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 1;
}
#reader .rr-text :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
}
#reader .rr-text span.markedContent {
  top: 0;
  height: 0;
}
#reader .rr-text ::selection {
  background: rgba(139, 164, 58, 0.42);
}

#reader .rr-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
#reader .rr-marks i {
  position: absolute;
  opacity: 0.36;
  border-radius: 2px;
  pointer-events: auto;
  cursor: pointer;
}

#reader .rr-panel,
#reader .rr-selection {
  position: absolute;
  z-index: 6;
  bottom: max(10px, env(safe-area-inset-bottom));
  right: max(8px, env(safe-area-inset-right));
  left: max(8px, env(safe-area-inset-left));
  margin: 0 auto;
  box-sizing: border-box;
  max-height: min(76dvh, 620px);
  overflow: auto;
  max-inline-size: 440px;
  background:
    linear-gradient(180deg, rgba(248, 240, 214, 0.54), rgba(235, 217, 177, 0.6)),
    url("art/parchment-texture.webp") center / cover no-repeat;
  color: #1f2a17;
  border: 2px solid #c5a15c;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 40px rgba(10, 15, 7, 0.55);
  overscroll-behavior: contain;
  transition: transform 200ms var(--ease-out-snappy, cubic-bezier(0.23, 1, 0.32, 1)),
              opacity 200ms var(--ease-out-snappy, cubic-bezier(0.23, 1, 0.32, 1));
}
@starting-style {
  #reader .rr-panel:not([hidden]),
  #reader .rr-selection:not([hidden]) {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
}

#reader .rr-panel {
  display: grid;
  gap: 10px;
}
#reader .rr-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#reader .rr-panel h2 {
  margin: 0;
  font: 700 1.35rem var(--type-display, "Crimson Text", Georgia, serif);
  color: #1f2a17;
}
#reader .rr-panel label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  min-inline-size: 0;
  gap: 8px;
  font-size: 0.92rem;
  font-weight: 600;
}
#reader .rr-panel :is(select, input, textarea) {
  width: 100%;
  min-inline-size: 0;
  box-sizing: border-box;
  color: #1f2a17;
  background: #faf5e9;
  border: 1px solid rgba(122, 92, 62, 0.55);
  border-radius: 8px;
  padding: 6px 8px;
  accent-color: #4f6b2a;
}
#reader .rr-panel form {
  display: flex;
  gap: 6px;
}
#reader .rr-panel form input {
  flex: 1;
}
#reader .rr-panel .rr-list button {
  display: block;
  width: 100%;
  text-align: left;
  margin: 4px 0;
  white-space: normal;
  justify-content: flex-start;
}
#reader .rr-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
#reader .rr-thumb {
  display: grid;
  gap: 4px;
  padding: 6px;
  text-align: center;
  white-space: normal;
  font-size: 0.8rem;
}
#reader .rr-thumb canvas {
  width: 100%;
  height: auto;
  background: #fff;
  border-radius: 4px;
}
#reader .rr-selection {
  display: grid;
  gap: 10px;
}
#reader .rr-swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#reader .rr-swatch {
  min-height: 34px !important;
  width: 34px;
  height: 34px;
  padding: 0 !important;
  border-radius: 50% !important;
  border: 2px solid #1f2a17 !important;
}
#reader .rr-swatch[aria-pressed="true"] {
  outline: 3px solid #5a3e28;
  transform: scale(1.1);
}
#reader .rr-sel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#reader .rr-modal {
  background:
    linear-gradient(180deg, rgba(248, 240, 214, 0.54), rgba(235, 217, 177, 0.6)),
    url("art/parchment-texture.webp") center / cover no-repeat;
  color: #1f2a17;
  border: 2px solid #c5a15c;
  border-radius: 16px;
  padding: 20px;
  width: min(92vw, 430px);
  max-height: 86dvh;
  overflow: auto;
}
#reader .rr-modal::backdrop {
  background: rgba(12, 18, 9, 0.78);
}
#reader .rr-modal h3 {
  margin: 0 0 10px;
  font-family: var(--type-display, "Crimson Text", Georgia, serif);
  font-size: 1.4rem;
}
#reader .rr-modal textarea,
#reader .rr-modal input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  background: #faf5e9;
  color: #1f2a17;
  border: 1px solid rgba(122, 92, 62, 0.55);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
}
#reader .rr-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

@media (max-width: 420px) {
  #reader button {
    padding: 0.3em 0.55em;
    font-size: 0.9rem;
  }
  #reader .rr-panel label {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
@media (max-height: 450px) {
  #reader .rr-foot {
    flex-direction: row;
    flex-wrap: wrap;
  }
  #reader .rr-foot-row {
    width: auto;
    flex: 1 1 200px;
  }
  #reader .rr-slider {
    flex: 1 1 140px;
    min-inline-size: 60px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #reader *, #reader *::before, #reader *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

#reader .rr-foot-actions {flex-wrap:wrap}
#reader .rr-note-pin {position:absolute; right:0; pointer-events:auto; z-index:2; border:2px solid currentColor; background:#fff4ce; color:#342813; font-size:1.1rem; min-width:32px; min-height:32px}
#reader .rr-panel article {border-block-start:1px solid currentColor; padding-block:1rem; overflow-wrap:anywhere}
#reader .rr-panel article p {white-space:pre-wrap}
#reader .rr-notebook-actions {display:flex; flex-wrap:wrap; gap:.5rem}
#reader :focus-visible {outline:3px solid currentColor; outline-offset:2px}

#reader .rr-written-note {right:auto; max-width:40%; max-height:5em; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; text-align:start; font:inherit; padding:3px 6px}

/* Reading controls share the paper and ink chosen for the book. */
#reader .rr-head, #reader .rr-foot {
  background:var(--rr-paper); color:var(--rr-ink); border:0; box-shadow:none;
  padding-block:2px;
}
#reader .rr-head {padding-top:max(2px,env(safe-area-inset-top))}
#reader .rr-foot {padding-bottom:max(2px,env(safe-area-inset-bottom))}
#reader .rr-head button,#reader .rr-foot button,#reader .rr-selection button:not(.rr-swatch){
  color:inherit; background:transparent; border-color:transparent; box-shadow:none;
}
#reader .rr-head strong {font:inherit;font-size:.9rem}
#reader .rr-msg {color:inherit}
#reader #rr-tools,#reader .rr-selection,#reader .rr-panel {
  background:var(--rr-paper);color:var(--rr-ink);
  border:1px solid color-mix(in srgb,currentColor 25%,transparent);
  border-radius:14px;box-shadow:0 8px 32px #0002;
}
#reader #rr-tools {
  position:fixed;inset:max(50px,env(safe-area-inset-top)) 12px auto auto;
  margin:0;padding:12px; width:min(272px,calc(100% - 24px));
  max-height:75dvh;overflow:auto;box-sizing:border-box;
}
#reader #rr-tools:popover-open {display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
#reader .rr-menu-actions {display:contents}
#reader #rr-tools button {white-space:normal;justify-content:flex-start}
#reader #rr-tools .rr-slider {grid-column:1/-1;width:100%;accent-color:currentColor}
#reader .rr-sheet {box-shadow:none;border-radius:0;border:0}
#reader .rr-selection {width:fit-content;padding:4px 8px;max-width:calc(100% - 16px)}
#reader .rr-selection summary {cursor:pointer;line-height:44px}
#reader .rr-selection details[open] {flex-basis:100%}
#reader .rr-foot-row {max-width:34rem}
#reader .rr-panel button {border-color:color-mix(in srgb,currentColor 22%,transparent);background:var(--rr-paper);color:var(--rr-ink)}

#reader .rr-extracted {
  font:var(--rr-weight,400) var(--rr-size)/var(--rr-line) var(--rr-font);
  padding:var(--rr-vertical) min(var(--rr-margin),8%);
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  max-inline-size:65ch;
  margin-inline:auto;
}
#reader .rr-panel:has(.rr-extracted) {max-inline-size:52rem;max-block-size:85dvh}
#reader :is(.rr-panel,.rr-modal) :is(input:not([type=color]),select,textarea),#reader .rr-modal {
  background:var(--rr-paper);color:var(--rr-ink);border-color:color-mix(in srgb,currentColor 45%,transparent)
}
#reader .rr-panel :is(label,h2,h3,p),#reader .rr-modal :is(h3,label,p) {color:inherit}
#reader .rr-panel article {padding-block:1em;border-color:color-mix(in srgb,currentColor 25%,transparent)}
#reader .rr-panel article p {line-height:1.55;margin-block:.5em .75em}
