:root {
  color-scheme: light;
  --ink:#352d23; --muted:#716758; --red:#ac231e; --red-dark:#8e1c18;
  --paper:#fcf8ee; --line:#dcd4c4; --table:#eae3d5;
  font: 100% / 1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;
}
* {box-sizing:border-box}
body {margin:0;height:100vh;height:100dvh;display:grid;grid-template-rows:auto minmax(0,1fr) auto;color:var(--ink);background:var(--paper);overflow:hidden}
button,input {font:inherit}
button {border:0;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:.56rem;background:none;color:inherit;-webkit-tap-highlight-color:transparent}
button:disabled {cursor:default;opacity:.36}
button:not(:disabled):active {transform:translateY(1px)}
button:focus-visible,input:focus-visible,[tabindex]:focus-visible {outline:3px solid #a32719;outline-offset:3px}
[hidden] {display:none !important}
.symbols {position:absolute;width:0;height:0;overflow:hidden;pointer-events:none}
button svg {width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.sr-only {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.masthead,.toolbar {--gutter:max(4vw,24px);background:var(--paper);padding-left:max(var(--gutter),env(safe-area-inset-left));padding-right:max(var(--gutter),env(safe-area-inset-right));position:relative;z-index:2}
.masthead {display:flex;justify-content:space-between;align-items:center;gap:1rem;min-height:76px;padding-block:.7rem;padding-top:max(.7rem,env(safe-area-inset-top));border-bottom:1px solid var(--line)}
.brand,.top-actions,.pager,.scale-buttons {display:flex;align-items:center}
.brand {flex:none}
.brand img {height:52px;width:auto;display:block}
.top-actions {gap:.75rem}
.outlined,.icon-button,.forward,.zoom-button {border-radius:999px;font-weight:640;min-height:44px}
.order-grab {display:inline-flex;align-items:center;justify-content:center;min-height:44px;border-radius:999px;background:#007c43;color:white;font-weight:680;font-size:.91rem;text-decoration:none;padding:0 1rem;white-space:nowrap}
.order-grab:hover {background:#006738}
.order-grab:focus-visible {outline:3px solid #005c34;outline-offset:3px}
.index-phone {display:none}
.outlined {border:1px solid #c8beaa;padding:.55rem 1rem;background:#fffaf0;font-size:.9rem}
.icon-button {width:44px;padding:0;flex:none}
.outlined:hover,.zoom-button:hover,.icon-button:not(:disabled):hover {background:#ede4d2}
.table {min-height:0;position:relative;display:flex;padding:clamp(16px,3.2vh,38px) max(3vw,14px);isolation:isolate;background-color:var(--table);background-image:radial-gradient(ellipse at 50% 34%,#fff9e788,transparent 73%),repeating-linear-gradient(0deg,transparent 0 4px,#69502705 4px 5px),repeating-linear-gradient(90deg,transparent 0 4px,#69502707 4px 5px)}
.stage {position:relative;display:grid;place-items:center;min-width:0;width:100%;height:100%;min-height:0;container-type:size;touch-action:pan-y}
.book {position:relative;display:flex;isolation:isolate;width:min(100cqw,79.12cqh);aspect-ratio:666.142/841.89;box-shadow:0 1px 2px #45321a38,1px 3px 0 -1px #f7f4df,2px 4px 0 -1px #b7ab90,3px 5px 0 -1px #eee3ce,4px 6px 0 -1px #b9a992,0 15px 25px -9px #43341b4d,0 29px 50px -26px #332b214a;background:#fbf6e8}
.leaf {padding:0;display:block;position:relative;overflow:hidden;min-width:0;flex:1;background:var(--paper);height:100%}
.leaf img,.turn img,.stay img {width:100%;height:100%;display:block;user-select:none;-webkit-user-drag:none;object-fit:fill}
.book.ready .leaf {cursor:zoom-in;touch-action:none}
.leaf-status {position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);max-width:90%;width:max-content;padding:.4rem .7rem;border-radius:6px;background:var(--paper);color:var(--ink);font-size:1rem;font-weight:600}
.leaf.failed img {visibility:hidden}
.book.ready .leaf.failed {cursor:pointer}
.book .leaf:active {transform:none}
.book .leaf:focus-visible {z-index:2;outline-offset:0}
.book.ready.cover .leaf {cursor:pointer}
.book.spread .leaf:first-child:after,.book.spread .leaf:nth-child(2):after {content:"";position:absolute;inset:0;pointer-events:none}
.book.spread .leaf:first-child:after {background:linear-gradient(to left,#211c143d,transparent 3.2%)}
.book.spread .leaf:nth-child(2):after {background:linear-gradient(to right,#211c1433,transparent 3.2%)}
.turn,.stay {position:absolute;pointer-events:none;background:var(--paper)}
.turn {z-index:4;backface-visibility:hidden}
.stay {z-index:3}
.turn-target {visibility:hidden}
.book.turning-cover {background:transparent;box-shadow:none}
.turning-cover .turn,.turning-cover .stay,.turning-cover .leaf:not(.turn-target) {box-shadow:0 5px 14px #43341b35}
.toolbar {border-top:1px solid var(--line);display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:1rem;min-height:76px;padding-block:.8rem;padding-bottom:max(.8rem,env(safe-area-inset-bottom))}
.caption {font-family:Georgia,"Times New Roman",serif;font-weight:600;font-size:1.05rem;line-height:1.22;text-wrap:balance;max-width:32ch}
.pager {gap:.8rem;justify-content:center}
.round {border:1px solid #c8beaa;background:#fffaf0}
.page-count,.scale {font-size:.9rem;font-weight:650;white-space:nowrap;font-variant-numeric:tabular-nums}
.forward {color:#fffaf0;background:var(--red);padding:0 1rem;font-size:.91rem}
.forward:hover:not(:disabled) {background:var(--red-dark)}
.forward svg {width:16px}
.zoom-button {justify-self:end;padding:0 .85rem;font-size:.91rem}
.error {position:absolute;background:var(--paper);box-shadow:0 1px 8px #3333;border-radius:6px;bottom:12px;left:50%;transform:translateX(-50%);padding:.65rem 1rem}
.error button {text-decoration:underline}
dialog {color:var(--ink);background:var(--paper);border:1px solid #bdb09b;box-shadow:0 22px 80px #211a1840;padding:0;border-radius:14px}
dialog::backdrop {background:#29201885}
dialog[open] {display:flex;flex-direction:column}
.index-dialog {
  --inset-top:max(8px,env(safe-area-inset-top));--inset-bottom:max(8px,env(safe-area-inset-bottom));
  --inset-left:max(8px,env(safe-area-inset-left));--inset-right:max(8px,env(safe-area-inset-right));
  position:fixed;inset:auto;margin:0;left:calc(50% + (var(--inset-left) - var(--inset-right)) / 2);
  top:calc(var(--index-center,50dvh) + (var(--inset-top) - var(--inset-bottom)) / 2);transform:translate(-50%,-50%);
  width:min(880px,calc(100% - 32px));max-height:min(88dvh,var(--index-height,88dvh));overflow:hidden;
}
.index-head {display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"title close" "search search";align-items:center;gap:.45rem .75rem;flex:none;padding:.65rem 1.35rem .85rem;border-bottom:1px solid var(--line)}
.index-head h2 {grid-area:title}
.index-head button {grid-area:close}
.index-dialog.compact .index-head {grid-template-areas:"search close";padding:.35rem .6rem}
.index-dialog.compact h2 {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
.zoom-head {display:flex;align-items:center;gap:1rem;justify-content:space-between;flex-shrink:0;padding:.85rem 1.35rem;background:var(--paper)}
.index-head h2,.zoom-head h2 {margin:0;font-family:Georgia,serif;font-size:1.45rem;letter-spacing:-.03em;line-height:1.12}
#index-search {grid-area:search;min-width:0;font-size:max(16px,1rem);border:1px solid #c6bba6;border-radius:7px;background:#fffdf7;width:100%;padding:.55rem .8rem;color:var(--ink);min-height:42px}
#no-matches {padding:.7rem 1.35rem 1rem;margin:0}
.page-grid {min-height:0;overscroll-behavior:contain;overflow-y:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(125px,1fr));gap:1.2rem .9rem;padding:1.25rem 1.35rem 1.75rem}
.thumb {border-radius:6px;display:flex;flex-direction:column;align-items:stretch;text-align:left;justify-content:flex-start;gap:0;padding:.35rem}
.thumb[aria-current="page"] {box-shadow:0 0 0 2px var(--red);background:#f9f0df}
.thumb:hover {background:#efe6d6}
.thumb img {width:100%;height:auto;aspect-ratio:666.142/841.89;object-fit:contain;background:var(--table);border-radius:2px}
.thumb .number {font-size:.76rem;color:var(--muted);margin:.45rem 0 .12rem}
.thumb .name {font-size:.9rem;font-weight:650;line-height:1.25}
.zoom-dialog {width:min(1240px,calc(100% - 48px));height:94dvh;max-height:94dvh;max-width:100%;overflow:hidden}
.zoom-head {border-bottom:1px solid var(--line);gap:.7rem}
.zoom-title-block {min-width:0;flex:1}
.zoom-title-block span {font-size:.8rem;color:var(--muted)}
.zoom-title-block h2 {font-size:1.12rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.scale-buttons {border:1px solid var(--line);border-radius:999px}
.scale {text-align:center;min-width:42px}
.zoom-view {background:var(--table);overflow:auto;min-height:0;flex:1;overscroll-behavior:contain;cursor:grab;touch-action:none}
.zoom-view.dragging {cursor:grabbing}
.zoom-view img {display:block;max-width:none;height:auto;margin:0 auto;user-select:none;-webkit-user-drag:none}
@media(max-width:720px){
  .masthead,.toolbar {--gutter:12px}
  .masthead {display:grid;grid-template-columns:auto minmax(0,1fr);gap:8px;min-height:65px}
  .top-actions {justify-content:flex-end;flex-wrap:wrap;gap:.25rem}
  .index-desktop {display:none}
  .index-phone {display:inline}
  .table {padding-inline:max(6px,env(safe-area-inset-left)) max(6px,env(safe-area-inset-right))}
  .brand img {height:40px}
  .outlined {padding:0 .8rem}
  .top-full {width:44px}
  .toolbar {display:flex;justify-content:space-between;flex-wrap:wrap;gap:4px 8px;min-height:66px}
  .caption {display:none}
  .pager {max-width:100%;justify-content:start;flex-wrap:wrap;gap:clamp(4px,2vw,10px)}
  .forward {padding-inline:12px;gap:6px}
  .zoom-button {margin-left:auto;min-width:44px;padding-inline:9px}
  .index-dialog {width:calc(100% - var(--inset-left) - var(--inset-right));max-width:100%;max-height:var(--index-height,94dvh)}
  .index-head,.page-grid {padding-inline:.9rem}
  .page-grid {gap:.7rem;grid-template-columns:repeat(auto-fill,minmax(115px,1fr))}
}
@media(max-width:360px){
  #open-index span,.zoom-button span {display:none}
  #open-index {width:44px;padding:0}
  .top-actions {gap:3px}
  .masthead,.toolbar {--gutter:8px}
  .masthead {gap:6px}
  .zoom-button {padding:0}
  .order-grab {padding-inline:10px}
}
@media(max-height:520px) and (orientation:landscape){.masthead,.toolbar {min-height:44px;padding-block:2px}.brand img{height:34px}.table{padding-block:7px}}
@media(pointer:coarse) and (orientation:landscape) and (max-height:540px) and (max-width:1024px){
  .masthead,.toolbar {--gutter:12px}
  .masthead {padding-top:max(2px,env(safe-area-inset-top))}
  .toolbar {padding-bottom:max(2px,env(safe-area-inset-bottom));display:flex;justify-content:space-between;gap:8px}
  .caption {display:none}
  .table {padding:0 max(8px,env(safe-area-inset-right)) 0 max(8px,env(safe-area-inset-left))}
  .stage {display:block;overflow-x:hidden;overflow-y:auto;overscroll-behavior-y:contain}
  .stage .book {margin-inline:auto}
  .stage .book.ready .leaf {touch-action:pan-y}
}
@media (max-width:720px), (pointer:coarse) and (orientation:landscape) and (max-height:540px) and (max-width:1024px){
  .zoom-dialog {width:100%;height:100dvh;max-height:100dvh;border:0;border-radius:0;padding-bottom:env(safe-area-inset-bottom)}
  .zoom-head {padding:max(.45rem,env(safe-area-inset-top)) max(.55rem,env(safe-area-inset-right)) .45rem max(.55rem,env(safe-area-inset-left))}
}

.index-dialog.compact .page-grid {grid-template-columns:1fr;gap:.3rem;padding:.45rem .55rem max(.45rem,env(safe-area-inset-bottom))}
.index-dialog.compact .thumb {display:grid;grid-template-columns:36px minmax(0,1fr);grid-template-rows:auto auto;column-gap:.65rem;align-items:center;padding:.3rem .4rem}
.index-dialog.compact .thumb img {width:36px;grid-row:1 / 3}
.index-dialog.compact .thumb .number {align-self:end;margin:0}
.index-dialog.compact .thumb .name {align-self:start}
