:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #212529;
    --border-color: #dee2e6;
    --success-color: #28a745;
    --error-color: #dc3545;

    --font-family-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 0.5rem;
    --shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

body {
    font-family: var(--font-family-sans-serif);
    line-height: 1.6;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

header {
    background-color: var(--surface-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 2rem 0;
    text-align: center;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
}

header p {
    margin-top: 0.5rem;
    font-size: 1.1rem;
    color: var(--secondary-color);
}

main {
    flex: 1;
    padding: 2rem 0;
}

section {
    padding: 3rem 0;
}

.section-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 3rem;
}

.image-compressor-section {
    background-color: var(--surface-color);
    padding: 3rem 0;
}

.upload-zone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background-color: var(--background-color);
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

.upload-zone:hover, .upload-zone.dragover {
    background-color: #e9ecef;
    border-color: var(--primary-color);
}

.upload-zone p {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    font-weight: 500;
}

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

.image-queue {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.image-card {
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease-in-out;
    position: relative;
}

.remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 14px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
}

.image-card:hover {
    transform: translateY(-5px);
}

.image-card figure {
    margin: 0;
    padding: 0;
    position: relative;
    height: 160px;
    background-color: var(--background-color);
}

.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: none;
}

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

.image-card.compressing .spinner {
    display: block;
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-card figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.6) 50%, transparent 100%);
    color: white;
    font-size: 0.9rem;
    padding: 1.5rem 0.75rem 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-card .card-meta, .image-card .card-results {
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
}

.image-card .status {
    font-weight: 500;
}

.image-card .card-results {
    background-color: #e9f5e9;
}

.image-card .download-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}

.image-card .reduction {
    color: var(--success-color);
    font-weight: bold;
}

.image-card.error .status {
    color: var(--error-color);
}

.image-card .card-controls {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
}

#batch-controls {
    text-align: center;
    margin-top: 2rem;
}

#downloadAllBtn, #clearAllBtn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin: 0 0.5rem;
}

#clearAllBtn {
    background-color: var(--secondary-color);
}

.features-section {
    background-color: var(--background-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    text-align: center;
}

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

.feature-item h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.how-it-works-section {
    background-color: var(--surface-color);
}

.steps-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.step {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.step-number {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-content h3 {
    font-size: 1.2rem;
    margin: 0 0 0.5rem 0;
}

.faq-section {
    background-color: var(--background-color);
}

.faq-container {
    max-width: 700px;
    margin: 0 auto;
}

.faq-item {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    padding: 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-icon {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--primary-color);
    transition: transform 0.2s ease-in-out;
}

.faq-answer {
    padding: 0 1.5rem;
    color: var(--secondary-color);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.faq-answer p {
    margin: 0;
    padding-bottom: 1.5rem;
}

.faq-item.active .faq-answer {
    max-height: 200px; /* Adjust as needed */
}

.faq-item.active .faq-icon {
    transform: rotate(45deg);
}

footer {
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

@media (min-width: 768px) {
    .steps-container {
        flex-direction: row;
        justify-content: space-between;
    }
    .step {
        flex-direction: column;
        text-align: center;
        align-items: center;
        max-width: 250px;
    }
}