:root {
  --toolbar-height: 46px;
  --ink: #181818;
  --muted: #666;
  --rule: #c7c7c7;
  --surface: #fff;
  --stage: #d7d7d7;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--stage);
  color: var(--ink);
}

button,
input,
.toolbar-link {
  min-width: 34px;
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--ink);
  font: 600 13px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button:hover,
button:focus-visible,
.toolbar-link:hover,
.toolbar-link:focus-visible {
  border-color: var(--rule);
  background: #f1f1f1;
  outline: none;
}

.viewer-toolbar {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: calc(var(--toolbar-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 10px 0;
  border-bottom: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.page-controls,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.page-controls {
  justify-self: start;
}

.zoom-controls {
  justify-self: center;
}

#pageNumber {
  width: 42px;
  min-width: 42px;
  padding: 0 5px;
  border-color: var(--rule);
  text-align: center;
}

#pageCount {
  min-width: 34px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  text-decoration: none;
}

#viewerContainer {
  position: absolute;
  inset: calc(var(--toolbar-height) + env(safe-area-inset-top)) 0 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.pdfViewer {
  padding: 12px 0 30px;
}

.pdfViewer .page {
  margin: 0 auto 12px;
  border: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

#loading,
#error {
  position: fixed;
  z-index: 30;
  top: calc(var(--toolbar-height) + env(safe-area-inset-top) + 18px);
  left: 50%;
  translate: -50% 0;
  max-width: min(90vw, 460px);
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

#error {
  color: #7a201c;
}

#error a {
  color: #174ea6;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 560px) {
  .viewer-toolbar {
    grid-template-columns: auto 1fr auto;
    padding-inline: 4px;
  }

  #fitWidth,
  #previous,
  #next {
    display: none;
  }

  .zoom-controls {
    justify-self: center;
  }

  .toolbar-link {
    padding-inline: 5px;
  }

  .pdfViewer {
    padding-top: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
