.sg,
.sg *,
.sg-toast,
.sg-toast * {
    box-sizing: border-box;
}

.sg {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    background: #fff;
}

.sg-ico {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sg-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: min(600px, 80vh);
    overflow: hidden;
    background: #f3f4f6;
}

.sg-track {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    touch-action: manipulation;
    scrollbar-width: none;
}

.sg-track::-webkit-scrollbar,
.sg-lb-track::-webkit-scrollbar {
    display: none;
}

.sg-slide {
    flex: 0 0 100%;
    min-width: 0;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.sg-photo {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    cursor: zoom-in;
}

.sg-photo img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}

.sg-count {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.65);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 20px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.sg-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    z-index: 2;
    padding: 6px 7px;
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.45);
    transform: translateX(-50%);
    pointer-events: none;
}

.sg-dots-in {
    display: flex;
    max-width: 110px;
    overflow: hidden;
}

.sg-dot {
    flex: 0 0 6px;
    width: 6px;
    height: 6px;
    margin: 0 2px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
}

.sg-dot.is-on {
    background: #fff;
}

.sg-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    padding: 0;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.sg-nav:hover {
    background: #fff;
    color: #e25848;
}

.sg-nav-prev {
    left: 12px;
}

.sg-nav-next {
    right: 12px;
}

.sg-thumbs {
    display: none;
    gap: 6px;
    width: 100%;
    padding: 8px;
    overflow-x: auto;
    contain: inline-size;
    scrollbar-width: thin;
}

.sg-thumb {
    position: relative;
    flex: 0 0 72px;
    width: 72px;
    height: 54px;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    background: #f3f4f6;
    opacity: 0.72;
    cursor: pointer;
    transition: opacity 150ms ease;
}

.sg-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: 8px;
}

.sg-thumb:hover,
.sg-thumb[aria-current="true"] {
    opacity: 1;
}

.sg-thumb[aria-current="true"]::after {
    border-color: #e25848;
}

.sg-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
}

.sg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 220px;
    padding: 24px;
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 500;
    text-align: center;
}

.sg-empty .sg-ico {
    width: 40px;
    height: 40px;
    stroke-width: 1.5;
}

.sg-photo:focus-visible,
.sg-thumb:focus-visible {
    outline: 2px solid #e25848;
    outline-offset: -2px;
}

.sg-nav:focus-visible,
.sg-lb-btn:focus-visible,
.sg-toast-close:focus-visible {
    outline: 2px solid #e25848;
    outline-offset: 2px;
}

html.sg-lock {
    overflow: hidden;
}

html.sg-lock body {
    padding-right: var(--sg-scrollbar, 0);
}

.sg-lb {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #161616;
    color: #fff;
    overscroll-behavior: contain;
}

.sg-lb[open] {
    display: flex;
    flex-direction: column;
}

.sg-lb::backdrop {
    background: #161616;
}

.sg-lb-top {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px 12px;
    pointer-events: none;
}

.sg-lb-count {
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    font-variant-numeric: tabular-nums;
}

.sg-lb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    cursor: pointer;
    pointer-events: auto;
    transition: background-color 150ms ease;
}

.sg-lb-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

.sg-lb-close {
    margin-left: auto;
}

.sg-lb-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.sg-lb-track {
    position: absolute;
    inset: 0;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y pinch-zoom;
    scrollbar-width: none;
}

.sg-lb-slide {
    flex: 0 0 100%;
    min-width: 0;
    height: 100%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

.sg-lb-slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}

.sg-lb-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: none;
    width: 48px;
    height: 48px;
    margin-top: -24px;
}

.sg-lb-prev {
    left: 16px;
}

.sg-lb-next {
    right: 16px;
}

.sg-lb-thumbs {
    display: none;
    flex: 0 0 auto;
    gap: 6px;
    padding: 8px 16px 12px;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.sg-lb-thumbs .sg-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 48px;
    background: #2d2d2d;
}

.sg-lb-thumbs .sg-thumb:first-child {
    margin-left: auto;
}

.sg-lb-thumbs .sg-thumb:last-child {
    margin-right: auto;
}

.sg-spin {
    display: inline-block;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    vertical-align: -3px;
    animation: sg-spin 800ms linear infinite;
}

@keyframes sg-spin {
    to {
        transform: rotate(360deg);
    }
}

.sg-toast {
    position: fixed;
    top: 16px;
    right: 16px;
    left: 16px;
    z-index: 10000;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 420px;
    margin-left: auto;
    padding: 14px;
    border-radius: 14px;
    background: #1a1a1a;
    color: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.sg-toast.is-in {
    opacity: 1;
    transform: none;
}

.sg-toast-error {
    background: #7f1d1d;
}

.sg-toast-img {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
}

.sg-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.sg-toast-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.sg-toast-msg {
    margin-top: 2px;
    color: #d1d5db;
    font-size: 13px;
    line-height: 1.4;
}

.sg-toast-close {
    display: flex;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: -8px -8px 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.sg-toast-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

@media (min-width: 768px) {
    .sg-nav {
        display: flex;
    }

    .sg-dots {
        display: none;
    }

    .sg-thumbs {
        display: flex;
    }

    .sg-lb-nav {
        display: flex;
    }

    .sg-lb-thumbs {
        display: flex;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .sg-track,
    .sg-thumbs,
    .sg-lb-track,
    .sg-lb-thumbs {
        scroll-behavior: smooth;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sg-spin {
        animation: none;
    }

    .sg-nav,
    .sg-thumb,
    .sg-lb-btn,
    .sg-toast {
        transition: none;
    }
}
