:root {
  color-scheme: dark;
  --ink: #f5f5f2;
  --muted: #9c9c99;
  --panel: #131313;
  --line: #2a2a2a;
  --accent: #ee312f;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #080808;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; }

.topbar {
  min-height: 78px;
  padding: 16px clamp(18px, 4vw, 64px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 8, .92);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: .08em;
  text-decoration: none;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border: 2px solid currentColor;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  right: -5px;
  top: -5px;
  border: 2px solid currentColor;
  background: #080808;
}

.document-title { text-align: center; line-height: 1.25; }
.document-title strong { display: block; font-size: .95rem; letter-spacing: .01em; }
.document-title span { color: var(--muted); font-size: .78rem; }

.download {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  padding: 10px 15px;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 650;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.download:hover { border-color: var(--accent); background: #171717; transform: translateY(-1px); }
.download svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.viewer { padding: clamp(20px, 3.6vw, 54px) clamp(12px, 3vw, 48px) 32px; }

.stage {
  display: grid;
  grid-template-columns: 48px minmax(0, 1260px) 48px;
  gap: clamp(8px, 1.4vw, 22px);
  align-items: center;
  justify-content: center;
}

.page-frame {
  margin: 0;
  min-width: 0;
  position: relative;
}

.page-frame::before {
  content: "";
  position: absolute;
  inset: 3% 4% -2%;
  background: #000;
  filter: blur(30px);
  opacity: .65;
  z-index: -1;
}

#current-page {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: white;
  box-shadow: 0 20px 55px rgba(0, 0, 0, .55);
}

#current-page.is-changing { animation: page-in .22s ease both; }
@keyframes page-in { from { opacity: .55; transform: scale(.993); } to { opacity: 1; transform: scale(1); } }

figcaption {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: .72rem;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity .2s ease;
}

.page-frame:hover figcaption { opacity: 1; }

.nav-button {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, opacity .2s ease;
}

.nav-button:hover:not(:disabled) { border-color: var(--accent); background: #1c1c1c; }
.nav-button:disabled { opacity: .25; cursor: default; }
.nav-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.rail-wrap {
  max-width: 1360px;
  margin: clamp(20px, 3vw, 38px) auto 0;
  position: relative;
}

.rail {
  display: flex;
  gap: 10px;
  padding: 7px 2px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #4a4a4a transparent;
  scroll-snap-type: x proximity;
}

.thumb {
  flex: 0 0 138px;
  margin: 0;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  opacity: .56;
  scroll-snap-align: center;
  transition: opacity .18s ease, border-color .18s ease, transform .18s ease;
}

.thumb:hover { opacity: .9; transform: translateY(-2px); }
.thumb.active { opacity: 1; border-color: var(--accent); }
.thumb img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #fff; }
.thumb span { display: block; padding: 7px 2px 3px; color: var(--muted); font-size: .72rem; text-align: left; }
.thumb.active span { color: #fff; }

footer {
  min-height: 74px;
  padding: 20px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .78rem;
}

footer a { text-decoration: none; }
footer a:hover { color: #fff; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

@media (max-width: 720px) {
  .topbar { min-height: 66px; grid-template-columns: 1fr auto; }
  .document-title { display: none; }
  .download { padding: 9px 11px; }
  .download span { display: none; }
  .viewer { padding-inline: 0; }
  .stage { grid-template-columns: 1fr; gap: 12px; }
  .page-frame { grid-row: 1; }
  .nav-button { position: absolute; z-index: 4; top: 50%; width: 42px; height: 42px; background: rgba(10, 10, 10, .84); }
  .nav-button.previous { left: 8px; }
  .nav-button.next { right: 8px; }
  .rail-wrap { margin-top: 18px; padding-inline: 12px; }
  .thumb { flex-basis: 112px; }
  figcaption { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
