:root {
    --light-bg: #ffffff;
    --light-text: #24292f;
    --light-border: #e1e4e8;
    --dark-bg: #0d1117;
    --dark-text: #e6edf3;
    --dark-border: #30363d;
    --link-color: #66ccff;
    --nav-height: 60px;
    --footer-height: 80px;
    --content-max-width: 980px;
    --content-container-width: 760px;
    /* 时间轴配色变量 */
    --tm-axis: #39C5BB;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s, color 0.3s;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--light-bg);
    color: var(--light-text);
    padding-top: var(--nav-height);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

body.dark-mode {
    background-color: var(--dark-bg);
    color: var(--dark-text);
}

/* --- 自定义原生抽屉栏 --- */
.side-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    display: flex;
    visibility: hidden;
    transition: visibility 0.3s;
}

.side-drawer.active {
    visibility: visible;
}

.drawer-content {
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.7));
    padding: 80px 20px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

body.dark-mode .drawer-content {
    background: linear-gradient(to right, rgba(13, 17, 23, 0.98), rgba(13, 17, 23, 0.7));
}

.side-drawer.active .drawer-content {
    transform: translateX(0);
}

.drawer-overlay {
    flex: 1;
    height: 100%;
}

.drawer-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 30px;
    color: inherit;
}

.drawer-links {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.drawer-links a {
    font-size: 1.1rem;
    color: inherit;
    padding: 10px;
    border-radius: 6px;
}

.drawer-links a:hover {
    background: rgba(102, 204, 255, 0.1);
}

/* --- 导航栏补丁 --- */
nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background-color: var(--light-bg);
    border-bottom: 1px solid var(--light-border);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

body.dark-mode nav {
    background-color: var(--dark-bg);
    border-bottom-color: var(--dark-border);
}

.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
}

.menu-toggle span {
    width: 24px;
    height: 2px;
    background-color: currentColor;
    transition: 0.3s;
}

.theme-switch-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    display: flex;
    align-items: center;
}

.nav-logo {
    font-weight: bold;
    font-size: 1.2rem;
    color: inherit;
}

.nav-links {
    display: flex;
    gap: 15px;
}

.nav-links a {
    color: inherit;
    padding: 5px 10px;
}

.nav-icon-link,
.github-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    transition: opacity 0.2s;
}

.nav-icon-link:hover,
.github-link:hover {
    opacity: 0.7;
}

/* --- 内容区布局 --- */
.content-container {
    flex: 1;
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 0 20px 40px;
    width: 100%;
    display: flex;
    justify-content: center;
}

#main-content {
    background-color: var(--light-bg);
    width: var(--content-container-width);
    max-width: 100%;
    padding: 40px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    word-wrap: break-word;
}

body.dark-mode #main-content {
    background-color: var(--dark-bg);
    border: 1px solid var(--dark-border);
}

/* --- MathJax --- */
mjx-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    padding: 10px 0;
}

/* --- 路径导航 --- */
.path-nav {
    max-width: var(--content-max-width);
    margin: 20px auto;
    padding: 0 20px;
    font-size: 0.9rem;
    color: #6e7681;
}

.path-nav a {
    color: #0969da;
    cursor: pointer;
}

body.dark-mode .path-nav a {
    color: #58a6ff;
}

/* --- 页脚 --- */
footer {
    height: var(--footer-height);
    border-top: 1px solid var(--light-border);
    display: flex;
    align-items: center;
    justify-content: center;
    /* 确保居中 */
    font-size: 0.9rem;
    color: #6e7681;
}

body.dark-mode footer {
    border-top-color: var(--dark-border);
}

.footer-content {
    text-align: center;
}

/* --- 转场蒙版 --- */
#page-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--light-bg);
    z-index: 4000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode #page-mask {
    background: var(--dark-bg);
}

#page-mask.active {
    transform: translateX(0);
}

#page-mask.exit {
    transform: translateX(-100%);
}

/* --- Markdown 强制修复 --- */
.markdown-body {
    background-color: transparent !important;
    color: inherit !important;
}

.markdown-body a {
    color: var(--link-color) !important;
}

.markdown-body p,
.markdown-body li,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    color: inherit !important;
}

/* --- 融合：Timeline 样式 --- */
.timeline-list {
    list-style: none;
    padding-left: 20px;
    margin: 20px 0 20px 10px;
    border-left: 2px solid var(--tm-axis);
    position: relative;
}

.timeline-year {
    font-size: 1.5rem;
    margin: 20px 0;
    font-weight: bold;
}

.timeline-item {
    position: relative;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -27px;
    width: 12px;
    height: 12px;
    background-color: var(--tm-axis);
    border-radius: 50%;
    border: 2px solid var(--light-bg);
    /* 动态边框防止穿帮 */
}

body.dark-mode .timeline-item::before {
    border-color: var(--dark-bg);
}

.timeline-date {
    font-family: monospace;
    margin-right: 15px;
    color: #6e7681;
    min-width: 45px;
}

.timeline-link {
    color: var(--tm-axis);
}

/* --- 响应式规则 --- */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: flex;
    }

    #main-content {
        padding: 20px;
        border-radius: 0;
        box-shadow: none;
    }

    .content-container {
        padding: 0;
    }

    .drawer-content {
        width: 70%;
    }
}