.resource-thumbnail {
  max-width: 220px;
  max-height: 150px;
  border: 1px solid var(--line);
  border-radius: 0;
  object-fit: cover;
}

main.preview-main {
  width: calc(100% - 2 * clamp(16px, 1.5vw, 28px));
  max-width: none;
  margin-inline: auto;
  padding: 12px 0 32px;
}

.preview-panel {
  min-width: 0;
  overflow: hidden;
  padding: clamp(10px, 1.2vw, 18px);
}

.preview-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(10px, 1.5vw, 20px);
  padding-bottom: clamp(10px, 1vw, 14px);
  border-bottom: 1px solid var(--line);
}

.preview-back { white-space: nowrap; }
.preview-title { min-width: 0; }
.preview-title .eyebrow { margin: 0 0 2px; font-size: .78rem; }
.preview-title h1 {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.2;
}
.preview-page-count { margin: 0; color: var(--muted); white-space: nowrap; }

.preview-security-note,
.guest-document-preview__notice {
  margin: 10px 0 0;
  padding: 8px 12px;
  font-size: .9rem;
}

.preview-viewport {
  min-width: 0;
  border: 1px solid var(--line);
  background: #e9e4da;
}

.preview-viewport--document,
.preview-viewport--video,
.preview-viewport--image {
  display: grid;
  place-items: center;
  margin-top: 10px;
  overflow: auto;
}

.preview-viewport--video { background: #111; }
.preview-viewport--image { min-height: clamp(420px, 68dvh, 900px); padding: clamp(8px, 1vw, 16px); }

.preview-frame {
  display: block;
  width: 100%;
  height: clamp(520px, calc(100dvh - 230px), 1080px);
  border: 0;
  border-radius: 0;
  background: #fff;
}

video.preview-media {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 230px);
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #111;
  object-fit: contain;
}

img.preview-media {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(100dvh - 250px);
  margin: auto;
  border: 0;
  border-radius: 0;
  object-fit: contain;
}

.guest-document-preview {
  display: grid;
  gap: 10px;
}

.guest-document-preview__controls {
  position: sticky;
  top: calc(var(--site-header-height) + 8px);
  z-index: var(--z-sticky-panel);
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(247, 243, 234, .97);
  box-shadow: 0 10px 24px rgba(36, 30, 24, .08);
  backdrop-filter: blur(8px);
}

.guest-document-preview__jump {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
}

.guest-document-preview__jump input { width: 5.5rem; text-align: center; }
.guest-document-preview__controls .is-disabled { opacity: .38; pointer-events: none; }

.guest-document-preview__stage {
  position: relative;
  display: grid;
  width: 100%;
  height: clamp(440px, 68dvh, 900px);
  place-items: start center;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: clamp(8px, 1vw, 16px);
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(38, 31, 24, .035) 50%, transparent 50.1%),
    #e9e4da;
}

.guest-document-preview__page {
  display: block;
  width: min(100%, 1100px);
  max-width: none;
  max-height: none;
  border: 1px solid rgba(40, 34, 29, .14);
  background: #fff;
  box-shadow: 0 16px 44px rgba(37, 30, 23, .16);
  opacity: 0;
}

.guest-document-preview__page.is-loaded { opacity: 1; }
.guest-document-preview__loading { position: absolute; inset: 50% auto auto 50%; margin: 0; color: var(--muted); transform: translate(-50%, -50%); }
.guest-document-preview__load-error { max-width: 560px; align-self: center; }

.guest-document-preview__state {
  display: grid;
  min-height: 320px;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 32px;
  border: 1px solid var(--line);
  background: #f1ede5;
  text-align: center;
}

.guest-document-preview__state h2,
.guest-document-preview__state p { margin: 0; }
.guest-document-preview__state--error { border-color: rgba(185, 35, 25, .35); }

.preview-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(216, 52, 36, .18);
  border-top-color: #d83424;
  border-radius: 50%;
  animation: preview-spin .8s linear infinite;
}

.guest-document-preview__legacy { padding: 14px 16px; border: 1px dashed var(--line); }
.guest-document-preview__legacy pre {
  max-height: 280px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #fff;
  font: inherit;
}

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

@media (max-width: 760px) {
  main.preview-main { width: auto; margin-inline: 12px; padding: 8px 0 24px; }
  .preview-panel { padding: 10px; }
  .preview-toolbar { grid-template-columns: 1fr auto; align-items: start; }
  .preview-back { grid-column: 1 / -1; justify-self: start; }
  .preview-title h1 { font-size: 1.35rem; }
  .preview-page-count { align-self: end; }
  .preview-security-note,
  .guest-document-preview__notice { font-size: .85rem; }
  .preview-frame { height: 70dvh; min-height: 420px; }
  video.preview-media { max-height: 70dvh; }
  .preview-viewport--image { min-height: 56dvh; }
  img.preview-media { max-height: 68dvh; }
  .guest-document-preview__controls { top: 8px; grid-template-columns: 1fr 1fr; }
  .guest-document-preview__controls .button,
  .guest-document-preview__controls button { min-height: 44px; text-align: center; }
  .guest-document-preview__jump { grid-column: 1 / -1; grid-row: 1; flex-wrap: wrap; }
  .guest-document-preview__controls > :last-child { text-align: center; }
  .guest-document-preview__stage { height: clamp(360px, 58dvh, 620px); padding: 8px; scrollbar-gutter: auto; }
  .guest-document-preview__page { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .preview-spinner { animation: none; }
}
