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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding: 20px;
    position: relative;
}

.header-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 10px;
}

.keyboard-hint {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 10px;
}

.keyboard-hint kbd {
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

main {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* Upload Section */
.upload-section {
    margin-bottom: 30px;
}

.drop-zone {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9ff;
}

.drop-zone:hover,
.drop-zone.drag-over {
    background: #e8ecff;
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-icon {
    width: 80px;
    height: 80px;
    color: #667eea;
    margin-bottom: 20px;
}

.drop-zone h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.drop-zone p {
    color: #666;
    margin-bottom: 5px;
}

.hint {
    font-size: 0.9rem;
    color: #999;
    margin-top: 15px;
}

/* Browse/Paste Button */
.paste-button-container {
    text-align: center;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.btn-paste {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.btn-paste:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
}

.btn-paste svg {
    flex-shrink: 0;
}

.paste-btn-text {
    font-weight: 600;
}

.paste-hint {
    color: #666;
    font-size: 0.9rem;
}

.paste-hint span {
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    color: #667eea;
}

/* Quality Control */
.quality-control {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
}

/* Options Section */
.options-section {
    margin-top: 20px;
    padding: 20px;
    background: #f8f9ff;
    border-radius: 10px;
}

.options-section > h3 {
    color: #667eea;
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.option-group {
    margin-bottom: 25px;
}

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

.option-group h4 {
    color: #333;
    font-size: 1rem;
    margin-bottom: 12px;
    font-weight: 600;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: rgba(102, 126, 234, 0.1);
}

.checkbox-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.checkbox-label span {
    color: #333;
    font-size: 0.95rem;
}

/* Preset Buttons */
.presets-section {
    margin-bottom: 25px;
    padding-bottom: 25px;
    border-bottom: 2px solid #e0e0e0;
}

.presets-section h4 {
    color: #333;
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.btn-preset {
    background: white;
    border: 2px solid #667eea;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
}

.btn-preset:hover {
    background: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-preset:hover .preset-name,
.btn-preset:hover .preset-desc {
    color: white;
}

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

.preset-name {
    font-weight: 600;
    color: #667eea;
    font-size: 1rem;
}

.preset-desc {
    font-size: 0.8rem;
    color: #666;
}

/* Stats Summary */
.stats-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    text-align: center;
}

.stat-card {
    padding: 10px;
}

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.stat-card-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.quality-control label {
    display: block;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

#qualitySlider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

#qualitySlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
}

#qualitySlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.quality-hint {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #666;
}

/* Preview Section */
.preview-section {
    margin-bottom: 30px;
}

.preview-section h3 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.preview-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.preview-item .remove-btn:hover {
    background: rgba(255, 0, 0, 1);
}

.preview-item .file-info {
    padding: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.8rem;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-success {
    background: #10b981;
    color: white;
    font-size: 1.2rem;
    padding: 15px 40px;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Progress Section */
.progress-section {
    text-align: center;
    padding: 40px 20px;
}

.progress-section h3 {
    color: #667eea;
    margin-bottom: 30px;
    font-size: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: #667eea;
}

/* Results Section */
.results-section {
    text-align: center;
    padding: 20px;
}

.results-section h3 {
    color: #10b981;
    margin-bottom: 30px;
    font-size: 2rem;
}

.stats {
    background: #f8f9ff;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 30px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: 600;
    color: #666;
}

.stat-value {
    color: #667eea;
    font-weight: 600;
}

/* Individual Images List */
.images-list-section {
    margin: 30px 0;
}

.images-list-section h4 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.3rem;
    text-align: left;
}

.images-list {
    background: #f8f9ff;
    border-radius: 10px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.image-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.image-item:last-child {
    margin-bottom: 0;
}

.image-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    gap: 10px;
}

.image-name {
    font-weight: 600;
    color: #333;
    word-break: break-word;
    flex: 1;
}

.btn-download-single {
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-download-single:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.btn-download-single svg {
    display: block;
}

.image-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    font-size: 0.9rem;
}

.image-stat {
    display: flex;
    flex-direction: column;
}

.image-stat-label {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 3px;
}

.image-stat-value {
    color: #667eea;
    font-weight: 600;
}

.image-stat-value.saved {
    color: #10b981;
}

.download-section {
    margin: 30px 0;
}

.expiration-notice {
    margin-top: 15px;
    color: #f59e0b;
    font-size: 0.9rem;
}

/* Error Section */
.error-section {
    text-align: center;
    padding: 40px 20px;
}

.error-message {
    background: #fee2e2;
    color: #dc2626;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid #dc2626;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    padding: 20px;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    main {
        padding: 20px;
    }

    .drop-zone {
        padding: 40px 15px;
    }

    .upload-icon {
        width: 60px;
        height: 60px;
    }

    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }

    .preview-item img {
        height: 100px;
    }

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

    .btn {
        width: 100%;
    }

    .stat-item {
        flex-direction: column;
        text-align: center;
        gap: 5px;
    }

    .images-list-section h4 {
        text-align: center;
    }

    .image-stats {
        grid-template-columns: 1fr;
    }

    .images-list {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    main {
        padding: 15px;
    }

    .image-item {
        padding: 10px;
    }

    .image-name {
        font-size: 0.9rem;
    }

    .image-stats {
        font-size: 0.85rem;
    }
}

/* Dark Mode */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode main {
    background: #0f3460;
    color: #e0e0e0;
}

body.dark-mode .drop-zone {
    background: #16213e;
    border-color: #667eea;
    color: #e0e0e0;
}

body.dark-mode .drop-zone:hover,
body.dark-mode .drop-zone.drag-over {
    background: #1a1a2e;
}

body.dark-mode .quality-control,
body.dark-mode .options-section,
body.dark-mode .stats,
body.dark-mode .images-list {
    background: #16213e;
    color: #e0e0e0;
}

body.dark-mode .option-group h4,
body.dark-mode .checkbox-label span,
body.dark-mode .stat-label,
body.dark-mode .image-name {
    color: #e0e0e0;
}

body.dark-mode .btn-preset {
    background: #16213e;
    border-color: #667eea;
}

body.dark-mode .btn-preset:hover {
    background: #667eea;
}

body.dark-mode .image-item {
    background: #1a1a2e;
}

body.dark-mode .stat-item {
    border-bottom-color: #2a2a3e;
}

body.dark-mode .paste-hint {
    color: #aaa;
}

body.dark-mode footer {
    color: rgba(255, 255, 255, 0.8);
}

/* ===== LIGHTBOX ===== */
.lightbox {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    animation: lightboxZoom 0.3s ease;
}

@keyframes lightboxZoom {
    from { transform: scale(0.8); }
    to { transform: scale(1); }
}

.lightbox-image {
    max-width: 100%;
    max-height: 85vh;
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
    transition: transform 0.2s ease;
}

.lightbox-close:hover {
    transform: scale(1.2);
}

.lightbox-caption {
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 0 0 8px 8px;
}

/* ===== OFFCANVAS MENU ===== */
.offcanvas-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.offcanvas-overlay.active {
    opacity: 1;
    visibility: visible;
}

.offcanvas {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100%;
    background: white;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.offcanvas.active {
    right: 0;
}

.offcanvas-header {
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.offcanvas-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.offcanvas-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
    transition: color 0.2s ease;
}

.offcanvas-close:hover {
    color: #333;
}

.offcanvas-body {
    padding: 20px;
}

.preset-btn-offcanvas {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
}

.preset-btn-offcanvas:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.preset-btn-offcanvas .preset-icon {
    font-size: 24px;
}

.preset-btn-offcanvas .preset-info {
    flex: 1;
}

.preset-btn-offcanvas .preset-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 5px;
    color: #ffffff;
}

.preset-btn-offcanvas .preset-desc {
    font-size: 12px;
    opacity: 0.95;
    color: #f0f0f0;
}

body.dark-mode .offcanvas {
    background: #0f3460;
}

body.dark-mode .offcanvas-header {
    border-bottom-color: #2a2a3e;
}

body.dark-mode .offcanvas-header h3 {
    color: #e0e0e0;
}

body.dark-mode .offcanvas-close {
    color: #aaa;
}

body.dark-mode .offcanvas-close:hover {
    color: #fff;
}

/* ===== PASTE LOADER ===== */
.paste-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.paste-loader-content {
    text-align: center;
    color: white;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.paste-loader-content p {
    font-size: 18px;
    margin: 0;
}

/* ===== IMAGE PREVIEW IN RESULTS ===== */
.image-item {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.image-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.image-preview {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: #f5f5f5;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-preview:hover img {
    transform: scale(1.1);
}

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-preview:hover .preview-overlay {
    opacity: 1;
}

.image-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.custom-resize-control {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.custom-resize-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.custom-resize-control input[type="range"] {
    width: 100%;
}

body.dark-mode .custom-resize-control {
    background: #1a1a2e;
    border-left-color: #764ba2;
}

body.dark-mode .custom-resize-control label {
    color: #e0e0e0;
}

body.dark-mode .image-item {
    background: #1a1a2e;
}

body.dark-mode .image-preview {
    background: #0f3460;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .offcanvas {
        width: 100%;
        right: -100%;
    }

    .image-item {
        flex-direction: column;
    }

    .image-preview {
        width: 100%;
        height: 200px;
    }

    .lightbox-content {
        max-width: 95%;
        max-height: 95%;
    }
}
