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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding: 5px;
    overflow-x: hidden;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 5px;
}

header {
    text-align: center;
    margin-bottom: 8px;
    color: white;
}

header h1 {
    font-size: 1.3rem;
    margin-bottom: 3px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: 600;
}

header p {
    font-size: 0.8rem;
    opacity: 0.9;
}

main {
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

/* 模式选择样式 */
.mode-selection {
    margin-bottom: 10px;
}

.mode-tabs {
    display: flex;
    background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.08);
}

.mode-tab {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #6c757d;
    letter-spacing: 0.2px;
}

.mode-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.mode-tab:hover:not(.active) {
    background: linear-gradient(145deg, #ffffff 0%, #f1f3f4 100%);
    color: #495057;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}

/* 转换模式容器 */
.conversion-mode {
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 上传区域样式 */
.upload-section {
    margin-bottom: 10px;
}

.upload-area {
    border: 2px dashed #ddd;
    border-radius: 6px;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    position: relative;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-area:hover, .upload-area.dragover {
    border-color: #667eea;
    background: linear-gradient(145deg, #f0f4ff 0%, #e8f0ff 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
}

.upload-icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
    opacity: 0.7;
}

.upload-area h3 {
    margin-bottom: 4px;
    color: #333;
    font-size: 0.9rem;
    font-weight: 600;
}

.upload-area p {
    color: #666;
    margin-bottom: 2px;
    font-size: 0.75rem;
    line-height: 1.3;
}

.upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* 文件列表样式 */
.file-list {
    margin-bottom: 10px;
}

.file-list h3 {
    margin-bottom: 6px;
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: 600;
}

#selectedFiles {
    min-height: 50px;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px;
    background: #fafafa;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    margin-bottom: 4px;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.file-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.file-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.file-icon {
    font-size: 1rem;
    margin-right: 8px;
}

.file-details h4 {
    margin-bottom: 1px;
    color: #333;
    font-size: 0.8rem;
    font-weight: 600;
}

.file-details p {
    color: #666;
    font-size: 0.7rem;
}

.remove-btn {
    background: linear-gradient(135deg, #ff4757 0%, #ff3742 100%);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    font-weight: 600;
}

.remove-btn:hover {
    background: linear-gradient(135deg, #ff3742 0%, #ff2730 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(255, 71, 87, 0.4);
}

/* PDF文件信息样式 */
.pdf-file-info {
    margin-bottom: 10px;
}

.pdf-file-info h3 {
    margin-bottom: 6px;
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

#pdfDetails {
    background: linear-gradient(145deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 6px;
    padding: 8px;
    border: 1px solid #e3e6ea;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.pdf-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

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

.pdf-info-item:hover {
    background-color: rgba(102, 126, 234, 0.08);
    border-radius: 4px;
    padding-left: 8px;
    padding-right: 8px;
}

.pdf-info-label {
    font-weight: 700;
    color: #495057;
    min-width: 80px;
    font-size: 0.85rem;
    letter-spacing: 0.3px;
}

.pdf-info-value {
    color: #333;
    text-align: right;
    flex: 1;
    margin-left: 10px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* 转换选项样式 */
.conversion-options {
    margin-bottom: 10px;
}

.conversion-options h3 {
    margin-bottom: 6px;
    color: #2c3e50;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.format-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 6px;
}

.format-btn {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border: 2px solid #e3e6ea;
    border-radius: 6px;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    position: relative;
    overflow: hidden;
    min-height: 35px;
}

.format-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.15), transparent);
    transition: left 0.6s ease;
}

.format-btn:hover::before {
    left: 100%;
}

.format-btn:hover {
    border-color: #667eea;
    background: linear-gradient(145deg, #f0f4ff 0%, #ffffff 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.2);
}

.format-btn.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.format-btn.selected::before {
    display: none;
}

.format-icon {
    font-size: 1rem;
    margin-right: 6px;
    opacity: 0.9;
    transition: transform 0.3s ease;
}

.format-btn:hover .format-icon {
    transform: scale(1.05);
}

.format-name {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1px;
    line-height: 1.2;
}

/* 控制按钮样式 */
.controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
    margin-top: 6px;
}

.convert-btn, .clear-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.2px;
    position: relative;
    overflow: hidden;
    min-width: 100px;
    justify-content: center;
}

.convert-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.convert-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.8s ease;
}

.convert-btn:hover:not(:disabled)::before {
    left: 100%;
}

.convert-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.convert-btn:disabled {
    background: linear-gradient(135deg, #bbb 0%, #999 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.convert-btn:disabled::before {
    display: none;
}

.clear-btn {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.clear-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.8s ease;
}

.clear-btn:hover::before {
    left: 100%;
}

.clear-btn:hover {
    background: linear-gradient(135deg, #5a6268 0%, #495057 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.5);
}

/* 加载动画 */
.loading {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 预览区域样式 */
.preview-section {
    margin-top: 10px;
    padding: 10px;
    background: linear-gradient(145deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 8px;
    border: 2px solid #e9ecef;
    box-shadow: 0 3px 12px rgba(0,0,0,0.1);
}

.preview-section h3 {
    margin-bottom: 8px;
    color: #333;
    font-size: 1rem;
    font-weight: 700;
}

#previewContent {
    max-height: 200px;
    overflow-y: auto;
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    font-size: 0.85rem;
}

/* 消息样式 */
.success-message, .error-message, .info-message {
    padding: 8px 12px;
    border-radius: 6px;
    margin: 8px 0;
    font-weight: 600;
    font-size: 0.85rem;
    animation: slideIn 0.4s ease-out;
}

.success-message {
    background: linear-gradient(145deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #c3e6cb;
}

.error-message {
    background: linear-gradient(145deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.info-message {
    background: linear-gradient(145deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
    border: 2px solid #bee5eb;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 4px;
        max-width: 100%;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    main {
        padding: 15px;
    }
    
    .mode-tabs {
        flex-direction: column;
        gap: 6px;
    }
    
    .mode-tab {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .format-options {
        grid-template-columns: 1fr;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .convert-btn, .clear-btn {
        width: 100%;
        max-width: 250px;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .remove-btn {
        align-self: flex-end;
    }
}

@media (max-width: 480px) {
    body {
        padding: 3px;
    }
    
    .upload-area {
        padding: 20px 12px;
        min-height: 120px;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .upload-area h3 {
        font-size: 1rem;
    }
    
    .format-btn {
        padding: 10px 15px;
        min-height: 50px;
    }
    
    .format-icon {
        font-size: 1.2rem;
    }
    
    .format-name {
        font-size: 0.9rem;
    }
}

/* 高度优化 - 确保在一屏内显示 */
@media (max-height: 900px) {
    body {
        padding: 4px;
    }
    
    .container {
        padding: 4px;
    }
    
    header {
        margin-bottom: 6px;
    }
    
    header h1 {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    
    main {
        padding: 10px;
        max-height: calc(100vh - 60px);
    }
    
    .mode-selection, .upload-section, .file-list, .pdf-file-info, .conversion-options {
        margin-bottom: 8px;
    }
    
    .controls {
        margin-bottom: 6px;
    }
    
    .upload-area {
        padding: 12px 10px;
        min-height: 70px;
    }
    
    .format-btn {
        padding: 4px 6px;
        min-height: 30px;
    }
    
    .format-name {
        font-size: 0.7rem;
    }
}

@media (max-height: 800px) {
    body {
        padding: 3px;
    }
    
    header h1 {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }
    
    header p {
        font-size: 0.75rem;
    }
    
    main {
        padding: 8px;
        max-height: calc(100vh - 50px);
    }
    
    .upload-area {
        padding: 10px 8px;
        min-height: 60px;
    }
    
    .upload-icon {
        font-size: 1.3rem;
        margin-bottom: 3px;
    }
    
    .format-options {
        gap: 4px;
    }
    
    .format-btn {
        padding: 3px 5px;
        min-height: 28px;
    }
    
    #selectedFiles, #pdfDetails {
        padding: 6px;
    }
    
    .file-item {
        padding: 4px;
        margin-bottom: 3px;
    }
    
    .mode-selection, .upload-section, .file-list, .pdf-file-info, .conversion-options {
        margin-bottom: 6px;
    }
    
    .controls {
        margin-bottom: 4px;
    }
    
    .convert-btn, .clear-btn {
        padding: 5px 12px;
        font-size: 0.75rem;
    }
    
    .pdf-info-item {
        padding: 4px 0;
    }
    
    .pdf-info-label, .pdf-info-value {
        font-size: 0.8rem;
    }
}

/* 超小屏幕优化 */
@media (max-height: 700px) {
    body {
        padding: 2px;
    }
    
    header {
        margin-bottom: 4px;
    }
    
    header h1 {
        font-size: 1rem;
        margin-bottom: 1px;
    }
    
    header p {
        font-size: 0.7rem;
    }
    
    main {
        padding: 6px;
        max-height: calc(100vh - 40px);
    }
    
    .upload-area {
        padding: 8px 6px;
        min-height: 50px;
    }
    
    .upload-icon {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    
    .upload-area h3 {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }
    
    .upload-area p {
        font-size: 0.65rem;
    }
    
    .format-btn {
        padding: 2px 4px;
        min-height: 25px;
    }
    
    .format-icon {
        font-size: 0.9rem;
        margin-right: 4px;
    }
    
    .format-name {
        font-size: 0.65rem;
    }
    
    .mode-selection, .upload-section, .file-list, .pdf-file-info, .conversion-options {
        margin-bottom: 4px;
    }
    
    .controls {
        margin-bottom: 3px;
    }
    
    .convert-btn, .clear-btn {
        padding: 4px 10px;
        font-size: 0.7rem;
        min-width: 80px;
    }
    
    .file-list h3, .pdf-file-info h3, .conversion-options h3 {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    
    .pdf-info-item {
        padding: 3px 0;
    }
    
    .pdf-info-label, .pdf-info-value {
        font-size: 0.75rem;
    }
    
    #selectedFiles, #pdfDetails {
        padding: 5px;
        min-height: 40px;
    }
    
    .file-item {
        padding: 3px;
        margin-bottom: 2px;
    }
    
    .file-details h4 {
        font-size: 0.75rem;
    }
    
    .file-details p {
        font-size: 0.65rem;
    }
    
    .remove-btn {
        padding: 3px 6px;
        font-size: 0.7rem;
    }
}