:root {
  color-scheme: light;
  --paper: #fff;
  --site-background: #f6f2e9;
  --ink: #221e1d;
  --muted: #625a59;
  --rule: #e5dfda;
  --red: #a80e35;
  --bright-red: #da3156;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--site-background); color: var(--ink); font: 1rem/1.5 var(--sans); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--bright-red); outline-offset: 4px; }

.masthead { background: var(--site-background); border-bottom: 1px solid var(--rule); }
.masthead-inner, main { width: min(calc(100% - 5rem), 88rem); margin-inline: auto; }
.masthead-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 4.65rem;
  gap: 1rem;
}
.wordmark { mix-blend-mode: multiply; display: inline-flex; padding-block: .3rem; }
.wordmark img { display: block; width: 10.75rem; height: auto; }
.site-actions, .reading-tools { display: flex; align-items: center; gap: .4rem; }
.quiet, .accent {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: .25rem;
  padding: .45rem .75rem;
  color: var(--ink);
  background: transparent;
  text-decoration: none;
  font-size: .89rem;
  font-weight: 600;
  white-space: nowrap;
}
.quiet:hover:not(:disabled) { background: #ded7d24d; color: var(--red); }
.quiet:disabled { opacity: .45; }
.accent { background: var(--red); color: white; padding-inline: .9rem; }
.accent:hover:not(:disabled) { background: #870a2a; }
.accent:disabled { opacity: .65; }

.edition-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem 1.75rem;
  padding-block: 1.4rem 1.2rem;
}
.edition-meta {
  margin: 0 0 .15rem;
  color: var(--red);
  font-size: .84rem;
  font-weight: 650;
  letter-spacing: .04em;
}
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -.037em; }
h1 { margin: 0; font-size: clamp(2rem, 2.8vw, 3.2rem); line-height: 1.1; overflow-wrap: anywhere; }
.reading-tools { flex-wrap: wrap; padding-bottom: .06rem; }
.reading-tools .quiet + .quiet { border-left: 1px solid var(--rule); border-radius: 0; }
.page-navigation { display: flex; gap: .27rem; margin-inline-end: .35rem; }
.download { font-variant-numeric: tabular-nums; }

