* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: #1a1a1a;
  background: #f4f5f7;
}
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 32rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.sign-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}
.sign-header h1 {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
}
.muted {
  color: #555;
  font-size: 0.9rem;
}
.pdf-panel {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.pdf-loading {
  margin: 0;
  text-align: center;
}
.pdf-pages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}
.pdf-page {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 100%;
}
.pdf-page-frame {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
.pdf-page-canvas {
  max-width: 100%;
  height: auto;
  object-fit: contain;
  border: 1px solid #ddd;
}
.pdf-page-footer {
  margin: 0.1rem 0 0;
  text-align: right;
  font-size: 0.72rem;
  line-height: 1.2;
}
.sign-panel {
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.signing-controls {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
}
.signing-controls[hidden] {
  display: none;
}
.signing-controls.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.consent-field {
  margin-bottom: 1rem;
}
.consent-field .field-validation-target {
  display: inline-flex;
  flex-shrink: 0;
  align-items: flex-start;
}
.consent-field--error .checkbox-row {
  color: #8a0000;
}
.field-validation-target {
  border: 2px solid transparent;
  border-radius: 6px;
}
.field-validation-target.is-invalid {
  border-color: #a40000;
}
.checkbox-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.95rem;
  line-height: 1.4;
}
.checkbox-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.required-badge {
  display: inline-block;
  width: fit-content;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #174a8c;
  background: #e8f1fb;
}
.required-badge[hidden] {
  display: none;
}
.consent-field--error .required-badge:not([hidden]),
.signature-field--error .required-badge:not([hidden]),
.field-row--error .required-badge:not([hidden]) {
  color: #fff;
  background: #a40000;
}
.field-hint {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #666;
}
.field-hint--indented {
  margin: 0.45rem 0 0 1.65rem;
}
.field-label-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.field-label-row .pad-label {
  margin: 0;
}
.field-row {
  display: block;
  margin-bottom: 1rem;
}
.field-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
  font-weight: 600;
}
.text-input {
  width: 100%;
  max-width: 600px;
  padding: 0.55rem 0.65rem;
  border: 2px solid transparent;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px #ccc;
  font: inherit;
}
.text-input.is-invalid {
  box-shadow: none;
}
.text-input--prefilled:disabled,
.text-input:disabled {
  background: #f4f6f8;
  color: #333;
  cursor: not-allowed;
  opacity: 1;
}
.pad-wrap {
  margin-bottom: 1rem;
}
.pad-label {
  margin: 0 0 0.35rem;
  font-weight: 600;
}
.sig-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 600px;
}
.sig-canvas-wrap--empty .sig-canvas {
  border: 2px dashed #8aa8cc;
  box-shadow: none;
  cursor: crosshair;
}
.sig-canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 1rem;
  font-size: 1rem;
  color: #6b7f99;
  text-align: center;
  pointer-events: none;
  user-select: none;
}
.sig-canvas-placeholder[hidden] {
  display: none;
}
.signature-field--error .sig-canvas-placeholder {
  color: #a40000;
}
.sig-canvas {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 3 / 1;
  height: auto;
  border: 2px solid transparent;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px #ccc;
  touch-action: none;
  overscroll-behavior: contain;
  contain: layout paint;
  display: block;
}
.pad-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}
.btn-primary,
.btn-secondary {
  padding: 0.55rem 1rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 1rem;
  cursor: pointer;
}
.btn-primary {
  background: #1a5fb4;
  color: #fff;
  border-color: #174a8c;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: #fff;
}
.btn-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.btn-spinner[hidden] {
  display: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.error-text {
  color: #a40000;
}
.validation-modal[hidden] {
  display: none;
}
.validation-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.validation-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
}
.validation-modal__panel {
  position: relative;
  width: min(100%, 28rem);
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.validation-modal__title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}
.validation-modal__lead {
  margin: 0 0 1rem;
  color: #555;
  font-size: 0.95rem;
  line-height: 1.45;
}
.validation-modal__list {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  color: #1a1a1a;
}
.validation-modal__list li + li {
  margin-top: 0.45rem;
}
.validation-modal__close {
  width: 100%;
}
body.validation-modal-open {
  overflow: hidden;
}
.health-summary {
  margin: 1rem 0 0.5rem;
}
.health-dl {
  margin: 0.5rem 0 1rem;
}
.health-dl dt {
  font-weight: 600;
  margin-top: 0.75rem;
}
.health-dl dt:first-of-type {
  margin-top: 0;
}
.health-dl dd {
  margin: 0.25rem 0 0;
}
.health-note {
  font-size: 0.9rem;
  color: #555;
  margin-top: 1rem;
}

