/* ==========================================================================
   个人博客 · 样式表
   --------------------------------------------------------------------------
   设计约定：
   - 暖纸白底 + 墨黑字 + 朱砂红点缀，衬线体标题，适合中文长文阅读
   - 所有颜色走 CSS 变量，深浅色主题切换只改 <html data-theme>
   - 不依赖任何外部资源（字体/CDN 均用系统内置），国内服务器加载快
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root{
  --paper:#faf8f5;
  --surface:#ffffff;
  --surface-2:#f4f1ec;
  --ink:#1c1917;
  --ink-2:#44403c;
  --muted:#78716c;
  --line:#e7e2da;
  --accent:#b0413e;
  --accent-ink:#ffffff;
  --accent-soft:#f7ece9;
  --link:#0f766e;

  --tok-kw:#b0413e; --tok-str:#0f766e; --tok-com:#a8a29e;
  --tok-num:#a16207; --tok-fn:#1d4ed8;

  --radius:16px; --radius-sm:10px; --radius-xs:7px;
  --shadow:0 1px 2px rgba(28,25,23,.04), 0 8px 26px -14px rgba(28,25,23,.16);
  --shadow-lg:0 2px 6px rgba(28,25,23,.05), 0 24px 60px -28px rgba(28,25,23,.28);

  --maxw:1140px; --readw:724px;
  --sans:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  --serif:"Noto Serif SC","Source Han Serif SC","Songti SC","STSong","SimSun",Georgia,serif;
  --mono:"JetBrains Mono","Cascadia Code",Consolas,"SF Mono",Menlo,monospace;
}

html[data-theme="dark"]{
  --paper:#12100f;
  --surface:#1a1817;
  --surface-2:#221f1d;
  --ink:#ece8e3;
  --ink-2:#c9c3bb;
  --muted:#9a938a;
  --line:#2e2a27;
  --accent:#e07a5f;
  --accent-ink:#1a1817;
  --accent-soft:#2a201d;
  --link:#5eead4;

  --tok-kw:#e07a5f; --tok-str:#5eead4; --tok-com:#6b6560;
  --tok-num:#e0b45f; --tok-fn:#93b4ff;

  --shadow:0 1px 2px rgba(0,0,0,.3), 0 10px 30px -16px rgba(0,0,0,.7);
  --shadow-lg:0 2px 8px rgba(0,0,0,.4), 0 28px 64px -30px rgba(0,0,0,.9);
}

/* ---------- 2. 基础 ---------- */
*,*::before,*::after{box-sizing:border-box}
html{scroll-behavior:smooth; -webkit-text-size-adjust:100%}
body{
  margin:0; background:var(--paper); color:var(--ink);
  font-family:var(--sans); font-size:16px; line-height:1.75;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  display:flex; flex-direction:column; min-height:100vh;
}
img{max-width:100%; height:auto; display:block}
a{color:inherit; text-decoration:none}
button{font:inherit; cursor:pointer}
::selection{background:var(--accent); color:var(--accent-ink)}

.wrap{width:100%; max-width:var(--maxw); margin:0 auto; padding:0 24px}
.readwrap{width:100%; max-width:var(--readw); margin:0 auto; padding:0 24px}
.muted{color:var(--muted)}
main{flex:1}

:focus-visible{outline:2px solid var(--accent); outline-offset:3px; border-radius:4px}

/* ---------- 3. 顶部导航 ---------- */
.site-header{
  position:sticky; top:0; z-index:60;
  background:color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter:saturate(160%) blur(12px);
  -webkit-backdrop-filter:saturate(160%) blur(12px);
  border-bottom:1px solid transparent; transition:border-color .25s, box-shadow .25s;
}
.site-header.is-stuck{border-bottom-color:var(--line); box-shadow:0 6px 24px -20px rgba(0,0,0,.5)}
.nav{display:flex; align-items:center; gap:20px; height:64px}
.logo{display:flex; align-items:center; gap:10px; font-family:var(--serif); font-weight:700; font-size:18px; letter-spacing:.02em; white-space:nowrap}
.logo .mark{
  width:30px; height:30px; border-radius:9px; flex:none;
  display:grid; place-items:center; font-family:var(--serif); font-size:15px;
  background:var(--accent); color:var(--accent-ink);
}
.nav-links{display:flex; align-items:center; gap:4px; margin-left:auto; list-style:none; padding:0}
.nav-links a{
  display:block; padding:7px 13px; border-radius:999px; font-size:14.5px;
  color:var(--muted); transition:color .15s, background .15s;
}
.nav-links a:hover{color:var(--ink); background:var(--surface-2)}
.nav-links a.is-active{color:var(--accent); background:var(--accent-soft); font-weight:600}
.icon-btn{
  width:36px; height:36px; flex:none; display:grid; place-items:center;
  border:1px solid var(--line); border-radius:10px; background:var(--surface);
  color:var(--ink-2); transition:.15s;
}
.icon-btn:hover{border-color:var(--accent); color:var(--accent)}
.icon-btn svg{width:17px; height:17px}
.nav-toggle{display:none}
@media(max-width:820px){
  .nav-toggle{display:grid}
  .nav-links{
    position:absolute; top:64px; left:0; right:0; flex-direction:column; gap:2px;
    margin:0; padding:10px 18px 16px; align-items:stretch;
    background:var(--paper); border-bottom:1px solid var(--line);
    box-shadow:var(--shadow); display:none;
  }
  .nav-links.is-open{display:flex}
  .nav-links a{padding:11px 14px; border-radius:var(--radius-sm)}
}

