footer {
    position: relative;
    isolation: isolate;
    background: transparent;
    padding: 18px 12px 28px;
    width: 100%;
    margin-left: 0;
    bottom: 0;
    text-align: center; /* 确保内容居中显示 */
}

footer::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 100vw;
    transform: translateX(-50%);
    background:
        linear-gradient(135deg, rgba(255, 247, 236, 0.98), rgba(255, 250, 241, 0.98)),
        #fff7ec;
    box-shadow: inset 0 1px 0 rgba(44, 36, 39, 0.06);
}

.footer-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    max-width: 1180px;
    margin: 0 auto;
    align-items: center;
}

body.home-page .footer-container {
    max-width: 1260px;
}

.footer-ad {
    width: 100%;
    text-align: center;
    overflow: hidden; /* 确保多出的部分隐藏 */
}

.donation-ad {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    min-height: 60px;
    overflow: hidden;
    touch-action: pan-y;
}

.donation-network-banner,
.donation-native-container {
    display: flex;
    max-width: 100%;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    overflow: hidden;
}

.donation-inline-ad {
    width: min(1180px, calc(100% - 32px));
    margin: 22px auto;
    padding: 10px;
    border: 1px solid rgba(44, 36, 39, 0.07);
    border-radius: 8px;
    background: rgba(255, 253, 249, 0.68);
    box-shadow: 0 10px 26px rgba(64, 41, 31, 0.06);
}

.donation-inline-ad--between {
    margin-top: 14px;
    margin-bottom: 28px;
}

.donation-inline-ad--wide {
    margin-top: 26px;
    margin-bottom: 26px;
}

.donation-inline-ad .donation-ad {
    min-height: 50px;
}

/* Keep empty ad shells out of the document flow until the network renders. */
.donation-placement--pending {
    position: absolute !important;
    left: -10000px !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.donation-sticky-ad {
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 1180;
    width: auto;
    max-width: calc(100vw - 24px);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.donation-sticky-ad--ready {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.donation-network-banner iframe,
.donation-native-container iframe {
    max-width: 100%;
    margin: 0 auto;
}

body.home-page .donation-inline-ad {
    width: min(1260px, calc(100% - 24px));
}

.donation-sticky-close {
    position: absolute;
    top: -10px;
    right: -10px;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid rgba(44, 36, 39, 0.14);
    border-radius: 50%;
    color: var(--ink, #2c2427);
    background: rgba(255, 253, 249, 0.98);
    box-shadow: 0 8px 18px rgba(64, 41, 31, 0.16);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: none;
}

.donation-sticky-ad--ready .donation-sticky-close {
    display: inline-flex;
}

.donation-sticky-close:hover {
    color: var(--accent-strong, #8f2f36);
}

.footer-content {
    width: 100%;
    text-align: center;
    line-height: 1.7;
    padding: 8px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

#footer-ad-left {
    order: 1;
}

.footer-content {
    order: 2;
}

.footer-content p {
    margin: 6px 0;
    font-size: 14px;
}

.footer-legal-links {
    font-size: 14px;
}

.floating-home-link {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(92px + env(safe-area-inset-bottom));
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 92px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(143, 47, 54, 0.18);
    border-radius: 999px;
    color: var(--accent-strong, #8f2f36);
    background:
        linear-gradient(135deg, rgba(255, 253, 249, 0.94), rgba(255, 240, 238, 0.92)),
        var(--surface, #fffdf9);
    box-shadow:
        0 10px 24px rgba(64, 41, 31, 0.12),
        inset 0 -8px 0 rgba(181, 72, 72, 0.08);
    backdrop-filter: blur(12px);
    font-size: 13px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.floating-home-link:hover {
    color: var(--accent-strong, #8f2f36);
    transform: translateY(-2px);
    background:
        linear-gradient(135deg, rgba(255, 253, 249, 0.98), rgba(255, 232, 228, 0.96)),
        var(--surface, #fffdf9);
    box-shadow:
        0 13px 30px rgba(64, 41, 31, 0.16),
        inset 0 -8px 0 rgba(181, 72, 72, 0.12);
}

.floating-home-link strong {
    font-size: 17px;
    line-height: 1;
}

@media (max-width: 1679px) {
    .donation-sticky-ad {
        display: none !important;
    }
}

@media (max-width: 1180px) {
    .footer-ad .donation-network-banner {
        width: min(100%, 320px) !important;
    }
}

@media (max-width: 800px) {
    .footer-ad {
        margin: 10px auto;
    }

    .donation-ad {
        min-height: 50px;
    }

    .donation-inline-ad {
        width: calc(100% - 20px);
        margin: 16px auto 22px;
        padding: 8px;
    }

    .donation-network-banner {
        width: min(100%, 320px) !important;
    }

    .floating-home-link {
        right: max(8px, env(safe-area-inset-right));
        bottom: calc(84px + env(safe-area-inset-bottom));
        min-width: 78px;
        min-height: 34px;
        padding: 0 10px;
        font-size: 12px;
        box-shadow:
            0 8px 18px rgba(64, 41, 31, 0.12),
            inset 0 -7px 0 rgba(181, 72, 72, 0.08);
    }

    .floating-home-link strong {
        font-size: 15px;
    }
}
