/* Chat 页 AI 回复的 markdown 渲染样式, 作用于气泡内的 .md-content 容器 */

.md-content > :first-child { margin-top: 0 }
.md-content > :last-child { margin-bottom: 0 }

.md-content p { margin: 0.5em 0; line-height: 1.7 }

.md-content h1, .md-content h2, .md-content h3, .md-content h4, .md-content h5, .md-content h6 {
    margin: 1em 0 0.4em;
    font-weight: 600;
    line-height: 1.4;
}
.md-content h1 { font-size: 1.35em; padding-bottom: 0.2em; border-bottom: 1px solid #e5e7eb }
.md-content h2 { font-size: 1.2em; padding-bottom: 0.2em; border-bottom: 1px solid #f3f4f6 }
.md-content h3 { font-size: 1.1em }
.md-content h4, .md-content h5, .md-content h6 { font-size: 1em }

.md-content ul, .md-content ol { margin: 0.5em 0; padding-left: 1.5em }
.md-content li { margin: 0.25em 0 }

.md-content code {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 0.1em 0.35em;
    font-size: 0.875em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}
.md-content pre {
    background: #1f2937;
    color: #f9fafb;
    border-radius: 8px;
    padding: 0.75em 1em;
    margin: 0.6em 0;
    overflow-x: auto;
}
.md-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font-size: 0.85em;
}

/* 代码块复制按钮: 悬浮在右上角, hover 代码块时才显示 */
.md-code-wrap { position: relative }
.md-code-wrap pre { padding-top: 1.6em }
.md-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #d1d5db;
    background: rgba(55, 65, 81, 0.9);
    border: 1px solid #4b5563;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    user-select: none;
}
.md-code-wrap:hover .md-copy-btn { opacity: 1 }
.md-copy-btn:hover { color: #f9fafb; border-color: #6b7280 }
.md-copy-btn.md-copied { color: #34d399; border-color: #34d399 }

.md-content blockquote {
    margin: 0.6em 0;
    padding: 0.1em 0.9em;
    border-left: 3px solid #d1d5db;
    background: #f9fafb;
    color: #6b7280;
}

.md-content a { color: #2563eb; text-decoration: underline }
.md-content hr { border: none; border-top: 1px solid #e5e7eb; margin: 1em 0 }
.md-content img { max-width: 100% }

/* 表格: 外层容器横向滚动, 避免宽表格把气泡撑破或挤在一起 */
.md-table-wrap { overflow-x: auto; margin: 0.6em 0 }
.md-content table {
    border-collapse: collapse;
    width: max-content;
    max-width: 100%;
    font-size: 0.9em;
}
.md-content th, .md-content td {
    border: 1px solid #e5e7eb;
    padding: 0.4em 0.75em;
    text-align: left;
    vertical-align: top;
}
.md-content th { background: #f9fafb; font-weight: 600; white-space: nowrap }
.md-content tr:nth-child(even) td { background: #fafafa }
