.xdgb-gallery {
    --xdgb-bg: #0b1220;
    --xdgb-panel: #111c2e;
    --xdgb-line: rgba(255, 255, 255, 0.1);
    --xdgb-text: #f4f8ff;
    --xdgb-muted: #91a2ba;
    --xdgb-accent: #78d5ff;
    margin: 18px 0 30px;
    color: var(--xdgb-text);
    background: linear-gradient(145deg, #101a2b 0%, var(--xdgb-bg) 58%, #0e1727 100%);
    border: 1px solid rgba(120, 213, 255, 0.16);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    overflow: hidden;
    isolation: isolate;
}

.xdgb-gallery *,
.xdgb-gallery *::before,
.xdgb-gallery *::after {
    box-sizing: border-box;
}

.xdgb-gallery-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px 13px;
}

.xdgb-gallery-kicker {
    color: var(--xdgb-accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
}

.xdgb-gallery-hint {
    color: var(--xdgb-muted);
    font-size: 12px;
}

.xdgb-stage {
    position: relative;
    margin: 0 12px;
    aspect-ratio: 16 / 9;
    background: #050912;
    border: 1px solid var(--xdgb-line);
    border-radius: 12px;
    overflow: hidden;
    outline: none;
    touch-action: pan-y;
}

.xdgb-stage:focus-visible {
    box-shadow: 0 0 0 3px rgba(120, 213, 255, 0.35);
}

.xdgb-stage-image {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    opacity: 1;
    transition: opacity 0.25s ease, transform 0.5s ease;
}

.xdgb-stage.is-loading .xdgb-stage-image {
    opacity: 0.25;
    transform: scale(0.995);
}

.xdgb-stage.is-error .xdgb-stage-image {
    opacity: 0;
}

.xdgb-stage.is-error::after {
    content: '图片加载失败，请切换其他截图';
    position: absolute;
    top: 50%;
    left: 50%;
    color: var(--xdgb-muted);
    font-size: 13px;
    transform: translate(-50%, -50%);
}

.xdgb-stage-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(2, 6, 23, 0.03) 45%, rgba(2, 6, 23, 0.78) 100%);
}

.xdgb-stage-open {
    position: absolute;
    inset: 0;
    width: 100%;
    padding: 0;
    color: #fff;
    background: transparent;
    border: 0;
    cursor: zoom-in;
}

