/* ============ Markdown 编辑器：md-* ============ */

/* ---------- Hero ---------- */
.md-hero {
    margin: 18px 0 26px;
    padding: 22px;
    background: linear-gradient(135deg, #eef4ff 0%, #f6f9ff 55%, #fff8f6 100%);
    border: 1px solid #e2e8f6;
    border-radius: 18px;
}
.md-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.md-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.md-logo {
    width: 46px;
    height: 46px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(43, 98, 217, .18);
}
.md-title { font-size: 20px; font-weight: 800; color: #1f2b45; letter-spacing: .3px; }
.md-tagline { font-size: 13px; color: #6b7a96; margin-top: 2px; }
.md-privacy {
    font-size: 12px;
    color: #2f7d55;
    background: #e8f7ef;
    border: 1px solid #c6ead8;
    border-radius: 999px;
    padding: 6px 12px;
    white-space: nowrap;
}

/* ---------- 工具栏 ---------- */
.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: #fff;
    border: 1px solid #e3e8f1;
    border-radius: 10px;
    padding: 6px;
    margin-bottom: 12px;
}
.md-tb {
    border: 1px solid transparent;
    background: transparent;
    border-radius: 7px;
    padding: 5px 9px;
    font-size: 13px;
    color: #4a587a;
    cursor: pointer;
    min-width: 30px;
    transition: background .15s, color .15s;
}
.md-tb:hover { background: #eef3fc; color: #2b62d9; }
.md-tb b { font-weight: 700; }
.md-tb-sep { width: 1px; background: #e3e8f1; margin: 4px 2px; }

/* ---------- 主区 ----------
   宽屏：大纲(左) | 编辑(中) | 预览(右，最右侧)
   中屏：编辑(左) | 预览(右)，隐藏大纲
   窄屏：上下堆叠
------------------------------------------------ */
.md-wrap { display: grid; gap: 12px; align-items: start; }

.md-view-split.md-wrap { grid-template-columns: 176px minmax(0, 1fr) minmax(0, 1.15fr); }
.md-wrap.md-view-split .md-toc-box { order: 1; }
.md-wrap.md-view-split .md-input-pane { order: 2; }
.md-wrap.md-view-split .md-preview-pane { order: 3; }

.md-view-preview.md-wrap { grid-template-columns: minmax(0, 1fr) 176px; }
.md-wrap.md-view-preview .md-input-pane { display: none; }
.md-wrap.md-view-preview .md-preview-pane { order: 1; }
.md-wrap.md-view-preview .md-toc-box { order: 2; }

.md-view-edit.md-wrap { grid-template-columns: 1fr; }
.md-wrap.md-view-edit .md-preview-pane,
.md-wrap.md-view-edit .md-toc-box { display: none; }

@media (max-width: 1080px) {
    .md-view-split.md-wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .md-wrap.md-view-split .md-toc-box { display: none; }
    .md-wrap.md-view-split .md-input-pane { order: 1; }
    .md-wrap.md-view-split .md-preview-pane { order: 2; }

    .md-view-preview.md-wrap { grid-template-columns: 1fr; }
    .md-wrap.md-view-preview .md-toc-box { display: none; }
}
@media (max-width: 760px) {
    .md-view-split.md-wrap { grid-template-columns: 1fr; }
    .md-wrap.md-view-split .md-input-pane { order: 1; }
    .md-wrap.md-view-split .md-preview-pane { order: 2; }
}

.md-input-pane, .md-preview-pane, .md-toc-box {
    background: #fff;
    border: 1px solid #e3e8f1;
    border-radius: 12px;
    overflow: hidden;
}
.md-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 12px;
    background: #f7faff;
    border-bottom: 1px solid #e3e8f1;
    font-size: 12px;
    color: #6b7a96;
}
.md-pane-tip { color: #8a94ab; font-size: 11.5px; }
.md-input {
    width: 100%;
    min-height: 560px;
    border: 0;
    outline: none;
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.85;
    color: #1a2b4a;
    font-family: ui-monospace, Consolas, "Courier New", monospace;
    resize: vertical;
    display: block;
}
.md-preview-pane { max-height: 620px; overflow-y: auto; }
.md-preview { padding: 18px 20px; }

/* ---------- 大纲 ---------- */
.md-toc-box { padding: 12px; max-height: 620px; overflow-y: auto; }
.md-toc-title { font-size: 12px; color: #8a94ab; margin-bottom: 8px; }
.md-toc { display: flex; flex-direction: column; gap: 2px; }
.md-toc-item {
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 12.5px;
    color: #4a587a;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.md-toc-item:hover { background: #eef3fc; color: #2b62d9; }
.md-toc-l1 { font-weight: 600; }
.md-toc-l2 { padding-left: 14px; }
.md-toc-l3 { padding-left: 26px; font-size: 12px; }
.md-toc-l4, .md-toc-l5, .md-toc-l6 { padding-left: 38px; font-size: 12px; }
.md-toc-empty, .md-placeholder { color: #b9c6dc; font-size: 13px; }

/* ---------- 操作区 ---------- */
.md-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 12px;
}
.md-btn {
    border: 1px solid #c5d1e3;
    background: #fff;
    color: #1a2b4a;
    padding: 8px 14px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}
.md-btn:hover { background: #f7faff; border-color: #2b62d9; }
.md-btn.primary { background: #2b62d9; color: #fff; border-color: #2b62d9; }
.md-btn.primary:hover { background: #1e4cb8; border-color: #1e4cb8; }
.md-select {
    border: 1px solid #c5d1e3;
    border-radius: 9px;
    padding: 8px 10px;
    font-size: 13px;
    color: #1a2b4a;
    background: #fff;
    outline: none;
}
.md-seg { display: flex; gap: 4px; background: #eef3fc; border-radius: 10px; padding: 4px; }
.md-seg-btn {
    border: 0;
    background: transparent;
    padding: 6px 10px;
    font-size: 12.5px;
    color: #4a587a;
    border-radius: 7px;
    cursor: pointer;
}
.md-seg-btn.active { background: #fff; color: #1a2b4a; font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.md-check { display: flex; align-items: center; gap: 6px; color: #4a587a; font-size: 13px; cursor: pointer; }
.md-check input { accent-color: #2b62d9; }
.md-stats { color: #6b7a96; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.md-status { margin-top: 10px; color: #4a587a; font-size: 13px; }
.md-status.is-ok { color: #2b62d9; }
.md-status.is-warn { color: #c0392b; }

/* ================= 预览正文 ================= */

.md-body { font-size: 15px; line-height: 1.75; word-wrap: break-word; }
.md-body > *:first-child { margin-top: 0; }
.md-body h1, .md-body h2, .md-body h3,
.md-body h4, .md-body h5, .md-body h6 {
    margin: 24px 0 14px;
    font-weight: 600;
    line-height: 1.35;
}
.md-body h1 { font-size: 1.9em; }
.md-body h2 { font-size: 1.5em; }
.md-body h3 { font-size: 1.25em; }
.md-body h4 { font-size: 1.1em; }
.md-body h5, .md-body h6 { font-size: 1em; }
.md-body p, .md-body ul, .md-body ol,
.md-body blockquote, .md-body table, .md-body pre { margin: 0 0 14px; }
.md-body ul, .md-body ol { padding-left: 1.6em; }
.md-body li { margin-bottom: 4px; }
.md-body li > ul, .md-body li > ol { margin: 4px 0; }
.md-body img { max-width: 100%; height: auto; border-radius: 4px; }
.md-body hr { border: 0; border-top: 1px solid #d8dee4; margin: 22px 0; }
.md-body table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.md-body th, .md-body td { border: 1px solid #d0d7de; padding: 6px 12px; }
.md-body ul.md-task { list-style: none; padding-left: 1.2em; }
.md-body ul.md-task input { margin-right: 6px; }

/* 主题：GitHub */
.md-theme-github { color: #24292f; background: #fff; }
.md-theme-github h1, .md-theme-github h2 { border-bottom: 1px solid #d8dee4; padding-bottom: .3em; }
.md-theme-github a { color: #0969da; text-decoration: none; }
.md-theme-github a:hover { text-decoration: underline; }
.md-theme-github code {
    background: #eff1f3; padding: .2em .4em; border-radius: 6px; font-size: 86%;
    font-family: ui-monospace, Consolas, monospace;
}
.md-theme-github pre {
    background: #f6f8fa; padding: 14px 16px; border-radius: 6px; overflow-x: auto;
}
.md-theme-github pre code { background: none; padding: 0; }
.md-theme-github blockquote { border-left: .25em solid #d0d7de; padding: 0 1em; color: #57606a; }
.md-theme-github th { background: #f6f8fa; }

/* 主题：经典 */
.md-theme-classic { color: #333; background: #fffdf8; font-size: 16px; line-height: 1.9; }
.md-theme-classic h1 { text-align: center; border: 0; }
.md-theme-classic h2 { border: 0; }
.md-theme-classic a { color: #b45309; }
.md-theme-classic code { background: #f3efe6; padding: .15em .4em; border-radius: 4px; font-size: 88%; font-family: ui-monospace, Consolas, monospace; }
.md-theme-classic pre { background: #f3efe6; padding: 14px 16px; border-radius: 6px; overflow-x: auto; }
.md-theme-classic pre code { background: none; padding: 0; }
.md-theme-classic blockquote { border-left: 3px solid #d6c6a8; padding: 2px 1em; color: #6b6151; }
.md-theme-classic th { background: #f3efe6; }
.md-theme-classic th, .md-theme-classic td { border-color: #e3d9c6; }
.md-theme-classic hr { border-top: 1px dashed #d6c6a8; }

/* 主题：暗色 */
.md-theme-dark { color: #c9d1d9; background: #0d1117; }
.md-theme-dark h1, .md-theme-dark h2, .md-theme-dark h3,
.md-theme-dark h4, .md-theme-dark h5, .md-theme-dark h6 { color: #e6edf3; }
.md-theme-dark h1, .md-theme-dark h2 { border-bottom: 1px solid #30363d; padding-bottom: .3em; }
.md-theme-dark a { color: #58a6ff; }
.md-theme-dark code { background: #161b22; padding: .2em .4em; border-radius: 6px; font-size: 86%; font-family: ui-monospace, Consolas, monospace; }
.md-theme-dark pre { background: #161b22; padding: 14px 16px; border-radius: 6px; overflow-x: auto; }
.md-theme-dark pre code { background: none; padding: 0; }
.md-theme-dark blockquote { border-left: .25em solid #30363d; padding: 0 1em; color: #8b949e; }
.md-theme-dark th, .md-theme-dark td { border-color: #30363d; }
.md-theme-dark th { background: #161b22; }
.md-theme-dark hr { border-top-color: #30363d; }

/* ---------- 打印（导出 PDF） ---------- */
@media print {
    body * { visibility: hidden !important; }
    .md-preview, .md-preview * { visibility: visible !important; }
    .md-preview {
        position: absolute !important;
        left: 0;
        top: 0;
        width: 100% !important;
        max-height: none !important;
        overflow: visible !important;
        border: 0 !important;
        padding: 0 !important;
    }
    .md-preview-pane {
        max-height: none !important;
        overflow: visible !important;
        border: 0 !important;
    }
}

/* ---------- 简介块 / 免责 ---------- */
.md-info-block { margin-bottom: 26px; }
.md-info-block .detail-icon {
    --icon-bg: linear-gradient(135deg, #2563eb, #7c3aed);
    --icon-shadow: rgba(37, 99, 235, .3);
}
.md-disclaim {
    margin: 16px 0 0;
    padding: 12px 16px;
    border-radius: 12px;
    background: #fff8ea;
    border: 1px solid #f3e2b8;
    font-size: 12.5px;
    line-height: 1.8;
    color: #8a6516;
}
