/* The Library's web page.
   Classical design system tokens (dark variant, as in the design) + the page's components. */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;600&family=Lora:wght@400;600&display=swap');

:root {
  --color-bg: #1a1817;
  --color-surface: #242120;
  --color-text: #eae7e7;
  --color-accent: #e1ad66;
  --color-divider: color-mix(in srgb, #eae7e7 16%, transparent);

  --color-neutral-300: #c9c6c6;
  --color-neutral-600: #7d7979;

  --color-accent-100: #fff3e4;
  --color-accent-300: #facb8d;
  --color-accent-400: #e1ad66;
  --color-accent-700: #7d5411;

  --font-heading: "Cormorant Garamond", system-ui, sans-serif;
  --font-heading-weight: 600;
  --font-body: "Lora", system-ui, sans-serif;

  --space-1: 4.6px;
  --space-2: 9.2px;
  --space-3: 13.8px;
  --space-4: 18.4px;
  --space-6: 27.6px;
  --space-8: 36.8px;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 7px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-size: 15px; line-height: 1.55; font-weight: 400;
  background: var(--color-bg); color: var(--color-text); font-family: var(--font-body);
  overflow: hidden;
}
h1, h2, h3 {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 var(--space-2);
}
p { margin: 0 0 var(--space-3); }
a { color: var(--color-accent); text-underline-offset: 3px; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

.hr { height: 1px; border: 0; margin: var(--space-4) 0; background: var(--color-divider); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: var(--space-2) calc(var(--space-3) * 1.2);
  border-radius: var(--radius-md);
}
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-1); }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }


/* ── frame ───────────────────────────────────────────────────────────── */

.library {
  height: 100vh; min-height: 640px; display: flex; flex-direction: column; position: relative;
  background: radial-gradient(ellipse at 30% 50%, #242120 0%, #1a1817 60%);
}
.main { flex: 1; min-height: 0; display: flex; position: relative; }
/* A child of .main, not of the stage: the stage's fade mask would dim it.
   Centred over the stage by syncSearch(), like the search box. */
.brand {
  position: absolute; left: 50%; top: 36px; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 14px; white-space: nowrap; pointer-events: none;
}
.brand-logo { flex: none; filter: drop-shadow(0 0 8px rgba(225, 173, 102, .35)); }
.brand-title {
  font-family: var(--font-heading); font-weight: 400; font-size: 30px; line-height: 1;
  letter-spacing: 0.03em; margin: 0; color: var(--color-text);
}
.brand-sub {
  margin-top: 4px; font-size: 10.5px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--color-accent);
}

.kicker {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--color-accent); font-feature-settings: 'tnum';
}
.muted { color: color-mix(in srgb, var(--color-text) 62%, transparent); }

/* ── sidebar ─────────────────────────────────────────────────────────── */

.side {
  flex: 0 0 260px; align-self: stretch; min-height: 0;
  padding: 16px var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-6);
}
.side-title { font-weight: 400; font-size: 30px; margin: var(--space-1) 0 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* the page language: УКР | ENG */
.lang-switch {
  display: flex; padding: 2px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
}
.lang-switch button {
  border: 0; background: none; cursor: pointer; border-radius: 999px; padding: 3px 7px;
  font-family: var(--font-body); font-size: 9.5px; font-weight: 600; letter-spacing: .1em; line-height: 1;
  color: color-mix(in srgb, var(--color-text) 55%, transparent); transition: color .2s, background .2s;
}
.lang-switch button:hover { color: var(--color-text); }
.lang-switch button[aria-pressed="true"] {
  color: var(--color-text); background: color-mix(in srgb, var(--color-accent) 24%, transparent);
}
.lang-switch button:focus-visible { outline: 1px solid var(--color-accent); outline-offset: 1px; }
.ornament { display: flex; align-items: center; gap: 8px; margin-top: var(--space-3); }
.orn-line { flex: 1; height: 1px; background: color-mix(in srgb, var(--color-accent) 50%, transparent); }
.orn-diamond { width: 5px; height: 5px; transform: rotate(45deg); border: 1px solid var(--color-accent); }

.cats {
  display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; overflow-y: auto;
  padding: 4px 12px 28px 4px; margin: -4px -12px 0 -4px;
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 48px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 48px), transparent 100%);
}

