/* tier colours inside cream cards */
.panel { --t1: #6e4399; --t2: #8a65b5; --t3: #b49bd0; --t4: #d8cce6; --t5: #e8e0f0; }

/* ---------------------------------------------------------------- desk reader */
.desk { --pw: min(calc((100vw - 120px) / 2), calc((100vh - 64px - 150px) * 0.7), 560px); min-height: calc(100vh - 64px); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px 110px; overflow: hidden;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, rgba(255,255,255,.05), transparent 70%),
    repeating-linear-gradient(92deg, rgba(0,0,0,.05) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, #34253f, #241933); }
.book { position: relative; width: calc(var(--pw) * 2); height: calc(var(--pw) / 0.7); perspective: 2400px; transition: width .7s cubic-bezier(.3,.7,.2,1), transform .7s cubic-bezier(.3,.7,.2,1); }
.b-page { position: absolute; top: 0; width: var(--pw); height: 100%; background: #f6f1ea; overflow: hidden; }
.b-left { left: 0; border-radius: 4px 0 0 4px; box-shadow: -18px 26px 50px -22px rgba(0,0,0,.65); }
.b-right { right: 0; border-radius: 0 4px 4px 0; box-shadow: 18px 26px 50px -22px rgba(0,0,0,.65); }
.b-page img, .b-flip img { width: 100%; height: 100%; display: block; mix-blend-mode: multiply; user-select: none; }
.b-page.blank { background: #efe8de; }
.b-num { display: none; }
.b-gutter { position: absolute; top: 0; bottom: 0; left: 50%; width: 70px; transform: translateX(-50%); pointer-events: none; z-index: 3;
  background: linear-gradient(90deg, transparent 0%, rgba(60,40,30,.10) 35%, rgba(40,25,20,.28) 49%, rgba(40,25,20,.28) 51%, rgba(60,40,30,.10) 65%, transparent 100%); }
.b-left::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.05), transparent 12%, transparent 88%, rgba(0,0,0,.05)); pointer-events: none; }
.b-right::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.06), transparent 10%); pointer-events: none; }
/* stacked page edges on each side: thicker on the side with more pages */
.b-edges { --t: 7; position: absolute; top: 3px; bottom: 3px; width: calc(var(--t) * 1px); z-index: 0;
  background: repeating-linear-gradient(90deg, #e9e1d5 0 1px, #d6ccbe 1px 2px); transition: width .4s; }
.b-edges-l { right: calc(100% - 1px); border-radius: 3px 0 0 3px; }
.b-edges-r { left: calc(100% - 1px); border-radius: 0 3px 3px 0; }
/* page turn */
.b-flip { position: absolute; top: 0; width: var(--pw); height: 100%; z-index: 4; transform-style: preserve-3d; pointer-events: none; display: none; }
.b-flip.go-next { display: block; left: 50%; transform-origin: left center; }
.b-flip.go-prev { display: block; left: 0; transform-origin: right center; }
.b-flip.go-next.run { transition: transform .6s cubic-bezier(.45,.05,.3,1); transform: rotateY(-180deg); }
.b-flip.go-prev.run { transition: transform .6s cubic-bezier(.45,.05,.3,1); transform: rotateY(180deg); }
.f-front, .f-back { position: absolute; inset: 0; background: #f6f1ea; backface-visibility: hidden; overflow: hidden; }
.f-back { transform: rotateY(180deg); }
.b-flip.run .f-front::after, .b-flip.run .f-back::after { content: ''; position: absolute; inset: 0; animation: shade .6s ease; pointer-events: none; }
@keyframes shade { 0% { background: rgba(0,0,0,0); } 50% { background: rgba(0,0,0,.18); } 100% { background: rgba(0,0,0,0); } }
/* the cover */
.b-cover { position: absolute; top: 0; left: 50%; width: var(--pw); height: 100%; padding: 0; border: 0; background: none; cursor: pointer; z-index: 6; transform-origin: left center; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.4,.1,.2,1), opacity .2s .75s; }
.b-cover img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px 6px 6px 2px; display: block; backface-visibility: hidden; box-shadow: 0 0 0 1px rgba(0,0,0,.15), 24px 30px 60px -20px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.2); }
.b-cover-in { position: absolute; inset: 0; background: #ede5d9; transform: rotateY(180deg); backface-visibility: hidden; border-radius: 6px 2px 2px 6px; }
.book.closed { width: var(--pw); }
.book.closed .b-cover { left: 0; }
.book.closed .b-page, .book.closed .b-edges, .book.closed .b-gutter, .book.closed .b-hit { opacity: 0; }
.book.closed .b-cover:hover img { transform: translateY(-4px) rotate(-.4deg); }
.b-cover img { transition: transform .3s ease; }
.book:not(.closed) .b-cover { transform: rotateY(-180deg); opacity: 0; pointer-events: none; }
.book.opening .b-page, .book.opening .b-edges { animation: appear .5s .45s both; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
/* click zones */
.b-hit { position: absolute; top: 0; bottom: 0; width: 22%; border: 0; background: transparent; cursor: pointer; z-index: 5; }
.b-hit-l { left: 0; cursor: w-resize; } .b-hit-r { right: 0; cursor: e-resize; }
.d-hint { color: #cdbfdc; font-size: 14px; margin: 26px 0 0; letter-spacing: -.005em; }
/* toolbar */
.d-bar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 99px; background: rgba(28,19,38,.88); backdrop-filter: blur(10px); box-shadow: 0 0 0 1px rgba(245,240,233,.12), 0 20px 40px -14px rgba(0,0,0,.7); z-index: 30; max-width: calc(100vw - 24px); }
.d-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 0; border-radius: 99px; background: transparent; color: #efe7f6; font: 500 13.5px var(--body); cursor: pointer; white-space: nowrap; }
.d-btn.icon { width: 38px; padding: 0; justify-content: center; }
.d-btn:hover { background: rgba(245,240,233,.1); }
.d-sep { width: 1px; height: 20px; background: rgba(245,240,233,.16); margin: 0 4px; }
.d-page { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #bcaccb; }
.d-page input { width: 50px; text-align: center; font: 500 13px var(--mono); color: #fff; background: rgba(0,0,0,.25); border: 1px solid rgba(245,240,233,.16); border-radius: 99px; padding: 7px 2px; }
.d-chap { font-size: 13px; color: #bcaccb; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; }
/* drawer */
.d-drawer { position: fixed; top: 80px; left: 20px; bottom: 90px; width: 330px; background: #f5f0e9; color: #2a1d3a; border-radius: 18px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.7); z-index: 31; display: flex; flex-direction: column; overflow: hidden; }
.dr-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px 16px; border-bottom: 1px solid #e4dacd; }
.dr-tabs { display: flex; gap: 4px; background: #ebe3d8; padding: 3px; border-radius: 99px; }
.dr-tabs button { border: 0; background: transparent; padding: 7px 14px; border-radius: 99px; font: 500 13px var(--body); color: #6b5d78; cursor: pointer; }
.dr-tabs button[aria-pressed="true"] { background: #fff; color: #2a1d3a; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.dr-x { border: 0; background: none; font-size: 22px; color: #7a6c86; cursor: pointer; width: 34px; height: 34px; border-radius: 99px; }
.dr-x:hover { background: #ebe3d8; }
.dr-toc, .dr-search { overflow-y: auto; padding: 8px; flex: 1; }
.dr-toc a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: #3b2f48; font-size: 14px; line-height: 1.35; }
.dr-toc a span { color: #9a8ea5; font: 500 12px var(--mono); }
.dr-toc a:hover { background: #ebe3d8; }
.dr-toc a.on { background: #2a1d3a; color: #f5f0e9; }
.dr-toc a.on span { color: #c9b2e8; }
.dr-toc a.part { color: #6e4399; font-weight: 600; margin-top: 12px; }
.dr-search input { width: 100%; font: 15px var(--body); padding: 11px 16px; border-radius: 99px; border: 1px solid #ddd2c4; background: #fff; color: #2a1d3a; margin: 6px 0 4px; }
.dr-search input:focus { outline: none; border-color: #6e4399; box-shadow: 0 0 0 3px rgba(110,67,153,.15); }
.dr-search p { font-size: 13px; color: #7a6c86; margin: 6px 8px; }
.dr-search a { display: block; padding: 10px; border-radius: 10px; cursor: pointer; font-size: 13.5px; border-top: 1px solid #ebe3d8; }
.dr-search a:hover { background: #ebe3d8; }
.dr-search a b { font-weight: 600; margin-right: 6px; }
.dr-ch { color: #7a6c86; }
.dr-snip { display: block; color: #4a3c58; margin-top: 3px; line-height: 1.45; }
.dr-search mark { background: #c9b2e8; color: #2a1d3a; border-radius: 3px; padding: 0 2px; }
/* phone and narrow screens: one page at a time */
@media (max-width: 899px) {
  .desk { --pw: min(calc(100vw - 40px), calc((100vh - 64px - 140px) * 0.7)); padding: 24px 20px 100px; }
  .book, .book.closed { width: var(--pw); }
  .b-left, .b-edges-l, .b-gutter { display: none; }
  .b-right { left: 0; right: auto; border-radius: 4px; }
  .b-cover { left: 0; }
  .book.slide-next .b-right { animation: slideL .22s ease; } .book.slide-prev .b-right { animation: slideR .22s ease; }
  @keyframes slideL { to { transform: translateX(-24px); opacity: .2; } } @keyframes slideR { to { transform: translateX(24px); opacity: .2; } }
  .b-hit { width: 40%; }
  .d-chap, .d-btn span { display: none; }
  .d-btn { padding: 0 11px; }
  .d-drawer { left: 10px; right: 10px; width: auto; top: 74px; }
}

[hidden] { display: none !important; }

/* zoom */
.desk.zoomed { overflow: auto; height: calc(100vh - 64px); justify-content: flex-start; align-items: flex-start; cursor: grab; padding: 40px 60px 140px; }
.desk.zoomed .book { margin: 0 auto; }
.desk.zoomed.dragging { cursor: grabbing; user-select: none; }
.desk.zoomed .b-hit { pointer-events: none; }
.desk.zoomed .d-hint { display: none; }
.d-zlevel { min-width: 58px; justify-content: center; font-variant-numeric: tabular-nums; }
/* notes panel */
.desk.with-notes { --pw: min(calc((100vw - 120px - 380px) / 2), calc((100vh - 64px - 150px) * 0.7), 560px); padding-right: 400px; }
.d-notes { position: fixed; top: 80px; right: 20px; bottom: 90px; width: 360px; z-index: 29; display: flex; flex-direction: column; border-radius: 18px; background: rgba(24,18,52,.94); backdrop-filter: blur(10px); box-shadow: 0 0 0 1px rgba(206,194,255,.16), 0 30px 70px -20px rgba(0,0,0,.7); color: #e9e4ff; overflow: hidden; }
.dn-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 12px; border-bottom: 1px solid rgba(206,194,255,.12); }
.dn-head b { font-size: 16px; color: #fff; }
.d-notes .dr-x { color: #c9c3ec; }
.dn-body { overflow-y: auto; padding: 6px 20px 24px; scrollbar-width: thin; }
.dn-body h3 { font-size: 14px; color: #c6b8ff; margin: 18px 0 10px; font-weight: 600; }
.dn-notes { list-style: none; padding: 0; margin: 0; }
.dn-notes li { display: grid; grid-template-columns: 28px 1fr; gap: 8px; font-size: 14.5px; line-height: 1.55; color: #ddd8f5; padding: 10px 0; border-top: 1px solid rgba(206,194,255,.08); }
.dn-notes li:first-child { border-top: 0; }
.dn-n { color: #f0abfc; font-weight: 700; font-variant-numeric: tabular-nums; }
.dn-notes i { color: #fff; }
.dn-links { display: grid; gap: 8px; }
.dn-links a { display: block; padding: 11px 14px; border-radius: 12px; background: rgba(167,139,250,.12); color: #fff; text-decoration: none; font-size: 15px; box-shadow: inset 0 0 0 1px rgba(206,194,255,.14); }
.dn-links a:hover { background: rgba(167,139,250,.22); }
.dn-empty { color: #a9a3cf; font-size: 15px; margin-top: 16px; }
@media (max-width: 1279px) { .d-notes { left: 10px; right: 10px; width: auto; top: auto; bottom: 86px; max-height: 55vh; } }
.desk.zoomed.with-notes { padding-right: 420px; }
@media (max-width: 899px) { #d-zin, #d-zout, #d-zlevel, .d-bar .d-sep:nth-of-type(3) { display: none; } .d-bar .d-chap { display: none; } }
