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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #ec4899;
    --accent: #06b6d4;
    --bg-dark: #0f0f23;
    --bg-card: rgba(255, 255, 255, 0.05);
    --text: #ffffff;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --success: #22c55e;
    --error: #ef4444;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-dark);
    min-height: 100vh;
    color: var(--text);
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 0;
    animation: fadeInDown 0.8s ease;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

header h1 svg {
    width: 2.5rem;
    height: 2.5rem;
    stroke: var(--primary);
}

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

/* Main */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Upload Section */
.upload-section {
    animation: fadeInUp 0.8s ease 0.2s both;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 20px;
    padding: 4rem 2rem;
    text-align: center;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.01);
}

.drop-zone.drag-over {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 2s infinite;
}

.upload-icon svg {
    width: 4rem;
    height: 4rem;
    stroke: var(--primary);
}

.drop-zone h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.drop-zone p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.upload-btn {
    display: inline-block;
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 1rem 0;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.upload-btn svg {
    width: 1.2rem;
    height: 1.2rem;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.3rem;
}

.paste-hint {
    font-size: 0.9rem;
    color: var(--accent) !important;
    margin-top: 1rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.paste-hint svg {
    width: 1rem;
    height: 1rem;
}

.formats {
    font-size: 0.85rem;
    opacity: 0.6;
}

/* Settings Section */
.settings-section {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--border);
    animation: fadeInUp 0.6s ease;
}

.settings-section h3 {
    margin-bottom: 1.5rem;
    font-weight: 500;
}

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

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-item label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.setting-item span {
    text-align: center;
    font-weight: 600;
    color: var(--primary);
}

.process-btn {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 15px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.process-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.4);
}

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

/* Adjustment Section */
.adjustment-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.adjustment-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
    color: var(--text-muted);
}

.adjustment-section h4 svg {
    width: 1.2rem;
    height: 1.2rem;
}

.adjustment-item {
    margin-bottom: 1.5rem;
}

.adjustment-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.adjustment-item label svg {
    width: 1rem;
    height: 1rem;
}

.adjustment-item input[type="range"] {
    width: calc(100% - 50px);
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    display: inline-block;
    vertical-align: middle;
}

.adjustment-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.adjustment-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.adjustment-item span {
    display: inline-block;
    width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--primary);
    vertical-align: middle;
    margin-left: 10px;
}

/* Toggle Switch */
.adjustment-toggle {
    margin-bottom: 1.5rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    user-select: none;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    width: 50px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    position: relative;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-label input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.toggle-label input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.toggle-label span svg {
    width: 1.1rem;
    height: 1.1rem;
}

.smooth-option {
    padding-left: 66px;
    transition: all 0.3s ease;
}

.smooth-option.hidden {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.smooth-option:not(.hidden) {
    opacity: 1;
    max-height: 100px;
}

.reprocess-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.reprocess-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
}

.reprocess-btn svg {
    width: 1.1rem;
    height: 1.1rem;
}

/* Preview Section */
.preview-section {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--border);
    animation: fadeInUp 0.6s ease;
}

.preview-section h3 {
    margin-bottom: 1.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.preview-section h3 svg {
    width: 1.3rem;
    height: 1.3rem;
}

.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.preview-box {
    flex: 1;
    min-width: 280px;
    max-width: 450px;
    text-align: center;
}

.preview-box h4 {
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

.image-wrapper {
    background: #1a1a2e;
    border-radius: 15px;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    overflow: hidden;
}

.image-wrapper.checkered {
    background-image: 
        linear-gradient(45deg, #2a2a3e 25%, transparent 25%),
        linear-gradient(-45deg, #2a2a3e 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2a3e 75%),
        linear-gradient(-45deg, transparent 75%, #2a2a3e 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #1a1a2e;
}

.image-wrapper canvas {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
}

.image-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.arrow {
    font-size: 2rem;
    color: var(--primary);
    animation: pulse 1.5s infinite;
}

.arrow svg {
    width: 2rem;
    height: 2rem;
}

.detected-color {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

.detected-color span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detected-color svg {
    width: 1.1rem;
    height: 1.1rem;
}

/* AI Badge */
.ai-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    margin-bottom: 2rem;
    color: var(--accent);
    font-size: 0.95rem;
}

.ai-badge svg {
    width: 1.3rem;
    height: 1.3rem;
    stroke: var(--secondary);
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid var(--border);
}

#colorValue {
    font-family: monospace;
    font-size: 1rem;
    color: var(--accent);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
}

.action-btn svg {
    width: 1.2rem;
    height: 1.2rem;
}

.download-btn {
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.4);
}

.copy-btn {
    background: linear-gradient(135deg, var(--accent), #0891b2);
    color: white;
}

.copy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(6, 182, 212, 0.4);
}

.reset-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border);
}

.reset-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 35, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loader p {
    font-size: 1.1rem;
    color: var(--text-muted);
    text-align: center;
    max-width: 300px;
}

.loader .progress-info {
    font-size: 0.9rem;
    color: var(--accent);
    margin-top: -0.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 2rem;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-weight: 500;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.2);
}

.toast.error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.2);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer p {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

footer svg {
    width: 1rem;
    height: 1rem;
}

footer .heart-icon {
    stroke: var(--secondary);
    fill: var(--secondary);
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .preview-container {
        flex-direction: column;
    }

    .arrow {
        transform: rotate(90deg);
    }

    .action-buttons {
        flex-direction: column;
    }

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

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

    .subtitle {
        font-size: 0.95rem;
    }

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