/* Imam & Science. — reader for articles and book chapters (scroll or swipe pages) */
:root {
	--r-font: var(--font-ui); --r-size: 19px; --r-lh: 1.7; --r-weight: 400; --r-align: start; --r-liga: common-ligatures;
	--r-ar: 1.3; --measure: 1180px; --page-bg: var(--bg); --page-ink: var(--text);
}
.is-reader { background: var(--page-bg); }
.progress { position: fixed; left: 0; right: 0; top: 0; z-index: 80; height: 2.5px; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--green); }

/* Layout (scroll mode) */
.rd { padding-bottom: 40px; }
.rd__flow { width: 100%; max-width: calc(var(--measure) + var(--gutter) * 2); margin-inline: auto; padding-inline: var(--gutter); }
.rd__head { text-align: center; padding: clamp(30px, 5vw, 60px) 0 clamp(22px, 3vw, 30px); }
.rd__tag { display: inline-flex; padding: 5px 12px; border-radius: 999px; background: var(--green-soft); color: var(--green-ink); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; margin-top: 16px; }
.rd__title { font-size: clamp(32px, 5.4vw, 56px); letter-spacing: -.045em; line-height: 1.06; margin: 16px auto 0; text-wrap: balance; font-weight: 790; }
.rd__dek { margin: 16px auto 0; max-width: 600px; font-size: clamp(17px, 2vw, 19.5px); line-height: 1.6; color: var(--muted); }
.rd__meta { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px 16px; margin-top: 20px; font-size: 14px; font-weight: 600; color: var(--muted); }
.rd__meta span { display: inline-flex; align-items: center; gap: 6px; }
.rd__meta .icon { width: 16px; height: 16px; }
.rd__by { color: var(--ink); font-weight: 700; }
.rd__by img { width: 26px; height: 26px; border-radius: 7px; }
.rd__head--ch { padding-top: clamp(28px, 5vw, 56px); }
.rd__book { display: inline-block; font-size: 14px; font-weight: 700; color: var(--green-ink); }
.rd__chn { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.rd__title--ch { font-size: clamp(30px, 4.6vw, 48px); margin-top: 12px; }

.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 24px; padding: 10px 10px 10px 16px; border-radius: 16px; background: var(--fill); font-size: 14.5px; color: var(--muted); }
.resume span { display: flex; align-items: center; gap: 8px; }
.resume .icon { color: var(--green); }
.resume strong { color: var(--ink); }