.xdgb-stage-open svg {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    padding: 8px;
    background: rgba(5, 9, 18, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 9px;
    opacity: 0;
    backdrop-filter: blur(8px);
    transition: opacity 0.2s ease;
}

.xdgb-stage:hover .xdgb-stage-open svg,
.xdgb-stage-open:focus-visible svg {
    opacity: 1;
}

.xdgb-nav {
    position: absolute;
    top: 50%;
    display: grid;
    width: 38px;
    height: 38px;
    padding: 9px;
    color: #fff;
    background: rgba(5, 9, 18, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    backdrop-filter: blur(8px);
    transform: translateY(-50%);
    transition: opacity 0.2s ease, background 0.2s ease;
}

.xdgb-nav:hover,
.xdgb-lightbox-nav:hover,
.xdgb-lightbox-close:hover {
    background: rgba(31, 51, 79, 0.92);
}

.xdgb-stage:hover .xdgb-nav,
.xdgb-stage:focus-within .xdgb-nav {
    opacity: 1;
}

.xdgb-nav-prev {
    left: 14px;
}

.xdgb-nav-next {
    right: 14px;
}

.xdgb-nav svg,
.xdgb-lightbox-nav svg,
.xdgb-lightbox-close svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.xdgb-stage-status {
    position: absolute;
    right: 18px;
    bottom: 14px;
    left: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    pointer-events: none;
}

.xdgb-counter {
    flex: 0 0 auto;
    color: #dceaff;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    letter-spacing: 0.12em;
}

.xdgb-progress {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 99px;
    overflow: hidden;
}

.xdgb-progress-bar {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #4cc9ff, #a7e8ff);
    border-radius: inherit;
    transform-origin: left center;
    transition: transform 0.3s ease;
}

.xdgb-rail-wrap {
    position: relative;
    padding: 13px 12px 15px;
}

.xdgb-thumbs {
    display: flex;
    gap: 9px;
    padding: 2px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(120, 213, 255, 0.35) transparent;
}

.xdgb-thumbs::-webkit-scrollbar {
    height: 4px;
}

.xdgb-thumbs::-webkit-scrollbar-thumb {
    background: rgba(120, 213, 255, 0.35);
    border-radius: 99px;
}

.xdgb-thumb {
    position: relative;
    flex: 0 0 108px;
    padding: 0;
    aspect-ratio: 16 / 9;
    background: #050912;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    opacity: 0.58;
    transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.xdgb-thumb:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.xdgb-thumb.is-active {
    border-color: var(--xdgb-accent);
    box-shadow: 0 0 0 2px rgba(120, 213, 255, 0.18);
    opacity: 1;
}

.xdgb-thumb.is-unavailable {
    opacity: 0.25;
}

.xdgb-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
    object-fit: cover;
}

.xdgb-thumb-index {
    position: absolute;
    right: 5px;
    bottom: 4px;
    padding: 1px 4px;
    color: #eaf6ff;
    background: rgba(2, 6, 23, 0.7);
    border-radius: 4px;
    font-size: 9px;
    font-variant-numeric: tabular-nums;
}

.xdgb-lightbox {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100vh;
    max-height: none;
    margin: 0;
    padding: 54px 68px;
    color: #fff;
    background: rgba(3, 7, 16, 0.96);
    border: 0;
    overflow: hidden;
}

.xdgb-lightbox::backdrop {
    background: rgba(3, 7, 16, 0.96);
}

.xdgb-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.xdgb-lightbox-image {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    object-fit: contain;
}

.xdgb-lightbox-close,
.xdgb-lightbox-nav {
    position: absolute;
    display: grid;
    width: 42px;
    height: 42px;
    padding: 11px;
    color: #fff;
    background: rgba(20, 32, 51, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.xdgb-lightbox-close {
    top: 18px;
    right: 20px;
}

.xdgb-lightbox-prev {
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
}

.xdgb-lightbox-next {
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
}

.xdgb-lightbox-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    padding: 5px 12px;
    color: #cfe7ff;
    background: rgba(20, 32, 51, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.12em;
    transform: translateX(-50%);
}

body.xdgb-lightbox-open {
    overflow: hidden;
}

@media (max-width: 640px) {
    .xdgb-gallery {
        margin: 14px 0 24px;
        border-radius: 14px;
    }

    .xdgb-gallery-head {
        padding: 13px 13px 11px;
    }

    .xdgb-gallery-kicker {
        font-size: 9px;
        letter-spacing: 0.13em;
    }

    .xdgb-gallery-hint {
        font-size: 10px;
    }

    .xdgb-stage {
        margin: 0 7px;
        border-radius: 9px;
    }

    .xdgb-nav {
        width: 34px;
        height: 34px;
        padding: 8px;
        opacity: 1;
    }

    .xdgb-nav-prev {
        left: 9px;
    }

    .xdgb-nav-next {
        right: 9px;
    }

    .xdgb-stage-open svg {
        top: 9px;
        right: 9px;
        width: 30px;
        height: 30px;
        padding: 7px;
        opacity: 1;
    }

    .xdgb-stage-status {
        right: 12px;
        bottom: 10px;
        left: 12px;
    }

    .xdgb-rail-wrap {
        padding: 10px 7px 12px;
    }

    .xdgb-thumb {
        flex-basis: 84px;
    }

    .xdgb-lightbox {
        padding: 52px 12px;
    }

    .xdgb-lightbox-nav {
        top: auto;
        bottom: 18px;
        transform: none;
    }

    .xdgb-lightbox-prev {
        left: 18px;
    }

    .xdgb-lightbox-next {
        right: 18px;
    }

    .xdgb-lightbox-counter {
        bottom: 27px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .xdgb-gallery *,
    .xdgb-lightbox * {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
