html:has(.document-preview[open]) {
  overflow: hidden;
}
.document-preview {
  width: min(940px, calc(100% - 28px));
  height: min(90dvh, 1000px);
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--line, #ded8cf);
  border-radius: 6px;
  background: #f8f6f2;
  color: #393632;
}
.document-preview[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}
.document-preview::backdrop {
  background: rgb(30 27 24 / 65%);
}
.document-preview-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 18px;
  padding: 14px clamp(12px, 3vw, 24px);
  border-bottom: 1px solid #ded8cf;
}
.document-preview-toolbar h2 {
  margin: 0;
  font-size: clamp(20px, 3vw, 26px);
}
.document-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px 16px;
  flex-wrap: wrap;
  font-size: 16px;
}
.document-preview-actions a {
  color: #2c4a63;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.document-preview-actions button {
  background: #2c4a63;
  color: #f8f6f2;
  min-height: 44px;
  padding: 6px 16px;
  border-radius: 4px;
}
.document-preview :focus-visible {
  outline: 2px solid #2c4a63;
  outline-offset: 2px;
}
.document-preview-pages {
  position: relative;
  padding: clamp(8px, 2vw, 24px);
  overflow: auto;
  overscroll-behavior: contain;
  background: #ebe7e1;
}
.document-preview-pages figure {
  margin: 0 0 12px;
}
.document-preview-pages img {
  display: block;
  width: 100%;
  height: auto;
  background: white;
}
.document-preview-page-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media print {
  .document-preview {
    display: none !important;
  }
}
