:root {
  color-scheme: dark;
  --surface-default: #efe7d8;
  --surface-deep: #e2d5c0;
  --text-primary: #241d18;
  --text-secondary: #75695e;
  --surface-inverse: #1b1011;
  --book-color: #4a171c;
  --book-foil: #c6a56b;
  --line: rgba(53, 39, 29, .17);
  --serif: "Gowun Batang", "Noto Serif KR", serif;
  --sans: "Noto Sans KR", sans-serif;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --page-pad-outer: clamp(28px, 4.2vh, 48px);
  --page-pad-inner: clamp(32px, 4.8vh, 56px);
  --page-pad-top: clamp(30px, 5vh, 54px);
  --page-pad-bottom: clamp(34px, 5.4vh, 60px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--surface-inverse);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: #f6eddf;
  background:
    radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--book-color), transparent 30%), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--book-color), #211217 52%), #0d090a 76%);
  font-family: var(--sans);
  font-kerning: normal;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--book-foil);
  outline-offset: 4px;
}

.reader-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 62px;
  padding: 0 clamp(18px, 3vw, 46px);
  background: linear-gradient(180deg, rgba(13, 7, 8, .72), transparent);
  pointer-events: none;
}

.reader-header > * {
  pointer-events: auto;
}

.reader-header__link {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  gap: 10px;
  color: inherit;
  font-size: 11px;
  letter-spacing: .08em;
  text-decoration: none;
}

.reader-header__brand,
.reader-header__volume {
  margin: 0;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.reader-header__brand {
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .08em;
}

.reader-header__volume {
  justify-self: end;
  color: rgba(246, 237, 223, .62);
}

.reader-main {
  position: fixed;
  inset: 0;
}

.reader-status {
  position: fixed;
  top: 66px;
  left: 50%;
  z-index: 22;
  margin: 0;
  color: rgba(246, 237, 223, .64);
  font-size: 9px;
  letter-spacing: .18em;
  transform: translateX(-50%);
}

.book-stage {
  position: absolute;
  inset: 78px 0 100px;
  display: grid;
  padding: 18px clamp(54px, 5vw, 82px);
  cursor: grab;
  touch-action: pan-y;
  place-items: center;
  perspective: 1800px;
}

.physical-book {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(84vw, calc((100dvh - 214px) * 1.48), 1050px);
  height: auto;
  aspect-ratio: 1.48 / 1;
  transform: translateZ(0);
}

.physical-book.is-page-turning {
  cursor: grabbing;
}

.physical-book::before {
  position: absolute;
  inset: -12px -16px -18px;
  z-index: -2;
  border-radius: 3px 10px 10px 3px;
  background: color-mix(in srgb, var(--book-color), #1b0c0f 24%);
  box-shadow:
    0 38px 44px rgba(0, 0, 0, .38),
    inset 0 0 0 1px color-mix(in srgb, var(--book-foil), transparent 65%);
  content: "";
}

.physical-book::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 14;
  width: 30px;
  background: linear-gradient(90deg, rgba(45, 30, 21, .24), rgba(255, 255, 255, .17) 47%, rgba(45, 30, 21, .2));
  content: "";
  pointer-events: none;
  transform: translateX(-50%);
}

.reader-page {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  color: var(--text-primary);
  background:
    repeating-linear-gradient(88deg, rgba(70, 48, 34, .018) 0 1px, transparent 1px 5px),
    var(--surface-default);
  contain: layout paint style;
  transform-style: preserve-3d;
}

.reader-page--left {
  border-radius: 2px 0 0 3px;
  box-shadow: inset -26px 0 34px rgba(80, 57, 39, .1);
  transform-origin: right center;
}

.reader-page--right {
  border-radius: 0 3px 3px 0;
  box-shadow: inset 26px 0 34px rgba(80, 57, 39, .09);
  transform-origin: left center;
}

.page-turn-underlay,
.page-turn-sheet {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  pointer-events: none;
}

.page-turn-underlay {
  z-index: 3;
}

.page-turn-underlay::before {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(42, 25, 18, var(--turn-shadow, .22));
  content: "";
  pointer-events: none;
}

.page-turn-underlay--left {
  left: 0;
}

.page-turn-underlay--right {
  right: 0;
}

.page-turn-sheet {
  z-index: 11;
  will-change: transform;
  transform-style: preserve-3d;
}

.page-turn-sheet--next {
  left: 50%;
  transform-origin: left center;
}

.page-turn-sheet--previous {
  left: 0;
  transform-origin: right center;
}

.page-turn-face--front,
.page-turn-face--back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  pointer-events: none;
  transform-box: border-box;
  transform-origin: center center;
  transform-style: preserve-3d;
}

.page-turn-face--front {
  transform: rotateY(0deg) translateZ(.1px);
}

