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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    color: #fff;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
}

header p {
    opacity: 0.7;
    font-size: 1.1rem;
}

main {
    width: 100%;
    background: #111;
    border: 1px solid #333;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.upload-area {
    padding: 3rem 2rem;
    border: 2px dashed #444;
    margin: 2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.upload-area:hover {
    border-color: #fff;
    background: #222;
}

.upload-area.dragover {
    border-color: #fff;
    background: #333;
    transform: scale(1.02);
}

.upload-content h3 {
    font-size: 1.3rem;
    margin: 1rem 0 0.5rem;
    color: #fff;
}

.upload-content p {
    color: #999;
    font-size: 0.9rem;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: #fff;
    margin: 0 auto;
}

.controls {
    padding: 2rem;
    border-top: 1px solid #333;
}

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

.control-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

select, input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background: #222;
    color: #fff;
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: #fff;
}

input[type="range"] {
    width: calc(100% - 60px);
    margin-right: 10px;
    accent-color: #fff;
}

#qualityValue {
    font-weight: 600;
    color: #fff;
    min-width: 50px;
}

.size-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.size-inputs input {
    flex: 1;
}

.size-inputs span {
    color: #fff;
    font-weight: bold;
}

.convert-btn {
    width: 100%;
    padding: 1rem;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
}

.convert-btn:hover {
    background: #ccc;
    transform: translateY(-2px);
}

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

.result {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid #333;
}

.result-content h3 {
    color: #fff;
    margin: 1rem 0 0.5rem;
}

.result-content p {
    color: #999;
    margin-bottom: 1.5rem;
}

.success-icon {
    width: 48px;
    height: 48px;
    color: #fff;
    margin: 0 auto;
}

.download-btn, .reset-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    margin: 0.5rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.download-btn {
    background: #fff;
    color: #000;
    border: none;
}

.reset-btn {
    background: #222;
    color: #fff;
    border: 2px solid #444;
}

.download-btn:hover, .reset-btn:hover {
    transform: translateY(-2px);
}

.loading {
    padding: 3rem 2rem;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #999;
    font-size: 1.1rem;
}

.result-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.result-buttons button {
    flex: 1;
    min-width: 140px;
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .upload-area, .controls, .result {
        padding: 1.5rem;
    }
    
    .size-inputs {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .size-inputs span {
        order: -1;
    }
    
    .resize-inputs {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.image-preview-area {
    margin: 2rem;
    text-align: center;
}

.image-container {
    position: relative;
    display: inline-block;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #333;
}

.image-preview {
    max-width: 100%;
    max-height: 300px;
    display: block;
    transition: opacity 0.3s ease;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.image-container:hover .image-preview {
    opacity: 0.7;
}

.image-overlay p {
    color: #fff;
    font-weight: 600;
    margin: 0;
    padding: 1rem;
    text-align: center;
}

.image-info {
    background: #222;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: left;
    border: 1px solid #333;
}

.image-info p {
    color: #999;
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.preview-section {
    margin: 1.5rem 0;
}

.before-after {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.preview-item {
    background: #222;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #333;
}

.preview-item h5 {
    color: #fff;
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-info {
    color: #999;
    font-size: 0.85rem;
    line-height: 1.4;
}

.conversion-result {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: #222;
    border: 1px solid #333;
    border-radius: 8px;
}

.result-stats h4 {
    color: #fff;
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    text-align: center;
}

.result-stats p {
    color: #999;
    margin: 0 0 1.5rem 0;
    white-space: pre-line;
    line-height: 1.5;
}

.secondary-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: #333;
    color: #fff;
    border: 2px solid #555;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: #444;
    transform: translateY(-2px);
}

.resize-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.dimension-input label {
    display: block;
    color: #fff;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-with-unit {
    display: flex;
    gap: 0.5rem;
}

.input-with-unit input {
    flex: 3;
    padding: 0.75rem;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 1rem;
    background: #222;
    color: #fff;
    transition: border-color 0.3s ease;
    min-width: 120px;
}

.input-with-unit input:focus {
    outline: none;
    border-color: #fff;
}

.input-with-unit select {
    flex: 1;
    min-width: 50px;
    max-width: 65px;
    padding: 0.75rem 0.5rem;
    border: 2px solid #444;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #222;
    color: #fff;
    transition: border-color 0.3s ease;
}

.input-with-unit select:focus {
    outline: none;
    border-color: #fff;
}

.resolution-preview {
    background: #333;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #444;
    margin-top: 0.5rem;
}

.resolution-preview p {
    margin: 0;
    color: #ccc;
    font-size: 0.9rem;
    text-align: center;
}