/* reader */
body.reader { background: #07060b; overscroll-behavior-y: none; }
.r-bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px clamp(10px, 3vw, 24px); min-height: 60px;
  background: rgba(10, 8, 16, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #221c33;
  transition: transform .3s ease;
}
.r-bar.hide { transform: translateY(-105%); }
.r-title { min-width: 0; text-align: center; line-height: 1.35; }
.r-title b { display: block; font-family: var(--display); font-size: 17px; color: #f1e8d6; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-title span { font-size: 13px; color: var(--mist); }
.icon-btn {
  min-width: 44px; height: 44px; padding: 0 10px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--ash); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 14px var(--body); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { color: var(--gold-hi); border-color: #2f2745; }
.icon-btn svg { width: 22px; height: 22px; }
.r-tools { display: flex; gap: 4px; }
.mode-label { display: none; }
@media (min-width: 700px) { .mode-label { display: inline; } }

.r-progress { position: fixed; inset: auto 0 0 0; height: 3px; z-index: 21; background: rgba(164, 107, 255, .14); }
.r-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .25s; }
html[dir="rtl"] .r-progress i { margin-inline-start: 0; }

/* pages */
.r-pages { max-width: 900px; margin: 0 auto; padding: 68px 0 0; display: flex; flex-direction: column; gap: 6px; }
.r-page { position: relative; margin: 0; background: #120f1b; }
.r-page img {
  width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-user-drag: none; cursor: zoom-in;
}
.r-page figcaption { position: absolute; inset-block-end: 8px; inset-inline-start: 10px; font-size: 12px; color: #fff; background: rgba(0, 0, 0, .45); padding: 0 8px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.r-page:hover figcaption { opacity: .8; }

/* paged mode */
body.paged { overflow: hidden; }
body.paged .r-pages { max-width: none; height: 100svh; padding: 0; display: block; position: relative; }
body.paged .r-page { display: none; position: absolute; inset: 62px 0 4px 0; background: transparent; }
body.paged .r-page.current { display: flex; align-items: center; justify-content: center; }
body.paged .r-page img { width: auto; max-width: 100%; height: auto; max-height: calc(100svh - 66px); object-fit: contain; }
body.paged .r-end { display: none; }
body.paged.at-end .r-end { display: flex; position: fixed; inset: 0; z-index: 5; overflow: auto; background: #07060b; }
body.paged.at-end .r-page.current { display: none; }
.tap { display: none; }
body.paged .tap { display: block; position: fixed; top: 60px; bottom: 0; width: 34%; z-index: 4; background: transparent; border: 0; cursor: pointer; }
body.paged .tap-next { left: 0; }
body.paged .tap-prev { right: 0; }

/* end of chapter */
.r-end { flex-direction: column; align-items: center; text-align: center; gap: 18px; padding: 72px 20px 96px; display: flex; }
.r-end .seal { width: min(70vw, 360px); }
.r-end h2 { margin: 6px 0 0; font-family: var(--display); color: #f1e8d6; font-size: clamp(28px, 4vw, 38px); line-height: 1.35; }
.r-end p { margin: 0; color: var(--ash); max-width: 46ch; }
.r-end .row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 10px; }
.r-end-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; margin: auto; }

/* resume toast */
.toast {
  position: fixed; z-index: 30; inset-inline: 12px; bottom: 18px; margin: 0 auto; max-width: 480px;
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 10px 10px 10px 16px; padding-inline-start: 18px; border-radius: 14px;
  background: #1a1528; border: 1px solid #3a2f55; box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
  font-size: 15px; color: #ece6f5;
}
.toast[hidden] { display: none; }
.toast .btn { min-height: 40px; padding: 6px 18px; font-size: 15px; }

/* zoom viewer */
.zoom { position: fixed; inset: 0; z-index: 50; background: rgba(5, 4, 8, .97); display: none; }
.zoom.open { display: block; }
.zoom-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.zoom-scroll img { width: 100%; max-width: 1100px; margin: 0 auto; height: auto; cursor: zoom-in; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.zoom.z2 .zoom-scroll img { width: 220%; max-width: none; cursor: zoom-out; }
@media (min-width: 900px) { .zoom.z2 .zoom-scroll img { width: 2110px; } }
.zoom-bar { position: fixed; z-index: 51; top: 10px; inset-inline-end: 10px; display: flex; gap: 6px; }
.zoom-bar .icon-btn { background: rgba(26, 21, 40, .9); border-color: #3a2f55; }
.zoom-hint { position: fixed; z-index: 51; bottom: 14px; left: 50%; transform: translateX(-50%); margin: 0; padding: 4px 14px; border-radius: 999px; background: rgba(13, 11, 20, .85); font-size: 13px; color: var(--ash); pointer-events: none; white-space: nowrap; }
.zoom .hd { position: fixed; z-index: 51; top: 18px; inset-inline-start: 14px; font-size: 12px; color: var(--gold); border: 1px solid #5a4a28; border-radius: 6px; padding: 0 6px; }

/* ---------- pages built from text + vector (cover, credits) ---------- */
.r-html .sheet { container-type: inline-size; position: relative; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; }
body.paged .r-html .sheet { width: min(100%, calc((100svh - 66px) * 2 / 3)); }

/* cover */
.cover { background: #0a0811; color: #f1e8d6; }
.cover .art { position: absolute; inset: 0 0 auto 0; width: 100%; height: 74.9%; object-fit: cover; object-position: top; cursor: default; }
.cover::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 8, 17, 0) 50%, rgba(10, 8, 17, .65) 62%, #0a0811 75%); }
.cover .label { text-shadow: 0 0 2cqw rgba(0,0,0,.95), 0 0 .6cqw #000; position: absolute; z-index: 1; top: 4.6%; inset-inline-start: 7%; text-align: center; font-family: var(--display); font-weight: 300; font-size: 5.6cqw; line-height: 1.25; color: #ecd7ad; }
.cover .label i { display: block; margin: 1.6cqw auto 0; width: 22cqw; height: 1px; background: linear-gradient(90deg, transparent, #b98cff, transparent); position: relative; }
.cover .label i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 2.2cqw; height: 2.2cqw; transform: translate(-50%, -50%) rotate(45deg); background: #c79bff; box-shadow: 0 0 2cqw #a46bff; }
.cover .title { position: absolute; z-index: 1; inset: auto 0 6.5% 0; display: flex; flex-direction: column; align-items: center; gap: 1.4cqw; }
.cover .title img { width: 80%; height: auto; cursor: default; }
.cover .title b { font-family: var(--display); font-weight: 700; font-size: 7.6cqw; line-height: 1.3; color: #c9a6ff; text-shadow: 0 0 4cqw rgba(164, 107, 255, .45); }

/* credits */
.credits { background: #efe6d2; color: #2b2116; text-align: center; font-family: var(--body); }
.credits::before { content: ""; position: absolute; inset: 3.2cqw; border: .45cqw solid #b08a4a; pointer-events: none; }
.credits::after { content: ""; position: absolute; inset: 4.6cqw; border: .15cqw solid #c9ab72; pointer-events: none; }
.credits .corner { position: absolute; width: 11cqw; height: 11cqw; color: #a9844a; }
.credits .corner.tl { top: 2cqw; left: 2cqw; }
.credits .corner.tr { top: 2cqw; right: 2cqw; transform: scaleX(-1); }
.credits .corner.bl { bottom: 2cqw; left: 2cqw; transform: scaleY(-1); }
.credits .corner.br { bottom: 2cqw; right: 2cqw; transform: scale(-1, -1); }
.credits .inner { position: absolute; inset: 8cqw 10cqw; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3.6cqw; }
.credits .block { display: flex; flex-direction: column; align-items: center; gap: .9cqw; }
.credits .logo { width: 54%; height: auto; cursor: default; }
.credits .rule { width: 46cqw; height: 2cqw; color: #a9844a; }
.credits .ch { font-family: var(--display); font-weight: 300; font-size: 4.4cqw; color: #7a5a26; }
.credits .role { font-size: 3.3cqw; color: #4a3b26; margin-top: 1.2cqw; }
.credits .name { font-family: var(--display); font-weight: 700; font-size: 5cqw; color: #8a6224; line-height: 1.2; }
.credits .legal { font-size: 2.75cqw; line-height: 1.6; color: #3d2f1d; max-width: 66cqw; }
.credits .ed { font-size: 3cqw; color: #8a6224; }
.credits .en { font-family: "Markazi Text", var(--display); direction: ltr; }
.credits .en .big { font-family: var(--display); font-weight: 700; font-size: 6.6cqw; letter-spacing: .06em; color: #1f170e; line-height: 1.1; }
.credits .en .sub { font-size: 3.4cqw; letter-spacing: .08em; color: #8a6224; }
.credits .en .legal { font-size: 2.45cqw; }
.credits .crest { width: 9cqw; height: auto; cursor: default; }
.cover .label.end { inset-inline-start: auto; inset-inline-end: 7%; }
