/* Mermaid 图表可视化 - 前台样式 */
.em-mermaid-box {
    position: relative;
    margin: 1.2em auto;
    padding: 12px 12px 8px;
    border: 1px solid #e3e6eb;
    border-radius: 6px;
    background: #fcfcfd;
    overflow: hidden;
}

.em-mermaid-box.is-error {
    border-color: #e0b4b4;
    background: #fdf7f7;
}

.em-mermaid-bar {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 6px;
    opacity: 0;
    transition: opacity .2s ease;
}

.em-mermaid-box:hover .em-mermaid-bar,
.em-mermaid-box:focus-within .em-mermaid-bar {
    opacity: 1;
}

.em-mermaid-btn {
    padding: 2px 10px;
    font-size: 12px;
    line-height: 1.6;
    color: #5b6472;
    background: #fff;
    border: 1px solid #d8dce3;
    border-radius: 4px;
    cursor: pointer;
}

.em-mermaid-btn:hover,
.em-mermaid-btn:focus {
    color: #2f7a5b;
    border-color: #2f7a5b;
    outline: none;
}

.em-mermaid-graph {
    overflow-x: auto;
    text-align: center;
}

.em-mermaid-graph svg {
    max-width: 100%;
    height: auto;
}

.em-mermaid-source {
    margin: 8px 0 0;
    padding: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: #3d4450;
    background: #f4f5f7;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    text-align: left;
}

.em-mermaid-tip {
    margin: 0 0 6px;
    font-size: 13px;
    color: #a2554f;
}

/* 放大查看层 */
.em-mermaid-modal {
    position: fixed;
    inset: 0;
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(28, 32, 38, .72);
}

.em-mermaid-modal[hidden] {
    display: none;
}

.em-mermaid-modal-body {
    max-width: 96vw;
    max-height: 92vh;
    padding: 16px;
    overflow: auto;
    background: #fff;
    border-radius: 6px;
}

.em-mermaid-modal-body svg {
    max-width: none;
}

.em-mermaid-modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 34px;
    height: 34px;
    font-size: 20px;
    line-height: 1;
    color: #fff;
    background: transparent;
    border: 0;
    cursor: pointer;
}

@media (max-width: 640px) {
    .em-mermaid-box {
        max-width: 100% !important;
        padding: 8px;
    }

    .em-mermaid-bar {
        opacity: 1;
    }
}
