/* ================================================================
   菜刀客在线工具页 · markdown-editor.html 私有样式
   需在 /css/common.css 之后加载。
   ================================================================ */

.container {
    max-width: 1400px;
}

.footer {
    max-width: 1400px;
}

/* ---- 覆盖公共布局：双栏并排 ---- */
.main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

/* ---- 面板：固定高 + 纵向布局 ---- */
.panel {
    height: 640px;
    display: flex;
    flex-direction: column;
}

.panel .status-bar {
    border-radius: 0;
    flex-shrink: 0;
}

/* ---- 编辑区工具栏 ---- */
.md-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.md-toolbar + .main .panel {
    border-radius: 0;
    border: 1px solid #e5e7eb;
}

.md-toolbar + .main .panel:first-child {
    border-right: none;
}

.md-toolbar .btn {
    padding: 4px 9px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #374151;
    border-radius: 5px;
}

.md-toolbar .btn:hover {
    color: #667eea;
    border-color: #667eea;
    background: #eef2ff;
}

.md-toolbar .btn:active {
    background: #e0e7ff;
    transform: translateY(0);
}

.md-toolbar .sep {
    width: 1px;
    height: 18px;
    background: #e5e7eb;
    margin: 0 3px;
}

.md-toolbar .tool-label {
    font-size: 12px;
    color: #9ca3af;
    margin: 0 4px 0 8px;
}

/* ---- 编辑器 ---- */
.editor-area {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 14px 16px;
    font-family: ui-monospace, SFMono-Regular, Consolas, Menlo, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
    background: #ffffff;
}

/* ---- 预览区 ---- */
.md-preview {
    flex: 1;
    overflow: auto;
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.75;
    color: #333;
    word-break: break-word;
}

.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 {
    color: #374151;
    margin: 1.2em 0 0.6em;
    line-height: 1.35;
}

.md-preview h1 { font-size: 24px; border-bottom: 1px solid #f0f1f3; padding-bottom: 8px; }
.md-preview h2 { font-size: 20px; border-bottom: 1px solid #f0f1f3; padding-bottom: 6px; }
.md-preview h3 { font-size: 17px; }
.md-preview h4 { font-size: 15px; }
.md-preview h5 { font-size: 14px; }
.md-preview h6 { font-size: 13px; color: #6b7280; }

.md-preview p { margin: 0.6em 0; }

.md-preview a {
    color: #667eea;
    text-decoration: none;
}

.md-preview a:hover {
    text-decoration: underline;
}

.md-preview ul, .md-preview ol {
    margin: 0.6em 0;
    padding-left: 24px;
}

.md-preview li { margin: 0.2em 0; }

.md-preview blockquote {
    margin: 0.8em 0;
    padding: 6px 14px;
    border-left: 4px solid #c7d2fe;
    background: #f9fafb;
    color: #4b5563;
    border-radius: 0 6px 6px 0;
}

.md-preview code {
    font-family: ui-monospace, SFMono-Regular, Consolas, Menlo, 'Courier New', monospace;
    font-size: 13px;
    background: #f3f4f6;
    color: #be123c;
    padding: 2px 5px;
    border-radius: 4px;
}

.md-preview pre {
    margin: 0.8em 0;
    padding: 10px 14px 10px 0;
    background: #1e1e1e;
    border: 1px solid #30363d;
    border-radius: 0;
    overflow: auto;
}

.md-preview pre code {
    background: none;
    color: inherit;
    padding: 0;
}

/* ---- 代码块：黑底 + 矩形边框 + 行号 ---- */
.md-preview pre.hljs {
    counter-reset: hljs-ln;
    line-height: 1.3;
}

.md-preview pre.hljs code {
    display: block;
    white-space: pre;
    font-size: 13px;
}

.md-preview .hljs-ln {
    display: block;
    position: relative;
    padding-left: 3em;
    min-height: 1em;
}

.md-preview .hljs-ln:before {
    content: counter(hljs-ln);
    counter-increment: hljs-ln;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2.2em;
    padding-right: 0.6em;
    text-align: right;
    color: #6b7280;
    border-right: 1px solid #30363d;
    user-select: none;
}

.md-preview table {
    border-collapse: collapse;
    margin: 0.8em 0;
    width: 100%;
    font-size: 13px;
}

.md-preview th, .md-preview td {
    border: 1px solid #e5e7eb;
    padding: 7px 12px;
    text-align: left;
}

.md-preview th {
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
}

.md-preview tr:nth-child(even) td {
    background: #fafbff;
}

.md-preview img {
    max-width: 100%;
    border-radius: 6px;
}

.md-preview hr {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 1.4em 0;
}

.md-preview > :first-child {
    margin-top: 0;
}

.md-preview .task-list-item {
    list-style: none;
    margin-left: -24px;
}

.md-preview .task-list-item-checkbox {
    margin-right: 6px;
    accent-color: #667eea;
    vertical-align: -2px;
}


/* ---- 插件说明条 ---- */
.plugin-note {
    margin-top: 15px;
    padding: 10px 15px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    font-size: 12px;
    color: #6b7280;
    line-height: 1.8;
}

.plugin-note b {
    color: #374151;
}

/* ---- 小屏适配：单列纵向 + 放开固定高 ---- */
@media (max-width: 600px) {
    .main {
        grid-template-columns: 1fr;
    }

    .panel {
        height: auto;
    }

    .editor-area {
        min-height: 240px;
    }

    .md-preview {
        height: auto;
        min-height: 240px;
    }

    .md-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .md-toolbar .sep,
    .md-toolbar .tool-label {
        display: none;
    }
}