:root {
    --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    --font-mono: "SFMono-Regular", "Cascadia Code", Consolas, "PingFang SC", "Microsoft YaHei", monospace;
    --bg: #ffffff;
    --panel: #ffffff;
    --panel-2: #f5f5f7;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --line: #e5e5e7;
    --accent: #0066cc;
    --accent-soft: #eef6ff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.025);
    --shadow-hover: 0 4px 18px rgba(0, 0, 0, 0.055);
    --code-bg: #f5f5f7;
    --code-text: #1d1d1f;
    --radius: 14px;
    color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; scrollbar-gutter: stable; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.7 var(--font-sans);
    -webkit-font-smoothing: antialiased;
}
::selection { background: #cce4ff; color: #1d1d1f; }
button, input, select, textarea { font-family: var(--font-sans); }
main { flex: 1; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.wide .wrap { max-width: 1760px; padding: 0 32px; }
.top .shell, .foot .shell { max-width: 1760px; padding-left: 32px; padding-right: 32px; }

/* 顶栏 */
.top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 28px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    box-shadow: none;
}
.menu { display: flex; gap: 4px; margin-left: auto; }
.menu a { padding: 6px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.menu a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.menu a.active { color: var(--accent); background: var(--accent-soft); }
/* 首页标题 */
.hero { padding: 40px 0 26px; text-align: center; }
.hero h1 { margin: 0; font-size: 34px; letter-spacing: 1px; }
.hero h1::after {
    content: "";
    display: block;
    width: 44px;
    height: 4px;
    margin: 14px auto 0;
    border-radius: 4px;
    background: var(--accent);
}
.hero p { margin: 12px 0 0; color: var(--muted); }
.hero .stat { font-size: 13px; margin-top: 14px; }

/* 收藏：左边分类、右边卡片 */
.nav-layout { display: grid; grid-template-columns: 172px minmax(0, 1fr); gap: 32px; padding-bottom: 40px; }
.cats { position: sticky; top: 86px; align-self: start; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 110px); overflow-y: auto; }
.cats a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 14px;
}
.cats a span { font-size: 12px; opacity: 0.7; }
.cats a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.cats a.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.cats .cat-notes { margin-top: 8px; border-top: 1px dashed var(--line); border-radius: 0 0 9px 9px; padding-top: 10px; }
.group { margin-bottom: 30px; }
.group h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; font-size: 17px; }
.group h2::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.count { padding: 0 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 500; line-height: 20px; }
.more { margin-left: auto; font-size: 13px; font-weight: 500; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.card {
    position: relative;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card .link { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 13px 34px 13px 14px; color: var(--text); border-radius: inherit; }
.card .link:hover { text-decoration: none; }
.star {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s, transform 0.15s;
}
.star svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.card:hover .star, .star:focus-visible { opacity: 0.75; }
.star:hover { opacity: 1; color: #bd7400; background: #fff7e8; }
.star.on { opacity: 1; color: #bd7400; }
.star.on svg { fill: currentColor; }
.star.pop { transform: scale(1.3); }
@media (hover: none) { .star { opacity: 0.45; } }
.fav h2::before { background: #bd7400; }
.fav-empty { margin: 0; padding: 16px 18px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 13.5px; }
.cats .cat-fav { color: #976000; font-weight: 600; margin-bottom: 6px; }
.avatar {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--panel-2);
    color: var(--text);
    font-weight: 700;
    font-size: 17px;
    overflow: hidden;
}
.avatar img { position: absolute; width: 22px; height: 22px; opacity: 0; transition: opacity 0.2s; }
.avatar img.ok { opacity: 1; }
.avatar img.ok + .letter { visibility: hidden; }
.avatar:has(img.ok) { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.meta b, .meta small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.meta b { font-size: 14.5px; font-weight: 600; }
.meta small { margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.empty { padding: 40px 0; color: var(--muted); text-align: center; }
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.note { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); }
.note:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.note b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; }
.note small { flex: none; color: var(--muted); }

/* 笔记列表 */
.page { padding: 40px 24px 50px; max-width: 880px; }
.page-title { margin: 0; font-size: 28px; }
.page-sub { margin: 6px 0 22px; color: var(--muted); }
.tagbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.tagbar button {
    padding: 4px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.tagbar button:hover { color: var(--text); }
.tagbar button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.post-list { display: flex; flex-direction: column; gap: 14px; }
.posts-page { max-width: 1760px; padding: 40px 32px 50px; }
.posts-page .post-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); align-items: stretch; }
.posts-page .post-item { display: flex; flex-direction: column; }
.posts-page .post-meta { margin-top: auto; }
.post-item {
    display: block;
    padding: 20px 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s;
}
.post-item:hover { text-decoration: none; box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.post-item h3 { margin: 0; font-size: 18px; }
.post-item p { margin: 8px 0 12px; color: var(--muted); font-size: 14px; }
.post-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.tags { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 0 9px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; line-height: 22px; }

/* 文章 */
.article-wrap { display: grid; grid-template-columns: minmax(0, 860px); justify-content: center; gap: 32px; padding: 36px 24px 56px; }
.article-wrap.has-toc { grid-template-columns: minmax(0, 860px) 220px; }
.article { min-width: 0; padding: 34px 44px 40px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); font-size: 14px; }
.article > h1 { margin: 0 0 10px; font-size: 30px; line-height: 1.35; }
.article > .post-meta { padding-bottom: 20px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.toc { position: sticky; top: 86px; align-self: start; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 110px); overflow-y: auto; font-size: 13.5px; }
.toc b { margin-bottom: 8px; font-size: 13px; color: var(--muted); letter-spacing: 1px; }
.toc a { padding: 4px 10px; border-left: 2px solid var(--line); color: var(--muted); }
.toc a.l3 { padding-left: 22px; }
.toc a:hover, .toc a.on { color: var(--accent); border-left-color: var(--accent); text-decoration: none; }

.prose { font-size: 15.5px; line-height: 1.85; overflow-wrap: break-word; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.4; margin: 1.8em 0 0.7em; }
.prose h1 { font-size: 26px; }
.prose h2 { font-size: 22px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.prose h3 { font-size: 18px; }
.prose h4 { font-size: 16px; }
.prose > :first-child { margin-top: 0.6em; }
.prose p { margin: 0.9em 0; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0.8em 0; }
.prose li { margin: 0.25em 0; }
.prose li.task { list-style: none; margin-left: -1.3em; }
.prose img { max-width: 100%; border-radius: 10px; }
.prose hr { border: 0; border-top: 1px dashed var(--line); margin: 2em 0; }
.prose mark { background: var(--panel-2); color: inherit; padding: 0 2px; border-radius: 3px; }
.prose code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font: 0.9em/1.5 var(--font-mono);
}
.prose blockquote { margin: 1.2em 0; padding: 10px 18px; border-left: 4px solid var(--accent); border-radius: 0 10px 10px 0; background: var(--panel-2); color: var(--muted); }
.prose blockquote p { margin: 0.4em 0; }
.prose blockquote.warning { border-left-color: var(--text); }
.prose blockquote.tip { border-left-color: var(--text); }
.prose blockquote.important { border-left-color: var(--text); }
.code { margin: 1.3em 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--line); }
.code figcaption {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px 6px 16px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font: 12px/1.6 Consolas, monospace;
    text-transform: lowercase;
}
.code .copy {
    padding: 2px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font: 12px/1.6 inherit;
    cursor: pointer;
}
.code .copy:hover { color: var(--text); border-color: var(--text); }
.code pre { margin: 0; padding: 14px 18px; overflow-x: auto; }
.code pre code { padding: 0; background: none; color: var(--code-text); font: 13.5px/1.7 var(--font-mono); white-space: pre; }
.table { overflow-x: auto; margin: 1.2em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.prose th, .prose td { padding: 9px 14px; border: 1px solid var(--line); text-align: left; }
.prose th { background: var(--panel-2); font-weight: 600; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-weight: 600; }
.pager a:hover { text-decoration: none; border-color: var(--accent); }
.pager a small { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.pager .next { text-align: right; }

.notfound { text-align: center; padding-top: 90px; }
.notfound h1 { margin: 0; font-size: 72px; color: var(--accent); }

/* 底栏 */
.foot { padding: 26px 0 30px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.foot p { margin: 0; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--accent); }
.foot img { vertical-align: -2px; margin-right: 4px; }
.foot .dot { margin: 0 10px; opacity: 0.6; }

@media (max-width: 1080px) {
    .article-wrap.has-toc { grid-template-columns: minmax(0, 860px); }
    .toc { display: none; }
}

@media (max-width: 820px) {
    .top .shell, .foot .shell { padding-left: 16px; padding-right: 16px; }
    .posts-page { padding: 28px 16px 40px; }
    .wrap { padding: 0 16px; }
    .top .wrap { gap: 14px; height: 56px; }
    .brand .name { display: none; }
    .menu a { padding: 6px 12px; }
    .hero { padding: 36px 0 22px; }
    .hero h1 { font-size: 26px; }
    .nav-layout { grid-template-columns: 1fr; gap: 16px; }
    .cats {
        position: sticky;
        top: 56px;
        z-index: 5;
        flex-direction: row;
        overflow-x: auto;
        max-height: none;
        margin: 0 -16px;
        padding: 8px 16px;
        background: var(--bg);
        scrollbar-width: none;
    }
    .cats::-webkit-scrollbar { display: none; }
    .cats a { flex: none; border: 1px solid var(--line); background: var(--panel); }
    .cats .cat-notes { margin-top: 0; padding-top: 7px; border-top: 1px solid var(--line); border-radius: 9px; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
    .wide .wrap { padding: 0 16px; }
    .card .link { padding: 11px 30px 11px 12px; gap: 10px; }
    .avatar { width: 34px; height: 34px; font-size: 15px; border-radius: 10px; }
    .page { padding: 28px 16px 40px; }
    .article-wrap { padding: 18px 12px 40px; }
    .article { padding: 22px 18px 28px; border-radius: 14px; }
    .article > h1 { font-size: 24px; }
    .pager { grid-template-columns: 1fr; }
    .pager .next { text-align: left; }
}

/* 窄屏顶栏也保持所有页面一致，320px 宽度不挤出横向滚动。 */
@media (max-width: 380px) {
    .top .wrap { gap: 10px; }
    .menu a { padding-left: 8px; padding-right: 8px; font-size: 13px; }
}
