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

html,
body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(93, 72, 199, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(45, 180, 120, 0.1) 0%, transparent 40%);
}

main {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

main section {
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    gap: var(--space-xl);
    padding: var(--space-lg);
    background: var(--bg-panel);
    backdrop-filter: var(--backdrop-blur);
    border: var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

/* --- Left Column (Image Area) --- */
main section .left {
    flex: 1;
    /* Takes available space */
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    height: 100%;
}

main section .top {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-lg);
    width: fit-content;
}

/* Button & Controls Styling */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    outline: none;
    border-radius: var(--radius-md);
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
    border: 1px solid transparent;
}

.btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

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

label.btn {
    display: inline-block;
}

#reset-btn:hover {
    background-color: rgba(255, 59, 48, 0.2);
    /* Danger color low opacity */
    color: #ff5b5b;
    border-color: #ff5b5b;
}

#download-btn {
    background-color: var(--primary-color);
    color: var(--text-on-accent);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

#download-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5);
}

/* Image Canvas Area */
main section .bottom {
    flex: 1;
    background-color: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    transition: var(--transition-base);
}

main section .bottom.drag-active {
    border-color: var(--primary-color);
    background-color: rgba(124, 58, 237, 0.1);
}

main section .bottom .placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    color: var(--text-secondary);
    gap: var(--space-md);
    pointer-events: none;
}

main section .bottom .placeholder i {
    font-size: 4rem;
    opacity: 0.5;
}

#record-btn.recording-active {
    background-color: var(--bg-danger-color);
    color: white;
    box-shadow: 0 0 10px red;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 1;
    }

    to {
        opacity: 0.7;
    }
}

canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- Right Column (Controls) --- */
main section .right {
    width: 350px;
    /* Fixed width for controls */
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.03);
    /* Subtle internal panel */
    border-radius: var(--radius-lg);
    border: var(--border-light);
    overflow-y: auto;
}

h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.5px;
}

/* Filter Sliders */
.filters {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.filter {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-info {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

/* New Range Slider Styling */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    /* Fix lint error */
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    margin-top: -6px;
    /* align center */
    box-shadow: 0 0 10px rgba(124, 58, 237, 0.5);
    transition: transform 0.1s ease;
}

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

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Presets Grid */
.presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: var(--space-sm);
}

.preset-btn {
    padding: var(--space-xs);
    font-size: var(--text-xs);
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    transition: var(--transition-base);
}

.preset-btn:hover {
    background-color: var(--bg-active-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Scrollbar styling for controls */
main section .right::-webkit-scrollbar {
    width: 6px;
}

main section .right::-webkit-scrollbar-track {
    background: transparent;
}

main section .right::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

main section .right::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    main section {
        width: 98%;
        gap: var(--space-md);
        padding: var(--space-md);
    }

    main section .right {
        width: 300px;
        /* Slightly narrower controls on tablet */
    }
}

@media (max-width: 900px) {

    html,
    body {
        overflow: auto;
        /* Allow scrolling on mobile */
        height: auto;
        min-height: 100%;
    }

    main {
        height: auto;
        padding: var(--space-sm);
        display: block;
        /* Remove centering flex */
    }

    main section {
        flex-direction: column;
        height: auto;
        max-width: 100%;
        overflow: visible;
        margin: var(--space-md) auto;
    }

    main section .left {
        width: 100%;
        height: auto;
        min-height: auto;
    }

    /* Make the canvas area responsive but not too tall on mobile */
    main section .bottom {
        width: 100%;
        height: auto;
        /* Let content dictate height */
        min-height: 300px;
        max-height: 60vh;
        aspect-ratio: auto;
    }

    canvas {
        max-height: 60vh;
    }

    main section .right {
        width: 100%;
        max-width: none;
        height: auto;
        overflow: visible;
        /* Show all controls */
    }

    /* Improve button layout on mobile */
    main section .top {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .btn {
        flex: 1;
        /* Buttons share space */
        text-align: center;
        white-space: nowrap;
    }

    /* Make sliders easier to touch */
    input[type=range]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
        margin-top: -8px;
    }

    /* Grid for presets on mobile - ensure they stay clickable */
    .presets {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

@media (max-width: 480px) {
    :root {
        --space-lg: 1rem;
        --space-xl: 1.5rem;
    }

    main section {
        padding: var(--space-sm);
        border-radius: var(--radius-lg);
    }

    main section .top {
        gap: var(--space-sm);
    }

    .btn {
        padding: 0.5rem 0.8rem;
        font-size: var(--text-xs);
    }
}

/* Resize & Quality Controls */
.resize-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.resize-inputs {
    display: flex;
    gap: var(--space-sm);
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.input-group input[type="number"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: var(--text-primary);
    font-size: var(--text-sm);
    outline: none;
    transition: var(--transition-base);
}

.input-group input[type="number"]:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: 4px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    accent-color: var(--primary-color);
    cursor: pointer;
    width: 16px;
    height: 16px;
}