/*
 * Biblioteca — la stanza (vedi DESIGN.md): noce scuro alle pareti e sugli scaffali,
 * dorsi in pelle tinta, doratura a foglia per titoli e filetti, cuoio verde dello
 * scrittoio per i pannelli, carta vergata per la pagina, lume di candela per la notte.
 */

@font-face { font-family: 'Fell'; src: url('/fonts/IMFeENrm28P.ttf'); font-display: swap; }
@font-face { font-family: 'Fell'; font-style: italic; src: url('/fonts/IMFeENit28P.ttf'); font-display: swap; }
@font-face { font-family: 'Fell SC'; src: url('/fonts/IMFeENsc28P.ttf'); font-display: swap; }
@font-face { font-family: 'Caslon'; src: url('/fonts/LibreCaslonText.ttf'); font-display: swap; }
@font-face { font-family: 'Caslon'; font-style: italic; src: url('/fonts/LibreCaslonText-Italic.ttf'); font-display: swap; }
@font-face { font-family: 'Garamond'; src: url('/fonts/EBGaramond.ttf'); font-display: swap; }
@font-face { font-family: 'Garamond'; font-style: italic; src: url('/fonts/EBGaramond-Italic.ttf'); font-display: swap; }
@font-face { font-family: 'Pica'; src: url('/fonts/IMFePIrm28P.ttf'); font-display: swap; }
@font-face { font-family: 'Pica'; font-style: italic; src: url('/fonts/IMFePIit28P.ttf'); font-display: swap; }

:root {
  --walnut-deep: #1E130D;
  --walnut: #2A1A12;
  --walnut-raised: #3A2519;
  --plank: #5A3822;
  --plank-light: #8A5A36;
  --plank-shadow: #120B07;
  --gilt: #D4AF5A;
  --gilt-bright: #EBCF85;
  --gilt-dim: #9C7D3C;
  --baize: #1F3527;
  --baize-deep: #172A1F;
  --vellum: #EADCBF;
  --vellum-dim: #BFAF8F;
  --paper: #EFE3C8;
  --paper-edge: #DCCBA6;
  --ink: #2A2019;
  --ink-soft: #6B5A48;
  --rubric: #8C2A1C;
  --night-paper: #1A130E;
  --night-edge: #0F0B08;
  --night-ink: #D8C39C;
  --night-ink-soft: #9A8565;
  --night-rubric: #C98A55;
  --ribbon: #9E2B25;
  --error: #E08A6E;

  --display: 'Fell', Georgia, serif;
  --label: 'Fell SC', Georgia, serif;
  --body: 'Caslon', Georgia, serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--walnut-deep);
  color: var(--vellum);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow: hidden; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, input:focus-visible { outline: 2px solid var(--gilt-bright); outline-offset: 2px; }

.icon { display: block; flex: none; }

#app { position: fixed; inset: 0; }

.screen { position: absolute; inset: 0; }
.screen.enter { animation: fade-in 220ms ease-out; }
@keyframes fade-in { from { opacity: 0; } }

/* ------------------------------------------------------------------ parete */

.room {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--walnut-deep);
  background-image:
    radial-gradient(ellipse 110% 70% at 50% 0%, rgba(255, 184, 102, 0.20), rgba(255, 184, 102, 0.06) 45%, transparent 75%),
    var(--grain, none);
  background-attachment: local, local;
  padding-bottom: calc(110px + var(--safe-bottom));
}

.masthead {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(34px + var(--safe-top)) 24px 26px;
}
.masthead h1 {
  margin: 0;
  font: normal 42px/48px var(--display);
  color: var(--gilt);
}
.masthead .gilt-rule { width: 196px; margin: 6px 0 8px; }
.masthead .count { margin: 0; font: 14px/18px var(--label); letter-spacing: 0.06em; color: var(--vellum-dim); }

.gilt-rule { display: block; height: 12px; color: var(--gilt); }

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 24px 14px;
  font: 16px/20px var(--label);
  letter-spacing: 0.06em;
  color: var(--gilt);
}
.section-heading::before, .section-heading::after { content: ''; flex: 1; height: 1px; }
.section-heading::before { background: linear-gradient(90deg, transparent, var(--gilt-dim)); }
.section-heading::after { background: linear-gradient(90deg, var(--gilt-dim), transparent); }
.section-heading.shelves-heading { margin-bottom: 6px; }

