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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #1e1e1e;
    color: #d4d4d4;
    overflow: hidden; /* prevent body scroll — panes scroll independently */
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 16px;
    background-color: #2d2d2d;
    border-bottom: 1px solid #3c3c3c;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.topbar-filename {
    font-size: 13px;
    color: #888;
    font-style: italic;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    background-color: #252525;
    border-bottom: 1px solid #3c3c3c;
    flex-shrink: 0;
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background-color: #555;
}

.heading-dropdown,
.toolbar-dropdown {
    position: relative;
}

.heading-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    flex-direction: column;
    background-color: #2d2d2d;
    border: 1px solid #555;
    border-radius: 4px;
    overflow: hidden;
    white-space: nowrap;
}

.heading-menu.open {
    display: flex;
}

.heading-option {
    padding: 7px 16px;
    background: none;
    border: none;
    color: #d4d4d4;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.heading-option:hover {
    background-color: #3a3a3a;
}

.toolbar-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 100;
    flex-direction: column;
    background-color: #2d2d2d;
    border: 1px solid #555;
    border-radius: 4px;
    overflow: hidden;
    white-space: nowrap;
}

.toolbar-menu.open {
    display: flex;
}

.toolbar-option {
    padding: 7px 16px;
    background: none;
    border: none;
    color: #d4d4d4;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.toolbar-option:hover {
    background-color: #3a3a3a;
}

.btn-format {
    min-width: 34px;
    padding: 6px 10px;
    font-family: Georgia, 'Times New Roman', serif;
}

.btn {
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid #555;
    border-radius: 4px;
    background-color: #3a3a3a;
    color: #d4d4d4;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.btn:hover {
    background-color: #505050;
}

.btn:active {
    background-color: #606060;
}

.editor-container {
    display: flex;
    height: calc(100vh - 92px); /* 48px topbar + 44px toolbar */
    overflow: hidden;
}

.pane {
    display: flex;
    flex-direction: column;
    flex: 1; /* each pane takes 50% */
    min-width: 0; /* prevents flex overflow */
    overflow: hidden;
}

.pane-header {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    background-color: #252525;
    border-bottom: 1px solid #3c3c3c;
    flex-shrink: 0;
}

.markdown-input {
    flex: 1;
    width: 100%;
    padding: 20px;
    font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.7;
    color: #d4d4d4;
    background-color: #1e1e1e;
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
}

.markdown-input::placeholder {
    color: #555;
}

.status-bar {
    padding: 4px 14px;
    font-size: 11px;
    color: #666;
    background-color: #1e1e1e;
    border-top: 1px solid #2d2d2d;
    flex-shrink: 0;
    user-select: none;
}

.markdown-preview {
    flex: 1;
    padding: 20px 28px;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #1e1e1e;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.placeholder-text {
    color: #555;
    font-style: italic;
}

.divider {
    width: 1px;
    background-color: #3c3c3c;
    flex-shrink: 0;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
    color: #ffffff;
    margin: 24px 0 12px;
    line-height: 1.3;
}

.markdown-preview h1 { font-size: 28px; border-bottom: 1px solid #3c3c3c; padding-bottom: 8px; }
.markdown-preview h2 { font-size: 22px; border-bottom: 1px solid #3c3c3c; padding-bottom: 6px; }
.markdown-preview h3 { font-size: 18px; }
.markdown-preview h4 { font-size: 15px; }

.markdown-preview p {
    margin-bottom: 14px;
}

.markdown-preview a {
    color: #4ec9b0;
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

.markdown-preview ul,
.markdown-preview ol {
    margin: 0 0 14px 24px;
}

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

.markdown-preview code {
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    background-color: #2d2d2d;
    padding: 2px 6px;
    border-radius: 3px;
    color: #ce9178;
}

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

.markdown-preview pre code {
    background: none;
    padding: 0;
    color: #d4d4d4;
}

.markdown-preview blockquote {
    border-left: 3px solid #4ec9b0;
    margin: 0 0 14px;
    padding: 4px 16px;
    color: #888;
}

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

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

.markdown-preview th {
    background-color: #2d2d2d;
    color: #ffffff;
}

.markdown-preview tr:nth-child(even) {
    background-color: #252525;
}

.markdown-preview img {
    max-width: 100%;
    border-radius: 4px;
}

.markdown-preview hr {
    border: none;
    border-top: 1px solid #3c3c3c;
    margin: 24px 0;
}

@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
    }

    .divider {
        width: 100%;
        height: 1px;
    }
}