/* Prose */
.prose { font-family: var(--r-font); font-size: var(--r-size); line-height: var(--r-lh); font-weight: var(--r-weight); color: var(--page-ink); overflow-wrap: break-word; text-align: var(--r-align); font-variant-ligatures: var(--r-liga); hyphens: auto; -webkit-hyphens: auto; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-family: var(--font-ui); font-size: 1.45em; line-height: 1.22; margin-top: 1.9em; letter-spacing: -.03em; text-align: start; }
.prose h3 { font-family: var(--font-ui); font-size: 1.18em; line-height: 1.3; margin-top: 1.6em; letter-spacing: -.02em; text-align: start; }
.prose h4, .prose h5 { font-family: var(--font-ui); font-size: 1.02em; margin-top: 1.4em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: .6em; }
.prose a { color: var(--green-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose strong { color: var(--ink); font-weight: max(650, calc(var(--r-weight) + 250)); }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--green); }
.prose blockquote, .prose .quote { margin: 1.4em 0 0; padding: 1.05em 1.2em; border-radius: 18px; background: var(--fill); font-style: normal; color: var(--page-ink); }
.prose blockquote > * + * { margin-top: .6em; }
.prose blockquote cite, .prose .quote cite { display: block; font-family: var(--font-ui); font-size: 14px; font-style: normal; font-weight: 700; color: var(--green-ink); margin-top: .7em; }
.prose .quote .ar { display: block; text-align: right; direction: rtl; }
.prose .quote .en { display: block; margin-top: .6em; }
.prose [dir="rtl"], .prose .ar, .prose [lang="ar"], .prose [lang="ur"] { font-family: var(--font-ar); font-size: calc(var(--r-ar) * 1em); line-height: 1.9; text-align: right; direction: rtl; }
.prose [lang="ur"] { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", var(--font-ar); line-height: 2.2; }
.prose span.ar, .prose span[lang="ar"] { font-size: calc(var(--r-ar) * .95em); }
.prose .lead { font-size: 1.1em; color: var(--ink); }
.prose .lead::first-letter { float: left; font-size: 3.2em; line-height: .9; font-weight: 800; padding: .06em .1em 0 0; color: var(--green); font-family: var(--font-ui); }
.prose .note { padding: 1em 1.15em; border-radius: 16px; background: var(--green-soft); font-family: var(--font-ui); font-size: .9em; line-height: 1.6; }
.prose .ref { font-size: .8em; color: var(--faint); font-family: var(--font-ui); line-height: 1.6; }
.prose hr { border: 0; height: .5px; background: var(--hair-2); margin-block: 2em; }
.prose img { border-radius: 14px; margin-inline: auto; }
.prose figure { margin-inline: 0; }
.prose figcaption { font-family: var(--font-ui); font-size: 14px; color: var(--faint); margin-top: 8px; text-align: center; }
.prose table { width: 100%; border-collapse: collapse; font-size: .88em; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 8px 10px; border-bottom: .5px solid var(--hair-2); text-align: start; }
.prose sup a { text-decoration: none; font-weight: 700; padding: 0 2px; }
.prose mark.hit { background: rgba(255, 204, 0, .38); color: inherit; border-radius: 3px; }
.prose mark.hit.is-cur { background: #ffcc00; color: #000; }
.prose .is-speaking { background: var(--green-soft); border-radius: 8px; box-shadow: 0 0 0 6px var(--green-soft); }

/* Focus mode: only the paragraph you are reading is bright */
.is-focus .prose > * { opacity: .22; transition: opacity .35s var(--ease); }
.is-focus .prose > .is-focused { opacity: 1; }
.is-focus .rd__head, .is-focus .rd__end, .is-focus .more { opacity: .3; }

/* End of article / chapter */
.rd__end { margin-top: 44px; padding-top: 26px; border-top: .5px solid var(--hair-2); display: grid; gap: 22px; }
.fb { text-align: center; padding: 22px; border-radius: 20px; background: var(--fill); }
.fb__q { font-weight: 750; color: var(--ink); font-size: 17px; }
.fb__btns { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.fb__btns .pillbtn { background: var(--surface); }
.fb__thanks { margin-top: 10px; color: var(--muted); font-size: 15px; }
.fb__thanks a { color: var(--green-ink); font-weight: 700; }
.fix { text-align: center; }
.rd__share { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; }
.rd__share p { font-weight: 700; color: var(--ink); }
.share { display: flex; gap: 6px; }
.share a, .share button { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--fill); color: var(--ink); transition: background-color .2s; }
.share a:hover, .share button:hover { background: var(--fill-2); }
.share .icon { width: 18px; height: 18px; }
.next { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 14px; padding: 20px 22px; border-radius: 20px; background: var(--fill); }
.next:hover { background: var(--fill-2); }
.next__k { font-size: 12.5px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; color: var(--green-ink); }
.next__t { grid-column: 1; font-size: 20px; font-weight: 750; letter-spacing: -.02em; color: var(--ink); line-height: 1.3; }
.next > .icon { grid-row: 1 / span 2; grid-column: 2; width: 24px; height: 24px; color: var(--green-ink); }
.done { text-align: center; padding: 26px; border-radius: 20px; background: var(--fill); display: grid; gap: 12px; justify-items: center; }
.done__i { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--green); color: var(--on-green); }
.prevlink { display: inline-flex; align-items: center; gap: 8px; justify-self: start; font-size: 14.5px; font-weight: 650; color: var(--muted); }
.prevlink:hover { color: var(--ink); }
.more .card { background: var(--surface); }

/* Bottom reading bar */
.rbar { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 70; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 999px; background: var(--bar); -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); box-shadow: var(--float); transition: transform .4s cubic-bezier(.16, 1, .3, 1), opacity .3s ease; }
.rbar.is-hidden { transform: translate(-50%, calc(100% + 50px + env(safe-area-inset-bottom, 0px))); opacity: 0; pointer-events: none; }
.rbar button { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text); transition: background-color .2s, color .2s; }
.rbar button:hover { background: var(--fill); }
.rbar button[aria-pressed="true"], .rbar button.is-on { color: var(--green-ink); }
.rbar button[aria-pressed="true"] .icon { fill: currentColor; }
.rbar .icon { width: 21px; height: 21px; }
.rbar__pos { min-width: 58px; padding: 0 6px; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.rbar__aa { width: auto !important; padding: 0 16px; border-radius: 999px !important; background: var(--fill) !important; font-weight: 750; font-size: 16px; letter-spacing: -.02em; color: var(--ink) !important; }
body.is-reader .footer__base { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }

/* Voice and find bars */
.vbar, .fbar { position: fixed; left: 50%; z-index: 72; transform: translateX(-50%); width: min(520px, calc(100% - 20px)); display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 22px; background: var(--bar); -webkit-backdrop-filter: saturate(1.8) blur(20px); backdrop-filter: saturate(1.8) blur(20px); box-shadow: var(--float); animation: barin .45s var(--spring); }
@keyframes barin { from { opacity: 0; transform: translate(-50%, 16px); } }
.vbar { bottom: calc(72px + env(safe-area-inset-bottom)); }
.vbar__play { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--green); color: var(--on-green); flex: none; }
.vbar__play .icon { width: 18px; height: 18px; }
.vbar .i-play { display: none; }
.vbar.is-paused .i-play { display: block; }
.vbar.is-paused .i-pause { display: none; }
.vbar__txt { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); line-height: 1.3; }
.vbar__txt strong { display: block; color: var(--ink); font-size: 14.5px; }
.vbar__rate { min-width: 46px; height: 34px; padding: 0 10px; border-radius: 999px; background: var(--fill); font-weight: 750; font-size: 14px; font-variant-numeric: tabular-nums; }
.fbar { top: calc(10px + env(safe-area-inset-top)); padding-left: 14px; }
.fbar > .icon { color: var(--faint); width: 18px; height: 18px; }
.fbar input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; outline: none; font-size: 16px; }
.fbar__n { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.fbar__done { color: var(--green-ink); font-weight: 750; padding: 8px 10px; }

/* Control center ---------------------------------------------------------- */
.cc .sheet__panel { width: min(400px, 100%); padding-inline: 18px; overflow-x: hidden; }
.cc__label { text-align: center; font-size: 13.5px; font-weight: 650; color: var(--muted); margin: 2px 0 14px; }
.cc__label--left { text-align: left; margin: 18px 4px 8px; text-transform: none; }
.cc__pages { --n: 2; --i: 0; display: flex; width: calc(100% * var(--n)); transform: translateX(calc(-100% / var(--n) * var(--i))); transition: transform .5s var(--spring); align-items: flex-start; }
.cc__page { width: calc(100% / var(--n)); flex: none; padding-inline: 1px; transition: visibility 0s, max-height 0s; }
.cc__pages:not([data-at="main"]) [data-cc-page="main"], .cc__pages:not([data-at="text"]) [data-cc-page="text"], .cc__pages:not([data-at="sounds"]) [data-cc-page="sounds"] { visibility: hidden; max-height: 0; overflow: hidden; transition: visibility 0s .5s, max-height 0s .5s; }
.cc__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: 88px 92px 92px 92px; gap: 10px 12px; align-items: start; }
.cc__grid--pdf { grid-template-rows: 88px 92px 92px 92px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--ink); }
.tile__b { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--surface); transition: background-color .2s, color .2s, transform .2s var(--ease); }
.tile:active .tile__b { transform: scale(.94); }
.tile.is-on .tile__b, .tile[aria-pressed="true"] .tile__b { background: var(--green); color: var(--on-green); }
.tile__t { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tile .icon { width: 23px; height: 23px; }
.tile--theme { grid-column: 1 / span 3; flex-direction: row; justify-content: space-around; height: 60px; padding: 0 8px; border-radius: 999px; background: var(--surface); }
.tile--text { grid-column: 1 / span 2; grid-row: 2 / span 2; height: calc(92px * 2 - 12px); align-items: flex-start; justify-content: space-between; padding: 16px; border-radius: 24px; background: var(--surface); text-align: left; }
.tile--wide { grid-column: 1 / span 2; grid-row: 2; height: 70px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 22px; background: var(--surface); text-align: left; }
.tile--wide .tile__b { width: auto; height: auto; background: none; }
.tile__aa .icon { width: 30px; height: 30px; }
.tile__l strong { display: block; font-size: 16px; }
.tile__l span { font-size: 13.5px; color: var(--muted); }
.cc__grid > [data-cc-act="voice"] { grid-area: 1 / 4; }
.cc__grid > [data-cc-act="find"] { grid-area: 2 / 3; }
.cc__grid > [data-cc-act="mode"] { grid-area: 2 / 4; }
.cc__grid > [data-vs="size"] { grid-area: 3 / 3 / span 2; }
.cc__grid > [data-vs="bright"] { grid-area: 3 / 4 / span 2; }
.cc__grid > [data-cc-act="offline"] { grid-area: 4 / 1; }
.cc__grid > [data-cc-act="focus"] { grid-area: 4 / 2; }
.cc__grid--pdf > [data-cc-act="find"] { grid-area: 1 / 4; }
.cc__grid--pdf > [data-cc-act="mode"] { grid-area: 2 / 1 / auto / span 2; }
.cc__grid--pdf > [data-cc-act="spread"] { grid-area: 3 / 1; }
.cc__grid--pdf > [data-cc-act="awake"] { grid-area: 3 / 2; }
.cc__grid--pdf > [data-cc-act="offline"] { grid-area: 4 / 1; }
.cc__grid--pdf > [data-vs="zoom"] { grid-area: 2 / 3 / span 3; }
.cc__grid--pdf > [data-vs="bright"] { grid-area: 2 / 4 / span 3; }
.cc__under { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.cc__under span:first-child { grid-column: 3; }

/* Theme dots */
.dot--light, .dot--paper, .dot--gray, .dot--dark, .dot--custom { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; transition: box-shadow .2s, transform .2s var(--ease); }
.dot--light { background: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.dot--paper { background: #e9cf96; }
.dot--gray { background: #5a5a5d; }
.dot--dark { background: #111; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.dot--custom { position: relative; color: var(--ink); width: 34px; height: 34px; background: var(--fill); }
.dot--custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
[data-theme-set][aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--green); transform: scale(1.06); }
.dot--light[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.15), 0 0 0 2px var(--surface), 0 0 0 4px var(--green); }

/* Vertical sliders (iOS Control Center style) */
.vs { position: relative; width: 62px; height: 100%; min-height: 160px; justify-self: center; border-radius: 32px; background: var(--surface); overflow: hidden; touch-action: none; cursor: ns-resize; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 15px; color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; box-shadow: 0 1px 3px rgba(0, 0, 0, .06); transition: transform .18s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .18s ease; }
.vs:active, .vs.is-dragging { transform: scale(0.965); box-shadow: 0 0 0 2px var(--green), 0 8px 24px -6px rgba(0, 0, 0, .2); }
.vs__fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--fill-3); transition: height .2s cubic-bezier(0.16, 1, 0.3, 1); will-change: height; pointer-events: none; }
.vs.is-dragging .vs__fill, .vs:active .vs__fill { transition: none !important; }
.vs .icon, .vs .vs__glyph { position: relative; z-index: 2; pointer-events: none; transition: transform .15s ease; }
.vs.is-dragging .icon, .vs.is-dragging .vs__glyph { transform: scale(1.12); }
.vs:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Text page */
.fcards { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px; margin: 0 -2px; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; cursor: grab; user-select: none; scrollbar-width: thin; scrollbar-color: var(--hair-2) transparent; }
.fcards.is-dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; }
.fcards.is-dragging .fcard { pointer-events: none; }
@media (hover: hover) {
	.fcards::-webkit-scrollbar { height: 4px; }
	.fcards::-webkit-scrollbar-track { background: transparent; }
	.fcards::-webkit-scrollbar-thumb { background: var(--hair-2); border-radius: 4px; }
	.fcards::-webkit-scrollbar-thumb:hover { background: var(--faint); }
}
.fcard { flex: 0 0 calc((100% - 24px) / 4); scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px 10px; border-radius: 16px; background: var(--surface); color: var(--ink); }
.fcard span { font-size: 24px; line-height: 1.1; }
.fcard small { font-size: 12px; color: var(--muted); font-family: var(--font-ui); }
.fcard[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--green); }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; cursor: default; }
.row__i { color: var(--muted); display: grid; place-items: center; }
.row__i .icon { width: 19px; height: 19px; }
.row__l { flex: 1; min-width: 0; font-weight: 650; font-size: 15px; color: var(--ink); }
.row__l small { display: block; font-weight: 500; font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row--solo { background: var(--surface); border-radius: var(--r); margin-top: 14px; }
.step { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border-radius: 10px; background: var(--fill); }
.step button { display: grid; place-items: center; width: 32px; height: 30px; border-radius: 8px; color: var(--ink); }
.step button:hover { background: var(--fill-2); }
.step output { min-width: 58px; text-align: center; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.switch { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 31px; background: var(--fill-3); position: relative; cursor: pointer; transition: background-color .25s; flex: none; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .3s var(--spring); }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.acards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acard { text-align: left; padding: 12px 14px; border-radius: 16px; background: var(--surface); color: var(--ink); }
.acard strong { display: block; font-size: 15px; }
.acard small { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 3px; }
.acard[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--green); }
.backpill { position: sticky; bottom: 4px; display: flex; align-items: center; gap: 6px; margin: 16px auto 0; height: 40px; padding: 0 18px 0 12px; border-radius: 999px; background: var(--bar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: var(--float); font-weight: 650; color: var(--ink); }

/* Contents sheet list */
.tocl { list-style: none; counter-reset: t; }
.tocl li a { display: flex; gap: 12px; padding: 11px 12px; border-radius: 12px; font-size: 15.5px; font-weight: 600; color: var(--text); line-height: 1.35; }
.tocl li.l3 a { padding-left: 38px; font-size: 14.5px; font-weight: 550; color: var(--muted); }
.tocl li.l2 a::before { counter-increment: t; content: counter(t, decimal-leading-zero); font-weight: 750; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.tocl li a:hover { background: var(--fill); }
.tocl li a.is-active, .tocl li.is-current a { background: var(--green-soft); color: var(--green-ink); }

/* Swipe pages mode ------------------------------------------------------- */
html.is-paged, html.is-paged body { overflow: hidden; height: 100%; overscroll-behavior: none; }
.is-paged .header, .is-paged .footer, .is-paged .more, .is-paged .progress, .is-paged .resume { display: none !important; }
.is-paged .rd { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 28px); bottom: calc(env(safe-area-inset-bottom) + 64px); padding: 0; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; -webkit-user-select: none; }
.is-paged.allow-select .rd { user-select: text; -webkit-user-select: text; }
.is-paged .rd__flow { max-width: none; padding: 0; margin: 0; height: 100%; width: var(--pw); margin-left: var(--pm); column-width: var(--cw); column-gap: var(--pg); column-fill: auto; will-change: transform; transform: translate3d(0, 0, 0); }
.is-paged .rd__flow.is-anim { transition: transform .42s var(--spring); }
.is-paged .rd__head { padding: 8px 0 18px; break-inside: avoid; }
.is-paged .prose h2, .is-paged .prose h3 { break-after: avoid; }
.is-paged .prose img { max-height: calc(var(--ph) - 60px); width: auto; object-fit: contain; }
.is-paged .prose blockquote, .is-paged .prose figure, .is-paged .fb, .is-paged .next, .is-paged .done { break-inside: avoid; }
.is-paged .rd__end { break-before: column; }
.is-paged .rbar { bottom: calc(10px + env(safe-area-inset-bottom)); }
.pg-edge { position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 0; right: 0; z-index: 60; text-align: center; font-size: 12px; font-weight: 650; color: var(--faint); pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 60px; }
.is-paged .pg-edge { display: block; }
.pg-edge { display: none; }
.pg-hint { position: fixed; top: 50%; z-index: 61; width: 44px; height: 44px; margin-top: -22px; border-radius: 50%; display: none; place-items: center; background: var(--bar); box-shadow: var(--float); color: var(--ink); opacity: .0; transition: opacity .2s; }
@media (hover: hover) and (min-width: 900px) {
	.is-paged .pg-hint { display: grid; }
	.is-paged .rd:hover ~ .pg-hint, .pg-hint:hover { opacity: .9; }
	.pg-hint--prev { left: 14px; } .pg-hint--next { right: 14px; }
}
.want-pages .is-reader .rd { opacity: 0; }

/* =========================================================================
   Reader craft details (v3)
   ========================================================================= */
.cc__grid { grid-template-rows: 88px 92px 92px 92px 64px; }
.cc__grid--pdf { grid-template-rows: 88px 92px 92px 92px 64px; }
.tile--sound { grid-column: 1 / -1; grid-row: 5; flex-direction: row; align-items: center; gap: 12px; height: 60px; padding: 0 14px 0 10px; border-radius: 20px; background: var(--surface); text-align: left; }
.tile--sound .tile__si { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--fill); color: var(--ink); transition: background-color .25s, color .25s; }
.tile--sound .tile__l { flex: 1; }
.tile--sound > .icon { color: var(--faint); }
.tile--sound.is-on .tile__si { background: var(--green); color: var(--on-green); }
.tile--sound.is-on [data-sound-state] { color: var(--green-ink); font-weight: 650; }
.cc__hint { text-align: center; font-size: 12.5px; line-height: 1.45; color: var(--muted); margin: -6px 10px 14px; }
.cc__hint--left { text-align: left; margin: 8px 4px 0; }
.group--gap { margin-top: 14px; }
.row__v { font-weight: 700; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row--range { padding: 2px 14px 14px; min-height: 0; }

/* Sound cards */
.sgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scard { position: relative; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px; border-radius: 18px; background: var(--surface); text-align: left; color: var(--ink); transition: background-color .25s, box-shadow .25s, transform .15s var(--ease); }
.scard:last-child:nth-child(odd) { grid-column: 1 / -1; }
.scard:active { transform: scale(.97); }
.scard__i { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--fill); flex: none; transition: background-color .25s, color .25s; }
.scard__i .icon { width: 21px; height: 21px; }
.scard__t { min-width: 0; line-height: 1.25; }
.scard__t strong { display: block; font-size: 14.5px; }
.scard__t small { display: block; font-size: 11.5px; color: var(--muted); }
.scard[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--green); }
.scard[aria-pressed="true"] .scard__i { background: var(--green); color: var(--on-green); }
.scard__eq { position: absolute; top: 10px; right: 10px; display: none; align-items: flex-end; gap: 2px; height: 12px; }
.scard[aria-pressed="true"] .scard__eq { display: flex; }
.scard__eq i { width: 3px; border-radius: 2px; background: var(--green); animation: eq 1s ease-in-out infinite; }
.scard__eq i:nth-child(2) { animation-delay: -.35s; } .scard__eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* iOS-style horizontal slider */
.hrange { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; --v: 55%; }
.hrange::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(var(--green), var(--green)) 0 0 / var(--v) 100% no-repeat, var(--fill-2); }
.hrange::-moz-range-track { height: 6px; border-radius: 6px; background: var(--fill-2); }
.hrange::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--green); }
.hrange::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.22), 0 0 0 .5px rgba(0,0,0,.08); }
.hrange::-moz-range-thumb { width: 26px; height: 26px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.22); }
.hrange:focus-visible { outline: none; }
.hrange:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--green); }

