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

:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 720px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

header .subtitle {
    font-size: 16px;
    color: var(--text-muted);
}

main {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow);
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.2s ease;
    background: var(--bg);
}

.upload-area.dragging {
    border-color: var(--primary);
    background: #eff6ff;
}

.upload-area.has-file {
    border-style: solid;
    border-color: var(--border);
    background: white;
    padding: 0;
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-icon {
    color: var(--text-muted);
}

.upload-text {
    font-size: 16px;
    color: var(--text-muted);
}

.upload-text strong {
    color: var(--primary);
}

.upload-hint {
    font-size: 13px;
    color: var(--text-muted);
    opacity: 0.7;
}

.upload-btn {
    display: inline-block;
    padding: 12px 28px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.upload-btn:hover {
    background: var(--primary-hover);
}

/* Files List */
.files-list {
    width: 100%;
}

.files-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    border-radius: 10px 10px 0 0;
}

.files-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.btn-add-more {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add-more:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.files-scroll {
    max-height: 350px;
    overflow-y: auto;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    flex-wrap: wrap;
}

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

.file-item:hover {
    background: var(--bg);
}

.file-item.processing {
    background: #fefce8;
}

.file-item.done {
    background: #f0fdf4;
}

.file-icon {
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-item.done .file-icon {
    color: var(--success);
}

.file-item.uploading {
    background: #f0f9ff;
}

.file-item.uploading .file-icon {
    color: var(--primary);
}

.file-details {
    flex: 1;
    min-width: 200px;
}

.filename {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    word-break: break-word;
    line-height: 1.4;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Upload Progress */
.upload-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.upload-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.2s ease;
}

.upload-progress-text {
    font-size: 11px;
    color: var(--primary);
    font-weight: 500;
    min-width: 32px;
}

.badge {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-done {
    background: #dbeafe;
    color: #1e40af;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

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

.btn-action {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

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

.btn-action.btn-view {
    color: #6366f1;
    border-color: #c7d2fe;
}

.btn-action.btn-view:hover:not(:disabled) {
    background: #eef2ff;
    border-color: #6366f1;
}

.btn-action.btn-download {
    color: var(--primary);
    border-color: #bfdbfe;
}

.btn-action.btn-download:hover:not(:disabled) {
    background: #eff6ff;
    border-color: var(--primary);
}

.btn-remove {
    color: var(--text-muted);
}

.btn-remove:hover {
    background: #fee2e2;
    color: var(--error);
}

/* Options */
.options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}

.option-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.option-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text);
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.option-group select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Actions */
.actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-primary {
    flex: 1;
    padding: 16px 28px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-secondary {
    padding: 14px 20px;
    background: white;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--error);
    border-color: var(--error);
}

.loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    animation: spin 1s linear infinite;
}

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

/* Error Message */
.error-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: var(--error);
    font-size: 14px;
    text-align: center;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Scrollbar */
.files-scroll::-webkit-scrollbar {
    width: 6px;
}

.files-scroll::-webkit-scrollbar-track {
    background: var(--bg);
}

.files-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.files-scroll::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-close {
    color: var(--text-muted);
}

.btn-close:hover {
    background: var(--bg);
    color: var(--text);
}

.modal-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: var(--bg);
}

.markdown-preview {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.btn-copy {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--primary-hover);
}

.btn-secondary-sm {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary-sm:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

/* Modal Multi-Parte */
.parts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.part-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}

.part-item:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.part-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.part-info strong {
    font-size: 14px;
    color: var(--text);
}

.part-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.part-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-copy-sm,
.btn-download-sm,
.btn-preview-sm {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.btn-copy-sm {
    color: var(--success);
    border-color: #d1fae5;
}

.btn-copy-sm:hover {
    background: #ecfdf5;
    border-color: var(--success);
}

.btn-download-sm {
    color: var(--primary);
    border-color: #bfdbfe;
}

.btn-download-sm:hover {
    background: #eff6ff;
    border-color: var(--primary);
}

.btn-preview-sm {
    color: #6366f1;
    border-color: #c7d2fe;
}

.btn-preview-sm:hover {
    background: #eef2ff;
    border-color: #6366f1;
}

.part-preview {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.part-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.part-preview-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.part-preview .markdown-preview {
    max-height: 300px;
    overflow: auto;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    main {
        padding: 20px;
    }

    .options {
        grid-template-columns: 1fr;
    }

    .actions {
        flex-direction: column;
    }

    .btn-secondary {
        order: 1;
    }

    header h1 {
        font-size: 24px;
    }

    .files-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .modal {
        max-height: 80vh;
    }

    .modal-footer {
        flex-direction: column;
    }

    .part-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .part-actions {
        width: 100%;
        justify-content: space-between;
    }

    .btn-copy-sm,
    .btn-download-sm,
    .btn-preview-sm {
        flex: 1;
        justify-content: center;
    }
}
