/* Fit the available viewport without clipping content or disabling zoom. */
:root { --screen-height: 100vh; }
@supports (height: 100svh) { :root { --screen-height: 100svh; } }
@supports (height: 100dvh) { :root { --screen-height: 100dvh; } }
.payment-page,
.payment-shell,
.is-pix-payment .payment-shell { min-height: var(--visible-height, var(--screen-height)); }
.payment-shell {
  padding-left: max(28px, env(safe-area-inset-left));
  padding-right: max(28px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top);
}
.payment-main { min-width: 0; }
.currency-input input { font-size: 20px; }
.checkout-section { position: static; }
.pix-payment { padding-top: max(56px, env(safe-area-inset-top)); }
.pix-manual-code { display: block; resize: none; font-size: 16px; line-height: 1.35; }
.pix-copy-button { white-space: normal; }
@media (min-width: 640px) and (min-height: 761px) {
  .payment-shell { padding-left: max(36px, env(safe-area-inset-left)); padding-right: max(36px, env(safe-area-inset-right)); }
}

@media (max-width: 600px), (max-height: 760px) {
  .payment-shell { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .payment-header { height: 50px; }
  .brand > span { font-size: 30px; }
  .brand > .pix-mark { width: 26px; height: 26px; }
  .payment-main { display: grid; align-content: center; padding-top: 12px; padding-bottom: 8px; }
  .step-content { position: relative; width: 100%; }
  .intro-icon { position: absolute; right: 0; top: 2px; width: 38px; height: 38px; margin: 0; border-radius: 12px; }
  .intro-copy h1 { max-width: calc(100% - 44px); font-size: 29px; line-height: 1.12; }
  .intro-copy p { margin-top: 7px; font-size: 13px; line-height: 19px; }
  .amount-fieldset { margin-top: 16px; }
  .amount-fieldset legend, .custom-amount label { margin-bottom: 7px; line-height: 17px; }
  .amount-grid { gap: 8px; }
  .amount-button { height: 46px; flex-basis: calc(33.33% - 6px); }
  .custom-amount { margin-top: 14px; }
  .currency-input { height: 46px; }
  .checkout-section { margin-top: 14px; padding: 10px 0 0; }
  .total-row { margin-bottom: 9px; }
  .total-row > strong { font-size: 21px; line-height: 28px; }
  .payment-button { height: 50px; }
  .payment-note { margin-top: 9px; line-height: 16px; text-align: center; }
  .payment-footer { padding: 6px 0 max(10px, env(safe-area-inset-bottom)); line-height: 16px; }
  .input-error { margin-top: 5px; line-height: 17px; }
  .is-pix-payment .payment-main { display: block; }
  .pix-payment { width: min(calc(100% - 40px - env(safe-area-inset-left) - env(safe-area-inset-right)), 462px); }
}

@media (max-height: 700px) {
  .pix-payment { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .pix-payment-logo { width: 80px; height: 80px; margin-bottom: 22px; border-radius: 28px; }
  .pix-payment-logo .pix-mark { width: 44px; height: 44px; }
  .pix-payment-title { font-size: 28px; }
  .pix-payment-description { margin-top: 12px; font-size: 16px; line-height: 24px; }
  .pix-payment-description br { display: none; }
  .pix-payment-action { margin-top: 24px; }
  .pix-copy-button { min-height: 60px; padding: 14px 16px; font-size: 19px; border-radius: 18px; }
  .pix-payment-steps { margin-top: 26px; gap: 12px; }
  .pix-payment-steps li { font-size: 15px; line-height: 23px; }
  .pix-payment-footer { margin-top: 20px; font-size: 13px; line-height: 20px; }
  .pix-manual-code { min-height: 64px; height: 64px; margin-top: 12px; padding: 8px; }
  .pix-payment-message { margin-bottom: 12px; font-size: 15px; line-height: 22px; }
}

@media (max-height: 600px) {
  .payment-header { height: 44px; }
  .payment-main { padding-top: 10px; padding-bottom: 4px; }
  .intro-copy h1 { font-size: 27px; }
  .intro-copy p { margin-top: 5px; }
  .amount-fieldset { margin-top: 12px; }
  .amount-button { height: 44px; }
  .custom-amount { margin-top: 12px; }
  .currency-input { height: 44px; }
  .checkout-section { margin-top: 12px; padding-top: 8px; }
  .payment-button { height: 46px; }
  .payment-note { margin-top: 7px; }
  .payment-footer { padding-top: 4px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .pix-back-button { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
  .pix-payment { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .pix-payment-logo { width: 68px; height: 68px; margin-bottom: 16px; border-radius: 24px; }
  .pix-payment-logo .pix-mark { width: 38px; height: 38px; }
  .pix-payment-title { font-size: 26px; }
  .pix-payment-description { margin-top: 10px; line-height: 23px; }
  .pix-payment-action { margin-top: 20px; }
  .pix-copy-button { min-height: 56px; font-size: 18px; }
  .pix-payment-steps { margin-top: 22px; gap: 10px; }
  .pix-payment-steps li { gap: 10px; }
  .pix-payment-footer { margin-top: 16px; }
}

@media (max-height: 510px) {
  .payment-header { height: 40px; }
  .payment-main { padding-top: 8px; }
  .intro-copy h1 { font-size: 24px; }
  .intro-copy p { font-size: 12px; line-height: 17px; }
  .amount-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .amount-button { font-size: 17px; gap: 2px; }
  .amount-currency { font-size: 10px; }
  .amount-fieldset, .custom-amount, .checkout-section { margin-top: 10px; }
  .pix-payment-logo { width: 52px; height: 52px; margin-bottom: 10px; border-radius: 19px; }
  .pix-payment-logo .pix-mark { width: 30px; height: 30px; }
  .pix-payment-title { font-size: 24px; }
  .pix-payment-description { font-size: 14px; line-height: 20px; margin-top: 7px; }
  .pix-payment-action { margin-top: 14px; }
  .pix-copy-button { min-height: 48px; padding: 10px 12px; font-size: 17px; gap: 10px; }
  .pix-copy-button svg { width: 24px; height: 24px; }
  .pix-payment-steps { margin-top: 16px; gap: 8px; }
  .pix-payment-steps li { font-size: 14px; line-height: 22px; }
  .pix-step-number { width: 24px; height: 24px; }
  .pix-payment-footer { margin-top: 12px; font-size: 12px; }
}

/* Landscape: use the available width instead of stacking a tall phone screen. */
@media (min-width: 600px) and (max-height: 500px) {
  .payment-shell { max-width: 860px; }
  .payment-main { padding-top: 10px; padding-bottom: 4px; }
  .step-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'intro custom' 'amount checkout'; gap: 12px 28px; align-items: start; }
  .intro-icon { display: none; }
  .intro-copy { grid-area: intro; }
  .intro-copy h1 { max-width: none; font-size: 25px; }
  .intro-copy p { margin-top: 5px; }
  .amount-fieldset { grid-area: amount; margin: 0; }
  .custom-amount { grid-area: custom; margin: 0; }
  .checkout-section { grid-area: checkout; margin: 0; padding-top: 8px; }
  .payment-footer { padding-top: 4px; }
  .pix-payment { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'logo action' 'title steps' 'description steps' 'footer footer'; align-content: center; align-items: center; gap: 10px 28px; width: min(calc(100% - 144px - env(safe-area-inset-left) - env(safe-area-inset-right)), 760px); min-height: var(--visible-height, var(--screen-height)); padding: max(12px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom)); }
  .pix-payment-logo { grid-area: logo; margin: 0 auto; }
  .pix-payment-title { grid-area: title; font-size: 25px; }
  .pix-payment-description { grid-area: description; margin: 0; font-size: 14px; line-height: 21px; }
  .pix-payment-action { grid-area: action; margin: 0; align-self: end; }
  .pix-payment-steps { grid-area: steps; margin: 0; align-self: start; gap: 8px; }
  .pix-payment-steps li { font-size: 14px; line-height: 21px; }
  .pix-payment-footer { grid-area: footer; margin: 0; }
  .pix-manual-code { height: 58px; min-height: 58px; margin-top: 8px; }
}

/* The keyboard gets a compact editor; blur restores the complete overview. */
.viewport-keyboard:not(.is-pix-payment) .payment-main { align-content: center; padding-top: 8px; }
.viewport-keyboard:not(.is-pix-payment) .payment-header,
.viewport-keyboard:not(.is-pix-payment) .intro-icon,
.viewport-keyboard:not(.is-pix-payment) .intro-copy,
.viewport-keyboard:not(.is-pix-payment) .amount-fieldset,
.viewport-keyboard:not(.is-pix-payment) .payment-footer { display: none; }
.viewport-keyboard:not(.is-pix-payment) .custom-amount { margin-top: 0; }
.viewport-keyboard:not(.is-pix-payment) .checkout-section { margin-top: 12px; }
.viewport-keyboard:not(.is-pix-payment) .step-content { display: block; }
