:root {
  color-scheme: light;
  --ink: #22201c;
  --muted: #6f665a;
  --paper: #fffdf7;
  --paper-deep: #f2eadb;
  --line: #d9cbb6;
  --accent: #9b2f2f;
  --accent-dark: #5f1d1d;
  --gold: #b88b45;
  --green: #243b35;
  --shadow: 0 18px 46px rgba(20, 24, 20, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #23322f;
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif CJK SC", "STSong", serif;
}

button {
  font: inherit;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px 14px 18px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    #23322f;
  background-size: 28px 28px, 28px 28px, auto;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  color: #fff8ea;
  padding: 2px 2px 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #e7c98f;
  font-size: 12px;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.page-count {
  flex: 0 0 auto;
  margin: 4px 0 0;
  color: #e7c98f;
  font-family: "Times New Roman", serif;
  font-size: 13px;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  perspective: 1300px;
}

.book {
  position: relative;
  width: min(100%, 430px);
  height: min(720px, calc(100dvh - 154px));
  min-height: 440px;
  border-radius: 4px 12px 12px 4px;
  filter: drop-shadow(var(--shadow));
  transform-style: preserve-3d;
}

.book::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px -8px;
  width: 18px;
  border-radius: 12px 0 0 12px;
  background: linear-gradient(90deg, #2b1f18, #735238 48%, rgba(255, 255, 255, 0.18));
  box-shadow: inset -5px 0 12px rgba(0, 0, 0, 0.22);
  z-index: 0;
}

.page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid rgba(116, 86, 47, 0.36);
  border-radius: 4px 12px 12px 4px;
  background:
    linear-gradient(90deg, rgba(79, 46, 26, 0.12), transparent 9%, transparent 92%, rgba(95, 55, 28, 0.08)),
    repeating-linear-gradient(0deg, rgba(155, 120, 72, 0.045), rgba(155, 120, 72, 0.045) 1px, transparent 1px, transparent 30px),
    var(--paper);
  box-shadow:
    inset 12px 0 24px rgba(80, 53, 30, 0.1),
    inset -1px 0 0 rgba(255, 255, 255, 0.72);
  backface-visibility: hidden;
  transform-origin: left center;
}

.page--current {
  z-index: 2;
}

.page--incoming {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}

.page--flipper {
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}

.book.is-flipping-next .page--current {
  opacity: 0;
}

.book.is-flipping-next .page--incoming {
  opacity: 1;
}

.book.is-flipping-next .page--flipper {
  opacity: 1;
  animation: turn-next 620ms cubic-bezier(0.2, 0.7, 0.14, 1) forwards;
}

.book.is-flipping-prev .page--current {
  z-index: 1;
}

.book.is-flipping-prev .page--flipper {
  opacity: 1;
  animation: turn-prev 620ms cubic-bezier(0.2, 0.7, 0.14, 1) forwards;
}

@keyframes turn-next {
  0% {
    transform: rotateY(0deg);
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.16);
  }
  100% {
    transform: rotateY(-108deg);
    box-shadow: 18px 0 34px rgba(0, 0, 0, 0.08);
  }
}

@keyframes turn-prev {
  0% {
    transform: rotateY(-108deg);
    box-shadow: 18px 0 34px rgba(0, 0, 0, 0.08);
  }
  100% {
    transform: rotateY(0deg);
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.16);
  }
}

.page-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 20px 24px 26px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.cover-page .page-scroll {
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: center;
}

.cover-photo {
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  background: #f8f1e4;
  box-shadow: 0 10px 22px rgba(58, 43, 26, 0.14);
}

.cover-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 2362 / 1795;
  object-fit: contain;
  background: #151515;
}

.cover-title {
  margin: 0;
  color: var(--accent-dark);
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: 0;
}

.cover-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.cover-mark {
  width: 58px;
  height: 4px;
  border-radius: 999px;
  background: var(--gold);
}

.person-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.class-name {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.person-name {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  color: var(--ink);
  letter-spacing: 0;
}

.student-no {
  margin: 0;
  color: var(--muted);
  font-family: "Times New Roman", serif;
  font-size: 14px;
  white-space: nowrap;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.photo-card {
  margin: 0;
  padding: 7px;
  border: 1px solid var(--line);
  background: #f9f4e9;
  box-shadow: 0 8px 18px rgba(55, 38, 20, 0.12);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: contain;
  background: #ebe3d4;
}

.memory-text {
  display: grid;
  gap: 11px;
  color: #2c2924;
  font-size: 16px;
  line-height: 1.78;
}

.memory-text p {
  margin: 0;
  text-align: justify;
}

.edge-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 25%;
  z-index: 5;
  border: 0;
  background: transparent;
  opacity: 0;
}

.edge-hit--prev {
  left: 0;
}

.edge-hit--next {
  right: 0;
}

.edge-hit:disabled {
  pointer-events: none;
}

.controls {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 88px;
  min-height: 42px;
  border: 1px solid rgba(231, 201, 143, 0.56);
  border-radius: 999px;
  background: rgba(255, 248, 234, 0.1);
  color: #fff8ea;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.nav-button:disabled {
  color: rgba(255, 248, 234, 0.42);
  border-color: rgba(255, 248, 234, 0.18);
  box-shadow: none;
}

.page-slider {
  --slider-progress: 0%;
  width: 100%;
  min-width: 0;
  height: 34px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  accent-color: #e7c98f;
  background: transparent;
  cursor: pointer;
}

.page-slider:disabled {
  cursor: default;
  opacity: 0.62;
}

.page-slider::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #e7c98f 0%,
    #e7c98f var(--slider-progress),
    rgba(255, 248, 234, 0.26) var(--slider-progress),
    rgba(255, 248, 234, 0.26) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(231, 201, 143, 0.08);
}

.page-slider::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -8.5px;
  border: 2px solid #fff8ea;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: #e7c98f;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28);
}

.page-slider::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #e7c98f 0%,
    #e7c98f var(--slider-progress),
    rgba(255, 248, 234, 0.26) var(--slider-progress),
    rgba(255, 248, 234, 0.26) 100%
  );
  box-shadow: inset 0 0 0 1px rgba(231, 201, 143, 0.08);
}

.page-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid #fff8ea;
  border-radius: 50%;
  background: #e7c98f;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.28);
}

@media (max-width: 360px) {
  .app {
    padding-inline: 10px;
  }

  .page-scroll {
    padding: 18px 16px 20px 22px;
  }

  .person-name {
    font-size: 26px;
  }

  .memory-text {
    font-size: 15px;
  }

  .nav-button {
    min-width: 76px;
  }
}

@media (min-width: 760px) {
  .app {
    padding: 26px 24px 24px;
  }

  .topbar {
    width: min(100%, 680px);
    justify-self: center;
  }

  h1 {
    font-size: 22px;
  }

  .book {
    width: min(68vw, 640px);
    height: min(800px, calc(100dvh - 174px));
    min-height: 560px;
  }

  .page-scroll {
    padding: 34px 34px 36px 42px;
  }

  .cover-title {
    font-size: 38px;
  }

  .photo-grid {
    gap: 14px;
  }

  .controls {
    width: min(100%, 680px);
    justify-self: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book.is-flipping-next .page--flipper,
  .book.is-flipping-prev .page--flipper {
    animation-duration: 1ms;
  }

  .page-slider::-webkit-slider-thumb {
    transition: none;
  }
}
