* { box-sizing: border-box; }
body { margin: 0; background: #e6e2d9; color: #242424; font-family: system-ui, sans-serif; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: #292d29; color: #fff; }
.toolbar h1 { margin: 0; font-size: 1rem; text-align: center; }
.toolbar a { color: #fff; }
.reader { padding: 12px 12px 24px; }
.controls, #page-form, .zoom-controls { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; }
.controls button, .controls input { font: inherit; padding: 6px 10px; }
.controls button { cursor: pointer; }
.controls button:disabled { cursor: default; }
.controls input { width: 75px; text-align: center; }
.zoom-controls output { min-width: 3.5em; text-align: center; }
#status, .hint { margin: 10px 0; text-align: center; font-size: 0.9rem; }
#status:empty { display: none; }
.book-scroll { max-height: calc(100vh - 190px); overflow: auto; }
.book-area { position: relative; display: flex; justify-content: center; width: calc(min(100vw - 24px, 1100px, (100vh - 210px) * var(--page-ratio, 0.65) * 2) * var(--zoom, 1)); margin: 0 auto; }
#book { width: 100%; }
.book-hand-overlay { display: none; position: absolute; inset: 0; cursor: grab; touch-action: none; }
.book-scroll.is-hand-mode .book-hand-overlay { display: block; }
.book-scroll.is-dragging .book-hand-overlay { cursor: grabbing; }
#hand-mode[aria-pressed="true"] { background: #dce8da; color: #172a17; }
.pdf-page { background: #fffdf7; box-shadow: inset 0 0 8px #0002; }
.pdf-page-image { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: center / 100% 100% no-repeat; color: #777; font-size: 0.9rem; }
.pdf-page-image:not(.is-ready)::after { content: "Загрузка страницы…"; }
.hint { color: #4c504b; }
@media (max-width: 600px) {
    .toolbar { justify-content: center; }
    .toolbar h1 { order: -1; width: 100%; }
    .book-scroll { max-height: calc(100vh - 240px); }
    .book-area { width: calc(min(100vw - 24px, (100vh - 240px) * var(--page-ratio, 0.65)) * var(--zoom, 1)); }
}