/* ---------- 4. 首页 Hero ---------- */
.hero{position:relative; overflow:hidden; padding:76px 0 56px; border-bottom:1px solid var(--line)}
.hero::before{
  content:""; position:absolute; inset:-40% -20% auto -20%; height:120%;
  background:radial-gradient(58% 62% at 22% 0%, var(--accent-soft) 0%, transparent 62%),
             radial-gradient(46% 56% at 88% 12%, color-mix(in srgb, var(--link) 12%, transparent) 0%, transparent 60%);
  pointer-events:none;
}
.hero .wrap{position:relative}
.hero-eyebrow{
  display:inline-flex; align-items:center; gap:8px; font-size:13px; letter-spacing:.06em;
  text-transform:uppercase; color:var(--accent); font-weight:700; margin-bottom:16px;
}
.hero-eyebrow::before{content:""; width:22px; height:2px; background:var(--accent); border-radius:2px}
.hero h1{
  font-family:var(--serif); font-size:clamp(30px,4.6vw,46px); line-height:1.28;
  margin:0 0 16px; letter-spacing:-.01em; font-weight:700; max-width:22ch;
}
.hero h1 em{font-style:normal; color:var(--accent); position:relative}
.hero .sub{font-size:17px; color:var(--muted); max-width:56ch; margin:0 0 26px}
.hero-actions{display:flex; flex-wrap:wrap; gap:11px; margin-bottom:34px}
.btn{
  display:inline-flex; align-items:center; gap:8px; padding:10px 20px;
  border-radius:999px; font-size:14.5px; font-weight:600; border:1px solid transparent; transition:.16s;
}
.btn-primary{background:var(--accent); color:var(--accent-ink); box-shadow:var(--shadow)}
.btn-primary:hover{transform:translateY(-1px); box-shadow:var(--shadow-lg)}
.btn-ghost{border-color:var(--line); color:var(--ink-2); background:var(--surface)}
.btn-ghost:hover{border-color:var(--accent); color:var(--accent)}
.hero-stats{display:flex; flex-wrap:wrap; gap:36px; padding-top:24px; border-top:1px dashed var(--line)}
.hero-stats div strong{display:block; font-family:var(--serif); font-size:26px; line-height:1.2}
.hero-stats div span{font-size:13.5px; color:var(--muted)}

/* ---------- 5. 首页主体布局 ---------- */
.layout{display:grid; grid-template-columns:minmax(0,1fr) 306px; gap:52px; padding:56px 0 72px; align-items:start}
@media(max-width:940px){ .layout{grid-template-columns:minmax(0,1fr); gap:44px} }

.section-head{display:flex; align-items:baseline; justify-content:space-between; gap:16px; margin-bottom:22px}
.section-head h2{
  font-family:var(--serif); font-size:21px; margin:0; display:flex; align-items:center; gap:10px;
}
.section-head h2::before{content:""; width:4px; height:18px; border-radius:2px; background:var(--accent)}
.section-head .count{font-size:13.5px; color:var(--muted)}

/* 筛选条 */
.filter-bar{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:26px}
.chip{
  padding:5px 14px; border-radius:999px; font-size:13.5px; border:1px solid var(--line);
  background:var(--surface); color:var(--muted); transition:.15s;
}
.chip:hover{border-color:var(--accent); color:var(--accent)}
.chip.is-active{background:var(--accent); border-color:var(--accent); color:var(--accent-ink); font-weight:600}

