:root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --line: #e6e8ec;
    --text: #1f2328;
    --muted: #6b7280;
    --brand: #2563eb;
    --brand-soft: #eef4ff;
    --radius: 12px;
    --hd: 58px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
    font-size: 16px;
    line-height: 1.75;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 900px; margin: 0 auto; padding: 0 16px; }

/* ---------- 顶栏 / 页脚 ---------- */
.site-hd {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.site-hd .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--hd);
    gap: 16px;
}
.logo { font-size: 19px; font-weight: 700; color: var(--text); }
.logo:hover { text-decoration: none; }
.nav a { margin-left: 16px; color: var(--muted); font-size: 15px; }
.nav a:hover { color: var(--brand); text-decoration: none; }

main { padding: 22px 16px 44px; min-height: 60vh; }

.site-ft {
    border-top: 1px solid var(--line);
    background: var(--card);
    padding: 18px 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}
.icp { margin-left: 8px; }

/* ---------- 首页 ---------- */
.hero { padding: 14px 0 6px; }
.hero h1 { font-size: 26px; margin: 0 0 6px; }
.hero .sub { color: var(--muted); margin: 0; font-size: 15px; }

section { margin-top: 28px; }
section h2 {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 17px;
    margin: 0 0 14px;
    padding-left: 10px;
    border-left: 4px solid var(--brand);
    line-height: 1.3;
}
.h2-act {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 12px;
    white-space: nowrap;
}
.h2-act:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.card-t { font-weight: 600; color: var(--text); word-break: break-all; }
.card-n { color: var(--muted); font-size: 13px; margin-top: 4px; }

.tagbox { display: flex; flex-wrap: wrap; gap: 8px; }
.tagbox a {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 14px;
    color: var(--text);
    transition: border-color .15s, color .15s;
}
.tagbox a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.tagbox a i { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 4px; }

/* ---------- 文章列表 ---------- */
.alist { list-style: none; margin: 0; padding: 0; }
.alist li {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 13px 16px;
    margin-bottom: 10px;
    display: block;
    transition: border-color .15s;
}
.alist li:hover { border-color: #cfd6e4; }
.alist li .t { display: block; font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.6; }
.alist li .t:hover { color: var(--brand); text-decoration: none; }
.alist li .ex {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.75;
}
.from { color: var(--muted); font-size: 12px; white-space: nowrap; margin-top: 7px; display: inline-block; }

/* ---------- 面包屑 / 标题 ---------- */
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--brand); }
.crumb .sep { margin: 0 7px; opacity: .55; }

.page-title { font-size: 22px; margin: 0 0 18px; }
.page-title small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 6px; line-height: 1.6; }

/* ---------- 分页 ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 6px; margin: 24px 0; }
.pg {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 14px;
    color: var(--text);
}
.pg:hover { border-color: var(--brand); text-decoration: none; }
.pg.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.gap { padding: 5px 4px; color: var(--muted); }

/* ================= 文章页 ================= */
.article-wrap { max-width: 780px; margin: 0 auto; }

.post, .empty-box {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 30px 34px 24px;
}

/* 头部 */
.post-hd { margin-bottom: 20px; }
.post-title {
    font-size: clamp(23px, 4.2vw, 31px);
    font-weight: 700;
    line-height: 1.38;
    letter-spacing: .2px;
    margin: 0 0 14px;
    word-break: break-word;
}
.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 0;
    color: var(--muted);
    font-size: 13px;
}
.post-meta span { display: inline-flex; align-items: center; }
.post-meta span + span::before { content: "·"; margin: 0 9px; opacity: .6; }

.post-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.ptag-k { font-size: 12px; color: var(--muted); }
.ptag {
    background: var(--brand-soft);
    color: var(--brand);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 3px 12px;
    font-size: 12.5px;
    line-height: 1.6;
}
.ptag:hover { border-color: var(--brand); text-decoration: none; }