.reader {
  color: var(--ink);
  margin-bottom: 1.5rem;
}
.reading-area {
  position: relative;
  height: clamp(23rem, calc(100svh - 16.3rem), 53rem);
  overflow: hidden;
  isolation: isolate;
  touch-action: pan-y pinch-zoom;
  scrollbar-color: #ae9297 #faf5f5;
}
.reading-area.is-zoomed { overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.reading-area.is-draggable .paper { cursor: grab; }
.reading-area.is-dragging, .reading-area.is-dragging .paper { cursor: grabbing; }
.desk {
  display: grid;
  place-items: center;
  width: max(100%, var(--desk-width, 0px));
  height: max(100%, var(--desk-height, 0px));
  user-select: none;
}
.book { position: relative; }
.scene { position: absolute; inset: 0; }
.paper {
  position: absolute;
  inset-block: 0;
  width: var(--sheet-width);
  margin: 0;
  background: #fff;
  overflow: hidden;
}
.paper > img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.left { left: 0; }
.right { left: var(--sheet-width); }
.paper.left { box-shadow: -4px 6px 16px rgb(45 24 23 / calc(.157 * var(--paper-shadow-strength, 1))), 0 1px 4px rgb(45 24 23 / calc(.102 * var(--paper-shadow-strength, 1))); }
.paper.right, .paper.single { box-shadow: 4px 6px 16px rgb(45 24 23 / calc(.157 * var(--paper-shadow-strength, 1))), 0 1px 4px rgb(45 24 23 / calc(.102 * var(--paper-shadow-strength, 1))); }
.spine-shadow {
  position: absolute;
  inset-block: 0;
  left: var(--sheet-width);
  width: min(54px, calc(var(--sheet-width) * .115));
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, #382d2d0b 30%, #382d2d28 49%, #382d2d1c 56%, transparent);
}
.page-curl {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}
.reader-message {
  position: absolute;
  margin: 0;
  left: 50%;
  top: 50%;
  max-width: calc(100% - 2rem);
  width: max-content;
  text-align: center;
  padding: .65rem 1rem;
  border-radius: .35rem;
  background: var(--site-background);
  border: 1px solid var(--rule);
  box-shadow: 0 6px 20px #2d181719;
  transform: translate(-50%, -50%);
  z-index: 3;
  pointer-events: none;
}
.reader-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: min(100%, 40rem);
  min-height: 2.75rem;
  gap: 1.15rem;
  margin-inline: auto;
  padding-inline: .6rem;
}
.page-control {
  display: grid;
  place-items: center;
  width: 2.65rem;
  min-height: 2.75rem;
  border-radius: .22rem;
  border: 1px solid var(--rule);
  background: var(--site-background);
  color: var(--red);
  font-size: 1.65rem;
  line-height: 1;
  padding: 0 0 .14rem;
}
.page-control:hover:not(:disabled) { background: #fff4f6; border-color: #b93655; color: var(--red); }
.page-control:disabled { opacity: .36; }
@property --slider-position {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 0%;
}
.page-slider-field {
  position: relative;
  --slider-position: 0%;
  transition: --slider-position 200ms cubic-bezier(.22, .7, .26, 1);
}
.page-slider-rail::before,
.page-slider-rail::after {
  content: '';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.page-slider-rail { position: absolute; inset: 0 .5rem; pointer-events: none; }
.page-slider-rail::before {
  inset-inline: 0;
  height: 2px;
  border-radius: 1px;
  background: linear-gradient(to right, var(--red) 0 var(--slider-position), var(--rule) var(--slider-position) 100%);
}
.page-slider-rail::after {
  left: var(--slider-position);
  width: 1rem;
  height: 1rem;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}
.page-slider {
  position: relative;
  appearance: none;
  display: block;
  width: 100%;
  height: 2.75rem;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.page-slider::-webkit-slider-runnable-track { height: 2px; background: transparent; }
.page-slider::-moz-range-track { height: 2px; background: transparent; }
.page-slider::-webkit-slider-thumb {
  appearance: none;
  width: 1rem;
  height: 1rem;
  margin-top: -.4375rem;
  opacity: 0;
}
.page-slider::-moz-range-thumb {
  box-sizing: border-box;
  width: 1rem;
  height: 1rem;
  opacity: 0;
}
.page-slider-field:has(.page-slider:disabled) { opacity: .4; }
.page-slider:disabled { cursor: default; }
.folio { min-width: 5.2em; text-align: end; color: var(--muted); font-size: .87rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.noscript { margin: 0; padding-bottom: 1rem; }

.panel {
  width: min(calc(100% - 2rem), 42rem);
  max-height: min(85dvh, 45rem);
  border: 1px solid var(--rule);
  border-radius: .37rem;
  background: var(--site-background);
  color: var(--ink);
  padding: 0 1.5rem 1.5rem;
  box-shadow: 0 30px 100px #170f1466;
}
.panel::backdrop { background: #1a1319b3; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--site-background);
  padding-block: .85rem;
}
h2 { margin: 0; font-size: 2rem; line-height: 1.05; }
#archive { width: min(calc(100% - 2rem), 21rem); }
.edition-list { display: grid; gap: .7rem; }
.archive-actions { display: flex; justify-content: flex-end; }
.archive-actions:has(button:not([hidden])) { margin-top: .9rem; }
.edition-card {
  display: grid;
  justify-items: center;
  gap: 1rem;
  width: 100%;
  background: var(--site-background);
  color: var(--ink);
  text-align: center;
  border: 1px solid var(--rule);
  border-radius: .25rem;
  padding: 1rem .75rem;
}
.edition-card:hover, .edition-card[aria-current='true'] { border-color: var(--red); }
.edition-cover {
  border-radius: .5rem;
  width: min(100%, 14rem, 43dvh);
  aspect-ratio: 7 / 9;
  background: #3d252b;
  display: grid;
  place-items: center;
  color: #fff;
  font: italic 1.2rem/1 var(--serif);
  overflow: hidden;
}
.edition-cover > * { grid-area: 1 / 1; }
.edition-cover img { width: 100%; height: 100%; object-fit: contain; }
.edition-name { display: block; font: 1.42rem/1.2 var(--serif); overflow-wrap: anywhere; }
.edition-info { margin-top: .25rem; display: block; color: var(--muted); font-size: .86rem; }
.contents { list-style: none; margin: 0 0 1.2rem; padding: 0; }
.contents:empty { display: none; }
.contents button {
  width: 100%;
  min-height: 2.75rem;
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: .5rem;
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: .4rem .15rem;
  text-align: left;
  color: var(--ink);
  line-height: 1.25;
}
.contents button:hover, .contents button[aria-current='page'] { color: var(--red); }
.contents button span:first-child { color: var(--red); font: 1.1rem/1 var(--serif); }
.thumbnails { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.25rem, 1fr)); gap: .7rem; }
.thumbnail {
  display: grid;
  gap: .22rem;
  padding: .3rem;
  background: var(--site-background);
  border: 1px solid var(--rule);
  border-radius: .18rem;
  color: var(--ink);
  font-size: .84rem;
  font-variant-numeric: tabular-nums;
}
.thumbnail:hover, .thumbnail[aria-current='page'] { border-color: var(--red); color: var(--red); }
.thumbnail img { width: 100%; aspect-ratio: var(--ratio, 7 / 9); object-fit: contain; background: #e9e4e0; }
.upload-panel { max-width: 29rem; }
.upload-panel form { display: grid; gap: .5rem; }
.upload-panel label { margin-top: .32rem; font-size: .9rem; font-weight: 650; }
.optional { font-weight: 400; color: var(--muted); }
.upload-panel input {
  width: 100%;
  border-radius: .2rem;
  padding: .58rem .65rem;
  border: 1px solid #cfc4c0;
  background: var(--site-background);
  color: var(--ink);
}
.upload-panel input::file-selector-button { font: inherit; margin-right: .6rem; }
.form-message { margin: .35rem 0 0; min-height: 1.5em; color: var(--red); font-size: .87rem; }
.upload-panel .accent { justify-self: start; }

@media (max-width: 650px) {
  .masthead-inner, main { width: calc(100% - 1.5rem); }
  .masthead-inner { min-height: 3.85rem; gap: .25rem; }
  .wordmark img { width: clamp(6.8rem, 29vw, 9rem); }
  .site-actions { gap: .15rem; }
  .site-actions button { padding-inline: .53rem; }
  .edition-heading { align-items: start; flex-direction: column; gap: .4rem; padding-block: .95rem .45rem; }
  .reading-tools .quiet { min-height: 2.5rem; }
  .reading-area { height: clamp(19rem, calc(100svh - 15.5rem), 40rem); }
  .reader-controls { gap: .85rem; }
  .page-control { width: 2.5rem; min-height: 2.55rem; }
  .panel { padding-inline: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
