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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: #f5f7fa;
    height: 100vh;
    padding: 16px;
    padding-bottom: 0;
    overflow: hidden;
    transition: background 0.3s ease;
}

body.dark-mode {
    background: #1a202c;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    height: calc(100vh - 16px);
    display: flex;
    flex-direction: column;
    padding-bottom: 16px;
}

header {
    text-align: center;
    color: #2d3748;
    margin-bottom: 8px;
    padding: 4px 0;
    position: relative;
    transition: color 0.3s ease;
}

body.dark-mode header {
    color: #e2e8f0;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.theme-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.editor-panel,
.preview-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

body.dark-mode .editor-panel,
body.dark-mode .preview-panel {
    background: #2d3748;
    border-color: #4a5568;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #ffffff;
    color: #2d3748;
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.3s ease;
}

body.dark-mode .panel-header {
    background: #1a202c;
    color: #e2e8f0;
    border-bottom-color: #4a5568;
}

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #4a5568;
    transition: color 0.3s ease;
}

body.dark-mode .panel-header h2 {
    color: #cbd5e0;
}

.btn {
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid #cbd5e0;
    color: #4a5568;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #f7fafc;
    border-color: #a0aec0;
    color: #2d3748;
}

body.dark-mode .btn {
    background: #4a5568;
    border-color: #718096;
    color: #e2e8f0;
}

body.dark-mode .btn:hover {
    background: #718096;
    border-color: #a0aec0;
}

#markdown-input {
    flex: 1;
    padding: 20px;
    padding-bottom: 100px;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: white;
    color: #2d3748;
    transition: all 0.3s ease;
}

body.dark-mode #markdown-input {
    background: #2d3748;
    color: #e2e8f0;
}

.markdown-preview {
    flex: 1;
    padding: 20px;
    padding-bottom: 100px;
    overflow-y: auto;
    line-height: 1.8;
    scroll-behavior: smooth;
}

/* Markdown Styling */
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: #1a202c;
}

.markdown-preview h1 {
    font-size: 2em;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0.3em;
}

.markdown-preview h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.3em;
}

.markdown-preview h3 { font-size: 1.25em; }
.markdown-preview h4 { font-size: 1em; }
.markdown-preview h5 { font-size: 0.875em; }
.markdown-preview h6 { font-size: 0.85em; color: #718096; }

.markdown-preview p {
    margin-bottom: 16px;
    color: #2d3748;
}

.markdown-preview a {
    color: #3182ce;
    text-decoration: none;
    font-weight: 500;
}

.markdown-preview a:hover {
    text-decoration: underline;
    color: #2c5282;
}

.markdown-preview code {
    background: #f7fafc;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #e53e3e;
}

.markdown-preview pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.markdown-preview pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.875em;
}

.markdown-preview blockquote {
    border-left: 4px solid #3182ce;
    padding-left: 16px;
    margin: 16px 0;
    color: #4a5568;
    font-style: italic;
}

.markdown-preview ul,
.markdown-preview ol {
    margin-bottom: 16px;
    padding-left: 32px;
}

.markdown-preview li {
    margin-bottom: 8px;
}

.markdown-preview hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 24px 0;
}

.markdown-preview table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 16px;
}

.markdown-preview table th,
.markdown-preview table td {
    border: 1px solid #e2e8f0;
    padding: 12px;
    text-align: left;
}

.markdown-preview table th {
    background: #f7fafc;
    font-weight: 600;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 16px 0;
}

.markdown-preview strong {
    font-weight: 700;
    color: #1a202c;
}

body.dark-mode .markdown-preview strong {
    color: #f7fafc;
}

.markdown-preview em {
    font-style: italic;
}

/* Dark mode text colors */
body.dark-mode .markdown-preview {
    color: #e2e8f0;
}

body.dark-mode .markdown-preview h1,
body.dark-mode .markdown-preview h2,
body.dark-mode .markdown-preview h3,
body.dark-mode .markdown-preview h4,
body.dark-mode .markdown-preview h5,
body.dark-mode .markdown-preview h6 {
    color: #f7fafc;
    border-color: #4a5568;
}

body.dark-mode .markdown-preview p {
    color: #e2e8f0;
}

body.dark-mode .markdown-preview a {
    color: #63b3ed;
}

body.dark-mode .markdown-preview a:hover {
    color: #90cdf4;
}

body.dark-mode .markdown-preview code {
    background: #1a202c;
    color: #fc8181;
}

body.dark-mode .markdown-preview pre {
    background: #1a202c;
    border: 1px solid #4a5568;
}

body.dark-mode .markdown-preview blockquote {
    border-left-color: #63b3ed;
    color: #cbd5e0;
}

body.dark-mode .markdown-preview hr {
    border-top-color: #4a5568;
}

body.dark-mode .markdown-preview table th,
body.dark-mode .markdown-preview table td {
    border-color: #4a5568;
}

body.dark-mode .markdown-preview table th {
    background: #1a202c;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        height: auto;
    }

    .editor-panel,
    .preview-panel {
        min-height: 400px;
    }

    header h1 {
        font-size: 2rem;
    }
}

/* Scrollbar Styling */
.markdown-preview::-webkit-scrollbar,
#markdown-input::-webkit-scrollbar {
    width: 8px;
}

.markdown-preview::-webkit-scrollbar-track,
#markdown-input::-webkit-scrollbar-track {
    background: #f1f1f1;
}

body.dark-mode .markdown-preview::-webkit-scrollbar-track,
body.dark-mode #markdown-input::-webkit-scrollbar-track {
    background: #1a202c;
}

.markdown-preview::-webkit-scrollbar-thumb,
#markdown-input::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

body.dark-mode .markdown-preview::-webkit-scrollbar-thumb,
body.dark-mode #markdown-input::-webkit-scrollbar-thumb {
    background: #4a5568;
}

.markdown-preview::-webkit-scrollbar-thumb:hover,
#markdown-input::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

body.dark-mode .markdown-preview::-webkit-scrollbar-thumb:hover,
body.dark-mode #markdown-input::-webkit-scrollbar-thumb:hover {
    background: #718096;
}