.page-turn-face--back {
  transform: rotateY(180deg) translateZ(.1px);
}

.page-turn-face--front::before,
.page-turn-face--back::before {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: linear-gradient(90deg, rgba(255, 250, 238, .18), rgba(54, 34, 23, .52));
  content: "";
  opacity: var(--turn-light, .08);
  pointer-events: none;
}

.page-turn-sheet--previous .page-turn-face--front::before,
.page-turn-sheet--previous .page-turn-face--back::before {
  background: linear-gradient(90deg, rgba(54, 34, 23, .52), rgba(255, 250, 238, .18));
}

.page-inner {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
  padding-block: var(--page-pad-top) var(--page-pad-bottom);
}

.reader-page--left .page-inner {
  padding-right: var(--page-pad-inner);
  padding-left: var(--page-pad-outer);
}

.reader-page--right .page-inner {
  padding-right: var(--page-pad-outer);
  padding-left: var(--page-pad-inner);
}

.page-folio {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  min-height: 25px;
  margin-bottom: clamp(18px, 3vh, 30px);
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
  color: var(--text-secondary);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.page-body {
  min-height: 0;
  overflow: hidden;
}

.page-body h1,
.page-body h2,
.page-body h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.28;
  text-wrap: balance;
}

.page-body h1 {
  font-size: clamp(2rem, 3.8vw, 4.7rem);
}

.page-body h2 {
  margin-bottom: 1.1em;
  color: color-mix(in srgb, var(--book-color), #2b211b 25%);
  font-size: clamp(1.45rem, 2.25vw, 2.45rem);
  line-height: 1.34;
}

.page-body p,
.page-body blockquote,
.page-body figcaption {
  text-wrap: pretty;
}

.page-body p {
  margin: 0 0 1.15em;
  font-family: var(--serif);
  font-size: clamp(.88rem, .96vw, 1.02rem);
  line-height: 1.88;
  line-break: strict;
  text-align: justify;
  text-align-last: left;
  text-justify: inter-character;
}

.page-body p[data-continuation="true"]::before {
  color: var(--text-secondary);
  content: "… ";
}

.page-body blockquote {
  display: grid;
  width: min(100%, 19em);
  min-height: 42%;
  margin: 0 auto;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: color-mix(in srgb, var(--book-color), #2b211b 14%);
  font-family: var(--serif);
  font-size: clamp(1.25rem, 1.9vw, 2rem);
  letter-spacing: -.012em;
  line-break: strict;
  line-height: 1.68;
  text-align: left;
  text-wrap: pretty;
  place-items: center start;
}

.essay-image {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  margin: 0;
  gap: 12px;
  place-items: center;
}

.essay-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.essay-image--placeholder {
  min-height: 0;
}

.essay-image__placeholder {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: rgba(70, 48, 34, .035);
}

.essay-image figcaption {
  color: var(--text-secondary);
  font-size: 9px;
  line-height: 1.55;
  text-align: center;
}

.page--cover {
  color: #f7ecdd;
  background-color: var(--book-color);
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, .22), transparent 13%, transparent 88%, rgba(255, 255, 255, .06)),
    var(--cover-image);
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
  background-size: 100% 100%, contain;
}

.page--cover::after {
  position: absolute;
  inset: 18px;
  border: 1px solid color-mix(in srgb, var(--book-foil), transparent 42%);
  content: "";
  pointer-events: none;
}

.cover-copy {
  position: absolute;
  right: 10%;
  bottom: 9%;
  left: 10%;
  display: grid;
  gap: 12px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, .38);
}

.cover-copy span {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .2em;
}

.cover-copy strong {
  max-width: 14ch;
  font-family: var(--serif);
  font-size: clamp(1.75rem, 5vh, 3.4rem);
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1.3;
  text-wrap: balance;
}

.title-page .page-body {
  display: grid;
  align-content: safe center;
  gap: clamp(var(--space-lg), 2.5vh, var(--space-xl));
}

.title-page .page-body h1 {
  max-width: 13.5ch;
  margin: 0;
  font-size: clamp(1.9rem, 4.5vh, 3.8rem);
  letter-spacing: -.025em;
  line-height: 1.34;
}

.title-deck {
  max-width: 38ch;
  margin: 0;
  color: var(--text-secondary);
  font-family: var(--serif);
  font-size: clamp(.9rem, 1.9vh, 1.05rem);
  line-height: 1.82;
}

.title-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin: clamp(0px, .7vh, var(--space-sm)) 0 0;
  color: color-mix(in srgb, var(--book-color), #2b211b 26%);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .13em;
}

