:root{--red:#ee7203;--ink:#27282b;--bg:#f0f0f2;--ratio:0.70710678;--spread-ratio:1.41421356}
*{box-sizing:border-box}
html,body{margin:0;padding:0;min-height:100%;color:var(--ink);background:var(--bg);font-family:system-ui,-apple-system,"Segoe UI",Arial,sans-serif}
button,a{font:inherit}button{cursor:pointer}button:focus-visible,a:focus-visible,.sheet:focus-visible{outline:2px solid var(--red);outline-offset:3px}
.app{height:100dvh;min-height:380px;display:flex;flex-direction:column;overflow:hidden}
.toolbar{flex:0 0 auto;display:flex;justify-content:space-between;align-items:center;gap:12px;background:#fff;border-bottom:1px solid #e3e3e5;padding:12px clamp(12px,2vw,24px);position:relative;z-index:4}
.brand{font-size:16px;font-weight:850;letter-spacing:.14em;line-height:1.3}.brand strong{color:var(--red)}.subtitle{color:#858589;font-size:12px;margin-top:2px}
.tools{display:flex;align-items:center;justify-content:flex-end;gap:6px;flex-wrap:wrap}
.tool{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:1px solid #dddde1;background:#fff;color:#44464a;padding:8px 11px;text-decoration:none;border-radius:6px;white-space:nowrap;font-size:13px;min-height:38px;transition:color .16s,border-color .16s}
.tool svg{width:17px;height:17px;stroke:currentColor;stroke-width:1.7;fill:none;stroke-linecap:round;stroke-linejoin:round;flex:none}
.tool:hover,.tool:focus-visible{border-color:var(--red);color:var(--red)}.tool[aria-pressed=true]{color:#a64e00;background:#fff5e9;border-color:#f9d2a4}.tool-sep{height:26px;width:1px;background:#eee;margin:0 3px}
.layout{flex:1;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.stage{flex:1;min-height:0;display:flex;justify-content:center;align-items:center;gap:clamp(4px,1.7vw,26px);padding:12px 8px;overflow:hidden}
.book{flex:none;position:relative;width:min(1160px,calc((100dvh - 180px)*var(--spread-ratio)),calc(100vw - 154px));aspect-ratio:var(--spread-ratio);display:flex;perspective:2400px;filter:drop-shadow(0 8px 12px rgba(0,0,0,.16));touch-action:pan-y}
.sheet{position:relative;flex:0 0 50%;height:100%;background:#fff;overflow:hidden;cursor:zoom-in}
.sheet.left{border-radius:3px 0 0 3px}.sheet.right{border-radius:0 3px 3px 0}
.sheet.empty{background:transparent;cursor:default}.sheet.empty img{visibility:hidden}
.sheet img,.leaf img{display:block;width:100%;height:100%;object-fit:contain;object-position:center;background:#fff;user-select:none;-webkit-user-drag:none}
.sheet.empty img{background:transparent}.sheet:focus-visible{outline-offset:0}
.spine{pointer-events:none;position:absolute;left:calc(50% - 2px);top:0;bottom:0;width:4px;z-index:2;background:linear-gradient(90deg,transparent,rgba(0,0,0,.14),rgba(255,255,255,.2))}
.spine.hidden{display:none}
.arrow{width:54px;height:80px;flex:none;border:0;background:transparent;color:#ee7203;display:grid;place-items:center;padding:0;transition:color .18s,transform .18s}
.arrow svg{width:35px;height:35px;stroke:currentColor;stroke-width:1.7;fill:none;stroke-linecap:round;stroke-linejoin:round}
.arrow:hover:not(:disabled){color:#95c11f;transform:scale(1.1)}.arrow:disabled{opacity:.2;cursor:default}
.leaf{position:absolute;top:0;left:50%;width:50%;height:100%;transform-origin:left center;transform-style:preserve-3d;z-index:3;pointer-events:none}
.leaf.reverse{left:0;transform-origin:right center}.face{position:absolute;inset:0;background:#fff;backface-visibility:hidden;overflow:hidden}.face.back{transform:rotateY(180deg)}
.leaf.forward{animation:turnForward .65s cubic-bezier(.32,.62,.23,1) forwards}.leaf.backward{animation:turnBackward .65s cubic-bezier(.32,.62,.23,1) forwards}
@keyframes turnForward{to{transform:rotateY(-180deg)}}@keyframes turnBackward{to{transform:rotateY(180deg)}}
.footer{flex:none;display:flex;align-items:center;justify-content:center;gap:10px;color:#77787d;font-size:12px;padding:7px 12px 14px}.red-dot{width:4px;height:4px;border-radius:50%;background:var(--red)}
.reading,.overview{display:none;flex:1;min-height:0;overflow:auto;overscroll-behavior:contain}
.reading.show{display:block;padding:24px 12px}.reading img{display:block;width:min(100%,680px);height:auto;margin:0 auto 20px;background:white;box-shadow:0 5px 18px rgba(0,0,0,.13);cursor:zoom-in}
.overview.show{display:block;padding:24px}.thumb-grid{max-width:1130px;margin:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(115px,1fr));gap:19px}
.thumb{display:flex;align-items:center;flex-direction:column;gap:7px;padding:8px;background:#fff;border:1px solid #dadade;border-radius:5px;color:#6b6c70;transition:border-color .15s}
.thumb:hover,.thumb.current{border-color:var(--red)}.thumb img{width:100%;height:auto;aspect-ratio:var(--ratio);object-fit:contain}.thumb span{font-size:12px}
.zoom{position:fixed;inset:0;z-index:10;background:#161616ef;display:none;flex-direction:column}
.zoom.show{display:flex}.zoom-head{display:flex;align-items:center;justify-content:space-between;gap:14px;background:#27282b;color:#fff;padding:10px clamp(12px,3vw,24px);font-size:13px;min-height:57px}
.zoom-tools{display:flex;gap:7px}.zoom-tools button{color:#fff;background:#3b3c40;border:1px solid #777;border-radius:6px;padding:6px 12px;min-width:38px;min-height:36px}.zoom-tools button:hover{border-color:#fff}
.zoom-body{flex:1;overflow:auto;overscroll-behavior:contain;padding:16px;cursor:grab}.zoom-body.dragging{cursor:grabbing;user-select:none}.zoom-body img{display:block;max-width:none;height:auto;margin:auto;background:#fff;box-shadow:0 10px 30px #0007}
.hidden{display:none!important}
@media(max-width:980px){.toolbar{align-items:flex-start}.tools{gap:4px}.tool{padding:7px 8px}.tool span{display:none}.identity{min-width:132px}.tool-sep{display:none}}
@media(max-width:720px){.toolbar{padding:10px 11px;align-items:center}.brand{font-size:13px}.subtitle{font-size:10px}.tool{padding:7px;min-height:34px}.tool svg{width:18px;height:18px}.stage{padding:8px 2px;gap:1px}.book{width:min(calc((100dvh - 151px)*var(--ratio)),calc(100vw - 86px),520px);aspect-ratio:var(--ratio)}.sheet.left,.spine{display:none}.sheet.right{flex-basis:100%;border-radius:3px}.arrow{width:39px;height:72px}.arrow svg{width:30px;height:30px}.leaf,.leaf.reverse{left:0;width:100%}.footer{padding:6px 10px 10px}.reading.show{padding:12px 8px}.overview.show{padding:14px}.thumb-grid{gap:11px;grid-template-columns:repeat(auto-fill,minmax(92px,1fr))}.zoom-tools button{padding:5px 9px}.zoom-tools #closeZoom span{display:none}}
@media(max-height:580px) and (min-width:721px){.book{width:min(calc((100dvh - 150px)*var(--spread-ratio)),calc(100vw - 154px),1160px)}.toolbar{padding-top:6px;padding-bottom:6px}.footer{padding-bottom:5px}}
@media(prefers-reduced-motion:reduce){.leaf.forward,.leaf.backward{animation-duration:.05s}}
