.ad-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 15px auto;
    overflow: hidden;
    min-height: 50px;
    text-align: center;
}

#ad-banner-top {
    max-width: 728px;
    min-height: 90px;
    margin: 10px auto;
}

#ad-banner-bottom {
    max-width: 728px;
    min-height: 90px;
    margin: 10px auto 0;
}

.ad-slot.ad-sidebar-top,
.ad-slot.ad-sidebar-bottom {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 300px;
    min-height: 250px;
    margin: 15px auto;
    overflow: hidden;
    text-align: center;
}

.ad-slot.ad-content-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 728px;
    min-height: 90px;
    margin: 20px auto;
    overflow: hidden;
    text-align: center;
}

.ad-native {
    max-width: 100%;
    min-height: 100px;
    margin: 20px auto;
    padding: 0 15px;
    box-sizing: border-box;
}

.ad-container iframe,
.ad-slot iframe {
    max-width: 100%;
    border: none;
}

.ad-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    min-height: inherit;
    background: var(--bg-secondary, #f0f0f0);
    border: 1px dashed var(--border-color, #ddd);
    border-radius: 8px;
    color: var(--text-sub, #999);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.4;
}

[data-theme="dark"] .ad-placeholder {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {

    #ad-banner-top,
    #ad-banner-bottom,
    .ad-slot.ad-content-banner {
        max-width: 320px;
        min-height: 50px;
    }

    /* Ensure sidebar ads are visible on mobile tool pages and scaled slightly to fit better */
    .tool-page .ad-slot.ad-sidebar-top,
    .tool-page .ad-slot.ad-sidebar-bottom {
        display: flex !important;
        margin: 15px auto;
        transform: scale(0.95);
        transform-origin: center top;
        min-height: auto;
    }

    .ad-native {
        padding: 0 10px;
    }
}

@media (max-width: 480px) {

    #ad-banner-top,
    #ad-banner-bottom,
    .ad-slot.ad-content-banner {
        max-width: 300px;
        min-height: 50px;
    }
}

@media print {

    .ad-container,
    .ad-slot,
    .ad-placeholder,
    .ad-native {
        display: none !important;
    }
}