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

.kwg {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 100%;
}

/* ═══ LAYOUT ═══ */
.kwg-layout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* ═══ THUMBNAILS (VERTICAL) ═══ */
.kwg-thumbs {
    flex-shrink: 0;
    width: 80px;
    height: 420px;
    overflow: hidden;
}

.kwg-thumbs-view {
    overflow-y: auto;
    height: 100%;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.kwg-thumbs-track {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform .3s ease;
}

.kwg-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    overflow: hidden;
    cursor: pointer;
    padding: 0;
    background: #fff;
    transition: all .25s;
    position: relative;
}
.kwg-thumb:hover {
    border-color: #94a3b8;
    box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.kwg-thumb.is-active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,.25);
}
.kwg-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ═══ MAIN IMAGE ═══ */
.kwg-main {
    flex: 1;
    min-width: 0;
}

.kwg-main-inner {
    position: relative;
    width: 100%;
    height: 420px;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #eef2f6;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.kwg-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .4s ease, transform .4s ease;
    transform: scale(.96);
    pointer-events: none;
    cursor: zoom-in;
}
.kwg-slide.is-active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}
.kwg-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

/* ═══ NAV ARROWS ═══ */
.kwg-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,.85);
    color: #334155;
    font-size: 22px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    transition: all .25s;
    opacity: 0;
    backdrop-filter: blur(4px);
}
.kwg-main-inner:hover .kwg-nav { opacity: 1; }
.kwg-nav:hover {
    background: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
    transform: translateY(-50%) scale(1.08);
}
.kwg-prev { left: 12px; }
.kwg-next { right: 12px; }

/* ═══ COUNTER ═══ */
.kwg-counter {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

/* ═══ LIGHTBOX ═══ */
.kwg-lb {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0,0,0,.92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease;
    backdrop-filter: blur(8px);
}
.kwg-lb.is-active {
    opacity: 1;
    pointer-events: auto;
}

.kwg-lb-img {
    width: calc(100vw - 160px);
    height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.kwg-lb-img img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity .3s ease;
}
.kwg-lb-img img.is-loaded { opacity: 1; }

.kwg-lb-close {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 10;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 28px;
    line-height: 42px;
    text-align: center;
    cursor: pointer;
    transition: background .25s;
}
.kwg-lb-close:hover { background: rgba(255,255,255,.25); }

.kwg-lb-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 48px;
    height: 72px;
    border: 0;
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 42px;
    line-height: 72px;
    text-align: center;
    cursor: pointer;
    transition: all .25s;
}
.kwg-lb-nav:hover { background: rgba(255,255,255,.18); }
.kwg-lb-prev { left: 0; border-radius: 0 8px 8px 0; }
.kwg-lb-next { right: 0; border-radius: 8px 0 0 8px; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .kwg-layout {
        flex-direction: column;
        gap: 8px;
    }

    .kwg-thumbs {
        width: 100%;
        height: auto;
        order: 2;
    }

    .kwg-thumbs-view {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 6px 0;
    }
    .kwg-thumbs-view::-webkit-scrollbar { display: none; }

    .kwg-thumbs-track {
        flex-direction: row;
        width: max-content;
        gap: 8px;
        padding: 0 4px;
    }

    .kwg-main { order: 1; width: 100%; }
    .kwg-main-inner {
        height: 80vw;
        max-height: 60vh;
        min-height: 280px;
    }

    .kwg-slide img {
        padding: 0;
    }

    .kwg-thumb {
        width: 64px;
        height: 64px;
    }

    .kwg-nav { opacity: 1; width: 32px; height: 32px; font-size: 18px; line-height: 32px; }

    .kwg-lb-img { width: calc(100vw - 60px); height: calc(100vh - 60px); }
    .kwg-lb-nav { width: 36px; height: 56px; font-size: 30px; line-height: 56px; }
}