/* 文章列表 */
.post-list{display:flex; flex-direction:column; gap:16px; list-style:none; margin:0; padding:0}
.post-item{
  position:relative; padding:22px 24px; border:1px solid var(--line); border-radius:var(--radius);
  background:var(--surface); transition:transform .18s, box-shadow .18s, border-color .18s;
}
.post-item:hover{transform:translateY(-2px); box-shadow:var(--shadow-lg); border-color:color-mix(in srgb, var(--accent) 34%, var(--line))}
.post-item::after{
  content:""; position:absolute; left:0; top:22px; bottom:22px; width:3px; border-radius:0 3px 3px 0;
  background:var(--accent); opacity:0; transition:opacity .18s;
}
.post-item:hover::after{opacity:1}
.post-item h3{
  font-family:var(--serif); font-size:19px; line-height:1.45; margin:0 0 8px; font-weight:700;
}
.post-item:hover h3{color:var(--accent)}
.post-item .excerpt{color:var(--muted); font-size:14.8px; margin:0 0 14px; line-height:1.7}
.post-meta{display:flex; flex-wrap:wrap; align-items:center; gap:14px; font-size:13px; color:var(--muted)}
.post-meta .dot{width:3px; height:3px; border-radius:50%; background:currentColor; opacity:.5}
.tag-list{display:flex; flex-wrap:wrap; gap:6px}
.tag{
  font-size:12px; padding:2px 9px; border-radius:6px; background:var(--surface-2);
  color:var(--ink-2); border:1px solid var(--line);
}
.post-item:hover .tag{background:var(--accent-soft); border-color:transparent; color:var(--accent)}
.empty{text-align:center; padding:48px 0; color:var(--muted); font-size:15px}

/* ---------- 6. 侧边栏 ---------- */
.sidebar{display:flex; flex-direction:column; gap:22px; position:sticky; top:84px}
@media(max-width:940px){ .sidebar{position:static} }
.card{
  padding:22px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface);
}
.card h3{
  font-size:13px; letter-spacing:.1em; text-transform:uppercase; color:var(--muted);
  margin:0 0 16px; font-weight:700;
}
.author{display:flex; gap:14px; align-items:center; margin-bottom:14px}
.avatar{
  width:52px; height:52px; flex:none; border-radius:14px; display:grid; place-items:center;
  font-family:var(--serif); font-size:20px; font-weight:700;
  background:var(--accent-soft); color:var(--accent); border:1px solid var(--line);
}
.author strong{display:block; font-size:15.5px; font-family:var(--serif)}
.author span{font-size:13px; color:var(--muted)}
.card p{font-size:14.3px; color:var(--muted); margin:0 0 16px; line-height:1.7}
.social{display:flex; flex-wrap:wrap; gap:8px}
.social a{
  font-size:13px; padding:6px 13px; border-radius:8px; border:1px solid var(--line);
  color:var(--ink-2); transition:.15s;
}
.social a:hover{border-color:var(--accent); color:var(--accent)}
.cloud{display:flex; flex-wrap:wrap; gap:7px}
.cloud a{
  font-size:12.8px; padding:4px 11px; border-radius:999px; background:var(--surface-2);
  border:1px solid var(--line); color:var(--ink-2); transition:.15s;
}
.cloud a:hover{background:var(--accent); border-color:var(--accent); color:var(--accent-ink)}
.mini-list{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:13px}
.mini-list a{display:block; font-size:14.3px; line-height:1.55; transition:color .15s}
.mini-list a:hover{color:var(--accent)}
.mini-list time{display:block; font-size:12.5px; color:var(--muted); margin-top:3px}

/* ---------- 7. 文章页 ---------- */
.progress-bar{position:fixed; top:0; left:0; height:2px; width:0; z-index:100; background:var(--accent); transition:width .08s linear}
.post-header{padding:56px 0 34px; border-bottom:1px solid var(--line); margin-bottom:40px}
.post-header .back{font-size:13.5px; color:var(--muted); display:inline-flex; align-items:center; gap:6px; margin-bottom:20px}
.post-header .back:hover{color:var(--accent)}
.post-header h1{
  font-family:var(--serif); font-size:clamp(26px,3.6vw,37px); line-height:1.35;
  margin:0 0 18px; letter-spacing:-.005em; font-weight:700;
}
.post-header .lede{font-size:16.5px; color:var(--muted); margin:0 0 22px; line-height:1.75}

.post-layout{display:grid; grid-template-columns:minmax(0,1fr) 232px; gap:52px; padding-bottom:72px; align-items:start}
@media(max-width:1020px){ .post-layout{grid-template-columns:minmax(0,1fr)} .toc-col{display:none} }

