:root {
  --ink: #0a0c0e;
  --paper: #ffffff;
  --rule: #e6e4e0;
  --desk: #eceae6;
  --bar: 3.25rem;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--desk);
  color: #1b1f23;
  font-family: "Inter Tight", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- top bar ---- */
.rbar {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  height: var(--bar);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 1rem; padding: 0 clamp(0.8rem, 2vw, 1.6rem);
  background: var(--ink); color: #fff;
}
.rbar a { color: #fff; text-decoration: none; }
.rbar__back {
  font-size: 0.78rem; letter-spacing: 0.02em; opacity: 0.75;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rbar__back:hover { opacity: 1; }
.rbar__mid { display: flex; align-items: center; gap: 0.5rem; }
.rbar__mid input {
  width: 3.6rem; padding: 0.3rem 0.4rem; text-align: center;
  font: inherit; font-size: 0.8rem; color: #fff;
  background: #1b2024; border: 1px solid #2c3237; border-radius: 0;
  -moz-appearance: textfield;
}
.rbar__mid input::-webkit-outer-spin-button,
.rbar__mid input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.rbar__count { font-size: 0.78rem; opacity: 0.6; min-width: 3.2rem; }
.rbar button {
  font: inherit; font-size: 0.82rem; line-height: 1;
  padding: 0.42rem 0.6rem; cursor: pointer;
  color: #fff; background: transparent;
  border: 1px solid #2c3237; border-radius: 0;
}
.rbar button:hover { background: #1b2024; border-color: #3a4147; }
.rbar button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.rbar__tools { display: flex; align-items: center; gap: 0.4rem; justify-self: end; }
.rbar__dl {
  font-size: 0.78rem; padding: 0.45rem 0.7rem;
  border: 1px solid #2c3237;
}
.rbar__dl:hover { background: #1b2024; }

.progress { position: fixed; top: var(--bar); left: 0; right: 0; height: 2px; z-index: 11; }
.progress i {
  display: block; height: 100%; background: #00aeef; transform-origin: 0 50%;
  transform: scaleX(0); transition: transform 0.25s linear;
}

/* ---- pages ---- */
.reader { padding: calc(var(--bar) + 2rem) 0 4rem; }
.pages {
  display: grid; gap: clamp(0.8rem, 1.6vw, 1.4rem);
  justify-items: center;
}
.page {
  position: relative; width: 100%; max-width: 920px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(20, 20, 20, 0.08), 0 8px 24px rgba(20, 20, 20, 0.06);
  overflow: hidden;
}
.page canvas { display: block; }
.page--blank::after {
  content: "This page is blank in the printed report";
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.72rem; letter-spacing: 0.08em; color: #c2beb7;
  pointer-events: none;
}
.page__no {
  position: absolute; inset: auto auto 0.5rem 0.6rem;
  font-size: 0.6rem; letter-spacing: 0.12em; color: #b9b5ae;
  font-variant-numeric: tabular-nums; pointer-events: none;
}

.status[hidden] { display: none; }
.status {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--desk); color: #6d7278; font-size: 0.9rem;
}

@media (max-width: 720px) {
  .rbar { grid-template-columns: auto 1fr auto; gap: 0.4rem; padding: 0 0.6rem; }
  /* on a phone the title eats the bar, so keep the arrow only and show the
     page count instead */
  .rbar__back span { display: none; }
  .rbar__count { display: inline; min-width: 0; font-size: 0.7rem; }
  .rbar button { min-width: 2.4rem; min-height: 2.4rem; }
  .rbar__back { white-space: nowrap; overflow: hidden; }
  .rbar__back { display: inline-flex; align-items: center; gap: 0.35rem; }
  .rbar__mid { gap: 0.3rem; }
  .rbar__mid input { width: 2.8rem; padding: 0.25rem 0.2rem; }
  #zout, #zin, #zfit { display: none; }
  .rbar button { padding: 0.4rem 0.5rem; }
  .rbar__dl { padding: 0.42rem 0.55rem; font-size: 0.72rem; }
  .reader { padding-top: calc(var(--bar) + 0.8rem); }
  .pages { gap: 0.6rem; }
  .page { max-width: 100%; }
}

/* a whole spread needs more room than a single page */
body.reader--spread .page { max-width: 1240px; }

/* text layer: invisible glyphs over the canvas, so pages can be copied and
   searched. Sizes come from pdf.js through --scale-factor. */
.textLayer {
  position: absolute; top: 0; left: 0;
  overflow: hidden;
  line-height: 1;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 2;
}
.textLayer span,
.textLayer br {
  color: transparent;
  position: absolute;
  white-space: pre;
  cursor: text;
  transform-origin: 0% 0%;
}
.textLayer span::selection { background: rgba(0, 173, 239, 0.32); }
.textLayer br::selection { background: rgba(0, 173, 239, 0.32); }
.textLayer .endOfContent {
  display: block; position: absolute; inset: 100% 0 0;
  z-index: -1; cursor: default; user-select: none;
}

/* the back link is only an arrow on phones; give it a finger-sized target */
@media (max-width: 52rem) {
  .rbar__back { padding: 0.55rem 0.6rem; margin: -0.55rem 0 -0.55rem -0.6rem; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* the cover shown while the first canvas is still being fetched */
.page__ph { display: block; width: 100%; height: auto; }