/* Download signed document page */
.page-download.page-center {
  width: 100%;
  padding: max(1rem, env(safe-area-inset-top, 0px))
    max(1rem, env(safe-area-inset-right, 0px))
    max(1rem, env(safe-area-inset-bottom, 0px))
    max(1rem, env(safe-area-inset-left, 0px));
}

.card-download {
  width: 100%;
  max-width: min(36rem, 100%);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-download :where(h1, p, div, a, strong) {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.download-title {
  font-size: clamp(1.25rem, 4vw + 0.5rem, 1.625rem);
  line-height: 1.25;
  margin: 0 0 1rem;
}

.download-lead,
.download-meta {
  margin: 0 0 1rem;
  line-height: 1.5;
}

.download-meta {
  font-size: clamp(0.9rem, 2.5vw + 0.5rem, 1rem);
  color: #333;
}

.download-actions {
  margin: 0 0 1.25rem;
  min-width: 0;
  max-width: 100%;
}

.btn-download {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 1.25rem;
  text-decoration: none;
  text-align: center;
}

.download-fallback {
  margin: 0 0 1.25rem;
  min-width: 0;
  max-width: 100%;
}

.download-fallback-label {
  margin: 0 0 0.5rem;
  font-size: clamp(0.875rem, 2vw + 0.5rem, 0.95rem);
  line-height: 1.45;
  color: #444;
}

.download-url {
  margin: 0;
  padding: 0.75rem 0.85rem;
  max-width: 100%;
  min-width: 0;
  font-size: clamp(0.75rem, 2vw + 0.35rem, 0.875rem);
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #1a1a1a;
  background: #f4f5f7;
  border: 1px solid #e0e2e6;
  border-radius: 6px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
  -webkit-overflow-scrolling: touch;
  user-select: all;
}

.download-expiry {
  margin-bottom: 0;
}

.download-fingerprint {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e8eaed;
  min-width: 0;
  max-width: 100%;
}

.download-fingerprint-label {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #666;
}

.download-fingerprint-value {
  margin: 0;
  max-width: 100%;
  min-width: 0;
  font-size: clamp(0.7rem, 1.8vw + 0.35rem, 0.8125rem);
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
  color: #333;
}

@media (max-width: 479px) {
  .page-download.page-center {
    align-items: flex-start;
  }

  .card-download {
    padding: 1.25rem;
    border-radius: 6px;
  }

  .download-actions {
    margin-bottom: 1rem;
  }
}

@media (min-width: 480px) {
  .card-download {
    padding: clamp(1.5rem, 3vw, 2rem);
  }
}

@media (min-width: 768px) {
  .btn-download {
    width: auto;
    min-width: 12rem;
  }
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .card-download {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.05);
  }

  .download-url,
  .download-fingerprint {
    border-color: rgba(0, 0, 0, 0.1);
  }

  .download-fingerprint {
    border-top-color: rgba(0, 0, 0, 0.08);
  }

  .page-download {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

.sign-testing-banner {
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
  color: #5a4200;
  background: #fff8e6;
  border: 1px solid #e8d48a;
  border-radius: 6px;
}

.stamp-style-toolbar {
  background: #fff;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.stamp-style-toolbar__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.stamp-style-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 7rem;
  flex: 1 1 7rem;
}

.stamp-style-field__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stamp-style-select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
}

.test-preview-results {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e8e8e8;
}

.test-preview-results__title {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
}

.test-preview-results__list {
  margin: 0;
  padding: 0 0 0 1.1rem;
}

.test-preview-results__item {
  margin: 0.35rem 0;
}

.test-preview-results__item a {
  font-weight: 600;
}