.cat {
  position: relative; width: 100%; padding: 14px 14px 12px 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  color: var(--color-text); font-family: var(--font-body);
  background: rgba(255,255,255,.02); border: 1px solid var(--color-divider);
  border-radius: var(--radius-md); box-shadow: none; transform: translateX(0);
  transition: transform .4s cubic-bezier(.2,.7,.2,1), background .4s, border-color .4s, box-shadow .4s;
}
.cat.active {
  background: color-mix(in srgb, var(--color-accent) 9%, #1f1c1b);
  border-color: color-mix(in srgb, var(--color-accent) 55%, transparent);
  box-shadow: 0 0 26px color-mix(in srgb, var(--color-accent-400) 20%, transparent);
  transform: translateX(4px);
}
.cat-bar {
  position: absolute; left: -1px; top: 12px; bottom: 12px; width: 2px; border-radius: 2px;
  background: transparent; transition: background .4s;
}
.cat.active .cat-bar { background: var(--color-accent); }
.cat-shelf {
  display: flex; align-items: flex-end; gap: 2px; height: 60px; padding: 0 4px;
  border-bottom: 3px solid #3a3431; box-shadow: 0 6px 10px -6px rgba(0,0,0,.6);
  transition: border-color .4s;
}
.cat.active .cat-shelf { border-bottom-color: #6b5233; }
.cat-icon {
  flex: none; display: flex; align-items: flex-end; margin-right: 7px;
  color: #b8975c; filter: none; transition: color .4s, filter .4s;
}
.cat.active .cat-icon { color: #f3d9a2; filter: drop-shadow(0 0 6px rgba(225,173,102,.55)); }

/* Shelf ornaments (app.js ICONS): a rest pose, and a loop of motion while the shelf is active.
   Rest values match each animation's first frame, so nothing jumps when it starts. */
.cat-icon [class^="a-"], .cat-icon [class*=" a-"] { transform-box: fill-box; }
.cat-icon :is(.a-drip, .a-ink, .a-petal, .a-gleam, .a-note, .a-tear, .a-spark) { opacity: 0; }
.cat-icon :is(.a-halo, .a-orb) { opacity: .1; transform: scale(.92); transform-origin: 50% 50%; }
.cat-icon .a-spot { opacity: .08; transform: scale(.7); transform-origin: 50% 50%; }
.cat-icon :is(.a-outer, .a-inner) { transform: scale(.86); }
.cat-icon .a-print { opacity: .3; }
.cat-icon .a-boom { opacity: 0; transform-origin: 50% 50%; }
.cat-icon :is(.a-fspark, .a-flick) { transform-origin: 50% 50%; }
.cat-icon .a-lid { transform: scaleY(0); transform-origin: 50% 0%; }
.cat-icon .a-shine { transform: translateX(-34px); }
.cat-icon .a-cshine { transform: translateX(-26px); }
.cat-icon .a-flame, .cat-icon .a-stem, .cat-icon .a-crest, .cat-icon .a-laugh, .cat-icon .a-head,
.cat-icon .a-crown, .cat-icon .a-min, .cat-icon .a-outer, .cat-icon .a-inner { transform-origin: 50% 100%; }
.cat-icon .a-quill { transform-origin: 20% 95%; }
.cat-icon .a-thrust { transform-origin: 50% 0%; }
.cat-icon .a-bloom { transform-origin: 50% 90%; }
.cat-icon :is(.a-needle, .a-moon, .a-star, .a-maskA, .a-maskB, .a-jewel, .a-spark) { transform-origin: 50% 50%; }
.cat-icon .a-lens { transform-origin: 80% 90%; }
.cat-icon .a-laurel { transform-origin: 100% 100%; }
.cat-icon .a-tear, .cat-icon .a-mouth { transform-origin: 50% 0%; }
.cat-icon .a-droop { transform-origin: 50% 10%; }
.cat-icon .a-flag { transform-origin: 0% 50%; }
.cat-icon .a-curtL { transform-origin: 0% 0%; }
.cat-icon .a-curtR { transform-origin: 100% 0%; }
.cat-icon .a-hour { transform-origin: 0% 0%; }
.cat-icon .a-watch { transform-origin: 50% 0%; }

.cat-icon .a-bigstar { transform-origin: 50% 50%; }
.cat.active .cat-icon {
  & .a-bigstar { animation: ic-bloom 2.4s ease-in-out infinite; }
  & .a-flame { animation: ic-flicker 1.8s ease-in-out infinite; }
  & .a-halo { animation: ic-halo 1.8s ease-in-out infinite; }
  & .a-drip { animation: ic-drip 4s ease-in infinite; }
  & .a-quill { animation: ic-dip 3s ease-in-out infinite; }
  & .a-ink { animation: ic-inkdrop 3s ease-in infinite; }
  & .a-bloom { animation: ic-bloom 3.2s ease-in-out infinite; }
  & .a-stem { animation: ic-sway 4s ease-in-out infinite; }
  & .a-petal { animation: ic-petal 4.8s ease-in infinite; }
  & .a-needle { animation: ic-needle 4s ease-in-out infinite; }
  & .a-eye { animation: ic-eyeglow 2.6s ease-in-out infinite; }
  & .a-jaw { animation: ic-chatter 2.6s linear infinite; }
  & .a-lens { animation: ic-scan 3.4s ease-in-out infinite; }
  & .a-glint { animation: ic-glint 3.4s ease-in-out infinite; }
  & .a-print { animation: ic-print 3.4s ease-in-out infinite; }
  & .a-boom { animation: ic-boom 4.2s ease-out infinite; }
  & .a-bomb { animation: ic-bshake 4.2s linear infinite; }
  & .a-fuse { animation: ic-fuse 4.2s linear infinite; }
  & .a-fspark { animation: ic-fspark 4.2s linear infinite; }
  & .a-flick { animation: ic-flick .32s ease-in-out infinite alternate; }
  & .a-moon { animation: ic-float 5s ease-in-out infinite; }
  & .a-star { animation: ic-twinkle 2s ease-in-out infinite; }
  & .a-crest { animation: ic-crest 2.4s ease-in-out infinite; }
  & .a-shine { animation: ic-shine 3.2s ease-in-out infinite; }
  & .a-gleam { animation: ic-gleam 3s ease-in-out infinite; }
  & .a-laurel { animation: ic-sway 4.2s ease-in-out infinite; }
  & .a-str { animation: ic-pluck 2.4s linear infinite; }
  & .a-note { animation: ic-note 2.4s ease-out infinite; }
  & .a-tear { animation: ic-tear 3s ease-in infinite; }
  & .a-droop { animation: ic-droop 4s ease-in-out infinite; }
  & .a-laugh { animation: ic-laugh 1.6s ease-in-out infinite; }
  & .a-mouth { animation: ic-mouth 1.6s ease-in-out infinite; }
  & .a-maskA { animation: ic-orbitA 4s ease-in-out infinite; }
  & .a-maskB { animation: ic-orbitB 4s ease-in-out infinite; }
  & .a-lid { animation: ic-blink 3.6s ease-in-out infinite; }
  & .a-head { animation: ic-tilt 5s ease-in-out infinite; }
  & .a-crown { animation: ic-bob 3s ease-in-out infinite; }
  & .a-rocket { animation: ic-bob 2.4s ease-in-out infinite; }
  & .a-thrust { animation: ic-thrust .18s ease-in-out infinite alternate; }
  & .a-streak { animation: ic-streak 1.6s linear infinite; }
  & .a-jewel { animation: ic-twinkle 1.8s ease-in-out infinite; }
  & .a-spark { animation: ic-spark 2.6s ease-in-out infinite; }
  & .a-globe { animation: ic-globe 6s linear infinite; }
  & .a-flag { animation: ic-flag 1.2s ease-in-out infinite; }
  & .a-window { animation: ic-windowglow 3s ease-in-out infinite; }
  & .a-curtL, & .a-curtR { animation: ic-curtain 4.4s ease-in-out infinite; }
  & .a-spot { animation: ic-spot 4.4s ease-in-out infinite; }
  & .a-min { animation: ic-spin 4s linear infinite; }
  & .a-hour { animation: ic-spin 48s linear infinite; }
  & .a-watch { animation: ic-tick 1s steps(2) infinite; }
  & .a-outer { animation: ic-open 4s ease-in-out infinite; }
  & .a-inner { animation: ic-open 4s ease-in-out -.4s infinite; }
  & .a-orb { animation: ic-halo 4s ease-in-out infinite; }
  & .a-ripple { animation: ic-ripple 3s ease-in-out infinite; }
  & .a-specs { animation: ic-bob 3.2s ease-in-out infinite; }
  & .a-lglint { animation: ic-glint 3.2s ease-in-out infinite; }
  & .a-cshine { animation: ic-cshine 4s ease-in-out infinite; }
  & .a-sil { animation: ic-windowglow 4s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) { .cat-icon * { animation: none !important; } }

@keyframes ic-flicker { 0%,100% { transform: scale(1,1) rotate(-3deg); } 25% { transform: scale(.93,1.09) rotate(2deg); } 50% { transform: scale(1.06,.93) rotate(-1deg); } 75% { transform: scale(.97,1.05) rotate(3deg); } }
@keyframes ic-halo { 0%,100% { opacity: .1; transform: scale(.92); } 50% { opacity: .26; transform: scale(1.06); } }
@keyframes ic-drip { 0%,55% { transform: translateY(0); opacity: 0; } 62% { opacity: 1; } 100% { transform: translateY(16px); opacity: 0; } }
@keyframes ic-dip { 0%,100% { transform: translateY(0) rotate(0); } 35%,50% { transform: translateY(-1px) rotate(2deg); } 70% { transform: translateY(1px) rotate(-1deg); } }
@keyframes ic-inkdrop { 0%,38% { transform: translateY(0); opacity: 0; } 42% { opacity: 1; } 58% { transform: translateY(7px); opacity: 0; } 100% { opacity: 0; } }
@keyframes ic-bloom { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes ic-sway { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes ic-petal { 0%,20% { transform: translate(0,0) rotate(0); opacity: 0; } 28% { opacity: 1; } 100% { transform: translate(11px,30px) rotate(170deg); opacity: 0; } }
@keyframes ic-needle { 0% { transform: rotate(0); } 12% { transform: rotate(80deg); } 26% { transform: rotate(-46deg); } 40% { transform: rotate(24deg); } 54% { transform: rotate(-11deg); } 66% { transform: rotate(5deg); } 76%,100% { transform: rotate(0); } }
@keyframes ic-eyeglow { 0%,100% { fill: rgba(0,0,0,.65); } 50% { fill: rgba(226,120,64,.95); } }
@keyframes ic-chatter { 0%,70%,100% { transform: translateY(0); } 74%,82% { transform: translateY(2px); } 78%,86% { transform: translateY(0); } }
@keyframes ic-scan { 0%,100% { transform: translate(-1.5px,.5px) rotate(-3deg); } 50% { transform: translate(1.5px,-.5px) rotate(3deg); } }
@keyframes ic-glint { 0%,40%,100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes ic-print { 0%,100% { opacity: .25; } 50% { opacity: .9; } }
/* thriller bomb: the spark rides the fuse down, the fuse burns away, a flash and a shake, then it relights */
@keyframes ic-fspark { 0% { transform: translate(0,0) scale(1); opacity: 1; } 13.9% { transform: translate(-1.61px,2.76px); } 26.5% { transform: translate(-2.21px,5.59px); } 38.8% { transform: translate(-2.21px,8.43px); } 51% { transform: translate(-2.02px,11.21px); } 62.6% { transform: translate(-2.05px,13.88px); } 70% { transform: translate(-2.4px,15.56px) scale(1); opacity: 1; } 78% { transform: translate(-2.4px,15.56px) scale(1.8); opacity: 1; } 86% { transform: translate(-2.4px,15.56px) scale(.2); opacity: 0; } 93% { transform: translate(0,0) scale(.2); opacity: 0; } 100% { transform: translate(0,0) scale(1); opacity: 1; } }
@keyframes ic-fuse { 0% { stroke-dashoffset: 0; opacity: 1; } 70%,86% { stroke-dashoffset: 85.7; opacity: 1; } 92% { stroke-dashoffset: 85.7; opacity: 0; } 93% { stroke-dashoffset: 0; opacity: 0; } 100% { stroke-dashoffset: 0; opacity: 1; } }
@keyframes ic-bshake { 0%,72%,88%,100% { transform: translate(0,0); } 74% { transform: translate(-.8px,.4px); } 76% { transform: translate(.8px,-.4px); } 78% { transform: translate(-.6px,-.3px); } 80% { transform: translate(.6px,.4px); } 82% { transform: translate(-.4px,0); } 84% { transform: translate(.4px,.2px); } 86% { transform: translate(0,0); } }
@keyframes ic-boom { 0%,72% { transform: scale(.2); opacity: 0; } 80% { transform: scale(1); opacity: .55; } 90%,100% { transform: scale(1.3); opacity: 0; } }
@keyframes ic-flick { from { transform: scale(.75) rotate(-12deg); } to { transform: scale(1.12) rotate(12deg); } }
@keyframes ic-float { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-3px) rotate(4deg); } }
/* the selected book's star: hollow, filled once the book is on the Starred shelf */
.star-btn svg { fill: none; transition: fill .2s; }
.star-btn[aria-pressed="true"] { color: var(--color-accent); }
.star-btn[aria-pressed="true"] svg { fill: currentColor; }
@keyframes ic-twinkle { 0%,100% { transform: scale(.55); opacity: .35; } 50% { transform: scale(1.15); opacity: 1; } }
@keyframes ic-crest { 0%,100% { transform: skewX(0) scaleY(1); } 50% { transform: skewX(-14deg) scaleY(1.06); } }
@keyframes ic-shine { 0%,50% { transform: translateX(-34px); } 100% { transform: translateX(46px); } }
@keyframes ic-gleam { 0%,30% { transform: translateY(30px); opacity: 0; } 40% { opacity: 1; } 75% { transform: translateY(0); opacity: 1; } 85%,100% { transform: translateY(-2px); opacity: 0; } }
@keyframes ic-pluck { 0%,14%,100% { transform: translateX(0); } 2% { transform: translateX(1.1px); } 4% { transform: translateX(-1px); } 6% { transform: translateX(.8px); } 8% { transform: translateX(-.6px); } 10% { transform: translateX(.3px); } }
@keyframes ic-note { 0%,30% { transform: translate(0,0); opacity: 0; } 40% { opacity: 1; } 100% { transform: translate(-4px,-13px); opacity: 0; } }
@keyframes ic-tear { 0%,35% { transform: translateY(0) scale(.3); opacity: 0; } 48% { transform: translateY(0) scale(1); opacity: 1; } 88% { transform: translateY(13px) scale(1); opacity: 1; } 100% { transform: translateY(15px); opacity: 0; } }
@keyframes ic-droop { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(1px); } }
@keyframes ic-laugh { 0%,100% { transform: translateY(0) scale(1); } 20% { transform: translateY(-3px) scale(1.03,.97); } 40% { transform: translateY(0) scale(.98,1.02); } 60% { transform: translateY(-2px); } 80% { transform: translateY(0); } }
@keyframes ic-mouth { 0%,100% { transform: scaleY(1); } 20%,60% { transform: scaleY(1.3); } 40%,80% { transform: scaleY(.8); } }
@keyframes ic-orbitA { 0%,100% { transform: translate(0,0) rotate(0); } 50% { transform: translate(3px,-3px) rotate(4deg); } }
@keyframes ic-orbitB { 0%,100% { transform: translate(0,0) rotate(0); } 50% { transform: translate(-3px,3px) rotate(-4deg); } }
@keyframes ic-blink { 0%,44%,54%,100% { transform: scaleY(0); } 48%,50% { transform: scaleY(1); } }
@keyframes ic-tilt { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-9deg); } 65% { transform: rotate(7deg); } }
@keyframes ic-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes ic-thrust { from { transform: scale(.9,.72); } to { transform: scale(1.05,1.12); } }
@keyframes ic-streak { 0% { transform: translateY(-6px); opacity: 0; } 20% { opacity: .9; } 100% { transform: translateY(16px); opacity: 0; } }
@keyframes ic-spark { 0%,60%,100% { transform: scale(0) rotate(0); opacity: 0; } 75% { transform: scale(1.2) rotate(45deg); opacity: 1; } 90% { transform: scale(.4) rotate(90deg); opacity: .6; } }
@keyframes ic-globe { from { transform: translateX(0); } to { transform: translateX(-24px); } }
@keyframes ic-flag { 0%,100% { transform: skewY(0) scaleX(1); } 50% { transform: skewY(-14deg) scaleX(.82); } }
@keyframes ic-windowglow { 0%,100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes ic-curtain { 0%,100% { transform: scaleX(1); } 40%,62% { transform: scaleX(.5); } }
@keyframes ic-spot { 0%,100% { opacity: .08; transform: scale(.7); } 40%,62% { opacity: .38; transform: scale(1.1); } }
@keyframes ic-spin { to { transform: rotate(360deg); } }
@keyframes ic-tick { 0% { transform: rotate(-1.5deg); } 100% { transform: rotate(1.5deg); } }
@keyframes ic-open { 0%,100% { transform: scale(.86); } 50% { transform: scale(1.04); } }
@keyframes ic-ripple { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-3px); } }
@keyframes ic-cshine { 0%,55% { transform: translateX(-26px); } 100% { transform: translateX(30px); } }
.cat-spine {
  flex: none; border-radius: 1px 1px 0 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.09) 40%, rgba(0,0,0,.28)),
    linear-gradient(180deg, transparent 0 13%, rgba(201,169,106,.7) 13% 16%, transparent 16% 84%, rgba(201,169,106,.7) 84% 87%, transparent 87%),
    var(--fill);
  transform-origin: bottom center; transform: translateY(0) rotate(0deg);
  transition: transform .45s cubic-bezier(.2,.7,.2,1);
}
.cat-spine.sp-tilt { transform: rotate(-7deg); }
.cat.active .cat-spine.sp-lift { transform: translateY(-7px); }
.cat.active .cat-spine.sp-lift.sp-tilt { transform: translateY(-7px) rotate(-7deg); }
.cat-head { display: flex; flex-direction: column; gap: 3px; }
.cat-name { font-family: var(--font-heading); font-size: 20px; line-height: 1.1; color: var(--color-text); transition: color .4s; }
.cat.active .cat-name { color: var(--color-accent-100); }
.cat-meta {
  font-size: 11px; letter-spacing: 0.02em; font-feature-settings: 'tnum'; white-space: nowrap;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.cat-count { color: var(--color-text); transition: color .4s; }
.cat.active .cat-count { color: var(--color-accent-100); }
.cat-blurb { font-size: 12px; font-style: italic; line-height: 1.35; color: color-mix(in srgb, var(--color-text) 62%, transparent); }


/* ── the helix ───────────────────────────────────────────────────────── */

.stage {
  flex: 1 1 420px; min-width: 0; position: relative; overflow: hidden;
  perspective: 1100px; touch-action: none; user-select: none; -webkit-user-select: none;
  cursor: grab;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 22%, #000 78%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 22%, #000 78%, transparent 100%);
}
/* The grabbing cursor rides a childless overlay: cursor is inherited, so changing it
   on the stage itself would recompute style for every book element (another freeze). */
.drag-cursor { position: fixed; inset: 0; z-index: 90; cursor: grabbing; display: none; }
.drag-cursor.show { display: block; }
.spiral { position: absolute; inset: 0; transform-style: preserve-3d; }

.book {
  position: absolute; left: 50%; top: 50%; width: 92px; height: 128px;
  padding: 0; margin: 0; border: 0; background: none; cursor: inherit;
  transform-style: preserve-3d; font-family: var(--font-heading);
  color: #e3c890; --foil: #c9a96a; --foil-dim: rgba(201,169,106,.6);
}
.book.on { color: #fbe9c4; --foil: #f5dca6; --foil-dim: rgba(245,220,166,.8); }
/* Transitions are gated per book (render() toggles .settle on the visible ones only):
   a stage-level class here would invalidate styles for the whole library on the first
   drag frame — a ~400ms freeze with a few thousand books. */
.book.settle { transition: transform .8s cubic-bezier(.2,.7,.2,1); }
/* The fade lives on the faces, never on the .book itself: opacity < 1 on a
   preserve-3d element flattens its 3D children (the book would lose its body). */
.book.settle > span { transition: opacity .8s cubic-bezier(.2,.7,.2,1); }
.book.settle .book-face { transition: border-color .8s cubic-bezier(.2,.7,.2,1), box-shadow .8s cubic-bezier(.2,.7,.2,1), opacity .8s cubic-bezier(.2,.7,.2,1); }
.book.settle .book-shade, .book.settle .book-overlay { transition: opacity .8s cubic-bezier(.2,.7,.2,1); }

.book > span { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
/* Distance shading: a solid ground-coloured veil whose opacity is the only thing that
   changes per frame — the faces' gradients rasterise once and only composite after that. */
.book-shade { position: absolute; inset: 0; background: #1a1817; border-radius: inherit; pointer-events: none; }
.book-back {
  position: absolute; inset: 0;
  transform: translateZ(calc(-1 * var(--depth))) rotateY(180deg);
  background: linear-gradient(rgba(0,0,0,.35), rgba(0,0,0,.35)), var(--fill);
  border-radius: 1px var(--radius-md) var(--radius-md) 1px;
}
.book-spine {
  position: absolute; top: 0; right: 100%; width: var(--depth); height: 100%;
  transform-origin: right center; transform: rotateY(-90deg);
  background:
    linear-gradient(90deg, rgba(0,0,0,.4), rgba(255,255,255,.07) 35%, rgba(0,0,0,.15) 65%, rgba(0,0,0,.45)),
    linear-gradient(180deg, transparent 0 10%, var(--foil-dim) 10% 11%, transparent 11% 89%, var(--foil-dim) 89% 90%, transparent 90%),
    var(--fill);
}
.book-edge {
  position: absolute; top: 2px; left: 100%; width: var(--depth); height: calc(100% - 4px);
  transform-origin: left center; transform: rotateY(90deg);
  background:
    linear-gradient(90deg, rgba(0,0,0,.25), transparent 20%, transparent 80%, rgba(0,0,0,.3)),
    repeating-linear-gradient(90deg, #d9ccae 0 1px, #bfb08f 1px 2px);
}
.book-top {
  position: absolute; bottom: calc(100% - 2px); left: 0; width: calc(100% - 2px); height: var(--depth);
  transform-origin: center bottom; transform: rotateX(90deg);
  background:
    linear-gradient(0deg, rgba(0,0,0,.3), transparent 25%, transparent 75%, rgba(0,0,0,.3)),
    repeating-linear-gradient(0deg, #e2d6ba 0 1px, #c7b897 1px 2px);
}
.book-bottom {
  position: absolute; top: calc(100% - 2px); left: 0; width: calc(100% - 2px); height: var(--depth);
  transform-origin: center top; transform: rotateX(-90deg);
  background:
    linear-gradient(0deg, rgba(0,0,0,.45), rgba(0,0,0,.2)),
    repeating-linear-gradient(0deg, #cdbf9f 0 1px, #b2a382 1px 2px);
}
.book-face {
  position: absolute; inset: 0; padding: 12px 9px 10px 12px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
  background: var(--fill); border: 1px solid rgba(0,0,0,.5);
  border-radius: 1px var(--radius-md) var(--radius-md) 1px;
  box-shadow: 3px 5px 10px rgba(0,0,0,.4);
}
.book.on .book-face {
  border-color: var(--color-accent-300);
  box-shadow: 0 0 28px color-mix(in srgb, var(--color-accent-400) 50%, transparent), 4px 6px 14px rgba(0,0,0,.5);
}
.book-pattern { position: absolute; inset: 0; background: var(--pattern); pointer-events: none; }
.book-groove {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0,0,0,.45) 0, rgba(0,0,0,.15) 7px, rgba(255,255,255,.06) 8px, transparent 14px),
    linear-gradient(160deg, rgba(255,255,255,.08), transparent 45%);
}
.book-frame { position: absolute; inset: 5px 5px 5px 9px; border: 1px solid var(--foil); opacity: .55; border-radius: 1px; pointer-events: none; }
.book-title {
  position: relative; font-size: 12px; font-weight: 600; line-height: 1.1; text-align: center;
  letter-spacing: 0.02em; transition: opacity .4s;
}
.book-rule { position: relative; width: 14px; height: 1px; background: var(--foil); }
.book-author {
  position: relative; font-family: var(--font-body); font-style: italic; font-size: 8.5px;
  line-height: 1.15; text-align: center; transition: opacity .4s;
}
.book-overlay { position: absolute; inset: 0; background-color: #1a1817; pointer-events: none; }

/* A book with its real cover (app.js loadCover): the picture replaces the cloth, the
   foil title and the frame (the cover prints its own); the hinge groove stays. The back
   and the spine keep their plain cloth, in the cover's average colour (--fill). */
.book.has-cover .book-face { background: var(--cover) center / cover no-repeat, var(--fill); }
/* A printed cover is a paperback: no boards overhanging the block, so the pages run flush
   to its edges and the corners are square (a cloth book keeps its 2px overhang). */
.book.has-cover :is(.book-face, .book-back) { border-radius: 1px; }
.book.has-cover .book-edge { top: 0; height: 100%; }
.book.has-cover .book-top { bottom: 100%; width: 100%; }
.book.has-cover .book-bottom { top: 100%; width: 100%; }
.book.has-cover :is(.book-pattern, .book-frame, .book-title, .book-rule, .book-author) { display: none; }
/* Bare cover art (Standard Ebooks' painting without its title box): the title and author
   go back on, white on a dark band near the foot, as on their printed covers. */
.book.art.has-cover .book-face {
  justify-content: flex-end; gap: 3px; padding: 0 9px 13px 12px;
  background:
    linear-gradient(transparent 0 58%, rgba(20,18,17,.82) 58% 94%, transparent 94%),
    var(--cover) center / cover no-repeat, var(--fill);
}
.book.art.has-cover :is(.book-title, .book-author) { display: block; color: #fff; }
.book.art.has-cover .book-title {
  font-family: var(--font-body); font-size: 8px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; line-height: 1.12; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.book.art.has-cover .book-author {
  font-style: normal; font-size: 6px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.book.has-cover .book-groove {
  background:
    linear-gradient(90deg, rgba(0,0,0,.4) 0, rgba(0,0,0,.12) 5px, rgba(255,255,255,.1) 6px, transparent 11px),
    linear-gradient(160deg, rgba(255,255,255,.06), transparent 45%);
}
.line-svg { position: absolute; overflow: visible; pointer-events: none; }
.line-dot { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); pointer-events: none; }
.line-anchor {
  position: absolute; top: calc(50% - 204.5px); right: 3.5px; width: 9px; height: 9px;
  border-radius: 50%; border: 1px solid var(--color-accent); background: #1a1817;
}
/* the shelf minimap, just right of the shelves: a small copy of the spiral seen from the side.
   The helix (drawn on the canvas) shows the shelf, or on a long shelf a window of books around
   you that scrolls along; the thin rail at its left stands for the whole shelf (lit: the
   window, the dot: you). The gold bar is where the spiral is turned to, the frame is what's on screen */
.shelf-map {
  position: absolute; left: calc(260px + 22px); top: 50%; width: 64px; height: 140px; /* left: set by smPlace() */
  transform: translateY(-50%); z-index: 3; cursor: pointer;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.shelf-map:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 10px; border-radius: 6px; }
/* the whole-shelf rail is itself a tiny spiral: a thin wave down the full height */
.sm-rail { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.sm-wave { fill: none; stroke: rgba(234,231,231,.2); stroke-width: 1; }
.sm-wave-lit { fill: none; stroke: var(--color-accent); stroke-width: 1.4; }
.sm-dot { fill: var(--color-accent); filter: drop-shadow(0 0 3px rgba(225,173,102,.8)); }
.sm-helix { position: absolute; left: 16px; right: 0; top: 0; bottom: 0; overflow: hidden; pointer-events: none; }
/* a window onto a long shelf fades out at both ends: there is more above and below */
.sm-helix.windowed {
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 8%, #000 92%, transparent);
}
.sm-band {
  position: absolute; left: 3px; right: 3px; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  background: color-mix(in srgb, var(--color-accent) 7%, transparent);
}
.sm-bars { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.sm-cur {
  position: absolute; left: 50%; width: 22px; height: 5px; margin-top: -2.5px; border-radius: 2px; z-index: 4;
  background: var(--color-accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--color-accent) 70%, transparent);
}

.counter {
  position: absolute; right: 70px; bottom: 56px; z-index: 5;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
  font-feature-settings: 'tnum'; pointer-events: none;
}

/* ── search ──────────────────────────────────────────────────────────── */

/* A child of .main, not of the stage: the stage's fade mask would dim it.
   Centred over the stage by syncSearch() (the stage's width is fluid). */
.search { position: absolute; left: 50%; bottom: 56px; transform: translateX(-50%); width: 260px; z-index: 6; }
.search-box {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 5px 0 16px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 45%, transparent);
  border-radius: 999px; background: rgba(26, 24, 23, .88); box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
}
.search-box:focus-within { border-color: var(--color-accent); }
.search-box svg { flex: none; }
.search-input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent;
  color: var(--color-text); font-family: var(--font-body); font-size: 14px; outline: none;
}
.search-list {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); margin: 0; padding: 6px;
  list-style: none; background: rgba(26, 24, 23, .97); border: 1px solid var(--color-divider);
  border-radius: var(--radius-md); box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
}
.search-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px;
  border: 0; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  color: var(--color-text); background: transparent; font-family: var(--font-body);
}
.search-item.sel { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.search-spine {
  flex: none; width: 8px; height: 24px; border-radius: 1px;
  background: linear-gradient(90deg, rgba(0, 0, 0, .35), rgba(255, 255, 255, .08) 45%, rgba(0, 0, 0, .25)), var(--fill);
  box-shadow: inset 0 0 0 1px rgba(201, 169, 106, .35);
}
.search-text { display: flex; flex-direction: column; min-width: 0; }
.search-t { font-family: var(--font-heading); font-size: 15px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-a {
  font-size: 11px; font-style: italic; color: color-mix(in srgb, var(--color-text) 62%, transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-item:hover { background: color-mix(in srgb, var(--color-accent) 9%, transparent); }
.search-item.sel:hover { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
/* the history's header: "Recent" and a way to forget it */
.search-head {
  display: flex; align-items: baseline; justify-content: space-between; padding: 4px 10px 6px;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.search-clear {
  padding: 0; border: 0; background: none; cursor: pointer; font: inherit; letter-spacing: .08em;
  color: var(--color-accent);
}
.search-clear:hover, .search-clear:focus-visible { color: var(--color-text); }
.search-none { padding: 8px 10px; font-size: 13px; font-style: italic; color: color-mix(in srgb, var(--color-text) 62%, transparent); }

/* ── filters ─────────────────────────────────────────────────────────── */

.filter-btn {
  position: relative; flex: none; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; border: 0; border-left: 1px solid var(--color-divider);
  border-radius: 0 999px 999px 0; background: transparent;
  color: color-mix(in srgb, var(--color-text) 75%, transparent); cursor: pointer;
}
.filter-btn.active { color: var(--color-accent); }
.filter-badge {
  position: absolute; top: -4px; right: 0; min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 999px; background: var(--color-accent); color: #1a1817;
  font-size: 10px; line-height: 15px; font-weight: 600; text-align: center; font-feature-settings: 'tnum';
}

.chips {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 520px; display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px; margin: 0; padding: 0; list-style: none;
}
.chips li {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 3px 2px 10px;
  border-radius: 999px; border: 1px solid color-mix(in srgb, var(--color-accent) 50%, transparent);
  background: rgba(26, 24, 23, .85); font-size: 11.5px; white-space: nowrap; color: var(--color-accent-100);
}
.chips button {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--color-accent); cursor: pointer;
}

.fpanel {
  position: absolute; left: 50%; bottom: calc(100% + 12px); transform: translateX(-50%);
  width: 520px; max-height: calc(100vh - 230px); overflow-y: auto; padding: 12px 16px 10px;
  background: rgba(26, 24, 23, .62);
  -webkit-backdrop-filter: blur(12px) saturate(1.2); backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
  border-radius: 10px; box-shadow: 0 18px 40px rgba(0, 0, 0, .5); font-family: var(--font-body);
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
}
.fp-ranges { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 8px; }
.fp-ranges .fp-group { margin-bottom: 0; min-width: 0; }
.fp-group { margin-bottom: 8px; }
/* reading status shares a row with the author field; language gets its own row below */
.fp-mid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; align-items: start; }
.fp-mid-groups { min-width: 0; }
.fp-mid-groups .fp-opts { align-items: center; height: 34px; padding-bottom: 0; }
#fpLangGroups .fp-group { margin-bottom: 10px; }
.fp-author { margin-bottom: 8px; min-width: 0; }
.fp-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.fp-label {
  display: block; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 70%, transparent); margin-bottom: 4px;
}
.fp-row .fp-label { margin-bottom: 0; }
.fp-value { font-size: 12px; font-feature-settings: 'tnum'; color: var(--color-accent-100); }

/* the two-handle range slider: ticks for every book on the shelf, fill between the handles */
.rng-wrap { position: relative; height: 28px; }
.rng-ticks { position: absolute; left: 8px; right: 8px; top: 2px; height: 7px; }
.rng-ticks span { position: absolute; top: 0; width: 1px; height: 7px; }
.rng-track { position: absolute; left: 8px; right: 8px; top: 17px; height: 2px; border-radius: 2px; background: var(--color-divider); }
.rng-fill { position: absolute; top: 0; bottom: 0; background: var(--color-accent); }
.rng {
  -webkit-appearance: none; appearance: none; position: absolute; left: 0; right: 0; top: 8px;
  width: 100%; height: 20px; margin: 0; background: transparent; pointer-events: none;
}
.rng::-webkit-slider-runnable-track { background: transparent; height: 20px; }
.rng::-moz-range-track { background: transparent; }
.rng::-webkit-slider-thumb {
  -webkit-appearance: none; pointer-events: auto; width: 16px; height: 16px; margin-top: 2px;
  border-radius: 50%; background: #1a1817; border: 2px solid #e1ad66;
  box-shadow: 0 0 0 4px rgba(225, 173, 102, .14); cursor: grab;
}
.rng::-moz-range-thumb { pointer-events: auto; width: 12px; height: 12px; border-radius: 50%; background: #1a1817; border: 2px solid #e1ad66; cursor: grab; }
.rng:active::-webkit-slider-thumb { cursor: grabbing; box-shadow: 0 0 0 6px rgba(225, 173, 102, .22); }
.rng:focus { outline: none; }
.rng:focus-visible::-webkit-slider-thumb { outline: 2px solid #e1ad66; outline-offset: 2px; }
.rng:focus-visible::-moz-range-thumb { outline: 2px solid #e1ad66; outline-offset: 2px; }

/* one row: a group with more options than fits scrolls sideways instead of wrapping */
.fp-opts {
  display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; padding-bottom: 3px;
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
}
.fp-opt {
  flex: none; display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--color-divider); background: rgba(255, 255, 255, .03); color: var(--color-text);
  font-family: var(--font-body); font-size: 11.5px; cursor: pointer; white-space: nowrap;
  transition: background .2s, border-color .2s;
}
.fp-opt span { font-size: 10px; opacity: .7; font-feature-settings: 'tnum'; }
.fp-opt.on {
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  border-color: var(--color-accent); color: var(--color-accent-100);
}

.author-wrap { position: relative; }
.author-box {
  display: flex; align-items: center; gap: 2px; height: 34px; padding: 0 4px 0 14px;
  border-radius: 999px; border: 1px solid var(--color-divider); background: rgba(26, 24, 23, .55);
  transition: border-color .2s;
}
.author-box.active { border-color: var(--color-accent); }
.author-input {
  flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent;
  color: var(--color-text); font-family: var(--font-heading); font-size: 15px; outline: none;
}
.author-input.chosen { color: var(--color-accent-100); }
.author-x, .author-chev {
  flex: none; display: flex; align-items: center; justify-content: center; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--color-accent); cursor: pointer;
}
.author-x[hidden], .chips[hidden] { display: none; }
.author-x { width: 26px; height: 26px; }
.author-chev { width: 28px; height: 28px; }
.author-chev svg { transition: transform .2s; }
.author-chev.open svg { transform: rotate(180deg); }
.fpanel.a-open { overflow: visible; }
.author-list {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 4; max-height: 232px;
  overflow-y: auto; margin: 0; padding: 6px; list-style: none; background: rgba(26, 24, 23, .97);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md); box-shadow: 0 14px 34px rgba(0, 0, 0, .55);
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
}
.author-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%;
  padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--color-text); font-family: var(--font-heading); font-size: 15px; text-align: left; cursor: pointer;
}
.author-item.sel { background: color-mix(in srgb, var(--color-accent) 14%, transparent); }
.author-item.chosen { color: var(--color-accent); }
.author-item .author-n {
  flex: none; font-family: var(--font-body); font-size: 11px; font-feature-settings: 'tnum';
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.author-none { padding: 7px 10px; font-size: 13px; font-style: italic; color: color-mix(in srgb, var(--color-text) 62%, transparent); }

.fp-foot {
  display: flex; align-items: center; gap: 6px;
  padding-top: 8px; border-top: 1px solid var(--color-divider);
}
.fp-summary {
  margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--color-divider);
  font-size: 12px; font-feature-settings: 'tnum'; white-space: nowrap;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.fp-spacer { flex: 1; }
.fp-foot .btn-secondary { padding: 5px 14px; }
.fp-switch {
  display: flex; align-items: center; gap: 8px; padding: 4px 0; border: 0; background: transparent;
  color: var(--color-text); font-family: var(--font-body); font-size: 12.5px; text-align: left; cursor: pointer;
}
.sw {
  flex: none; position: relative; width: 34px; height: 18px; border-radius: 999px;
  background: transparent; border: 1px solid var(--color-neutral-600);
  transition: background .25s, border-color .25s;
}
.sw-knob {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--color-neutral-300); transform: translateX(0);
  transition: transform .25s, background .25s;
}
.fp-switch.on .sw { background: var(--color-accent); border-color: var(--color-accent); }
.fp-switch.on .sw-knob { transform: translateX(16px); background: #1a1817; }

/* ── the details panel ───────────────────────────────────────────────── */

.detail {
  flex: 1 1 380px; min-width: 0; max-width: 560px; min-height: 0; overflow-y: auto;
  padding: 16px var(--space-8); border-left: 1px solid var(--color-accent);
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
}
.detail-kicker {
  font-size: 12px; text-decoration: none;
  display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-height: 1.4em; /* keeps the title in place on books without an ISBN */
}
.detail-kicker:hover { text-decoration: underline; }
.detail-title { font-weight: 400; font-size: 52px; margin: var(--space-2) 0 var(--space-1); text-wrap: balance; }
.detail-author { font-style: italic; font-size: 16px; color: color-mix(in srgb, var(--color-text) 75%, transparent); }
.detail-pub { margin-top: 4px; font-size: 13px; font-feature-settings: 'tnum'; color: color-mix(in srgb, var(--color-text) 62%, transparent); }
.detail-pub:empty { display: none; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-3) 0 0; padding: 0; }
.tags li {
  font-size: 11px; letter-spacing: 0.04em; padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--color-accent) 55%, transparent);
  border-radius: 999px; color: var(--color-accent);
}
.detail-desc { text-align: justify; hyphens: auto; text-wrap: pretty; }
/* the description shows its first 3 lines; "Read more" opens the rest */
.detail-desc.clamped {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.desc-more {
  display: block; margin: calc(-1 * var(--space-2)) 0 var(--space-4); padding: 2px 0;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: 12px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--color-accent);
}
.desc-more:hover { text-decoration: underline; text-underline-offset: 3px; }
.desc-more:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 2px; }
.desc-more[hidden] { display: none; }
.facts {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-6);
  font-size: 13px; font-feature-settings: 'tnum'; margin-top: var(--space-4);
}
.facts .k {
  padding: var(--space-2) 0; border-top: 1px solid var(--color-divider);
  letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.facts .v { padding: var(--space-2) 0; border-top: 1px solid var(--color-divider); }

/* editions: tabs over a box that holds everything belonging to the chosen edition */
.ed-wrap { margin-top: var(--space-6); }
.ed-tabs {
  display: flex; align-items: flex-end; gap: 2px; padding: 0 10px 8px;
  overflow-x: auto; scrollbar-width: none;
}
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tab {
  position: relative; flex: none; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px 12px 10px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer;
  color: color-mix(in srgb, var(--color-text) 62%, transparent); transition: color .2s;
}
.ed-tab:hover, .ed-tab[aria-selected="true"] { color: var(--color-text); }
.ed-tab::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 1px;
  background: var(--color-accent); opacity: 0; transition: opacity .2s;
}
.ed-tab[aria-selected="true"]::after { opacity: 1; }
.ed-tab:focus-visible { outline: 2px solid var(--color-accent); outline-offset: -2px; border-radius: 6px; }
.ed-lang { font-family: var(--font-heading); font-size: 17px; line-height: 1.1; white-space: nowrap; }
.ed-meta {
  font-size: 11px; letter-spacing: .04em; white-space: nowrap; font-feature-settings: 'tnum';
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.ed-tab[aria-selected="true"] .ed-meta { color: var(--color-accent); }
.ed-box {
  padding: 0 20px 20px; border-radius: 12px; background: rgba(255,255,255,.02);
  border: 1px solid color-mix(in srgb, var(--color-accent) 38%, transparent);
}
.ed-box .facts { margin-top: 10px; }
.ed-box .facts > :nth-child(-n+2) { border-top-color: transparent; }
.ed-box .ed-progress { margin-top: 0; padding-top: 8px; }
.ed-box .ed-contents { margin-top: 8px; padding-top: 8px; border-top: 0; }
.ed-box .ed-contents .block-head { margin-bottom: 0; }
.ed-box .chapters { margin: 0 -20px; }
.ed-box .actions { margin-top: 8px; }

.block { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-divider); }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-bottom: var(--space-2); }
.block-label {
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.block-value { font-size: 13px; font-feature-settings: 'tnum'; }
.contents-title { font-weight: 400; font-size: 22px; margin: 0; }
.progress-track { height: 3px; border-radius: 2px; background: var(--color-divider); overflow: hidden; }
.progress-fill {
  height: 100%; background: var(--color-accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--color-accent) 60%, transparent);
  transition: width .6s cubic-bezier(.2,.7,.2,1);
}

.chapters {
  cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none;
  position: relative; height: 200px; margin: 0 calc(-1 * var(--space-8)); overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 20%, #000 80%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 20%, #000 80%, transparent 100%);
}
.chapters.dragging { cursor: grabbing; }
.ch-track { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.chapters.dragging .ch-track { transition: none; }
.ch-page {
  position: absolute; top: 0; width: 84px; height: 118px; margin: -59px 0 0 -42px;
  padding: 10px 7px 12px; cursor: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: linear-gradient(90deg, rgba(0,0,0,.12), transparent 14%), #efe6d2;
  color: #2a2520; border: 0; border-radius: 1px 3px 3px 1px;
  font-family: var(--font-body);
  transition: transform .5s cubic-bezier(.2,.7,.2,1), opacity .5s, box-shadow .5s;
}
.chapters.dragging .ch-page { transition: none; }
.ch-unit { font-size: 8.5px; letter-spacing: .14em; text-transform: uppercase; color: #6b5c45; }
.ch-rn { font-family: var(--font-heading); line-height: 1.1; color: #7a5a22; white-space: nowrap; }
.ch-rule { width: 16px; height: 1px; background: #7a5a22; opacity: .6; }
.ch-title {
  font-family: var(--font-heading); font-size: 10.5px; line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ch-mark { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.ch-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-2); }
.ch-nav .btn { font-size: 30px; line-height: 1; width: 40px; height: 40px; padding: 0 0 4px; }
.ch-caption { flex: 1; text-align: center; font-size: 13px; font-feature-settings: 'tnum'; }
.actions { display: flex; gap: var(--space-2); margin-top: var(--space-6); }

/* ── the opened book: the reader (overlay, sidebar, page carousel, page strip) ── */

.read-overlay {
  position: absolute; inset: 0; z-index: 30;
  /* opaque: the library page underneath must not ghost through the backdrop */
  background: radial-gradient(ellipse at 58% 46%, #1e1b18, #0a0908);
  color: var(--color-text);
}
.read-overlay[hidden] { display: none; }

.rd-top {
  position: absolute; left: 48px; right: 48px; top: 28px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.rd-now {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #c9a96a;
}
.rd-now > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-badge {
  flex: none; padding: 3px 9px; border: 1px solid rgba(201,169,106,.35); border-radius: 999px;
  font-size: 10px; letter-spacing: .1em; color: rgba(239,230,210,.6);
}

.rd-side {
  position: absolute; left: 48px; top: 96px; bottom: 48px; width: 320px; z-index: 5;
  display: flex; flex-direction: column; gap: 22px; padding: 24px 22px;
  border-radius: 16px; background: rgba(26,24,23,.6); border: 1px solid rgba(201,169,106,.16);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.rd-book { display: flex; gap: 14px; align-items: center; }
.rd-mini {
  flex: none; position: relative; width: 46px; height: 64px; border-radius: 2px 4px 4px 2px;
  overflow: hidden; background: var(--fill); box-shadow: 0 6px 14px rgba(0,0,0,.5);
}
.rd-mini .mp { position: absolute; inset: 0; background: var(--pattern); }
.rd-mini .me { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.45), transparent 6px); }
.rd-bt { min-width: 0; }
.rd-title { font-family: var(--font-heading); font-size: 20px; line-height: 1.15; }
.rd-author { margin-top: 4px; font-style: italic; font-size: 13px; opacity: .7; }

.rd-prow { display: flex; justify-content: space-between; align-items: baseline; }
.rd-plabel { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .6; }
.rd-pct { font-family: var(--font-heading); font-size: 28px; color: #e8c98a; font-feature-settings: 'tnum'; }
.rd-pbar { position: relative; height: 6px; margin: 10px 0; border-radius: 3px; background: rgba(239,230,210,.1); }
.rd-pfill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--color-accent); }
.rd-phere {
  position: absolute; top: -4px; width: 2px; height: 14px; margin-left: -1px; border-radius: 1px;
  background: #efe6d2; box-shadow: 0 0 6px rgba(239,230,210,.6);
  transition: left .45s cubic-bezier(.2,.7,.2,1);
}
.rd-pstate { font-size: 13px; }
.rd-pleft { margin-top: 3px; font-size: 12px; opacity: .6; font-feature-settings: 'tnum'; }
.rd-resume { width: 100%; margin-top: 16px; }
.rd-tochead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: -12px; }
.rd-tochead span:first-child { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .6; }
.rd-tochead span:last-child { font-size: 12px; opacity: .5; }
.rd-chapters {
  position: relative; flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0 -10px; padding: 0 4px;
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
}
.rd-ch {
  width: 100%; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; gap: 8px;
  align-items: baseline; padding: 8px; border: 0; border-radius: 8px; background: transparent;
  color: rgba(239,230,210,.85); text-align: left; font: inherit; font-size: 13.5px; line-height: 1.3; cursor: pointer;
}
.rd-ch:hover { background: rgba(239,230,210,.06); }
.rd-ch[aria-current="true"] { background: rgba(201,169,106,.16); color: #f6ecd6; }
.rd-ch.done { color: rgba(239,230,210,.5); }
.rd-ch .n { font-size: 11px; color: rgba(239,230,210,.45); font-feature-settings: 'tnum'; }
.rd-ch.done .n { color: var(--color-accent); }
.rd-ch .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-ch .tag { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #e8c98a; }
.rd-ch .pg { font-size: 11px; opacity: .5; font-feature-settings: 'tnum'; }
/* a section inside a chapter: smaller, indented by its nesting (--d), a thin guide line on the left */
.rd-sec {
  box-sizing: border-box; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px; align-items: baseline;
  margin-left: calc(26px + (var(--d) - 1) * 12px); width: calc(100% - 26px - (var(--d) - 1) * 12px);
  padding: 4px 8px 4px 10px; border: 0; border-left: 1px solid rgba(239,230,210,.12); border-radius: 0 6px 6px 0;
  background: transparent; color: rgba(239,230,210,.62); text-align: left; font: inherit;
  font-size: calc(12.5px - (var(--d) - 1) * .5px); line-height: 1.3; cursor: pointer;
}
.rd-sec:hover { background: rgba(239,230,210,.05); color: rgba(239,230,210,.85); }
.rd-sec[aria-current="true"] { color: #f6ecd6; border-left-color: var(--color-accent); background: rgba(201,169,106,.08); }
.rd-sec .n { font-size: 10.5px; color: rgba(239,230,210,.4); font-feature-settings: 'tnum'; }
.rd-sec .n:empty { margin-right: -6px; } /* stays in its grid column, its gap taken back */
.rd-sec .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-sec .pg { font-size: 10.5px; opacity: .45; font-feature-settings: 'tnum'; }
/* a volume / part heading over its chapters */
.rd-gh {
  width: 100%; display: flex; align-items: baseline; gap: 10px; margin-top: 14px; padding: 10px 8px 6px;
  border: 0; border-bottom: 1px solid rgba(201,169,106,.25); background: none;
  color: rgba(239,230,210,.9); text-align: left; font: inherit; cursor: pointer;
}
.rd-gh.first { margin-top: 0; }
.rd-gh.on { color: #f6ecd6; }
.rd-gh:hover .t { color: #f6ecd6; }
.rd-gh .l { flex: none; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--color-accent); }
.rd-gh .l:empty { display: none; }
.rd-gh .t {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-heading); font-size: 18px; line-height: 1.15;
}
.rd-gh .tag { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: #e8c98a; }
/* a part inside a volume: lighter, no rule */
.rd-gh.sub { margin-top: 6px; padding-top: 6px; border-bottom: 0; }
.rd-gh.sub .t { font-size: 15px; }
/* the cover row: a tiny cover where the chapter number goes */
.rd-ch-cover { align-items: center; }
.rd-ch-cover .n img {
  display: block; width: 18px; height: 25px; object-fit: cover; border-radius: 1px;
  box-shadow: 0 2px 5px rgba(0,0,0,.5);
}

.rd-pages {
  position: absolute; left: 368px; right: 0; top: 80px; bottom: 150px; overflow: hidden;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.rd-pages.dragging { cursor: grabbing; }
.rd-wrap { position: absolute; inset: 0; }
.rd-slot {
  position: absolute; left: 50%; top: 50%; width: 480px; height: 660px; margin: -330px 0 0 -240px;
  border-radius: 3px; overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.18), transparent 30%), #efe6d2;
}
.rd-tp {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 56px; text-align: center;
  color: #2a2520; font-family: var(--font-body);
}
.rd-tp .k { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #6b5c45; }
.rd-tp .t { font-family: var(--font-heading); font-size: 42px; line-height: 1.1; }
.rd-tp .r { width: 44px; height: 1px; background: #7a5a22; }
.rd-tp .a { font-style: italic; font-size: 18px; }
.rd-tp .m { margin-top: 28px; font-size: 12px; line-height: 1.7; color: #6b5c45; font-feature-settings: 'tnum'; }
/* the loader on the title page while the book is fetched and laid out:
   a little book flipping its pages over a slim progress bar */
.rd-load { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 26px; }
.rd-load .bk { position: relative; width: 64px; height: 46px; perspective: 160px; }
.rd-load .bk::before, .rd-load .bk::after {
  content: ''; position: absolute; top: 2px; bottom: 0; width: 31px;
  border: 1px solid rgba(122,90,34,.6); background: #f7efdd;
}
.rd-load .bk::before { left: 1px; border-radius: 4px 1px 1px 4px; border-right-color: rgba(122,90,34,.9); }
.rd-load .bk::after { right: 1px; border-radius: 1px 4px 4px 1px; border-left: 0; }
.rd-load .bk i {
  position: absolute; left: 50%; top: 2px; width: 31px; height: 44px; z-index: 1;
  background: linear-gradient(90deg, #efe4cc, #f9f2e2);
  border: 1px solid rgba(122,90,34,.5); border-left: 0; border-radius: 1px 4px 4px 1px;
  transform-origin: left center;
  will-change: transform; /* own compositor layer: keeps flipping while the shelf is built */
  animation: rd-flip 2.4s cubic-bezier(.5,.1,.5,.9) infinite;
}
.rd-load .bk i:nth-child(2) { animation-delay: .2s; }
.rd-load .bk i:nth-child(3) { animation-delay: .4s; }
@keyframes rd-flip {
  0% { transform: rotateY(0); }
  40%, 100% { transform: rotateY(-180deg); }
}
.rd-load .bar {
  position: relative; width: 190px; height: 4px; border-radius: 2px;
  background: rgba(122,90,34,.16); overflow: hidden;
}
.rd-load .bar i {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 2px;
  background: linear-gradient(90deg, #a5803c, #7a5a22);
  transition: width .35s ease;
}
/* a sheen keeps moving even while the width holds, so the wait never looks stuck */
.rd-load .bar i::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,250,235,.55), transparent);
  background-size: 60px 100%; background-repeat: no-repeat;
  animation: rd-sheen 1.5s linear infinite;
}
@keyframes rd-sheen {
  from { background-position: -60px 0; }
  to { background-position: 190px 0; }
}
.rd-load .lb {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: #6b5c45; font-feature-settings: 'tnum';
}
/* the same loader over the whole page while the library loads, on the dark ground */
.boot {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: var(--color-bg); transition: opacity .45s ease, visibility 0s .45s;
}
.boot.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot .rd-load { margin-top: 0; }
.boot .bar { background: color-mix(in srgb, var(--color-accent) 16%, transparent); }
.boot .bar i { background: linear-gradient(90deg, var(--color-accent-700), var(--color-accent)); }
.boot .lb { color: var(--color-neutral-600); }
.boot.failed .bk i { animation: none; }
.boot.failed .bar { visibility: hidden; }
.boot.failed .lb { color: var(--color-accent); }
.rd-pg {
  position: absolute; inset: 0; padding: 40px 48px 30px; display: flex; flex-direction: column;
  font-family: var(--font-body); color: #2a2520;
}
.rd-pg .head {
  text-align: center; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #8a7a60;
  margin-bottom: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rd-chh { text-align: center; margin: 14px 0 24px; }
.rd-chh .l { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #7a5a22; }
.rd-chh .t { font-family: var(--font-heading); font-size: 26px; line-height: 1.15; margin-top: 8px; }
.rd-chh .r { width: 36px; height: 1px; background: #7a5a22; margin: 14px auto 0; }
.rd-pg .body {
  flex: 1; min-height: 0; overflow: hidden;
  font-size: 14.5px; line-height: 1.62; text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.rd-pg .body p { margin: 0; }
/* a volume's / part's own page: whatever else it holds centred under the heading */
.rd-part .body { text-align: center; hyphens: none; -webkit-hyphens: none; }
.rd-part .body p { text-indent: 0 !important; }
.rd-pg .num { text-align: center; font-size: 11px; color: #8a7a60; margin-top: 12px; font-feature-settings: 'tnum'; }
/* the chapter's big first letter stands on the first line and rises into an empty line
   above it (line-height 0, so it doesn't grow the line): the text starts at its foot */
.rd-drop { padding-top: 1.62em; }
.rd-drop::first-letter {
  font-family: var(--font-heading); font-size: 3.3em; line-height: 0;
  padding-right: 3px; color: #7a5a22;
}
/* a heading paragraph out of the epub (front matter, part titles) */
.rd-h {
  font-family: var(--font-heading); font-size: 20px; line-height: 1.35;
  text-align: center; padding: 8px 0 10px; hyphens: none; -webkit-hyphens: none;
}
/* how the epub sets out a paragraph: a quotation or epigraph, verse lines, centred and
   right-aligned lines (signatures, dates), a scene break, a list item */
.rd-q { margin: 0 1.2em 0 2.2em !important; font-size: 13.5px; }
.rd-q + p:not(.rd-q), p:not(.rd-q) + .rd-q { margin-top: .5em !important; }
.rd-v { text-align: left; padding-left: 1.2em; hyphens: manual; -webkit-hyphens: manual; }
.rd-v + .rd-v { margin-top: .6em !important; }
.rd-vl { text-align: left; padding-left: 1.2em; hyphens: manual; -webkit-hyphens: manual; }
.rd-c { text-align: center; }
.rd-r { text-align: right; }
.rd-sep { text-align: center; letter-spacing: .4em; padding: .3em 0; opacity: .7; }
.rd-li { padding-left: 1.4em; text-indent: -1em; }
p sup { font-size: .68em; line-height: 0; vertical-align: .55em; opacity: .8; }
/* a table row out of the epub: its cells in the table's columns, figures to the right */
.rd-tr {
  display: grid; column-gap: .45em; font-size: 12.5px; line-height: 1.62;
  text-align: left; hyphens: auto; -webkit-hyphens: auto;
  border-bottom: 1px solid rgba(80, 60, 40, .12);
}
.rd-tr > div { overflow-wrap: anywhere; }
.rd-tr > .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-tr.th { font-weight: 600; border-bottom-color: rgba(80, 60, 40, .35); }
.rd-tr.j { border-bottom-color: transparent; }
/* a cell spanning rows from above, repeated faded when its rows run on to a new page */
.rd-tr > .carry { visibility: hidden; }
.rd-tr:first-child > .carry { visibility: visible; opacity: .45; }
/* an in-text image: a fixed box, so pagination and the shown page agree */
.rd-im { display: flex; align-items: center; justify-content: center; }
.rd-im img { max-width: 92%; max-height: 100%; }
/* the cover page: the epub's cover image on its own leaf */
.rd-cv { position: absolute; inset: 0; display: flex; background: #171310; }
.rd-cv img { width: 100%; height: 100%; object-fit: contain; }
.rd-pages img { user-select: none; -webkit-user-drag: none; pointer-events: none; }
.rd-arrow {
  position: absolute; z-index: 20; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  padding: 0 0 4px; border-radius: 50%; background: rgba(26,24,23,.7);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 34px; line-height: 1; transition: opacity .4s;
}
.rd-prev { left: calc(50% - 320px); }
.rd-next { left: calc(50% + 320px); }

.rd-stripzone {
  position: absolute; left: calc(368px + (100% - 368px) / 2); bottom: 44px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.rd-striplabel {
  max-width: 760px; font-size: 12px; opacity: .7; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; font-feature-settings: 'tnum';
}
.rd-strip {
  position: relative; width: 760px; height: 80px; overflow: hidden;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}
.rd-strip.dragging { cursor: grabbing; }
.rd-striptrack { position: absolute; left: 50%; top: 20px; width: 0; height: 0; }
.rd-thumb {
  position: absolute; top: 0; width: 34px; height: 46px; margin-left: -17px;
  border: 0; border-radius: 2px; cursor: inherit;
  background: repeating-linear-gradient(180deg, rgba(42,37,32,.32) 0 1px, transparent 1px 4px) content-box, #efe6d2;
  transition: transform .35s cubic-bezier(.2,.7,.2,1), filter .35s, box-shadow .35s;
}
.rd-thumb .mark {
  position: absolute; left: 50%; top: -14px; transform: translateX(-50%);
  font-size: 10px; line-height: 1; letter-spacing: .04em; white-space: nowrap;
  color: var(--color-accent); opacity: .85;
}
.rd-thumb[aria-current="true"] .mark { opacity: 1; }
/* a part's own page: its number over a short rule, set apart from the chapter numbers */
.rd-thumb .mark.part { top: -17px; font-weight: 600; color: var(--color-accent-300); }
.rd-thumb .mark.part::after {
  content: ''; display: block; width: 12px; height: 1px; margin: 2px auto 0; background: currentColor;
}
/* a part page with no text: the heading and maybe a picture, no text lines */
.rd-thumb.part-only { background: #efe6d2; }
.rd-thumb .pic {
  position: absolute; left: 4px; right: 4px; display: flex; align-items: center; justify-content: center;
  background: #efe6d2; overflow: hidden; pointer-events: none;
}
.rd-thumb .pic img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.rd-thumb .pic.fill { inset: 0; border-radius: 2px; background: #2a2520; }
.rd-thumb .pic.fill img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; }
.rd-thumb .num {
  position: absolute; left: -4px; right: -4px; bottom: -15px; font-size: 10px; line-height: 1;
  color: rgba(239,230,210,.45); font-feature-settings: 'tnum';
}
.rd-thumb[aria-current="true"] .num { color: #e8c98a; }


/* в”Ђв”Ђ the auth wall: a closed book cover over the library (Sign In / Register design) в”Ђв”Ђ */

.auth-overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 20px; overflow: auto;
  background: radial-gradient(ellipse at 50% 38%, #242120 0%, #1a1817 62%);
  transition: opacity .6s ease, visibility 0s .6s;
}
.auth-overlay[hidden] { display: none; }
.auth-overlay.done { opacity: 0; visibility: hidden; pointer-events: none; }
/* candle halo behind the book */
.auth-glow {
  position: fixed; top: 50%; left: 50%; width: 1060px; height: 1060px; margin: -530px 0 0 -530px;
  border-radius: 50%; background: radial-gradient(circle, rgba(225, 173, 102, .10) 0%, transparent 60%);
  pointer-events: none; animation: authGlow 5s ease-in-out infinite;
}
@keyframes authGlow { 0%, 100% { opacity: .5; } 50% { opacity: .8; } }
.auth-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 34px; position: relative; flex: none;
  transition: opacity .5s ease;
}
.auth-overlay.opening .auth-head { opacity: 0; }
/* the swinging cover's 3D projection would overflow the overlay: no scrollbar while it opens */
.auth-overlay.opening { overflow: hidden; }
.auth-head span:not(.auth-rule) { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #c9a96a; }
.auth-rule { width: 44px; height: 1px; background: #7a5a22; }

.auth-book { position: relative; width: min(700px, 96vw); perspective: 2200px; flex: none; }
/* behind the cover: the page-flipping loader */
.auth-loader {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 18px;
  align-items: center; justify-content: center;
}
.abl-lbl { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: #c9a96a; }
.abl { position: relative; width: 150px; height: 110px; perspective: 900px; }
.abl .abl-l {
  position: absolute; right: 50%; top: 12px; width: 62px; height: 86px; border-radius: 8px 0 0 8px;
  background: linear-gradient(90deg, #e2d4b4, #efe3c8); transform-origin: right center; transform: rotateY(16deg);
}
.abl .abl-r {
  position: absolute; left: 50%; top: 12px; width: 62px; height: 86px; border-radius: 0 8px 8px 0;
  background: linear-gradient(90deg, #f6ecd6, #e6d9bc); transform-origin: left center; transform: rotateY(-16deg);
}
.abl b { position: absolute; left: 50%; top: 8px; bottom: 8px; width: 2px; margin-left: -1px; background: #b68235; border-radius: 1px; }
.abl i {
  position: absolute; left: 50%; top: 12px; width: 62px; height: 86px; transform-origin: left center;
  border-radius: 0 6px 6px 0; background: linear-gradient(90deg, #efe3c8, #f6ecd6);
  will-change: transform; /* own compositor layer: keeps flipping while the shelf is built */
  animation: ablFlip 1.5s cubic-bezier(.45, .05, .55, .95) infinite;
}
.abl i:nth-child(5) { animation-delay: .2s; }
.abl i:nth-child(6) { animation-delay: .4s; }
@keyframes ablFlip { 0% { transform: rotateY(-14deg); } 100% { transform: rotateY(-166deg); } }

/* the cover: dark leather, gold tooling; signing in swings it open on its spine */
.auth-cover {
  position: relative; margin: 0; border-radius: 16px; display: flex;
  background: linear-gradient(135deg, #2e2822 0%, #262019 55%, #211b15 100%);
  box-shadow: 0 34px 70px rgba(0, 0, 0, .55), 0 6px 18px rgba(0, 0, 0, .4), inset 0 0 18px rgba(0, 0, 0, .3);
  transform-origin: left center; transform-style: preserve-3d;
  transition: transform 1.05s cubic-bezier(.65, 0, .3, 1), opacity .5s ease .5s;
}
#authOv.register .auth-cover { background: linear-gradient(135deg, #332b23 0%, #2a231b 55%, #241d16 100%); }
/* the cover swings open and fades away, leaving only the loader behind it */
.auth-cover.open { transform: rotateY(-108deg); opacity: 0; pointer-events: none; }
/* endpaper: the inside of the front cover */
.auth-endpaper {
  position: absolute; inset: 0; border-radius: 16px; transform: rotateY(180deg); backface-visibility: hidden;
  background: radial-gradient(ellipse at 30% 30%, #e8d9b8 0%, #d9c89f 55%, #cdbc92 100%);
}
/* gold-tooled double frame */
.auth-frame {
  flex: 1; margin: 16px; border: 1px solid rgba(225, 173, 102, .55); border-radius: 2px;
  position: relative; padding: 3px; backface-visibility: hidden;
}
.auth-inner {
  border: 1px solid rgba(225, 173, 102, .25); border-radius: 1px; padding: 56px 58px 42px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  min-height: min(860px, calc(100vh - 200px));
}
.auth-quill { filter: drop-shadow(0 0 8px rgba(225, 173, 102, .35)); }
.auth-edition { margin-top: 22px; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: #c9a96a; }
.auth-title {
  font-family: var(--font-heading); font-weight: 400; font-size: clamp(38px, 7vw, 64px); line-height: 1.12;
  color: #f3d9a2; margin: 14px 0 6px; text-wrap: balance; letter-spacing: normal;
}
/* inputs: centered handwriting lines, dashed gold underline, pen nib that lifts away */
.auth-field { position: relative; width: 100%; max-width: 340px; }
.auth-field-name { max-width: 470px; margin-top: 8px; }
.auth-field + .auth-field, .auth-orn + .auth-field { margin-top: 18px; }
.auth-input {
  background: linear-gradient(180deg, rgba(225, 173, 102, .04), rgba(225, 173, 102, .1));
  border: none; border-bottom: 1px dashed rgba(225, 173, 102, .8); border-radius: 3px 3px 0 0;
  width: 100%; text-align: center; color: #f3d9a2; cursor: text;
  transition: border-color .25s ease, background .25s ease;
}
.auth-input::placeholder { color: #a89066; font-style: italic; opacity: 1; font-family: var(--font-body); }
.auth-input:hover { border-bottom-style: solid; background: linear-gradient(180deg, rgba(225, 173, 102, .08), rgba(225, 173, 102, .15)); }
.auth-input:focus { outline: none; border-bottom: 1px solid #e1ad66; background: linear-gradient(180deg, rgba(225, 173, 102, .08), rgba(225, 173, 102, .15)); }
.auth-input:focus-visible { outline: 2px solid #e1ad66; outline-offset: 4px; }
/* browser autofill paints its own pale-blue box and dark text over the field;
   an inset shadow covers the box (background can't be overridden), the text
   colour is forced, and the background change is postponed out of sight */
.auth-input:-webkit-autofill, .auth-input:-webkit-autofill:hover, .auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f3d9a2; caret-color: #f3d9a2;
  -webkit-box-shadow: 0 0 0 1000px #2d251b inset; box-shadow: 0 0 0 1000px #2d251b inset;
  transition: background-color 100000s ease 0s;
}
/* Chrome draws page-load autofill in its own system font until the first click;
   ::first-line is the one place that still takes the field's font */
.auth-name:-webkit-autofill::first-line { font-family: var(--font-heading); font-style: italic; font-size: clamp(26px, 5vw, 38px); }
.auth-small:-webkit-autofill::first-line { font-family: var(--font-body); font-size: 20px; }
.auth-input:autofill { -webkit-text-fill-color: #f3d9a2; box-shadow: 0 0 0 1000px #2d251b inset; }
.auth-name { font-family: var(--font-heading); font-style: italic; font-size: clamp(26px, 5vw, 38px); font-weight: 400; padding: 2px 42px 10px; }
.auth-small { font-size: 20px; letter-spacing: .05em; padding: 6px 32px 10px; font-family: var(--font-body); }
.auth-pen { position: absolute; right: 11px; bottom: 15px; opacity: .75; pointer-events: none; transition: opacity .2s ease; }
.auth-field:focus-within .auth-pen, .auth-input:not(:placeholder-shown) ~ .auth-pen { opacity: 0; }
.auth-pentag { margin: 14px 0 0; font-style: italic; color: #c9a96a; font-size: 17px; }
.auth-flex { flex: 1; min-height: 24px; }
.auth-orn { display: flex; align-items: center; gap: 10px; margin: 24px 0 20px; }
.auth-orn span { width: 36px; height: 1px; background: #7a5a22; }
.auth-orn b { width: 4px; height: 4px; border-radius: 50%; background: #b68235; }
.auth-error { margin: 18px 0 0; font-style: italic; font-size: 14px; color: #d98f6a; max-width: 400px; }
.auth-open {
  display: inline-block; margin-top: 36px; cursor: pointer;
  background: transparent; border: 1px solid #e1ad66; color: #e1ad66;
  padding: 17px 50px; font-family: var(--font-body); font-size: 14px; letter-spacing: .18em;
  text-transform: uppercase; border-radius: var(--radius-sm);
  transition: background .25s ease, color .25s ease;
}
.auth-open:hover { background: rgba(225, 173, 102, .12); color: #f3d9a2; }
.auth-open:active { background: rgba(225, 173, 102, .2); }
.auth-open:focus-visible { outline: 2px solid #e1ad66; outline-offset: 3px; }
.auth-open:disabled { opacity: .6; cursor: default; }
.auth-switch { margin: 20px 0 0; font-size: 13px; color: #8a7a60; }
.auth-link {
  color: #c9a96a; text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: rgba(225, 173, 102, .4); transition: color .2s ease;
}
.auth-link:hover { color: #f3d9a2; }
.auth-link:focus-visible { outline: 2px solid #e1ad66; outline-offset: 2px; }
.auth-print { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: #6b5c45; margin-top: 26px; }
/* register-only fields */
#authOv:not(.register) .auth-reg { display: none; }

@media (max-width: 560px) { .auth-inner { padding: 40px 22px 32px; } }
@media (prefers-reduced-motion: reduce) {
  .auth-glow { animation: none; }
  .abl i { animation: none; transform: rotateY(-90deg); }
  .auth-cover { transition: opacity .5s ease; }
  .auth-cover.open { transform: none; opacity: 0; }
}

/* the profile: a round icon at the spiral's top-right corner; opens the settings */
.stage-corner { flex: 0 0 0; position: relative; z-index: 7; }
.profile-btn {
  position: absolute; top: 41px; right: 28px; /* centred on the brand: its 48px logo sits at top 36px */
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  width: 38px; height: 38px; padding: 0; border-radius: 50%;
  background: rgba(26, 24, 23, .88); color: var(--color-accent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 45%, transparent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  transition: border-color .2s ease, background .2s ease;
}
.profile-btn[hidden] { display: none; }
.profile-btn:hover { border-color: var(--color-accent); background: #2a241d; }
.profile-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* admin-only frame rate readout in the window's top-right corner */
.fps-meter {
  position: fixed; top: 6px; right: 8px; z-index: 100; pointer-events: none;
  font: 11px/1 ui-monospace, Consolas, monospace; color: var(--color-neutral-300);
  padding: 3px 6px; border-radius: var(--radius-md); background: rgba(10, 9, 8, .6);
}
.fps-meter[hidden] { display: none; }


/* ── user settings: a small dialog with the reader's invitation codes ── */
.set-overlay {
  position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 9, 8, .72); backdrop-filter: blur(3px);
}
.set-overlay[hidden] { display: none; }
.set-card {
  position: relative; width: min(520px, 100%); max-height: calc(100vh - 48px); overflow-y: auto;
  padding: 32px 34px 30px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #2e2822 0%, #262019 55%, #211b15 100%);
  border: 1px solid color-mix(in srgb, var(--color-accent) 45%, transparent);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6);
  scrollbar-width: thin; scrollbar-color: var(--color-neutral-600) transparent;
}
.set-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 50%; color: #a89066;
}
.set-close:hover, .set-close:focus-visible { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); outline: none; }
.set-kicker { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: #c9a96a; }
.set-title { margin: 6px 0 0; font-family: var(--font-heading); font-style: italic; font-weight: 400; font-size: 32px; color: #f3d9a2; overflow-wrap: anywhere; }
.set-role { margin-top: 2px; font-size: 13px; color: #a89066; }
.set-sec { margin-top: 26px; padding-top: 18px; border-top: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent); }
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-head h3 { margin: 0; font-weight: 400; font-size: 18px; font-family: var(--font-heading); color: var(--color-text); }
.set-note { margin: 8px 0 0; font-size: 13px; font-style: italic; color: #a89066; }
.set-note:empty { display: none; }
.inv-list, .inv-readers { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.inv-list:empty, .inv-readers:empty { display: none; }
.inv-list li {
  display: flex; align-items: center; gap: 12px; min-height: 30px; padding: 6px 8px 6px 14px; border-radius: var(--radius-sm);
  background: rgba(225, 173, 102, .06); border: 1px solid rgba(225, 173, 102, .18);
}
.inv-code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 15px; letter-spacing: .08em; color: #f3d9a2; }
.inv-state { flex: 1; min-width: 0; text-align: right; font-size: 12px; color: #a89066; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-list li.used { background: transparent; border-style: dashed; border-color: rgba(225, 173, 102, .12); }
.inv-list li.used .inv-code { color: #7d6a4c; text-decoration: line-through; text-decoration-color: rgba(225, 173, 102, .45); }
.inv-list li:not(.used) .inv-state { color: #9cc08a; }
.inv-copy {
  flex: none; width: 28px; height: 28px; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: #a89066; border: 1px solid rgba(225, 173, 102, .3); border-radius: var(--radius-sm);
}
.inv-copy:hover, .inv-copy:focus-visible { color: var(--color-accent); border-color: var(--color-accent); outline: none; }
.inv-copy.done { color: #9cc08a; border-color: #9cc08a; }
.set-add {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; cursor: pointer;
  background: transparent; color: #a89066; font: inherit; font-size: 13px;
  border: 1px solid rgba(225, 173, 102, .3); border-radius: var(--radius-sm);
}
.set-add:hover, .set-add:focus-visible { color: var(--color-accent); border-color: var(--color-accent); outline: none; }
.set-add:disabled { opacity: .5; cursor: default; }
.set-add[hidden] { display: none; }
.inv-readers li { display: flex; align-items: baseline; gap: 10px; padding: 4px 2px; }
.inv-readers li.set-note { margin: 0; padding: 0; }
.inv-readers .ir-name { font-family: var(--font-heading); font-style: italic; font-size: 19px; color: #f3d9a2; }
.inv-readers .ir-date { margin-left: auto; font-size: 12px; color: #a89066; }
.set-foot { margin-top: 26px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent); display: flex; justify-content: flex-end; }
.set-logout {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer;
  background: transparent; border: none; border-radius: var(--radius-sm);
  color: #a89066; font: inherit; font-size: 14px;
}
.set-logout:hover, .set-logout:focus-visible { color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 10%, transparent); outline: none; }

/* ── the admin's edit dialog (styled as the settings dialog) ── */
.ed-rm { margin-top: 14px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.ed-rm > [hidden], #editBtn[hidden] { display: none; }
.ed-confirm { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 14px; font-style: italic; color: #f3d9a2; }
.ed-danger { color: #e08a74; border-color: rgba(224, 138, 116, .55); }
.ed-danger:hover { background: rgba(224, 138, 116, .12); }
.ed-danger:active { background: rgba(224, 138, 116, .22); }
.ed-danger:disabled { opacity: .5; cursor: default; }
.ed-err { margin: 10px 0 0; font-size: 13px; font-style: italic; color: #e08a74; }
.ed-err:empty { display: none; }