/* A small speaker on the reading bar while sounds play */
.rbar__snd { display: none !important; }
.has-sound .rbar__snd { display: grid !important; color: var(--green-ink) !important; }

/* The end of an article is marked like the end of a chapter in a book */
.fin { display: flex; justify-content: center; margin: 2.2em 0 0; }
.fin .orn { max-width: 200px; color: var(--green); }

/* Quotes: a quiet opening mark */
.prose blockquote { position: relative; }
.prose blockquote::before { content: "“"; position: absolute; top: -.18em; right: .35em; font: 800 3.6em/1 var(--font-serif); color: var(--green); opacity: .16; pointer-events: none; }

/* Links that leave the site say so */
.prose a[target="_blank"]::after { content: "↗"; display: inline-block; margin-left: 2px; font-size: .75em; text-decoration: none; opacity: .7; }
.prose sup a { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; padding: 0 .3em; border-radius: 999px; background: var(--green-soft); font-size: .78em; line-height: 1; }

/* Pictures can be opened full screen */
.prose img { cursor: zoom-in; transition: transform .3s var(--spring); }
.lightbox { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.88); opacity: 0; transition: opacity .25s; cursor: zoom-out; }
.lightbox.is-open { opacity: 1; }
.lightbox img { max-width: 100%; max-height: 86vh; border-radius: 8px; transform: scale(.96); transition: transform .4s var(--spring); }
.lightbox.is-open img { transform: none; }
.lightbox p { color: rgba(255,255,255,.8); font-size: 14px; margin-top: 12px; text-align: center; }
.lightbox button { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; }

