.pdf-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10020;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  background: rgba(2, 6, 23, 0.86);
  backdrop-filter: blur(10px);
}

.pdf-preview-backdrop.hidden {
  display: none !important;
}

.pdf-preview-dialog {
  width: min(100%, 1180px);
  min-height: 100dvh;
  max-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: #0f172a;
  color: #ffffff;
}

.pdf-preview-header,
.pdf-preview-controls {
  position: sticky;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem;
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(148, 163, 184, 0.24);
}

.pdf-preview-header {
  top: 0;
  justify-content: space-between;
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
}

.pdf-preview-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: clamp(0.96rem, 4vw, 1.2rem);
  font-weight: 950;
  line-height: 1.18;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-preview-close,
.pdf-preview-button,
.pdf-preview-download,
.pdf-preview-fallback-link {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
}

.pdf-preview-close {
  flex: 0 0 auto;
  font-size: 1.35rem;
}

.pdf-preview-button:disabled,
.pdf-preview-download[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.42;
}

.pdf-preview-close:focus-visible,
.pdf-preview-button:focus-visible,
.pdf-preview-download:focus-visible,
.pdf-preview-fallback-link:focus-visible {
  outline: 3px solid rgba(96, 165, 250, 0.9);
  outline-offset: 2px;
}

.pdf-preview-body {
  min-height: 0;
  overflow: auto;
  padding: 0.85rem;
  background:
    radial-gradient(circle at top, rgba(30, 90, 168, 0.20), transparent 34rem),
    #111827;
}

.pdf-preview-stage {
  width: 100%;
  min-height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.pdf-preview-canvas {
  width: var(--pdf-preview-canvas-width, auto) !important;
  max-width: calc(100vw - 1.7rem) !important;
  height: var(--pdf-preview-canvas-height, auto) !important;
  flex: 0 0 auto;
  display: block;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.pdf-preview-canvas.is-zoomed {
  max-width: none !important;
}

.pdf-preview-status,
.pdf-preview-fallback {
  width: min(100%, 680px);
  margin: 1rem auto;
  padding: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.86);
  color: #e2e8f0;
  font-weight: 850;
  line-height: 1.45;
  text-align: center;
}

.pdf-preview-fallback {
  display: grid;
  gap: 0.8rem;
}

.pdf-preview-fallback[hidden],
.pdf-preview-status[hidden],
.pdf-preview-canvas[hidden] {
  display: none !important;
}

.pdf-preview-fallback-link {
  width: fit-content;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  background: #ffffff;
  color: #0b2f5b;
}

.pdf-preview-controls {
  bottom: 0;
  flex-wrap: wrap;
  justify-content: center;
  border-top: 1px solid rgba(148, 163, 184, 0.24);
}

.pdf-preview-page-label,
.pdf-preview-zoom-label {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #e2e8f0;
  font-size: 0.86rem;
  font-weight: 950;
  line-height: 1;
}

.pdf-preview-download {
  padding: 0 0.85rem;
  background: #ffffff;
  color: #0b2f5b;
}

@media (min-width: 768px) {
  .pdf-preview-backdrop {
    padding: 1rem;
  }

  .pdf-preview-dialog {
    min-height: auto;
    max-height: calc(100dvh - 2rem);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 24px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
  }

  .pdf-preview-body {
    padding: 1.1rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .pdf-preview-dialog {
    animation: pdfPreviewIn 0.16s ease-out;
  }
}

@keyframes pdfPreviewIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
