* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --background-dark: #201b24;
  --cover-red: #9f263d;
  --cover-red-dark: #681326;
  --paper: #f4ead8;
  --paper-edge: #ddcfb8;
  --ink: #302830;
  --muted: #827276;
  --accent: #8f263b;
}
html, body { margin: 0; min-height: 100%; width: 100%; -webkit-tap-highlight-color: transparent; }
body {
  min-height: 100svh; color: var(--ink);
  background: radial-gradient(ellipse at 50% 15%, #423747, var(--background-dark) 70%);
  font-family: Georgia, "Times New Roman", serif;
}
button { font: inherit; }
.app { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.book-wrapper { position: relative; width: min(100%, 500px); }
.cover, .book {
  width: 100%; min-height: min(740px, calc(100svh - 48px));
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 28px 75px #0008;
}
.cover {
  position: relative; display: grid; place-items: center; text-align: center;
  color: #fff4e8;
  background:
    linear-gradient(135deg, #a82b43 0%, var(--cover-red) 48%, var(--cover-red-dark) 100%);
  border: 1px solid #d28b8d55;
  transition: opacity .45s ease, transform .45s ease;
}
.cover::before {
  content: ""; position: absolute; inset: 12px; border: 1px solid #f9e7d455;
  border-radius: 7px; pointer-events: none;
}
.cover-content { position: relative; z-index: 1; padding: 32px 28px; width: 100%; }
.cover-subtitle, .chapter-number, .page-topline, .cover-signature {
  font-family: Arial, sans-serif; letter-spacing: .17em; text-transform: uppercase;
}
.cover-subtitle { font-size: .68rem; font-weight: 700; }
.cover-line { width: 64px; height: 1px; margin: 22px auto; background: #fff3dfaa; }
.cover h1 { margin: 0; font-weight: 400; font-size: clamp(3rem, 11vw, 4.5rem); line-height: .98; }
.cover-small-text { margin: 22px 0 30px; color: #f7dfd7; font-style: italic; }
.cover-art { display: block; width: 112px; height: 112px; margin: 0 auto 16px; object-fit: contain; }
.cover-ornament { position: absolute; color: #f9dfd2; opacity: .5; pointer-events: none; }
.ornament-one { top: 42px; left: 38px; font-size: 1.7rem; }
.ornament-two { right: 38px; bottom: 46px; font-size: 2rem; }
.cover-signature { position: absolute; bottom: 28px; left: 0; right: 0; font-size: .58rem; opacity: .65; }
.open-book-button {
  min-height: 48px; padding: 12px 26px; border: 1px solid #fff9;
  border-radius: 999px; color: #fff4e8; background: #ffffff14; cursor: pointer;
}
.open-book-button:active, .navigation-button:active { transform: scale(.96); }
.cover.closing { opacity: 0; transform: translateX(-12px) rotateY(-12deg); }
.book { position: relative; display: flex; flex-direction: column; background: var(--paper); }
.hidden { display: none !important; }
.book-spine {
  position: absolute; z-index: 4; top: 0; bottom: 84px; left: 0; width: 9px;
  background: linear-gradient(90deg, #7d5e50aa, #fff4e033, transparent);
  pointer-events: none;
}
.page-stage {
  position: relative; flex: 1; min-height: 590px; overflow: hidden;
  perspective: 1800px; -webkit-perspective: 1800px;
  isolation: isolate; background: var(--paper); touch-action: pan-y;
}
.page {
  display: none; position: absolute; inset: 0; padding: 36px 42px 48px;
  overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: linear-gradient(100deg, #e8dcc7 0, #f7efdf 5%, var(--paper) 100%);
  box-shadow: inset 9px 0 18px #503b2810;
}
.page.active { display: block; }
.page-topline {
  display: flex; justify-content: space-between; gap: 12px; padding-bottom: 12px;
  border-bottom: 1px solid #8f263b30; color: var(--muted); font-size: .58rem;
}
.page-content { max-width: 100%; padding-top: 38px; }
.chapter-number { margin: 0 0 14px; color: var(--muted); font-size: .65rem; }
.page-divider { width: 56px; height: 1px; margin: 0 0 25px; background: var(--accent); opacity: .65; }
.page-number { position: absolute; bottom: 18px; right: 28px; color: #8a7772; font: .72rem Arial, sans-serif; }
.art-slot { margin: 22px auto 0; text-align: center; }
.art-slot img { display: block; width: 100%; height: 100%; object-fit: contain; }
.art-slot-large { width: 132px; height: 132px; }
.art-slot-small { width: 92px; height: 92px; }
.art-slot figcaption { margin-top: 4px; color: #95827b; font: .56rem Arial, sans-serif; letter-spacing: .06em; }
.art-row { display: flex; justify-content: center; align-items: flex-start; gap: 20px; margin-top: 22px; }
.art-row .art-slot { margin: 0; }
.reminder-list { padding-left: 20px; margin: 4px 0 18px; }
.reminder-list li { padding-left: 3px; margin-bottom: 12px; font-size: .98rem; line-height: 1.5; }
.final-art { margin-top: 8px; }
.closing-line { margin-top: 12px !important; text-align: center; font-style: italic; color: var(--accent); }
.book-navigation {
  position: relative; z-index: 6; min-height: 84px; padding: 14px 24px;
  display: flex; justify-content: space-between; align-items: center;
  background: #e9ddc9; border-top: 1px solid #59432c20;
}
.navigation-button {
  width: 46px; height: 46px; border: 0; border-radius: 50%;
  display: grid; place-items: center; color: #fff7ed; background: var(--accent);
  font-size: 1.35rem; cursor: pointer; touch-action: manipulation;
}
.navigation-button:disabled { opacity: .25; cursor: default; }
.page-indicator { color: var(--muted); font: .82rem Arial, sans-serif; }
.page-indicator-divider { margin: 0 6px; opacity: .5; }

/* The turning sheet is a real two-sided plane hinged at the book's vertical spine. */
.turn-sheet {
  position: absolute; z-index: 5; inset: 0;
  transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
  pointer-events: none; will-change: transform;
}
.turn-sheet.next { transform-origin: left center; animation: turn-forward .78s cubic-bezier(.45,.05,.2,1) both; }
.turn-sheet.previous { transform-origin: right center; animation: turn-backward .78s cubic-bezier(.45,.05,.2,1) both; }
.turn-face {
  position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto;
  -webkit-overflow-scrolling: touch; padding: 36px 42px 48px;
  transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transform: translateZ(0); -webkit-transform: translateZ(0);
  background: linear-gradient(100deg, #e8dcc7 0, #f7efdf 5%, var(--paper) 100%);
}
/* The turning faces are not .page elements, so they need the same typography rules. */
.page h2, .turn-face h2 { margin: 0 0 20px; font-size: clamp(2rem, 7vw, 2.7rem); font-weight: 400; line-height: 1.08; }
.page p:not(.chapter-number), .turn-face p:not(.chapter-number) { margin: 0 0 17px; font-size: 1rem; line-height: 1.72; }
.turn-face.back { transform: rotateY(180deg) translateZ(0); -webkit-transform: rotateY(180deg) translateZ(0); }
.turn-sheet.next .turn-face.front { box-shadow: inset -18px 0 24px #30201622; }
.turn-sheet.previous .turn-face.front { box-shadow: inset 18px 0 24px #30201622; }
.turn-sheet::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, #24170f00, #24170f18);
  opacity: .7;
}
@keyframes turn-forward { from { transform: rotateY(0); } to { transform: rotateY(-180deg); } }
@keyframes turn-backward { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }

@media (max-width: 600px) {
  .app { padding: 0; min-height: 100svh; }
  .book-wrapper { width: 100%; min-height: 100svh; }
  .cover, .book { min-height: 100svh; min-height: 100dvh; border-radius: 0; }
  .cover::before { inset: 10px; }
  .page-stage { min-height: 0; }
  .page, .turn-face { padding: max(30px, env(safe-area-inset-top)) 27px 44px; }
  .page-content { padding-top: 32px; }
  .page h2, .turn-face h2 { font-size: clamp(1.85rem, 8vw, 2.35rem); }
  .page p:not(.chapter-number), .turn-face p:not(.chapter-number) { font-size: .98rem; line-height: 1.68; }
  .book-navigation { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .book-spine { bottom: 84px; width: 6px; }
  .cover-signature { bottom: max(28px, env(safe-area-inset-bottom)); }
}
@media (max-height: 700px) and (min-width: 601px) {
  .cover, .book { min-height: 650px; }
  .page-stage { min-height: 566px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Install and daily-reminder UI */
.install-offer { display: none; margin: 20px auto 0; max-width: 310px; }
.install-offer.is-mobile { display: block; }
.install-button {
  min-height: 42px; padding: 10px 18px; border: 1px solid #f6d9d7aa;
  border-radius: 999px; color: #fff4e8; background: #3c101b55;
  font: 600 .78rem Arial, sans-serif; cursor: pointer;
}
.install-hint { max-width: 290px; margin: 8px auto 0; color: #f7dfd7; font: .68rem/1.45 Arial, sans-serif; opacity: .88; }
.daily-card {
  margin: 24px 0 20px; padding: 16px 17px 14px; border: 1px solid #9b6e6a55;
  border-radius: 10px; background: #fff8ecaa; text-align: center;
}
.daily-card-label { margin: 0 0 10px !important; color: var(--muted); font: 600 .58rem Arial, sans-serif !important; letter-spacing: .14em; }
.daily-message { margin: 0 0 7px !important; color: var(--accent); font-size: 1.04rem !important; line-height: 1.5 !important; font-style: italic; }
.daily-message-date { margin: 0 0 12px !important; color: var(--muted); font: .62rem Arial, sans-serif !important; }
.notification-button {
  min-height: 38px; padding: 8px 14px; border: 1px solid #8f263b66; border-radius: 999px;
  color: var(--accent); background: transparent; font: 600 .72rem Arial, sans-serif; cursor: pointer;
}
.notification-button:disabled { opacity: .58; cursor: default; }
.notification-status { margin: 9px 0 0 !important; color: var(--muted); font: .65rem/1.45 Arial, sans-serif !important; }
@media (max-width: 600px) {
  .install-offer { margin-top: 15px; }
  .install-hint { max-width: 270px; }
  .daily-card { margin-top: 18px; padding: 13px 14px; }
}
