.flipbook-reader {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) 120px;
  grid-template-rows: minmax(0, 1fr);
  min-height: 320px;
  overflow: hidden;
  background: #e9efec;
  color: #182722;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.flipbook-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
  min-width: 0;
  padding: 24px 12px;
}

.flipbook-toolbar button,
.flipbook-footer button,
.flipbook-contents button {
  border: 1px solid #bdcbc3;
  border-radius: 6px;
  background: #ffffff;
  color: #204e43;
  font: inherit;
  cursor: pointer;
}

.flipbook-toolbar button {
  min-height: 36px;
  padding: 6px 11px;
  font-size: 13px;
  font-weight: 700;
}

.flipbook-toolbar button img,
.flipbook-footer button img {
  display: block;
  width: 18px;
  height: 18px;
}

.flipbook-toolbar .flipbook-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.flipbook-back span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flipbook-toolbar button:hover,
.flipbook-footer button:hover:not(:disabled),
.flipbook-contents button:hover {
  background: #e5f3ee;
  border-color: #71a996;
}

.flipbook-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.flipbook-heading strong,
.flipbook-heading span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flipbook-heading strong {
  font-size: 15px;
}

.flipbook-heading span {
  color: #587067;
  font-size: 12px;
}

.flipbook-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.flipbook-tools button {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 6px;
}

.flipbook-main {
  position: relative;
  display: flex;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.flipbook-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 0;
  padding: 12px;
  overflow: hidden;
  background: radial-gradient(circle at center, #f4f7f5 0%, #e9efec 72%);
}

.flipbook-reader.is-zoomed .flipbook-stage {
  overflow: auto;
}

.flipbook-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  transition: transform 180ms ease;
}

.flipbook-reader.is-zoomed .flipbook-canvas {
  transform: scale(1.2);
}

.flipbook-reader:fullscreen {
  height: 100dvh !important;
}

.flipbook-reader:fullscreen .flipbook-main {
  min-height: 0;
}

.flipbook-contents {
  position: absolute;
  z-index: 20;
  top: 12px;
  left: clamp(12px, 3vw, 36px);
  display: grid;
  align-content: start;
  gap: 6px;
  width: min(270px, calc(100% - 24px));
  max-height: min(66dvh, 520px);
  padding: 12px;
  overflow-y: auto;
  border: 1px solid #cfdbd5;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 16px 36px #14291e2e;
}

.flipbook-contents[hidden] {
  display: none;
}

.flipbook-contents button {
  min-height: 38px;
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
}

.flipbook-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
  padding: 18px 10px;
}

.flipbook-footer button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 38px;
}

.flipbook-footer button:disabled {
  opacity: 0.35;
  cursor: default;
}

.flipbook-position {
  min-width: 0;
  text-align: center;
  color: #476157;
  font-size: 13px;
  font-weight: 700;
}

.flipbook-measurement {
  position: fixed;
  top: 0;
  left: -10000px;
  visibility: hidden;
  pointer-events: none;
}

.flipbook-page {
  position: relative;
  flex: none;
  overflow: hidden;
  box-sizing: border-box;
  background: #fffefb;
  box-shadow: inset 0 0 0 1px #d8dfda;
}

.flipbook-page * {
  box-sizing: border-box;
}

.flipbook-page-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 32px 30px 18px;
}

.flipbook-page-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  color: #29352e;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  line-height: 1.52;
  overflow-wrap: anywhere;
}

.flipbook-page-content[dir='rtl'] {
  text-align: right;
}

.flipbook-page-number {
  height: 18px;
  flex: 0 0 18px;
  text-align: center;
  color: #84938b;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
}

.flipbook-chapter-title {
  margin: 0 0 18px;
  color: #183d35;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 25px;
  line-height: 1.16;
}

.flipbook-page-content p,
.flipbook-page-content blockquote,
.flipbook-page-content ul,
.flipbook-page-content ol {
  margin: 0 0 12px;
}

.flipbook-page-content blockquote {
  margin-left: 0;
  padding-left: 12px;
  border-left: 3px solid #2e806c;
}

.flipbook-page-content img:not(.story-dialog-avatar) {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  float: none;
  clear: both;
  object-fit: contain;
  border: 0;
  box-shadow: none;
}

.flipbook-page-content img.story-float-image.is-left {
  margin-left: 0;
  margin-right: auto;
}

.flipbook-page-content img.story-float-image.is-right {
  margin-left: auto;
  margin-right: 0;
}

.flipbook-figure {
  margin: 0 0 16px;
}

.flipbook-page-content .story-dialog-turn {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 9px;
  margin: 10px 0 14px;
}

.flipbook-page-content .story-dialog-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.flipbook-page-content .story-dialog-body {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 5px;
  background: #edf3ef;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.42;
}

.flipbook-page-content .story-dialog-name {
  display: block;
  color: #176451;
  font-size: 12px;
}

.flipbook-page-content .story-dialog-body p:last-child {
  margin-bottom: 0;
}

.flipbook-empty-chapter {
  color: #718078;
  font-style: italic;
}

.flipbook-inside-cover {
  background: #f0f5f0;
}

.flipbook-inside-cover h2 {
  margin: 24px 0 20px;
  color: #183d35;
  font-size: 27px;
}

.flipbook-inside-cover ol {
  padding-left: 22px;
}

.flipbook-inside-cover li {
  margin-bottom: 12px;
  color: #4c6155;
}

.flipbook-cover,
.flipbook-back-cover {
  background: #12372f;
  color: #ffffff;
}

.flipbook-cover .flipbook-page-inner,
.flipbook-back-cover .flipbook-page-inner {
  padding: 0;
}

.flipbook-cover .flipbook-page-content,
.flipbook-back-cover .flipbook-page-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 38px;
  color: #ffffff;
  text-align: center;
}

.flipbook-cover .flipbook-page-content::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(180deg, #0b211d33 18%, #0b211dea 100%);
}

.flipbook-cover-image {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

.flipbook-cover-copy {
  position: relative;
  z-index: 2;
  width: 100%;
}

.flipbook-cover-copy h1 {
  margin: 0 0 18px;
  color: #ffffff;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 38px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.flipbook-cover-copy span {
  color: #d1eee1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.flipbook-back-cover .flipbook-page-content {
  justify-content: center;
  gap: 16px;
}

.flipbook-end-mark {
  color: #9ccead;
  font-size: 34px;
}

.flipbook-back-cover p {
  margin: 0;
  font-size: 30px;
}

@media (max-width: 900px) {
  .flipbook-reader {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .flipbook-toolbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #cfdbd5;
    background: #ffffff;
  }

  .flipbook-heading {
    flex: 1;
  }

  .flipbook-tools {
    flex-direction: row;
    align-items: center;
    gap: 4px;
  }

  .flipbook-stage {
    padding: 10px;
    min-height: 0;
  }

  .flipbook-footer {
    flex-direction: row;
    gap: 12px;
    padding: 6px 10px;
    background: #e9efec;
  }

  .flipbook-position {
    min-width: 115px;
  }
}

@media (max-width: 490px) {
  .flipbook-heading {
    order: 3;
    flex: 1 0 100%;
    text-align: center;
  }

  .flipbook-tools {
    margin-left: auto;
  }
}
