/* 基础通用样式（明暗共用） */
.markdown-body {
    box-sizing: border-box;
    margin: 0 auto;
    padding: 1rem;
    line-height: 1.7;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow-wrap: break-word;
}
@media (max-width: 768px) {
    .markdown-body {
        padding: 1.2rem 1.5rem;
        margin: 1rem;
    }
}

/* 标题通用 */
.markdown-body h1 {
    font-size: 2rem;
    padding-bottom: 0.5rem;
    margin: 1.6rem 0 1rem;
}
.markdown-body h2 {
    font-size: 1.6rem;
    border-left: 4px solid #42b983;
    padding-left: 0.8rem;
    margin: 1.4rem 0 0.8rem;
}
.markdown-body h3 {
    font-size: 1.35rem;
    margin: 1.2rem 0 0.7rem;
}
.markdown-body h4,.markdown-body h5,.markdown-body h6 {
    font-size: 1.15rem;
    margin: 1rem 0 0.6rem;
}

.markdown-body p { margin: 0.8rem 0; font-size: 1rem; }
.markdown-body ul,.markdown-body ol { margin: 0.8rem 0; padding-left: 1.8rem; }
.markdown-body li { margin: 0.4rem 0; }
.markdown-body a { text-decoration: none; border-bottom:1px solid transparent; transition:0.2s; }
.markdown-body a:hover { border-color: currentColor; }

/* 行内代码 */
.markdown-body code {
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: Consolas,Monaco,monospace;
    font-size: 0.9rem;
}
/* 代码块 */
.markdown-body pre {
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}
.markdown-body pre code { background: none; padding:0; }

/* 引用 */
.markdown-body blockquote {
    border-left:4px solid #42b983;
    padding:0.8rem 1rem;
    margin:1rem 0;
    font-style: italic;
}

/* 表格 */
.markdown-body table { width:100%; border-collapse:collapse; margin:1rem 0; }
.markdown-body th,.markdown-body td { padding:0.6rem 1rem; text-align:left; }
.markdown-body img { max-width:100%; border-radius:6px; margin:0.5rem 0; }
.markdown-body hr { height:1px; border:none; margin:1.5rem 0; }