.end-page .page-body {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.end-page .page-inner {
  padding: 0;
}

.end-page .page-folio {
  display: none;
}

.end-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.end-links {
  position: absolute;
  right: clamp(16px, 4vw, 34px);
  bottom: clamp(16px, 4vh, 34px);
  left: clamp(16px, 4vw, 34px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.end-link {
  display: inline-flex;
  min-width: 112px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 999px;
  color: #fff;
  background: rgba(18, 18, 18, .78);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .2em;
  text-decoration: none;
  backdrop-filter: blur(7px);
}

.end-link:hover {
  background: rgba(18, 18, 18, .94);
}

.end-link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.blank-page {
  background: var(--surface-deep);
}

.page-controls {
  position: fixed;
  top: 50%;
  right: clamp(10px, 2vw, 30px);
  left: clamp(10px, 2vw, 30px);
  z-index: 24;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  transform: translateY(-50%);
}

.page-button {
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(246, 237, 223, .48);
  border-radius: 50%;
  color: #f6eddf;
  background: rgba(23, 10, 12, .48);
  cursor: pointer;
  pointer-events: auto;
  place-items: center;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease;
}

.page-button:hover:not(:disabled) {
  color: #1c0d10;
  background: #f6eddf;
  transform: scale(1.05);
}

.page-button:disabled {
  opacity: .18;
  cursor: default;
}

.reader-hint {
  position: fixed;
  right: 0;
  bottom: 87px;
  left: 0;
  z-index: 15;
  margin: 0;
  color: rgba(246, 237, 223, .46);
  font-size: 9px;
  letter-spacing: .08em;
  text-align: center;
}

.mobile-hint {
  display: none;
}

.audio-player {
  position: fixed;
  right: clamp(14px, 3vw, 46px);
  bottom: calc(14px + var(--safe-bottom));
  left: clamp(14px, 3vw, 46px);
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(150px, .75fr) minmax(180px, 1.4fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  padding: 9px 18px 9px 10px;
  color: #f6eddf;
  background: rgba(24, 11, 12, .95);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .3);
}

.audio-player[hidden] {
  display: none;
}

.audio-button {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(246, 237, 223, .5);
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  place-items: center;
  transition: transform 180ms ease, background 180ms ease;
}

.audio-button:hover {
  color: #1c0d10;
  background: #f6eddf;
  transform: scale(1.04);
}

.audio-title {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.audio-title strong {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-title span,
.audio-time,
.audio-part {
  color: rgba(246, 237, 223, .58);
  font-size: 9px;
  letter-spacing: .1em;
}

.audio-progress {
  width: 100%;
  min-height: 24px;
  accent-color: var(--book-foil);
  cursor: pointer;
}

.audio-progress:disabled {
  opacity: .45;
  cursor: wait;
}

.audio-time {
  min-width: 82px;
  text-align: right;
}

.audio-part {
  min-width: 40px;
  padding-left: 13px;
  border-left: 1px solid rgba(246, 237, 223, .2);
}

.loading-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  background: #170d0f;
  transition: opacity 360ms ease;
}

.loading-panel[hidden] {
  display: none;
}

.loading-panel p {
  margin: 0;
  color: rgba(246, 237, 223, .68);
  font-family: var(--serif);
  font-size: 13px;
}

.loading-mark {
  width: 36px;
  height: 48px;
  border: 1px solid var(--book-foil);
  border-left-width: 4px;
  animation: loading-book 1.1s ease-in-out infinite alternate;
}

@keyframes loading-book {
  to { transform: perspective(160px) rotateY(-22deg); }
}

.is-ready .loading-panel {
  opacity: 0;
  pointer-events: none;
}

.is-error .loading-panel {
  padding: 28px;
  text-align: center;
}

.is-error .loading-mark {
  animation: none;
}

.pagination-lab {
  position: fixed;
  top: 0;
  left: -200vw;
  z-index: -1;
  overflow: hidden;
  color: var(--text-primary);
  background: var(--surface-default);
  visibility: hidden;
  pointer-events: none;
}

[data-reader-audit-select] {
  position: fixed;
  inline-size: 1px;
  block-size: 1px;
  inset: 0 auto auto 0;
  opacity: 0.001;
  pointer-events: none;
}

.pagination-surface {
  width: 100%;
  height: 100%;
}

noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  padding: 40px;
  color: #f6eddf;
  background: #170d0f;
  place-items: center;
}

@media (max-width: 900px) {
  .book-stage {
    padding-right: 42px;
    padding-left: 42px;
  }

  .physical-book {
    width: min(90vw, calc((100dvh - 214px) * 1.48), 960px);
  }
}

@media (max-width: 720px) {
  .reader-header {
    min-height: 54px;
    padding: 0 15px;
  }

  .reader-header__brand {
    display: none;
  }

  .reader-header__volume {
    grid-column: 3;
  }

  .reader-status {
    top: 58px;
  }

  .book-stage {
    inset: 57px 0 83px;
    padding: 26px 12px 30px;
  }

  .physical-book {
    grid-template-columns: 1fr;
    width: min(91vw, calc((100dvh - 170px) * .74), 520px);
    height: auto;
    aspect-ratio: .74 / 1;
  }

  .physical-book::before {
    inset: -9px -10px -12px;
  }

  .physical-book::after,
  .reader-page--left {
    display: none;
  }

  .page-turn-underlay,
  .page-turn-sheet {
    right: auto;
    left: 0;
    width: 100%;
  }

  .page-turn-sheet--next {
    transform-origin: left center;
  }

  .page-turn-sheet--previous {
    transform-origin: right center;
  }

  .reader-page--right {
    border-radius: 2px 5px 5px 2px;
    box-shadow: inset 18px 0 30px rgba(80, 57, 39, .1);
  }

  .page-inner {
    padding: 32px 28px 48px;
  }

  .page-folio {
    margin-bottom: 22px;
  }

  .page-body h1 {
    font-size: clamp(2rem, 9.2vw, 3.35rem);
    line-height: 1.32;
  }

  .page-body h2 {
    font-size: clamp(1.5rem, 7vw, 2.4rem);
  }

  .page-body p {
    font-size: clamp(.92rem, 4vw, 1.02rem);
    line-height: 1.84;
  }

  .title-page .page-body {
    gap: clamp(14px, 2.2vh, 20px);
  }

  .title-page .page-body h1 {
    font-size: clamp(1.75rem, 8.4vw, 2.7rem);
    line-height: 1.28;
  }

  .title-deck {
    font-size: clamp(.82rem, 3.7vw, .95rem);
    line-height: 1.68;
  }

  .title-meta {
    gap: 6px 12px;
    font-size: 8px;
  }

  .page-controls {
    right: 3px;
    left: 3px;
  }

  .page-button {
    width: 44px;
    height: 44px;
    color: #1c0d10;
    background: rgba(246, 237, 223, .9);
  }

  .reader-hint {
    bottom: 74px;
  }

  .desktop-hint {
    display: none;
  }

  .mobile-hint {
    display: inline;
  }

  .audio-player {
    right: 9px;
    bottom: calc(8px + var(--safe-bottom));
    left: 9px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 9px;
    min-height: 60px;
    padding: 7px 10px 7px 7px;
  }

  .audio-progress {
    grid-column: 2 / 4;
    height: 10px;
  }

  .audio-time,
  .audio-part,
  .audio-title span {
    display: none;
  }

  .audio-title strong {
    font-size: 12px;
  }
}

@media (max-height: 760px) and (min-width: 721px) {
  .title-page .page-body h1 {
    font-size: clamp(1.5rem, 4.4vh, 3.2rem);
    line-height: 1.32;
  }

  .title-deck {
    font-size: clamp(.78rem, 1.85vh, .98rem);
    line-height: 1.7;
  }

  .title-meta {
    margin-top: 0;
  }
}

@media (max-height: 640px) and (min-width: 721px) {
  .book-stage {
    inset: 66px 0 86px;
  }

  .physical-book {
    width: min(84vw, calc((100dvh - 182px) * 1.48), 1050px);
    height: auto;
  }

  .page-inner {
    padding-top: 30px;
    padding-bottom: 38px;
  }
}

@media (max-height: 500px) and (min-width: 721px) and (orientation: landscape) {
  .reader-header { min-height: 50px; }

  .reader-status { top: 53px; }

  .book-stage {
    inset: 53px 0 72px;
    padding-block: 8px 10px;
  }

  .physical-book {
    width: min(88vw, calc((100dvh - 135px) * 1.48), 1050px);
  }

  .page-inner {
    padding-top: 14px;
    padding-bottom: 16px;
  }

  .page-folio {
    min-height: 16px;
    margin-bottom: 8px;
    padding-bottom: 5px;
    font-size: 7px;
  }

  .page-body p {
    margin-bottom: .72em;
    font-size: clamp(.7rem, 1.25vw, .82rem);
    line-height: 1.58;
  }

  .page-body h2 {
    margin-bottom: .65em;
    font-size: clamp(1rem, 2.2vw, 1.35rem);
  }

  .page-body blockquote {
    min-height: 0;
    padding-block: 10px;
    font-size: clamp(.92rem, 1.75vw, 1.18rem);
    line-height: 1.45;
  }

  .essay-image {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .essay-image img,
  .essay-image__placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
  }

  .essay-image figcaption {
    position: absolute;
    right: 8px;
    bottom: 6px;
    left: 8px;
    z-index: 1;
    padding: 3px 6px;
    color: var(--text-primary);
    background: color-mix(in srgb, var(--surface-default), transparent 12%);
  }

  .reader-hint { bottom: 58px; }

  .audio-player {
    min-height: 52px;
    padding-block: 5px;
  }
}

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