.toc-col{position:sticky; top:88px; font-size:13.5px}
.toc-col .toc-title{font-size:12px; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); font-weight:700; margin-bottom:12px}
.toc-list{list-style:none; margin:0; padding:0; border-left:1px solid var(--line); display:flex; flex-direction:column; gap:2px}
.toc-list a{
  display:block; padding:5px 0 5px 14px; margin-left:-1px; border-left:2px solid transparent;
  color:var(--muted); line-height:1.5; transition:.15s;
}
.toc-list a:hover{color:var(--ink)}
.toc-list a.is-active{color:var(--accent); border-left-color:var(--accent); font-weight:600}
.toc-list .lv3 a{padding-left:26px; font-size:13px}

/* 正文排版 */
.prose{font-size:16.6px; line-height:1.92; color:var(--ink-2)}
.prose > *:first-child{margin-top:0}
.prose h2{
  font-family:var(--serif); font-size:24px; color:var(--ink); margin:52px 0 18px;
  padding-bottom:10px; border-bottom:1px solid var(--line); scroll-margin-top:88px; line-height:1.4;
}
.prose h3{
  font-family:var(--serif); font-size:19px; color:var(--ink); margin:36px 0 12px;
  scroll-margin-top:88px; line-height:1.5;
}
.prose h4{font-size:16.5px; color:var(--ink); margin:26px 0 10px}
.prose p{margin:0 0 20px}
.prose ul,.prose ol{margin:0 0 20px; padding-left:24px}
.prose li{margin-bottom:9px}
.prose li::marker{color:var(--accent)}
.prose strong{color:var(--ink); font-weight:700}
.prose a{color:var(--link); border-bottom:1px solid color-mix(in srgb, var(--link) 35%, transparent); transition:.15s}
.prose a:hover{border-bottom-color:var(--link)}
.prose hr{border:none; border-top:1px solid var(--line); margin:40px 0}
.prose img{border-radius:var(--radius-sm); margin:24px 0}
.prose code{
  font-family:var(--mono); font-size:.875em; padding:2px 6px; border-radius:5px;
  background:var(--surface-2); border:1px solid var(--line); color:var(--accent);
  word-break:break-word;
}
.prose pre{
  position:relative; margin:0 0 24px; padding:18px 20px; overflow-x:auto;
  background:var(--surface-2); border:1px solid var(--line); border-radius:var(--radius-sm);
  font-size:13.8px; line-height:1.75;
}
.prose pre code{
  background:none; border:none; padding:0; color:var(--ink-2);
  font-size:inherit; word-break:normal;
}
.prose pre .lang-tag{
  position:absolute; top:0; right:0; font-family:var(--mono); font-size:10.5px;
  letter-spacing:.08em; text-transform:uppercase; color:var(--muted);
  padding:5px 11px; background:var(--surface); border-left:1px solid var(--line); border-bottom:1px solid var(--line);
  border-radius:0 var(--radius-sm) 0 var(--radius-xs); user-select:none;
}
.copy-btn{
  position:absolute; top:8px; right:8px; opacity:0; transition:opacity .18s;
  font-size:12px; padding:4px 10px; border-radius:6px; border:1px solid var(--line);
  background:var(--surface); color:var(--muted);
}
.prose pre:hover .copy-btn{opacity:1}
.copy-btn:hover{color:var(--accent); border-color:var(--accent)}
.copy-btn.done{color:var(--link); border-color:var(--link)}
.prose blockquote{
  margin:0 0 24px; padding:16px 22px; border-left:3px solid var(--accent);
  background:var(--accent-soft); border-radius:0 var(--radius-sm) var(--radius-sm) 0;
  color:var(--ink-2);
}
.prose blockquote p:last-child{margin-bottom:0}
.prose table{width:100%; border-collapse:collapse; margin:0 0 24px; font-size:14.8px}
.prose th,.prose td{padding:10px 14px; border:1px solid var(--line); text-align:left; vertical-align:top}
.prose th{background:var(--surface-2); color:var(--ink); font-weight:700; font-size:13.8px}
.prose tbody tr:nth-child(even){background:color-mix(in srgb, var(--surface-2) 55%, transparent)}

.tok-kw{color:var(--tok-kw); font-weight:600}
.tok-str{color:var(--tok-str)}
.tok-com{color:var(--tok-com); font-style:italic}
.tok-num{color:var(--tok-num)}
.tok-fn{color:var(--tok-fn)}

