:root {
    color-scheme: light;
    --shell-bg: 247 249 248;
    --shell-surface: 255 255 255;
    --shell-text: 29 45 43;
    --shell-muted: 86 105 103;
    --shell-border: 37 72 68;
    --shell-accent: 19 111 99;
    --shell-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    --navbar-height: 4rem;
    --note-anchor-offset: calc(var(--navbar-height) + 1.5rem);
    --primary-color: #136f63;
    --secondary-color: #5f706e;
    --text-color: #263735;
    --light-bg: #edf3f0;
    --white: #ffffff;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --code-font: "Consolas", "Menlo", "Ubuntu Mono", "DejaVu Sans Mono", "Monaco", "Roboto Mono", "Courier New", monospace;

    /* 代码高亮特定颜色 */
    --code-bg: #000a2008;
    --code-text: #333333;
    --code-border: #444c56;
    --code-line-number: #768390;
    --code-line-highlight: rgba(99, 110, 123, 0.4);
    --code-toolbar-bg: #edf3f8;
    --code-toolbar-border: #d8e1ec;
    --code-toolbar-text: #42546a;
    --code-control-bg: #ffffff;
    --code-control-hover: #dfe9f5;
    --code-control-success: #287a52;
    --code-control-error: #b42318;

    /* 语法高亮颜色 */
    --code-keyword: #0077aa;
    --code-type: #0077aa;
    --code-string: #dd1144;
    --code-number: #990073;
    --code-comment: #999999;
    --code-function: #0086b3;
    --code-constant: #990073;
    --code-tag: #22863a;
    --code-attribute: #6f42c1;
    --code-regex: #d16965;
    --code-title: #6f42c1;
    --code-section: #005cc5;
    --code-builtin: #d73a49;
    --code-meta: #555555;
    --code-addition: #22863a;
    --code-deletion: #b31d28;
}

/* 暗黑模式变量 */
[data-theme="dark"] {
    color-scheme: dark;
    --shell-bg: 25 32 32;
    --shell-surface: 34 43 42;
    --shell-text: 234 243 239;
    --shell-muted: 167 185 179;
    --shell-border: 213 235 226;
    --shell-accent: 111 211 186;
    --primary-color: #6fd3ba;
    --secondary-color: #adbfba;
    --text-color: #eaf3ef;
    --light-bg: #263633;
    --white: #2b3c38;

    /* 代码高亮特定颜色 */
    --code-bg: #282c34;
    --code-text: #abb2bf;
    --code-border: #444c56;
    --code-line-number: #768390;
    --code-line-highlight: rgba(99, 110, 123, 0.4);
    --code-toolbar-bg: #20252d;
    --code-toolbar-border: #3b424d;
    --code-toolbar-text: #b8c2cf;
    --code-control-bg: #2d333d;
    --code-control-hover: #39414d;
    --code-control-success: #75c69b;
    --code-control-error: #ff8d85;

    /* 语法高亮颜色 */
    --code-keyword: #c678dd;
    --code-type: #e5c07b;
    --code-string: #98c379;
    --code-number: #d19a66;
    --code-comment: #5c6370;
    --code-function: #61afef;
    --code-constant: #56b6c2;
    --code-tag: #e06c75;
    --code-attribute: #d19a66;
    --code-regex: #f69d50;
    --code-title: #e5c07b;
    --code-section: #e06c75;
    --code-builtin: #56b6c2;
    --code-meta: #7f848e;
    --code-addition: #98c379;
    --code-deletion: #e06c75;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

.icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    flex: 0 0 auto;
    overflow: visible;
    vertical-align: -0.15em;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: 'Times New Roman', '宋体', sans-serif;
    color: var(--text-color);
    background-color: rgb(var(--shell-bg));
    line-height: 1.6;
    transition: var(--transition);
}

/* 导航栏样式 */
.navbar,
.title-section,
.note-tools,
.footer {
    font-family: var(--shell-font);
    -webkit-font-smoothing: antialiased;
}

.navbar {
    color: rgb(var(--shell-text));
    background: rgb(var(--shell-surface) / 0.96);
    border-bottom: 1px solid rgb(var(--shell-border) / 0.18);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    width: min(100% - 3rem, 80rem);
    min-height: var(--navbar-height);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: clamp(1.5rem, 4vw, 3.5rem);
    position: relative;
}

.site-brand, .site-nav-links, .site-nav-actions {
    display: flex;
    align-items: center;
}

