.caiv-open { overflow: hidden; }

/* Match the Compac product-template secondary action button exactly. */
.caiv-trigger {
  appearance: none;
  font: inherit;
  cursor: pointer;
  margin: 0;
}
.caiv-trigger.cptp-btn--secondary {
  background: #fff !important;
  border: 1px solid var(--cp-navy, #071c32) !important;
  color: var(--cp-navy, #071c32) !important;
  opacity: 1 !important;
}
.caiv-trigger.cptp-btn--secondary:hover,
.caiv-trigger.cptp-btn--secondary:focus-visible {
  background: var(--cp-navy, #071c32) !important;
  border-color: var(--cp-navy, #071c32) !important;
  color: #fff !important;
  opacity: 1 !important;
  outline: none;
}

.caiv-modal[aria-hidden="true"] { display: none; }
.caiv-modal[aria-hidden="false"] { display: block; }
.caiv-modal { position: fixed; z-index: 999999; inset: 0; }
.caiv-modal__backdrop { position: absolute; inset: 0; background: rgba(8, 16, 23, .68); backdrop-filter: blur(4px); }
.caiv-modal__panel {
  position: relative;
  width: min(1080px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin: 16px auto;
  background: #fff;
  color: #071c32;
  padding: 42px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
  outline: none;
}
.caiv-close {
  position: absolute;
  right: 18px;
  top: 12px;
  border: 0;
  background: transparent;
  color: #071c32;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}
.caiv-header { max-width: 760px; margin-bottom: 28px; }
.caiv-eyebrow { color: #00a99e; font-size: 12px; letter-spacing: .09em; text-transform: uppercase; font-weight: 800; margin-bottom: 6px; }
.caiv-header h2, .caiv-result h3 { margin: 0 0 10px; color: #071c32; }
.caiv-header p { margin: 0; color: #536273; font-size: 16px; line-height: 1.6; }
.caiv-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .75fr); gap: 18px; }
.caiv-upload-card, .caiv-surface-card { border: 1px solid #dce3e8; padding: 22px; background: #fbfcfc; }
.caiv-step { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #00b9ad; color: #008f87; font-weight: 800; font-size: 12px; margin-bottom: 15px; }
.caiv-upload-card h3, .caiv-surface-card h3 { margin: 0 0 8px; color: #071c32; font-size: 18px; }
.caiv-help, .caiv-file-note { color: #677481; font-size: 13px; line-height: 1.5; }
.caiv-upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  background: #00b9ad;
  color: #fff;
  padding: 0 20px;
  font-weight: 800;
  cursor: pointer;
  margin: 10px 0 8px;
}
.caiv-upload-button input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.caiv-surface-preview { aspect-ratio: 1.2/1; overflow: hidden; background: #eef1f2; margin: 0 0 12px; }
.caiv-surface-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.caiv-surface-card strong, .caiv-surface-card > span { display: block; }
.caiv-surface-card > span { color: #677481; font-size: 13px; margin-top: 3px; }
.caiv-surface-switcher { border-top: 1px solid #dce3e8; margin-top: 18px; padding-top: 16px; }
.caiv-surface-switcher label { display: block; margin-bottom: 7px; color: #071c32; font-size: 12px; font-weight: 800; }
.caiv-surface-select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd9df;
  border-radius: 0;
  background: #fff;
  color: #071c32;
  padding: 0 38px 0 12px;
  font: inherit;
  font-size: 14px;
}
.caiv-surface-switcher p { margin: 7px 0 0; color: #7a858e; font-size: 11px; line-height: 1.45; }
.caiv-photo-preview { margin-top: 18px; background: #f3f5f6; border: 1px solid #dce3e8; padding: 10px; }
.caiv-photo-preview img { display: block; max-width: 100%; max-height: 360px; margin: 0 auto; object-fit: contain; }
.caiv-consent { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0; color: #536273; font-size: 13px; line-height: 1.5; }
.caiv-consent input { margin-top: 3px; }
.caiv-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.caiv-generate, .caiv-download, .caiv-try-again {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid #071c32;
  background: #071c32;
  color: #fff;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.caiv-generate:disabled { opacity: .45; cursor: not-allowed; }
.caiv-generate.is-loading::after { content: ''; width: 15px; height: 15px; margin-left: 10px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: caiv-spin .8s linear infinite; }
@keyframes caiv-spin { to { transform: rotate(360deg); } }
.caiv-status { color: #677481; font-size: 13px; max-width: 520px; }
.caiv-result { margin-top: 34px; border-top: 1px solid #dce3e8; padding-top: 28px; }
.caiv-result__header { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 16px; }
.caiv-result__buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.caiv-try-again { background: #fff; color: #071c32; }
.caiv-download { background: #00b9ad; border-color: #00b9ad; }
.caiv-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.caiv-compare figure { margin: 0; background: #f5f6f6; border: 1px solid #dce3e8; }
.caiv-compare img { width: 100%; height: auto; display: block; }
.caiv-compare figcaption { padding: 9px 11px; font-size: 12px; font-weight: 700; color: #536273; }
.caiv-disclaimer { color: #7a858e; font-size: 11px; line-height: 1.5; margin: 12px 0 0; }

@media (max-width: 760px) {
  .caiv-modal__panel { width: 100%; max-height: 100vh; min-height: 100vh; margin: 0; padding: 54px 20px 28px; }
  .caiv-grid, .caiv-compare { grid-template-columns: 1fr; }
  .caiv-result__header { align-items: flex-start; flex-direction: column; }
  .caiv-surface-preview { aspect-ratio: 1.35/1; }
}

/* v0.2.3: keep the action copy readable and separated. */
.caiv-generate {
  gap: 5px;
  white-space: nowrap;
}

/* v0.3.0: qualified lead gate + safer usage limits. */
.caiv-lead-gate {
  max-width: 680px;
  border: 1px solid #dce3e8;
  background: #fbfcfc;
  padding: 24px;
}
.caiv-lead-gate h3 { margin: 0 0 8px; color: #071c32; font-size: 20px; }
.caiv-lead-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}
.caiv-lead-form label { display: block; color: #071c32; font-size: 12px; font-weight: 800; }
.caiv-lead-form label:first-child { grid-column: 1 / -1; }
.caiv-lead-form label span { display: block; margin-bottom: 6px; }
.caiv-lead-form input[type="text"],
.caiv-lead-form input[type="email"],
.caiv-lead-form input[type="tel"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cfd9df;
  border-radius: 0;
  background: #fff;
  color: #071c32;
  padding: 0 12px;
  font: inherit;
  font-weight: 400;
  box-sizing: border-box;
}
.caiv-lead-form input:focus { border-color: #071c32; outline: 2px solid rgba(7,28,50,.08); outline-offset: 1px; }
.caiv-lead-submit {
  grid-column: 1 / -1;
  min-height: 50px;
  border: 1px solid #071c32;
  border-radius: 0;
  background: #071c32;
  color: #fff;
  padding: 0 22px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  justify-self: start;
}
.caiv-lead-submit:hover,
.caiv-lead-submit:focus-visible { background: #fff; color: #071c32; }
.caiv-lead-note { margin: 14px 0 0; color: #7a858e; font-size: 11px; line-height: 1.5; }
.caiv-lead-error { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #d9a3a3; background: #fff7f7; color: #7c2424; font-size: 13px; }
.caiv-sample {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid #071c32;
  background: #fff;
  color: #071c32;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.caiv-sample:hover,
.caiv-sample:focus-visible { background: #071c32; color: #fff; }

@media (max-width: 760px) {
  .caiv-lead-gate { padding: 20px; }
  .caiv-lead-form { grid-template-columns: 1fr; }
  .caiv-lead-form label:first-child,
  .caiv-lead-submit { grid-column: auto; }
  .caiv-lead-submit { width: 100%; }
  .caiv-result__buttons > * { width: 100%; }
}


/* v0.3.4: keep HubSpot context in the form without adding clutter to the customer UI. */
.caiv-lead-form .caiv-context-field {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.caiv-lead-submit.is-loading {
  opacity: .75;
  cursor: wait;
}