/* Pages mode: a soft paper shadow follows your finger, and a folio sits at the foot */
.pg-shade { position: fixed; top: 0; bottom: 0; width: 60px; z-index: 59; pointer-events: none; opacity: 0; transition: opacity .3s; }
.pg-shade--r { right: 0; background: linear-gradient(90deg, transparent, rgba(0,0,0,.12)); }
.pg-shade--l { left: 0; background: linear-gradient(270deg, transparent, rgba(0,0,0,.12)); }
.folio { position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 22px); z-index: 58; display: none; text-align: center; font: 600 12px var(--font-serif); letter-spacing: .12em; color: var(--faint); pointer-events: none; }
.is-paged .folio { display: block; }
.is-paged .rbar:not(.is-hidden) ~ .folio { opacity: 0; }

/* First-visit hint pointing at the settings button */
.coach { position: fixed; z-index: 75; right: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(50%); width: min(300px, calc(100% - 32px)); padding: 14px 16px; border-radius: 16px; background: var(--ink); color: var(--bg); box-shadow: var(--float); font-size: 14px; line-height: 1.45; animation: barin .5s var(--spring); }
.coach strong { display: block; font-size: 15px; margin-bottom: 2px; }
.coach button { margin-top: 10px; padding: 6px 12px; border-radius: 999px; background: var(--bg); color: var(--ink); font-weight: 750; font-size: 13px; }
.coach::after { content: ""; position: absolute; bottom: -6px; right: 34px; width: 12px; height: 12px; background: var(--ink); transform: rotate(45deg); border-radius: 2px; }

