/* Shared ad and friend-link layout for all site themes. */
.top-resource-zone {
  padding: 10px 0 14px;
  background: var(--site-top-resource-bg, transparent);
}

.top-resource-zone:not(:has(.site-ad-stack--pc:not(:empty), .site-ad-grid--app:not(:empty), .site-friend-zone__list:not(:empty))) {
  display: none;
}

.top-resource-zone__inner {
  display: grid;
  gap: 0;
}

.top-resource-zone .site-ad-zone,
.top-resource-zone .site-friend-zone {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.site-ad-zone {
  width: min(1200px, calc(100% - 32px));
  margin: 12px auto 0;
}

.site-ad-zone--top {
  display: grid;
  gap: 8px;
}

.site-ad-stack,
.site-ad-grid {
  min-width: 0;
}

.site-ad-stack:empty,
.site-ad-grid:empty,
.site-friend-zone__list:empty {
  display: none;
  min-height: 0;
}

.site-ad-item {
  position: relative;
  min-width: 0;
}

.site-ad-stack--pc {
  display: grid;
  gap: 8px;
}

.site-ad-stack--pc > a,
.site-ad-stack--pc > img,
.site-ad-stack--pc .site-ad-item,
.site-ad-stack--pc .site-ad-item > a,
.site-ad-stack--pc .site-ad-item > img {
  display: block;
  width: 100%;
  height: 60px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: var(--site-ad-slot-bg, #eef2f7);
}

.site-ad-stack--pc img,
.site-ad-stack--pc .site-ad-item img {
  display: block;
  width: 100%;
  height: 60px;
  object-fit: fill;
}

.site-ad-grid--app {
  display: grid;
  grid-template-columns: repeat(auto-fill, 100px);
  justify-content: center;
  align-items: start;
  gap: 10px 20px;
}

.site-ad-grid--app > a,
.site-ad-grid--app > img,
.site-ad-grid--app .site-ad-item {
  display: grid;
  place-items: center;
  width: 100px;
  height: 100px;
  min-width: 100px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.site-ad-grid--app .site-ad-item {
  grid-template-rows: 70px 1fr;
  gap: 4px;
  padding: 4px 0 0;
}

.site-ad-grid--app .site-ad-item > a,
.site-ad-grid--app > img,
.site-ad-grid--app .site-ad-item > img {
  width: 70px;
  height: 70px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--site-ad-slot-bg, #eef2f7);
}

.site-ad-grid--app img {
  width: 70px;
  height: 70px;
  object-fit: cover;
}

.site-ad-title {
  max-width: 100%;
  overflow: hidden;
  color: var(--site-ad-title-color, #111827);
  font-size: 13px;
  line-height: 18px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-friend-zone {
  width: min(1200px, calc(100% - 32px));
  margin: 12px auto 0;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--site-friend-color, #111827);
}

.site-friend-zone:has(.site-friend-zone__list:empty) {
  display: none;
}

.site-friend-zone--top {
  margin-top: 0;
  padding: 0;
}

.site-friend-zone--top .site-friend-zone__inner {
  margin-top: 12px;
  width: 100%;
}

.top-resource-zone > .site-friend-zone--top > .site-friend-zone__inner {
  width: min(100% - 24px, 1320px);
  margin-right: auto;
  margin-left: auto;
}

.site-friend-zone--bottom {
  width: min(980px, 100%);
  margin: 0;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  border: 1px solid var(--site-friend-border, #e5eaf2);
  border-radius: 6px;
  background: var(--site-friend-bg, #fafbfe);
}

.site-friend-zone__list {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.site-friend-zone__list a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: auto;
  padding: 0;
  overflow: hidden;
  border: 0 !important;
  border-radius: 0;
  color: var(--site-friend-color, #111827) !important;
  background: transparent !important;
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-friend-zone__list a:hover {
  color: var(--site-friend-hover-color, var(--brand, #2563eb)) !important;
  background: transparent !important;
}

.site-friend-zone__label {
  color: var(--site-friend-color, #111827) !important;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.site-friend-zone--bottom .site-friend-zone__list {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.site-friend-zone--top .site-friend-zone__list {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.site-friend-zone--top .site-friend-zone__list a {
  width: auto;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}

.site-ad-zone--footer-mobile {
  display: none;
}

.site-ad-zone--footer-mobile .site-ad-stack--mobile > a,
.site-ad-zone--footer-mobile .site-ad-stack--mobile > img,
.site-ad-zone--footer-mobile .site-ad-stack--mobile .site-ad-item,
.site-ad-zone--footer-mobile .site-ad-stack--mobile .site-ad-item > a,
.site-ad-zone--footer-mobile .site-ad-stack--mobile .site-ad-item > img {
  display: block;
  width: 100%;
  height: 40px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: var(--site-ad-slot-bg, #eef2f7);
}

.site-ad-zone--footer-mobile .site-ad-stack--mobile img,
.site-ad-zone--footer-mobile .site-ad-stack--mobile .site-ad-item img {
  display: block;
  width: 100%;
  height: 40px;
  object-fit: fill;
}

@media (max-width: 860px) {
  .top-resource-zone {
    padding: 8px 0 12px;
  }

  .site-ad-zone {
    width: calc(100% - 24px);
    margin-top: 10px;
  }

  .top-resource-zone .site-ad-zone,
  .top-resource-zone .site-friend-zone {
    width: 100%;
    margin: 0;
  }

  .site-ad-stack--pc > a,
  .site-ad-stack--pc > img,
  .site-ad-stack--pc .site-ad-item,
  .site-ad-stack--pc .site-ad-item > a,
  .site-ad-stack--pc .site-ad-item > img {
    height: 50px;
  }

  .site-ad-stack--pc img,
  .site-ad-stack--pc .site-ad-item img {
    height: 50px;
  }

  .site-ad-grid--app,
  .site-friend-zone--top .site-friend-zone__list {
    justify-content: flex-start;
    gap: 8px 6px;
  }

  .site-ad-grid--app > a,
  .site-ad-grid--app > img,
  .site-ad-grid--app .site-ad-item {
    width: 100%;
    min-width: 0;
    max-width: 100px;
    height: 100px;
  }

  .site-friend-zone {
    width: calc(100% - 24px);
    padding: 10px;
  }

  .site-friend-zone--top {
    padding: 0;
  }

  .site-friend-zone--bottom {
    width: 100%;
  }

  .site-friend-zone__list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .site-friend-zone__list a {
    min-height: 26px;
    padding: 4px 6px;
    font-size: 11px;
  }

  .site-friend-zone--top .site-friend-zone__list a {
    width: auto;
    font-size: 15px;
  }

  .site-ad-zone--footer-mobile {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--site-mobile-ad-bottom, 0);
    z-index: 80;
    display: block;
    width: 100%;
    margin: 0;
    padding: 4px 8px;
    background: var(--site-mobile-ad-bg, rgba(255, 255, 255, .96));
    box-shadow: var(--site-mobile-ad-shadow, 0 -8px 20px rgba(15, 23, 42, .12));
  }

  .site-ad-stack--mobile {
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
  }
}