/* 文章底部 */
.post-footer{margin-top:56px; padding-top:28px; border-top:1px solid var(--line)}
.post-footer .tag-list{margin-bottom:24px}
.post-nav{display:grid; grid-template-columns:1fr 1fr; gap:14px}
@media(max-width:640px){ .post-nav{grid-template-columns:1fr} }
.post-nav a{
  padding:16px 18px; border:1px solid var(--line); border-radius:var(--radius-sm);
  background:var(--surface); transition:.16s;
}
.post-nav a:hover{border-color:var(--accent); transform:translateY(-1px)}
.post-nav .dir{font-size:12px; color:var(--muted); display:block; margin-bottom:5px}
.post-nav .ttl{font-family:var(--serif); font-size:15.5px; line-height:1.5; display:block}
.post-nav .next{text-align:right}

/* ---------- 8. 关于页 ---------- */
.page-header{padding:60px 0 36px; border-bottom:1px solid var(--line); margin-bottom:44px}
.page-header h1{font-family:var(--serif); font-size:clamp(28px,4vw,40px); margin:0 0 12px; line-height:1.3}
.page-header p{color:var(--muted); font-size:16.5px; margin:0; max-width:58ch}
.timeline{list-style:none; margin:0; padding:0 0 0 26px; border-left:2px solid var(--line)}
.timeline li{position:relative; padding-bottom:30px}
.timeline li::before{
  content:""; position:absolute; left:-33px; top:8px; width:11px; height:11px;
  border-radius:50%; background:var(--paper); border:2px solid var(--accent);
}
.timeline time{display:block; font-size:12.8px; letter-spacing:.05em; color:var(--accent); font-weight:700; margin-bottom:5px}
.timeline strong{display:block; font-family:var(--serif); font-size:16.5px; margin-bottom:5px}
.timeline p{margin:0; font-size:14.5px; color:var(--muted)}

.grid-3{display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:16px}
.feature{padding:20px 22px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface)}
.feature .ico{
  width:36px; height:36px; border-radius:10px; display:grid; place-items:center;
  background:var(--accent-soft); color:var(--accent); font-size:17px; margin-bottom:14px;
}
.feature h3{font-family:var(--serif); font-size:16px; margin:0 0 7px}
.feature p{margin:0; font-size:14.3px; color:var(--muted); line-height:1.7}

/* ---------- 9. 页脚 ---------- */
.site-footer{margin-top:auto; border-top:1px solid var(--line); background:var(--surface)}
.footer-main{display:grid; grid-template-columns:1.6fr 1fr 1fr; gap:40px; padding:48px 0 34px}
@media(max-width:760px){ .footer-main{grid-template-columns:1fr; gap:30px} }
.footer-main h4{
  font-size:12px; letter-spacing:.1em; text-transform:uppercase; color:var(--muted);
  margin:0 0 14px; font-weight:700;
}
.footer-main .logo{margin-bottom:12px}
.footer-main p{font-size:14px; color:var(--muted); margin:0; max-width:38ch; line-height:1.75}
.footer-main ul{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:9px}
.footer-main ul a{font-size:14.2px; color:var(--muted); transition:color .15s}
.footer-main ul a:hover{color:var(--accent)}
.footer-bottom{
  border-top:1px solid var(--line); padding:20px 0; font-size:13.3px; color:var(--muted);
  display:flex; flex-wrap:wrap; gap:10px 22px; align-items:center; justify-content:space-between;
}
.footer-bottom a{transition:color .15s}
.footer-bottom a:hover{color:var(--accent)}
.icp{display:inline-flex; align-items:center; gap:7px}
.icp svg{width:13px; height:13px; opacity:.7}

/* 回到顶部 */
.to-top{
  position:fixed; right:26px; bottom:26px; width:42px; height:42px; z-index:70;
  display:grid; place-items:center; border-radius:12px; border:1px solid var(--line);
  background:var(--surface); color:var(--ink-2); box-shadow:var(--shadow);
  opacity:0; visibility:hidden; transform:translateY(10px); transition:.22s;
}
.to-top.is-show{opacity:1; visibility:visible; transform:none}
.to-top:hover{color:var(--accent); border-color:var(--accent)}
.to-top svg{width:17px; height:17px}

/* 打印 */
@media print{
  .site-header,.site-footer,.toc-col,.to-top,.progress-bar,.copy-btn,.post-nav{display:none!important}
  body{background:#fff; color:#000}
  .prose pre{border:1px solid #ccc; background:#f7f7f7}
}
