* {
    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(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.hero-section {
    margin-bottom: 50px;
    text-align: center;
}

.hero-section h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #333;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-section > p {
    font-size: 1.2rem;
    color: #666;
    max-width: 800px;
    margin: 0 auto 40px;
    line-height: 1.6;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

.feature {
    text-align: left;
    padding: 20px;
    border-radius: 12px;
    background: #f8f9fa;
    border-left: 4px solid #667eea;
}

.feature h3 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: #333;
}

.feature p {
    color: #666;
    line-height: 1.5;
}

.how-to-use {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
}

.how-to-use h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

.how-to-use ol {
    max-width: 600px;
    margin: 0 auto;
    padding-left: 20px;
}

.how-to-use li {
    margin-bottom: 12px;
    color: #555;
    line-height: 1.5;
    font-size: 1.1rem;
}

@media (max-width: 768px) {
    .hero-section h2 {
        font-size: 2rem;
    }
    
    .features {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .how-to-use {
        padding: 20px;
    }
}

.upload-section {
    margin-bottom: 40px;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: scale(1.02);
}

.upload-content svg {
    color: #667eea;
    margin-bottom: 20px;
}

.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.upload-content p {
    color: #666;
    font-size: 1rem;
}

.controls-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 40px;
    align-items: start;
}

.controls-section .color-controls {
    margin-bottom: 20px;
}

.color-controls {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.color-controls h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #333;
}

.preset-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    cursor: pointer;
    user-select: none;
    gap: 8px;
}

.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 2px;
    transition: all 0.2s ease;
    color: #888;
    display: flex;
    align-items: center;
    margin-top: -2px;
}

.collapse-btn:hover {
    color: #555;
}

.collapse-btn svg {
    transition: transform 0.3s ease;
}

.preset-colors.collapsed .collapse-btn svg {
    transform: rotate(-90deg);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
    max-height: 1000px;
}

.preset-colors.collapsed .preset-grid {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}

.preset-item {
    aspect-ratio: 3/2;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.preset-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.preset-item.active {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.preset-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, var(--shadow) 0%, var(--highlight) 100%);
}

.color-inputs {
    display: flex;
    align-items: end;
    gap: 15px;
}

.color-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.color-input label {
    font-weight: 500;
    color: #666;
}

.color-input input[type="color"] {
    width: 80px;
    height: 50px;
    border: 3px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding: 0;
    background: none;
    overflow: hidden;
}

.color-input input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border: none;
    border-radius: 7px;
    overflow: hidden;
}

.color-input input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 7px;
}

.color-input input[type="color"]::-moz-color-swatch {
    border: none;
    border-radius: 7px;
}

.color-input input[type="color"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.swap-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #f8f9fa;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-bottom: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.swap-btn:hover {
    background: #667eea;
    color: white;
    transform: rotate(180deg);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.preview-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    background: #f8f9fa;
    border-radius: 15px;
    position: relative;
}

#canvas {
    max-width: 100%;
    max-height: 500px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

.action-buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#resetBtn {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #ddd;
}

#resetBtn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

#downloadBtn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

#downloadBtn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}


@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 20px;
    }
    
    .controls-section {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .color-inputs {
        justify-content: center;
    }
    
    .preset-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    /* Auto-collapse presets on mobile */
    .preset-colors {
        order: 2;
    }
    
    .custom-colors {
        order: 1;
    }
}