/* The viewport gets only the space LEFT AFTER controls, never a fixed iframe height. */
.terms-pdf-viewer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #e2e8f0;
}
.terms-pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  flex: none;
  gap: 4px;
  padding: 6px;
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
  color: #1e293b;
  font: 13px/1.4 system-ui, sans-serif;
}
.terms-pdf-toolbar button {
  width: auto;
  min-width: 32px;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  color: #1e293b;
  background: white;
  font: inherit;
  cursor: pointer;
}
.terms-pdf-toolbar button:disabled { opacity: .45; cursor: default; }
.terms-pdf-toolbar button[aria-pressed="true"] { background: #e0e7ff; border-color: #818cf8; }
.terms-pdf-toolbar button:focus-visible, .terms-pdf-viewport:focus-visible {
  outline: 2px solid #4338ca;
  outline-offset: -2px;
}
.terms-pdf-zoom { min-width: 40px; text-align: center; }
.terms-pdf-page-number { white-space: nowrap; min-width: 42px; text-align: center; }
.terms-pdf-viewport {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  padding: 8px;
  overscroll-behavior: contain;
}
.terms-pdf-page {
  position: relative;
  margin: 0 auto;
  background: white;
  box-shadow: 0 1px 4px #0003;
}
.terms-pdf-page[hidden] { display: none; }
.terms-pdf-page canvas { display: block; max-width: none; }
.terms-pdf-viewer .terms-pdf-status {
  flex: none;
  margin: 0;
  padding: 6px 10px;
  color: #334155;
  background: #f8fafc;
  font: 12px/1.4 system-ui, sans-serif;
}
.terms-pdf-status:empty { display: none; }
.terms-document {
  display: flex;
  flex-direction: column;
  height: min(800px, calc(100vh - 32px));
  height: min(800px, calc(100dvh - 32px));
  min-height: 0;
}
.terms-document > div:not(.terms-pdf-viewer), .terms-document > p { flex: none; }
.terms-document .terms-pdf-viewer { flex: 1; }

/* PDF mode only: preserve HTML terms sizing and its existing scroll consent gate. */
#termsModal.terms-modal-pdf .campaign-details-modal-card {
  height: 85vh;
  height: 85dvh;
  max-height: 85vh;
  max-height: 85dvh;
}
#termsModal.terms-modal-pdf .campaign-details-modal-header,
#termsModal.terms-modal-pdf .campaign-details-modal-footer { flex: none; }
#termsModal.terms-modal-pdf #termsModalBody {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  gap: 8px;
}
#termsModal.terms-modal-pdf .terms-pdf-viewer { flex: 1; }
.terms-pdf-links { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; flex: none; font-size: 13px; }
.terms-pdf-links a { color: var(--primary-color); text-decoration: underline; font-weight: 600; }
#termsModal .terms-pdf-hint { flex: none; margin: 0; font-size: 12px; color: #64748b; }
@media (max-width: 768px), (max-height: 500px) {
  #termsModal.terms-modal-pdf { padding: 0; }
  #termsModal.terms-modal-pdf .campaign-details-modal-card {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  #termsModal.terms-modal-pdf .campaign-details-modal-header { padding: 12px 16px 4px; }
  #termsModal.terms-modal-pdf .campaign-details-modal-header h2 { margin-bottom: 8px; font-size: 20px; }
  #termsModal.terms-modal-pdf #termsModalBody { padding: 8px 12px; }
  #termsModal.terms-modal-pdf .campaign-details-modal-footer { padding: 8px 12px; }
}