.em-mermaid-figure {
    margin: 1.25em auto;
    text-align: center;
}

.em-mermaid-figure img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px auto;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 28px rgba(28, 40, 48, 0.08);
}

.em-mermaid-code {
    margin: 1.75em auto;
    padding: 1.2rem 1.1rem;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #3b4a54;
    background: linear-gradient(165deg, #fbfcfb 0%, #f4f7f8 48%, #eef3f1 100%);
    border: 1px solid #d9e3e8;
    border-radius: 14px;
}

.em-mermaid-block {
    --em-mm-bg: linear-gradient(165deg, #fbfcfb 0%, #f4f7f8 48%, #eef3f1 100%);
    --em-mm-border: #d9e3e8;
    --em-mm-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset, 0 10px 30px rgba(28, 40, 48, 0.07);
    margin: 1.75em auto;
    padding: 1.35rem 1.2rem 1.2rem;
    max-width: 100%;
    overflow-x: auto;
    text-align: center;
    background: var(--em-mm-bg);
    border: 1px solid var(--em-mm-border);
    border-radius: 14px;
    box-shadow: var(--em-mm-shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.em-mermaid-block.is-dark {
    --em-mm-bg: linear-gradient(165deg, #1d262d 0%, #1a2229 55%, #182028 100%);
    --em-mm-border: #33424d;
    --em-mm-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(0, 0, 0, 0.28);
}

.em-mermaid-block:hover {
    border-color: #c7d5dc;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 14px 34px rgba(28, 40, 48, 0.09);
}

.em-mermaid-block.is-dark:hover {
    border-color: #425664;
}

.em-mermaid-block .em-mermaid-svg {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 80px;
}

.em-mermaid-block svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 3px 10px rgba(31, 48, 56, 0.05));
}

.em-mermaid-block.is-dark svg {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.25));
}

.em-mermaid-block .node rect,
.em-mermaid-block .node polygon,
.em-mermaid-block .node circle,
.em-mermaid-block .node path {
    filter: drop-shadow(0 2px 4px rgba(36, 54, 62, 0.06));
}

.em-mermaid-block .edgeLabel {
    border-radius: 4px;
}

.em-mermaid-block .actor,
.em-mermaid-block .actor-top,
.em-mermaid-block .actor-bottom {
    filter: drop-shadow(0 2px 5px rgba(36, 54, 62, 0.05));
}

.em-mermaid-source {
    display: none;
    margin: 0;
    padding: 12px 14px;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
    color: #3b4a54;
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed #c7d3de;
    border-radius: 8px;
}

@media (max-width: 640px) {
    .em-mermaid-block {
        padding: 1rem 0.75rem;
        border-radius: 10px;
    }
}
