:root {
  color-scheme: dark;
  font-family: system-ui, "Segoe UI", sans-serif;
  background: #171c21;
  color: #f6f7f8;
  --rule: #444d56;
  --ink: #20272e;
  --focus: #ffc36d;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: grid; grid-template-rows: auto minmax(0,1fr) auto; height: 100dvh; overflow: hidden; }
button, input { font: inherit; }
button, .action { background: #2d363f; color: inherit; border: 1px solid var(--rule); border-radius: 5px; padding: 7px 11px; cursor: pointer; text-decoration: none; }
button:hover:not(:disabled), .action:hover { background: #404b55; }
button:disabled { opacity: .4; cursor: default; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.toolbar { background: #171c21; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 10px clamp(9px,2vw,22px); border-bottom: 1px solid #39414a; }
.brand { display: flex; gap: 11px; align-items: baseline; color: inherit; text-decoration: none; white-space: nowrap; }
.brand strong { color: #ffd39a; font-size: 1.48rem; letter-spacing: .05em; font-family: Georgia, serif; }
.brand span { font-size: .86rem; }
.brand i { color: #a2aeba; font-style: normal; padding: 0 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 5px; font-size: .86rem; }
#viewport { display: flex; justify-content: safe center; align-items: safe center; position: relative; overflow: auto; background: #505254; padding: 14px; }
.spread { display: flex; align-items: center; justify-content: center; flex: none; position: relative; isolation: isolate; }
.turn-canvas { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3; pointer-events: none; }
.edge-arrow { position: fixed; top: 50%; transform: translateY(-50%); z-index: 5; padding: 9px 7px; font-size: 1.4rem; background: #20272eb0; border: 0; }
.edge-arrow:disabled { visibility: hidden; }
.edge-previous { left: 4px; }
.edge-next { right: 4px; }
.sheet { position: relative; margin: 0; aspect-ratio: 210/297; flex: none; background: white; box-shadow: 0 6px 20px #0008; }
.sheet + .sheet { border-left: 1px solid #0003; }
.sheet:has(+ .sheet)::before, .sheet + .sheet::before { content: ""; position: absolute; inset-block: 0; width: 3%; pointer-events: none; }
.sheet:has(+ .sheet)::before { right: 0; background: linear-gradient(to left,#0003,transparent); }
.sheet + .sheet::before { left: 0; background: linear-gradient(to right,#0002,transparent); }
#page-progress { flex: 1; min-width: 32px; max-width: 560px; accent-color: #e1e5e8; }
.sheet img { display: block; width: 100%; height: 100%; object-fit: fill; }
.hotspot { position: absolute; border-radius: 2px; }
.hotspot:hover, .hotspot:focus-visible { background: #ffd17c4f; outline: 2px solid #bb6f0e; outline-offset: 0; }
.controls { border-top: 1px solid #39414a; border-bottom: 0; justify-content: center; font-size: .87rem; }
.controls button { padding: 5px 8px; min-width: 34px; }
#page-form { display: flex; align-items: center; gap: 5px; }
#page-number { color: inherit; background: #11171c; border: 1px solid var(--rule); border-radius: 4px; padding: 4px; width: 49px; text-align: center; appearance: textfield; }
#page-number::-webkit-inner-spin-button, #page-number::-webkit-outer-spin-button { appearance: none; }
.control-divider { height: 23px; border-left: 1px solid var(--rule); margin: 0 1px; }
dialog { color-scheme: light; color: var(--ink); background: #f8f9fa; border: 0; border-radius: 8px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 35px); box-shadow: 0 15px 70px #0008; }
dialog::backdrop { background: #10161bb5; }
.panel-top { display: flex; justify-content: space-between; align-items: center; padding: 13px 17px; background: #1d272e; color: white; }
.panel-top h1 { margin: 0; font-size: 1.08rem; }
.panel-top button { font-size: 1.2rem; padding: 0 9px; }
#panel-body { padding: 13px 16px 17px; }
.entry { padding: 8px 0; border-bottom: 1px solid #d5dbe1; }
.entry:last-child { border: 0; }
.entry a, .result { color: #10446c; text-underline-offset: 2px; }
.entry .row { display: flex; justify-content: space-between; gap: 7px; }
.entry .folio { color: #495764; white-space: nowrap; }
.entry .contacts { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 5px; font-size: .83rem; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(76px,1fr)); gap: 12px; }
.page-grid a { text-decoration: none; text-align: center; color: var(--ink); display: grid; gap: 4px; font-size: .8rem; }
.page-grid img { width: 100%; aspect-ratio: 210/297; display: block; box-shadow: 0 1px 5px #1113; }
.search-field { width: 100%; padding: 8px 10px; border: 1px solid #a4b0bc; border-radius: 4px; }
.search-note { font-size: .85rem; color: #475764; }
.noscript { position: absolute; inset: 20% 10% auto; padding: 18px; background: #171c21; }
.noscript a { color: #ffd39a; }
.visually-hidden { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
@media (max-width: 690px) {
  header.toolbar { flex-wrap: wrap; gap: 5px; padding: 6px 9px; }
  .actions button, .actions a { padding: 5px 6px; font-size: .78rem; }
  .brand strong { font-size: 1.18rem; }
  .brand span { font-size: .77rem; }
  #viewport { padding: 8px; }
  .edge-arrow { padding: 6px 4px; font-size: 1rem; }
  .controls { padding: 5px; gap: 4px; }
  .controls button { min-width: 29px; padding: 5px; }
  #view-mode, #page-form label, .control-divider { display: none; }
}