/* ========== 明亮默认（无.dark） ========== */
.markdown-body {
    background:#fff;
    box-shadow:0 2px 12px rgba(0,0,0,.06);
    color:#333;
}
.markdown-body h1 { border-bottom:2px solid #eaecef; color:#222; }
.markdown-body h2,.markdown-body h3,.markdown-body h4,.markdown-body h5,.markdown-body h6 { color:#222; }
.markdown-body a { color:#42b983; }
.markdown-body code { background:#f6f8fa; color:#e53935; }
.markdown-body pre { background:#f6f8fa; }
.markdown-body pre code { color:#333; }
.markdown-body blockquote { background:#f9fff9; color:#555; }
.markdown-body th,.markdown-body td { border:1px solid #eaecef; }
.markdown-body th { background:#f6f8fa; }
.markdown-body hr { background:#eaecef; }
.markdown-body img { box-shadow:0 1px 6px rgba(0,0,0,.05); }


/* ========== 暗黑主题（父级增加 .dark 类） ========== */
.dark .markdown-body {
    background:#1e1e1e;
    box-shadow:0 2px 12px rgba(0,0,0,.25);
    color:#d4d4d4;
}
.dark .markdown-body h1 { border-bottom-color:#3a3a3a; color:#fff; }
.dark .markdown-body h2,.dark .markdown-body h3,.dark .markdown-body h4,.dark .markdown-body h5,.dark .markdown-body h6 { color:#fff; }
.dark .markdown-body h2 { border-left-color:#4ec9b0; }
.dark .markdown-body a { color:#4ec9b0; }
.dark .markdown-body code { background:#2d2d30; color:#ce9178; }
.dark .markdown-body pre { background:#2d2d30; }
.dark .markdown-body pre code { color:#ddd; }
.dark .markdown-body blockquote { border-left-color:#4ec9b0; background:#252525; color:#aaa; }
.dark .markdown-body th,.dark .markdown-body td { border:1px solid #3c3c3c; }
.dark .markdown-body th { background:#2d2d30; }
.dark .markdown-body hr { background:#3a3a3a; }

/* ========== Markdown 写作 ========== */
.markdown-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    border: 1px solid #e6e6e6;
    border-bottom: 0;
    background: #f8f8f8;
}
.markdown-toolbar .layui-btn {
    margin: 0 !important;
    line-height: 22px;
    height: 24px;
    padding: 0 8px;
}
.markdown-lang {
    height: 28px;
    padding: 0 8px;
    border: 1px solid #e6e6e6;
    border-radius: 2px;
    background: #fff;
    color: #333;
}
.markdown-editor {
    min-height: 520px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    font-size: 14px;
    line-height: 1.7;
    border-radius: 0;
}
.markdown-preview {
    min-height: 520px;
    padding: 16px 20px;
    border: 1px solid #e6e6e6;
    border-top: 0;
    background: #fff;
    overflow: auto;
}
.markdown-preview[hidden] { display: none; }

/* ========== 代码块 ========== */
pre.code-block {
    position: relative;
    padding-top: 46px !important;
}
.code-toolbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid rgba(128,128,128,.2);
    font-size: 12px;
    color: #888;
}
.code-lang { text-transform: uppercase; letter-spacing: .05em; }
.code-copy {
    border: 0;
    background: transparent;
    color: #42b983;
    cursor: pointer;
    font-size: 12px;
}
.code-copy:hover { text-decoration: underline; }
.hljs-comment { color: #6a9955; font-style: italic; }
.hljs-string { color: #ce9178; }
.hljs-keyword { color: #c586c0; font-weight: 600; }
.hljs-number { color: #b5cea8; }
.hljs-meta { color: #dcdcaa; }
.hljs-variable { color: #9cdcfe; }
.hljs-function { color: #dcdcaa; }

html[data-theme="dark"] pre.code-block,
.dark pre.code-block,
.layui-theme-dark pre.code-block { background: #2d2d30; }
html[data-theme="dark"] .code-toolbar,
.dark .code-toolbar,
.layui-theme-dark .code-toolbar { border-bottom-color: rgba(255,255,255,.12); color: #aaa; }

/* ========== 文章编辑页 ========== */
.post-editor-page {
    padding: 24px 28px 36px;
    background: #f5f7fb;
    min-height: 100%;
}
.post-form-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}
.post-form-head h2 {
    margin: 4px 0 6px;
    font-size: 22px;
    font-weight: 650;
    color: #1f2329;
}
.post-form-head p {
    margin: 0;
    font-size: 13px;
    color: #8a909c;
}
.post-kicker {
    font-size: 12px;
    letter-spacing: .06em;
    color: #1e9fff;
}
.post-head-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.post-head-actions .layui-btn {
    height: 36px;
    line-height: 36px;
    padding: 0 20px;
    border-radius: 8px;
}
.post-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 18px;
    align-items: start;
}
.post-card {
    background: #fff;
    border: 1px solid #edf0f5;
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 4px 18px rgba(31,35,41,.04);
}
.post-card-title {
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 650;
    color: #1f2329;
    margin-bottom: 20px;
    padding-left: 10px;
    border-left: 3px solid #1e9fff;
    line-height: 18px;
}
.post-card-subtitle {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 24px 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2329;
}
.post-tip {
    font-size: 12px;
    font-weight: 400;
    color: #9aa0aa;
}
.post-field { margin-bottom: 16px; }
.post-field-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #9aa0aa;
}
.post-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #4e5969;
}
.post-label.required::before {
    content: "*";
    color: #ff5722;
    margin-right: 4px;
}
.post-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.post-form .layui-input,
.post-form .layui-select,
.post-form .layui-textarea {
    border-radius: 8px;
    border-color: #e5e8ee;
}
.post-form .post-title {
    height: 44px;
    line-height: 44px;
    font-size: 16px;
}
.post-form .layui-textarea { min-height: 84px; }
.post-upload .layuimini-upload-btn {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}
.post-upload .layuimini-upload-show { margin-top: 8px; }
.post-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-top: 1px solid #f0f2f5;
}
.post-switch-row .post-label { margin-bottom: 2px; }
.post-switch-hint {
    font-size: 12px;
    color: #9aa0aa;
}
.post-editor-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: #f7f9fc;
    border-radius: 8px;
}
.post-editor-bar .layui-btn { margin: 0 !important; }
.post-editor-bar span {
    font-size: 12px;
    color: #9aa0aa;
}
.post-card #edui1 {
    border: 1px solid #e5e8ee;
    border-radius: 8px;
    overflow: hidden;
}
@media (max-width: 900px) {
    .post-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .post-editor-page { padding: 16px; }
    .post-form-head { flex-direction: column; align-items: flex-start; }
    .post-row { grid-template-columns: 1fr; }
}

/* ========== 文档阅读页 ========== */
.doc-page {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 24px;
    max-width: 1240px;
    margin: 0 auto;
    padding: 32px 24px 48px;
    align-items: start;
}
.doc-toc {
    position: sticky;
    top: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid #eef0f5;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 18px rgba(31,35,41,.04);
}
.doc-toc-title {
    font-size: 12px;
    letter-spacing: .08em;
    color: #1e9fff;
    text-transform: uppercase;
}
.doc-toc-book {
    margin: 6px 0 16px;
    font-size: 18px;
    font-weight: 650;
    color: #1f2329;
}
.doc-toc-chapter {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 16px 0 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7f9fc;
    font-size: 13px;
    font-weight: 600;
    color: #1f2329;
}
.doc-toc-chapter small,
.doc-toc-section small { color: #9aa0aa; font-weight: 400; }
.doc-toc-section {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    color: #4e5969;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.doc-toc-section:hover { background: #f7f9fc; color: #1e9fff; }
.doc-toc-section.active { background: #eaf4ff; color: #1e9fff; font-weight: 600; }
.doc-article {
    min-width: 0;
    background: #fff;
    border: 1px solid #eef0f5;
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 4px 18px rgba(31,35,41,.04);
}
.doc-breadcrumb { font-size: 13px; color: #9aa0aa; margin-bottom: 14px; }
.doc-breadcrumb a { color: #1e9fff; text-decoration: none; }
.doc-article h1 { font-size: 28px; line-height: 1.35; margin: 0 0 14px; color: #1f2329; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: #9aa0aa; padding-bottom: 18px; border-bottom: 1px solid #f0f2f5; }
.doc-content { padding-top: 22px; font-size: 15px; line-height: 1.9; }
.doc-content h2 { font-size: 22px; margin: 28px 0 12px; }
.doc-content h3 { font-size: 18px; margin: 22px 0 10px; }
.doc-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 36px; padding-top: 20px; border-top: 1px solid #f0f2f5; }
.doc-nav a { padding: 12px 16px; border-radius: 10px; background: #f7f9fc; color: #4e5969; text-decoration: none; }
.doc-nav a:hover { color: #1e9fff; }
.doc-nav span { display: block; font-size: 12px; color: #9aa0aa; margin-bottom: 4px; }
@media (max-width: 900px) {
    .doc-page { grid-template-columns: 1fr; padding: 20px 16px 36px; }
    .doc-toc { position: static; max-height: none; }
    .doc-article { padding: 22px; }
}
html[data-theme="dark"] .doc-toc,
html[data-theme="dark"] .doc-article { background: #1e1e1e; border-color: #333; }
html[data-theme="dark"] .doc-toc-book,
html[data-theme="dark"] .doc-article h1 { color: #e5e5e5; }
html[data-theme="dark"] .doc-toc-chapter { background: #2d2d30; color: #ddd; }
html[data-theme="dark"] .doc-toc-section { color: #bbb; }
html[data-theme="dark"] .doc-toc-section.active { background: #2d3f55; color: #6cb4ff; }
html[data-theme="dark"] .doc-meta { border-bottom-color: #333; }
html[data-theme="dark"] .doc-nav a { background: #2d2d30; color: #bbb; }

/* ========== 后台文档录入页 ========== */
.doc-editor-page {
    padding: 24px 28px 36px;
    background: #f5f7fb;
    min-height: 100%;
}
.doc-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 18px;
}
.doc-editor-head h2 {
    margin: 4px 0 6px;
    font-size: 22px;
    font-weight: 650;
    color: #1f2329;
}
.doc-editor-head p { margin: 0; font-size: 13px; color: #8a909c; }
.doc-editor-actions { display: flex; gap: 8px; flex-shrink: 0; }
.doc-editor-actions .layui-btn { margin: 0 !important; }
.doc-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #edf0f5;
    border-radius: 12px;
    margin-bottom: 18px;
}
.doc-editor-toolbar label { font-size: 13px; color: #4e5969; }
.doc-editor-toolbar select { min-width: 220px; height: 34px; border: 1px solid #e5e8ee; border-radius: 8px; padding: 0 10px; }
.doc-editor-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.doc-editor-toc,
.doc-editor-main {
    background: #fff;
    border: 1px solid #edf0f5;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 18px rgba(31,35,41,.04);
}
.doc-editor-toc { max-height: calc(100vh - 210px); overflow-y: auto; }
.doc-editor-chapter {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 14px 0 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7f9fc;
    font-size: 13px;
    font-weight: 600;
    color: #1f2329;
}
.doc-editor-chapter small, .doc-editor-section small { color: #9aa0aa; font-weight: 400; }
.doc-editor-section {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    color: #4e5969;
    text-decoration: none;
}
.doc-editor-section:hover { background: #f7f9fc; color: #1e9fff; }
.doc-editor-section.active { background: #eaf4ff; color: #1e9fff; font-weight: 600; }
.doc-editor-form-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 110px 110px 110px;
    gap: 12px;
}
.doc-editor-save {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 12px;
}
.doc-editor-save .layui-btn { margin: 0 !important; }
.doc-editor-save span { font-size: 12px; color: #9aa0aa; }
.doc-empty { padding: 40px; text-align: center; color: #9aa0aa; background: #fff; border-radius: 14px; }
@media (max-width: 1000px) {
    .doc-editor-grid { grid-template-columns: 1fr; }
    .doc-editor-form-row { grid-template-columns: 1fr 1fr; }
}
.doc-editor-list { display: flex; flex-direction: column; gap: 18px; }
.doc-chapter-card {
    background: #fff;
    border: 1px solid #edf0f5;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 4px 18px rgba(31,35,41,.04);
}
.doc-chapter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f0f2f5;
}
.doc-chapter-head > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.doc-chapter-head h3 { margin: 0; font-size: 16px; font-weight: 650; color: #1f2329; }
.doc-chapter-head small { font-size: 12px; color: #9aa0aa; flex-shrink: 0; }
.doc-chapter-no {
    display: inline-flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #eaf4ff;
    color: #1e9fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}
.doc-section-card {
    margin-top: 14px;
    padding: 16px;
    background: #fafbfc;
    border: 1px solid #eef0f4;
    border-radius: 12px;
}
.doc-section-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 100px 100px 100px;
    gap: 12px;
}
.doc-section-actions {
    display: flex;
    gap: 10px;
    padding-top: 10px;
}
.doc-section-actions .layui-btn { margin: 0 !important; }
.doc-inline-add { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.doc-editor-actions .layui-input { height: 36px; }
.post-section-link {
    padding: 14px 16px 6px;
    margin-bottom: 18px;
    border: 1px solid #e8f2ff;
    border-radius: 12px;
    background: #f7fbff;
}
.post-section-link-title {
    font-size: 14px;
    font-weight: 650;
    color: #1e9fff;
    margin-bottom: 4px;
}
.post-row-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .post-row-three { grid-template-columns: 1fr; } }
@media (max-width: 1000px) {
    .doc-section-fields { grid-template-columns: 1fr 1fr; }
}