.site-brand {
    gap: 0.65rem;
    color: rgb(var(--shell-text));
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 4px;
    background: rgb(var(--shell-accent));
    color: rgb(var(--shell-surface));
    font-size: 0.88rem;
    font-weight: 800;
}

.site-nav-links { gap: 1.4rem; }
.site-nav-actions { gap: 1rem; margin-left: auto; }
.site-nav-actions .main-site-link {
    color: rgb(var(--shell-accent));
    font-size: 0.84rem;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}
.site-nav-actions .main-site-link:hover { text-decoration: underline; text-underline-offset: 0.3em; }

.site-nav-links a, .language-control summary {
    color: rgb(var(--shell-muted));
    font-size: 0.875rem;
    text-decoration: none;
    white-space: nowrap;
    transition: color 140ms ease;
}

.site-nav-links a:hover, .language-control summary:hover,
.site-nav-links a[aria-current="page"] { color: rgb(var(--shell-text)); }
.site-nav-links a:hover, .site-nav-links a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-color: rgb(var(--shell-accent));
    text-decoration-thickness: 2px;
    text-underline-offset: 0.4em;
}

.nav-icon-button, .mobile-nav summary {
    display: grid;
    place-items: center;
    min-width: 2.2rem;
    min-height: 2.2rem;
    border: 1px solid rgb(var(--shell-border) / 0.13);
    border-radius: 5px;
    background: transparent;
    color: rgb(var(--shell-text));
    cursor: pointer;
}

.language-control { position: relative; }
.language-control summary { cursor: pointer; list-style: none; }
.language-control summary::-webkit-details-marker { display: none; }
.language-control summary { display: flex; align-items: center; gap: 0.35rem; }
.language-control summary::after { content: '⌄'; color: rgb(var(--shell-muted)); transition: transform 140ms ease; }
.language-control[open] summary::after { transform: rotate(180deg); }
.language-control:not([open]) > .language-menu { display: none; }

.navbar a:focus-visible, .navbar button:focus-visible, .navbar summary:focus-visible,
.tool-btn:focus-visible, .footer a:focus-visible {
    outline: 2px solid rgb(var(--shell-accent));
    outline-offset: 3px;
}

.language-menu {
    position: absolute;
    top: calc(100% + 0.55rem);
    right: 0;
    z-index: 50;
    display: grid;
    min-width: 8rem;
    gap: 0.2rem;
    padding: 0.4rem;
    background: rgb(var(--shell-surface));
    border: 1px solid rgb(var(--shell-border) / 0.12);
    border-radius: 0.75rem;
    box-shadow: 0 12px 32px rgb(0 0 0 / 0.12);
}

.language-menu a {
    padding: 0.55rem 0.7rem;
    color: rgb(var(--shell-text));
    background: transparent;
    border: 0;
    border-radius: 0.45rem;
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.language-menu a:hover { background: rgb(var(--shell-border) / 0.06); }
.mobile-nav { display: none; }

.outline-parent-link {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
    min-height: 3.25rem;
    padding: 0.65rem 1rem;
    color: var(--text-color);
    border-bottom: 1px solid color-mix(in srgb, var(--primary-color) 18%, transparent);
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    transition: var(--transition);
}

.outline-parent-link:hover,
.outline-parent-link:focus-visible {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
    outline: none;
}

/* 标题区域 */
.title-section {
    color: rgb(var(--shell-text));
    padding: 0 0 2rem;
}

.chapter-title {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.25;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.chapter-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    color: rgb(var(--shell-muted));
    font-size: 0.82rem;
}

.chapter-date {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.chapter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chapter-tags .tag {
    background: rgb(var(--shell-border) / 0.055);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.72rem;
    overflow-wrap: anywhere;
}

/* 内容区域 */
.content-section {
    flex: 1;
    width: 100%;
    margin: 0 auto;
    padding: 3.5rem 1.5rem 3rem;
}

.chapter-content {
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    min-width: 0;
    min-height: 0;
    line-break: strict;
    word-break: normal;
    hyphens: manual;
    overflow-wrap: break-word;
    hanging-punctuation: none;
}

/* 添加H1样式 */
.chapter-content h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--primary-color);
    margin: 2.5rem 0 1.5rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.7rem;
}

/* 调整现有的H2样式，确保层级正确 */
.chapter-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--primary-color);
    margin: 2rem 0 1rem;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.chapter-content h3 {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--primary-color);
    margin: 1.5rem 0 0.8rem;
}

.chapter-content h4 {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--primary-color);
    margin: 1.2rem 0 0.6rem;
}

.chapter-content h5 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--primary-color);
    margin: 1rem 0 0.5rem;
}

