:root {
  --book-desk: #d9d2c4;
  --book-desk-edge: #cfc6b5;
  --book-leaf: var(--paper);
  --book-leaf-shadow: drop-shadow(0 23px 55px rgb(64 53 39 / 20%)) drop-shadow(0 4px 12px rgb(64 53 39 / 13%));
  --book-flourish: #886b4c;
  --leaf-top: clamp(68px, 9vh, 88px);
  --leaf-bottom: clamp(48px, 7vh, 64px);
  --leaf-inset-x: clamp(38px, 5vw, 58px);
  --gutter-content: clamp(82px, 9vw, 112px);
}
:root[data-theme="night"] {
  --book-desk: #151a17;
  --book-desk-edge: #121612;
  --book-leaf-shadow: drop-shadow(0 23px 55px rgb(0 0 0 / 42%)) drop-shadow(0 4px 12px rgb(0 0 0 / 22%));
  --book-flourish: #c4a277;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { overflow: hidden; background: var(--book-desk); color: var(--ink); }
button, select { font: inherit; }

.book-app {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 86px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.book-header, .book-footer {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  color: var(--muted);
  transition: opacity .3s ease, transform .3s ease;
}
.book-header { justify-content: space-between; gap: 24px; padding: 0 clamp(20px, 4vw, 55px); }
.book-identity { display: flex; align-items: center; gap: 9px; color: var(--ink); font: 600 12px/1.2 system-ui, sans-serif; letter-spacing: .11em; text-transform: uppercase; white-space: nowrap; }
.book-glyph { color: var(--book-flourish); font: 29px/.7 Georgia, serif; letter-spacing: -.27em; transform: rotate(-13deg); margin-right: 7px; }
.book-contents { display: flex; align-items: center; gap: 10px; min-width: 0; }
.book-contents label, .book-time { font: 500 11px/1.2 system-ui, sans-serif; letter-spacing: .11em; text-transform: uppercase; white-space: nowrap; }
.book-contents select {
  max-width: min(300px, 32vw);
  min-width: 110px;
  padding: 8px 22px 8px 7px;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--ink), transparent 75%);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 500 13px/1.2 system-ui, sans-serif;
  text-overflow: ellipsis;
}

