/* Keep the four contact choices and the action button inside the viewport. */
@media (max-width: 767px) {
  .matching-dialog .profile-dialog-panel:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) {
    height: 100dvh;
    max-height: 100dvh;
    grid-template-rows: 96px minmax(0, 1fr) auto;
    border-radius: 0;
  }

  .matching-dialog .profile-dialog-panel:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child)::before {
    display: none;
  }

  .matching-dialog .profile-dialog-panel:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-head {
    min-height: 96px;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: 12px;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) {
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    overflow: hidden;
    padding: 12px 18px;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-step,
  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) h2 {
    margin: 0;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-options {
    min-height: 0;
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-card {
    min-height: 0;
    height: 100%;
    padding: 8px 14px;
  }
}

@media (max-width: 767px) and (max-height: 620px) {
  .matching-dialog .profile-dialog-panel:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) {
    grid-template-rows: 80px minmax(0, 1fr) auto;
  }

  .matching-dialog .profile-dialog-panel:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-head {
    min-height: 80px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) {
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-options {
    gap: 6px;
  }

  .matching-flow-body:has(.matching-flow-options > .matching-flow-card:nth-child(4):last-child) .matching-flow-card {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}