.rbar button, .pv__top .iconbtn, .pv__bot .iconbtn { position: relative; }

/* Slider captions sit under each slider inside the grid */
.cc__grid > [data-vs] { height: calc(100% - 22px); min-height: 0; align-self: start; }
.vs__cap { align-self: end; justify-self: center; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.cc__grid > [data-cap="size"], .cc__grid > [data-cap="zoom"] { grid-column: 3; grid-row: 4; }
.cc__grid > [data-cap="bright"] { grid-column: 4; grid-row: 4; }
.cc__grid--pdf > [data-cap] { grid-row: 4; }

/* Books: whole book on one page, or chapter by chapter ------------------- */
.bkh { text-align: left; }
.bkh .crumbs { justify-content: flex-start; }
.bkh__grid { display: grid; grid-template-columns: 170px 1fr; gap: clamp(20px, 3.5vw, 40px); align-items: start; margin-top: 18px; }
.bkh__cover img, .bkh__cover .cover { width: 100%; border-radius: 5px 12px 12px 5px; box-shadow: 0 0 0 .5px var(--hair-2), 0 22px 44px -24px rgba(0,0,0,.55); }
.bkh__cover .cover { padding: 16px; }
.bkh .rd__tag { margin-top: 0; }
.bkh__title { margin: 12px 0 0; text-align: left; font-size: clamp(30px, 4.4vw, 48px); }
.bkh__author { margin-top: 8px; font-size: 17px; font-weight: 650; color: var(--muted); }
.bkh__desc { margin-top: 12px; font-size: 16.5px; line-height: 1.6; color: var(--text); max-width: 680px; }
.bkh .bk__chips { margin-top: 14px; }
.bkh__btns { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
@media (max-width: 640px) {
	.bkh__grid { grid-template-columns: 1fr; justify-items: center; text-align: center; }
	.bkh__cover { width: 150px; }
	.bkh__title { text-align: center; }
	.bkh .bk__chips, .bkh__btns, .bkh .crumbs { justify-content: center; }
}
.bmode { display: inline-flex; gap: 0; padding: 3px; border-radius: 999px; background: var(--fill); }
.bmode button { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--muted); transition: background-color .2s, color .2s, box-shadow .2s; }
.bmode button .icon { width: 16px; height: 16px; }
.bmode button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1), 0 0 0 .5px var(--hair); }
.sheet .bmode { display: flex; margin: 0 0 12px; }
.sheet .bmode button { flex: 1; justify-content: center; }
.bch + .bch { margin-top: 3.2em; padding-top: 2.4em; border-top: .5px solid var(--hair-2); }
.bch__head { text-align: center; margin-bottom: 1.4em; }
.bch__n { display: block; font-family: var(--font-ui); font-size: 12.5px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; color: var(--green-ink); }
.prose .bch__t { margin-top: .35em; font-size: 1.7em; text-align: center; text-wrap: balance; }
.is-paged .bch { break-before: column; }
.is-paged .bch + .bch { border-top: 0; margin-top: 0; padding-top: 0; }
.chmode { display: inline-flex; align-items: center; gap: 7px; margin-top: 14px; padding: 7px 14px; border-radius: 999px; background: var(--fill); font-size: 13.5px; font-weight: 700; color: var(--green-ink); }
.chmode:hover { background: var(--green-soft); }
.chmode .icon { width: 16px; height: 16px; }
.rd__head--ch .crumbs { margin-bottom: 12px; }
