@font-face {
    font-family: 'StudentTestArialRounded';
    src: url('fonter/Arial Rounded.ttf') format('truetype');
    font-display: swap;
}

.student-test-gallery {
    width: min(1800px, 96vw);
    margin: 20px auto 40px;
}

.gallery-header {
    text-align: center;
    margin-bottom: 20px;
}

.gallery-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 6px;
}

.gallery-subtitle {
    font-size: 1rem;
    color: #555;
    margin: 0 0 10px 0;
}

.style-info-text {
    max-width: 900px;
    margin: 10px auto 0 auto;
    color: #000;
    font-size: 0.9rem;
}

.style-select {
    min-width: 260px;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, 220px);
    gap: 14px;
    align-items: start;
    justify-content: center;
}

.template-card {
    display: block;
    background: #fff;
    border-radius: 12px;
    overflow: visible;
    border: none;
    text-decoration: none;
    color: #222;
    transition: transform 0.15s ease;
    height: 100%;
    width: 220px;
}

.template-card-media {
    position: relative;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.15s ease;
}

.template-card-media::before {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 8px;
    background-image: url('demo.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    pointer-events: none;
    z-index: 0;
}

.template-text-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.template-text-name,
.template-text-class {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'StudentTestArialRounded', 'Arial Rounded MT', Arial, sans-serif;
    color: rgb(0, 120, 255);
    font-weight: 300;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
    white-space: nowrap;
    z-index: 3;
}

.template-text-name {
    top: -5px;
    font-size: 36px;
}

.template-text-class {
    bottom: 6px;
    font-size: 27px;
}

.template-card:hover {
    transform: translateY(-2px);
}

.template-card:hover .template-card-media {
    border-color: #b70e13;
}

.template-card img {
    position: relative;
    z-index: 1;
    width: 220px;
    height: 293px;
    object-fit: contain;
    background: transparent;
    display: block;
    transform: scaleX(1.06);
    transform-origin: center;
}

.template-flag-hint {
    z-index: 2;
    position: absolute;
    left: 50%;
    bottom: 16%;
    transform: translateX(-50%) rotate(-15deg);
    color: #b70e13;
    font-weight: 700;
    font-size: clamp(1.3rem, 2.2vw, 2rem);
    white-space: nowrap;
    text-shadow: 0 0 8px #fff, 0 0 12px #fff, 0 0 16px #fff;
    pointer-events: none;
}

.template-card > span {
    display: none;
}

.template-program-description {
    margin-top: 8px;
    font-size: 0.86rem;
    line-height: 1.25;
    color: #333;
    text-align: center;
    min-height: 2.2em;
}

.template-empty-state {
    grid-column: 1 / -1;
    text-align: center;
    color: #666;
    padding: 25px 10px;
    background: #fff;
    border: 1px dashed #ccc;
    border-radius: 10px;
}

.student-test-step-header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
}

.student-test-step-header h2 {
    margin: 0;
    font-size: 1.35rem;
}

.student-test-back-link {
    color: #b70e13;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
}

.student-test-design-actions {
    margin: 20px auto 10px;
    text-align: center;
}

#finishDesignBtn {
    border: none;
    background: #b70e13;
    color: #fff;
    padding: 13px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}

#alternateTemplateHeading {
    font-size: 0.95rem;
    margin-bottom: 8px;
    white-space: nowrap;
}

.step-design .student-test-options-stage {
    display: none;
}

.step-options .student-test-design-stage {
    display: none;
}

@media (min-width: 1024px) {
    .student-test-builder-page.step-design.student-test-desktop-layout .combined-layout {
        display: block !important;
        position: relative;
        max-width: 1400px;
        margin: 0 auto;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .design-section {
        width: 600px;
        max-width: 600px;
        margin: 0 auto;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .design-section .container {
        max-width: 600px;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external {
        position: absolute;
        top: 0;
        left: calc(50% + 350px);
        width: 440px;
        background: #fff;
        border-style: dotted;
        border-color: #b70e13;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        padding: 10px;
        box-sizing: border-box;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-external {
        position: absolute;
        top: 0;
        right: calc(50% + 350px);
        width: 440px;
        background: #fff;
        border-style: dotted;
        border-color: #b70e13;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
        padding: 10px;
        box-sizing: border-box;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-external.hidden {
        display: none !important;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-content {
        height: 100%;
        overflow-y: auto;
        background: #f9f9f9;
        border-radius: 5px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
        padding: 12px 14px;
        box-sizing: border-box;
        text-align: left;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-content h3 {
        margin: 0 0 10px 0;
        color: #b70e13;
        font-size: 1.05rem;
        text-align: center;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-content p {
        margin: 0 0 10px 0;
        line-height: 1.45;
        font-size: 0.9rem;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-content ol {
        margin: 0 0 10px 18px;
        padding: 0;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-tips-content li {
        margin-bottom: 8px;
        line-height: 1.4;
        font-size: 0.9rem;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external.hidden {
        display: none !important;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external #thumbnailsContent,
    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external #thumbnailsContent.hidden {
        display: block !important;
        background: #f9f9f9;
        border: none;
        border-radius: 5px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
        overflow: hidden;
        box-sizing: border-box;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external #thumbnailsContent .thumbnails-content {
        height: calc(100% - 44px);
        max-height: none;
        overflow-y: auto;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external #thumbnailsContent .thumbnails {
        grid-template-columns: repeat(auto-fit, 96px);
        gap: 10px;
        padding: 8px;
        justify-content: center;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external #thumbnailsContent .thumbnail img {
        width: 96px;
        height: 128px;
        object-fit: cover;
        display: block;
    }

    .student-test-builder-page.step-design.student-test-desktop-layout .student-test-template-external #closeThumbnailsSidebar,
    .student-test-builder-page.step-design.student-test-desktop-layout #showThumbnailsBtn {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .student-test-gallery {
        width: 98vw;
    }

    .template-grid {
        grid-template-columns: repeat(auto-fit, 160px);
        gap: 10px;
        justify-content: center;
    }

    .template-card {
        width: 160px;
    }

    .template-card img {
        width: 160px;
        height: 213px;
    }

    .template-text-name {
        top: -2px;
        font-size: 26px !important;
    }

    .template-text-class {
        bottom: 8px;
        font-size: 20px !important;
    }

    .template-card span {
        font-size: 0.88rem;
    }

    .template-program-description {
        font-size: 0.8rem;
    }
}

.student-image-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 20px;
    box-sizing: border-box;
}

.student-image-progress-overlay.hidden {
    display: none !important;
}

.student-image-progress-box {
    width: min(460px, 92vw);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    padding: 22px 20px 18px;
    box-sizing: border-box;
    text-align: center;
}

.student-image-progress-title {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 14px;
}

.student-image-progress-bar {
    width: 100%;
    height: 14px;
    background: #ececec;
    border-radius: 999px;
    overflow: hidden;
}

.student-image-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #b70e13 0%, #de3c40 100%);
    border-radius: 999px;
    transition: width 0.2s ease;
}

.student-image-progress-text {
    margin-top: 10px;
    color: #555;
    font-size: 0.92rem;
}
