:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --toolbar: #1c2527;
  --toolbar-border: #344143;
  --toolbar-text: #f7f9f8;
  --muted: #aeb9b7;
  --viewer: #e8eceb;
  --control: #2a3537;
  --control-hover: #3a484a;
  --accent: #b8e23c;
  --accent-hover: #c8ee56;
  --focus: #f3cf3f;
  --paper-shadow: 0 10px 32px rgb(24 32 34 / 18%);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--viewer);
  color: #172022;
}

button,
input,
a {
  font: inherit;
  letter-spacing: 0;
}

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

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
}

.toolbar {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px 20px;
  color: var(--toolbar-text);
  background: var(--toolbar);
  border-bottom: 1px solid var(--toolbar-border);
  box-shadow: 0 2px 10px rgb(20 28 30 / 22%);
}

.document-identity,
.toolbar-actions,
.control-group,
.page-control,
.download-button {
  display: flex;
  align-items: center;
}

.document-identity {
  min-width: 0;
  gap: 12px;
}

.document-icon {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--toolbar);
  background: var(--focus);
  border-radius: 6px;
}

.document-icon svg {
  width: 21px;
  height: 21px;
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  max-width: 440px;
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-block p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.toolbar-actions {
  flex: 0 0 auto;
  gap: 10px;
}

.control-group {
  height: 40px;
  gap: 2px;
  padding: 3px;
  background: var(--control);
  border: 1px solid var(--toolbar-border);
  border-radius: 6px;
}

.icon-button,
.fit-button {
  height: 32px;
  color: var(--toolbar-text);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 32px;
  padding: 0;
  place-items: center;
}

.icon-button svg,
.download-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.fit-button {
  min-width: 70px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 600;
}

.icon-button:hover:not(:disabled),
.fit-button:hover:not(:disabled) {
  background: var(--control-hover);
}

.icon-button:disabled,
.fit-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.page-control {
  gap: 5px;
  min-width: 72px;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.page-control input {
  width: 31px;
  height: 28px;
  padding: 0;
  color: var(--toolbar-text);
  text-align: center;
  background: transparent;
  border: 0;
  border-radius: 3px;
  appearance: textfield;
}

.page-control input::-webkit-inner-spin-button,
.page-control input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.download-button {
  height: 40px;
  gap: 8px;
  padding: 0 14px;
  color: #172022;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  background: var(--accent);
  border-radius: 6px;
}

.download-button:hover {
  background: var(--accent-hover);
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
.viewer:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.viewer {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 32px;
  overflow: auto;
  background: var(--viewer);
  overscroll-behavior: contain;
}

.page-surface {
  width: max-content;
  min-width: min-content;
  margin: 0 auto;
  background: white;
  box-shadow: var(--paper-shadow);
}

#pdfCanvas {
  display: block;
  max-width: none;
  background: white;
}

.loading-state,
.error-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5859;
  font-size: 14px;
}

.loading-state {
  gap: 10px;
}

.loading-state[hidden] {
  display: none;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #bdc7c5;
  border-top-color: #2d6e63;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.error-state {
  gap: 12px;
}

.error-state[hidden] {
  display: none;
}

.error-state svg {
  width: 24px;
  height: 24px;
  color: #b14832;
}

.error-state strong {
  display: block;
  color: #172022;
  font-size: 15px;
}

.error-state p {
  margin: 4px 0 0;
}

.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;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .toolbar {
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 14px;
  }

  .document-identity {
    flex: 1 1 280px;
  }

  .toolbar-actions {
    flex: 1 1 auto;
    justify-content: flex-end;
  }

  .viewer {
    padding: 20px;
  }
}

@media (max-width: 560px) {
  .toolbar {
    min-height: 112px;
    align-content: center;
    padding: 10px 12px;
  }

  .document-icon {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .title-block h1 {
    max-width: calc(100vw - 78px);
    font-size: 14px;
  }

  .title-block p {
    font-size: 11px;
  }

  .toolbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .zoom-controls {
    display: none;
  }

  .download-button {
    padding: 0 12px;
  }

  .viewer {
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.6s;
  }
}
