/* Clean GitHub-style Markdown rendering for public & panel pages */
.markdown-body {
    font-size: 15px;
    line-height: 1.68;
    color: inherit;
    word-wrap: break-word;
}

.markdown-body > *:first-child {
    margin-top: 0 !important;
}

.markdown-body > *:last-child {
    margin-bottom: 0 !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin-top: 24px;
    margin-bottom: 14px;
    font-weight: 700;
    line-height: 1.35;
    color: #1a202c;
}

.markdown-body h1 { font-size: 24px; border-bottom: 1px solid #e2e8f0; padding-bottom: 8px; }
.markdown-body h2 { font-size: 20px; border-bottom: 1px solid #edf2f7; padding-bottom: 6px; }
.markdown-body h3 { font-size: 17px; }
.markdown-body h4 { font-size: 15px; }

.markdown-body p {
    margin-top: 0;
    margin-bottom: 14px;
}

.markdown-body blockquote {
    margin: 16px 0;
    padding: 10px 18px;
    border-left: 4px solid var(--primary, #43d477);
    background-color: #f7fafc;
    border-radius: 0 8px 8px 0;
    color: #4a5568;
    font-style: italic;
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-body ul,
.markdown-body ol {
    margin-top: 0;
    margin-bottom: 14px;
    padding-left: 24px !important;
    padding-inline-start: 24px !important;
}

.markdown-body ul {
    list-style-type: disc !important;
}

.markdown-body ol {
    list-style-type: decimal !important;
}

.markdown-body li {
    margin-bottom: 6px;
    display: list-item !important;
    list-style: inherit !important;
}

.markdown-body ul ul { list-style-type: circle; }
.markdown-body ul ul ul { list-style-type: square; }
.markdown-body ol ol { list-style-type: lower-alpha; }
.markdown-body ol ol ol { list-style-type: lower-roman; }

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    display: block;
    overflow-x: auto;
}

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

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

.markdown-body table tr:nth-child(even) td {
    background-color: #f7fafc;
}

.markdown-body pre {
    background-color: #1e293b;
    color: #f8fafc;
    padding: 14px 18px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13.5px;
    line-height: 1.5;
    margin: 16px 0;
}

.markdown-body code {
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 87.5%;
    background-color: #edf2f7;
    color: #e53e3e;
    padding: 2px 6px;
    border-radius: 4px;
}

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

.markdown-body hr {
    height: 1px;
    background-color: #e2e8f0;
    border: none;
    margin: 24px 0;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
}

.markdown-body a {
    color: var(--primary, #43d477);
    text-decoration: underline;
}

.markdown-body a:hover {
    color: var(--secondary, #1f3b64);
}

/* Math / KaTeX container styling */
.markdown-body .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    margin: 14px 0;
}

.markdown-body .katex {
    font-size: 1.08em;
}

/* Mermaid diagram container */
.markdown-body .mermaid-container,
.markdown-body pre.mermaid,
.markdown-body div.mermaid {
    display: flex;
    justify-content: center;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin: 18px 0;
    overflow-x: auto;
}

.markdown-body pre.mermaid {
    color: inherit;
    font-size: inherit;
}

.markdown-body .mermaid svg {
    max-width: 100%;
    height: auto;
}

/* ── Dark Mode ── */
body.dark-mode .markdown-body h1,
body.dark-mode .markdown-body h2,
body.dark-mode .markdown-body h3,
body.dark-mode .markdown-body h4,
body.dark-mode .markdown-body h5,
body.dark-mode .markdown-body h6 {
    color: #e2e8f0;
}

body.dark-mode .markdown-body h1 { border-bottom-color: #2d3748; }
body.dark-mode .markdown-body h2 { border-bottom-color: #2d3748; }

body.dark-mode .markdown-body blockquote {
    background-color: rgba(255,255,255,0.05);
    color: #cbd5e1;
    border-left-color: var(--primary, #43d477);
}

body.dark-mode .markdown-body table th,
body.dark-mode .markdown-body table td {
    border-color: #2d3748;
}

body.dark-mode .markdown-body table th {
    background-color: rgba(255,255,255,0.08);
    color: #e2e8f0;
}

body.dark-mode .markdown-body table tr:nth-child(even) td {
    background-color: rgba(255,255,255,0.03);
}

body.dark-mode .markdown-body code {
    background-color: rgba(255,255,255,0.1);
    color: #f87171;
}

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

body.dark-mode .markdown-body a:hover {
    color: var(--primary, #43d477);
}

body.dark-mode .markdown-body .mermaid-container,
body.dark-mode .markdown-body pre.mermaid,
body.dark-mode .markdown-body div.mermaid {
    background-color: rgba(255,255,255,0.05);
    border-color: #2d3748;
}

/* Syntax Highlighting overrides */
.markdown-body pre[class*="language-"] {
    position: relative;
    padding: 16px 20px;
    border-radius: 8px;
}

/* EasyMDE Preview Support for Mermaid & Math */
.editor-preview .mermaid,
.editor-preview-side .mermaid {
    display: flex;
    justify-content: center;
    background: #fff;
    padding: 12px;
    margin: 12px 0;
    border: 1px solid #edf2f7;
    border-radius: 6px;
}

/* EasyMDE Preview list styles (global reset strips them — !important needed to win) */
.editor-preview ul,
.editor-preview-side ul {
    list-style-type: disc !important;
    padding-left: 24px !important;
    margin-bottom: 14px !important;
}

.editor-preview ol,
.editor-preview-side ol {
    list-style-type: decimal !important;
    padding-left: 24px !important;
    margin-bottom: 14px !important;
}

.editor-preview li,
.editor-preview-side li {
    display: list-item !important;
    list-style: inherit !important;
    margin-bottom: 6px !important;
}

/* Nested list markers in preview */
.editor-preview ul ul,
.editor-preview-side ul ul { list-style-type: circle !important; }
.editor-preview ul ul ul,
.editor-preview-side ul ul ul { list-style-type: square !important; }
.editor-preview ol ol,
.editor-preview-side ol ol { list-style-type: lower-alpha !important; }
.editor-preview ol ol ol,
.editor-preview-side ol ol ol { list-style-type: lower-roman !important; }

.editor-preview .katex-display,
.editor-preview-side .katex-display {
    overflow-x: auto;
    padding: 8px 0;
}

/* EasyMDE Toolbar & Editor Refinements */

/* Space between label and editor wrapper */
.form-group:has(.EasyMDEContainer) {
    padding-top: 14px;
}

.content-summernote:has(.EasyMDEContainer),
.form-group .content-summernote .EasyMDEContainer {
    margin-top: 0 !important;
}

.EasyMDEContainer {
    position: relative;
    z-index: 1;
}

.EasyMDEContainer .editor-toolbar {
    opacity: 1 !important;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
    padding: 6px 8px;
}

.EasyMDEContainer .editor-toolbar button {
    color: #475569 !important;
    border-radius: 4px;
    margin: 2px 1px;
    width: 30px;
    height: 30px;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
    background: #e2e8f0;
    color: #0f172a !important;
    border-color: #cbd5e1;
}

.EasyMDEContainer .CodeMirror {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border: 1px solid #e2e8f0;
    border-top: none;
    font-size: 14px;
    line-height: 1.6;
    background: #ffffff;
}

.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
    background: #ffffff;
    padding: 16px 20px;
}

/* ── Fullscreen: sit above everything, clean toolbar ── */
.EasyMDEContainer .editor-toolbar.fullscreen {
    z-index: 99999 !important;
    opacity: 1 !important;
    background: #fff;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0;
    padding: 10px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.EasyMDEContainer .CodeMirror-fullscreen {
    z-index: 99999 !important;
    border: none;
    border-radius: 0;
    background: #fff;
}

/* ── Side-by-side: fix preview to right half ── */
.editor-preview-side {
    z-index: 99999 !important;
    left: auto !important;
    right: 0 !important;
}

.EasyMDEContainer .editor-preview-side.editor-preview-active-side {
    border-left: 1px solid #e2e8f0;
    background: #fafbfc;
    padding: 20px 24px;
    font-size: 15px;
    line-height: 1.65;
}

/* Side-by-side editor half: visual separator */
.EasyMDEContainer .CodeMirror-sided.CodeMirror-fullscreen {
    border-right: 1px solid #e2e8f0;
}


