body {
    width: 60% !important;
    max-width: 95% !important;
    margin: -0.5rem;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 1em;
    line-height: 1.5;
    background-image: url('/images/background.png');
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

/* ================= 强制换行 ================= */
p,
li,
a,
span:not(pre span):not([class]):not([style]),
span.article-meta-title,
code:not(pre code) {
    overflow-wrap: break-word;
    word-break: break-all;
}

/* 文本换行添加连字符 */
main {
    hyphens: auto;
}

/* ================= 滚动条样式 ================= */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-thumb {
    background-color: #999;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:vertical:hover {
    background-color: #666;
}

::-webkit-scrollbar-thumb:vertical:active {
    background-color: #333;
}

::-webkit-scrollbar-button {
    display: none;
}

::-webkit-scrollbar-track {
    background-color: #f1f1f1;
}

/* ================= 菜单栏 ================= */
.menu {
    padding: 0;
    text-align: center;
}

.menu li {
    display: inline-block;
}

.menu a {
    text-decoration: none;
    background: #efefef;
    color: black !important;
    padding: 5px;
    border-radius: 5px;
}

/* ================= 网页基本元素 ================= */

/* 分割线 */
hr {
    border-style: dashed;
    color: #ddd;
}

/* 脚注 */
footer {
    text-align: center;
}

footer a {
    text-decoration: none;
}

/* 超链接 */
a {
    color: #2e59a7;
    text-decoration: none;
    padding: 4px 0;
    position: relative;
}

ol:not([class]):not([style]) a:not([class]):not([style])::before,
ul:not([class]):not([style]) a:not([class]):not([style])::before,
p a:not([class]):not([style]):not(:has(img))::before {
    content: "";
    display: inline-block;
    width: 1rem;
    height: 1rem;
    margin: 0px 2px 2px 0px;
    background-image: url('/images/link.png');
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
}

p a:visited {
    color: #6f94cd;
}

a:not([class]):not([style]):not(:has(img)):hover {
    color: #2e59a7 !important;
    text-decoration: dotted;
    background-color: rgb(220, 199, 225);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 4'%3E%3Cpath fill='none' stroke='%23aed0ee' d='M0 3.5c5 0 5-3 10-3s5 3 10 3 5-3 10-3 5 3 10 3'/%3E%3C/svg%3E") repeat-x 0 100%;
    background-size: 20px auto;
    animation: waveMove 1s infinite linear;
}

@keyframes waveMove {
    from {
        background-position: 0 100%;
    }

    to {
        background-position: -20px 100%;
    }
}

/* 代码块 */
pre {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow-x: auto;
    position: relative;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

/* 嵌入代码块 */
code {
    color: #2c3e50;
    background-color: #f5f6fa;
    font-family: "Maple Mono NF CN", "Fira Code", Consolas, "Lucida Console", "Courier", monospace, "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 1.1rem;
    font-weight: 550;
    margin: 0 0px;
    padding: 1px 6px 1px 6px;
    border-radius: 6px;
    transition: all 0.3s ease;
    z-index: -1;
}

/* 引用 */
blockquote {
    border-left: 4px solid #bdc3c7;
    padding: 1px 15px;
    margin-left: 0px;
    background-color: rgb(250, 250, 250);
    border-radius: 3px;
    line-height: 1.4;
}

/* 列表 */
li p {
    margin: 0;
}

ul:not([class]):not([style]),
ol:not([class]):not([style]) li:not([class]):not([style]) {
    margin-bottom: 0.1rem;
    margin-left: -0.3rem;
}

/* 按键 */
kbd {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 2px 4px;
    color: #333;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* 高亮 */
mark {
    background: #def3d1 !important;
    border-bottom: 0.5px solid #c6c5c5;
    border-radius: 3px;
    padding: 0.2px 0.5px 0.2px 0.5px;
    margin: 0.2px 0.5px 0.2px 0.5px;
}

/* 斜体 */
em {
    color: #57606f;
}

/* 删除 */
del {
    opacity: 0.3;
}

/* 脚注引用样式 */
sup a.footnote-ref {
    background: #aed0ee;
    color: white;
    border-radius: 36%;
    margin: 0.2rem;
    padding: 0.06rem 0.2rem;
    font-size: 0.6em;
    text-decoration: none;
}

/* ================= 表格 ================= */
table {
    margin: auto;
    border-top: 1px solid #666;
    border-bottom: 1px solid #666;
}

table thead th {
    border-bottom: 1px solid #ddd;
}

th,
td {
    padding: 5px;
}

thead,
tfoot,
tr:nth-child(even) {
    background: #eee;
}

/* ================= 图片视频等多媒体 ================= */
img,
.common-markdown-diagram,
iframe,
video {
    max-width: 100%;
}

/* ================= 自动排版图片样式 ================= */
.img-align {
    width: 100%;
    display: flex;
}

.img-align>* {
    flex: 1;
    min-width: 0;
    text-align: center;
    object-fit: contain;
}

/* ================= 标题自动编号 ================= */

h5 {
    font-size: 0.88rem;
}

h6 {
    font-size: 0.8rem;
}

h2::before,
h3::before,
h4::before,
h5::before,
h6::before {
    color: rgb(196, 194, 194);
    font-size: 0.8rem;
    vertical-align: central;
    margin: 0 6px 0 0;
}

body {
    counter-reset: section2;
}

h2 {
    counter-increment: section2;
    counter-reset: section3 section4 section5 section6;
}

h2::before {
    content: counter(section2);
}

h3 {
    counter-increment: section3;
    counter-reset: section4 section5 section6;
}

h3::before {
    content: counter(section2) "." counter(section3);
}

h4 {
    counter-increment: section4;
    counter-reset: section5 section6;
}

h4::before {
    content: counter(section2) "." counter(section3) "." counter(section4);
}

h5 {
    counter-increment: section5;
    counter-reset: section6;
}

h5::before {
    content: counter(section2) "." counter(section3) "." counter(section4) "." counter(section5);
}

h6 {
    counter-increment: section6;
}

h6::before {
    content: counter(section2) "." counter(section3) "." counter(section4) "." counter(section5) "." counter(section6);
}

/* ================= 手机端（< 768px）=================  */
@media (max-width: 768px) {
    body {
        width: 90% !important;
        max-width: 100% !important;
        font-size: 100% !important;
        background-image: none !important;
    }

    .archieve-right-section {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.5rem;
        align-items: center;
    }

    .archieve-list-item {
        margin-left: -1.2rem;
    }

    .code-rendered-diagram {
        max-width: 100% !important;
    }

    /* 分类页排版 */
    .taxonomy-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* 搜索框样式调整 */
    #search-input {
        width: 90% !important;
        padding: 0.8rem;
        font-size: 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        margin-bottom: 1rem;
    }

    /* tags词云调整 */
    #tag-cloud-canvas {
        width: 100% !important;
        margin: 0 auto;
        padding: 0;
        transform-origin: center;
    }

    /* 目录最大宽度限制 */
    .toc-panel {
        max-width: 260px !important;
        max-height: 70vh !important;
    }
}