.book-main { position: relative; display: grid; min-height: 0; place-items: center; padding: 2px clamp(12px, 3vw, 42px); background: linear-gradient(155deg, var(--book-desk), var(--book-desk-edge)); }
.desk-grain { position: absolute; inset: 0; opacity: .14; pointer-events: none; background-image: repeating-linear-gradient(0deg, transparent 0 14px, rgb(74 58 41 / 9%) 15px 16px), repeating-linear-gradient(90deg, transparent 0 33px, rgb(255 255 255 / 12%) 34px 35px); }
.book-object {
  position: relative;
  width: min(100%, 1040px);
  height: min(100%, 670px);
  isolation: isolate;
  filter: var(--book-leaf-shadow);
  perspective: 900px;
}
.book-object::before, .book-object::after {
  position: absolute;
  z-index: -1;
  bottom: -4px;
  width: 49.6%;
  height: 100%;
  background: color-mix(in srgb, var(--book-leaf), #917c5d 8%);
  content: "";
}
.book-object::before { left: -3px; transform: rotate(-.25deg); }
.book-object::after { right: -3px; transform: rotate(.25deg); }
.leaf { position: absolute; top: 0; bottom: 0; width: 50%; background: var(--book-leaf); }
.leaf-left { left: 0; border-radius: 7px 0 0 7px; box-shadow: inset -24px 0 25px -24px rgb(66 48 29 / 22%), inset 2px 0 3px rgb(255 255 255 / 30%); }
.leaf-right { right: 0; border-radius: 0 7px 7px 0; box-shadow: inset 24px 0 25px -24px rgb(66 48 29 / 22%), inset -2px 0 3px rgb(255 255 255 / 30%); }
.book-spine { position: absolute; z-index: 3; top: 0; bottom: 0; left: calc(50% - 1px); width: 2px; background: linear-gradient(to right, rgb(77 59 37 / 23%), rgb(255 255 255 / 10%)); box-shadow: -8px 0 15px rgb(76 58 40 / 12%), 8px 0 15px rgb(76 58 40 / 10%); pointer-events: none; }
.book-window {
  position: absolute;
  z-index: 2;
  top: var(--leaf-top);
  right: var(--leaf-inset-x);
  bottom: var(--leaf-bottom);
  left: var(--leaf-inset-x);
  overflow: hidden;
  isolation: isolate;
}
.book-flow {
  width: var(--page-width, 350px) !important;
  height: var(--page-height, 470px) !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  column-width: var(--page-width, 350px);
  column-count: auto;
  column-gap: var(--column-gap, 100px);
  column-fill: auto;
  overflow: visible;
  transform: translate3d(var(--flow-offset, 0px), 0, 0);
  transition: transform .48s cubic-bezier(.23,.75,.23,1);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: calc(16.5px * var(--font-scale, 1));
  line-height: 1.62;
  overflow-wrap: break-word;
}
.book-flow h1, .book-flow h2, .book-flow h3 { break-after: avoid-column; }
.book-flow h1 { max-width: 13ch; margin-top: .15em; font-size: 2.1em; line-height: 1.11; }
.book-flow h2 { margin-top: 1.6em; font-size: 1.36em; line-height: 1.19; }
.book-flow .chapter-opening { break-inside: avoid-column; }
.book-flow .chapter-opening .section-kicker { break-after: avoid-column; }
.book-flow p { margin-bottom: 1em; }
.book-flow .article-intro { margin-bottom: 2em; }
.book-flow section + section { margin-top: 2.2em; }
.book-flow pre, .book-flow table { max-width: 100%; }
.book-flow pre { max-height: calc(var(--page-height, 470px) - 16px); overflow: auto; }
.book-flow table { display: block; overflow: auto; max-height: calc(var(--page-height, 470px) - 16px); font-size: .78em; }
.book-flow blockquote { border-color: var(--book-flourish); }
.book-flow.reflowing { transition: none; }

.leaf-head, .leaf-foot { position: absolute; z-index: 2; color: var(--muted); font: 600 9px/1.25 system-ui, sans-serif; letter-spacing: .16em; text-transform: uppercase; pointer-events: none; }
.leaf-head { top: calc(var(--leaf-top) / 2); overflow: hidden; max-width: 32%; white-space: nowrap; text-overflow: ellipsis; }
.leaf-head-left { left: var(--leaf-inset-x); }
.leaf-head-right { right: var(--leaf-inset-x); text-align: right; }
.leaf-foot { bottom: calc(var(--leaf-bottom) / 2); color: var(--book-flourish); font-family: Georgia, serif; font-size: 12px; font-weight: normal; letter-spacing: .02em; }
.leaf-foot-left { left: var(--leaf-inset-x); }
.leaf-foot-right { right: var(--leaf-inset-x); }
.book-object.is-last-page .leaf-head-right, .book-object.is-last-page .leaf-foot-right { opacity: 0; }

.book-footer { justify-content: space-between; gap: 20px; padding: 0 clamp(20px, 4vw, 55px); }
.turn-button { display: flex; align-items: center; gap: 10px; min-width: 99px; padding: 6px 10px; border: 0; color: var(--ink); background: transparent; font: 600 12px/1.2 system-ui, sans-serif; cursor: pointer; }
.turn-previous span:first-child, .turn-next span:last-child { font: 28px/.8 Georgia, serif; }
.turn-button:hover:not(:disabled) { color: var(--book-flourish); background: transparent; }
.turn-button:disabled { opacity: .35; }
.turn-next { justify-content: flex-end; }
.book-location { display: grid; justify-items: center; gap: 5px; flex: 1; max-width: 360px; min-width: 60px; text-align: center; }
.book-chapter { overflow: hidden; max-width: 100%; color: var(--ink); font: 600 11px/1.2 system-ui, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.book-status { font: 500 10px/1.2 system-ui, sans-serif; letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; }
.book-progress { width: 100%; height: 2px; margin-top: 5px; background: color-mix(in srgb, var(--ink), transparent 80%); }
.book-progress span { display: block; width: 0; height: 100%; background: var(--book-flourish); transition: width .35s ease; }

body.chrome-hidden .reader-chrome { opacity: 0; transform: translateY(5px); pointer-events: none; }
body.chrome-hidden .reader-chrome:focus-within { opacity: 1; transform: none; pointer-events: auto; }

@media (max-width: 760px) {
  :root { --leaf-top: 58px; --leaf-bottom: 43px; --leaf-inset-x: clamp(25px, 6vw, 42px); --gutter-content: 60px; }
  .book-app { grid-template-rows: 49px minmax(0, 1fr) 71px; }
  .book-header, .book-footer { padding-right: 15px; padding-left: 15px; }
  .book-identity { font-size: 11px; }
  .book-time, .book-contents label { display: none; }
  .book-contents select { max-width: 49vw; font-size: 12px; }
  .book-main { padding: 2px clamp(8px, 2.5vw, 30px); }
  .book-object { max-width: 620px; }
  .book-object::before { width: calc(100% + 4px); }
  .book-object::after, .leaf-right, .book-spine, .leaf-head-right, .leaf-foot-right { display: none; }
  .leaf-left { width: 100%; border-radius: 5px; box-shadow: inset 2px 0 4px rgb(255 255 255 / 24%); }
  .book-flow { font-size: calc(16px * var(--font-scale, 1)); line-height: 1.52; }
  .book-flow h1 { font-size: 2em; }
  .turn-button { min-width: 34px; padding: 4px; font-size: 11px; gap: 4px; }
  .turn-button span:last-child:not(:first-child) { display: none; }
  .turn-next span:last-child { display: inline !important; }
  .turn-next span:first-child { display: none; }
}

@media (max-width: 400px) {
  .book-identity > span:last-child { display: none; }
  .book-flow { font-size: calc(15px * var(--font-scale, 1)); }
  .book-footer { gap: 8px; }
}

@media (max-height: 540px) and (max-width: 760px) {
  .book-flow h1 { font-size: 1.7em; }
  .book-flow .article-intro { margin-bottom: 1em; }
}

@media (prefers-reduced-motion: reduce) {
  .book-flow, .book-progress span, .reader-chrome { transition: none; }
}
