﻿/* ===== 暗黑模式变量 ===== */
:root {
    --md-text: #24292e;
    --md-text-light: #6a737d;
    --md-border: #eaecef;
    --md-border-light: #dfe2e5;
    --md-bg-code: #f6f8fa;
    --md-bg-table: #ffffff;
    --md-bg-table-alt: #f6f8fa;
    --md-link: #0366d6;
    --sidebar-text: #333333;
    --sidebar-active: #2470dc;
    --navbar-bg: #343a40;
    --navbar-text: #ffffff;
    --dropdown-bg: #ffffff;
    --dropdown-text: #333333;
}

@media (prefers-color-scheme: dark) {
    :root {
        --md-text: #c9d1d9;
        --md-text-light: #8b949e;
        --md-border: #21262d;
        --md-border-light: #30363d;
        --md-bg-code: #161b22;
        --md-bg-table: #0d1117;
        --md-bg-table-alt: #161b22;
        --md-link: #58a6ff;
        --sidebar-text: #c9d1d9;
        --sidebar-active: #58a6ff;
        --navbar-bg: #1f1f1f;
        --navbar-text: #e1e9f0;
        --dropdown-bg: #212529;
        --dropdown-text: #c9d1d9;
    }
}

/* ===== 整体样式 ===== */
.md {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    line-height: 1.6;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    color: var(--md-text);
    overflow-wrap: break-word;
}

/* 标题锚点定位时避开吸顶导航 */
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
    scroll-margin-top: 5rem;
}

    /* 标题样式 */
    .md h1, .md h2, .md h3, .md h4, .md h5, .md h6 {
        font-weight: 600;
        margin-top: 24px;
        margin-bottom: 16px;
        line-height: 1.25;
        color: var(--md-text);
    }

    .md h1 {
        font-size: 2em;
        border-bottom: 1px solid var(--md-border);
        padding-bottom: 0.3em;
    }

    .md h2 {
        font-size: 1.5em;
        border-bottom: 1px solid var(--md-border);
        padding-bottom: 0.3em;
    }

    .md h3 {
        font-size: 1.25em;
    }

    .md h4 {
        font-size: 1em;
    }

    .md h5 {
        font-size: 0.875em;
    }

    .md h6 {
        font-size: 0.85em;
        color: var(--md-text-light);
    }

    /* 段落样式 */
    .md p {
        margin-bottom: 16px;
        text-indent: 2em;
    }

    /* 链接样式 */
    .md a {
        color: var(--md-link);
        text-decoration: none;
    }

        .md a:hover {
            text-decoration: underline;
        }

    /* 列表样式 */
    .md ul, .md ol {
        padding-left: 2em;
        margin-bottom: 16px;
    }

    .md li {
        margin-bottom: 4px;
    }

    /* 代码块样式 */
    .md pre {
        background-color: var(--md-bg-code);
        border-radius: 3px;
        font-size: 85%;
        line-height: 1.45;
        overflow: auto;
        max-width: 100%;
        padding: 16px;
        margin-bottom: 16px;
    }

    .md code {
        background-color: rgba(27, 31, 35, 0.05);
        border-radius: 3px;
        font-size: 85%;
        margin: 0;
        padding: 0.2em 0.4em;
    }

@media (prefers-color-scheme: dark) {
    .md code {
        background-color: rgba(110, 118, 129, 0.2);
    }
}

.md pre code {
    background-color: transparent;
    border: 0;
    display: inline;
    line-height: inherit;
    margin: 0;
    max-width: auto;
    overflow: visible;
    padding: 0;
    word-wrap: normal;
}

/* 引用样式 */
.md blockquote {
    border-left: 0.25em solid var(--md-border-light);
    color: var(--md-text-light);
    padding: 0 1em;
    margin-bottom: 16px;
}

/* 表格样式 */
.md table {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin-bottom: 16px;
    width: 100%;
}

    .md table th, .md table td {
        border: 1px solid var(--md-border-light);
        padding: 6px 13px;
    }

    .md table th {
        font-weight: 600;
        color: var(--md-text);
    }

    .md table tr {
        background-color: var(--md-bg-table);
        border-top: 1px solid var(--md-border-light);
    }

        .md table tr:nth-child(2n) {
            background-color: var(--md-bg-table-alt);
        }

/* 图片样式 */
.md img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: var(--md-bg-table);
}

/*
 * Sidebar
 */

.sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    padding: 48px 0 0;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1);
}

@media (max-width: 767.98px) {
    .sidebar {
        top: 5rem;
    }
}

@media (prefers-color-scheme: dark) {
    .sidebar {
        box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.1);
    }
}

.sidebar-sticky {
    height: calc(100vh - 48px);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

    .sidebar-sticky::-webkit-scrollbar {
        width: 6px;
    }

    .sidebar-sticky::-webkit-scrollbar-track {
        background: transparent;
    }

    .sidebar-sticky::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 3px;
    }

        .sidebar-sticky::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

@media (prefers-color-scheme: dark) {
    .sidebar-sticky {
        scrollbar-color: #475569 transparent;
    }

        .sidebar-sticky::-webkit-scrollbar-thumb {
            background: #475569;
        }

            .sidebar-sticky::-webkit-scrollbar-thumb:hover {
                background: #64748b;
            }
}

.sidebar .nav-link {
    font-weight: 500;
    color: var(--sidebar-text);
}

    .sidebar .nav-link i {
        margin-right: 4px;
    }

    .sidebar .nav-link .feather {
        margin-right: 4px;
        color: var(--sidebar-text);
    }

    .sidebar .nav-link.active {
        color: var(--sidebar-active);
    }

        .sidebar .nav-link:hover .feather,
        .sidebar .nav-link.active .feather {
            color: inherit;
        }

.sidebar-heading {
    font-size: .75rem;
    color: var(--md-text-light);
}

/*
 * Navbar
 */

.navbar-brand {
    padding-top: .75rem;
    padding-bottom: .75rem;
    background-color: rgba(0, 0, 0, .25);
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}

@media (prefers-color-scheme: dark) {
    .navbar-brand {
        background-color: rgba(255, 255, 255, 0.1);
        box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.1);
    }
}

.navbar-brand img {
    margin-right: 10px;
}

.navbar .navbar-toggler {
    top: .25rem;
    right: 1rem;
}

.navbar {
    background-color: var(--navbar-bg) !important;
}

    .navbar .form-control {
        height: 56px;
        line-height: 43px;
    }

        .navbar .form-control > a {
            text-decoration: none;
            color: var(--navbar-text);
            margin: 20px;
        }

        .navbar .form-control .dropdown-menu {
            background-color: var(--dropdown-bg);
        }

            .navbar .form-control .dropdown-menu a {
                color: var(--dropdown-text);
            }

        .navbar .form-control a:hover {
            text-decoration: underline;
        }

.form-control-dark {
    color: var(--navbar-text);
    background-color: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .1);
}

    .form-control-dark:focus {
        border-color: transparent;
        box-shadow: 0 0 0 3px rgba(255, 255, 255, .25);
    }

/* 暗黑模式下的 navbar toggler 图标 */
@media (prefers-color-scheme: dark) {
    .navbar-toggler-icon {
        filter: invert(1);
    }
}

/* 暗黑模式下强制设置背景 */
@media (prefers-color-scheme: dark) {
    body,
    .container-fluid,
    .row,
    main,
    .col-md-9,
    .col-lg-10,
    .px-md-4 {
        background-color: #0f172a !important;
    }

    .sidebar {
        background-color: #1e293b !important;
    }
}
