.top-ad-container,
.infeed-ad-band,
.article-inline-ad {
  display: flex;
  justify-content: center;
  min-width: 0;
}

/* Reserve the header banner before the vendor responds so headlines stay put. */
.top-ad-container {
  margin-block: 1rem;
}

.top-ad-container .ad-slot-wrap:not(.has-ad) {
  height: calc(var(--ad-h) + 1.375rem);
}

@media (max-width: 351px) {
  .top-ad-container {
    padding-inline: 0;
  }

  .infeed-ad-band,
  .article-inline-ad {
    margin-inline: calc(-1 * var(--gutter));
  }

  .sidebar-rail > [data-slot-id="sidebar-monetag"] {
    width: 300px;
    margin-inline: calc((100% - 300px) / 2);
  }
}

.top-ad-container:has(> .has-ad),
.article-inline-ad:has(> .has-ad) {
  margin-block: 1rem;
}

.sidebar-rail > .has-ad {
  margin-block-start: 2rem;
}

.news-feed-list > .infeed-ad-band:not(:has(> .has-ad)) {
  margin-block-start: calc(-1 * var(--feed-gap, 1rem));
}

.ad-slot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, var(--ad-w));
  margin-inline: auto;
}

.ad-slot-wrap:not(.has-ad) {
  height: 0;
  overflow: hidden;
  visibility: hidden;
}

.ad-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  margin-block-end: 0.375rem;
  color: var(--muted, #5f5750);
  font: 600 0.625rem/1rem var(--sans, sans-serif);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ad-label::before,
.ad-label::after {
  flex: 1;
  height: 1px;
  background: var(--rule, #dad4cb);
  content: "";
}

.ad-slot {
  flex: none;
  width: 100%;
  height: var(--ad-h);
  overflow: hidden;
}

.ad-slot iframe {
  display: block;
  max-width: 100%;
  border: 0;
}

.ad-bp-desktop,
.ad-bp-desktop-wide,
.ad-bp-desktop-rail {
  display: none;
}

@media (min-width: 768px) {
  .ad-bp-desktop {
    display: flex;
  }

  .ad-bp-mobile-inline {
    display: none;
  }
}

/* The 728x90 only hands over from the 320x50 once the container can hold it.
   The page gutter is 4vw, so 728px of content needs about 792px of viewport;
   below that the wide unit would be shown but could never mount, leaving the
   display with no banner at all. */
@media (min-width: 792px) {
  .ad-bp-desktop-wide {
    display: flex;
  }

  .ad-bp-mobile {
    display: none;
  }
}

@media (min-width: 1024px) {
  .ad-bp-desktop-rail {
    display: flex;
  }
}
