@font-face { font-family: "Garamond"; src: url(../fonts/eb-garamond-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root { --zoom: 1; --bar: #fbf7ee; --desk: #e9dfc8; --ink: #1a294d; --soft: #7a6f5c; --line: #e4d8bf; color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root { --bar: #111a2e; --desk: #080d19; --ink: #f1e7d2; --soft: #a59a84; --line: #2b3858; color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* The bars stay put; only the page area scrolls (so zooming never pushes them off a phone screen) */
html, body { height: 100%; overflow: hidden; }
body { margin: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; background: var(--desk); color: var(--ink); font: 1.06rem/1.4 "Garamond", Georgia, serif; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

.top, .bottom { flex: none; display: flex; align-items: center; gap: .5rem; background: var(--bar); }
.top { min-height: 3.25rem; padding: env(safe-area-inset-top) .5rem 0; border-bottom: 1px solid var(--line); }
.bottom { justify-content: center; min-height: 3.5rem; padding: 0 .5rem env(safe-area-inset-bottom); border-top: 1px solid var(--line); }
.top h1 { flex: 1; min-width: 0; margin: 0; font-weight: 400; font-style: italic; font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.tool { display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; height: 2.75rem; padding: 0 .6rem; border: 0;
  border-radius: 3px; background: none; color: inherit; font: inherit; cursor: pointer; }
.tool:hover { background: var(--desk); }
.tool:disabled { opacity: .3; cursor: default; background: none; }
.zoom { font-size: 1.5rem; line-height: 1; }

.count { display: flex; align-items: center; gap: .4rem; color: var(--soft); white-space: nowrap; }
#page { width: 3.6rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 3px; background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; text-align: center; -moz-appearance: textfield; appearance: textfield; }
#page::-webkit-inner-spin-button { -webkit-appearance: none; }

/* A native menu sits invisibly over the button, so phones show their own picker */
.toc { position: relative; }
.toc select { position: absolute; inset: 0; width: 100%; opacity: 0; font-size: 16px; cursor: pointer; }
.toc:focus-within { outline: 2px solid currentColor; }

.pages { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 8px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; outline: none; }
.pages:empty { display: none; }
.sheet { width: calc(min(100vw - 16px, 860px) * var(--zoom)); aspect-ratio: var(--ratio, 445 / 703); margin: 0 auto 8px; overflow: hidden;
  background: #fbf7ee; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
.sheet canvas { display: block; width: 100%; height: 100%; }
body:not(.ready) .bottom { visibility: hidden; }

.status { flex: 1; margin: 0; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .35em; padding: 2rem; text-align: center; color: var(--soft); }
.status a { color: var(--ink); text-decoration: underline; }
@media print { .top, .bottom { display: none; } }
