:root {
  color-scheme: light;
  font-family: Georgia, "Times New Roman", serif;
  background: #eee;
  color: #000;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eee;
}

button {
  font: inherit;
}

.book {
  width: 100%;
  width: min(100%, 640px);
  max-width: 640px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 20px 18px;
  background: #fff;
}

.book-header {
  position: relative;
  padding-bottom: 10px;
  text-align: center;
  border-bottom: 2px solid #000;
}

.book-header h1 {
  margin: 0;
  font-size: 2rem;
  font-size: clamp(1.45rem, 5vw, 2rem);
  line-height: 1.1;
}

.home-link {
  display: block;
  margin: 0 0 8px;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
}

.book-header p {
  margin: 5px 0 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.9rem;
}

.pages {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.page {
  min-height: 610px;
  padding: 12px 0 4px;
  text-align: center;
}

.viewer-ready .page {
  display: none;
}

.viewer-ready .page.is-current {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.page img {
  display: block;
  width: auto;
  max-width: 100%;
  height: min(64vh, 490px);
  margin: 0 auto;
  object-fit: contain;
  image-rendering: auto;
}

.words {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 8px 8px;
}

.words p {
  margin: 0;
  font-size: 2rem;
  font-size: clamp(1.5rem, 6vw, 2.35rem);
  line-height: 1.15;
}

.words .sound {
  margin-top: 7px;
  font-weight: 700;
}

.book-long .page img {
  height: min(48vh, 350px);
}

.book-long .words {
  min-height: 220px;
}

.book-long .words p {
  margin-top: 5px;
  font-size: 1.45rem;
  font-size: clamp(1.15rem, 4vw, 1.55rem);
  line-height: 1.25;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 2px solid #000;
}

.page-button {
  min-height: 52px;
  padding: 8px 14px;
  border: 2px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.page-button:last-child {
  justify-self: stretch;
}

.page-button:active:not(:disabled) {
  color: #fff;
  background: #000;
}

.page-button:focus-visible {
  outline: 4px double #000;
  outline-offset: 3px;
}

.page-button:disabled {
  border-color: #888;
  color: #777;
  cursor: default;
}

.page-count {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hint {
  margin: 10px 0 0;
  text-align: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.78rem;
}

.download-row {
  margin: 14px 0 0;
  text-align: center;
}

.download {
  display: inline-block;
  padding: 9px 14px;
  border: 2px solid #000;
  color: #000;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  text-decoration: none;
}

.download:active,
.download:focus {
  color: #fff;
  background: #000;
}

.library {
  width: 100%;
  max-width: 920px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  background: #fff;
}

.library-header {
  padding: 24px 12px 28px;
  text-align: center;
  border-bottom: 3px solid #000;
}

.library-header h1 {
  margin: 8px 0 10px;
  font-size: 3rem;
  line-height: 0.98;
}

.library-header > p:last-child {
  margin: 0;
  font-size: 1.15rem;
}

.eyebrow {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-list {
  padding: 22px 0;
  border-bottom: 3px solid #000;
  font-family: Arial, Helvetica, sans-serif;
}

.category-list > p {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-list a {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  min-width: 190px;
  padding: 12px 14px;
  border: 2px solid #000;
  color: #fff;
  background: #000;
  text-decoration: none;
}

.category-list a span {
  font-size: 0.82rem;
}

.category-section {
  padding-top: 28px;
}

.category-heading {
  text-align: center;
}

.category-heading > p:first-child {
  margin: 0 0 4px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-heading h2 {
  margin: 0;
  font-size: 2.8rem;
}

.category-heading > p:last-child {
  margin: 8px auto 0;
  max-width: 480px;
  line-height: 1.4;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 24px 0;
}

.shelf-group {
  padding-top: 26px;
}

.shelf-group + .shelf-group {
  border-top: 3px solid #000;
}

.shelf-heading {
  text-align: center;
}

.shelf-heading p {
  margin: 0 0 4px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.shelf-heading h2,
.shelf-heading h3 {
  margin: 0;
  font-size: 2rem;
}

.story-card {
  margin: 0 0 24px;
  padding: 14px;
  border: 2px solid #000;
  background: #fff;
}

.cover-link {
  color: #000;
  text-decoration: none;
}

.story-card h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.05;
}

.story-card > p {
  min-height: 3em;
  margin: 10px 0 14px;
  line-height: 1.35;
}

.card-actions a {
  display: block;
  margin-top: 8px;
  padding: 10px;
  border: 2px solid #000;
  color: #000;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.card-actions a:first-child {
  color: #fff;
  background: #000;
}

.library-footer {
  padding-top: 12px;
  border-top: 2px solid #000;
  text-align: center;
}

@media (max-height: 850px) {
  .book {
    padding-top: 10px;
  }

  .page {
    min-height: 475px;
  }

  .page img {
    height: min(56vh, 390px);
  }

  .words {
    min-height: 84px;
  }

  .book-long .page img {
    height: min(38vh, 270px);
  }

  .book-long .words {
    min-height: 260px;
  }
}

@media (max-width: 420px) {
  .book {
    padding-right: 12px;
    padding-left: 12px;
  }

  .page-button span {
    display: none;
  }
}

@media (max-width: 760px) {
  .library {
    padding: 14px;
  }

  .library-header {
    padding-top: 16px;
  }

  .library-header h1 {
    font-size: 2.5rem;
  }

  .shelf {
    display: block;
  }

  .story-card > p {
    min-height: 0;
  }
}

@media print {
  :root,
  body {
    background: #fff;
  }

  .book {
    width: 100%;
    padding: 0;
  }

  .book-header,
  .controls,
  .hint,
  .download-row {
    display: none;
  }

  .viewer-ready .page,
  .viewer-ready .page.is-current,
  .page {
    display: flex;
    min-height: 100vh;
    break-after: page;
    page-break-after: always;
  }
}
