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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
    max-width: 100%;
    margin: 0;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    text-align: center;
    flex-shrink: 0;
}

.header h1 {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 2.2rem;
}

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

.controls {
    padding: 20px 30px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    align-items: center;
    gap: 25px;
    flex-shrink: 0;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.templates {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.template-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.95rem;
    white-space: nowrap;
}

.template-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.template-btn {
    background: white;
    border: 2px solid #e9ecef;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    color: #495057;
    font-weight: 500;
}

.template-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.editor-preview-container {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
}

.editor-container {
    flex: 1;
    transition: all 0.3s ease;
    position: relative;
}

.editor-container.half-width {
    flex: 0.5;
}

#textEditor {
    width: 100%;
    height: 100%;
    padding: 30px;
    border: none;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 16px;
    line-height: 1.7;
    resize: none;
    outline: none;
    background: #fafbfc;
    color: #2c3e50;
    transition: all 0.3s ease;
}

#textEditor:focus {
    background: white;
    box-shadow: inset 0 0 0 2px #667eea;
}

.preview-container {
    flex: 0.5;
    display: flex;
    flex-direction: column;
    background: white;
    border-left: 1px solid #e1e5e9;
    transition: all 0.3s ease;
}

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

.preview-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: white;
    line-height: 1.8;
    font-size: 15px;
}

/* Markdown 样式 */
.preview-content h1 {
    font-size: 2.2rem;
    margin: 1.8rem 0 1.2rem 0;
    padding-bottom: 0.8rem;
    border-bottom: 3px solid #e1e5e9;
    color: #2c3e50;
    font-weight: 700;
}

.preview-content h2 {
    font-size: 1.8rem;
    margin: 1.6rem 0 1rem 0;
    color: #34495e;
    font-weight: 600;
}

.preview-content h3 {
    font-size: 1.5rem;
    margin: 1.4rem 0 0.8rem 0;
    color: #34495e;
    font-weight: 600;
}

.preview-content h4 {
    font-size: 1.3rem;
    margin: 1.2rem 0 0.6rem 0;
    color: #34495e;
    font-weight: 600;
}

.preview-content p {
    margin-bottom: 1.2rem;
    color: #4a5568;
}

.preview-content code {
    background: #f7fafc;
    padding: 3px 8px;
    border-radius: 5px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 0.9em;
    color: #e53e3e;
    border: 1px solid #e2e8f0;
}

.preview-content pre {
    background: #1a202c;
    padding: 20px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 1.5rem 0;
    border-left: 5px solid #667eea;
}

.preview-content pre code {
    background: none;
    padding: 0;
    color: #cbd5e0;
    border: none;
    font-size: 0.95em;
}

.preview-content blockquote {
    border-left: 5px solid #667eea;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    color: #718096;
    font-style: italic;
    background: #f7fafc;
    padding: 1.2rem 1.2rem 1.2rem 1.5rem;
    border-radius: 0 8px 8px 0;
}

.preview-content ul, .preview-content ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

.preview-content li {
    margin-bottom: 0.6rem;
    color: #4a5568;
}

.preview-content ul li {
    list-style-type: disc;
}

.preview-content ol li {
    list-style-type: decimal;
}

.preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.preview-content th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    padding: 1rem;
    text-align: left;
}

.preview-content td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.preview-content tr:nth-child(even) {
    background: #f7fafc;
}

.preview-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.preview-content a:hover {
    border-bottom-color: #667eea;
}

.preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    padding: 15px 30px;
    background: #f8f9fa;
    border-top: 1px solid #e1e5e9;
    font-size: 0.9rem;
    color: #6c757d;
    flex-shrink: 0;
}

/* 滚动条样式 */
.preview-content::-webkit-scrollbar {
    width: 8px;
}

.preview-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        height: 100vh;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .controls {
        padding: 15px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .templates {
        width: 100%;
    }
    
    .template-buttons {
        width: 100%;
        justify-content: flex-start;
    }
    
    .editor-preview-container {
        flex-direction: column;
    }
    
    .editor-container.half-width {
        flex: 0.5;
    }
    
    .preview-container {
        border-left: none;
        border-top: 1px solid #e1e5e9;
    }
    
    #textEditor {
        padding: 20px;
        font-size: 15px;
    }
    
    .preview-content {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .template-buttons {
        flex-direction: column;
        width: 100%;
    }
    
    .template-btn {
        width: 100%;
        text-align: center;
    }
    
    #textEditor {
        padding: 15px;
        font-size: 14px;
    }
    
    .preview-content {
        padding: 15px;
        font-size: 14px;
    }
    
    .status-bar {
        padding: 12px 15px;
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }
}