:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --bg-color: #f4f4f9;
    --text-color: #333;
    --border-color: #ddd;
    --card-bg: #fff;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

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

header h1 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
}

/* Buttons and Inputs */
input[type="file"] {
    display: none;
}

.custom-file-upload {
    border: 1px solid var(--border-color);
    display: inline-block;
    padding: 10px 20px;
    cursor: pointer;
    background-color: var(--card-bg);
    border-radius: 5px;
    transition: all 0.3s;
}

.custom-file-upload:hover {
    background-color: #e9ecef;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
}

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

/* Main Content Area */
.main-content {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Important for nested flex scrolling */
}

.editor-section, .preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 15px;
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 5px;
}

textarea {
    width: 100%;
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 10px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    resize: none;
}

textarea:focus {
    outline: 2px solid var(--primary-color);
    border-color: transparent;
}

#previewContent {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 20px;
    background-color: #fff;
}

/* Markdown Styles (Simplified GitHub-like) */
.markdown-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    color: #24292e;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: #24292e;
}

.markdown-body h1 { font-size: 2em; border-bottom: 1px solid #eaecef; padding-bottom: .3em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid #eaecef; padding-bottom: .3em; }
.markdown-body h3 { font-size: 1.25em; }
.markdown-body h4 { font-size: 1em; }

.markdown-body p { margin-bottom: 16px; }

.markdown-body code {
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27,31,35,.05);
    border-radius: 3px;
    font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

.markdown-body pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid #e1e4e8;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    font-size: 100%;
    word-break: normal;
    white-space: pre;
}

.markdown-body blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: .25em solid #dfe2e5;
    margin-bottom: 16px;
    background-color: #fafbfc; /* Light background for quotes */
    padding-top: 8px;
    padding-bottom: 8px;
}

.markdown-body img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #fff;
    border-radius: 4px; /* Slightly rounded corners */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); /* Subtle shadow */
}

.markdown-body table {
    border-spacing: 0;
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
    display: table; /* Ensure table layout */
}

.markdown-body table th, .markdown-body table td {
    padding: 8px 13px;
    border: 1px solid #dfe2e5;
}

.markdown-body table th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.markdown-body table tr:nth-child(2n) {
    background-color: #fff; /* Clean white for print usually better, or keep light gray */
}

.markdown-body table tr {
    background-color: #fff;
    border-top: 1px solid #c6cbd1;
}

.markdown-body table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 2em;
    margin-bottom: 16px;
}

.markdown-body hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e1e4e8;
    border: 0;
}

/* PDF Generation Specific Styles */
.print-mode {
    width: 100% !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: white !important;
}

.print-mode .markdown-body {
    padding: 0 !important; /* Let html2pdf handle margins */
}
