/* Book reader pages. Everything is scoped under .rd so it cannot touch other pages. */
.rd .titlebar { padding-block: 1.2rem 1.4rem; display: flex; flex-wrap: wrap; gap: 0.6rem 2rem; align-items: baseline; justify-content: space-between; }
.rd .titlebar h1 { font-size: clamp(2rem, 4.4vw, 3.2rem); display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.rd .titlebar h1 .ur { font-size: 0.55em; color: var(--sage); font-weight: 400; }
.rd .titlebar p { color: var(--moon-dim); }
.rd .sec { font-size: 1.6rem; margin: 2rem 0 1rem; }
.rd .empty { padding: 2rem 0; color: var(--moon-dim); }

/* overview shelf */
.rd .shelf { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rd .shelf a { display: grid; grid-template-columns: minmax(0, 1fr) auto 7rem; gap: 0.3rem 1.5rem; align-items: baseline; padding: 1.1rem 0.3rem; border-bottom: 1px solid var(--line); text-decoration: none; transition: background .2s; }
.rd .shelf a:hover { background: var(--night-2); }
.rd .shelf .bt b { font-family: var(--f-display); font-size: 1.5rem; font-weight: 600; }
.rd .shelf .bt em { font-style: normal; color: var(--moon-dim); font-size: 0.92rem; margin-left: 0.4rem; }
.rd .shelf .bu { color: var(--sage); font-size: 1.2rem; }
.rd .shelf .bn { color: var(--moon-dim); font-size: 0.92rem; text-align: right; font-variant-numeric: tabular-nums; }

/* reader */
.rd .layout { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: clamp(1.2rem, 3vw, 2.5rem); align-items: start; }
.rd .side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 5.4rem); max-height: calc(100vh - 7rem); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; padding-right: 0.4rem; }
.rd .side h2 { font-size: 1.15rem; margin-bottom: 0.7rem; }
.rd .jump { display: flex; gap: 0.5rem; }
.rd .jump input { flex: 1; min-width: 0; font: inherit; font-variant-numeric: tabular-nums; color: var(--moon); background: var(--night-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.8rem; min-height: 2.75rem; }
.rd .jump input:focus { outline: none; border-color: var(--lamp); }
.rd .rbtn { font: inherit; font-weight: 600; background: var(--lamp); color: var(--night); border: 0; border-radius: 8px; padding: 0 1.1rem; min-height: 2.75rem; cursor: pointer; transition: background .2s; }
.rd .rbtn:hover { background: #ffc875; }
.rd .grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.3rem; margin-top: 1.2rem; }
.rd .grid a { font-size: 0.82rem; font-variant-numeric: tabular-nums; color: var(--moon-dim); border: 1px solid var(--line); border-radius: 6px; padding: 0.4rem 0; text-align: center; text-decoration: none; min-height: 2.2rem; display: grid; place-items: center; transition: all .15s; overflow: hidden; }
.rd .grid a:hover { color: var(--moon); border-color: var(--moon-dim); }
.rd .grid a[aria-current="true"] { background: var(--lamp); border-color: var(--lamp); color: var(--night); font-weight: 600; }
.rd .reading { min-width: 0; }
.rd .rbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; padding: 0.7rem; background: var(--night-3); border: 1px solid var(--line); border-radius: 12px; }
.rd .rbar .z { display: flex; gap: 0.4rem; }
.rd .count { display: flex; flex-direction: column; align-items: center; line-height: 1.25; min-width: 6.5rem; font-variant-numeric: tabular-nums; }
.rd .count b { font-weight: 600; }
.rd .count span { color: var(--moon-dim); font-size: 0.85rem; }
.rd .ic { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; background: transparent; color: var(--moon); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font: inherit; text-decoration: none; transition: all .2s; }
.rd .ic:hover { border-color: var(--lamp); color: var(--lamp); }
.rd .ic[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.rd .ic.txt { font-size: 0.8rem; }
.rd .ic svg { width: 1.1rem; height: 1.1rem; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rd .table { margin-top: 1rem; background: #070c14; border: 1px solid var(--line); border-radius: 14px; padding: clamp(0.8rem, 3vw, 2rem); overflow: auto; max-height: 80vh; text-align: center; touch-action: pan-y pinch-zoom; }
.rd .page { display: inline-block; width: var(--w, 62%); min-width: min(16rem, 100%); background: #f3ecd9; border-radius: 3px; box-shadow: 0 30px 60px -24px rgba(0,0,0,.9); line-height: 0; cursor: zoom-in; vertical-align: top; }
.rd .page img { width: 100%; height: auto; display: block; }
.rd .page.blend img { mix-blend-mode: multiply; }
.rd .rcap { margin-top: 1rem; color: var(--moon-dim); font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; justify-content: space-between; }
.rd .rcap .links { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.rd .rcap a { color: var(--lamp); text-decoration: none; font-weight: 600; }
.rd .rcap a:hover { text-decoration: underline; }
.rd details.mp { display: none; border: 1px solid var(--line); border-radius: 12px; background: var(--night-2); margin-bottom: 1rem; }
.rd details.mp summary { cursor: pointer; padding: 0.9rem 1rem; font-weight: 600; list-style: none; display: flex; justify-content: space-between; min-height: 2.75rem; }
.rd details.mp summary::-webkit-details-marker { display: none; }
.rd details.mp summary::after { content: "+"; color: var(--lamp); }
.rd details.mp[open] summary::after { content: "\2013"; }
.rd details.mp .in { padding: 0 1rem 1rem; max-height: 50vh; overflow-y: auto; }

@media (max-width: 880px) {
  .rd .layout { grid-template-columns: minmax(0, 1fr); }
  .rd .side { display: none; }
  .rd details.mp { display: block; }
  .rd .table { max-height: none; }
  .rd .page { --w: 100%; min-width: 0; }
  .rd.zoom .page { --w: 170%; cursor: zoom-out; }
  .rd-reader { padding-bottom: calc(5.4rem + var(--tabh, 0px)); }
  .rd .rbar { position: fixed; left: 0; right: 0; bottom: var(--tabh, 0px); z-index: 40; border-radius: 0; border-width: 1px 0 0; padding: 0.6rem max(16px, env(safe-area-inset-right, 0px)) 0.6rem max(16px, env(safe-area-inset-left, 0px)); justify-content: space-between; flex-wrap: nowrap; }
  .rd .rbar .z { display: none; }
  .rd .count { min-width: 0; }
  .rd .ic { width: 3.1rem; height: 3.1rem; }
  .rd .shelf a { grid-template-columns: minmax(0, 1fr) auto; }
  .rd .shelf .bn { grid-column: 1 / -1; text-align: left; }
}
.rd .count span, .rd .count b { direction: ltr; unicode-bidi: isolate; }
