* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1a73e8;
    --primary-hover: #1557b0;
    --secondary-color: #5f6368;
    --background: #f8f9fa;
    --card-background: #ffffff;
    --border-color: #dadce0;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --success-color: #34a853;
    --warning-color: #fbbc04;
    --error-color: #ea4335;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

@media (min-width: 768px) {
    .container {
        max-width: 900px;
        padding: 2rem;
    }
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem 0;
}

header h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (min-width: 768px) {
    section {
        padding: 1.5rem;
    }
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s ease;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--primary-color);
    background: rgba(26, 115, 232, 0.1);
    border-bottom: 3px solid var(--primary-color);
    margin-bottom: -2px;
}

.tab-btn:hover:not(.active) {
    background: rgba(0, 0, 0, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.8;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

@media (min-width: 768px) {
    textarea {
        min-height: 400px;
    }
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(26, 115, 232, 0.02);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(26, 115, 232, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.options-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .option-group {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1.5rem;
    }
}

.option-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.option-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: rgba(26, 115, 232, 0.1);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.preview-section {
    border: 2px solid var(--primary-color);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.preview-header h3 {
    color: var(--primary-color);
}

.preview-content {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    min-height: 300px;
    max-height: 500px;
    overflow-y: auto;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.8;
}

@media (min-width: 768px) {
    .preview-content {
        padding: 3rem;
        max-height: 600px;
    }
}

.preview-content .doc-title {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 0.5rem;
    font-family: "方正小标宋简体", "黑体", "SimHei", sans-serif;
    line-height: 1.5;
}

.preview-content .heading1 {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0.5rem 0 0.25rem;
    font-family: "黑体", "SimHei", sans-serif;
    line-height: 1.5;
}

.preview-content .heading2 {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0.4rem 0 0.25rem;
    font-family: "楷体", "KaiTi", "楷体_GB2312", serif;
    line-height: 1.5;
}

.preview-content .heading3 {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0.3rem 0 0.25rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .list-item {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .indent {
    text-indent: 2em;
}

.preview-content .paragraph {
    text-indent: 2em;
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    line-height: 1.5;
}

.preview-content .recipient {
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .signature {
    text-align: right;
    margin-top: 1.5rem;
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .doc-date {
    text-align: right;
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .stamp {
    text-align: right;
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .attachment {
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
    line-height: 1.5;
}

.preview-content .empty-line {
    height: 0.8rem;
    line-height: 0.8rem;
}

.preview-content .table-container {
    margin: 1rem 0;
    overflow-x: auto;
}

.preview-content .doc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
    font-family: "仿宋", "FangSong", "仿宋_GB2312", serif;
}

.preview-content .doc-table th,
.preview-content .doc-table td {
    border: 1px solid #333;
    padding: 0.5rem 0.75rem;
    text-align: center;
    vertical-align: middle;
}

.preview-content .doc-table th {
    background-color: #f0f0f0;
    font-weight: bold;
    font-family: "黑体", "SimHei", sans-serif;
}

.preview-content .doc-table td {
    text-align: left;
}

.export-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.help-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.help-content details {
    margin-bottom: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.help-content summary {
    padding: 1rem;
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
    transition: background 0.3s ease;
}

.help-content summary:hover {
    background: rgba(0, 0, 0, 0.05);
}

.help-content ul {
    padding: 1rem;
    padding-left: 2rem;
    background: white;
}

.help-content li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.help-content li strong {
    color: var(--text-primary);
}

footer {
    text-align: center;
    padding: 2rem 0 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.loading {
    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;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 1rem 2rem;
    border-radius: 8px;
    z-index: 1001;
    animation: fadeInUp 0.3s ease;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--error-color);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 0.75rem;
    }
    
    section {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .btn {
        padding: 0.875rem 1rem;
    }
    
    .preview-content {
        padding: 1rem;
    }
}

@media (hover: none) {
    .btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
}
