.book {
  position: relative;
  width: min(92vw, 720px);
  min-height: min(129vw, 520px);
}

.book .stf__parent {
  width: 100%;
}

.book .stf__wrapper {
  filter: drop-shadow(0 28px 34px rgba(54, 26, 10, 0.22));
}

.book .stf__wrapper.--portrait {
  margin-left: auto;
}

.book .stf__block {
  overflow: visible;
}

.page {
  background: transparent;
}

.book-content-page,
.book-cover-page {
  width: 100%;
  height: 100%;
}

.page-face,
.cover-surface {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.page-face {
  border-radius: 4px 16px 16px 4px;
  background:
    linear-gradient(90deg, rgba(166, 130, 95, 0.1), rgba(255, 252, 245, 0) 11%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0)),
    var(--paper-front);
  box-shadow:
    inset -14px 0 14px rgba(110, 80, 57, 0.08),
    10px 0 18px rgba(88, 58, 34, 0.08);
}

.page-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(120, 82, 52, 0.12), transparent 15% 78%, rgba(79, 48, 27, 0.08)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 24%);
  pointer-events: none;
}

.page-content {
  position: relative;
  z-index: 1;
  height: 100%;
  padding: 42px 34px 34px 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.page-copy {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.page-header {
  margin: 0 0 12px;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
  line-height: 0.92;
  font-weight: 600;
}

.page-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 10px;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: thin;
  scrollbar-color: rgba(111, 79, 53, 0.5) transparent;
  -webkit-overflow-scrolling: touch;
}

.title-sheet {
  min-height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0 12px;
  box-sizing: border-box;
}

.title-sheet-mark {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  display: block;
  max-width: 100%;
  width: 100%;
  font-size: clamp(1.1rem, 1.45vw, 1.6rem);
  line-height: 0.95;
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}

.toc-layout {
  display: grid;
  gap: 14px;
}

.toc-group {
  display: grid;
  gap: 8px;
}

.toc-children {
  display: grid;
  gap: 6px;
  padding-left: 10px;
}

.toc-link {
  width: 100%;
  border: 0;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  background: rgba(122, 85, 54, 0.12);
  color: var(--ink-strong);
  touch-action: manipulation;
  transition:
    background 180ms ease,
    transform 180ms ease;
}

.toc-link:hover {
  background: rgba(122, 85, 54, 0.18);
  transform: translateX(2px);
}

.toc-section {
  padding: 11px 14px;
  font-weight: 600;
}

.toc-track {
  padding: 8px 12px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.listen-links {
  display: grid;
  gap: 10px;
}

.listen-link {
  display: block;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(122, 85, 54, 0.12);
  color: var(--ink-strong);
  text-decoration: none;
  touch-action: manipulation;
  transition:
    background 180ms ease,
    transform 180ms ease;
}

.listen-link:hover {
  background: rgba(122, 85, 54, 0.18);
  transform: translateX(2px);
}

.page-figure {
  margin: 0 0 18px;
}

.page-image {
  display: block;
  width: 100%;
  max-width: 209px;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 14px 28px rgba(64, 33, 15, 0.16);
}

.page-caption {
  margin: 12px auto 0;
  max-width: 240px;
  text-align: center;
  color: rgba(82, 57, 38, 0.86);
  font-size: 0.88rem;
  line-height: 1.45;
}

.page-scroll::-webkit-scrollbar {
  width: 7px;
}

.page-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(111, 79, 53, 0.45);
}

.page-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.page-body {
  margin: 0;
  white-space: pre-line;
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 0.98rem;
}

.page-number {
  align-self: flex-end;
  color: rgba(78, 56, 39, 0.62);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
}

.cover-surface {
  border-radius: 18px;
  background:
    linear-gradient(135deg, var(--cover-start), var(--cover-mid) 38%, var(--cover-end)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 40%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 238, 214, 0.16),
    inset 0 0 42px rgba(255, 249, 239, 0.06),
    0 26px 36px rgba(54, 26, 10, 0.28);
}

.cover-surface::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(253, 234, 206, 0.24);
  border-radius: 12px;
  pointer-events: none;
}