/* 工具条（吸顶） */
.post-toolbar {
    position: sticky;
    top: calc(var(--hd) + 6px);
    z-index: 9;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 22px;
    padding: 9px 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(17, 24, 39, .04);
}
.rd-btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    border-radius: 9px;
    padding: 6px 12px;
    font-size: 13.5px;
    cursor: pointer;
    line-height: 1.2;
    transition: border-color .15s, color .15s, background .15s;
}
.rd-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.rd-btn:disabled { opacity: .42; cursor: default; }
.rd-main { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }
.rd-main:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.rd-sq { padding: 6px 10px; font-size: 13px; }
.rd-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.rd-font { display: inline-flex; align-items: center; gap: 5px; }
.rd-fs-val {
    min-width: 30px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    background: transparent;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 5px 4px;
    cursor: pointer;
    font-family: inherit;
}
.rd-fs-val:hover { border-color: var(--brand); color: var(--brand); }
.rd-rate { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 5px; }
.rd-rate select {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    border-radius: 9px;
    padding: 5px 8px;
    font-size: 13px;
    font-family: inherit;
}
.rd-status {
    margin: -10px 0 18px;
    padding: 9px 13px;
    font-size: 13.5px;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 9px;
    line-height: 1.65;
}

/* 正文排版 */
.post-body {
    font-size: 17px;
    line-height: 1.95;
    color: var(--text);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.post-body p { margin: 0 0 18px; text-align: justify; text-indent: 2em; }
.post-body > p:first-child { margin-top: 0; }
.post-body img { display: block; max-width: 100%; height: auto; margin: 20px auto; border-radius: 10px; }
.post-body h1, .post-body h2, .post-body h3, .post-body h4 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.45;
    margin: 32px 0 14px;
    padding-left: 12px;
    border-left: 4px solid var(--brand);
}
.post-body h3 { font-size: 18px; }
.post-body h4 { font-size: 17px; }
.post-body blockquote {
    margin: 20px 0;
    padding: 12px 18px;
    border-left: 4px solid var(--brand);
    background: var(--brand-soft);
    color: var(--muted);
    border-radius: 0 10px 10px 0;
}
.post-body blockquote p { text-indent: 0; margin-bottom: 8px; }
.post-body blockquote p:last-child { margin-bottom: 0; }
.post-body ul, .post-body ol { padding-left: 26px; margin: 0 0 18px; }
.post-body li { margin: 4px 0; }
.post-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 18px 0;
    font-size: 15px;
    display: block;
    overflow-x: auto;
}
.post-body td, .post-body th { border: 1px solid var(--line); padding: 8px 12px; text-indent: 0; }
.post-body th { background: var(--brand-soft); font-weight: 600; }
.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 26px 0; }
.post-body pre {
    background: #f6f7f9;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.7;
}
.post-body code { background: #f0f1f4; padding: 1px 5px; border-radius: 4px; font-size: .94em; }
.post-body pre code { background: transparent; padding: 0; }
.post-body a { border-bottom: 1px solid transparent; }
.post-body a:hover { border-bottom-color: var(--brand); text-decoration: none; }

.post-fin {
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
    letter-spacing: 3px;
    margin: 34px 0 4px;
    opacity: .75;
}

/* 上一篇 / 下一篇 */
.pn2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.pn-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    transition: border-color .15s;
}
.pn-card:hover { border-color: var(--brand); text-decoration: none; }
.pn-empty { background: transparent; border-style: dashed; }
.pn-empty:hover { border-color: var(--line); }
.pn-right { text-align: right; align-items: flex-end; }
.pn-k { font-size: 12px; color: var(--muted); }
.pn-t {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pn-card:hover .pn-t { color: var(--brand); }

/* 相关阅读 */
.related { margin-top: 30px; }
.ralist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.ralist li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .15s; }
.ralist li:hover { border-color: var(--brand); }
.ralist li a { display: block; padding: 13px 15px; }
.ralist li a:hover { text-decoration: none; }
.rt { display: block; color: var(--text); font-size: 14.5px; font-weight: 600; line-height: 1.55; }
.ralist li a:hover .rt { color: var(--brand); }
.rx {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.7;
}

.back { margin: 24px 0 0; font-size: 14px; }

