.ad-section{width:100%;display:flex;flex-direction:column;align-items:center}
.ad-section__label{align-self:flex-start;font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:rgba(255,255,255,.4);margin-bottom:8px}
.ad-section__inner{width:100%;display:flex;justify-content:center;align-items:center;overflow:hidden}
.ad-strip{grid-column:1/-1}
.ad-strip .mrg-tag{min-height:250px}
.ad-inarticle{display:none}
@media (min-width:1024px){.ad-inarticle{display:block}}



.ad-fallback { display: none; }
.ad-fallback__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
@media (max-width: 768px) {
    .ad-fallback__grid { grid-template-columns: repeat(2, 1fr); }
}
.ad-fallback__card {
    background: var(--panel, #14141f);
    border: 1px solid var(--border, rgba(255, 255, 255, .08));
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}
.ad-fallback__pic {
    width: 40px; height: 40px;
    margin: 0 auto 10px;
    border-radius: 10px;
    background: var(--grad, linear-gradient(90deg, #a855f7, #8b7cf6));
    color: #fff;
    font-weight: 700;
    font-size: 20px;
    line-height: 40px;
}
.ad-fallback__title { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--text, #e2e8f0); }
.ad-fallback__text { font-size: 12px; color: var(--muted, #94a3b8); margin-bottom: 10px; }
.ad-fallback__btn {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 10px;
    background: var(--grad, linear-gradient(90deg, #a855f7, #8b7cf6));
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.ad-fallback__btn:hover { opacity: .85; }

.ad-modal { position: fixed; inset: 0; z-index: 1000; }
.ad-modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .7); }
.ad-modal__box {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(360px, calc(100vw - 32px));
    background: var(--panel, #14141f);
    border: 1px solid var(--border, rgba(255, 255, 255, .08));
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}
.ad-modal__close {
    position: absolute;
    top: 8px; right: 12px;
    background: none; border: none;
    color: var(--muted, #94a3b8);
    font-size: 26px; line-height: 1;
    cursor: pointer;
}
.ad-modal__pic {
    width: 52px; height: 52px;
    margin: 0 auto 12px;
    border-radius: 12px;
    background: var(--grad, linear-gradient(90deg, #a855f7, #8b7cf6));
    color: #fff;
    font-weight: 700;
    font-size: 26px;
    line-height: 52px;
}
.ad-modal__title { color: var(--text, #e2e8f0); font-size: 18px; margin: 0 0 8px; }
.ad-modal__text { color: var(--muted, #94a3b8); font-size: 14px; margin: 0 0 18px; }
.ad-modal__btn {
    padding: 8px 24px;
    border: none;
    border-radius: 10px;
    background: var(--grad, linear-gradient(90deg, #a855f7, #8b7cf6));
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.ad-section__inner { position: relative; }
.mrg-tag.ad-hidden {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
}

.ad-fallback__card { position: relative; }
.ad-fb-mark { position: absolute; top: 6px; right: 6px; font-size: 9px; line-height: 1; padding: 3px 5px; border-radius: 4px; background: rgba(0,0,0,.35); color: #cbd5e1; text-decoration: none; }
.ad-fb-mark:hover { background: rgba(0,0,0,.55); }

/* Мобильная версия: лента из 4 карточек, по 2 в кадре, прокрутка */
@media (max-width: 767px) {
  .ad-fallback__grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: calc(50% - 6px);
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .ad-fallback__grid::-webkit-scrollbar { display: none; }
  .ad-fallback__grid {
    padding-left: 8px;
    padding-right: 8px;
    scroll-padding-inline: 8px;
  }
  .ad-fallback__card {
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    overflow: hidden;
  }
  .ad-fallback__title,
  .ad-fallback__text,
  .ad-fallback__btn {
    max-width: 100%;
    overflow-wrap: break-word;
  }
}


/* ===== Фолбэк: кнопка прижата к низу, тексты обрезаются по строкам ===== */
.ad-fallback__card {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.ad-fallback__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  flex-shrink: 0;
}
.ad-fallback__text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  flex: 1;
  min-height: 0;
}
.ad-fallback__btn {
  margin-top: auto;
  flex-shrink: 0;
}