.lozenge {
  display: inline-block;
  width: 7px;
  height: 9px;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

/* ------------------------------------------------------------------ pannelli in cuoio */

.leather {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 45%, rgba(0, 0, 0, 0.18)),
    var(--baize);
  border-radius: 3px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.45);
}
.leather::before, .leather::after {
  content: '';
  position: absolute;
  pointer-events: none;
}
.leather::before { inset: 6px; border: 1px solid var(--gilt-dim); }
.leather::after { inset: 9px; border: 0.75px solid rgba(156, 125, 60, 0.55); }

.install-note {
  margin: 0 18px 26px;
  padding: 20px 22px;
  font: 15px/22px var(--body);
  color: var(--vellum);
}
.install-note strong { font: 16px/20px var(--label); letter-spacing: 0.06em; color: var(--gilt); font-weight: normal; display: block; margin-bottom: 6px; }
.install-note p { margin: 0; }
.install-note .share { display: inline-block; vertical-align: -3px; }

/* ------------------------------------------------------------------ leggio */

.lectern {
  display: flex;
  gap: 18px;
  margin: 0 18px 30px;
  padding: 20px;
}
.lectern .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lectern h2 {
  margin: 0;
  font: normal 21px/26px var(--display);
  color: var(--vellum);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.author { font-style: italic; color: var(--vellum-dim); }
.lectern .author { font-size: 15px; line-height: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.small { font: 13px/19px var(--body); color: var(--vellum-dim); }
.lectern .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 6px; }

.cover {
  flex: none;
  width: 84px;
  height: 126px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
}
.cover.large { width: 96px; height: 144px; }

.board {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  text-align: center;
  font: 12px/16px var(--display);
  color: var(--gilt);
  overflow: hidden;
}
.board::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 50%, rgba(0, 0, 0, 0.15));
}
.board::after { content: ''; position: absolute; inset: 5px; border: 1px solid var(--gilt); }
.board span { position: relative; z-index: 1; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.board .lozenge { position: absolute; left: calc(50% - 3.5px); top: 76%; width: 6px; height: 8px; }

.thread { position: relative; height: 8px; margin-top: 12px; }
.thread::before { content: ''; position: absolute; left: 0; right: 0; top: 3px; height: 2px; background: rgba(0, 0, 0, 0.35); }
.thread .fill { position: absolute; left: 0; top: 3px; height: 2px; background: var(--gilt); }
.thread .lozenge { position: absolute; top: 0; width: 6px; height: 8px; margin-left: -3px; color: var(--gilt); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 3px;
  background: var(--gilt);
  color: var(--walnut);
  font: 16px/20px var(--label);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.btn:active { background: var(--gilt-bright); }
.btn.block { display: flex; width: 100%; min-height: 50px; }
.lectern .btn { align-self: flex-start; margin-top: 12px; }

.btn-outline {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(224, 138, 110, 0.6);
  border-radius: 3px;
  color: var(--error);
  font: 14px/18px var(--label);
  letter-spacing: 0.06em;
}

/* ------------------------------------------------------------------ scaffali */

.empty-note { padding: 18px 40px; text-align: center; }
.empty-note .lead { margin: 0 0 10px; font: italic 21px/26px var(--display); color: var(--vellum); }
.empty-note p { margin: 0; font: 15px/22px var(--body); color: var(--vellum-dim); }

.shelf {
  position: relative;
  height: 220px;
  border-left: 8px solid var(--plank);
  border-right: 8px solid var(--plank);
}
/* fondo dello scomparto, più scuro, con l'ombra dell'asse superiore */
.shelf::before {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 206px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.35) 2px, transparent 2px),
    linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 26px),
    rgba(0, 0, 0, 0.28);
}
/* asse: faccia superiore chiara, bordo frontale, ombra sotto */
.shelf::after {
  content: '';
  position: absolute;
  left: -8px; right: -8px; bottom: 0;
  height: 14px;
  background:
    linear-gradient(var(--plank-light), var(--plank-light)) top / 100% 3px no-repeat,
    linear-gradient(rgba(18, 11, 7, 0.8), rgba(18, 11, 7, 0.8)) bottom / 100% 1px no-repeat,
    linear-gradient(180deg, var(--plank), #3E2616);
  z-index: 2;
}
.shelf .row {
  position: absolute;
  left: 10px;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.spine {
  position: relative;
  flex: none;
  width: var(--w);
  height: var(--h);
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.45) 0%, rgba(255, 255, 255, 0.10) 28%, transparent 55%, rgba(0, 0, 0, 0.5) 100%),
    var(--leather);
  transition: transform 260ms var(--ease);
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
.spine.lift, .spine:active { transform: translateY(-10px); transition-duration: 120ms; }
.spine .band { position: absolute; left: 0; right: 0; height: 4.3px; }
.spine .band.top { top: 9px; border-top: 1.6px solid var(--gilt); border-bottom: 0.8px solid rgba(212, 175, 90, 0.7); }
.spine .band.bottom { bottom: 9.4px; border-bottom: 1.6px solid var(--gilt); border-top: 0.8px solid rgba(212, 175, 90, 0.7); }
.spine .nerve {
  position: absolute;
  left: 0; right: 0;
  top: 17%;
  height: 3px;
  background: rgba(255, 255, 255, 0.10);
  box-shadow: 0 3px 0 -1px rgba(0, 0, 0, 0.35);
}
.spine .label {
  position: absolute;
  left: 3px; right: 3px;
  top: 24%; bottom: 20%;
  background: var(--label-leather);
  outline: 0.75px solid rgba(212, 175, 90, 0.85);
  outline-offset: -2.25px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 4px 2px;
}
/* titolo letto dal basso verso l'alto, come sui dorsi italiani */
.spine .title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 100%;
  font: 14px/15px var(--display);
  color: var(--gilt-bright);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spine.narrow .title { font-size: 12px; line-height: 13px; }
.spine.wide .title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.spine .foot {
  position: absolute;
  left: 0; right: 0;
  top: 88%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2px;
  transform: translateY(-50%);
  color: var(--gilt);
}
.spine .foot .lozenge { width: 4.5px; height: 6.4px; }
.spine .foot .lozenge.small-l { width: 2.8px; height: 4px; opacity: 0.8; }
/* segnalibro di seta che pende sotto l'asse */
.spine .silk {
  position: absolute;
  left: 62%;
  top: calc(100% - 4px);
  width: 5px;
  height: 24px;
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 4px), 0 100%);
  z-index: 3;
}

