
*{
        box-sizing: border-box;
}

/* --- โหลดฟอนต์ Custom --- */
@font-face {
    font-family: 'MyCustomFont';
    src: url('custom_font.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
    /* ช่วยให้หน้าเว็บโหลดเร็วขึ้นระหว่างรอฟอนต์ */
}

/* --- ตั้งค่าเริ่มต้น --- */
:root {
    --cols: 4;
}
.btn-download {
    background: #4f545c;
    color: #fff !important;
    text-decoration: none;
    padding: 8px;
    border-radius: 4px;
    font-weight: normal;
    font-size: 10px;
    font-family: 'MyCustomFont', sans-serif;
    text-align: left;
    transition: 0.2s;

    /* --- ส่วนที่แก้ไข/เพิ่มใหม่ --- */
    flex-shrink: 0; /* ป้องกันไม่ให้ปุ่มโดนบีบความสูงเมื่อตกไปอยู่ด้านล่างสุดของกล่อง */
    white-space: normal; /* อนุญาตให้ข้อความปัดขึ้นบรรทัดใหม่ได้ */
    word-break: break-word; /* ตัดคำยาวๆ ขึ้นบรรทัดใหม่ จะได้ไม่ล้นทะลุปุ่ม */
}
a {
    color: #faa61a !important;
    text-decoration: unset;
}

body {
    background-color: #202225;
    color: #b9bbbe;
    font-family: 'MyCustomFont', 'Segoe UI', Tahoma, sans-serif;
    /* ใช้ฟอนต์ใหม่เป็นตัวแรก */
    font-size: 11px;
    padding: 100px 10px 10px 10px;
    max-width: 1200px;
    margin: 0 auto;
    overflow-x: hidden;
}

/* --- แถบเครื่องมือ (Toolbar) --- */
.toolbar {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    z-index: 100;
    display: flex;
    gap: 10px;
    padding: 15px;
    box-sizing: border-box;
    background: #2f3136;
    border-bottom: 2px solid #18191c;
    align-items: center;
    justify-content: center;
}

.search-input {
    background: #202225;
    border: 1px solid #000;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    flex-grow: 1;
    font-size: 13px;
    font-family: 'MyCustomFont', sans-serif;
    max-width: 300px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 11px;
   /*  min-width: 150px; */
}

/* --- โครงสร้าง Grid & Card --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 15px;
}

.card {
    background: #2f3136;
    border-radius: 3px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    border: 1px solid #202225;
    height: 100%;
    box-sizing: border-box;
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}

.card:hover {
   /*  transform: translateY(-2px); */
    border-color: #4f545c;
}

/* --- สีประจำหมวดหมู่ (Category Colors) --- */
.cat-project {
    border-top: 4px solid #43b581;
    background-color: rgba(67, 181, 129, 0.05);
}

.cat-model {
    border-top: 4px solid #00aff4;
    background-color: rgba(0, 175, 244, 0.05);
}

.cat-zip {
    border-top: 4px solid #f04747;
    background-color: rgba(240, 71, 71, 0.05);
}

.cat-bb {
    border-top: 4px solid #5865f2;
    background-color: rgba(88, 101, 242, 0.05);
}

.cat-kofi {
    border-top: 4px solid #ff5e5b;
    background-color: rgba(255, 94, 91, 0.05);
}

.cat-external {
    border-top: 4px solid #72767d;
    background-color: rgba(114, 118, 125, 0.05);
}

