/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-accent: #3b82f6;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.site-header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.tagline {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    margin-top: 0.25rem;
}

/* Main */
main {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

/* Hero */
.hero {
    margin-bottom: 2.5rem;
}

.description {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    max-width: 480px;
    margin: 0 auto 2rem;
    line-height: 1.5;
    padding: 1rem 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    box-shadow: var(--shadow);
}

/* Comparison Slider */
.comparison-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
    background: #f1f5f9;
    aspect-ratio: auto;
}

#demo-comparison {
    max-width: 420px;
}

.comparison-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.comparison-container .img-before {
    position: relative;
    z-index: 1;
}

.comparison-container .img-after {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    clip-path: inset(0 0 0 50%);
}

.slider-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: white;
    z-index: 10;
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
    pointer-events: none;
    transform: translateX(-50%);
}

.slider-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 11;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: transform 0.15s ease;
}

.comparison-container:active .slider-handle {
    transform: translate(-50%, -50%) scale(1.1);
}

.label {
    position: absolute;
    top: 12px;
    z-index: 5;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    pointer-events: none;
}

.label-before {
    left: 12px;
}

.label-after {
    right: 12px;
}

/* Upload Section */
.upload-section {
    margin-bottom: 3rem;
}

.drop-zone {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--color-surface);
}

.drop-zone:hover {
    border-color: var(--color-primary);
    background: #eff6ff;
}

.drop-zone.drag-over {
    border-color: var(--color-primary);
    background: #dbeafe;
    transform: scale(1.01);
    box-shadow: var(--shadow-lg);
}

.drop-icon {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    transition: color 0.2s;
}

.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
    color: var(--color-primary);
}

.drop-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.drop-hint {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.feature {
    text-align: center;
    padding: 1.5rem 1rem;
}

.feature-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
}

.feature h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.feature p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* Actions */
.actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Controls Panel */
.controls-panel {
    margin-top: 1.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.controls-header:hover {
    background: #f8fafc;
}

.controls-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.controls-header .chevron {
    transition: transform 0.25s ease;
    color: var(--color-text-muted);
}

.controls-panel.open .controls-header .chevron {
    transform: rotate(180deg);
}

.controls-body {
    display: none;
    padding: 0 1.25rem 1.25rem;
}

.pass-section {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem 1rem 0;
    margin-bottom: 1rem;
    background: #fafbfc;
}

.pass-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.two-pass-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.controls-panel.open .controls-body {
    display: block;
}

.control-group {
    margin-bottom: 1.25rem;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.control-label span:first-child {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
}

.control-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 40px;
    text-align: center;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-row input[type="range"] {
    flex: 1;
}

.auto-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.auto-toggle input[type="checkbox"] {
    accent-color: var(--color-primary);
    cursor: pointer;
}

.control-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 0.3rem;
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    outline: none;
    transition: opacity 0.2s;
}

input[type="range"]:disabled {
    opacity: 0.35;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.15s;
}

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

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

input[type="range"]:disabled::-webkit-slider-thumb {
    background: #94a3b8;
    cursor: default;
}

input[type="range"]:disabled::-moz-range-thumb {
    background: #94a3b8;
    cursor: default;
}

.btn-accent {
    background: #059669;
    color: white;
    width: 100%;
    justify-content: center;
    box-shadow: var(--shadow);
}

.btn-accent:hover {
    background: #047857;
    box-shadow: var(--shadow-lg);
}

.btn-accent:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

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

/* Processing Overlay */
#processing {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.processing-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.processing-content p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
}

.processing-hint {
    font-size: 0.875rem !important;
    font-weight: 400 !important;
    color: var(--color-text-muted) !important;
    margin-top: 0.5rem;
}

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

/* Responsive */
@media (max-width: 640px) {
    .site-header {
        padding: 1.5rem 1rem 1rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

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

    .feature {
        padding: 1rem;
    }

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

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        justify-content: center;
    }
}