.bookend {
  position: relative;
  flex: none;
  width: 16px;
  height: 88px;
  margin-left: 4px;
}
.bookend::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: linear-gradient(90deg, #8C6A2E, var(--gilt-bright), #6E5222);
}
.bookend::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 5px;
  background: linear-gradient(var(--gilt), #6E5222);
}
.bookend i {
  position: absolute;
  left: 0.3px; top: 7.8px;
  width: 4.4px; height: 4.4px;
  border-radius: 50%;
  background: var(--gilt-bright);
  z-index: 1;
}

.fab {
  position: fixed;
  right: calc(18px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 20px 0 16px;
  border-radius: 3px;
  background: var(--gilt);
  color: var(--walnut);
  font: 16px/20px var(--label);
  letter-spacing: 0.06em;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
  z-index: 5;
}
.fab:active { background: var(--gilt-bright); }

.binding {
  position: fixed;
  left: 18px; right: 18px;
  bottom: calc(88px + var(--safe-bottom));
  padding: 14px 18px;
  background: var(--paper);
  color: var(--ink);
  font: 15px/22px var(--body);
  z-index: 6;
  transform: translateY(20px);
  opacity: 0;
  transition: opacity 200ms, transform 200ms var(--ease);
  pointer-events: none;
}
.binding.on { transform: none; opacity: 1; }
.binding .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.binding .bar { position: relative; height: 4px; margin-top: 8px; background: var(--paper-edge); overflow: hidden; }
.binding .bar::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 40%;
  background: var(--rubric);
  animation: binding 1.2s ease-in-out infinite;
}
@keyframes binding { from { left: -40%; } to { left: 100%; } }

