* {
    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: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.3s ease;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo {
    width: 48px;
    height: 48px;
    display: block;
}

header h1 {
    font-size: 2.5em;
    color: #667eea;
    margin: 0;
    display: inline-block;
}

header h1 a {
    text-decoration: none;
    color: inherit;
}

header h1 a:hover {
    opacity: 0.8;
}

header h2 {
    font-size: 1.5em;
    color: #666;
    margin-top: 10px;
}

.tool-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.nav-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: #f5f7ff;
    color: #5568d3;
}

.nav-link.active {
    background: #667eea;
    color: white;
}

.subtitle {
    color: #888;
    font-size: 1.1em;
}

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.tool-card {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 30px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    text-align: center;
}

.tool-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.tool-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.tool-card h2 {
    color: #333;
    margin-bottom: 10px;
}

.tool-card p {
    color: #666;
    font-size: 0.9em;
}

.upload-section {
    margin-bottom: 30px;
}

.file-input-wrapper {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s ease;
    background: #fafafa;
    margin-bottom: 20px;
}

.file-input-wrapper:hover {
    border-color: #667eea;
    background: #f5f7ff;
}

.file-input-wrapper.drag-over {
    border-color: #667eea;
    background: #eef2ff;
}

#fileInput {
    display: none;
}

.file-label {
    cursor: pointer;
    display: block;
}

.file-label-text {
    display: block;
    font-size: 1.1em;
    color: #667eea;
    font-weight: 500;
    margin-bottom: 5px;
}

.file-label-hint {
    display: block;
    font-size: 0.9em;
    color: #888;
}

.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.preview-item {
    position: relative;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.preview-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.preview-info {
    padding: 8px;
    font-size: 0.85em;
}

.preview-name {
    display: block;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.preview-size {
    display: block;
    color: #888;
    font-size: 0.8em;
}

.preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    padding: 0;
}

.preview-remove:hover {
    background: rgba(220, 53, 69, 1);
}

.preview-container:empty {
    display: none;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.control-group label {
    font-weight: 500;
    color: #333;
}

#quality {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
}

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

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

#qualityValue {
    color: #667eea;
    font-weight: 600;
}

.control-group input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1em;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-primary:active {
    transform: scale(0.98);
}

.results-section {
    margin-top: 30px;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #667eea;
    font-size: 1.1em;
}

.results-list {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.results-list h3 {
    margin: 0;
    color: #333;
}

.download-all-dropdown {
    position: relative;
    display: inline-block;
}

.btn-download-all {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
    font-family: inherit;
}

.btn-download-all:hover {
    background: #5568d3;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 5px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 1000;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
}

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

.dropdown-item:hover {
    background: #f8f9fa;
    color: #667eea;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    background: white;
}

.result-item.success {
    border-left: 4px solid #28a745;
}

.result-item.error {
    border-left: 4px solid #dc3545;
}

.result-info {
    flex: 1;
    font-size: 0.95em;
}

.result-info strong {
    color: #333;
}

.btn-download {
    background: #28a745;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background 0.3s ease;
}

.btn-download:hover {
    background: #218838;
}

.error {
    color: #dc3545;
    padding: 15px;
    background: #f8d7da;
    border-radius: 6px;
    border-left: 4px solid #dc3545;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.history-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

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

.history-thumbnail {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.history-info {
    padding: 12px;
    flex: 1;
}

.history-filename {
    font-weight: 500;
    color: #333;
    font-size: 0.9em;
    margin-bottom: 6px;
    word-break: break-word;
    line-height: 1.3;
}

.history-size {
    font-size: 0.85em;
    color: #888;
}

.history-actions {
    display: flex;
    gap: 8px;
    padding: 0 12px 12px 12px;
}

.history-item .btn-download {
    flex: 1;
    text-align: center;
    padding: 8px;
}

.btn-delete {
    flex: 1;
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s ease;
    font-family: inherit;
}

.btn-delete:hover {
    background: #c82333;
}

.btn-delete:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state p {
    font-size: 1.1em;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .logo {
        width: 40px;
        height: 40px;
    }
    
    .file-input-wrapper {
        padding: 20px;
    }
    
    .preview-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .preview-item img {
        height: 100px;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .download-all-dropdown {
        width: 100%;
    }
    
    .btn-download-all {
        width: 100%;
        text-align: center;
    }
    
    .dropdown-menu {
        right: auto;
        left: 0;
        width: 100%;
    }
    
    .result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .history-thumbnail {
        height: 150px;
    }
    
    .tool-nav {
        flex-direction: column;
        gap: 10px;
    }
    
    .nav-link {
        text-align: center;
    }
}
