.article-mermaid {
    width: 100%;
    max-width: 100%;
    margin: 28px 0;
    padding: 22px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
}

.article-mermaid-stage {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    color: #64748b;
    text-align: center;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    -webkit-overflow-scrolling: touch;
}

.article-mermaid-stage svg {
    display: block;
    width: auto;
    min-width: min-content;
    height: auto;
    margin: 0 auto;
}

.article-mermaid.is-loading .article-mermaid-stage {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.article-mermaid.is-error {
    border-color: #fecaca;
    background: #fff7f7;
}

.article-mermaid.is-error .article-mermaid-stage {
    margin-bottom: 12px;
    color: #b91c1c;
}

.article-mermaid.is-error pre {
    margin: 0 !important;
    text-align: left;
}

:root[data-blog-theme="dark"] .article-mermaid {
    border-color: #334155;
    background: #172131;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
}

:root[data-blog-theme="dark"] .article-mermaid-stage {
    color: #94a3b8;
    scrollbar-color: #475569 transparent;
}

:root[data-blog-theme="dark"] .article-mermaid.is-error {
    border-color: #7f1d1d;
    background: #24191f;
}

:root[data-blog-theme="dark"] .article-mermaid.is-error .article-mermaid-stage {
    color: #fca5a5;
}

@media (max-width: 768px) {
    .article-mermaid {
        margin: 22px 0;
        padding: 14px 10px;
        border-radius: 12px;
    }

    .article-mermaid-stage {
        text-align: left;
    }

    .article-mermaid-stage svg {
        margin: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .article-mermaid,
    .article-mermaid * {
        scroll-behavior: auto !important;
        animation: none !important;
        transition: none !important;
    }
}