/* --- ส่วนหัวของการ์ด (Header) --- */
.header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.badge-container {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.badge {
    font-size: 9px;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 900;
    text-transform: uppercase;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.badge-project {
    background: #43b581;
}

.badge-model {
    background: #00aff4;
}

.badge-zip {
    background: #f04747;
}

.badge-bb {
    background: #5865f2;
}

.badge-kofi {
    background: #ff5e5b;
}

.badge-external {
    background: #72767d;
}

.author {
    font-size: 11px;
    color: #dcddde;
    border-bottom: 1px dashed #4f545c;
    padding-bottom: 4px;
    margin-bottom: 2px;
}

.model-title {
    font-weight: bold;
    color: #fff;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    margin-bottom: 4px;
}

.model-others {
    color: #8ea1e1;
    font-size: 10px;
    font-weight: normal;
}

/* --- กล่องแสดงรูป/วิดีโอ (Media Box) --- */
.media-box {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 0 10px 0;
    background: #18191c;
    border-radius: 4px;
    height: 100px;
    align-items: center;
    justify-content: flex-start;
    scrollbar-width: thin;
    scrollbar-color: #4f545c transparent;
    justify-content: space-evenly;
}

.media-box:not(:has(img + img, video + video, img + video, video + img)) {
    justify-content: center;
}

.media-box img,
.media-box video {
    height: 100%;
    border-radius: 2px;
    cursor: pointer;
    object-fit: contain;
    flex-shrink: 0;
    background: #000;
}

.action-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* --- ปุ่มต่างๆ (Buttons) --- */
.btn-toggle,
.btn-external {
    display: block;
    padding: 8px;
    font-weight: bold;
    font-size: 10px;
    font-family: 'MyCustomFont', sans-serif;
    cursor: pointer;
    text-align: center;
    border-radius: 4px;
    box-sizing: border-box;
    text-decoration: none;
    color: #fff;
    transition: background 0.2s;
    border: none;
    width: 100%;
}

.btn-toggle {
    background: #43b581;
}

.btn-toggle:hover {
    background: #3ca374;
}

.btn-ext {
    background: #bd009c;
    color: #ffffff !important;
}

.btn-external:hover {
    background: #5d6269;
}

.discord-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #5865f2;
    color: #ffffff;
    text-decoration: none;
    font-size: 10px;
    padding: 6px;
    border-radius: 4px;
    transition: 0.2s;
    width: 100%;
    box-sizing: border-box;
    font-family: 'MyCustomFont', sans-serif;
}

.discord-link:hover {
    background: #5865f2;
}

.discord-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* --- Slide Panel สำหรับดาวน์โหลด --- */
.download-panel {
    position: absolute;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    background: rgba(47, 49, 54, 0.98);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  
    border-left: 2px solid #43b581;
}

.download-panel.active {
    right: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #202225;
    border-bottom: 1px solid #18191c;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
}

.close-panel {
    cursor: pointer;
    background: #f04747;
    padding: 2px 6px;
    border-radius: 4px;
    transition: 0.2s;
}

.close-panel:hover {
    background: #d84040;
}

.panel-content {
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-download {
    background: #4f545c;
    color: #fff !important;
    text-decoration: none;
    padding: 8px;
    border-radius: 4px;
    font-weight: normal;
    font-size: 10px;
    font-family: 'MyCustomFont', sans-serif;
    text-align: left;
    transition: 0.2s;

    /* --- ส่วนที่แก้ไข/เพิ่มใหม่ --- */
    flex-shrink: 0; /* ป้องกันไม่ให้ปุ่มโดนบีบความสูงเมื่อตกไปอยู่ด้านล่างสุดของกล่อง */
    white-space: normal; /* อนุญาตให้ข้อความปัดขึ้นบรรทัดใหม่ได้ */
    word-break: break-word; /* ตัดคำยาวๆ ขึ้นบรรทัดใหม่ จะได้ไม่ล้นทะลุปุ่ม */
}

.btn-download:hover {
    background: #5865f2;
}

/* --- ซูมรูปภาพ (Lightbox) --- */
#lightbox {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(60, 63, 68, 0.96);
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

#lightbox-content img,
#lightbox-content video {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 4px;
    display: block;
    border: 2px solid #ffffff;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}


  /* --- ตั้งค่าทั่วไป --- */
    li {
        margin: 5px;
    }

    /* --- Grid Layout --- */
.workshop-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    gap: 0px 0px;
    margin-top: 20px;
}

.workshop-card {
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: #1e1e1e;
    border: none;
    padding: 1px;
    box-shadow: 0px 0px 0px 1px #515151;
}

    /* --- กล่องรูปภาพ --- */
    .thumb-container {
        width: 100%;
        aspect-ratio: 1 / 1;
        background: transparent;
        border-radius: 4px;
        position: relative;
        overflow: hidden;
        cursor: pointer;
    }

    .thumb-container img,
    .thumb-container video {
        width: 100%;
        height: 100%;
        object-fit: contain; /* รูปไม่โดนครอป */
        border-radius: 4px;
        display: block;       
    }

    /* --- ระบบ Slideshow & Indicator --- */
    .media-slides {
        width: 100%;
        height: 100%;
        position: relative;
        background: transparent;
        opacity: 1;
    }

    .slide {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: scale-down;
        opacity: 0;
        transition: none;
        pointer-events: none;        
        transform: translateZ(0);
        z-index: 1;
    }

    .slide.active {
        opacity: 1;
    }

    /* Glow layer — div ด้านหลังรูป */
.slide-glow {
    position: absolute;
    inset: -15%;
    background-size: cover;
    background-position: center;
    filter: saturate(20) blur(100px) brightness(0.6);
    opacity: 1;
    z-index: 1;
    pointer-events: none;
    transform: scale(1);
}

.slide-indicators {
    display: flex;
    gap: 10px;
    position: absolute;
    z-index: 5;
    left: 0px;
    bottom: 38px;
    width: 100%;
    height: 3px;
    padding: 0px 6px;
}

.indicator {
    height: 100%;
    flex-grow: 1;
    background: #2f3136;
    border-radius: 2px;
    transition: 1s all;
    will-change: auto;
}

.indicator.active {
    background: #7070ff;
    box-shadow: 0 0 5px #5865f2;
    transition: 0.1s all;
}

    .hover-zones {
        position: absolute;
        inset: 0;
        display: flex;
        z-index: 5;
    }

    .zone {
        flex: 1;
        height: 100%;
    }

    /* --- จุด Dot แท็ก (มุมซ้ายบน) --- */
    .tag-dots {
        position: absolute;       
        display: flex;
        gap: 4px;
        z-index: 6;
        pointer-events: none;
        left: auto !important;
        right: 8px !important;
    }

    .dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }

    /* --- Hover Overlay (ซ่อนปุ่มเต็มจอ) --- */
    .thumb-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.75);
        backdrop-filter: blur(2px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 8px;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
        z-index: 3;
        padding: 15px;
    }

    .thumb-container:hover .thumb-overlay {
        opacity: 1;
    }

    .overlay-btn {
        width: 100%;
        padding: 8px;
        font-size: 11px;
        font-weight: bold;
        border-radius: 4px;
        border: none;
        cursor: pointer;
        text-align: center;
        text-decoration: none;
        color: #fff;
        transition: 0.1s;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .overlay-btn:hover {
        filter: brightness(1.2);
        transform: scale(1.02);
    }

    /* --- Action Icons (ซ่อนขวาล่าง แบบ SteamDB) --- */
    .action-icons {
        position: absolute;
        bottom: 8px;
        right: 8px;
        display: flex;
        gap: 6px;
        opacity: 0;
        transform: translateY(5px);
        transition: none;
        z-index: 10;
    }

    .thumb-container:hover .action-icons {
        opacity: 1;
        transform: translateY(0);
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        border-radius: 4px;
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        text-decoration: none;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
        transition: 0.1s;
    }

    .icon-btn:hover {
        filter: brightness(1.2);
        transform: scale(1.1);
    }

    /* --- สีของปุ่ม --- */
    .btn-view { background: #4f545c; }
    .btn-dl { background: #1f9d63; }
    .btn-ext { background: #72767d; }
    .btn-dc { background: #5865f2; }
    .btn-dc img {
        width: 14px;
        height: 14px;
        filter: brightness(0) invert(1);
    }

    /* --- ปุ่ม YouTube Play --- */
    .yt-play-btn {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: #FF0000;
        color: #fff;
        border-radius: 8px;
        padding: 4px 12px;
        font-weight: bold;
        font-size: 14px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
        pointer-events: none;
        display: none;
        z-index: 8;
    }

    /* --- แจ้งเตือนในกล่องดาวน์โหลด --- */
.discord-notice {
    color: #faa61a;
    font-size: 11px;
    margin-bottom: 10px;
    padding: 8px;
    background: rgba(250, 166, 26, 0.1);
    border: 1px dashed #faa61a;
    border-radius: 4px;
    line-height: 1.4;
    text-align: left;
}

    .slide[data-type="youtube"].active ~ .yt-play-btn {
        display: block;
    }

    /* --- ข้อมูลใต้รูป --- */
.info-box {
    padding: 8px 4px 0 4px;
    background: linear-gradient(45deg, #000402, #00000000);
    padding: 5px 10px;
    padding-top: 10px;
}

.ws-title {
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 1px;
}

.ws-author {
    color: #b3b3b3;
    font-size: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.5px;
}

    /* --- Download Panel --- */
    .download-panel {
        z-index: 15;
        background: rgba(32, 34, 37, 0.98);
        border-left: none;
        border-bottom: 3px solid #43b581;
    }

    .panel-header {
        background: #18191c;
    }

    /* --- Lightbox --- */
    .lightbox-close {
        position: absolute;
        top: 20px;
        right: 30px;
        color: #aaa;
        font-size: 40px;
        font-weight: bold;
        cursor: pointer;
        transition: color 0.2s;
        z-index: 10000;
        user-select: none;
        line-height: 1;
    }

    .lightbox-close:hover {
        color: #fff;
    }

    .lightbox-iframe {
        width: 90vw;
        max-width: 800px;
        aspect-ratio: 16/9;
        border-radius: 6px;
        border: 2px solid #ffffff;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
        background: #000;
    }

    /* --- Lightbox Nav Arrows --- */
    .lb-nav {
        position: absolute;
        top: 0;
        width: 15%;          /* แถบข้างกว้าง 15% ของ lightbox */
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 56px;
        color: transparent;  /* ลูกศรซ่อนอยู่ */
        cursor: pointer;
        z-index: 10001;
        user-select: none;
        transition: color 0.1s, background 0.1s;
    }



.post-meta-badge {
    position: absolute;
    top: 0px;
    left: 0px;
    z-index: 6;
    pointer-events: none;
    display: flex;
    flex-direction: row;
    gap: 3px;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.8);
}
.post-meta-id {
    color: #fff;
    font-size: 10px;
    background: #00006c;
    padding: 1px 4px;
    width: fit-content;
    box-shadow: 0 0px 0px 1px #959595;
}
.post-meta-date {
    color: #ddd;
    font-size: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    width: fit-content;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

    /* desktop: โชว์ลูกศร + พื้นหลังจางๆ เมื่อ hover */
    @media (pointer: fine) {
        .lb-nav:hover {
            color: rgba(255,255,255,0.9);
            background: linear-gradient(to right, rgba(0,0,0,0.35), transparent);
        }
        .lb-nav-next:hover {
            background: linear-gradient(to left, rgba(0,0,0,0.35), transparent);
        }
    }

    /* mobile: ลูกศรโชว์ตลอด ปุ่มขนาดเล็กลง */
    @media (pointer: coarse) {
        .lb-nav {
            width: 56px;
            height: 56px;
            top: 50%;
            transform: translateY(-50%);
            border-radius: 50%;
            background: rgba(0,0,0,0.45);
            color: rgba(255,255,255,0.85);
            font-size: 36px;
        }
        .lb-nav-prev { left: 12px; }
        .lb-nav-next { right: 12px; }
    }

    .lb-nav-prev { left: 0; }
    .lb-nav-next { right: 0; }

    .lb-count {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        color: rgba(255,255,255,0.6);
        font-size: 13px;
        z-index: 10001;
        user-select: none;
        background: rgba(0,0,0,0.4);
        padding: 3px 10px;
        border-radius: 20px;
    }

    /* indicator bar ด้านบน lightbox (desktop) */
    .lb-indicators {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        display: flex;
        gap: 3px;
        padding: 8px 10px 0;
        z-index: 10002;
        pointer-events: none;
    }

    .lb-indicator {
        flex: 1;
        height: 3px;
        border-radius: 2px;
        background: rgba(255,255,255,0.25);
    }

    .lb-indicator.active {
        background: #fff;
    }

    /* ซ่อน counter บน desktop ใช้ indicator แทน */
    @media (pointer: fine) {
        .lb-count { display: none !important; }
    }




/* --- Mobile Swipe Hint --- */
@media (max-width: 768px) and (pointer: coarse) {
    /* ป้องกัน scroll หน้าตอน swipe บนรูป */
    .thumb-container {
        touch-action: pan-y;
    }

    /* แสดงลูกศรซ้าย-ขวาบางๆ เมื่อมีหลายรูป */
    .hover-zones {
        pointer-events: none; /* ปิด hover zones บนมือถือ ให้ touch event ทำงานแทน */
    }

    /* action icons โชว์ตลอดบนมือถือ ไม่ต้อง hover */
    .action-icons {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }
}

@media (max-width: 600px) {
    body {
        padding-top: 130px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .zoom-controls {
        justify-content: center;
    }

    .media-box {
        height: 180px;
    }
}