@media (max-width: 979px) {
  #vk_community_messages:not(:has(> iframe[height="399px"])) {
    /* The 50px VK button shares the center of the 45px contact button. */
    bottom: 63.5px !important;
    margin-bottom: 0 !important;
  }
}

@media (min-width: 980px) {
  #vk_community_messages {
    top: 50% !important;
    bottom: auto !important;
    margin-bottom: 0 !important;
    transform: translateY(-50%);
  }
}

@media (max-width: 767px) {
  #vk_community_messages {
    left: 10px !important;
    max-width: calc(100vw - 20px);
  }

  #vk_community_messages:has(> iframe[height="399px"]) {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    display: flex;
    align-items: flex-end;
    filter: drop-shadow(0 4px 12px rgba(0, 20, 51, 0.2));
  }

  /* VK's expanded frame has a 25px gutter before the 320px chat panel. */
  #vk_community_messages > iframe[height="399px"] {
    display: block;
    flex: none;
    width: 345px;
    margin-left: -25px;
    clip-path: inset(0 0 0 25px round 6px);
  }
}

@media (max-width: 339px) {
  #vk_community_messages > iframe[height="399px"] {
    zoom: 0.93;
  }
}
