* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    min-height: 100vh;
    padding: 20px;
}

.home-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 1rem;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding-top: 60px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 10px;
    letter-spacing: 0.05rem;
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.7);
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn.primary {
    background: linear-gradient(135deg, #ff6b6b, #f06595, #cc5de8, #845ef7, #5c7cfa, #339af0, #22b8cf, #20c997);
    border-color: transparent;
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.4);
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn.icon-btn {
    padding: 10px;
    min-width: 44px;
}

label.btn {
    display: inline-block;
    cursor: pointer;
}

.content-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
    align-items: start;
}

.content-layout:not(:has(.image-section.active)) {
    grid-template-columns: 1fr;
}

.image-section {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    min-height: 300px;
    align-items: center;
    justify-content: center;
}

.image-section.active {
    display: flex;
}

.image-section img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.color-swatch {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.color-swatch.add-color {
    background: rgba(255, 255, 255, 0.05);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    justify-content: center;
    align-items: center;
    padding: 0;
    display: flex;
}

.color-swatch.add-color:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

.add-color-icon {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.5);
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}

.remove-btn:hover {
    background: rgba(255, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
}

.lock-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}

.lock-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.color-swatch.locked .lock-btn {
    background: rgba(255, 215, 0, 0.6);
    border-color: rgba(255, 215, 0, 0.8);
}

.edit-color-btn {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: all 0.2s ease;
}

.color-swatch:hover .edit-color-btn {
    opacity: 1;
}

.edit-color-btn:hover {
    background: rgba(100, 150, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.5);
}

.color-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.image-section.picking-mode {
    cursor: crosshair;
    position: relative;
    border: 3px solid #22b8cf;
    box-shadow: 0 0 0 3px rgba(34, 184, 207, 0.3), 0 4px 15px rgba(0, 0, 0, 0.3);
}

.image-section.picking-mode img {
    cursor: crosshair;
}

.color-preview-cursor {
    position: fixed;
    width: 40px;
    height: 40px;
    border: 3px solid white;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    transform: translate(20px, 20px);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: background-color 0.05s ease;
}

.picker-overlay {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
}

.picker-message {
    background: rgba(34, 184, 207, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
    white-space: nowrap;
}

.picker-message small {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.9;
    display: block;
    margin-top: 4px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.color-swatch:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.color-info {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.color-hex {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.color-rgb {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    font-family: 'Courier New', monospace;
}

.export-section {
    text-align: center;
    margin-top: 30px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-export {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

.btn-export:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

@media (max-width: 968px) {
    .content-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .palette {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .color-swatch {
        padding: 12px;
    }

    .content-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding-top: 70px;
    }
    
    .controls {
        gap: 10px;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .btn.icon-btn {
        padding: 10px;
        min-width: 40px;
    }
    
    .palette {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .color-swatch {
        padding: 10px;
    }
    
    .color-info {
        padding: 8px;
    }
    
    .color-hex {
        font-size: 0.85rem;
    }
    
    .color-rgb {
        font-size: 0.75rem;
    }
}
