/* ======================================== */
/* Markdown Viewer                          */
/* ======================================== */
.md-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px - 70px);
}

.md-header {
    text-align: center;
    margin-bottom: 1.25rem;
    flex-shrink: 0;
}

.md-header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.02em;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.md-header p {
    color: var(--text-dim);
    margin-top: .35rem;
}

/* Toolbar */
.md-toolbar {
    display: flex;
    gap: .75rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.md-btn {
    padding: .5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s var(--ease), transform .15s var(--ease);
}

.md-btn:hover {
    transform: translateY(-1px);
}

.md-btn-primary {
    background: var(--accent);
    color: var(--bg);
}

.md-btn-primary:hover {
    background: var(--accent-dim);
}

.md-btn-secondary {
    background: rgba(255,255,255,.06);
    color: var(--text-dim);
    border: 1px solid var(--border);
}

.md-btn-secondary:hover {
    background: rgba(255,255,255,.1);
    color: var(--text);
}

.md-btn-success {
    background: rgba(74, 222, 128, .15);
    color: var(--green);
}

/* Split pane */
.md-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

.md-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.md-pane-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .5rem;
    flex-shrink: 0;
}

.md-editor {
    flex: 1;
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: 'Courier New', 'Fira Code', monospace;
    font-size: .85rem;
    line-height: 1.6;
    resize: none;
    transition: border-color .2s var(--ease);
}

.md-editor::placeholder {
    color: var(--text-mute);
}

.md-editor:focus {
    outline: none;
    border-color: var(--accent);
}

/* Preview pane */
.md-preview {
    flex: 1;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow-y: auto;
    min-height: 0;
}

/* ======================== */
/* Markdown Preview Typography */
/* ======================== */
.md-preview h1,
.md-preview h2,
.md-preview h3,
.md-preview h4,
.md-preview h5,
.md-preview h6 {
    color: var(--text);
    line-height: 1.3;
    margin-top: 1.5em;
    margin-bottom: .5em;
    font-weight: 700;
}

.md-preview h1:first-child,
.md-preview h2:first-child,
.md-preview h3:first-child {
    margin-top: 0;
}

.md-preview h1 { font-size: 1.75rem; letter-spacing: -.02em; border-bottom: 1px solid var(--border); padding-bottom: .5rem; }
.md-preview h2 { font-size: 1.4rem; letter-spacing: -.01em; border-bottom: 1px solid var(--border); padding-bottom: .4rem; }
.md-preview h3 { font-size: 1.15rem; }
.md-preview h4 { font-size: 1rem; }

.md-preview p {
    margin-bottom: 1em;
    color: var(--text-dim);
    line-height: 1.7;
}

.md-preview a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(34, 211, 238, .3);
    transition: text-decoration-color .2s var(--ease);
}

.md-preview a:hover {
    text-decoration-color: var(--accent);
}

.md-preview strong {
    color: var(--text);
    font-weight: 700;
}

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

.md-preview code {
    background: rgba(255,255,255,.06);
    padding: .15em .4em;
    border-radius: 4px;
    font-family: 'Courier New', 'Fira Code', monospace;
    font-size: .85em;
    color: var(--accent);
}

.md-preview pre {
    background: rgba(0,0,0,.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow-x: auto;
    margin-bottom: 1em;
}

.md-preview pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text);
    font-size: .82rem;
    line-height: 1.6;
}

.md-preview blockquote {
    border-left: 3px solid var(--accent);
    padding: .5rem 1rem;
    margin-bottom: 1em;
    background: rgba(34, 211, 238, .04);
    color: var(--text-dim);
}

.md-preview blockquote p:last-child {
    margin-bottom: 0;
}

.md-preview ul,
.md-preview ol {
    margin-bottom: 1em;
    padding-left: 1.5rem;
    color: var(--text-dim);
}

.md-preview li {
    margin-bottom: .35em;
    line-height: 1.7;
}

.md-preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}

.md-preview img {
    max-width: 100%;
    border-radius: var(--radius-sm);
}

.md-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: .85rem;
}

.md-preview th,
.md-preview td {
    border: 1px solid var(--border);
    padding: .5rem .75rem;
    text-align: left;
}

.md-preview th {
    background: rgba(255,255,255,.04);
    font-weight: 600;
    color: var(--text);
}

.md-preview td {
    color: var(--text-dim);
}

.md-preview-empty {
    color: var(--text-mute);
    font-style: italic;
    text-align: center;
    padding: 3rem 1rem;
}

/* Feedback toast */
.md-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--green);
    color: var(--bg);
    padding: .6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 600;
    z-index: 200;
    animation: fadeIn .3s var(--ease);
}

/* ======================== */
/* Responsive               */
/* ======================== */
@media (max-width: 768px) {
    .md-split {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .md-container {
        height: auto;
        min-height: calc(100vh - 60px - 70px);
    }

    .md-editor {
        min-height: 200px;
    }

    .md-preview {
        min-height: 200px;
    }

    .md-header h1 {
        font-size: 1.5rem;
    }
}
