/* ================= READER ================= */
.reader{position:fixed;inset:0;z-index:80;display:flex;flex-direction:column;color:#efe4d3;
  --paper:#fbf7ef;--ink:#2b241c;--col:#5a3b2a;
  background:radial-gradient(90% 70% at 50% 45%,#3a2a1e 0,#1e1510 60%,#120c08 100%);
  opacity:0;transition:opacity .35s}
.reader.on{opacity:1}
.reader::before{content:"";position:absolute;inset:0;pointer-events:none;opacity:.5;
  background:repeating-linear-gradient(0deg,transparent 0 46px,rgb(0 0 0/.18) 46px 47px,transparent 47px 140px),
             repeating-linear-gradient(90deg,transparent 0 3px,rgb(255 255 255/.012) 3px 4px)}
.reader.p-malam{background:radial-gradient(90% 70% at 50% 45%,#1d1915 0,#0f0c0a 70%)}
.r-top{position:relative;z-index:3;display:flex;align-items:center;gap:10px;padding:10px 16px;transition:opacity .3s,transform .3s}
.r-title{flex:1;min-width:0;text-align:center;line-height:1.25}
.r-title b{display:block;font:500 16px var(--serif);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.r-title small{display:block;font-size:12px;color:#bfae96;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.r-btn{display:flex;align-items:center;gap:6px;height:38px;min-width:38px;justify-content:center;padding:0 10px;border-radius:999px;border:1px solid rgb(255 255 255/.12);background:rgb(255 255 255/.06);color:#efe4d3;font-size:13.5px;font-weight:500}
.r-btn:hover{background:rgb(255 255 255/.12)}
.r-btn .aa{font:600 15px var(--serif)}
.r-stage{position:relative;flex:1;min-height:0;display:grid;place-items:center;perspective:2200px;perspective-origin:50% 40%}
.r-bottom{position:relative;z-index:3;display:flex;align-items:center;gap:14px;padding:8px 22px 16px;font-size:12.5px;color:#cbbba4;transition:opacity .3s,transform .3s}
.r-bottom input{flex:1;accent-color:#e7a95f;height:4px}
.r-bottom span{min-width:44px;font-variant-numeric:tabular-nums}
.r-bottom #rPage{min-width:130px}
.reader.chrome-off .r-top{opacity:0;transform:translateY(-8px);pointer-events:none}
.reader.chrome-off .r-bottom{opacity:0;transform:translateY(8px);pointer-events:none}

/* the book */
.rbook{position:relative;width:calc(var(--pw) * 2);height:var(--ph);transform-style:preserve-3d;
  transition:transform 1s cubic-bezier(.3,.7,.2,1)}
.rbook.single{width:var(--pw)}
.rb-case{position:absolute;top:-9px;bottom:-11px;left:-12px;right:-12px;border-radius:5px 7px 7px 5px;
  background:linear-gradient(90deg,rgb(0 0 0/.35),rgb(255 255 255/.06) 6%,transparent 20%,transparent 80%,rgb(255 255 255/.05) 94%,rgb(0 0 0/.35)),var(--col);
  box-shadow:0 40px 80px rgb(0 0 0/.6),0 12px 24px rgb(0 0 0/.45),inset 0 0 0 1px rgb(255 255 255/.08);
  transition:left 1s cubic-bezier(.3,.7,.2,1)}
.rb-edges{position:absolute;top:3px;bottom:-5px;width:9px;background:repeating-linear-gradient(90deg,#efe6d2 0 1px,#cfc2a6 1px 2px);box-shadow:0 2px 4px rgb(0 0 0/.3);transition:opacity .6s}
.p-sepia .rb-edges{background:repeating-linear-gradient(90deg,#eadcbc 0 1px,#c9b68f 1px 2px)}
.p-malam .rb-edges{background:repeating-linear-gradient(90deg,#3a342c 0 1px,#2a251f 1px 2px)}
.rb-edges.l{left:-8px;border-radius:3px 0 0 3px}
.rb-edges.r{right:-8px;border-radius:0 3px 3px 0}
.rb-page{position:absolute;top:0;height:100%;width:var(--pw);background:var(--paper);transition:opacity .6s,background .3s}
.rb-page.l{left:0;border-radius:3px 0 0 3px;background:linear-gradient(90deg,rgb(0 0 0/.06),transparent 6%,transparent 82%,rgb(0 0 0/.10) 96%,rgb(0 0 0/.22)),var(--paper)}
.rb-page.r{left:var(--pw);border-radius:0 3px 3px 0;background:linear-gradient(90deg,rgb(0 0 0/.24),rgb(0 0 0/.10) 4%,transparent 18%,transparent 94%,rgb(0 0 0/.06)),var(--paper)}
.rbook.single .rb-page.l,.rbook.single .rb-edges.l{display:none}
.rbook.single .rb-page.r{left:0;border-radius:2px 3px 3px 2px;background:linear-gradient(90deg,rgb(0 0 0/.18),rgb(0 0 0/.05) 3%,transparent 10%),var(--paper)}
.rbook.single .rb-case{left:-6px}
.rb-gutter{position:absolute;top:0;bottom:0;left:calc(var(--pw) - 18px);width:36px;pointer-events:none;z-index:2;
  background:linear-gradient(90deg,transparent,rgb(0 0 0/.07) 35%,rgb(0 0 0/.16) 50%,rgb(0 0 0/.07) 65%,transparent)}
.rbook.single .rb-gutter{display:none}
.rb-viewer{position:absolute;left:0;right:0;top:calc(var(--ph) * .065);bottom:calc(var(--ph) * .075);z-index:1;opacity:0;transition:opacity .45s}
.rbook.ready .rb-viewer{opacity:1}
.rb-viewer,.rb-viewer iframe{color-scheme:light}
.rb-viewer iframe{background:transparent!important}
/* folio (page numbers) */
.rb-folio{position:absolute;bottom:calc(var(--ph) * .028);font:11px var(--serif);color:var(--ink);opacity:.45;z-index:2;pointer-events:none}
.rb-folio.l{left:calc(var(--pw) * .5);transform:translateX(-50%)}
.rb-folio.r{left:calc(var(--pw) * 1.5);transform:translateX(-50%)}
.rbook.single .rb-folio.l{display:none}
.rbook.single .rb-folio.r{left:50%}
.rb-head{position:absolute;top:calc(var(--ph) * .028);left:calc(var(--pw) * 1.5);transform:translateX(-50%);font:italic 10.5px var(--serif);color:var(--ink);opacity:.4;z-index:2;max-width:calc(var(--pw) * .7);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
.rbook.single .rb-head{left:50%}

/* cover that swings open */
.rb-cover{position:absolute;top:-9px;bottom:-11px;left:var(--pw);width:calc(var(--pw) + 12px);transform-origin:0 50%;transform-style:preserve-3d;z-index:6;
  transition:transform 1.15s cubic-bezier(.45,.05,.2,1);pointer-events:none}
.rbook.single .rb-cover{left:-6px;width:calc(var(--pw) + 18px)}
.rb-cover>div{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;border-radius:2px 7px 7px 2px}
.rb-cover .front{background:var(--col) center/cover no-repeat;box-shadow:inset 0 0 0 1px rgb(255 255 255/.08)}
.rb-cover .front::after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(90deg,rgb(0 0 0/.35),rgb(255 255 255/.18) 2%,rgb(0 0 0/.12) 4.5%,transparent 9%,transparent 85%,rgb(255 255 255/.06))}
.rb-cover .back{transform:rotateY(180deg);border-radius:7px 2px 2px 7px;
  background:linear-gradient(270deg,rgb(0 0 0/.3),transparent 8%),linear-gradient(0deg,rgb(0 0 0/.15),rgb(0 0 0/.15)),var(--col)}
.rb-cover .back::after{content:"";position:absolute;inset:10px 12px 12px 10px;background:var(--endpaper,#e9dcc4);border-radius:2px;
  background-image:radial-gradient(circle at 25% 25%,rgb(0 0 0/.05) 2px,transparent 2.5px),radial-gradient(circle at 75% 75%,rgb(0 0 0/.05) 2px,transparent 2.5px);background-size:22px 22px}
.rbook.closed{transform:translateX(calc(var(--pw) * -.5)) rotateX(8deg) scale(.92)}
.rbook.closed .rb-case{left:calc(var(--pw) - 8px)}
.rbook.closed .rb-page.l,.rbook.closed .rb-edges.l,.rbook.closed .rb-gutter{opacity:0}
.rbook.single.closed{transform:rotateX(8deg) scale(.92)}
.rbook.single.closed .rb-case{left:-6px}
.rbook.open .rb-cover{transform:rotateY(-178deg)}
.rbook.single.open .rb-cover{transform:rotateY(-120deg);opacity:0;transition:transform 1.1s cubic-bezier(.45,.05,.2,1),opacity .5s .55s}
.rbook.ready .rb-cover{visibility:hidden}

/* loader */
.rb-load{position:absolute;left:50%;bottom:4%;transform:translateX(-50%);width:min(260px,70vw);text-align:center;color:#d9c8ae;font-size:13px;transition:opacity .3s;z-index:7}
.rb-load p{margin:0 0 8px}
.rb-load .pbar{background:rgb(255 255 255/.12)}
.rb-load .pbar i{background:#e7a95f;width:0}

/* page flip */
.rb-flip{position:absolute;top:0;height:100%;width:var(--pw);z-index:5;transform-style:preserve-3d;pointer-events:none}
.rb-flip.next{left:var(--pw);transform-origin:0 50%;animation:flipNext var(--fd,.62s) cubic-bezier(.45,.1,.3,1) forwards}
.rb-flip.prev{left:0;transform-origin:100% 50%;animation:flipPrev var(--fd,.62s) cubic-bezier(.45,.1,.3,1) forwards}
.rbook.single .rb-flip.next{left:0;animation-name:flipNextSingle}
.rbook.single .rb-flip.prev{left:0;transform-origin:0 50%;animation-name:flipPrevSingle}
.rb-flip>div{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;background:var(--paper)}
.rb-flip .a{background:linear-gradient(90deg,rgb(0 0 0/.16),transparent 12%,transparent 70%,rgb(0 0 0/.05)),var(--paper)}
.rb-flip .b{transform:rotateY(180deg);background:linear-gradient(270deg,rgb(0 0 0/.16),transparent 12%,transparent 70%,rgb(0 0 0/.05)),var(--paper)}
.rb-flip .a::after,.rb-flip .b::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent 40%,rgb(0 0 0/.0));animation:flipShade var(--fd,.62s) ease-in-out forwards}
.rb-flip .lines{position:absolute;inset:7% 11% 8%;opacity:.13;background:repeating-linear-gradient(180deg,var(--ink) 0 1px,transparent 1px 1.55em);font-size:calc(var(--ph) / 46);-webkit-mask:linear-gradient(90deg,#000 0 92%,transparent);mask:linear-gradient(90deg,#000,#000)}
@keyframes flipNext{0%{transform:rotateY(0)}100%{transform:rotateY(-180deg)}}
@keyframes flipPrev{0%{transform:rotateY(0)}100%{transform:rotateY(180deg)}}
@keyframes flipNextSingle{0%{transform:rotateY(0);opacity:1}70%{opacity:1}100%{transform:rotateY(-160deg);opacity:0}}
@keyframes flipPrevSingle{0%{transform:rotateY(-160deg);opacity:0}30%{opacity:1}100%{transform:rotateY(0);opacity:1}}
@keyframes flipShade{0%{background:transparent}50%{background:rgb(0 0 0/.22)}100%{background:transparent}}
.rb-shadow{position:absolute;top:0;height:100%;width:var(--pw);z-index:4;pointer-events:none;animation:castShade var(--fd,.62s) ease-in-out forwards}
@keyframes castShade{0%{opacity:0}45%{opacity:1}100%{opacity:0}}

.rb-hit{position:absolute;top:0;bottom:0;width:9%;z-index:4;cursor:pointer}
.rb-hit.l{left:-4%}.rb-hit.r{right:-4%}
.rb-hit:hover{background:linear-gradient(90deg,rgb(255 255 255/.05),transparent)}
.rb-hit.r:hover{background:linear-gradient(270deg,rgb(255 255 255/.05),transparent)}

/* panels */
.r-panel{position:absolute;z-index:6;top:58px;right:16px;width:min(340px,calc(100% - 32px));max-height:calc(100% - 140px);overflow:auto;
  background:rgb(28 21 16/.96);border:1px solid rgb(255 255 255/.1);border-radius:16px;padding:16px 16px 12px;box-shadow:0 30px 60px rgb(0 0 0/.5);backdrop-filter:blur(10px)}
.r-panel h3{margin:0 0 10px;font:500 18px var(--serif)}
#rTocPanel{left:16px;right:auto}
#rTocList a{display:block;padding:7px 10px;border-radius:8px;color:#e8dcc9;text-decoration:none;font-size:14px;line-height:1.3}
#rTocList a:hover{background:rgb(255 255 255/.07)}
#rTocList a.cur{background:rgb(231 169 95/.18);color:#ffd9a6}
#rTocList a.sub{padding-left:24px;font-size:13px;color:#bfae96}
.r-opt{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:9px 0;border-top:1px solid rgb(255 255 255/.07);font-size:13.5px}
.r-opt:first-of-type{border-top:0}
.r-steps{display:flex;align-items:center;gap:8px}
.r-steps button,.r-seg button{border:1px solid rgb(255 255 255/.14);background:rgb(255 255 255/.05);color:#efe4d3;border-radius:9px;padding:5px 10px;font-size:13px}
.r-steps b{min-width:44px;text-align:center;font-weight:500}
.r-seg{display:flex;gap:4px}
.r-seg button[aria-pressed="true"]{background:#efe4d3;color:#1d1611;border-color:#efe4d3}

@media (max-width:760px){
  .r-top{padding:8px 10px}
  .r-btn span:not(.aa){display:none}
  .r-bottom{padding:6px 14px 12px;gap:10px}
  .r-bottom #rPage{display:none}
  .wide-only{display:none!important}
  .rb-hit{width:16%}
  .rb-hit.l{left:0}.rb-hit.r{right:0}
}