.chapter-content h6 {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
    color: var(--primary-color);
    margin: 0.8rem 0 0.4rem;
}

.chapter-content p {
    line-height: 1.55;
    display: block;
}

.chapter-content p + p {
    margin-top: 1.25rem;
}

.chapter-content a {
    color: var(--primary-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary-color);
    transition: var(--transition);
}

.chapter-content a:hover {
    color: #3a5a8f;
    border-bottom-style: solid;
}

.chapter-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chapter-content ul,ol{
    margin-left: 1.2em;
}

code,
pre {
    font-family: var(--code-font);
}

code {
    white-space: pre-wrap;
    /* 保留空白符，但允许必要时的换行 */
    word-break: normal;
    display: inline-block;
    /* 防止代码片段被分割 */
    color: #245bad;
}

[data-theme="dark"] code {
    white-space: pre-wrap;
    /* 保留空白符，但允许必要时的换行 */
    word-break: normal;
    display: inline-block;
    /* 防止代码片段被分割 */
    color: #6d8cc7;
}

/* ===== 代码块核心样式 ===== */
figure.highlight {
    background: var(--light-bg);
    color: var(--text-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    /* margin: 1.5em 0; */
    /* overflow: hidden; */
    transition: var(--transition);
    margin: 1em 0;
    max-width: 100%;
    overflow: visible;
}

/* figure.highlight::before {
    content: var("--lang-name");
    top: 0;
    right: 0;
    background: #e0e0e0;
    color: #555;
    padding: 0.2em 0.5em;
    font-family: monospace;
} */

/* ===== 表格核心样式 ===== */
table {
    width: 100%;
    border-collapse: separate;
    /* 关键改动：分离边框模式 */
    border-spacing: 0;
    margin: 1.5em 0;
    background: var(--white);
    color: var(--text-color);
    box-shadow: var(--box-shadow);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

/* 单元格统一边框样式 */
table th:not(:has(pre)),
table td:not(:has(pre)) {
    padding: 12px 16px;
    text-align: center;
    vertical-align: middle;
    border-right: 1px solid var(--primary-color);
    /* 垂直分割线 */
    border-bottom: 1px solid var(--primary-color);
    /* 水平分割线 */
    transition: background-color 0.2s;
}

/* 最后一列去掉右边框 */
table th:last-child,
table td:last-child {
    border-right: none;
}

/* 表头特殊样式 */
table th {
    background: var(--light-bg);
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    /* 加粗表头底部线 */
    letter-spacing: 0.5px;
}

/* 最后一行去掉底部边框 */
table tr:last-child td {
    border-bottom: none;
}


/* 深色模式适配 */
[data-theme="dark"] table {
    background: var(--white);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] table th,
[data-theme="dark"] table td {
    border-right-color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

[data-theme="dark"] table th {
    background: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* 响应式优化 */
@media (max-width: 768px) {

    table th,
    table td {
        padding: 10px 12px;
        font-size: 0.9em;
    }
}

/* ===== 行号列 ===== */
figure.highlight .gutter {
    width: 2.5em;
    padding: 0.75em 0.5em;
    text-align: right;
    color: var(--secondary-color);
    background: rgba(0, 0, 0, 0.03);
    border-right: 1px solid;
    border-color: color-mix(in srgb, var(--secondary-color) 15%, transparent);
    user-select: none;
    vertical-align: top;
}

[data-theme="dark"] figure.highlight .gutter {
    background: rgba(255, 255, 255, 0.05);
}

/* ===== 代码列 ===== */
figure.highlight .code {
    padding: 0.75em 1em;
    vertical-align: top;
    overflow: visible;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    word-break: break-word;
}

figure.highlight br {
    content: "";
    /* 清除默认换行行为 */
    display: none;
    /* 完全隐藏 */
    line-height: 0;
    /* 或设置高度为0 */
}

/* ===== 代码行 ===== */
figure.highlight .line {
    line-height: 1.6em;
    font-size: 14px;
    display: block;
    min-height: 1.6em;
}

figure.highlight table {
    margin: 0;
    width: 100%;
    border-collapse: collapse;
}

figure.highlight tr {
    background: transparent !important;
}

figure.highlight td {
    padding: 0;
    border: none;
}

/* figure.highlight td.gutter {
    width: 2.5em;
    padding: 0.75em 1em;
    text-align: right;
    color: var(--code-line-number);
    background-color: var(--code-bg);
    border-right: 1px solid var(--code-border);
    user-select: none;
} */

figure.highlight td.code {
    padding: 0.75em 1em;
    vertical-align: top;
}

figure.highlight pre {
    margin: 0;
    max-height: none;
    overflow: visible;
}

/* 行高亮样式 */
figure.highlight .line.marked {
    background-color: var(--code-line-highlight);
}

/* ===== 语法高亮样式 ===== */
figure.highlight .keyword,
figure.highlight .keyword.function {
    color: var(--code-keyword);
    font-weight: bold;
}

figure.highlight .type {
    color: var(--code-type);
}

figure.highlight .string,
figure.highlight .string .value {
    color: var(--code-string);
}

figure.highlight .number {
    color: var(--code-number);
}

figure.highlight .comment {
    color: var(--code-comment);
    font-style: italic;
}

figure.highlight .function {
    color: var(--code-function);
}

figure.highlight .title.function {
    color: var(--code-function);
}

figure.highlight .params {
    color: var(--code-text);
}

figure.highlight .built_in {
    color: var(--code-builtin);
}

figure.highlight .literal {
    color: var(--code-constant);
}

figure.highlight .tag,
figure.highlight .selector-tag {
    color: var(--code-tag);
}

figure.highlight .attribute {
    color: var(--code-attribute);
}

figure.highlight .regexp {
    color: var(--code-regex);
}

figure.highlight .title.class_ {
    color: var(--code-title);
}

figure.highlight .section {
    color: var(--code-section);
}

figure.highlight .meta {
    color: var(--code-meta);
}

figure.highlight .addition {
    color: var(--code-addition);
    background-color: rgba(70, 149, 74, 0.15);
}

figure.highlight .deletion {
    color: var(--code-deletion);
    background-color: rgba(203, 36, 49, 0.15);
}

/* highlight.js token classes used by the dynamic note reader. */
.chapter-content pre.astro-code .hljs-comment,
.chapter-content pre.astro-code .hljs-quote {
    color: var(--code-comment);
    font-style: italic;
}

.chapter-content pre.astro-code .hljs-keyword,
.chapter-content pre.astro-code .hljs-selector-tag,
.chapter-content pre.astro-code .hljs-meta-keyword {
    color: var(--code-keyword);
    font-weight: 600;
}

.chapter-content pre.astro-code .hljs-type,
.chapter-content pre.astro-code .hljs-title.class_ {
    color: var(--code-type);
}

.chapter-content pre.astro-code .hljs-string,
.chapter-content pre.astro-code .hljs-regexp,
.chapter-content pre.astro-code .hljs-template-variable {
    color: var(--code-string);
}

.chapter-content pre.astro-code .hljs-number,
.chapter-content pre.astro-code .hljs-literal,
.chapter-content pre.astro-code .hljs-symbol {
    color: var(--code-number);
}

.chapter-content pre.astro-code .hljs-title.function_,
.chapter-content pre.astro-code .hljs-function .hljs-title,
.chapter-content pre.astro-code .hljs-built_in {
    color: var(--code-function);
}

.chapter-content pre.astro-code .hljs-params {
    color: var(--code-text);
}

.chapter-content pre.astro-code .hljs-meta,
.chapter-content pre.astro-code .hljs-doctag {
    color: var(--code-meta);
}

.chapter-content pre.astro-code .hljs-attr,
.chapter-content pre.astro-code .hljs-attribute {
    color: var(--code-attribute);
}

.chapter-content pre.astro-code .hljs-tag,
.chapter-content pre.astro-code .hljs-name {
    color: var(--code-tag);
}

/* ===== Katex 相关样式调整 ===== */
.katex {
    font-size: 1.05em !important;
}

.katex-display {
    overflow: auto hidden;
    padding: 0.5em 0;
}

/* 确保代码块和 Katex 公式在暗黑模式下协调 */
[data-theme="dark"] .katex {
    color: var(--text-color);
}

/* ===== 行内代码样式 ===== */
code:not([class*="language-"]) {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 0.85em;
    background-color: var(--code-bg);
    border-radius: 3px;
    color: var(--code-text);
    /* font-family: var(--code-font); */
    /* border: 1px solid var(--code-border); */
}

/* ===== 代码块标题样式 ===== */
figure.highlight figcaption {
    padding: 0.5em 1em;
    background-color: var(--code-border);
    color: var(--code-line-number);
    font-family: var(--code-font);
    font-size: 0.85em;
    border-bottom: 1px solid var(--code-border);
}

figure.highlight figcaption a {
    color: inherit;
    text-decoration: none;
}

figure.highlight figcaption a:hover {
    text-decoration: underline;
}

/* ===== 响应式优化 ===== */
@media (max-width: 768px) {
    .content-section .chapter-content figure.highlight {
        border-radius: calc(var(--border-radius) / 2);
        font-size: 0.85em;
    }
}



/* 笔记工具条 */
.note-tools {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.tool-btn {
    display: flex;
    align-items: center;
    min-height: 2.8rem;
    gap: 0.5rem;
    background: transparent;
    color: rgb(var(--shell-text));
    border: 1px solid rgb(var(--shell-border) / 0.15);
    padding: 0.7rem 1rem;
    border-radius: 0.7rem;
    cursor: pointer;
    transition: transform 140ms ease, background 140ms ease;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
}

.tool-btn:hover {
    background: rgb(var(--shell-border) / 0.05);
    transform: translateY(-1px);
}

.tool-btn .icon {
    font-size: 1rem;
}

/* 页脚样式 */
.footer {
    color: rgb(var(--shell-muted));
    background: rgb(var(--shell-bg));
    padding: 2rem 0;
    border-top: 1px solid rgb(var(--shell-border) / 0.09);
    font-size: 0.875rem;
}

.footer-content {
    width: min(100% - 3rem, 80rem);
    margin: 0 auto;
}

.footer-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.footer .footer-owner {
    color: rgb(var(--shell-text));
    font-weight: 650;
}

.footer-links {
    display: flex;
    gap: 1.25rem;
    white-space: nowrap;
}

.footer a {
    color: inherit;
    text-decoration: none;
    transition: color 140ms ease;
    text-underline-offset: 0.22em;
}

.footer a:hover {
    color: rgb(var(--shell-text));
    text-decoration: underline;
}

.footer-records {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgb(var(--shell-border) / 0.1);
    text-align: center;
    font-size: 0.75rem;
}

.footer-records:empty {
    display: none;
}

/* Responsive reading shell */
@media (max-width: 760px) {
    :root { --navbar-height: 6.5rem; }
    .navbar-container, .footer-content { width: min(100% - 2rem, 80rem); }
    .navbar-container { flex-wrap: wrap; gap: 0.2rem 1rem; padding: 0.6rem 0; }
    .site-brand { font-size: 0.88rem; }
    .site-nav-links { order: 3; width: 100%; gap: 1.25rem; }
    .site-nav-links a { font-size: 0.82rem; }
    .site-nav-actions { gap: 0.7rem; }
    .site-nav-actions .main-site-link { font-size: 0.78rem; }
    .language-control summary { font-size: 0.8rem; }
    .chapter-title { font-size: 1.75rem; }
    .content-section { padding: 2rem 1.25rem; }
    .note-tools { justify-content: flex-start; }
    .footer-main { align-items: flex-start; flex-direction: column; gap: 0.75rem; }
}

@media (max-width: 480px) {
    :root { --navbar-height: 7.25rem; }
    .site-nav-actions { order: 2; width: 100%; justify-content: flex-end; }
}

@media print {
    @page {
        margin: 18mm 16mm;
    }

    html,
    body {
        background: #ffffff !important;
        color: #111111 !important;
        font-family: "Noto Sans SC", Arial, "Microsoft YaHei", sans-serif;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    body {
        display: block;
        min-height: 0;
    }

    .navbar,
    .note-tools,
    .footer {
        display: none !important;
    }

    .title-section,
    .content-section,
    .title-container {
        display: block;
        max-width: none;
        min-width: 0;
        margin: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    .title-section {
        padding-bottom: 0.8rem;
        margin-bottom: 1.5rem;
        border-bottom: 1px solid #777777;
    }

    .chapter-title {
        color: #111111;
        font-size: 22pt;
        line-height: 1.25;
        margin: 0 0 0.45rem;
    }

    .chapter-meta,
    .chapter-meta *,
    .chapter-tags,
    .tag {
        color: #555555 !important;
        background: transparent !important;
        box-shadow: none;
    }

    .chapter-content {
        position: static;
        width: auto;
        min-width: 0;
        min-height: 0;
        padding: 0;
        color: #111111;
        background: #ffffff;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .chapter-content h1,
    .chapter-content h2,
    .chapter-content h3,
    .chapter-content h4,
    .chapter-content h5,
    .chapter-content h6 {
        color: #111111;
        border-color: #777777;
        break-after: avoid;
    }

    .chapter-content p,
    .chapter-content li,
    .chapter-content td,
    .chapter-content th {
        color: #111111;
    }

    .chapter-content a {
        color: #111111;
        border: 0;
        text-decoration: underline;
    }

    .chapter-content pre.astro-code,
    .chapter-content pre.astro-code * {
        color: #111111 !important;
        background: #f3f3f3 !important;
        border-color: #bbbbbb !important;
        box-shadow: none;
    }

    .chapter-content img,
    .chapter-content pre,
    .chapter-content table,
    .chapter-content .katex-display {
        break-inside: avoid;
    }

    .chapter-content {
        overflow: visible;
    }
}

/* Astro compatibility: keep the old note.css as the baseline and only map Astro output to it. */
.chapter-content pre.astro-code {
    background: var(--code-bg) !important;
    color: var(--code-text) !important;
    border: 1px solid var(--code-toolbar-border);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin: 1.5em 0;
    max-width: 100%;
    max-height: none;
    overflow: visible;
    padding: 0;
    position: relative;
    transition: var(--transition);
}

.chapter-content pre.astro-code .code-toolbar {
    align-items: center;
    background: var(--code-toolbar-bg);
    border-bottom: 1px solid var(--code-toolbar-border);
    border-radius: calc(var(--border-radius) - 1px) calc(var(--border-radius) - 1px) 0 0;
    display: flex;
    justify-content: space-between;
    min-height: 2.5rem;
    padding: 0.4rem 0.55rem 0.4rem 0.85rem;
    white-space: normal;
}

.chapter-content pre.astro-code .code-lang-label {
    align-items: center;
    color: var(--code-toolbar-text);
    display: inline-flex;
    font-family: var(--code-font);
    font-size: 0.875rem;
    font-weight: 600;
    gap: 0.5rem;
    letter-spacing: 0.04em;
}

.chapter-content pre.astro-code .code-lang-label::before {
    background: var(--primary-color);
    border-radius: 50%;
    content: '';
    height: 0.5rem;
    width: 0.5rem;
}

.chapter-content pre.astro-code .copy-code-btn {
    align-items: center;
    background: var(--code-control-bg);
    border: 1px solid var(--code-toolbar-border);
    border-radius: 6px;
    color: var(--code-toolbar-text);
    cursor: pointer;
    display: inline-flex;
    font-family: Arial, 'Microsoft YaHei', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    gap: 0.4rem;
    line-height: 1;
    padding: 0.45rem 0.65rem;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.chapter-content pre.astro-code .copy-code-btn:hover {
    background: var(--code-control-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.chapter-content pre.astro-code .copy-code-btn[data-state="copied"] {
    color: var(--code-control-success);
}

.chapter-content pre.astro-code .copy-code-btn[data-state="failed"] {
    color: var(--code-control-error);
}

.chapter-content pre.astro-code code,
.chapter-content pre.astro-code code:not([class*="language-"]) {
    background: transparent;
    border-radius: 0;
    color: inherit;
    display: block;
    font-family: var(--code-font);
    font-size: 14px;
    line-height: 1.6em;
    margin: 0;
    overflow: visible;
    padding: 1rem 1.1rem 1.1rem 3.9rem;
    white-space: normal;
}

.chapter-content pre.astro-code .line {
    display: block;
    min-height: 1.6em;
    overflow-wrap: anywhere;
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
}

.chapter-content pre.astro-code .line-number {
    position: absolute;
    left: -3.2em;
    width: 2.4em;
    padding-right: 0.7em;
    color: var(--secondary-color);
    text-align: right;
    user-select: none;
}

[data-theme="dark"] .chapter-content pre.astro-code {
    background: var(--code-bg) !important;
    color: var(--code-text) !important;
}

.chapter-content .katex-display {
    overflow: auto hidden;
    padding: 0.5em 0;
}

.note-code-language {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.content-section {
    width: 100%;
    max-width: 1280px;
    min-width: 0;
}

.content-section.wide-content {
    max-width: 1600px;
}

.note-layout {
    display: grid;
    grid-template-columns: 17rem minmax(0, 900px);
    justify-content: center;
    align-items: start;
    gap: 2rem;
    transition: grid-template-columns 0.2s ease;
}

.note-layout.outline-collapsed {
    grid-template-columns: 3.25rem minmax(0, 900px);
}

html[data-notes-outline="collapsed"] .note-layout {
    grid-template-columns: 3.25rem minmax(0, 900px);
}

.note-layout.wide-content {
    grid-template-columns: 14rem minmax(0, 1100px);
    gap: 1.5rem;
}

.note-layout.wide-content.outline-collapsed {
    grid-template-columns: 3.25rem minmax(0, 1100px);
}

html[data-notes-outline="collapsed"] .note-layout.wide-content {
    grid-template-columns: 3.25rem minmax(0, 1100px);
}

.note-layout:has(.note-outline[hidden]) {
    grid-template-columns: minmax(0, 900px);
}

.note-layout.wide-content:has(.note-outline[hidden]) {
    grid-template-columns: minmax(0, 1100px);
}

.note-article { min-width: 0; }

.wide-content .chapter-content table th:not(:has(pre)),
.wide-content .chapter-content table td:not(:has(pre)) {
    padding: 0.65rem 0.8rem;
}

.note-outline {
    position: sticky;
    top: var(--note-anchor-offset);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--note-anchor-offset) - 1.5rem);
    max-height: calc(100dvh - var(--note-anchor-offset) - 1.5rem);
    overflow: hidden;
    background: color-mix(in srgb, var(--white) 94%, var(--primary-color));
    border: 1px solid color-mix(in srgb, var(--primary-color) 22%, transparent);
    border-radius: var(--border-radius);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.07);
    font-family: Arial, "Microsoft YaHei", sans-serif;
    transition: var(--transition);
}

.note-outline.parent-only {
    align-self: start;
}

.note-outline.parent-only .outline-header,
.note-outline.parent-only .outline-links {
    display: none;
}

.note-outline.parent-only .outline-parent-link {
    padding-right: 3.25rem;
    border-bottom: 0;
}

.outline-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    min-height: 3.25rem;
    padding: 0.65rem 3.25rem 0.65rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--primary-color) 18%, transparent);
}

.outline-title {
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 700;
}

.outline-toggle {
    display: grid;
    place-items: center;
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    width: 2rem;
    height: 2rem;
    color: var(--secondary-color);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.outline-toggle:hover,
.outline-toggle:focus-visible {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    outline: none;
}

.outline-toggle .icon {
    transition: transform 0.2s ease;
}

.outline-links {
    align-content: start;
    display: grid;
    flex: 1 1 auto;
    gap: 0.15rem;
    grid-auto-rows: max-content;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.65rem;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
}

.outline-link {
    display: block;
    padding: 0.38rem 0.55rem;
    overflow: hidden;
    color: var(--secondary-color);
    border-left: 2px solid transparent;
    border-radius: 0 5px 5px 0;
    font-size: 0.82rem;
    line-height: 1.35;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.outline-link[data-level="1"] { font-weight: 700; }
.outline-link[data-level="2"] { padding-left: 1rem; font-weight: 600; }
.outline-link[data-level="3"] { padding-left: 1.55rem; }
.outline-link[data-level="4"] { padding-left: 2.1rem; }
.outline-link[data-level="5"] { padding-left: 2.65rem; }
.outline-link[data-level="6"] { padding-left: 3.2rem; }

.outline-link:hover,
.outline-link[aria-current] {
    color: var(--primary-color);
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
    border-left-color: var(--primary-color);
}

.outline-collapsed .outline-header {
    justify-content: center;
    padding: 0.65rem;
    border-bottom: 0;
}

html[data-notes-outline="collapsed"] .outline-header {
    justify-content: center;
    padding: 0.65rem;
    border-bottom: 0;
}

.outline-collapsed .note-outline.parent-only .outline-toggle {
    position: static;
    align-self: center;
    margin: 0.35rem;
}

html[data-notes-outline="collapsed"] .note-outline.parent-only .outline-toggle {
    position: static;
    align-self: center;
    margin: 0.35rem;
}

.outline-collapsed .note-outline {
    height: auto;
}

html[data-notes-outline="collapsed"] .note-outline {
    height: auto;
}

.outline-collapsed .outline-parent-link {
    display: none;
}

html[data-notes-outline="collapsed"] .outline-parent-link {
    display: none;
}

.outline-collapsed .outline-title,
.outline-collapsed .outline-links {
    display: none;
}

html[data-notes-outline="collapsed"] .outline-title,
html[data-notes-outline="collapsed"] .outline-links {
    display: none;
}

.outline-collapsed .outline-toggle .icon {
    transform: rotate(180deg);
}

html[data-notes-outline="collapsed"] .outline-toggle .icon {
    transform: rotate(180deg);
}

.chapter-content h1,
.chapter-content h2,
.chapter-content h3,
.chapter-content h4,
.chapter-content h5,
.chapter-content h6 {
    scroll-margin-top: var(--note-anchor-offset);
}

@media (max-width: 900px) {
    .note-layout,
    .note-layout.outline-collapsed,
    .note-layout.wide-content,
    .note-layout.wide-content.outline-collapsed,
    html[data-notes-outline="collapsed"] .note-layout,
    html[data-notes-outline="collapsed"] .note-layout.wide-content {
        grid-template-columns: minmax(0, 1fr);
        gap: 1rem;
    }

    .note-article { grid-row: 1; }
    .note-outline { grid-row: 2; }
    .note-layout:has(.note-outline[hidden]) .note-article { grid-row: auto; }

    .note-outline {
        position: static;
        width: 100%;
        height: auto;
        max-height: none;
    }

    .outline-links {
        flex: none;
        max-height: 18rem;
    }

    .outline-collapsed .note-outline {
        width: 3.25rem;
    }
}

.chapter-content .note-solution {
    margin: 1.5rem 0;
    padding: 0 1.25rem;
    border: 1px solid color-mix(in srgb, var(--primary-color) 30%, transparent);
    border-radius: var(--border-radius);
}

.chapter-content .note-solution > summary {
    padding: 0.85rem 1.25rem;
    margin: 0 -1.25rem;
    border-radius: inherit;
    background: var(--light-bg);
    color: var(--text-color);
    font-weight: 600;
    cursor: pointer;
}

.chapter-content .note-solution > summary::marker {
    color: var(--primary-color);
}

.chapter-content .note-solution > summary:hover {
    background: color-mix(in srgb, var(--primary-color) 12%, var(--light-bg));
}

.chapter-content .note-solution > summary:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
}

.chapter-content .note-solution[open] {
    padding-bottom: 0.5rem;
}

/* Keep this at the end: dark-mode editor rules above use !important. */
@media print {
    .chapter-content .note-solution {
        padding: 0;
        border: 0;
    }

    .chapter-content .note-solution > summary {
        display: none;
    }

    html,
    body,
    [data-theme="dark"] {
        background: #ffffff !important;
        color: #111111 !important;
        font-family: "Times New Roman", "Songti SC", SimSun, "宋体", serif !important;
    }

    .chapter-content,
    [data-theme="dark"] .chapter-content {
        color: #111111 !important;
        background: #ffffff !important;
    }

    .note-layout,
    .note-layout.outline-collapsed {
        display: block;
    }

    .note-outline {
        display: none !important;
    }

    .chapter-content table,
    [data-theme="dark"] .chapter-content table {
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        color: #111111 !important;
        background: #ffffff !important;
        box-shadow: none;
        border-radius: 0;
        break-inside: auto;
    }

    .chapter-content thead {
        display: table-header-group;
    }

    .chapter-content tr {
        break-inside: avoid;
    }

    .chapter-content th,
    .chapter-content td,
    [data-theme="dark"] .chapter-content th,
    [data-theme="dark"] .chapter-content td {
        color: #111111 !important;
        background: #ffffff !important;
        border: 1px solid #999999 !important;
        padding: 5pt 6pt;
    }

    .chapter-content th,
    [data-theme="dark"] .chapter-content th {
        background: #eeeeee !important;
        font-weight: 700;
    }

    .chapter-content .katex-display,
    [data-theme="dark"] .chapter-content .katex-display {
        overflow: visible !important;
        padding: 0.4em 0;
        text-align: center;
        break-inside: avoid;
    }

    .chapter-content .katex,
    [data-theme="dark"] .chapter-content .katex {
        color: #111111 !important;
        font-size: 0.95em !important;
    }

    .chapter-content pre.astro-code,
    [data-theme="dark"] .chapter-content pre.astro-code {
        overflow: visible !important;
        color: #111111 !important;
        background: #f3f3f3 !important;
        border: 1px solid #bbbbbb !important;
        border-radius: 0;
        box-shadow: none;
        break-inside: avoid;
    }

    .chapter-content pre.astro-code .code-toolbar {
        display: none !important;
    }

    .chapter-content pre.astro-code code,
    .chapter-content pre.astro-code .line,
    .chapter-content pre.astro-code .line-number,
    .chapter-content pre.astro-code code *,
    [data-theme="dark"] .chapter-content pre.astro-code code,
    [data-theme="dark"] .chapter-content pre.astro-code code * {
        color: #111111 !important;
        background: transparent !important;
    }

    .chapter-content :not(pre) > code:not([class*="language-"]),
    [data-theme="dark"] .chapter-content :not(pre) > code:not([class*="language-"]) {
        color: #111111 !important;
        background: #e9e9e9 !important;
        border: 1px solid #c8c8c8 !important;
        border-radius: 2pt;
        font-family: var(--code-font) !important;
        font-size: 0.9em;
        padding: 0.05em 0.25em;
        box-shadow: none;
    }
}
