.reader-page {
  --reader-green: #244137;
  --reader-paper: #fffaf0;
  --reader-line: #d8d9c9;
  min-height: 100vh;
  overflow-x: clip;
  background: #f2f2e9;
  color: #192f28;
}

.reader-page [hidden] { display: none !important; }

.reader-header,
.reader-main {
  width: min(1140px, calc(100% - 40px));
  margin-inline: auto;
}

.reader-header {
  min-height: 67px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--reader-line);
}

.reader-header a { color: var(--reader-green); }
.reader-home { font-weight: 700; text-underline-offset: 4px; }
.reader-home span:first-child { display: inline-block; padding-right: 4px; }
.reader-language { display: flex; gap: 3px; }
.reader-language a { display: grid; min-height: 44px; min-width: 44px; place-items: center; font-size: .83rem; text-decoration: none; border-radius: 999px; }
.reader-language a[aria-current] { background: var(--reader-green); color: white; }

.reader-intro { margin: clamp(20px, 4vw, 43px) auto 10px; text-align: center; max-width: 46rem; }
.reader-kicker { margin: 0 0 8px; font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.reader-intro h1 { margin: 0; font-family: Fraunces, Georgia, serif; font-size: clamp(2rem, 5vw, 4.2rem); line-height: 1.02; text-wrap: balance; }
.reader-intro p:last-child { margin: 12px 0; color: #42554d; }
.reader-help { margin: 0 0 16px; color: #42554d; text-align: center; font-size: .87rem; }
.reader-shelf { display: grid; justify-items: center; padding: 4px; min-width: 0; }
.reader-book { position: relative; max-width: 100%; isolation: isolate; user-select: none; }
.reader-book:focus-visible { outline: 3px solid #a22948; outline-offset: 5px; }
.reader-flip { filter: drop-shadow(0 13px 14px rgb(41 42 21 / 17%)); }
.reader-leaf { overflow: hidden; background: var(--reader-paper); border: 1px solid #d4c9b0; }
.reader-leaf img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.reader-cover {
  background: #29483c;
  color: var(--reader-paper);
  border: 4px double #ac976a;
  text-align: center;
}
.reader-cover-content { display: grid; align-content: center; justify-items: center; gap: 1rem; padding: 18px; height: 100%; }
.reader-cover strong { max-width: 16ch; font: 700 clamp(1.15rem, 4vw, 3rem)/1.04 Fraunces, Georgia, serif; }
.reader-cover span { font-size: 1.4rem; }
.reader-book[data-mode="plain"] { display: flex; filter: drop-shadow(0 13px 14px rgb(41 42 21 / 17%)); }
.reader-book[data-mode="plain"] .reader-leaf { position: relative; flex: 1 1 0; min-width: 0; }
.reader-controls { display: flex; justify-content: space-between; align-items: center; gap: 10px 20px; flex-wrap: wrap; margin: 18px auto 0; max-width: 56rem; }
.reader-navigation, .reader-tools { display: flex; align-items: center; gap: 8px; }
.reader-position, #reader-position { margin: 0; min-width: 8.5ch; text-align: center; font-weight: 700; font-size: .92rem; }
.reader-page button { min-height: 44px; min-width: 44px; border: 1px solid #aeb8a9; border-radius: 8px; padding: 7px 11px; background: #fbfcf6; color: #1e392e; font: inherit; font-weight: 700; cursor: pointer; }
.reader-page button.reader-listen { background: var(--reader-green); border-color: var(--reader-green); color: white; }
.reader-page button:disabled { opacity: .52; cursor: default; }
.reader-page a:focus-visible, .reader-page button:focus-visible, .reader-page summary:focus-visible, .reader-page audio:focus-visible { outline: 3px solid #a22948; outline-offset: 3px; }
.reader-audio { max-width: 56rem; margin: 12px auto 0; }
.reader-audio audio { display: block; width: min(100%, 440px); }
.reader-audio p { margin: 0; }
.reader-transcript { max-width: 56rem; margin: 14px auto 0; background: #fbfcf6; border: 1px solid var(--reader-line); border-radius: 8px; }
.reader-transcript summary { cursor: pointer; padding: 12px 16px; font-weight: 700; min-height: 44px; }
#reader-transcript-content { padding: 0 16px 10px; }
#reader-transcript-content section { margin-top: 14px; }
#reader-transcript-content h3 { margin: 0 0 6px; font-size: 1rem; }
#reader-transcript-content p { margin: 0 0 5px; line-height: 1.55; }
.reader-footer { margin: 25px 16px; text-align: center; color: #42554d; font-size: .83rem; }
.reader-zoom-dialog { width: min(760px, calc(100% - 20px)); max-height: 92vh; border: 1px solid var(--reader-line); border-radius: 10px; background: var(--reader-paper); color: #192f28; padding: 0; margin: auto; }
.reader-zoom-dialog::backdrop { background: rgb(20 32 28 / 82%); }
.reader-zoom-bar { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 12px; background: var(--reader-paper); }
.reader-zoom-bar h2 { margin: 0; font-size: 1.06rem; }
.reader-zoom-pages { padding: 8px; }
.reader-zoom-pages img { display: block; width: 100%; height: auto; margin: 0 auto 9px; }

@media (max-width: 575px) {
  .reader-main, .reader-header { width: calc(100% - 24px); }
  .reader-controls { justify-content: center; }
  .reader-intro { margin-top: 18px; }
  .reader-help { margin-bottom: 8px; }
}

@font-face {
  font-family: 'Reader Comic Neue';
  src: url('../assets/fonts/comic-neue/ComicNeue-Regular.ttf') format('truetype');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

.reader-art { position: relative; width: 100%; container-type: inline-size; }
.reader-art img { display: block; width: 100%; height: auto; margin: 0; }
.reader-overlays { position: absolute; inset: 0; pointer-events: none; }
.reader-lettering {
  position: absolute;
  display: grid;
  place-items: center;
  padding: .2em .38em;
  color: #151d19;
  background: #fffaf0;
  border: .1em solid #24322a;
  font-family: 'Reader Comic Neue', 'Trebuchet MS', sans-serif;
  font-weight: 700;
  line-height: 1.04;
  text-align: center;
  overflow-wrap: anywhere;
}

.reader-lettering.is-caption { border-radius: .12em; background: #fff4cf; }
.reader-lettering.is-balloon, .reader-lettering.is-thought { border-radius: 48%; padding-inline: .7em; }
.reader-lettering.is-thought { border-style: dashed; }
.reader-lettering.is-burst { border-radius: .7em .2em; border-width: .18em; background: #fff3d0; }
.reader-lettering.is-sfx { background: transparent; color: #fff1ab; border: 0; font-style: italic; text-shadow: .1em .1em .08em #1f2522, -.08em -.08em .05em #1f2522; }
.reader-leaf-number { position: absolute; right: 3px; bottom: 3px; background: var(--reader-paper); padding: 1px 4px; color: #273e33; font-size: .72rem; border-radius: 3px; pointer-events: none; }
.reader-zoom-pages .reader-art + .reader-art { margin-top: 12px; }
