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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --border: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --checkerboard-dark: #2d3748;
    --checkerboard-size: 20px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--background) 0%, #1a2332 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 1rem;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--surface-light);
    transform: translateY(-2px);
}

.upload-area.dragging {
    border-color: var(--primary-color);
    background: var(--surface-light);
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--primary-color);
}

.upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.processing-section {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--surface);
    border-radius: 1rem;
}

.loading-spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    border: 4px solid var(--surface-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.result-section {
    background: var(--surface);
    border-radius: 1rem;
    padding: 2rem;
}

.image-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.image-panel h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.image-container {
    background: var(--surface-light);
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    overflow: hidden;
}

.image-container.checkerboard {
    background-image: 
        linear-gradient(45deg, var(--checkerboard-dark) 25%, transparent 25%),
        linear-gradient(-45deg, var(--checkerboard-dark) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--checkerboard-dark) 75%),
        linear-gradient(-45deg, transparent 75%, var(--checkerboard-dark) 75%);
    background-size: var(--checkerboard-size) var(--checkerboard-size);
    background-position: 0 0, 0 calc(var(--checkerboard-size) / 2), calc(var(--checkerboard-size) / 2) calc(var(--checkerboard-size) / -2), calc(var(--checkerboard-size) / -2) 0px;
}

.image-container canvas {
    max-width: 100%;
    max-height: 500px;
    height: auto;
    border-radius: 0.25rem;
}

.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.error-section {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--surface);
    border-radius: 1rem;
}

.error-message {
    margin-bottom: 2rem;
}

.error-message svg {
    width: 64px;
    height: 64px;
    color: var(--error);
    margin-bottom: 1rem;
}

.error-message p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
}

.feature svg {
    width: 32px;
    height: 32px;
    color: var(--primary-color);
}

.feature span {
    font-weight: 600;
    font-size: 0.9rem;
}

.footer-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .container {
        padding: 1rem 0.75rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .result-section {
        padding: 1rem;
    }

    .image-comparison {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .features {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.75rem;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
    }

    .upload-text {
        font-size: 1rem;
    }

    .features {
        grid-template-columns: 1fr;
    }
}