#toast {
  position: fixed;
  left: 18px; right: 18px;
  bottom: calc(88px + var(--safe-bottom));
  padding: 14px 18px;
  background: var(--paper);
  color: var(--ink);
  font: 15px/22px var(--body);
  border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 200ms, transform 200ms var(--ease);
  pointer-events: none;
}
#toast.on { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ fogli e dialoghi */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(10, 6, 4, 0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 200ms ease-out;
}
.scrim.closing { opacity: 0; transition: opacity 180ms; }
.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 86%;
  display: flex;
  flex-direction: column;
  background: var(--baize);
  color: var(--vellum);
  border-radius: 3px 3px 0 0;
  padding-bottom: var(--safe-bottom);
  animation: sheet-up 300ms var(--ease);
}
.scrim.closing .sheet { transform: translateY(30%); transition: transform 180ms; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet .handle { width: 72px; margin: 14px auto 4px; color: var(--gilt-dim); flex: none; }
.sheet .body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 24px 28px; }
.sheet-title { margin: 6px 0 14px; text-align: center; font: normal 22px/28px var(--display); color: var(--gilt); }

.details .head { display: flex; gap: 18px; }
.details h2 { margin: 0; font: normal 22px/28px var(--display); color: var(--vellum); }
.details .author { font-size: 17px; line-height: 26px; }
.details .facts { margin-top: 10px; }
.details .thread { margin-top: 20px; }
.details .status { margin-top: 6px; }
.details .btn.block { margin-top: 20px; min-height: 52px; }
.details .remove { display: flex; justify-content: center; margin-top: 44px; }

.toc-list, .marks-list { list-style: none; margin: 0 -24px; padding: 0; }
.toc-list button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 10px 28px;
  text-align: left;
  font: 17px/26px var(--body);
  color: var(--vellum);
}
.toc-list button.sub { font-size: 15px; line-height: 22px; }
.toc-list button:active { background: rgba(0, 0, 0, 0.2); }
.toc-list button.current { color: var(--gilt-bright); }
.toc-list .here { margin-left: auto; padding-left: 12px; font: 12px/16px var(--label); letter-spacing: 0.06em; color: var(--gilt); }

