.ad-rail {
    display: none;
}

.ad-rail[hidden] {
    display: none !important;
}

@media (min-width: 1500px) {
    .ad-rail {
        display: block;
        position: fixed;
        top: 92px;
        bottom: 20px;
        width: 168px;
        z-index: 30;
    }

    .ad-rail-left { left: 14px; }
    .ad-rail-right { right: 14px; }
}

.ad-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ad-chrome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.92);
}

.ad-label {
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #cbd5e1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ad-chrome-actions {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.ad-rail-close,
.ad-modal-close {
    border: 0;
    background: transparent;
    color: inherit;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    line-height: 1;
    font-size: 20px;
    cursor: pointer;
}

.ad-rail-close:hover,
.ad-modal-close:hover {
    background: rgba(255, 255, 255, 0.12);
}

.ad-frame {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #020617;
}

.ad-image-link,
.ad-image-link img,
.ad-video,
.ad-motion,
.ad-playable,
.ad-playable-stage {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.ad-image-link img,
.ad-video,
.ad-motion-poster {
    object-fit: cover;
}

.ad-frame-expandable {
    cursor: pointer;
}

.ad-cta {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    display: block;
    text-align: center;
    text-decoration: none;
    background: #f8fafc;
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    border-radius: 999px;
    padding: 8px 12px;
}

.ad-cta:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.ad-playable-stage {
    position: relative;
}

.ad-playable-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.ad-motion {
    position: relative;
    overflow: hidden;
}

.ad-motion-poster {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.35;
}

.ad-motion-code {
    position: absolute;
    left: 16px;
    right: 16px;
    top: 18%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    color: #e0f2fe;
}

.ad-motion-code span {
    opacity: 0;
    transform: translateY(8px);
    animation: ad-line-in 4.8s ease-in-out infinite;
}

.ad-motion-code span:nth-child(2) { animation-delay: 0.6s; }
.ad-motion-code span:nth-child(3) { animation-delay: 1.2s; }
.ad-motion-code span:nth-child(4) { animation-delay: 1.8s; }

.ad-motion-caption {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 58px;
    margin: 0;
    font-weight: 700;
    color: #f8fafc;
}

@keyframes ad-line-in {
    0% { opacity: 0; transform: translateY(8px); }
    18%, 70% { opacity: 1; transform: none; }
    100% { opacity: 0; transform: translateY(-6px); }
}

.ad-modal[hidden] {
    display: none;
}

.ad-modal {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: grid;
    place-items: center;
    padding: 24px;
}

.ad-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
}

.ad-modal-dialog {
    position: relative;
    width: min(440px, calc(100vw - 32px));
    height: min(680px, calc(100vh - 48px));
    z-index: 1;
}

.ad-card-modal {
    height: 100%;
}

.ad-modal-close {
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 3;
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

body.ad-modal-open {
    overflow: hidden;
}

@media (max-width: 1499.98px) {
    .ad-rail {
        display: none !important;
    }
}

@media print {
    .ad-rail,
    .ad-modal {
        display: none !important;
    }
}
