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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #0F172A;
    background: #FAFCFF;
    min-height: 100vh;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 16px;
    padding: 20px 20px 12px;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 6px;
    font-weight: 700;
    color: #0369A1;
}

.header p {
    font-size: 1.1rem;
    color: #475569;
}

/* File Type Selector */
.file-type-selector {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
}

.file-type-selector h2 {
    color: #0F172A;
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: 600;
}

.type-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.tab-btn {
    background: #F1F5F9;
    color: #334155;
    border: 1px solid #E2E8F0;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: #E0F2FE;
    border-color: #7DD3FC;
    color: #0369A1;
}

.tab-btn.active {
    background: #0369A1;
    color: #FFFFFF;
    border-color: #0369A1;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.25);
}

/* Main Content */
.main-content {
    background: #FFFFFF;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
    border: 1px solid #E2E8F0;
    margin-bottom: 16px;
}

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

.upload-area {
    border: 2px dashed #7DD3FC;
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    background: #F8FAFC;
    transition: all 0.2s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #0369A1;
    background: #F0F9FF;
}

.upload-area.dragover {
    border-color: #0369A1;
    background: #E0F2FE;
    transform: scale(1.01);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-content h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #0F172A;
}

.upload-content p {
    color: #64748B;
    margin-bottom: 20px;
}

.upload-btn {
    background: #0369A1;
    color: #FFFFFF;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.upload-btn:hover {
    background: #075985;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.3);
}

/* File List */
.file-list-section {
    margin-bottom: 30px;
}

.file-list-section h3 {
    margin-bottom: 20px;
    color: #0F172A;
    font-size: 1.3rem;
}

.file-list {
    display: grid;
    gap: 15px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #F8FAFC;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.file-preview {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.file-preview.icon-preview {
    background-color: #F1F5F9;
    font-size: 1.5rem;
}

.file-details h4 {
    font-size: 1rem;
    color: #0F172A;
    margin-bottom: 5px;
}

.file-details p {
    font-size: 0.9rem;
    color: #64748B;
}

.file-remove {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
}

.file-remove:hover {
    background: #c82333;
}

/* Conversion Options */
.conversion-section {
    margin-bottom: 30px;
}

.conversion-section h3 {
    margin-bottom: 20px;
    color: #0F172A;
    font-size: 1.3rem;
}

.conversion-options {
    display: grid;
    gap: 20px;
    margin-bottom: 25px;
}

.option-category {
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 20px;
    background: #F8FAFC;
}

.option-category h4 {
    font-size: 1.1rem;
    color: #334155;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-icon {
    font-size: 1.2rem;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.option-group label {
    font-weight: 600;
    color: #475569;
    min-width: 120px;
}

.option-group select,
.option-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #CBD5E1;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 150px;
    color: #0F172A;
    background: #FFFFFF;
}

.option-group select:focus,
.option-group input[type="number"]:focus {
    outline: none;
    border-color: #0369A1;
    box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12);
}

.option-group input[type="range"] {
    flex: 1;
    max-width: 200px;
    accent-color: #0369A1;
}

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

.convert-btn {
    background: #16A34A;
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.convert-btn:hover:not(:disabled) {
    background: #15803D;
    box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.convert-btn:disabled {
    background: #94A3B8;
    cursor: not-allowed;
}

/* Progress Section */
.progress-section {
    margin-bottom: 30px;
}

.progress-section h3 {
    margin-bottom: 20px;
    color: #0F172A;
    font-size: 1.3rem;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: #E2E8F0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #16A34A;
    border-radius: 5px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-weight: 600;
    color: #16A34A;
    min-width: 50px;
}

.progress-details {
    font-size: 0.9rem;
    color: #64748B;
}

/* Download Section */
.download-section h3 {
    margin-bottom: 20px;
    color: #0F172A;
    font-size: 1.3rem;
}

.download-list {
    margin-bottom: 25px;
}

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #F8FAFC;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    margin-bottom: 10px;
}

.download-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.download-preview {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #E2E8F0;
}

.download-btn {
    background: #0369A1;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
}

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

.download-all-btn,
.reset-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 15px;
    transition: background 0.2s ease;
}

.download-all-btn {
    background: #0369A1;
    color: white;
}

.download-all-btn:hover {
    background: #075985;
    box-shadow: 0 2px 8px rgba(3, 105, 161, 0.3);
}

.reset-btn {
    background: #64748B;
    color: white;
}

.reset-btn:hover {
    background: #475569;
}

/* Footer */
.footer {
    text-align: center;
    color: #64748B;
    font-size: 0.9rem;
    padding: 16px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .file-type-selector {
        padding: 15px;
    }

    .type-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .tab-btn {
        width: 100%;
        padding: 15px;
    }

    .main-content {
        padding: 25px;
        border-radius: 12px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .upload-area {
        padding: 40px 15px;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .option-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .option-group label {
        min-width: auto;
    }

    .file-item {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .download-item {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .progress-container {
        flex-direction: column;
        gap: 10px;
    }
}

/* ---- 可及性與易用性補強 ---- */
:focus-visible {
    outline: 3px solid #0369A1;
    outline-offset: 2px;
}

.tab-btn,
.upload-btn,
.convert-btn,
.download-btn,
.download-all-btn,
.reset-btn,
.file-remove {
    min-height: 44px;
    min-width: 44px;
}

.option-group input[type="checkbox"] {
    width: 44px;
    height: 44px;
    min-width: 44px;
    accent-color: #0369A1;
    cursor: pointer;
}

.format-hint {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.5;
    margin: 4px 0 12px;
}

.header .steps {
    font-size: 0.95rem;
    color: #475569;
    margin-top: 6px;
}

.message-bar {
    display: none;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
}

.message-error { background: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }
.message-warn { background: #FFFBEB; color: #92400E; border: 1px solid #FCD34D; }
noscript .message-bar { display: block; }

.file-details h4,
.file-details p,
.download-item h4 {
    overflow-wrap: anywhere;
    word-break: break-word;
}

html, body { overflow-x: hidden; }

@media (max-width: 480px) {
    .container { padding: 12px; }
    .header h1 { font-size: 1.5rem; }
    .header p { font-size: 1rem; }
    .file-item, .download-item { flex-wrap: wrap; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

.option-group select,
.option-group input[type="number"] {
    min-height: 44px;
}