.cover-surface-front {
  display: grid;
  place-items: center;
}

.cover-surface-back {
  display: grid;
  place-items: center;
}

.cover-content {
  width: min(74%, 360px);
  text-align: center;
  color: #faeedf;
}

.cover-kicker {
  margin: 0 0 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  font-size: 0.7rem;
  opacity: 0.82;
}

.cover-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(2.2rem, 3vw, 3.6rem);
  line-height: 0.92;
  font-weight: 600;
}

.cover-subtitle {
  margin: 16px 0 0;
  font-size: 0.94rem;
  line-height: 1.6;
  opacity: 0.9;
}

.cover-author {
  margin: 26px 0 0;
  font-size: 0.82rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.86;
}

.cover-back-mark {
  color: rgba(250, 238, 223, 0.84);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.bookmark {
  position: relative;
  border: 0;
  width: 30px;
  height: 76px;
  margin-left: 30px;
  padding: 8px 5px 8px;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  color: #fff7ef;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 12px 24px rgba(58, 27, 12, 0.18);
  writing-mode: vertical-rl;
  text-orientation: upright;
  line-height: 1;
  transform: translateY(0);
  z-index: 1;
  pointer-events: auto;
  touch-action: manipulation;
  transition:
    transform 260ms ease,
    box-shadow 260ms ease,
    filter 260ms ease,
    opacity 260ms ease;
}

.bookmark:hover:not(:disabled),
.bookmark.is-active {
  transform: translateY(0);
  z-index: 4;
  box-shadow: 0 16px 32px rgba(58, 27, 12, 0.24);
  filter: saturate(1.08);
}

.bookmark:disabled {
  cursor: default;
  opacity: 0.72;
}

.settings-panel {
  display: grid;
  gap: 18px;
}

.settings-group {
  display: grid;
  gap: 10px;
}

.settings-legend {
  margin: 0;
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(82, 57, 38, 0.72);
}

.settings-field {
  display: grid;
  gap: 6px;
}

.settings-field-label {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.settings-number {
  width: 100%;
  border: 1px solid rgba(126, 88, 56, 0.22);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 252, 247, 0.72);
  color: var(--ink-strong);
}

.settings-theme-options {
  display: grid;
  gap: 8px;
}

.settings-theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(122, 85, 54, 0.08);
  color: var(--ink-soft);
}

.settings-custom-theme {
  display: none;
  gap: 10px;
}

.settings-panel[data-theme-mode="custom"] .settings-custom-theme {
  display: grid;
}

.settings-color-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.settings-color-input {
  width: 52px;
  height: 36px;
  border: 0;
  background: transparent;
  padding: 0;
}

@media (max-width: 640px) {
  .book {
    width: 100%;
    min-height: auto;
    clip-path: none;
    overflow: visible;
  }

  .book .stf__parent,
  .book .stf__wrapper,
  .book .stf__wrapper.--portrait,
  .book .stf__block {
    overflow: visible !important;
    clip-path: none !important;
  }

  .page-face,
  .cover-surface {
    overflow: visible;
  }

  .book .stf__wrapper.--portrait {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .page-content {
    padding: 28px 22px 24px 26px;
  }

  .page-body {
    font-size: 0.88rem;
    line-height: 1.56;
  }

  .page-scroll {
    padding-right: 6px;
  }

  .bookmark {
    width: var(--bookmark-width);
    height: var(--bookmark-height);
    margin-left: 0;
    padding: calc(var(--bookmark-width) * 0.26) calc(var(--bookmark-width) * 0.16);
    font-size: clamp(0.42rem, calc(var(--bookmark-width) * 0.022), 0.52rem);
  }

  .settings-panel {
    gap: 14px;
  }

  .settings-number {
    padding: 9px 11px;
  }

  .toc-section {
    padding: 10px 12px;
  }

  .toc-track {
    font-size: 0.84rem;
  }
}
