:root {
  color-scheme: light;
  --ink: #36352c;
  --wine: #873e36;
  --paper: #faf7ef;
  --gold: #dfc18e;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --sans: "DM Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body { margin: 0; color: var(--ink); font: 1rem/1.5 var(--sans); background: #eae7dd }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 42% 14%, #fffdf4a6, transparent 72%),
    repeating-linear-gradient(0deg, #80705305 0 1px, transparent 1px 4px);
}
button, select { color: inherit; font: inherit }
button, select { cursor: pointer }
button { background: transparent; border: 0 }
button:focus-visible, select:focus-visible { outline: 3px solid #a66c41; outline-offset: 4px }
button:disabled { cursor: default }
figure, h1, h2, p { margin: 0 }
.symbols, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
.icon { display: block; width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round }
header { background: #faf8f2; border-bottom: 1px solid #d4cfc2 }
.bar { width: min(1180px, 90%); margin: auto; min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 10px }
.brand, .directory, .directory label, .turn, .open-book { display: inline-flex; align-items: center }
.brand { gap: 10px; padding: 7px 0; font: 700 1.35rem var(--serif); letter-spacing: .08em }
.brand .icon { color: var(--wine); width: 27px; height: 27px }
.directory { gap: 11px; font-size: .88rem; color: #615d50 }
.directory label { gap: 7px; white-space: nowrap }
.directory label .icon { width: 16px; height: 16px }
.select-wrap { position: relative }
select { appearance: none; border: 1px solid #d2ccbf; border-radius: 5px; background: #fdfbf6; padding: 7px 30px 7px 11px; min-height: 36px }
.select-wrap .icon { position: absolute; pointer-events: none; right: 10px; top: calc(50% - 6px); width: 12px; height: 12px; transform: rotate(90deg) }
main { display: grid; place-items: center; min-height: calc(100svh - 69px); padding: 28px 0 20px }
.reader { width: min(1020px, 88%); --book-height: clamp(325px, 61vw, min(568px, calc(100svh - 200px))) }
#book {
  position: relative; isolation: isolate; height: var(--book-height); touch-action: pan-y pinch-zoom;
  border: 1px solid #64372e; border-radius: 9px 15px 13px 8px;
  background-color: var(--wine);
  box-shadow: 0 1px 0 1px #62372b, 1px 3px 0 1px #efe4c9, 2px 4px 0 1px #ada28b,
    3px 6px 0 1px #e9dfc9, 4px 8px 0 1px #634338, 5px 10px 0 1px #7f4a3b,
    12px 24px 26px -12px #3c362d59, 0 34px 50px -34px #292a2366;
}
#book::after {
  content: ""; pointer-events: none; position: absolute; inset: 0; border-radius: inherit;
  background: url("grain.png"); opacity: .075; z-index: 2; mix-blend-mode: multiply;
}
.cover-page, #photo-page, #future-page { position: absolute; inset: 0; border-radius: inherit; overflow: hidden }
.cover-page {
  display: grid; grid-template-columns: 49% 51%; grid-template-rows: 66% 34%; padding: 3% 7% 3% 12%;
  color: #fff4db;
  background:
    linear-gradient(90deg, #361a19a1, #4b262700 1.3%, #b7705b33 2.2%, #562e2a50 3.4%, #441d1c82 4%, #b270564a 4.6%, #6e352a00 5.6%),
    repeating-linear-gradient(0deg, #f1bca40a 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, #2a0f1314 0 1px, transparent 1px 3px),
    linear-gradient(110deg, #823c36, #943f39 55%, #7d3934);
}
.cover-page::before {
  content: ""; position: absolute; pointer-events: none; inset: 17px 17px 17px 6.5%;
  border: 1px solid #d8b47e77; outline: 1px solid #c4a16a47; outline-offset: -5px; border-radius: 2px 7px 7px 2px;
}
.cover-type { align-self: end; z-index: 1 }
.small-caps { color: var(--gold); font: 600 .76rem/1.45 Georgia, serif; text-transform: uppercase; letter-spacing: .23em }
.cover-type .small-caps::before { content: ""; display: inline-block; vertical-align: middle; margin-right: 10px; width: 21px; height: 1px; background: currentColor }
h1 { font: 600 clamp(2rem, 3.6vw, 3.6rem)/1.12 var(--serif); letter-spacing: .035em; margin: 20px 0 17px; text-shadow: 0 1px 2px #30120c80 }
h1 span { display: block; font-size: 1.44em; letter-spacing: .04em; margin-top: 3px }
.dates { font: .89rem/1.5 "Courier New", monospace; letter-spacing: .1em; color: #edd6af }
.dates span { margin: 0 3px }
.open-book { position: relative; grid-area: 2 / 1; place-self: start; margin-top: 21px; gap: 9px; border-radius: 3px; padding: 10px 18px; color: #5b3028; background: #f3e7cd; box-shadow: 0 2px 3px #361b183b; font-size: .94rem }
.open-book:hover { background: #fff3d9 }
.cover-photo {
  grid-area: 1 / 2 / 3 / 3; position: relative; place-self: center;
  height: min(77%, 368px); max-width: 94%; aspect-ratio: .78;
  display: grid; grid-template-rows: minmax(0, 1fr) auto; padding: 10px 10px 0;
  transform: rotate(6deg); background: #fffaf0;
  box-shadow: 2px 5px 7px #29170f42, 5px 15px 21px #2b160c42;
}
.cover-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center 52% }
.cover-photo figcaption { padding: 8px 0; text-align: center; text-wrap: balance; font: .95rem/1.45 "KaiTi", "Kaiti SC", var(--serif); color: #5b4c3e }
.tape { position: absolute; z-index: 1; top: -9px; left: 31%; width: 38%; height: 23px; transform: rotate(-5deg); background: repeating-linear-gradient(90deg, #a38a651f 0 2px, transparent 2px 4px), #dccda9d6; clip-path: polygon(0 0, 99% 3%, 97% 25%, 100% 45%, 98% 65%, 100% 95%, 0 100%, 2% 79%, 0 60%, 2% 35%) }
#photo-page { display: grid; grid-template-columns: 43% 57%; background: #f9f5e9 }
.month-side { display: grid; place-items: center; text-align: center; background: linear-gradient(90deg, #f6efdf 0, #f9f6ed 5%, #f9f6ed 88%, #e9e0ce 97%, #b9ab94 100%) }
.month-copy { width: 100%; padding: 10px }
#year { color: #7d5141; font: .94rem/1.3 "Courier New", monospace; letter-spacing: .19em }
#month-name { margin: 15px 0 1px; font: 600 clamp(2.3rem, 5vw, 4.4rem)/1.25 var(--serif); color: #46382e }
.script { font: italic clamp(1.35rem, 2.3vw, 2.1rem)/1.5 "Segoe Script", "Bradley Hand", Georgia, serif; color: #997253 }
.dash { width: 35px; height: 1px; background: #ac8e71; margin: 24px auto 18px }
#month-position { font-size: .9rem; color: #746859 }
.photo-side { padding: 23px 4% 17px; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-width: 0; min-height: 0; align-items: center; justify-items: center; background: linear-gradient(90deg, #d1c4ae, #f3eddf 3%, #fcf9ef 12%, #faf7ed 97%, #e8dfce) }
.photo-mat { display: flex; justify-content: center; align-items: center; width: 100%; height: 100%; min-height: 0 }
.photo-mat img { display: block; width: auto; height: auto; max-height: 100%; max-width: 100%; object-fit: contain; border: 7px solid #fffdf7; box-shadow: 1px 3px 8px #58452d38 }
.photo-mat { padding: 0; cursor: zoom-in }
#zoom-dialog { padding: 0; margin: auto; border: 0; color: #fffaf1; background: transparent; max-width: 97vw; max-height: 98dvh }
#zoom-dialog::backdrop { background: #211c19f5 }
#zoom-image { display: block; max-width: 96vw; max-height: 83dvh; object-fit: contain; margin: auto }
#zoom-close { display: grid; place-items: center; position: fixed; right: max(14px, 3vw); top: max(12px, 2vh); width: 42px; height: 42px; border-radius: 50%; color: white; background: #332a24dc; border: 1px solid #d4cbb578; font: 1.65rem/1 Arial, sans-serif }
#zoom-caption { padding: 12px 8px 0; text-align: center; font: 1rem/1.5 var(--serif) }
#caption { margin-top: 11px; text-align: center; color: #625442; font: clamp(.95rem, 1.5vw, 1.12rem)/1.5 "KaiTi", "Kaiti SC", var(--serif) }
#future-page { display: grid; place-items: center; background: radial-gradient(ellipse at 50% 38%, #fffdf6, #ede5d4); color: var(--wine) }
#future-page::before { content: ""; position: absolute; inset: 17px; border: 1px solid #c6bca5; pointer-events: none }
.ending { text-align: center }
.ending .dates { color: #756350 }
.ending h2 { margin: 20px 0 10px; font: 600 clamp(2.65rem, 6vw, 4.5rem)/1.25 var(--serif); letter-spacing: .1em }
.ending .icon { margin: 18px auto 24px }
#restart { padding: 8px 10px; border-bottom: 1px solid #b69780; font-size: .9rem }
.controls { width: min(500px, 100%); margin: 31px auto 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 25px }
.turn { justify-content: center; gap: 6px; border: 1px solid #c7bead; border-radius: 5px; background: #f9f7ef; font-size: .88rem; min-height: 40px; padding: 8px 15px }
.turn:not(:disabled):hover { background: #fffdf7; border-color: #936658; color: var(--wine) }
.turn:disabled { opacity: .4 }
.turn .icon { width: 14px; height: 14px }
#prev .icon { transform: rotate(180deg) }
.page-info { display: grid; justify-items: center; gap: 6px; color: #6e6659; font-size: .85rem; text-align: center }
progress { appearance: none; display: block; width: min(100%, 135px); height: 3px; border: 0; border-radius: 2px; overflow: hidden; background: #cbc4b6; color: var(--wine) }
progress::-webkit-progress-bar { background: #cbc4b6 }
progress::-webkit-progress-value { background: var(--wine) }
progress::-moz-progress-bar { background: var(--wine) }
@media (min-width: 651px) and (max-height: 540px) {
  .bar { min-height: 48px }
  main { min-height: calc(100svh - 49px); padding: 12px 0 }
  .reader { --book-height: max(220px, calc(100svh - 126px)) }
  .controls { margin-top: 16px }
  h1 { font-size: 1.9rem; margin: 9px 0 }
  .open-book { margin-top: 10px; padding: 6px 13px }
  .photo-side { padding-block: 10px }
}
@media (max-width: 650px) {
  .bar { width: 90%; min-height: 55px }
  .brand { font-size: 1.08rem; gap: 6px }
  .brand .icon { width: 22px; height: 22px }
  .directory { gap: 5px; font-size: .81rem }
  .directory label .icon { display: none }
  select { padding-left: 7px }
  main { min-height: calc(100svh - 56px); padding: 19px 0 16px }
  .reader { width: min(90%, 435px); --book-height: clamp(355px, calc(100svh - 160px), 650px) }
  .cover-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 22px 7% 21px 13% }
  .cover-type { align-self: center; text-align: center; flex: none }
  .cover-type .small-caps { font-size: .68rem }
  .cover-type .small-caps::before { display: none }
  h1 { margin: 6px 0; font-size: clamp(1.75rem, 8vw, 2.8rem); line-height: 1.3; letter-spacing: 0 }
  h1 span { display: inline; font-size: 1em; letter-spacing: 0 }
  .dates { font-size: .79rem }
  .cover-photo { flex: 0 1 auto; align-self: center; height: 48%; max-height: 304px; margin: 24px 0 18px; padding: 6px 6px 0; transform: rotate(4deg) }
  .cover-photo figcaption { padding-block: 5px; font-size: .88rem }
  .open-book { align-self: center; flex: none; margin: 0; padding: 9px 16px }
  #photo-page { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); padding: 17px 13px 13px 19px; background: linear-gradient(90deg,#c3b6a2,#f9f5e9 3%,#fbf8ee 96%,#ece4d6) }
  .month-side, .photo-side { background: transparent }
  .month-copy { display: flex; align-items: baseline; gap: 7px; padding: 0 2px 8px; text-align: left }
  #year { font-size: .82rem; letter-spacing: .06em }
  #month-name { font-size: 1.6rem; margin: 0 }
  #month-en, .dash { display: none }
  #month-position { margin-left: auto; font-size: .75rem; white-space: nowrap }
  .photo-side { padding: 4px 1px 0 }
  .photo-mat img { border-width: 5px }
  #caption { font-size: .98rem; margin-top: 9px }
  .controls { margin-top: 24px; gap: 10px }
  .turn { padding: 8px 12px }
}
@media (max-width: 365px) {
  .directory label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%) }
  .reader { width: 91% }
  #month-name { font-size: 1.27rem }
  .page-info { font-size: .76rem }
}
