:root {
  --ink: #211c17;
  --muted: #776b5f;
  --paper: #f5eddf;
  --paper-deep: #ead8c1;
  --line: rgba(54, 42, 31, 0.18);
  --accent: #9f3152;
  --accent-dark: #642238;
  --sage: #72764d;
  --violet: #7d5b88;
  --wash: #d2a39a;
  --shadow: 0 26px 60px rgba(31, 22, 15, 0.2);
  --reader-size: 1.05rem;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #f7f0e7;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-pale {
  --paper: #fbfaf5;
  --paper-deep: #ece8dc;
  --line: rgba(26, 28, 24, 0.14);
}

body.theme-dusk {
  --ink: #eee7d8;
  --muted: #b9ad9b;
  --paper: #201f22;
  --paper-deep: #17171a;
  --line: rgba(238, 231, 216, 0.16);
  --shadow: 0 26px 60px rgba(0, 0, 0, 0.34);
  background: #111113;
  color: var(--ink);
  color-scheme: dark;
}

body.font-small {
  --reader-size: 0.98rem;
}

body.font-large {
  --reader-size: 1.18rem;
}

a {
  color: inherit;
}

button,
a,
input {
  touch-action: manipulation;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  padding: 0.65rem 0.85rem;
  border-radius: 5px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  background: rgba(247, 240, 231, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.theme-dusk .site-header {
  background: rgba(17, 17, 19, 0.88);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 0.9rem;
  height: 1.2rem;
  border: 2px solid currentColor;
  border-bottom-width: 4px;
  border-radius: 50% 50% 2px 2px;
}

.site-nav {
  display: flex;
  gap: clamp(0.65rem, 2vw, 1.35rem);
  font-size: 0.92rem;
}

.site-nav a,
.text-link {
  text-decoration-color: transparent;
  text-underline-offset: 0.28em;
  transition: text-decoration-color 180ms ease, color 180ms ease;
}

.site-nav a:hover,
.text-link:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.hero {
  min-height: calc(100svh - 4rem);
  display: grid;
  grid-template-columns: minmax(18rem, 0.72fr) minmax(19rem, 0.9fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  padding: clamp(2.5rem, 7vw, 6rem) clamp(1rem, 5vw, 5rem) 3rem;
  background:
    radial-gradient(circle at 16% 24%, rgba(159, 49, 82, 0.18), transparent 18rem),
    radial-gradient(circle at 80% 16%, rgba(125, 91, 136, 0.2), transparent 20rem),
    radial-gradient(circle at 42% 82%, rgba(114, 118, 77, 0.16), transparent 18rem),
    linear-gradient(135deg, #f0dfca 0%, #fbf4ea 48%, #efe3d5 100%);
}

.theme-dusk .hero {
  background:
    radial-gradient(circle at 76% 18%, rgba(139, 40, 56, 0.2), transparent 28rem),
    linear-gradient(135deg, #181719 0%, #242023 50%, #13211e 100%);
}

.hero-art {
  position: relative;
  margin: 0;
  justify-self: center;
  width: min(100%, 28rem);
  aspect-ratio: 942 / 1413;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--paper);
}

.hero-art img,
.chapter-illustration img,
.gallery-strip img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-copy {
  max-width: 39rem;
}

.kicker,
.tool-label {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.05;
}

h1 {
  max-width: 10ch;
  font-size: clamp(4rem, 12vw, 9.5rem);
}

h2 {
  font-size: clamp(2.1rem, 5vw, 4.4rem);
}

h3 {
  font-size: 1.38rem;
}

.hero-copy p:not(.kicker),
.feature-band p {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.8rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0 1.1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 750;
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff9ef;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.28);
}

.about-novel {
  display: grid;
  grid-template-columns: minmax(18rem, 0.75fr) minmax(20rem, 1fr);
  gap: clamp(1.5rem, 5vw, 5rem);
  padding: clamp(3rem, 7vw, 6rem) clamp(1rem, 5vw, 5rem);
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 82% 12%, rgba(125, 91, 136, 0.12), transparent 18rem),
    var(--paper);
}

.about-novel h2 {
  max-width: 11ch;
}

.about-novel-copy {
  max-width: 47rem;
}

.about-novel-copy p {
  margin: 0 0 1.2rem;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.12rem, 1.7vw, 1.45rem);
  line-height: 1.65;
}

.about-novel-copy p:last-child {
  margin-bottom: 0;
}

.reader-shell {
  display: grid;
  grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
  gap: clamp(0.75rem, 2vw, 1.35rem);
  align-items: start;
  padding: clamp(0.65rem, 1.8vw, 1.25rem);
  border-top: 1px solid var(--line);
}

.reader-tools {
  position: sticky;
  top: 5.2rem;
  display: grid;
  gap: 0.9rem;
  max-height: calc(100svh - 6.5rem);
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.3);
}

