:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e4e5e7;
  color: #f1f3f4;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input { font: inherit; }
button,
a { -webkit-tap-highlight-color: transparent; }

.toolbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) auto minmax(12rem, 1fr);
  align-items: center;
  min-height: 3.5rem;
  padding: 0.45rem 0.75rem;
  gap: 0.75rem;
  background: #202124;
  box-shadow: 0 1px 4px rgb(0 0 0 / 38%);
  user-select: none;
}

.document-title,
.page-controls,
.document-actions,
.zoom-controls { display: flex; align-items: center; }

.document-title {
  min-width: 0;
  gap: 0.55rem;
  overflow: hidden;
  white-space: nowrap;
}

.brand-mark {
  width: 0.28rem;
  height: 1.65rem;
  flex: 0 0 auto;
  border-radius: 99px;
  background: #da291c;
}

.brand {
  color: #fff;
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.title-divider,
.action-divider {
  width: 1px;
  height: 1.5rem;
  flex: 0 0 auto;
  background: rgb(255 255 255 / 18%);
}

.title-text {
  overflow: hidden;
  color: #d8dadd;
  font-size: 0.88rem;
  text-overflow: ellipsis;
}

.page-controls { justify-content: center; gap: 0.25rem; }
.document-actions { justify-content: flex-end; gap: 0.28rem; }
.zoom-controls { gap: 0.12rem; }

.icon-button,
.zoom-value {
  display: inline-grid;
  height: 2.35rem;
  min-width: 2.35rem;
  padding: 0;
  border: 0;
  border-radius: 0.35rem;
  place-items: center;
  color: #e8eaed;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.icon-button:hover:not(:disabled),
.zoom-value:hover:not(:disabled) { background: rgb(255 255 255 / 11%); }

.icon-button:focus-visible,
.zoom-value:focus-visible,
.page-field input:focus-visible,
.viewer-container:focus-visible {
  outline: 2px solid #8ab4f8;
  outline-offset: -2px;
}

.icon-button:disabled,
.zoom-value:disabled { color: #777b80; cursor: default; }

.icon-button svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .pdfjs-print-icon,
.icon-button .pdfjs-download-icon,
.icon-button .pdfjs-presentation-icon {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
  stroke: none;
}

.print-frame {
  position: fixed;
  width: 1px;
  height: 1px;
  inset: auto auto 0 -10000px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.zoom-value {
  min-width: 3.35rem;
  padding-inline: 0.35rem;
  color: #d4d7db;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.page-field input {
  width: 3rem;
  height: 1.8rem;
  padding: 0.25rem 0.3rem;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 0.25rem;
  color: #fff;
  background: #303134;
  text-align: center;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.page-field input::-webkit-inner-spin-button,
.page-field input::-webkit-outer-spin-button { margin: 0; appearance: none; }
.page-field input:disabled { color: #8d9196; }

.page-total {
  min-width: 3.4rem;
  color: #bdc1c6;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.viewer-container {
  position: relative;
  height: calc(100vh - 3.5rem);
  height: calc(100dvh - 3.5rem);
  overflow: auto;
  overscroll-behavior: contain;
  background: #e4e5e7;
  scrollbar-color: #9ba0a6 #d7d9dc;
  scrollbar-width: thin;
}

.pdf-viewer {
  display: flex;
  width: 100%;
  min-height: 100%;
  padding: 1.5rem max(1rem, calc((100% - 75rem) / 2));
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.pdf-page {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  color-scheme: light;
  background: #fff;
  box-shadow: 0 2px 8px rgb(24 26 28 / 28%), 0 0 0 1px rgb(24 26 28 / 10%);
}

.viewer-container.is-presentation-mode {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  user-select: none;
}

.viewer-container.is-presentation-mode .pdf-viewer {
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 1rem;
  justify-content: center;
  gap: 0;
}

.viewer-container.is-presentation-mode .pdf-page { display: none; box-shadow: none; }
.viewer-container.is-presentation-mode .pdf-page.is-presenting { display: block; }
.viewer-container.is-presentation-mode .text-layer span { cursor: default; }

.pdf-page canvas,
.text-layer,
.annotation-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pdf-page canvas { display: block; }

.page-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8a8d91;
  background: linear-gradient(110deg, #fff 30%, #f3f4f5 46%, #fff 62%);
  background-size: 250% 100%;
  font-size: 0.78rem;
  animation: page-loading 1.35s ease-in-out infinite;
}

.pdf-page.is-rendered .page-placeholder { display: none; }
.pdf-page.has-error .page-placeholder { color: #9b1c1c; animation: none; }

.text-layer {
  z-index: 2;
  overflow: hidden;
  line-height: 1;
  opacity: 1;
  text-size-adjust: none;
  transform-origin: 0 0;
}

.text-layer span,
.text-layer br {
  position: absolute;
  color: transparent;
  white-space: pre;
  cursor: text;
  transform-origin: 0 0;
}

.text-layer ::selection { color: transparent; background: rgb(62 125 231 / 32%); }
.annotation-layer { z-index: 3; pointer-events: none; }
.annotation-layer a { position: absolute; pointer-events: auto; }
.annotation-layer a:hover { outline: 2px solid rgb(60 115 220 / 45%); background: rgb(60 115 220 / 8%); }

.loading-panel {
  position: fixed;
  z-index: 10;
  inset: calc(50% + 1.75rem) auto auto 50%;
  display: flex;
  min-width: 12rem;
  padding: 0.8rem 1rem;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  border-radius: 0.5rem;
  color: #f1f3f4;
  background: rgb(32 33 36 / 94%);
  box-shadow: 0 4px 18px rgb(0 0 0 / 24%);
  font-size: 0.85rem;
  transform: translate(-50%, -50%);
}

.loading-panel[hidden] { display: none; }
.loading-panel.error { max-width: min(30rem, calc(100vw - 2rem)); color: #ffd7d3; }

.spinner {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  border: 2px solid rgb(255 255 255 / 24%);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.error .spinner { display: none; }

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

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes page-loading { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (max-width: 760px) {
  .toolbar {
    grid-template-columns: minmax(4.6rem, 1fr) auto minmax(4.6rem, 1fr);
    padding-inline: 0.4rem;
    gap: 0.2rem;
  }
  .title-divider,
  .title-text,
  .zoom-controls,
  .action-divider,
  .optional-action { display: none; }
  .document-title { gap: 0.4rem; }
  .brand { font-size: 0.68rem; letter-spacing: 0.05em; }
  .document-actions { gap: 0; }
  .page-field input { width: 2.65rem; }
  .page-total { min-width: 2.8rem; font-size: 0.76rem; }
  .pdf-viewer { padding: 0.85rem 0.65rem 1.5rem; gap: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  .toolbar { display: none; }
  .viewer-container { height: auto; overflow: visible; background: #fff; }
  .pdf-viewer { padding: 0; gap: 0; }
  .pdf-page { break-after: page; box-shadow: none; }
}
