* { box-sizing: border-box; }
:root { --accent: #418889; }
html, body {
  margin: 0; padding: 0; background: transparent; overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
img { -webkit-user-drag: none; user-drag: none; pointer-events: none; }

#app { position: relative; padding: 12px 0 0; }
:fullscreen #app, #app:fullscreen { background: #1d1d1f; height: 100vh; display: flex; flex-direction: column; justify-content: center; }

#stage { display: flex; justify-content: center; }
.book { margin: 0 auto; transition: transform .5s ease; }

/* Библиотека перелистывания (StPageFlip) */
.stf__parent { position: relative; display: block; box-sizing: border-box; touch-action: pan-y; transform: translateZ(0); }
.stf__wrapper { position: relative; box-sizing: border-box; width: 100%; }
.stf__parent canvas { position: absolute; width: 100%; height: 100%; top: 0; left: 0; }
.stf__block { position: absolute; box-sizing: border-box; perspective: 2000px; width: 100%; height: 100%; }
.stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.stf__outerShadow, .stf__innerShadow, .stf__hardShadow, .stf__hardInnerShadow { position: absolute; top: 0; left: 0; }

/* Страницы */
.page { background: #fff; overflow: hidden; box-shadow: 0 10px 28px rgba(0,0,0,.30), 0 2px 6px rgba(0,0,0,.08); }
.page img { width: 100%; height: 100%; display: block; object-fit: cover; }
.page::after { content: ""; position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none; }
.page.--left::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.09), transparent); }
.page.--right::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.09), transparent); }
.portrait .page::after { display: none; }

/* Панель */
#bar { display: flex; align-items: center; justify-content: center; gap: 14px; height: 64px; margin-top: 22px; }
#bar button {
  width: 42px; height: 42px; border: 0; border-radius: 50%; padding: 0;
  background: var(--accent); color: #fff; font-size: 22px; line-height: 42px; cursor: pointer;
}
#bar button:hover { filter: brightness(1.12); }
#bar button.off { opacity: .45; }
#bar button:disabled { opacity: .3; cursor: default; }
#bar #count { width: auto; min-width: 84px; padding: 0 10px; border-radius: 21px; background: transparent; color: #333; font-size: 15px; font-variant-numeric: tabular-nums; }
#bar #count:hover { background: rgba(0,0,0,.06); filter: none; }
:fullscreen #count, #app:fullscreen #count { color: #eee; }

/* Все страницы */
#thumbs { position: fixed; inset: 0; z-index: 40; background: rgba(247,242,240,.98); display: flex; flex-direction: column; }
#thumbs[hidden] { display: none; }
.thumbs-head { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid rgba(0,0,0,.08); font-size: 15px; color: #333; flex-wrap: wrap; }
.thumbs-head > span { font-weight: 600; }
.goto { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.goto input { width: 70px; height: 36px; padding: 0 8px; border: 1px solid rgba(0,0,0,.2); border-radius: 8px; font: inherit; -webkit-user-select: text; user-select: text; }
.goto button, #thumbsClose { height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
#thumbsClose { width: 36px; padding: 0; font-size: 22px; line-height: 36px; }
#thumbsGrid { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 16px 12px; align-content: start; }
.thumb { border: 0; padding: 0; background: none; cursor: pointer; text-align: center; color: #555; font: 13px/1.6 inherit; }
.thumb img { display: block; width: 100%; aspect-ratio: var(--ratio); object-fit: cover; background: #e9e4e0; box-shadow: 0 3px 10px rgba(0,0,0,.12); transition: transform .2s; }
.thumb:hover img { transform: translateY(-3px); }
.thumb.cur img { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb.cur { color: var(--accent); font-weight: 600; }

/* Увеличение */
#zoom { position: fixed; inset: 0; background: #1d1d1f; z-index: 50; overflow: auto; -webkit-overflow-scrolling: touch; }
#zoom[hidden] { display: none; }
#zoomInner { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; }
#zoomInner img { display: block; background: #fff; }
#zoomClose {
  position: fixed; top: 10px; right: 10px; z-index: 51; width: 44px; height: 44px; border: 0;
  border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; font-size: 28px; line-height: 44px; cursor: pointer;
}

#notice { padding: 60px 16px; text-align: center; color: #333; font-size: 16px; }
#notice a { color: inherit; }

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

@media (max-width: 480px) {
  #bar { gap: 5px; }
  #bar button { width: 32px; height: 32px; font-size: 17px; line-height: 32px; }
  #bar #count { min-width: 52px; padding: 0 2px; font-size: 13px; }
  .thumbs-head { gap: 10px; }
  .thumbs-head > span { display: none; }
  .goto { margin-left: 0; }
  #thumbsGrid { grid-template-columns: repeat(3, 1fr); }
}