.marks-empty { margin: 16px 0; text-align: center; font: 15px/22px var(--body); color: var(--vellum-dim); }
.marks-list { margin-top: 16px; }
.marks-list li { display: flex; align-items: center; border-bottom: 1px solid rgba(156, 125, 60, 0.3); padding: 0 12px 0 24px; }
.marks-list .go { flex: 1; min-width: 0; padding: 10px 0; text-align: left; }
.marks-list .where { display: block; font: 12px/16px var(--label); letter-spacing: 0.06em; color: var(--gilt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.marks-list .quote {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font: italic 15px/22px var(--body);
  color: var(--vellum);
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  color: var(--gilt);
}
.marks-list .icon-btn { color: var(--vellum-dim); }

.type-label { margin: 0 0 8px; font: 14px/18px var(--label); letter-spacing: 0.06em; color: var(--vellum-dim); }
.type-row { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.size-btn { width: 48px; height: 48px; border: 1px solid var(--gilt-dim); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--gilt); }
.size-btn:disabled { opacity: 0.35; cursor: default; }
.size-value { flex: 1; text-align: center; font: 22px/28px var(--display); color: var(--vellum); }
.choice {
  flex: 1;
  min-height: 88px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(156, 125, 60, 0.45);
  text-align: center;
}
.choice.on { background: var(--baize-deep); border: 1.5px solid var(--gilt); }
.choice .aa { font-size: 26px; line-height: 32px; color: var(--vellum); }
.choice .name { font-size: 13px; line-height: 19px; color: var(--vellum-dim); }
.swatch { width: 44px; height: 30px; border: 1px solid var(--gilt-dim); margin-bottom: 6px; }
.swatch.DAY { background: var(--paper); }
.swatch.NIGHT { background: var(--night-paper); }
.swatch.AUTO { background: linear-gradient(90deg, var(--paper) 50%, var(--night-paper) 50%); }
.choice .theme-name { font: 13px/19px var(--body); color: var(--vellum); }

.dialog-scrim { align-items: center; padding: 24px; }
.dialog {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 3px;
  animation: fade-in 200ms;
}
.dialog h2 { margin: 0 0 14px; font: normal 22px/28px var(--display); }
.dialog p { margin: 0 0 22px; font: 15px/22px var(--body); color: var(--ink-soft); }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog .actions button { min-height: 44px; padding: 0 14px; font: 16px/20px var(--label); letter-spacing: 0.06em; }
.dialog .confirm { color: var(--rubric); }

/* ------------------------------------------------------------------ lettore */

.reader {
  --page: var(--paper);
  --edge: var(--paper-edge);
  --text: var(--ink);
  --soft: var(--ink-soft);
  --rub: var(--rubric);
  background-color: var(--page);
  background-image: radial-gradient(circle at 50% 50%, transparent 50%, color-mix(in srgb, var(--edge) 70%, transparent) 100%);
  overflow: hidden;
}
.reader.night {
  --page: var(--night-paper);
  --edge: var(--night-edge);
  --text: var(--night-ink);
  --soft: var(--night-ink-soft);
  --rub: var(--night-rubric);
}
.reader .page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.runhead {
  flex: none;
  position: relative;
  height: 44px;
  margin: 0 26px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-bottom: 1px solid color-mix(in srgb, var(--soft) 35%, transparent);
}
.runhead span {
  padding: 0 22px 8px;
  font: 14px/18px var(--label);
  letter-spacing: 0.06em;
  color: var(--rub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.leaf-box { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.leaf {
  /* nessun color-scheme sulla pagina: se iframe e capitolo avessero schemi diversi,
     il browser dipingerebbe sotto il capitolo uno sfondo opaco (bianco) */
  position: absolute;
  inset: 0;
  /* Safari iOS può allargare un iframe al suo contenuto: width 1px + min-width 100% lo impedisce */
  width: 1px;
  min-width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  opacity: 0;
  transition: opacity 90ms;
}
.leaf.ready { opacity: 1; transition-duration: 220ms; }
.runhead span, .runfoot .row { transition: opacity 220ms; }
.reader:not(.ready) .runhead span, .reader:not(.ready) .runfoot .row { opacity: 0; }
.runfoot {
  flex: none;
  height: 40px;
  margin: 0 26px;
  border-top: 1px solid color-mix(in srgb, var(--soft) 35%, transparent);
}
.runfoot .row { display: flex; align-items: center; height: 100%; }
.runfoot .side { flex: 1; font: 12px/16px var(--label); letter-spacing: 0.06em; color: var(--soft); }
.runfoot .side:last-child { text-align: right; }
.runfoot .folio { font: 15px/20px var(--display); color: var(--text); }

/* nastro segnalibro che pende dal bordo superiore della pagina */
.reader .mark-ribbon {
  position: absolute;
  top: 0;
  right: calc(20px + var(--safe-right));
  width: 14px;
  height: calc(46px + var(--safe-top));
  background: var(--ribbon);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 6px), 0 100%);
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 260ms var(--ease);
  pointer-events: none;
  z-index: 3;
}
.reader .mark-ribbon.on { transform: scaleY(1); }

.chrome {
  position: absolute;
  left: 0; right: 0;
  z-index: 10;
  background: var(--walnut);
  color: var(--vellum);
  transition: transform 260ms var(--ease), opacity 200ms;
  opacity: 0;
  pointer-events: none;
}
.chrome.top {
  top: 0;
  display: flex;
  align-items: center;
  padding: calc(6px + var(--safe-top)) calc(4px + var(--safe-right)) 6px calc(4px + var(--safe-left));
  border-bottom: 1px solid var(--gilt-dim);
  transform: translateY(-100%);
}
.chrome.bottom {
  bottom: 0;
  padding: 12px calc(20px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(20px + var(--safe-left));
  border-top: 1px solid var(--gilt-dim);
  transform: translateY(100%);
}
.reader.chrome-on .chrome { transform: none; opacity: 1; pointer-events: auto; }
.chrome .titles { flex: 1; min-width: 0; padding: 0 4px; }
.chrome .titles .t { font: 18px/24px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chrome .titles .a { font: italic 13px/19px var(--body); color: var(--vellum-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chrome .icon-btn.marked { color: #D9584E; }
.chrome .where { font: 13px/19px var(--body); color: var(--vellum-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chrome .actions { display: flex; justify-content: space-evenly; }
.chrome .action {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
  padding: 8px;
  font: 14px/18px var(--label);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.chrome .action .icon { color: var(--gilt); }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  margin: 4px 0;
  background: transparent;
}
input[type='range']::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--gilt) var(--pct, 0%), var(--walnut-raised) var(--pct, 0%)); }
input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: var(--walnut-raised); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--gilt); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: var(--gilt); border: 0; }
input[type='range']::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--gilt); border: 0; }

.noscript { padding: 40px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
