:root {
            --primary: #4f46e5;
            --primary-light: #6366f1;
            --primary-lighter: #818cf8;
            --secondary: #10b981;
            --danger: #ef4444;
            --warning: #f59e0b;
            --dark: #1e293b;
            --darker: #0f172a;
            --light: #f8fafc;
            --gray: #94a3b8;
            --gray-light: #e2e8f0;
            --gray-lighter: #f1f5f9;
            --success: #10b981;
            --info: #3b82f6;
            --white: #ffffff;
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        }

        body {
            background-color: var(--gray-lighter);
            color: var(--dark);
            min-height: 100vh;
            line-height: 1.5;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .headerp {
            text-align: center;
            margin-bottom: 1rem;
            margin-top: -0.5rem;
            background-color: var(--white);
            border-radius: 0.75rem;
            box-shadow: var(--shadow-sm);
            padding: 1rem 0;
        }

.headerp h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.headerp .subtitle {
    font-size: 0.9rem;
    color: var(--gray);
    max-width: 700px;
    margin: 0 auto;
}

        .tool-container {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        @media (max-width: 768px) {
            .tool-container {
                grid-template-columns: 1fr;
            }
            
            .headerp h1 {
                font-size: 1.5rem;
            }
            
            .btn {
                padding: 0.4rem 0.8rem;
                font-size: 0.8rem;
            }
            
            .panel-header, .upload-section, .uploaded-files, .merge-options, .controls {
                padding: 0.8rem;
            }
            
            .upload-option {
                padding: 1rem;
            }
            
            .results-grid {
                grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
                gap: 1rem;
                padding: 0.8rem;
            }
            
            .features-grid {
                grid-template-columns: 1fr;
            }
            
            .tool-description-container {
                padding: 1rem;
            }
            
            .preview-container {
                min-height: 250px;
            }
            
            .result-image {
                height: 120px;
            }
        }

        .panel {
            background: white;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            overflow: hidden;
            border: 1px solid rgba(0, 0, 0, 0.03);
        }

        .panel-header {
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--gray-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .panel-title {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-weight: 600;
            color: var(--darker);
        }

        .panel-actions {
            display: flex;
            gap: 0.5rem;
        }

        .btn {
            background: var(--primary);
            color: white;
            border: none;
            padding: 0.5rem 1rem;
            border-radius: 6px;
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.4rem;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
            white-space: nowrap;
        }

        .btn:hover {
            background: var(--primary-lighter);
            transform: translateY(-1px);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
        }

        .btn:active {
            transform: translateY(0);
        }

        .btn-sm {
            padding: 0.4rem 0.8rem;
            font-size: 0.8rem;
        }

        .btn-secondary {
            background: white;
            color: var(--primary);
            border: 1px solid var(--gray-light);
        }

        .btn-secondary:hover {
            background: rgba(79, 70, 229, 0.05);
            border-color: var(--primary-light);
        }

        .btn-success {
            background: var(--success);
        }

        .btn-success:hover {
            background: #0e9f72;
        }

        .btn-danger {
            background: var(--danger);
        }

        .btn-danger:hover {
            background: #dc2626;
        }

        .btn-disabled {
            opacity: 0.6;
            cursor: not-allowed;
            pointer-events: none;
        }

        .upload-section {
            padding: 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }

        .upload-option {
            border: 2px dashed var(--gray-light);
            border-radius: 10px;
            padding: 1.5rem;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s ease;
            position: relative;
            background-color: rgba(241, 245, 249, 0.5);
        }

        .upload-option:hover {
            border-color: var(--primary-light);
            background: rgba(79, 70, 229, 0.03);
        }

        .upload-option.active {
            border-color: var(--success);
            background: rgba(16, 185, 129, 0.05);
        }

        .upload-icon {
            font-size: 2rem;
            color: var(--primary);
            margin-bottom: 0.75rem;
            opacity: 0.8;
        }

        .upload-text {
            font-size: 1rem;
            margin-bottom: 0.5rem;
            font-weight: 500;
            color: var(--dark);
        }

        .upload-subtext {
            color: var(--gray);
            font-size: 0.85rem;
        }

        #file-input {
            display: none;
        }

        .uploaded-files {
            border-top: 1px solid var(--gray-light);
            padding: 1rem 1.5rem;
        }

        .uploaded-files-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .uploaded-files-title {
            font-weight: 600;
            color: var(--darker);
        }

        .uploaded-files-count {
            background: var(--gray-lighter);
            color: var(--dark);
            padding: 0.2rem 0.6rem;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 600;
        }

        .uploaded-files-list {
            max-height: 300px;
            overflow-y: auto;
            padding-right: 0.5rem;
        }

        .uploaded-files-list::-webkit-scrollbar {
            width: 6px;
        }

        .uploaded-files-list::-webkit-scrollbar-track {
            background: var(--gray-lighter);
            border-radius: 3px;
        }

        .uploaded-files-list::-webkit-scrollbar-thumb {
            background: var(--gray-light);
            border-radius: 3px;
        }

        .uploaded-files-list::-webkit-scrollbar-thumb:hover {
            background: var(--gray);
        }

        .image-card {
            display: flex;
            align-items: center;
            padding: 0.8rem;
            border-radius: 8px;
            margin-bottom: 0.5rem;
            background: var(--gray-lighter);
            transition: all 0.2s ease;
        }

        .image-card:hover {
            background: var(--gray-light);
        }

        .image-card.selected {
            background: rgba(79, 70, 229, 0.1);
            border: 1px solid var(--primary-light);
        }

        .image-preview {
            width: 50px;
            height: 50px;
            object-fit: cover;
            border-radius: 4px;
            margin-right: 1rem;
        }

        .image-info {
            flex: 1;
            min-width: 0;
        }

        .image-name {
            font-size: 0.85rem;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 0.2rem;
            color: var(--dark);
        }

        .image-stats {
            display: flex;
            font-size: 0.75rem;
            color: var(--gray);
            gap: 0.8rem;
        }

        .image-size, .image-dimensions {
            display: flex;
            align-items: center;
            gap: 0.2rem;
        }

        .remove-btn {
            background: none;
            border: none;
            color: var(--danger);
            cursor: pointer;
            padding: 0.2rem;
            opacity: 0.7;
            transition: opacity 0.2s ease;
        }

        .remove-btn:hover {
            opacity: 1;
        }

        .preview-container {
            padding: 1.5rem;
            text-align: center;
            min-height: 300px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .empty-state {
    color: #888;
    text-align: center;
    padding: 2rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fafafa;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

        canvas {
            max-width: 100%;
            max-height: 400px;
            display: none;
            margin-bottom: 1rem;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }

        #previewImage {
            max-width: 100%;
            max-height: 400px;
            display: none;
            margin-bottom: 1rem;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            border-radius: 8px;
        }

        .loading {
            display: none;
            flex-direction: column;
            align-items: center;
            gap: 0.5rem;
        }

        .spinner {
            width: 40px;
            height: 40px;
            border: 4px solid var(--gray-light);
            border-top: 4px solid var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: 1rem;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .progress-bar {
            width: 100%;
            height: 6px;
            background: var(--gray-light);
            border-radius: 3px;
            overflow: hidden;
            margin-top: 0.5rem;
        }

        .progress {
            height: 100%;
            background: linear-gradient(90deg, var(--primary), var(--primary-light));
            width: 0%;
            transition: width 0.3s ease;
            border-radius: 3px;
        }

        .merge-options {
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--gray-light);
        }

        .merge-options h3 {
            font-size: 1rem;
            margin-bottom: 1rem;
            color: var(--darker);
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .merge-options h3 i {
            color: var(--primary);
        }

        .size-control {
            margin-bottom: 1.5rem;
        }

        .control-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 0.5rem;
        }

        .control-label {
            font-size: 0.85rem;
            color: var(--dark);
            display: flex;
            align-items: center;
            gap: 0.4rem;
        }

        .control-value {
            font-weight: 600;
            color: var(--primary);
            background: rgba(79, 70, 229, 0.1);
            padding: 0.2rem 0.6rem;
            border-radius: 20px;
            font-size: 0.8rem;
        }

        .slider-container {
            width: 100%;
        }

        .slider {
            width: 100%;
            height: 5px;
            -webkit-appearance: none;
            background: var(--gray-light);
            border-radius: 3px;
            outline: none;
            margin-top: 0.3rem;
        }

        .slider::-webkit-slider-thumb {
            -webkit-appearance: none;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--primary);
            cursor: pointer;
            transition: all 0.2s ease;
            border: 2px solid white;
            box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        }

        .slider::-webkit-slider-thumb:hover {
            transform: scale(1.1);
            box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
        }

        .spacing-control {
            margin-bottom: 1.5rem;
        }

        .format-control {
            margin-bottom: 1.5rem;
        }

        .format-control label {
            font-size: 0.85rem;
            margin-bottom: 0.5rem;
            color: var(--dark);
            display: block;
        }

        .format-control select {
            padding: 0.5rem;
            border: 1px solid var(--gray-light);
            border-radius: 6px;
            font-size: 0.85rem;
            width: 100%;
            max-width: 200px;
        }

        .format-control select:focus {
            outline: none;
            border-color: var(--primary-light);
            box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
        }

        .layout-control {
            margin-bottom: 1.5rem;
        }

        .layout-options {
            display: flex;
            flex-wrap: wrap;
            gap: 0.8rem;
            margin-top: 0.8rem;
        }

        .layout-option {
            width: 60px;
            height: 60px;
            border: 2px solid var(--gray-light);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 2px;
            padding: 4px;
            background: var(--gray-lighter);
        }

        .layout-option:hover {
            border-color: var(--primary-light);
        }

        .layout-option.selected {
            border-color: var(--primary);
            background: rgba(79, 70, 229, 0.05);
        }

        .layout-option .cell {
            background: var(--primary);
            opacity: 0.5;
            border-radius: 2px;
        }

        .layout-option.horizontal .cell {
            grid-row: span 2;
        }

        .layout-option.vertical .cell {
            grid-column: span 2;
        }

        .layout-option.grid-2x2 {
            grid-template-columns: 1fr 1fr;
            grid-template-rows: 1fr 1fr;
        }

        .layout-option.grid-3x3 {
            grid-template-columns: 1fr 1fr 1fr;
            grid-template-rows: 1fr 1fr 1fr;
        }

        .controls {
            display: flex;
            justify-content: space-between;
            gap: 0.8rem;
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--gray-light);
        }

        .results-container {
            background: white;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            overflow: hidden;
            border: 1px solid rgba(0, 0, 0, 0.03);
            margin-bottom: 2rem;
            display: none;
        }

        .results-header {
            padding: 1rem 1.5rem;
            border-bottom: 1px solid var(--gray-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .results-title {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            font-weight: 600;
            color: var(--darker);
        }

        .results-count {
            background: var(--gray-lighter);
            color: var(--dark);
            padding: 0.2rem 0.6rem;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 600;
        }

        .results-grid {
            padding: 1.5rem;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
            gap: 1.5rem;
        }

        .result-card {
            background: var(--gray-lighter);
            border-radius: 8px;
            overflow: hidden;
            position: relative;
            transition: transform 0.2s ease;
        }

        .result-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .result-image {
            width: 100%;
            height: 150px;
            object-fit: cover;
            display: block;
        }

        .result-info {
            padding: 0.8rem;
        }

        .result-name {
            font-size: 0.85rem;
            font-weight: 600;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 0.5rem;
            color: var(--dark);
        }

        .result-stats {
            display: flex;
            justify-content: space-between;
            font-size: 0.75rem;
            color: var(--gray);
        }

        .download-btn {
            position: absolute;
            top: 0.5rem;
            right: 0.5rem;
            background: var(--primary);
            color: white;
            border: none;
            width: 30px;
            height: 30px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            transition: all 0.2s ease;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        }

        .result-card:hover .download-btn {
            opacity: 1;
        }

        .download-btn:hover {
            background: var(--primary-light);
            transform: scale(1.1);
        }

        .results-footer {
            padding: 1rem 1.5rem;
            border-top: 1px solid var(--gray-light);
            display: flex;
            justify-content: flex-end;
            gap: 0.8rem;
        }

        .tool-description-container {
            background: white;
            border-radius: 12px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
            overflow: hidden;
            border: 1px solid rgba(0, 0, 0, 0.03);
            padding: 2rem;
            margin-bottom: 2rem;
        }

        .tool-header {
            text-align: center;
            margin-bottom: 2rem;
        }

        .tool-header i {
            font-size: 2.5rem;
            color: var(--primary);
            margin-bottom: 1rem;
            background: rgba(79, 70, 229, 0.1);
            width: 80px;
            height: 80px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
        }

        .tool-header h2 {
            font-size: 1.8rem;
            margin-bottom: 0.5rem;
            color: var(--darker);
        }

        .tool-header .subtitle {
            color: var(--gray);
            max-width: 700px;
            margin: 0 auto;
        }

        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 1.5rem;
            margin-bottom: 2rem;
        }

        .feature-item {
            background: var(--gray-lighter);
            border-radius: 8px;
            padding: 1.5rem;
            display: flex;
            gap: 1rem;
            align-items: flex-start;
            transition: transform 0.2s ease;
        }

        .feature-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
        }

        .feature-icon {
            background: var(--primary);
            color: white;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }

        .feature-content h3 {
            font-size: 1.1rem;
            margin-bottom: 0.5rem;
            color: var(--darker);
        }

        .feature-content p {
            font-size: 0.9rem;
            color: var(--gray);
            line-height: 1.5;
        }

        .cta-section {
            text-align: center;
            margin-top: 2rem;
        }

        .cta-button {
            background: var(--primary);
            color: white;
            border: none;
            padding: 0.8rem 1.5rem;
            border-radius: 6px;
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 0.5rem;
            box-shadow: 0 2px 10px rgba(79, 70, 229, 0.3);
        }

        .cta-button:hover {
            background: var(--primary-light);
            transform: translateY(-2px);
            box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
        }

        .toast-container {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            gap: 0.8rem;
        }

        .toast {
            background: var(--dark);
            color: white;
            padding: 1rem;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            display: flex;
            align-items: flex-start;
            gap: 0.8rem;
            transform: translateY(100px);
            opacity: 0;
            transition: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
            max-width: 350px;
            position: relative;
            overflow: hidden;
        }

        .toast::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
        }

        .toast.success::before {
            background: var(--success);
        }

        .toast.error::before {
            background: var(--danger);
        }

        .toast.warning::before {
            background: var(--warning);
        }

        .toast.info::before {
            background: var(--info);
        }

        .toast.show {
            transform: translateY(0);
            opacity: 1;
        }

        .toast i {
            font-size: 1.2rem;
            margin-top: 2px;
        }

        .toast.success i {
            color: var(--success);
        }

        .toast.error i {
            color: var(--danger);
        }

        .toast.warning i {
            color: var(--warning);
        }

        .toast.info i {
            color: var(--info);
        }

        .toast-content {
            flex: 1;
        }

        .toast-title {
            font-weight: 600;
            margin-bottom: 0.3rem;
            font-size: 0.95rem;
        }

        .toast-message {
            font-size: 0.85rem;
            opacity: 0.9;
            line-height: 1.4;
        }

        .toast-close {
            background: none;
            border: none;
            color: white;
            opacity: 0.7;
            cursor: pointer;
            transition: opacity 0.2s ease;
            padding: 0.2rem;
            display: flex;
            font-size: 0.9rem;
        }

        .toast-close:hover {
            opacity: 1;
        }

        .toast-progress {
            position: absolute;
            bottom: 0;
            left: 0;
            height: 3px;
            background: rgba(255, 255, 255, 0.2);
            width: 100%;
        }

        .toast-progress-bar {
            height: 100%;
            background: white;
            width: 100%;
            transition: width linear;
        }

        .background-control {
            margin-bottom: 1.5rem;
        }

        .background-options {
            display: flex;
            gap: 0.8rem;
            margin-top: 0.8rem;
        }

        .background-option {
            padding: 0.5rem 1rem;
            border: 1px solid var(--gray-light);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            font-size: 0.85rem;
        }

        .background-option:hover {
            border-color: var(--primary-light);
        }

        .background-option.selected {
            border-color: var(--primary);
            background: rgba(79, 70, 229, 0.05);
            color: var(--primary);
            font-weight: 500;
        }

        .background-color-picker {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-top: 0.5rem;
        }

        .background-color-picker input {
            width: 30px;
            height: 30px;
            border: 1px solid var(--gray-light);
            border-radius: 4px;
            cursor: pointer;
        }

        .merge-status {
            font-size: 0.85rem;
            color: var(--gray);
            margin-top: 0.5rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .merge-status i {
            color: var(--primary);
        }

        .blog-section {
            margin-top: 2rem;
            background: white;
            border-radius: 12px;
            padding: 2rem;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
        }

        .blog-section h2 {
            color: var(--darker);
            margin-bottom: 1rem;
            font-size: 1.5rem;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .blog-section h2 i {
            color: var(--primary);
        }

        .blog-section p {
            color: var(--gray);
            margin-bottom: 1rem;
            line-height: 1.6;
        }

        .blog-section ul {
            margin-bottom: 1.5rem;
            padding-left: 1.5rem;
            color: var(--gray);
        }

        .blog-section li {
            margin-bottom: 0.5rem;
        }