/* ---------- 其它 ---------- */
.empty, .stat, .log { color: var(--muted); }
.empty code, .log { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
.log { display: block; padding: 12px; overflow: auto; max-height: 400px; font-size: 13px; white-space: pre-wrap; }

table.stat { border-collapse: collapse; margin: 10px 0; }
table.stat th, table.stat td { border: 1px solid var(--line); padding: 6px 14px; text-align: center; }
table.stat th { background: #f3f4f6; }

/* ---------- 返回顶部 ---------- */
.rd-top {
    position: fixed; right: 18px; bottom: 22px; z-index: 20;
    background: var(--brand); color: #fff; border: none; border-radius: 999px;
    padding: 10px 16px; font-size: 14px; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
    opacity: 0; transform: translateY(8px); pointer-events: none;
    transition: opacity .2s, transform .2s;
}
.rd-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.rd-top:hover { background: #1d4ed8; }

/* ---------- 阅读进度条 ---------- */
.rd-bar {
    position: fixed; left: 0; top: 0; height: 3px; width: 0; z-index: 30;
    background: var(--brand); border-radius: 0 2px 2px 0;
    transition: width .1s linear;
}

/* ---------- 夜间护眼模式 ---------- */
body.night {
    --bg: #15181d;
    --card: #1e2229;
    --line: #2e343e;
    --text: #d8dde4;
    --muted: #949da8;
    --brand: #6ea8fe;
    --brand-soft: #1d2836;
}
body.night .rd-btn, body.night .rd-rate select { background: #23272f; }
body.night .rd-fs-val { background: transparent; }
body.night .post-body pre { background: #171a1f; }
body.night .post-body code { background: #262b33; }
body.night .empty code, body.night .log { background: #23272f; }
body.night table.stat th { background: #23272f; }
body.night .rd-top { color: #0f1216; }
::selection { background: var(--brand-soft); }

/* ---------- 小屏 ---------- */
@media (max-width: 640px) {
    :root { --hd: 52px; }
    body { font-size: 15px; }
    .post, .empty-box { padding: 20px 17px 16px; border-radius: 14px; }
    .post-title { font-size: 22px; }
    .post-body { font-size: 16px; line-height: 1.9; }
    .nav a { margin-left: 10px; }
    .pn2 { grid-template-columns: 1fr; }
    .pn-empty { display: none; }
    .pn-right { text-align: left; align-items: flex-start; }
    .post-toolbar { gap: 6px; padding: 8px; }
    .rd-btn { padding: 6px 10px; font-size: 13px; }
    .hero h1 { font-size: 22px; }
}

/* ---------- 正文自动内链 ---------- */
.post-body a.ilink {
    color: var(--brand);
    border-bottom: 1px dotted var(--brand);
    text-decoration: none;
}
.post-body a.ilink:hover { background: var(--brand-soft); text-decoration: none; }

/* ---------- 分享条 ---------- */
.share {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    margin: 18px 0 0;
}
.share-k { color: var(--muted); font-size: 14px; margin-right: 2px; }
.sh {
    display: inline-block; padding: 6px 14px; font-size: 14px; line-height: 1.4;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--card); color: var(--muted); cursor: pointer;
    font-family: inherit;
}
.sh:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.sh-wx:hover { color: #07c160; border-color: #07c160; }

/* ---------- 本文信息 / 版权 ---------- */
.post-info {
    margin: 18px 0 0; padding: 16px 18px;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.post-info h2 {
    margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600;
}
.pinfo { margin: 0; padding: 0; list-style: none; }
.pinfo li {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 5px 0; font-size: 14px; border-bottom: 1px dashed var(--line);
}
.pinfo li:last-child { border-bottom: 0; }
.pinfo .k { color: var(--muted); flex: 0 0 76px; }
.pinfo .v { flex: 1 1 auto; min-width: 0; word-break: break-all; }
.plink {
    font-size: 13px; background: var(--bg); padding: 2px 6px; border-radius: 5px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
.copyright { margin: 12px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; }

/* ---------- 标签页：自动简介 / 内容块 ---------- */
.tag-intro {
    margin: 0 0 16px; padding: 14px 18px;
    background: var(--brand-soft); border-radius: var(--radius);
    font-size: 15px; line-height: 1.85; color: var(--text);
}
.tag-intro p { margin: 0; }
.tag-block { margin: 26px 0 0; }
.tag-block h2 {
    font-size: 16px; margin: 0 0 12px; padding-left: 10px;
    border-left: 3px solid var(--brand);
}
.tagbox.dist a { font-size: 14px; }

/* ---------- 页脚 ---------- */
.site-ft { margin-top: 34px; padding: 18px 0 26px; }
.ft-nav { margin-bottom: 8px; }
.ft-nav a { margin-right: 14px; font-size: 14px; color: var(--muted); }
.ft-nav a:hover { color: var(--brand); }
.ft-cp { margin: 0; font-size: 13px; color: var(--muted); }
.ft-cp .icp { color: var(--muted); margin-left: 6px; }
.ft-cp .icp:hover { color: var(--brand); }

body.night .tag-intro { background: #1d2836; }
body.night .plink { background: #23272f; }
body.night .sh { background: #23272f; }
