.reader-body {
  margin: 0;
  min-height: 100dvh;
  color: #f3e9d7;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  background:
    radial-gradient(ellipse 70% 45% at 50% 28%, rgba(232, 176, 90, 0.12), transparent 58%),
    radial-gradient(ellipse 90% 70% at 50% 110%, #1a0c2c, #07040f 62%);
  overflow-x: hidden;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .7rem;
  padding-top: max(.55rem, env(safe-area-inset-top));
  background: rgba(8, 5, 16, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 164, 90, .25);
}
.reader-bar .back {
  color: #d4a45a; text-decoration: none; font-size: 1.25rem;
  padding: .35rem .55rem; min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.titles { display: grid; line-height: 1.15; min-width: 0; flex: 1; }
.titles strong {
  font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.titles span { font-size: .68rem; color: #b9a88c; }
.controls {
  margin-left: auto; display: flex; align-items: center; gap: .3rem;
  flex-wrap: nowrap; justify-content: flex-end;
}
.controls button {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(212,164,90,.3);
  background: #140a24; color: #f3e9d7; cursor: pointer; font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.controls button:active { border-color: #d4a45a; background: #1d1030; }
#page-ind {
  font-size: .78rem; min-width: 4.2rem; text-align: center; color: #cbb894;
  white-space: nowrap;
}

.reader-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 0;
  align-items: stretch;
  min-height: calc(100dvh - 56px);
}

.stage {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.35rem 0.9rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.book-shell {
  position: relative;
  margin: 0 auto;
  filter: drop-shadow(0 24px 36px rgba(0, 0, 0, .55));
  transition: transform 0.15s ease;
  will-change: transform;
  max-width: 100%;
}
.book-shell::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -28px;
  height: 28px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .45), transparent 72%);
  pointer-events: none;
}

#book { margin: 0 auto; max-width: 100%; }
.stf__parent { margin: 0 auto !important; max-width: 100%; }

.leaf { background: #f4ead8; overflow: hidden; }
.leaf canvas { width: 100% !important; height: 100% !important; display: block; }
.leaf[data-density="hard"] { background: #0e0816; }
.leaf-blank {
  background:
    linear-gradient(90deg, rgba(80, 50, 20, .06), transparent 10%),
    #f4ead8;
}

.hint {
  margin: 1.2rem .75rem 0;
  color: #9a8668;
  font-size: .74rem;
  letter-spacing: .04em;
  text-align: center;
  line-height: 1.4;
}

.wm {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  mix-blend-mode: soft-light;
  opacity: .32;
  z-index: 6;
}
.wm span {
  position: absolute;
  white-space: nowrap;
  color: rgba(255, 230, 180, .5);
  font-size: 12px;
  letter-spacing: .08em;
  transform: rotate(-28deg);
  font-family: "Outfit", system-ui, sans-serif;
}

.reader-foot {
  text-align: center;
  color: #8e7d63;
  font-size: .7rem;
  padding: 0 1rem max(1rem, env(safe-area-inset-bottom));
}
.reader-foot a { color: #d4a45a; text-decoration: none; }
.reader-foot a:hover { color: #f0c57a; }

.shield {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(5, 3, 12, .92);
  color: #f0c57a;
  font-size: 1.05rem;
  letter-spacing: .04em;
  padding: 1.5rem;
  text-align: center;
}
.shield[hidden] { display: none !important; }

.side-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 28;
  border: 0;
  background: rgba(0,0,0,.45);
  padding: 0;
  cursor: pointer;
}
.side-backdrop[hidden] { display: none !important; }

.side-panel {
  background: rgba(10, 6, 20, .96);
  border-left: 1px solid rgba(212,164,90,.22);
  padding: 1rem .95rem max(1.4rem, env(safe-area-inset-bottom));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  backdrop-filter: blur(10px);
  transition: transform .22s ease;
}
.side-block { margin-bottom: 1.25rem; }
.side-block h3 {
  margin: 0 0 .55rem;
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #d4a45a;
  font-weight: 500;
}
.jump-form { display: flex; gap: .4rem; }
.jump-form input {
  flex: 1; height: 44px; border-radius: 10px;
  border: 1px solid rgba(212,164,90,.35);
  background: #140a24; color: #f3e9d7;
  padding: 0 .7rem; font: inherit; font-size: 16px; /* 16px avoids iOS zoom */
}
.btn-side {
  border-radius: 10px; border: 1px solid rgba(212,164,90,.4);
  background: linear-gradient(135deg, #c8923f, #e0b56a);
  color: #1a1005; font: inherit; font-size: .9rem; font-weight: 500;
  padding: 0 .9rem; height: 44px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-side.wide { width: 100%; margin-top: .55rem; }
.btn-side:active { filter: brightness(1.05); }

.meta {
  display: flex; justify-content: space-between; gap: .5rem;
  margin: 0 0 .35rem; font-size: .85rem; color: #b9a88c;
}
.meta strong { color: #f3e9d7; font-weight: 500; }
.progress {
  height: 6px; border-radius: 99px; background: #1a1028;
  overflow: hidden; margin-top: .45rem;
}
.progress i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #c8923f, #f0c57a);
  border-radius: 99px; transition: width .2s ease;
}

.index-list { display: grid; gap: .15rem; }
.index-list button {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: .5rem; width: 100%; text-align: left;
  border: 0; background: transparent; color: #e8dcc6;
  padding: .55rem .5rem; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: .9rem; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.index-list button:active, .index-list button.active {
  background: rgba(212,164,90,.14); color: #f0c57a;
}
.index-list button span { color: #9a8668; font-size: .75rem; }

.side-toggle { display: none; }

@media (max-width: 980px) {
  .reader-layout { grid-template-columns: 1fr; min-height: calc(100dvh - 56px); }
  .side-toggle { display: inline-flex !important; }
  .side-backdrop:not([hidden]) { display: block; }
  .side-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(320px, 88vw);
    z-index: 35;
    transform: translateX(105%);
    box-shadow: -12px 0 40px rgba(0,0,0,.5);
    padding-top: max(4.2rem, calc(env(safe-area-inset-top) + 3.4rem));
  }
  .side-panel.open { transform: translateX(0); }
  .titles span { display: none; }
  .hint { font-size: .7rem; margin-top: .9rem; }
  .reader-foot { display: none; }
  .stage {
    min-height: calc(100dvh - 56px);
    padding: .35rem .2rem .6rem;
    justify-content: flex-start;
    padding-top: .6rem;
  }
  .book-shell::after { bottom: -18px; height: 18px; }
  #page-ind { min-width: 3.6rem; font-size: .72rem; }
  .controls button { width: 38px; height: 38px; }
}

@media (max-width: 420px) {
  .controls #zoom-out,
  .controls #zoom-in { display: none; }
  .reader-bar { gap: .25rem; padding-left: .4rem; padding-right: .4rem; }
}

@media print {
  body * { display: none !important; }
}
