:root {
  color-scheme: light;
  --ink: #24313a;
  --muted: #687782;
  --paper: #fffaf0;
  --panel: #fffefb;
  --line: #d9e0df;
  --water: #147f98;
  --water-soft: #e6f3f1;
  --leaf: #5f8f3a;
  --sun: #f3c94b;
  --shadow: 0 18px 46px rgba(34, 51, 58, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 4%, rgba(243, 201, 75, 0.13), transparent 22rem),
    var(--paper);
  font-family: ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

.reader-shell {
  min-height: 100vh;
}

.reader-main {
  min-width: 0;
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px);
}

.reader-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.page-controls {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.page-controls a,
.reader-footer a {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--water);
  background: rgba(255, 255, 255, 0.8);
  font-weight: 900;
  text-decoration: none;
}

.page-controls a:hover,
.page-controls a:focus-visible,
.reader-footer a:hover,
.reader-footer a:focus-visible {
  background: var(--water-soft);
  border-color: #b8d7d2;
}

.book-spread {
  min-width: 0;
  min-height: min(70vh, 720px);
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.book-spread.portrait.has-story.has-image {
  grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.05fr);
}

.book-spread.landscape.has-story.has-image {
  grid-template-rows: auto minmax(0, 1fr);
}

.story-page {
  min-width: 0;
  display: flex;
  align-items: center;
  padding: clamp(24px, 4vw, 54px);
  background:
    linear-gradient(90deg, rgba(243, 201, 75, 0.035), transparent 28%),
    #fffdf8;
}

.portrait .story-page {
  border-right: 1px solid var(--line);
}

.landscape .story-page {
  border-bottom: 1px solid var(--line);
}

.front-matter .story-page {
  text-align: center;
}

.story-prose {
  width: 100%;
  max-width: 39rem;
  margin: auto;
  font-family: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.05rem, 1.45vw, 1.3rem);
  line-height: 1.62;
  text-wrap: pretty;
}

.story-prose p {
  margin: 0 0 1.12em;
}

.story-prose p:last-child {
  margin-bottom: 0;
}

.story-prose strong {
  color: #17252d;
}

.front-matter .story-prose {
  font-family: ui-rounded, "Avenir Next", "Segoe UI", sans-serif;
  font-size: clamp(1.45rem, 3vw, 2.5rem);
  font-weight: 750;
  line-height: 1.25;
  color: var(--water);
}

.picture-page {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  margin: 0;
  background: #fff;
}

.picture-page img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: #fff;
}

.landscape .picture-page img {
  height: auto;
  max-height: none;
}

.text-only .story-page {
  border: 0;
}

.text-only .story-prose {
  max-width: 48rem;
}

.reader-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .reader-main {
    padding: 18px 14px 24px;
  }

  .book-spread.portrait.has-story.has-image {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .portrait .story-page {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .picture-page img {
    width: 100%;
    height: auto;
    max-height: none;
  }
}

@media (max-width: 560px) {
  .book-spread {
    min-height: 0;
    border-radius: 9px;
  }

  .story-page {
    padding: 26px 22px;
  }

  .story-prose {
    font-size: 1.08rem;
    line-height: 1.58;
  }
}

@media print {
  .reader-header,
  .reader-footer {
    display: none;
  }

  .reader-main {
    width: 100%;
    padding: 0;
  }

  .book-spread {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
