﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(130deg, #5c7bff 0%, #7f58c8 45%, #4895ef 100%);
    min-height: 100vh;
    color: #27324a;
    line-height: 1.5;
}

.container {
    width: min(96vw, 1680px);
    margin: 0 auto;
    padding: clamp(16px, 2.1vw, 36px);
}

header {
    text-align: center;
    margin-bottom: clamp(24px, 4vw, 48px);
    color: #fff;
}

header h1 {
    font-size: clamp(2rem, 4vw, 3.3rem);
    margin-bottom: 12px;
    text-shadow: 0 6px 24px rgba(21, 24, 51, 0.28);
}

header p {
    font-size: clamp(1rem, 1.55vw, 1.24rem);
    opacity: 0.94;
    max-width: 920px;
    margin: 0 auto;
}

main {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 24px;
    padding: clamp(20px, 2.6vw, 44px);
    box-shadow: 0 24px 56px rgba(18, 25, 45, 0.14);
    margin-bottom: 18px;
}

#sandphoto-form-container {
    width: 100%;
}

.sandphoto-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: clamp(14px, 1.5vw, 24px);
}

.form-step,
.sandphoto-form .preview-container {
    border: 1px solid #e2e8f8;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8faff 100%);
    box-shadow: 0 8px 22px rgba(49, 68, 118, 0.08);
    padding: clamp(14px, 1.5vw, 20px);
}

.form-step strong {
    display: block;
    color: #1f2a44;
    font-size: 1.04rem;
    margin-bottom: 6px;
}

.form-step > br,
.sandphoto-form .preview-container > br {
    display: block;
    margin-bottom: 10px;
    content: '';
}

.form-step label {
    color: #38445d;
    font-weight: 600;
}

.form-control {
    width: 100%;
    min-height: 44px;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid #cfd8ef;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
    color: #27324a;
}

.form-control:focus {
    outline: none;
    border-color: #5c7bff;
    box-shadow: 0 0 0 3px rgba(92, 123, 255, 0.16);
}

#customSizeGroup,
#customSizeGroup2,
#customCountGroup,
#customSizeSection,
#photoCountSection {
    transition: all 0.28s ease;
}

#customSizeGroup.show,
#customSizeGroup2.show,
#customCountGroup.show,
#customSizeSection.show,
#photoCountSection.show {
    animation: slideDown 0.28s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

input[type="number"].form-control {
    -moz-appearance: textfield;
}

input[type="number"].form-control::-webkit-outer-spin-button,
input[type="number"].form-control::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-size-section,
.photo-count-section {
    margin-top: 12px;
}

.custom-size-section label,
.photo-count-section label {
    display: block;
    margin-bottom: 6px;
}

.upload-area {
    border: 2px dashed #c5d1ef;
    border-radius: 14px;
    padding: clamp(30px, 4.1vw, 62px) 20px;
    min-height: 165px;
    text-align: center;
    transition: all 0.25s ease;
    background: #f7faff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.upload-area p {
    color: #56627f;
}

.layout-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.layout-tab {
    position: relative;
    cursor: pointer;
}

.layout-tab input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.layout-tab span {
    display: inline-block;
    padding: 7px 14px;
    border: 1px solid #c9d5f3;
    border-radius: 999px;
    background: #f4f7ff;
    color: #314472;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.layout-tab input:checked + span {
    background: #5c7bff;
    border-color: #5c7bff;
    color: #fff;
    box-shadow: 0 6px 16px rgba(92, 123, 255, 0.25);
}

.upload-area:hover {
    border-color: #5c7bff;
    background: #eef3ff;
}

.upload-area.dragover {
    border-color: #4a69eb;
    background: #e8efff;
    transform: scale(1.01);
}

#photoListContainer {
    margin-top: 14px !important;
}

#photoList {
    border: 1px solid #d8e0f5 !important;
    border-radius: 10px !important;
    background: #fff;
}

.sandphoto-form .preview-container {
    grid-column: 1 / -1;
    display: block;
}

.sandphoto-form .preview-container p {
    margin-bottom: 10px;
    color: #38445d;
}

#previewCanvas {
    display: block;
    width: min(100%, 1200px);
    height: auto;
    margin: 12px auto 14px;
    border: 1px solid #d8e1f6;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 26px rgba(24, 36, 65, 0.12);
}

#count {
    font-weight: 700;
    color: #4a69eb;
}

.sandphoto-form > .form-step:last-child {
    grid-column: 1 / -1;
}

.download-btn {
    background: linear-gradient(135deg, #19a95a 0%, #19bf95 100%);
    color: #fff;
    border: none;
    padding: 13px 30px;
    border-radius: 999px;
    font-size: 1.04rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 24px rgba(25, 169, 90, 0.27);
}

.download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(25, 169, 90, 0.31);
}

.download-btn:disabled {
    background: #bec5d2;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

footer {
    text-align: center;
    color: #eef3ff;
    opacity: 0.9;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #5c7bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (min-width: 920px) {
    .sandphoto-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1420px) {
    .sandphoto-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .container {
        width: 100%;
        padding: 10px;
    }

    main {
        border-radius: 16px;
        padding: 14px;
    }

    .form-step,
    .sandphoto-form .preview-container {
        padding: 12px;
    }

    .upload-area {
        min-height: 135px;
        padding: 24px 14px;
    }

    #previewCanvas {
        width: 100%;
    }
}