.reader-preferences {
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line);
}

.chapter-picker {
  min-height: 0;
}

.chapter-picker .tool-label {
  margin-top: 0.45rem;
}

.theme-dusk .reader-tools,
.theme-dusk .button.secondary {
  background: rgba(255, 255, 255, 0.04);
}

.chapter-list {
  display: grid;
  gap: 0.25rem;
}

.chapter-select {
  display: none;
  width: 100%;
  min-height: 2.8rem;
  padding: 0 0.7rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.chapter-list button,
.segmented button,
.swatch {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.chapter-list button {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 0.65rem;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
  line-height: 1.25;
}

.chapter-list button small {
  display: block;
  margin-bottom: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.chapter-list button.active {
  background: var(--accent);
  color: #fff9ef;
}

.chapter-list button.active small {
  color: rgba(255, 249, 239, 0.72);
}

.segmented,
.swatches {
  display: flex;
  gap: 0.35rem;
}

.segmented {
  padding: 0.28rem;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.segmented button {
  width: 2.45rem;
  min-width: 2.65rem;
  height: 2.65rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
}

.segmented button:nth-child(1) {
  font-size: 0.85rem;
}

.segmented button:nth-child(3) {
  font-size: 1.2rem;
}

.segmented button.active {
  background: var(--ink);
  color: var(--paper);
}

.swatch {
  width: 2.75rem;
  height: 2.75rem;
  border: 2px solid transparent;
  border-radius: 50%;
}

.swatch.active {
  border-color: var(--accent);
}

.swatch.warm {
  background: #f4ebdc;
}

.swatch.pale {
  background: #fbfaf5;
}

.swatch.dusk {
  background: #201f22;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.toggle input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}

.reader-mode-button,
.reader-exit-button {
  min-height: 2.65rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.reader-exit-button {
  position: fixed;
  top: 0.9rem;
  right: 1rem;
  z-index: 100;
  display: none;
  box-shadow: 0 14px 30px rgba(32, 27, 24, 0.18);
}

.book {
  display: grid;
  align-items: stretch;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  width: min(100%, 92rem);
  max-width: 92rem;
  height: min(94svh, 78rem);
  min-height: 52rem;
  margin-inline: auto;
  color: var(--ink);
  filter: drop-shadow(0 28px 44px rgba(32, 27, 24, 0.16));
}

.book.art-collapsed {
  grid-template-columns: 1fr;
  max-width: 70rem;
  height: min(94svh, 78rem);
  min-height: 52rem;
}

.book.art-collapsed .title-page {
  display: none;
}

.book.art-collapsed .reading-page {
  border-left: 1px solid var(--line);
}

.book-page {
  min-height: 0;
  padding: clamp(1.5rem, 3.3vw, 4.6rem);
  background:
    linear-gradient(90deg, rgba(32, 27, 24, 0.05), transparent 1.2rem),
    var(--paper);
  border: 1px solid var(--line);
}

.title-page {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 0;
  overflow: auto;
}

.title-page h2 {
  max-width: 11ch;
  margin-bottom: 0.75rem;
}

.chapter-note {
  color: var(--muted);
  line-height: 1.55;
}

.chapter-illustration {
  width: min(100%, 18rem);
  aspect-ratio: 942 / 1331;
  margin-top: 2rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
}

.chapter-illustration img {
  object-fit: contain;
}

.reading-page {
  position: relative;
  height: 100%;
  max-height: none;
  overflow: auto;
  scroll-padding-top: 2rem;
  transform-origin: left center;
  will-change: transform, opacity;
}

.reading-page::before,
.reading-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.reading-page::before {
  inset: auto 0 0 auto;
  width: min(76%, 32rem);
  aspect-ratio: 1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82) 0%, var(--paper) 46%, rgba(32, 27, 24, 0.22) 48%, rgba(255, 255, 255, 0.35) 52%, var(--paper-deep) 100%);
  border-left: 1px solid rgba(32, 27, 24, 0.14);
  border-top: 1px solid rgba(32, 27, 24, 0.12);
  box-shadow: -1.8rem -1.8rem 3.2rem rgba(32, 27, 24, 0.22);
  clip-path: polygon(100% 100%, 100% 0, 0 100%);
  transform: translate(45%, 45%) rotate(0deg);
  transform-origin: 100% 100%;
  z-index: 3;
}

.reading-page::after {
  background:
    radial-gradient(circle at 100% 100%, rgba(32, 27, 24, 0.26), transparent 24rem),
    linear-gradient(135deg, transparent 42%, rgba(32, 27, 24, 0.16));
  z-index: 2;
}

.book.page-turn-next .reading-page {
  animation: pageTurnNext 690ms cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.book.page-turn-previous .reading-page {
  animation: pageTurnPrevious 560ms cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.book.page-turn-next .reading-page::before {
  animation: pageCurlNext 690ms cubic-bezier(0.2, 0.72, 0.2, 1) both;
}

.book.page-turn-next .reading-page::after,
.book.page-turn-previous .reading-page::after {
  animation: pageSheen 690ms ease both;
}

.book.page-settle .reading-page {
  animation: pageSettle 230ms ease-out both;
}

.reading-page p {
  margin: 0 0 1.05em;
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(var(--reader-size) * 1.08);
  line-height: 1.82;
}

.reading-page em {
  font-style: italic;
}

.reading-page p:first-child::first-letter {
  float: left;
  padding: 0.1rem 0.45rem 0 0;
  color: var(--accent);
  font-size: 4.3em;
  line-height: 0.82;
}

.reader-progress {
  position: sticky;
  top: 0;
  height: 0.24rem;
  margin: -1px -1px 1.5rem;
  background: rgba(139, 40, 56, 0.12);
}

.reader-progress span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
}

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.chapter-nav button {
  min-height: 2.6rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.chapter-nav button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

@keyframes pageTurnNext {
  0% {
    opacity: 1;
    transform: translateY(0);
  }

  52% {
    opacity: 0.92;
    transform: translateY(-0.18rem);
  }

  100% {
    opacity: 0.28;
    transform: translateY(-0.55rem);
  }
}

@keyframes pageTurnPrevious {
  0% {
    opacity: 1;
    transform: perspective(1200px) rotateY(0deg) translateX(0);
  }

  48% {
    opacity: 0.52;
    transform: perspective(1200px) rotateY(10deg) translateX(1.2rem);
  }

  100% {
    opacity: 0.08;
    transform: perspective(1200px) rotateY(18deg) translateX(2.5rem);
  }
}

@keyframes pageCurlNext {
  0% {
    opacity: 0;
    transform: translate(45%, 45%) rotate(0deg);
  }

  18% {
    opacity: 1;
  }

  50% {
    opacity: 1;
    transform: translate(4%, 3%) rotate(-17deg);
  }

  100% {
    opacity: 0;
    transform: translate(-64%, -72%) rotate(-38deg);
  }
}

@keyframes pageSheen {
  0%,
  100% {
    opacity: 0;
  }

  45% {
    opacity: 0.62;
  }
}

@keyframes pageSettle {
  0% {
    opacity: 0.42;
    transform: perspective(1200px) rotateY(4deg) translateX(0.7rem);
  }

  100% {
    opacity: 1;
    transform: perspective(1200px) rotateY(0deg) translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .book.page-turn-next .reading-page,
  .book.page-turn-previous .reading-page,
  .book.page-settle .reading-page,
  .book.page-turn-next .reading-page::before,
  .book.page-turn-next .reading-page::after,
  .book.page-turn-previous .reading-page::after {
    animation: none;
  }
}

.feature-band {
  display: grid;
  grid-template-columns: minmax(18rem, 0.8fr) minmax(18rem, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: start;
  padding: clamp(3rem, 7vw, 6rem) clamp(1rem, 5vw, 5rem);
  border-top: 1px solid var(--line);
}

.edition-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.edition-card {
  min-height: 13rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.34);
}

.theme-dusk .edition-card {
  background: rgba(255, 255, 255, 0.04);
}

.edition-card p {
  font-size: 0.95rem;
  line-height: 1.55;
}

.audio-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.play-button {
  width: 3.2rem;
  height: 3.2rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
}

.play-button::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin-left: 1.25rem;
  border-top: 0.55rem solid transparent;
  border-bottom: 0.55rem solid transparent;
  border-left: 0.78rem solid #fff9ef;
}

.audio-panel span {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
}

.author {
  background:
    radial-gradient(circle at 20% 15%, rgba(159, 49, 82, 0.12), transparent 18rem),
    radial-gradient(circle at 90% 65%, rgba(114, 118, 77, 0.12), transparent 16rem);
}

.author-note {
  max-width: 42rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 16px 38px rgba(31, 22, 15, 0.1);
}

.author-note p {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  line-height: 1.35;
}

.author-note .button {
  margin-top: 1.4rem;
}

.contact {
  background: var(--paper);
}

.contact-panel {
  display: grid;
  gap: 0.9rem;
  align-content: start;
  justify-items: start;
  max-width: 32rem;
  padding: clamp(1.2rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.3);
}

.support {
  align-items: center;
}

.art-gallery {
  padding: clamp(3rem, 7vw, 6rem) clamp(1rem, 5vw, 5rem);
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 10%, rgba(159, 49, 82, 0.13), transparent 18rem),
    radial-gradient(circle at 80% 30%, rgba(125, 91, 136, 0.14), transparent 22rem);
}

.art-gallery h2 {
  max-width: 12ch;
  margin-bottom: 1.5rem;
}

.gallery-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
}

.gallery-strip img {
  aspect-ratio: 942 / 1331;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 16px 38px rgba(31, 22, 15, 0.13);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 4vw, 3rem);
  color: var(--muted);
  border-top: 1px solid var(--line);
}

body.reader-mode {
  overflow: hidden;
  background: var(--paper-deep);
}

body.reader-mode .site-header,
body.reader-mode .hero,
body.reader-mode .feature-band,
body.reader-mode .art-gallery,
body.reader-mode .site-footer {
  display: none;
}

body.reader-mode main {
  height: 100svh;
}

body.reader-mode .reader-shell {
  grid-template-columns: 1fr;
  gap: 0;
  height: 100svh;
  padding: 0.65rem;
  border-top: 0;
}

body.reader-mode .reader-tools {
  display: none;
}

body.reader-mode .book,
body.reader-mode .book.art-collapsed {
  grid-template-columns: 1fr;
  width: 100%;
  max-width: none;
  height: calc(100svh - 1.3rem);
  min-height: 0;
}

body.reader-mode .title-page {
  display: none;
}

body.reader-mode .reader-exit-button {
  display: inline-flex;
  align-items: center;
}

@media (max-width: 980px) {
  .hero,
  .about-novel,
  .reader-shell,
  .feature-band {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-art {
    order: 2;
  }

  .reader-tools {
    position: static;
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .chapter-picker {
    grid-column: 1 / -1;
  }

  .chapter-select {
    display: block;
  }

  .chapter-list {
    display: none;
  }

  body.reader-mode {
    overflow: auto;
  }

  body.reader-mode .reader-shell {
    height: auto;
  }

  .book,
  .edition-grid,
  .gallery-strip {
    grid-template-columns: 1fr;
  }

  .book,
  .book.art-collapsed {
    height: auto;
    min-height: 0;
    width: 100%;
  }

  .title-page {
    border-right: 1px solid var(--line);
    border-bottom: 0;
    overflow: visible;
  }
}

@media (max-width: 680px) {
  .site-header,
  .site-nav,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }

  h1 {
    font-size: clamp(3.4rem, 21vw, 5.8rem);
  }

  .book-page {
    padding: 1.25rem;
  }

  .reader-tools {
    grid-template-columns: 1fr;
  }

  .reading-page {
    max-height: none;
  }

  body.reader-mode .reader-exit-button {
    top: 0.6rem;
    right: 0.6rem;
  }
}
