:root {
    --primary-color: #6366f1;
    /* Indigo */
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    /* Emerald */
    --success-hover: #059669;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --font-family: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-link {
    display: block;
    transition: transform 0.2s;
}

.logo-link:hover {
    transform: scale(1.05);
}

.logo {
    height: 40px;
    width: auto;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3rem 1.5rem 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: #6366f1;
    /* Primary color */
    letter-spacing: -0.025em;
}

.hero-subtitle {
    color: var(--text-muted);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Main */
.app-main {
    max-width: 1200px;
    /* Increased max-width for split layout */
    width: 100%;
    margin: 1rem auto 2rem;
    /* Reduced top margin since Hero is there */
    padding: 0 1.5rem;
    flex: 1;
}

@media (min-width: 1024px) {
    .app-main {
        display: grid;
        grid-template-columns: 1fr 400px;
        gap: 2rem;
        align-items: stretch;
        grid-template-areas:
            "upload controls"
            "results results";
    }

    .upload-section {
        grid-area: upload;
        height: 100%;
        /* Fill height */
        margin-bottom: 0;
        display: flex;
        justify-content: center;
        flex-direction: column;
    }

    .controls-section {
        grid-area: controls;
        margin-bottom: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .results-section {
        grid-area: results;
    }
}

/* Upload Section */
.upload-section {
    background: var(--card-bg);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    /* Further reduced */
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.upload-section:hover,
.upload-section.drag-over {
    border-color: var(--primary-color);
    background-color: #eef2ff;
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    /* Reduced gap */
}

.upload-icon {
    color: var(--text-muted);
    transition: color 0.3s;
    width: 48px;
    /* Reduced size */
    height: 48px;
}

.upload-section:hover .upload-icon {
    color: var(--primary-color);
}

.upload-text {
    color: var(--text-muted);
    font-size: 1.125rem;
}

/* Controls */
.controls-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

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

.control-group:last-child {
    margin-bottom: 0;
}

.control-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-main);
}

/* Ratio & Size Buttons */
.ratio-options,
.size-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ratio-btn,
.size-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    font-family: var(--font-family);
    color: var(--text-muted);
}

.ratio-btn:hover,
.size-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.ratio-btn.active,
.size-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.custom-ratio-input,
.custom-size-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    animation: fadeIn 0.3s ease;
}

.custom-ratio-input input,
.custom-size-input input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    text-align: center;
}

.custom-ratio-input input:focus,
.custom-size-input input:focus {
    border-color: var(--primary-color);
}

/* Radio Custom */
.mode-options {
    display: flex;
    gap: 1.5rem;
}

.radio-label {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.radio-label input {
    display: none;
}

.radio-custom {
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-muted);
    transition: color 0.2s;
}

.radio-custom::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    transition: all 0.2s;
}

.radio-custom::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    transition: transform 0.2s;
}

.radio-label input:checked+.radio-custom {
    color: var(--text-main);
    font-weight: 500;
}

.radio-label input:checked+.radio-custom::before {
    border-color: var(--primary-color);
}

.radio-label input:checked+.radio-custom::after {
    transform: translateY(-50%) scale(1);
}

/* Color Picker */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid var(--border-color);
    border-radius: 50%;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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

.btn-success {
    background: var(--success-color);
    color: white;
    width: 100%;
}

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.4);
}

.btn-success:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Results Section */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.results-actions {
    display: flex;
    gap: 0.75rem;
}

/* Specific button overrides for header to prevent full width */
.results-actions .btn {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.image-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-item {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.3s ease;
}

.thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.item-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.progress-container {
    height: 6px;
    background: var(--bg-color);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

.download-link {
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    opacity: 0.5;
    pointer-events: none;
}

.download-link.ready {
    color: var(--primary-color);
    opacity: 1;
    pointer-events: auto;
    background: #eef2ff;
}

.download-link:hover {
    background: var(--primary-color);
    color: white;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .app-header {
        padding: 1rem;
    }

    .mode-options {
        flex-direction: column;
        gap: 0.75rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}