* { box-sizing: border-box; }

.exchange-page {
  --muted: #536b88;
  --blue-2: #0873d2;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 1000; padding: 10px 14px; transform: translateY(-160%); border-radius: 10px; background: var(--navy-deep); color: #fff; font-size: 14px; font-weight: 750; }
.skip-link:focus-visible { transform: translateY(0); outline: 3px solid #075eb4; outline-offset: 3px; }

.exchange-header {
  width: 100%;
  min-height: 74px;
  padding: 0 max(20px, calc((100vw - var(--max)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}

.exchange-brand { display: inline-flex; align-items: center; min-width: 0; }
.exchange-brand img {
  display: block;
  width: min(174px, 42vw);
  height: 64px;
  object-fit: contain;
  object-position: left center;
}

.exchange-back { color: var(--blue-2); font-size: 13px; font-weight: 750; }
.exchange-back:focus-visible, .sdk-error button:focus-visible { outline: 3px solid #075eb4; outline-offset: 3px; }

.exchange-main {
  flex: 1;
  width: min(calc(100% - 40px), 1160px);
  padding-top: clamp(12px, 1.2vw, 20px);
  padding-bottom: 24px;
}

.exchange-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 454px);
  align-items: start;
  gap: clamp(32px, 6vw, 84px);
}

.exchange-intro { padding-top: clamp(18px, 4vw, 56px); }
.exchange-label {
  display: inline-flex;
  padding: 8px 12px;
  border: 1px solid #d5ebfa;
  border-radius: 999px;
  color: #35618f;
  background: #edf7ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.exchange-intro h1 {
  max-width: 600px;
  margin: 22px 0 16px;
  font-size: clamp(38px, 4.2vw, 58px);
  line-height: 1.05;
  letter-spacing: -.035em;
}

.exchange-intro > p { max-width: 540px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.exchange-benefits { display: grid; gap: 15px; margin: 32px 0 0; padding: 0; list-style: none; }
.exchange-benefits[hidden] { display: none; }
.exchange-benefits li { position: relative; max-width: 520px; padding-left: 30px; color: #425d7c; font-size: 14px; line-height: 1.6; }
.exchange-benefits li::before {
  content: "✓";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e4f3ed;
  color: #14785d;
  font-size: 12px;
  font-weight: 800;
}

.exchange-form { min-width: 0; }

.exchange-consent {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid #d5e4f2;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}
.exchange-consent h3 { margin: 0 0 8px; color: #17385d; font-size: 17px; line-height: 1.35; }
.exchange-consent > p { margin: 0; color: #536b88; font-size: 13px; line-height: 1.55; }
.exchange-legal-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 12px 0; }
.exchange-legal-links a, .exchange-operator-terms a { color: #145f9f; font-size: 12px; font-weight: 700; line-height: 1.5; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.exchange-legal-links a:focus-visible, .exchange-operator-terms a:focus-visible { outline: 3px solid #075eb4; outline-offset: 3px; border-radius: 2px; }
.exchange-legal-links span { color: #536b88; font-weight: 500; }
.exchange-consent-blocked { margin: 14px 0 0 !important; padding: 12px; border: 1px solid #efcf99; border-radius: 10px; background: #fff8ec; color: #684a1d !important; }
.exchange-consent-blocked code { font-size: 12px; font-weight: 750; }
.exchange-operator-identity { margin: 15px 0 6px !important; color: #17385d !important; font-size: 13px !important; font-weight: 750; }
.exchange-operator-terms { margin: 0 0 14px !important; }
.exchange-consent-checkbox { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: start; gap: 10px; color: #354f70; font-size: 13px; line-height: 1.55; cursor: pointer; }
.exchange-consent-checkbox input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: #0873d2; }
.exchange-consent-checkbox input:focus-visible { outline: 3px solid #075eb4; outline-offset: 3px; }
.exchange-consent #exchange-continue { width: 100%; min-height: 48px; margin-top: 15px; padding: 11px 16px; border: 0; border-radius: 11px; background: #0873d2; color: #fff; font: inherit; font-size: 14px; font-weight: 750; cursor: pointer; }
.exchange-consent #exchange-continue:hover:not(:disabled) { background: #0566c6; }
.exchange-consent #exchange-continue:focus-visible { outline: 3px solid #075eb4; outline-offset: 3px; }
.exchange-consent #exchange-continue:disabled { background: #879ab1; cursor: not-allowed; }
.exchange-consent[hidden], .exchange-consent [hidden] { display: none !important; }

.sdk-card {
  width: 100%;
  min-height: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: visible;
}
.sdk-card[data-state="loading"], .sdk-card[data-state="error"] { min-height: 0; }
.sdk-card[data-state="loading"] {
  position: relative;
  display: grid;
  min-height: 278px;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  border-color: #d6e8f6;
  background:
    radial-gradient(70% 85% at 50% 44%, rgba(21, 159, 227, .10), transparent 76%),
    linear-gradient(145deg, #fff 8%, #f7fbff 100%);
}
.sdk-card[data-state="error"] .sdk-mount { display: none; }
.sdk-card[data-state="error"] .sdk-status { display: none; }
.sdk-card[data-state="error"] .sdk-loading { display: none; }
.sdk-card[data-state="ready"] .sdk-loading { display: none; }
.sdk-card[data-state="loading"] .sdk-mount {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: 430px;
  min-width: 360px;
  min-height: 100%;
  margin: 0 auto;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.sdk-loading {
  display: grid;
  justify-items: center;
  gap: 17px;
  width: min(100%, 330px);
  text-align: center;
}
.sdk-loading-logo {
  display: block;
  width: min(174px, 64vw);
  height: auto;
  max-height: 64px;
  object-fit: contain;
}
.sdk-loading-indicator {
  width: 36px;
  height: 36px;
  border: 3px solid #d8e9f6;
  border-top-color: #2d79ef;
  border-right-color: #159fe3;
  border-radius: 50%;
  animation: arm-pay-loading-turn .9s linear infinite;
}
@keyframes arm-pay-loading-turn {
  to { transform: rotate(360deg); }
}
.sdk-card[data-state="loading"] .sdk-status {
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  color: #536b88;
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}
.sdk-status { min-height: 24px; margin: 0; padding: 4px 8px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.sdk-status:empty { display: none; }
.sdk-error { margin: 8px; padding: 14px; border: 1px solid #f0c9c9; border-radius: 14px; background: #fff4f4; color: #8d3030; font-size: 12px; line-height: 1.5; }
.sdk-error p { margin: 0; }
.sdk-error[data-kind="disabled"] { border-color: #cfe2f6; background: #f4f9ff; color: #244568; }
.sdk-disabled-actions { margin-top: 14px; padding-top: 14px; border-top: 1px solid #dce9f6; }
.sdk-disabled-actions h3 { margin: 0 0 6px; color: #17385d; font-size: 14px; line-height: 1.35; }
.sdk-disabled-actions > p { color: #526b87; }
.sdk-action-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sdk-action-links a { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border: 1px solid transparent; border-radius: 10px; font-size: 12px; font-weight: 750; text-decoration: none; }
.sdk-action-primary { background: var(--blue-2); color: #fff; }
.sdk-action-primary:hover { background: #0566c6; }
.sdk-action-secondary { border-color: #c7d8e9 !important; background: #fff; color: #245c9e; }
.sdk-action-secondary:hover { background: #f7fbff; }
.sdk-action-links a:focus-visible, .sdk-disabled-help a:focus-visible { outline: 3px solid #075eb4; outline-offset: 3px; }
.sdk-disabled-help { margin-top: 12px !important; }
.sdk-disabled-help a { color: #245c9e; font-weight: 700; text-underline-offset: 2px; }
.sdk-error button { min-height: 40px; margin-top: 12px; padding: 9px 14px; border: 1px solid #c7d8e9; border-radius: 10px; background: #fff; color: #245c9e; font: inherit; font-weight: 750; cursor: pointer; }
.sdk-error button:hover { background: #f7fbff; }
.sdk-error button:disabled { cursor: wait; opacity: .65; }
.sdk-mount { width: 100%; max-width: 430px; min-width: 360px; min-height: 0; margin: 0 auto; }
.sdk-card[data-state="ready"] .sdk-mount { min-height: 0; }
.sdk-mount iframe { display: block; width: 100%; min-width: 0; min-height: 0; border: 0; }
.exchange-note { max-width: 420px; margin: 14px auto 0; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.6; }
.exchange-footer { margin-top: auto; }

@media (min-width: 1025px) {
  /* WhiteBird fills the merchant-sized container; keep the full form on-page when viewport height allows. */
  .sdk-card[data-state="ready"] {
    display: flex;
    height: min(840px, max(630px, calc(100svh - 108px)));
    flex-direction: column;
  }
  .sdk-card[data-state="ready"] .sdk-mount {
    height: 0;
    flex: 1 1 auto;
  }
  .sdk-card[data-state="ready"] .sdk-mount iframe {
    height: 100%;
  }
}

@media (max-width: 1024px) {
  .exchange-main { width: min(calc(100% - 32px), 720px); padding-top: 12px; padding-bottom: 30px; }
  .exchange-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .exchange-form { width: min(100%, 454px); margin: 0 auto; }
  .exchange-intro { order: 0; padding: 0 4px; }
  .exchange-form { order: 1; }
  .exchange-intro h1 { margin: 6px 0 0; font-size: clamp(28px, 5vw, 40px); line-height: 1.1; }
  .exchange-intro > p#exchange-intro-ready, .exchange-benefits { display: none !important; }
  .sdk-card[data-state="ready"] { display: block; height: auto; }
  /* Keep the full merchant frame available; cross-origin content controls its own scrolling. */
  .sdk-card[data-state="ready"] .sdk-mount { height: max(840px, min(900px, calc(100svh - 24px))); min-height: 0; }
  .sdk-card[data-state="ready"] .sdk-mount iframe { height: 100%; min-height: 0; }
}

@media (max-width: 600px) {
  .exchange-header { min-height: 66px; padding-right: 14px; padding-left: 14px; }
  .exchange-brand img { height: 52px; }
  .exchange-back { font-size: 12px; }
  .exchange-main { width: calc(100% - 24px); padding-top: 10px; padding-bottom: 30px; }
  .exchange-layout { gap: 12px; }
  .exchange-form { width: 100%; }
  .exchange-consent { padding: 18px; border-radius: 16px; }
  .exchange-consent h3 { font-size: 16px; }
  .exchange-consent > p, .exchange-consent-checkbox { font-size: 12px; }
  .sdk-card { width: calc(100% + 24px); min-height: 0; margin-left: -12px; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .sdk-card[data-state="ready"] { display: block; height: auto; }
  .sdk-mount { width: 100%; max-width: 430px; min-width: 0; height: auto; }
  .sdk-mount iframe { height: max(840px, min(900px, calc(100svh - 24px))); }
  .sdk-error { margin: 0; }
  .sdk-action-links a { flex: 1 1 auto; }
  .exchange-intro { padding: 0; }
  .exchange-intro h1 { margin: 6px 0 0; font-size: clamp(28px, 8vw, 34px); }
  .exchange-intro > p { font-size: 14px; }
  .exchange-benefits { gap: 12px; margin-top: 0; }
  .exchange-benefits li { font-size: 13px; }
  .exchange-note { max-width: 350px; margin-top: 12px; }
  .exchange-footer .footer-grid { grid-template-columns: 1fr; gap: 20px; }
}

@media (max-width: 380px) {
  .exchange-main { width: calc(100% - 16px); }
  .sdk-card { width: calc(100% + 16px); margin-left: -8px; }
  .exchange-intro h1 { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sdk-loading-indicator { animation: none; }
}
