

/* =========================================================
   FULL BLOG EXTENSION — pages, posts, archive, sidebar,
   comments, admin, footer, responsive
   ========================================================= */

/* ---------- Global layout helpers ---------- */
.layout{display:grid;grid-template-columns:1fr 320px;gap:38px;}
@media(max-width:960px){.layout{grid-template-columns:1fr;}}
/* grid/flex 子项默认 min-width:auto，会被内部「不能断行的内容」撑开，
   最典型的是文章里的 <pre> 代码块（最长一行可达 75 字符 ≈ 630px）。
   一旦被撑开，pre 自己的 overflow:auto 就永远不会触发，整个页面反而变宽。
   加 min-width:0 让子项可以收缩，滚动条才会出现在 pre 内部。 */
.layout > *,
.article__body,
.article__content,
.sidebar{
  min-width: 0;
}
.sidebar__sticky{position:sticky;top:20px;}

/* ---------- Hero for inner pages (smaller) ---------- */
.hero--inner{min-height:340px;justify-content:center;}
.hero--inner .hero__body{max-width:820px;margin:0 auto;padding:40px 20px;}
.hero--inner .hero__headline{font-size:clamp(24px,3.2vw,40px);font-weight:800;}
.hero--inner h1{margin-top:8px;}
.page-intro{color:rgba(255,255,255,.9);font-size:16px;max-width:640px;}

/* ---------- Breadcrumbs ---------- */
.crumbs{position:relative;z-index:2;font-size:12.5px;color:rgba(255,255,255,.75);margin-bottom:14px;display:flex;gap:8px;flex-wrap:wrap;}
.crumbs a{color:var(--accent-2);}
.crumbs b{font-weight:600;color:#fff;}

/* ---------- Section shell ---------- */
.page{background:#fff;padding:46px 0 70px;}
.page__head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:26px;flex-wrap:wrap;}
.page__head h1{font-family:var(--font-head);font-size:30px;font-weight:700;position:relative;padding-left:16px;}
.page__head h1::before{content:"";position:absolute;left:0;top:6px;bottom:6px;width:4px;background:var(--accent);border-radius:2px;}
.page__head--alt h1{padding-left:0;}
.page__head--alt h1::before{display:none;}

/* ---------- Cards grid ---------- */
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:26px;}
.grid-2{display:grid;grid-template-columns:repeat(2,1fr);gap:26px;}
.grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:26px;}
@media(max-width:960px){
  .grid-3,.grid-4{grid-template-columns:repeat(2,1fr);}
}
@media(max-width:560px){
  .grid-3,.grid-4,.grid-2{grid-template-columns:1fr;}
}
.card--meta{display:flex;align-items:center;gap:12px;font-size:12.5px;color:#6b6b6b;margin-top:14px;}

/* ---------- 卡片等高对齐 ----------
   标题行数不同时（有的 1 行、有的 3 行），摘要和底部的日期/阅读时长
   就在不同的高度上，一排卡片看起来参差不齐。
   让 .card 成为纵向 flex、.card__body 撑满剩余高度、日期用 margin-top:auto
   顶到最底，同一行的卡片底部就对齐了。 */
.card{display:flex;flex-direction:column;height:100%;}
.card__body{flex:1;display:flex;flex-direction:column;}
.card__body .card__cat{flex:none;}
.card__body a.card__title{flex:none;}
/* 摘要固定 3 行高度：行数少的也占满，标题长短不一时底部不会错位 */
.card__body p{
  display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;
  overflow:hidden;flex:1;
}
/* 对比度：原来的 #9a9a9a 在白底只有 2.81，远低于 WCAG AA 的 4.5 */
.card__date{margin-top:auto;padding-top:12px;font-size:12.5px;color:#6b6b6b;}

/* ---------- List layout (archive) ---------- */
.list-row{display:grid;grid-template-columns:220px 1fr;gap:22px;padding:20px 0;border-bottom:1px solid var(--line);align-items:center;}
.list-row:first-of-type{border-top:1px solid var(--line);}
.list-row img{width:220px;height:140px;object-fit:cover;border-radius:10px;}
.list-row h3{font-family:var(--font-head);font-size:19px;line-height:1.3;margin:6px 0;}
@media(max-width:700px){.list-row{grid-template-columns:1fr;}.list-row img{width:100%;height:auto;}}

/* ---------- Pagination ---------- */
.pagination{display:flex;gap:10px;margin-top:40px;justify-content:center;}
.pagination a,.pagination span{display:inline-flex;align-items:center;justify-content:center;min-width:40px;height:40px;padding:0 12px;border:1px solid var(--line);border-radius:8px;font-weight:600;font-size:14px;}
.pagination .active{background:var(--accent);color:#fff;border-color:var(--accent);}
.pagination a:hover{border-color:var(--accent);color:var(--accent);}

/* ---------- Sidebar widgets ---------- */
.widget{background:#fff;border:1px solid var(--line);border-radius:12px;padding:22px;margin-bottom:24px;}
.widget__title{font-family:var(--font-head);font-size:18px;font-weight:700;padding-bottom:12px;margin-bottom:14px;border-bottom:2px solid #f1f1f1;position:relative;}
.widget__title::after{content:"";position:absolute;left:0;bottom:-2px;width:42px;height:2px;background:var(--accent);}
.widget__list a{display:flex;gap:12px;align-items:center;padding:9px 0;border-bottom:1px dashed #eee;font-size:14px;}
.widget__list a:last-child{border-bottom:0;}
.widget__list a:hover{color:var(--accent);}
.widget__list .thumb{width:46px;height:46px;border-radius:50%;overflow:hidden;flex:none;border:1px solid var(--line);}
.widget__list .thumb img{width:100%;height:100%;object-fit:cover;}
.widget__list .tt{line-height:1.3;}
.tags{display:flex;flex-wrap:wrap;gap:8px;}
.tag{background:#f5f4f3;border-radius:20px;padding:6px 13px;font-size:12.5px;font-weight:600;color:#555;}
.tag:hover{background:var(--accent);color:#fff;}
/* BGM 播放失败提示 */
.bgm-err{
  flex-basis:100%;margin-top:10px;font-size:12.5px;line-height:1.5;
  color:#8a2b27;background:rgba(216,46,42,.08);
  border:1px solid rgba(216,46,42,.25);border-radius:8px;padding:8px 11px;
}
.bgm-player.is-error{opacity:1;}

/* 标签颜色只用左侧小圆点表示（--tag-dot 由模板内联给出）。
   之前的做法是整块背景色内联在 style 上，优先级高于 .tag:hover，
   结果鼠标悬停时颜色纹丝不动，而且整排彩色标签和黑红白杂志风打架。 */
.tag{position:relative;}
.tag[style*="--tag-dot"]{padding-left:24px;}
.tag[style*="--tag-dot"]::before{
  content:"";position:absolute;left:11px;top:50%;
  width:6px;height:6px;margin-top:-3px;border-radius:50%;
  background:var(--tag-dot);transition:background .15s;
}
.tag[style*="--tag-dot"]:hover::before{background:#fff;}

/* ---------- Single post ---------- */
.article__body{background:#fff;}
.article__content{max-width:740px;font-size:17px;color:#333;line-height:1.85;}
.article__content p{margin-bottom:1.3em;}
.article__content h2{font-family:var(--font-head);font-size:26px;color:var(--ink);margin:1.6em 0 .6em;}
.article__content h3{font-family:var(--font-head);font-size:21px;color:var(--ink);margin:1.4em 0 .5em;}
.article__content blockquote{border-left:4px solid var(--accent);background:#faf7f6;padding:14px 20px;font-style:italic;color:#555;margin:1.4em 0;border-radius:0 8px 8px 0;}
.article__content img{width:100%;border-radius:10px;margin:1.4em 0;}
.article__content a{color:var(--accent);text-decoration:underline;}
/* article hero inside the white page: a big cover band */
/* 用 aspect-ratio 代替固定 height：固定 360px 在手机上会变成近正方形，把图裁得变形 */
.article-cover{width:100%;max-width:1000px;aspect-ratio:16/9;height:auto;object-fit:cover;border-radius:14px;margin:0 0 30px;position:relative;}
.article-meta-strip{display:flex;align-items:center;gap:16px;flex-wrap:wrap;color:#6b6b6b;font-size:13.5px;margin-bottom:30px;}
.article-meta-strip .author{display:flex;align-items:center;gap:10px;font-weight:600;color:var(--ink);}

/* ---------- Comments ---------- */
.comments{max-width:740px;margin-top:50px;background:#fff;border:1px solid var(--line);border-radius:14px;padding:28px;}
.comments h3{font-family:var(--font-head);font-size:22px;margin-bottom:20px;}
.comment{border-bottom:1px solid #eee;padding:14px 0;display:flex;gap:12px;}
.comment:last-child{border-bottom:0;}
.comment .avatar{width:40px;height:40px;flex:none;font-weight:800;color:#fff;background:var(--accent);display:flex;align-items:center;justify-content:center;border-radius:50%;}
.comment .cbody{flex:1;}
.comment .cmeta{font-size:12.5px;color:#6b6b6b;margin-bottom:4px;}
.comment .cbody p{color:#444;font-size:14.5px;}
.form-row{margin-bottom:14px;}
.form-row label{display:block;font-weight:600;font-size:13px;margin-bottom:6px;}
.form-row input,.form-row textarea,.form-row select{width:100%;padding:11px 13px;border:1px solid var(--line);border-radius:8px;font-size:14px;font-family:inherit;background:#fff;}
.form-row textarea{min-height:110px;resize:vertical;}
.form-row input:focus,.form-row textarea:focus,.form-row select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgba(216,46,42,.12);}
.btn{display:inline-flex;align-items:center;gap:8px;background:var(--accent);color:#fff;border:0;border-radius:8px;padding:12px 24px;font-weight:700;font-size:14px;cursor:pointer;text-align:center;}
.btn:hover{opacity:.9;}
.btn--dark{background:var(--ink);}
.btn--ghost{background:#fff;color:var(--ink);border:1px solid var(--line);}
.flash{background:#e8f7ee;color:#1b7a45;border:1px solid #bfe6cd;border-radius:8px;padding:12px 16px;margin-bottom:12px;font-size:14px;}

/* ---------- Search ---------- */
.searchbar{display:flex;gap:10px;max-width:560px;margin-bottom:28px;}
.searchbar input{flex:1;padding:13px 16px;border:1px solid var(--line);border-radius:8px;font-size:15px;}
.searchbar .btn{padding:13px 26px;}

/* ---------- Header nav (already defined) + dropdown adds ---------- */
.nav .brand{user-select:none;}
.site-header{
  /* 恒定 sticky 吸顶，毛玻璃盖在 hero 上。
     之前是 relative，滚过 10px 后由 JS 切成 fixed —— 一脱离文档流，
     整页内容就向上跳 76px（正好一个导航高度），而且此后所有锚点跳转都要
     靠把 scroll-padding-top 加到 nav-h*2 来补那段跳变。
     现在 position 不随滚动变化，只有阴影变，页面不再上下弹。 */
  position:sticky;top:0;z-index:1000;
  transition:box-shadow .25s ease;
}
.site-header.is-frozen .nav{ box-shadow:0 2px 14px rgba(0,0,0,0.18); }

/* 让 hero 背景延伸到导航下方，毛玻璃才能透出 hero 图片；导航随页面滚动(不吸顶) */
.hero, .hero--inner{ margin-top: calc(-1 * var(--nav-h)); }
.hero__body{ padding-top: calc(var(--nav-h) + 60px); }
.hero--inner .hero__body{ padding-top: calc(var(--nav-h) + 40px); }
.hero--inner .pages-nudge, .hero--inner .crumbs{ margin-top: 0; }
/* swap the hero bg to a scenic page-header band for inner pages */
.page-hero .hero__bg{background:radial-gradient(140% 120% at 20% 30%, rgba(190,32,30,.7), transparent 60%),linear-gradient(150deg,#2a1517,#4a0f13 55%,#180609);}

/* ---------- Footer ---------- */
footer.site-footer{background:#151010;color:#cfc8c8;padding:0;border-top:3px solid var(--accent);}
.footer-top{display:grid;grid-template-columns:2fr 1fr 1fr;gap:36px;padding:44px 0;}
.footer-top h4{color:#fff;font-family:var(--font-head);font-size:17px;margin-bottom:14px;}
.footer-top p{font-size:13.5px;color:#a89d9d;line-height:1.7;}
.footer-top ul li{margin-bottom:9px;}
.footer-top ul a{color:#cfc8c8;font-size:13.5px;}
.footer-top ul a:hover{color:var(--accent-2);}
.footer-bottom{border-top:1px solid rgba(255,255,255,.1);padding:18px 0;text-align:center;font-size:12.5px;color:#b5aaaa;}
.footer-logo{display:flex;align-items:center;gap:8px;margin-bottom:12px;color:#fff;font-weight:800;font-size:18px;}
@media(max-width:820px){.footer-top{grid-template-columns:1fr;}}

/* ---------- Admin ---------- */
.admin-panel{background:#fff;border:1px solid var(--line);border-radius:14px;padding:30px;max-width:820px;}
.admin-panel h2{font-family:var(--font-head);margin-bottom:18px;}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:0 18px;}
.admin-post-row{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:12px 0;border-bottom:1px solid #eee;font-size:14px;}
.admin-post-row h4{font-size:15px;}
.admin-post-row .meta{font-size:12px;color:#999;margin-top:2px;}
.admin-actions{display:flex;gap:8px;flex-wrap:wrap;}
.mini-btn{font-size:12px;padding:6px 12px;border-radius:6px;border:1px solid var(--line);background:#fff;cursor:pointer;font-weight:600;}
.mini-btn--del{color:var(--accent);border-color:#f2c4c2;}
.mini-btn--del:hover{background:var(--accent);color:#fff;}

/* ---------- States ---------- */
.empty{padding:50px 0;text-align:center;color:#6b6b6b;font-size:15px;}

/* =========================================================
   PRINT / MISC
   ========================================================= */
.two-cols{display:grid;grid-template-columns:1fr 1fr;gap:22px;}
@media(max-width:700px){.two-cols{grid-template-columns:1fr;}}


/* =========================================================
   FROSTED-GLASS DROPDOWN / MOBILE MENU  (requirement #5)
   Translucent + backdrop blur so page content shows through.
   =========================================================
*/
.nav {
  background: rgba(28,16,16,0.55);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 1px 10px rgba(0,0,0,0.15);
}
.dropdown {
  background: rgba(255,255,255,0.78) !important;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.4);
  box-shadow: 0 18px 44px rgba(0,0,0,0.20) !important;
}
.dropdown a { color:#333; }
.dropdown a:hover { background: rgba(216,46,42,0.08); color: var(--accent); }
.mobile-menu {
  background: rgba(255,255,255,0.82) !important;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-bottom: 1px solid rgba(255,255,255,0.4);
}

/* ---------- Tables (Markdown / 导入的表格) ---------- */
.article__content table, .preview table {
  width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 15px;
  border: 1px solid #e3e1df; border-radius: 8px; overflow: hidden;
}
.article__content th, .preview th {
  background: #faf8f6; color: #333; font-weight: 700; text-align: left;
  padding: 10px 14px; border: 1px solid #e3e1df;
}
.article__content td, .preview td {
  padding: 9px 14px; border: 1px solid #e7e5e3;
}
.article__content tr:nth-child(even) td, .preview tr:nth-child(even) td { background: #fbfafa; }
.article__content table a, .preview table a { color: var(--accent); }

/* ============ BGM 播放器（长条椭圆形） ============ */
.bgm-player{
  display:flex;align-items:center;gap:10px;max-width:720px;margin:6px auto 26px;
  padding:10px 18px;border-radius:999px;background:linear-gradient(180deg,#f7f5f3,#eceae7);
  border:1px solid #e2dfdb;box-shadow:0 4px 16px rgba(0,0,0,.06);position:relative;
}
.bgm-thumb{font-size:22px;flex:none;}
.bgm-btn{
  width:36px;height:36px;border-radius:50%;border:0;background:#d82e2a;color:#fff;
  font-size:15px;cursor:pointer;display:flex;align-items:center;justify-content:center;flex:none;
  transition:.15s;
}
.bgm-btn:hover{background:#a81f1c;}
.bgm-btn[data-act='toggle']{width:44px;height:44px;font-size:17px;}
.bgm-info{flex:1;min-width:0;}
.bgm-name{font-size:13px;font-weight:700;color:#333;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:4px;}
.bgm-track{display:flex;align-items:center;gap:8px;min-width:0;}
.bgm-seek{flex:1;min-width:0;height:6px;-webkit-appearance:none;appearance:none;border-radius:3px;background:#d8d4cf;outline:none;cursor:pointer;}
.bgm-seek::-webkit-slider-thumb{-webkit-appearance:none;width:14px;height:14px;border-radius:50%;background:#d82e2a;cursor:pointer;}
.bgm-time{font-size:11px;color:#666;font-variant-numeric:tabular-nums;white-space:nowrap;flex:none;}

@media(max-width:600px){
  .bgm-player{flex-wrap:wrap;padding:10px 12px;border-radius:22px;gap:8px;}
  .bgm-btn{width:32px;height:32px;font-size:13px;}
  .bgm-btn[data-act='toggle']{width:40px;height:40px;}
  .bgm-thumb{font-size:18px;}
  .bgm-time{font-size:10px;}
}

/* Mermaid 容器 */
#main-content .mermaid-host,
.article__content svg.mermaid{max-width:100%;}
.article__content pre{background:#1e1e1e;color:#eee;padding:12px 14px;border-radius:8px;overflow:auto;font-size:14px;max-width:100%;-webkit-overflow-scrolling:touch;}
.article__content code.language-mermaid svg{max-width:100%;height:auto;background:#fff;border-radius:8px;}

/* ============ 首页大图轮转（淡入淡出） ============ */

/* 轮播指示点的样式统一放在文件末尾的新块里（那里的 markup 是 <button>） */
/* ============ 全屏搜索覆盖层 ============ */
.search-overlay{position:fixed;inset:0;z-index:2000;background:rgba(8,6,6,.5);backdrop-filter:blur(6px);display:none;flex-direction:column;align-items:center;padding:12vh 20px 20px;}
.search-overlay.show{display:flex;}
.search-overlay .search-box{width:min(640px,92%);display:flex;align-items:center;gap:10px;background:#fff;border-radius:999px;padding:12px 20px;box-shadow:0 18px 50px rgba(0,0,0,.3);}
.search-box input{flex:1;border:0;outline:0;font-size:18px;font-weight:600;background:transparent;color:#222;}
.search-x{cursor:pointer;font-size:20px;color:#6b6b6b;background:none;border:0;line-height:1;padding:4px;}
.search-x:hover{color:#d82e2a;}
.search-results{width:min(640px,92%);margin-top:14px;max-height:60vh;overflow:auto;}
.search-results a{display:flex;gap:14px;align-items:center;background:#fff;border-radius:12px;padding:12px 16px;margin-bottom:8px;box-shadow:0 6px 22px rgba(0,0,0,.12);transition:.15s;}
.search-results a:hover{transform:translateY(-2px);border:1px solid #d82e2a;}
.search-results img{width:56px;height:44px;object-fit:cover;border-radius:6px;flex:none;}
.search-results .st{font-weight:700;color:#222;}
.search-results .st small{display:block;font-weight:600;color:#d82e2a;font-size:12px;}
.search-results .snone{color:#eee;text-align:center;padding:20px;background:rgba(255,255,255,.1);border-radius:12px;}

/* ============ 浅色毛玻璃导航（Bug修复：白底黑字可读） ============ */
.site-header,
.site-header .nav {
  background: rgba(255,255,255,.42) !important;
  backdrop-filter: blur(26px) saturate(190%);
  -webkit-backdrop-filter: blur(26px) saturate(190%);
  border-bottom: 1px solid rgba(255,255,255,.45);
  box-shadow: 0 4px 22px rgba(0,0,0,.10), inset 0 1px 0 rgba(255,255,255,.55);
}
.site-header .brand span,
.site-header .menu a,
.site-header .menu a:visited,
.site-header .brand,
.site-header .nav a { color: #20242b !important; }
.site-header .brand svg { stroke: var(--accent) !important; }
.site-header .menu a:hover { color: var(--accent) !important; }
.site-header .search svg { stroke: #20242b !important; }
.site-header .burger span { background: #20242b !important; }
.site-header .menu .caret { color: #6b6b6b !important; }
.site-header .dropdown a { color: #333; }
.site-header .pin--new, .pin--hot { color: #fff; }
/* ============ 首页大图轮转（重写：双层淡入淡出，最稳妥） ============ */
.hero-slider{position:relative;overflow:hidden;min-height:720px;display:block;background:#111;}
.hero-slider .hero-bg{position:absolute;inset:0;background-color:#111;
  background-size:cover;background-position:center center;background-repeat:no-repeat;
  opacity:0;transition:opacity .9s ease;}
.hero-slider .hero-bg.on{opacity:1;}
.hero-slider .hero-copy{position:absolute;inset:0;z-index:5;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(90deg, rgba(0,0,0,.52) 0%, rgba(0,0,0,.20) 42%, rgba(0,0,0,0) 68%);}
.hero-slider .hero-copy .copy-inner{max-width:var(--maxw);width:100%;padding:0 20px;}
.hero-slider .hero__headline a{color:#fff;text-shadow:0 2px 12px rgba(0,0,0,.8),0 1px 3px rgba(0,0,0,.6);}
.hero-slider .hero__meta{color:rgba(255,255,255,.92);}
.hero-slider .hero__meta .meta-author,.hero-slider .hero__meta .meta-cat{color:#fff;text-shadow:0 1px 6px rgba(0,0,0,.7);}
@media(max-width:720px){ .hero-slider{min-height:560px;} }
/* BGM 播放器图标（线性/描边风格，替换 emoji） */
.bgm-thumb{display:flex;align-items:center;justify-content:center;color:#d82e2a;}
.bgm-thumb svg{width:22px;height:22px;}
.bgm-btn{display:flex;align-items:center;justify-content:center;padding:0;}
.bgm-btn svg{width:20px;height:20px;display:block;}
.bgm-btn[data-act="toggle"] svg{width:18px;height:18px;}
.ic-pause{display:none;}
.bgm-player.is-playing .ic-play{display:none;}
.bgm-player.is-playing .ic-pause{display:block;}
/* 快退/快进：更轻的幽灵按钮，避免突兀 */
.bgm-btn[data-act="rwd"],.bgm-btn[data-act="fwd"]{
  width:34px;height:34px;background:transparent;color:#b3271f;border:1px solid rgba(216,46,42,.35);
}
.bgm-btn[data-act="rwd"]:hover,.bgm-btn[data-act="fwd"]:hover{background:rgba(216,46,42,.10);color:#a81f1c;}
/* ============ 文章标签 ============ */
.article-tags{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px;}
.article-tags .tag{font-size:12.5px;padding:4px 11px;border-radius:999px;text-decoration:none;background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.35);color:#fff;transition:opacity .18s;}
.article-tags .tag:hover{opacity:.82;background:rgba(255,255,255,.28);color:#fff;}
/* 文章 hero 里是深色背景：圆点用标签自己的颜色，悬停变白 */
.article-tags .tag[style*="--tag-dot"]{padding-left:26px;}
.article-tags .tag[style*="--tag-dot"]:hover::before{background:#fff;}
.widget .tags .tag em{font-style:normal;opacity:.75;font-size:11px;margin-left:3px;}
.widget .tags .tag{text-decoration:none;}


/* =========================================================================
   移动端响应式修复（问题3）
   症状：窄屏比例不对、上下错位、出现横向滚动。
   对策：兜底禁止横向溢出 + 按 768/560 两档收紧间距与字号。
   ========================================================================= */

/* --- 兜底：任何元素都不许把页面撑得比视口宽 ---
   注意：这里**不能**给 html/body 加 overflow-x:hidden。
   一旦 overflow-x 不是 visible，该祖先就成了新的滚动容器，
   而 position:sticky 的子元素会相对"这个滚动容器"而不是视口粘附——
   结果是 .site-header 完全不再吸顶（实测滚到 400px 时 header 的 top 是 -400）。
   用 max-width + clip 之外的常规约束（下面各处的 min-width:0 / word-break）来防溢出，
   拿捏不住的横向溢出交给下面 clip-path 的写法兜底。 */
html, body { max-width: 100%; }
html { overflow-x: clip; }
body { overflow-x: clip; }
/* 长单词/长 URL 不撑破容器 */
.article__content, .preview, .card, .list-row h3, .page__head h1 { overflow-wrap: break-word; word-wrap: break-word; }

/* ---------- 文章正文里的列表 ----------
   style.css 里有一句全局的 ul{list-style:none}（为了去掉导航菜单的标记），
   它把正文列表的小圆点也一起干掉了 —— Joplin 里正常的 "- 项目"，
   发到博客上圆点和缩进全没了。这里把正文列表的样式完整补回来：
   标记 + 缩进 + 层级区分 + 嵌套时的空行收紧。 */
.article__content ul,
.article__content ol{ margin:1em 0; padding-left:1.8em; }
.article__content ul{ list-style:disc; }
.article__content ul ul{ list-style:circle; margin:.35em 0; }
.article__content ul ul ul{ list-style:square; }
.article__content ol{ list-style:decimal; }
.article__content ol ol{ list-style:lower-alpha; }
.article__content li{ margin:.35em 0; line-height:1.7; }
/* 列表项里再嵌段落/列表时不要撑出大空隙 */
.article__content li > p{ margin:.35em 0; }
.article__content li > ul,
.article__content li > ol{ margin:.35em 0 .35em 0; }
/* 标记颜色跟随强调色，和标题的红色竖线呼应 */
.article__content li::marker{ color:var(--accent); }
/* 任务列表（- [ ] / - [x]）不需要额外的圆点 */
.article__content li:has(> input[type=checkbox]){ list-style:none; margin-left:-1.2em; }
/* 媒体元素永不超宽 */
.article__content img, .article__content video, .article__content iframe,
.preview img, .preview video, .preview iframe { max-width: 100%; height: auto; }

@media (max-width: 768px) {
  /* 导航：76px 在手机上太高，且左右留白把元素挤变形 */
  :root { --nav-h: 60px; }
  .nav { height: var(--nav-h); }
  .brand { margin-right: 14px; gap: 8px; }
  .brand svg { width: 32px; height: 32px; }
  .nav__tools { gap: 12px; }
  .search-label { display: none; }       /* 只留放大镜图标，省空间 */
  .search { gap: 0; }

  .container { padding: 0 16px; }

  /* 首屏大图：720px 在手机上过高，导致上下大片空白 */
  .hero { min-height: 460px; }
  .hero__body { padding: 40px 16px 24px; max-width: 100%; }
  .hero__headline { letter-spacing: -.5px; }
  .hero__meta { gap: 10px; font-size: 12.5px; }
  /* 小屏 flex-wrap 后分隔圆点会孤立在行尾，直接隐藏 */
  .hero__meta .meta-sep { display: none; }
  .hero__recs { padding: 20px 0 24px; }
  .rec-thumb { width: 56px; height: 56px; }
  .rec-title { font-size: 13.5px; }

  .hero--inner { min-height: 240px; }
  .hero--inner .hero__body { padding: 26px 16px; }
  .page-intro { font-size: 14.5px; }

  .page { padding: 28px 0 44px; }
  .section__head { padding: 34px 0 8px; }
  .featured { padding: 16px 0 40px; }
  .grid-sm, .grid-2, .grid-3, .grid-4 { gap: 18px; }

  /* 文章正文 */
  .article-cover { border-radius: 10px; margin-bottom: 20px; }
  .article__content { font-size: 16px; line-height: 1.75; }
  .article__content h1 { font-size: 26px; }
  .article__content h2 { font-size: 22px; }
  .article__content h3 { font-size: 19px; }
  .article__content pre { font-size: 13px; padding: 10px 12px; }
  .article__content table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 侧边栏在窄屏变成流式，取消 sticky 以免遮挡 */
  .sidebar__sticky { position: static; }

  /* 页脚 */
  .footer-top { gap: 22px; }

  /* 移动端下拉菜单：防止内容撑宽 */
  .mobile-menu { overflow-x: hidden; }
  .mobile-menu > li > a { justify-content: space-between; }
}

@media (max-width: 560px) {
  .hero { min-height: 420px; }
  .hero__body { padding: 32px 16px 20px; }
  .hero__recs .container { gap: 18px; }

  /* 搜索覆盖层：手机上别用 12vh 的大留白 */
  .search-overlay { padding: 10vh 14px 14px; }
  .search-overlay .search-box { width: 100%; padding: 10px 16px; }
  .search-box input { font-size: 16px; }
  .search-results { width: 100%; max-height: 64vh; }
  .search-results a { padding: 10px 12px; gap: 10px; }
  .search-results img { width: 46px; height: 36px; }

  /* BGM 播放器：小屏按钮和进度条换行排布 */
  .bgm-player { gap: 8px; }
  .bgm-btn[data-act='toggle'] { width: 40px; height: 40px; }

  .crumbs { font-size: 11.5px; }
  .pagination a, .pagination span { min-width: 34px; height: 34px; padding: 0 10px; font-size: 13px; }
}

/* =========================================================================
   本轮修复新增样式
   ========================================================================= */

/* ---------- 可访问性：屏幕阅读器专用文本 ---------- */
.visually-hidden{
  position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}
/* 键盘聚焦可见（之前 :focus 被 outline:none 抹掉了） */
a:focus-visible,button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible{
  outline:3px solid #1a6ee0;outline-offset:2px;border-radius:4px;
}

/* ---------- 下拉菜单按钮化（原来是个 href="#" 的 <a>） ---------- */
.menu .menu-dd-btn{
  display:flex;align-items:center;gap:5px;padding:8px 0;
  background:none;border:0;font:inherit;font-weight:600;color:#20242b;
  cursor:pointer;white-space:nowrap;
}
.menu .menu-dd-btn .caret{font-size:8px;opacity:.85;color:#8a8a8f;transition:transform .2s;}
.has-dd.open > .menu-dd-btn .caret,
.has-dd:hover > .menu-dd-btn .caret{transform:rotate(180deg);}
.has-dd.open > .dropdown{opacity:1;visibility:visible;transform:translateY(0);}
/* 键盘 Tab 到菜单项时也要能展开 */
.has-dd:focus-within > .dropdown{opacity:1;visibility:visible;transform:translateY(0);}

/* ---------- 首页轮播：暂停按钮 + 指示点 ---------- */
.hero-slider .hero-bg img{width:100%;height:100%;object-fit:cover;display:block;}
.hero__ctrl{
  /* z-index 必须高于 .hero-copy（它 inset:0 铺满整个 hero 且被抬到 z-index:7）。
     之前这里是 6，比 .hero-copy 低，于是暂停按钮和指示点**点不动**——
     视觉上看得见，实际点击全被透明的 .hero-copy 接走了。 */
  position:absolute;left:0;right:0;bottom:26px;z-index:8;
  display:flex;align-items:center;justify-content:center;gap:12px;
}
.hero__pause{
  width:34px;height:34px;border-radius:50%;cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  background:rgba(0,0,0,.45);border:1px solid rgba(255,255,255,.45);color:#fff;
  transition:background .18s;
}
.hero__pause:hover{background:rgba(0,0,0,.7);}
.hero__pause svg{width:14px;height:14px;display:block;}
.hero__pause .ic-play{display:none;}
.hero__pause.paused .ic-play{display:block;}
.hero__pause.paused .ic-pause{display:none;}
.hero__dots{display:flex;align-items:center;gap:8px;}
.hero__dots .dot{
  width:10px;height:10px;border-radius:50%;cursor:pointer;padding:0;border:0;
  background:rgba(255,255,255,.55);transition:background .2s,width .2s;
}
.hero__dots .dot:hover{background:rgba(255,255,255,.85);}
.hero__dots .dot.active{background:#fff;width:24px;border-radius:5px;}
/* 用户开了"减少动态效果"就不再自动播放 */
@media (prefers-reduced-motion: reduce){
  .hero-slider .hero-bg{transition:none;}
  html{scroll-behavior:auto;}
}

/* ---------- GitHub 风格提示块 [!NOTE] 等 ---------- */
.callout{
  display:flex;gap:12px;align-items:flex-start;
  margin:1.5em 0;padding:14px 18px;border-radius:10px;
  border-left:4px solid var(--callout-line,#3b82f6);
  background:var(--callout-bg,#eff6ff);color:#333;
  font-style:normal;
}
.callout__icon{width:20px;height:20px;flex:none;margin-top:2px;color:var(--callout-line,#3b82f6);}
.callout__body{flex:1;min-width:0;}
.callout__body > :first-child{margin-top:0;}
.callout__body > :last-child{margin-bottom:0;}
.callout--note{--callout-line:#2563eb;--callout-bg:#eff6ff;}
.callout--tip{--callout-line:#0d9488;--callout-bg:#f0fdfa;}
.callout--important{--callout-line:#7c3aed;--callout-bg:#f5f3ff;}
.callout--warning{--callout-line:#d97706;--callout-bg:#fffbeb;}
.callout--caution{--callout-line:#dc2626;--callout-bg:#fef2f2;}

/* ---------- ==高亮== ---------- */
.article__content mark{
  background:#fff3b8;color:inherit;padding:.05em .18em;border-radius:3px;
  box-decoration-break:clone;-webkit-box-decoration-break:clone;
}

/* ---------- 列表页标题（原来是 h3，现在为了标题层级改 h2） ---------- */
.list-row__title{font-family:var(--font-head);font-size:19px;line-height:1.3;margin:6px 0;}

/* ---------- 页脚分类计数 ---------- */
.ft-count{opacity:.55;font-size:12px;margin-left:4px;}

/* ---------- 语言切换：更明显的当前语言 ---------- */
/* 语言切换。
   原来当前语言是一块实心红底白字，在浅色毛玻璃导航里非常跳，
   和旁边"首页/技术/关于我"这些普通文字链接完全不搭。
   现在改成与菜单同色系：当前语言用主文字色 + 下划线强调，
   非当前语言用较浅的灰，hover 时才显出主色。 */
.lang-switch{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:700;letter-spacing:.4px;}
.lang-switch .lang-link{
  padding:3px 2px;
  color:#6b6b6b;
  text-decoration:none;
  border-bottom:2px solid transparent;
  transition:color .15s,border-color .15s;
}
.lang-switch .lang-link:hover{color:#20242b;}
.lang-switch .lang-link.active{
  color:#20242b;
  border-bottom-color:var(--accent);
}

/* ---------- 窄屏：轮播控件与品牌可访问名 ---------- */
@media (max-width:768px){
  .hero__ctrl{bottom:16px;gap:10px;}
  .hero__pause{width:30px;height:30px;}
  .hero__dots .dot{width:8px;height:8px;}
  .hero__dots .dot.active{width:18px;}
  .callout{padding:12px 14px;gap:10px;}
  .list-row__title{font-size:17px;}
}

/* =========================================================================
   修复：占位 SVG 封面（feat1.svg 等）中间有个巨大的 "feature" 字样，
   铺到 hero 上时正好压在标题后面，正文读不清。
   这里给 hero 背景图统一加一层深色压层，并让 SVG 类封面稍微放大虚化，
   使文字区始终有足够对比度。
   ========================================================================= */
.hero-slider .hero-bg::after{
  content:"";position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(90deg, rgba(0,0,0,.62) 0%, rgba(0,0,0,.34) 48%, rgba(0,0,0,.12) 78%);
}
.hero-slider .hero-copy{background:none;}   /* 压层改由 ::after 统一负责，避免叠两层 */
/* 标题与元信息在压层之上 */
.hero-slider .hero-copy{z-index:7;}

/* 文章详情页的内页 hero 也加同样的压层，保证标题可读 */
.hero--inner .hero__tint{
  background:linear-gradient(180deg, rgba(0,0,0,.42) 0%, rgba(0,0,0,.30) 45%, rgba(0,0,0,.60) 100%);
}

/* ---------- 侧栏搜索按钮：中文"搜索"两个字曾被挤成两行 ---------- */
.searchbar .btn{flex:none;white-space:nowrap;}

/* =========================================================================
   文章目录（TOC）
   桌面端：常驻右侧空白区，跟随滚动，当前小节高亮
   移动端：贴边收起，只露一个半透明小箭头；点击展开，背景模糊聚焦
   ========================================================================= */

/* 正文与目录并排。目录占右侧那一列"空白"，不挤压正文宽度。 */
.article-with-toc{position:relative;}
/* 没有目录时（短文章）退回单列，避免右侧留一条空栏 */
.article-with-toc > .article__content:only-child{grid-column:1 / -1;}

/* 目录轨只负责占位（撑满整行高度），真正的 sticky 在内层 .article__toc-inner。
   两处都写 sticky 会互相干扰：外层一旦有 max-height，内层的 sticky 就失效了。 */
.article__toc-rail{
  display:flex;
  flex-direction:column;
}
.article__toc-inner{min-height:0;display:flex;flex-direction:column;}

/* ---------- 目录本体 ---------- */
.toc{
  /* 左侧目录：左边框作为"竖轴"，条目左对齐更好读（右对齐在中文里很别扭） */
  border-left:2px solid var(--line);
  padding-left:18px;
  font-size:13.5px;
  line-height:1.5;
  text-align:left;
}
.toc__head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;}
.toc__title{
  font-family:var(--font-body);
  font-size:11px;
  font-weight:800;
  letter-spacing:1.6px;
  text-transform:uppercase;
  color:#6b6b6b;
  margin:0;
}
/* 移动端那个"小箭头"，桌面端隐藏 */
.toc__handle{display:none;}

.toc__list{
  list-style:none;
  margin:0;
  padding:0;
  overflow-y:auto;
  /* 最大高度与容器一致，标题多时（例如 50 个小节）内部滚动 */
  flex:1;
  min-height:0;
  scrollbar-width:thin;
  overscroll-behavior:contain;
}
.toc__list::-webkit-scrollbar{width:5px;}
.toc__list::-webkit-scrollbar-thumb{background:#d8d4cf;border-radius:3px;}

.toc__item{margin:0;}
.toc__item a{
  display:block;
  padding:5px 0 5px 18px;
  color:#767676;
  border-left:2px solid transparent;
  margin-left:-20px;
  transition:color .15s,border-color .15s;
  overflow-wrap:break-word;
}
.toc__item a:hover{color:var(--ink);}
/* 当前阅读到的小节 */
.toc__item a.is-active{
  color:var(--accent);
  border-left-color:var(--accent);
  font-weight:700;
}
/* 层级缩进：d1 一级标题，d2 二级，d3 三级 */
.toc__item--d2 a{padding-left:30px;font-size:13px;}
.toc__item--d3 a{padding-left:42px;font-size:12.5px;color:#8a8a8a;}



/* ---------- 中等屏幕（1181~1400）：目录改为收起式 ---------- */
@media(max-width:1400px){
  .article-with-toc{display:block;}
  .article__toc-rail{position:static;max-height:none;display:block;}
}

/* ---------- 移动端 / 中等屏幕：贴边收起 + 背景模糊 ---------- */
@media(max-width:1400px){
  /* 桌面端 .article__toc-inner 是 position:fixed（用于右侧/左侧固定悬浮）。
     移动端必须彻底还原成普通元素，否则它会形成包含块，
     把内部 .toc 的 position:fixed 困在这一层里，导致抽屉被遮罩盖住点不动。 */
  .article__toc-rail,
  .article__toc-inner{
    position:static !important;
    width:auto !important;
    height:auto !important;
    max-height:none !important;
    overflow:visible !important;
    visibility:visible !important;
    opacity:1 !important;
    left:auto !important;
  }
  /* 收起状态：只是贴着右边缘的一个小竖条 + 半透明箭头 */
  .toc{
    position:fixed;
    top:50%;
    left:0;
    right:auto;
    transform:translateY(-50%);
    z-index:1200;

    border-left:0;
    padding:0;
    margin:0;
    font-size:14.5px;

    /* 收起时只剩一个"把手"的可点击区域 */
    width:auto;
    max-width:min(320px,86vw);
    background:transparent;
  }
  /* 把手（半透明小箭头），常驻 */
  .toc__handle{
    display:flex;
    align-items:center;
    justify-content:center;
    width:26px;
    height:54px;
    border-radius:0 10px 10px 0;
    background:rgba(255,255,255,.62);
    backdrop-filter:blur(10px) saturate(150%);
    -webkit-backdrop-filter:blur(10px) saturate(150%);
    box-shadow:2px 0 14px rgba(0,0,0,.12);
    border:1px solid rgba(216,46,42,.28);
    border-left:0;
    color:var(--accent);
    cursor:pointer;
    transition:background .2s,transform .2s;
  }
  .toc__handle::before{
    content:"";
    width:7px;height:7px;
    border-right:2px solid currentColor;
    border-bottom:2px solid currentColor;
    transform:rotate(-45deg);          /* 收起时指向右侧（暗示"往这边展开"） */
    margin-right:3px;
    transition:transform .25s;
  }
  .toc.is-open .toc__handle::before{transform:rotate(135deg);margin-right:-2px;}

  /* 收起：标题与列表都不显示 */
  .toc__head{
    margin:0;
    /* head 变成左侧竖排把手 */
    position:fixed;
    top:50%;
    left:0;
    transform:translateY(-50%);
  }
  .toc__title{display:none;}
  .toc__list{
    display:none;
    max-height:none;
  }

  /* 展开状态：整块浮层 */
  .toc.is-open{
    width:min(320px,86vw);
    max-height:76vh;
    background:rgba(255,255,255,.97);
    border-radius:0 14px 14px 0;
    box-shadow:12px 0 44px rgba(0,0,0,.28);
    display:flex;
    flex-direction:column;
    overflow:hidden;
    /* 明确压过遮罩层，保证抽屉内条目可点击 */
    z-index:1200;
  }
  .toc.is-open .toc__list{position:relative;z-index:1;}
  .toc.is-open .toc__head{
    position:static;
    transform:none;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:14px 16px 10px 18px;
    border-bottom:1px solid var(--line);
    margin:0;
  }
  .toc.is-open .toc__title{
    display:block;
    font-size:12px;
    letter-spacing:1.4px;
    color:#4a4a4a;
  }
  .toc.is-open .toc__handle{
    width:30px;height:30px;border-radius:8px;border:1px solid rgba(216,46,42,.3);
    box-shadow:none;background:rgba(216,46,42,.08);
  }
  .toc.is-open .toc__list{
    display:block;
    overflow-y:auto;
    overflow-x:hidden;
    padding:8px 0 12px;
    max-height:calc(76vh - 60px);
  }
  .toc.is-open .toc__item a{
    margin-left:0;
    margin-right:0;
    border-left:0;
    border-right:0;
    text-align:left;
    padding:10px 16px 10px 18px;
    font-size:14.5px;
    color:#333;
    border-bottom:1px solid rgba(0,0,0,.04);
  }
  .toc.is-open .toc__item--d2 a{padding-left:30px;padding-right:16px;font-size:13.5px;}
  .toc.is-open .toc__item--d3 a{padding-left:42px;padding-right:16px;font-size:13px;}
  .toc.is-open .toc__item a.is-active{color:var(--accent);font-weight:700;background:rgba(216,46,42,.06);}

  /* 展开时给整页加一层模糊遮罩，突出目录 */
  .toc-backdrop{
    position:fixed;
    inset:0;
    /* 必须低于目录抽屉：抽屉 z-index 1200，遮罩 1100。
       实测遮罩曾盖住抽屉导致条目点不到（pointer events intercepted）。 */
    z-index:1100;
    background:rgba(20,16,16,.28);
    backdrop-filter:blur(7px) saturate(120%);
    -webkit-backdrop-filter:blur(7px) saturate(120%);
    opacity:0;
    pointer-events:none;
    transition:opacity .25s ease;
  }
  .toc-backdrop.show{opacity:1;pointer-events:auto;}
  /* 遮罩出现时锁住页面滚动，避免手指滑动带动正文 */
  body.toc-locked{overflow:hidden;}
}

@media(prefers-reduced-motion:reduce){
  .toc__handle,.toc-backdrop,.toc__item a{transition:none;}
}

/* ---------- 目录栅格修正 ----------
   .article__body 是 .layout（1fr 320px 栅格）的子项，
   里面再套一层 .article-with-toc 栅格是没问题的；
   之前目录不显示是因为 style="aspect-ratio:1600/900" 被 Hugo 过滤成
   ZgotmplZ，导致封面高度异常把下面的内容推出视口。
   这里再给目录轨加一些防御性样式即可。
*/
.article__body .article-with-toc{width:100%;}
/* ---------- 目录粘性定位修正 ----------
   问题：.article__toc-rail 是 align-items:start 的栅格子项，
   它的高度只有自身内容高度，sticky 一旦滚动到自身底部就没有"轨道"可粘了，
   于是目录标题会跟着正文一起滚走。
   解决：让目录轨撑满整行高度（align-self:stretch），sticky 才有附着范围。
*/
.article__toc-rail{
  align-self:stretch;
  height:auto;
}
.article__toc-inner{
  position:sticky;
  top:calc(var(--nav-h) + 24px);
  max-height:calc(100vh - var(--nav-h) - 48px);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}


/* =========================================================================
   目录定位（最终方案）
   sticky 在这里不生效：.article__toc-rail 是栅格子项，虽然 align-self:stretch
   拿到了整行高度，但 Hugo 主题里还有 .sidebar__sticky / .layout 等历史规则，
   祖先链上的 overflow 与高度计算让 sticky 反复失效（实测滚动后目录跟着滚走）。
   与其和一堆旧规则搏斗，不如直接用 fixed + JS 控制显隐：
     - 目录进入视口后固定到右侧
     - 滚过正文末尾时随正文一起离开（JS 加 .is-done）
   ========================================================================= */



/* =========================================================================
   锚点跳转避让固定导航
   用 html 的 scroll-padding-top（滚动容器级别的偏移），而不是给每个标题
   加 scroll-margin-top。
   原因：scroll-margin-top 会参与"滚动到元素"的计算，但一旦 JS 里
   还额外减过偏移量、或元素在滚动过程中触发重排，浏览器就会重复/部分
   抵消，实测表现为"有时差 15px、有时差 46px"，很难调试。
   scroll-padding-top 只作用在滚动容器上，语义更明确，也不会被
   scrollIntoView 二次处理。
   ========================================================================= */
html{
  /* 导航现在是 sticky（始终占着文档流里的位置），不再有 76px 的跳变，
     所以偏移量回到"导航高度 + 一点呼吸"即可，不再需要 ×2 的补偿。 */
  scroll-padding-top:calc(var(--nav-h) + 20px);
}
/* 文章里的标题再留一点余量，避免贴住导航下沿 */
.article__content :is(h2,h3,h4,h5){ scroll-margin-top:8px; }

/* =========================================================================
   文章页桌面布局（最终版）
   -------------------------------------------------------------------------
   目标（来自实际反馈）：
     左侧那一大块空白不要浪费——目录挪进去，正文往左长、变宽。

   视觉结构：
      [容器外留白 120px][目录 100px][正文 740px][右侧边栏 320px]
                        ↑ 目录浮在这里，不占栅格宽度

   走过的弯路（都不要再犯）：
     A) 把目录做成 .layout 的第三列          -> .layout 只有两个子元素，塌掉
     B) 在 .article__body 里开一列给目录      -> 正文被挤到 600px，且容器左侧
                                                 仍有 120px 空白，两头浪费
     C) 把文章区拉满容器宽                    -> 右侧边栏整个消失

   现在：目录绝对定位到 .article__body 左边缘之外的留白（容器 padding 那 120px），
   正文因此可以从容器左边缘重新开始，宽度回到 740px。
   ========================================================================= */
/* 只有"够宽"才显示左侧常驻目录。
   容器 max-width 1200 + 左右各 20 padding，视口 < 1400 时两侧留白
   不足以再塞下 100px 目录，硬塞就会压到正文上（1280 下实测重叠）。
   所以 1181~1400 之间退回移动端那套"贴边收起"的方案，
   >1400 才常驻左侧。 */
@media(min-width:1401px){
  .article__body{position:relative;}

  /* 目录轨：完全脱离文档流，不影响正文宽度。
     宽度自适应：视口越宽，目录越宽（最多 220px）。
     之前死写 100px，扣掉 padding-left 和三层缩进后，正文区只剩 74px，
     长标题被挤成 3~4 行。 */
  .article__toc-rail{
    position:absolute;
    top:0;
    bottom:0;
    right:calc(100% + 24px);
    width:var(--toc-w);
    pointer-events:none;
  }
  .article__toc-rail .article__toc-inner{
    /* sticky 在这套栅格/overflow 组合里会反复失效，用 fixed 更可控；
       横向/纵向位置由 JS 计算（含"不越过文章底部"的约束）。 */
    position:fixed;
    top:calc(var(--nav-h) + 24px);
    width:var(--toc-w);
    max-height:calc(100vh - var(--nav-h) - 48px);
    display:flex;
    flex-direction:column;
    overflow:hidden;
    pointer-events:auto;
    /* 隐藏时要彻底移出视口，否则 opacity:0 的盒子仍占位置、仍会露出边框 */
    visibility:hidden;
    opacity:0;
    transition:opacity .18s ease;
  }
  .article__toc-rail .article__toc-inner.is-floating{
    visibility:visible;
    opacity:1;
  }

  .article-with-toc{display:block;}
  .article-with-toc > .article__content{max-width:740px;}

  /* 目录宽度随留白自适应；两侧留白 = (100vw - 1200) / 2。
     1440 时留白只有 120px，所以下限必须 <= 120，否则 clamp 会先取到下限，
     JS 再把整个目录往右夹进视口 —— 结果压到正文上（实测 tocRight 158 > contentLeft 140）。
     这里下限给 110，1440 下算出 100 -> 取 110，仍然小于 120 的留白。 */
  :root{
    --toc-w: clamp(110px, calc((100vw - 1240px) / 2 - 24px), 220px);
  }

  .article__toc-rail .toc{font-size:12.5px;padding-left:12px;}
  .article__toc-rail .toc__title{font-size:10px;letter-spacing:1.2px;}
  .article__toc-rail .toc__item a{padding:4px 0 4px 10px;margin-left:-14px;}
  .article__toc-rail .toc__item--d2 a{padding-left:14px;font-size:12px;}
  .article__toc-rail .toc__item--d3 a{padding-left:20px;font-size:11.5px;}
}

/* =========================================================================
   Phase 2 体验升级：代码块工具栏、阅读进度条、返回顶部、图片灯箱、
   上下篇导航、相关文章、关于页卡片、全站暗黑模式 (Dark Mode)
   ========================================================================= */

/* ---------- 顶部阅读进度条 ---------- */
.reading-progress{
  position:fixed;top:0;left:0;height:3px;width:0;z-index:2200;
  background:linear-gradient(90deg, var(--accent), var(--accent-2));
  pointer-events:none;transition:width .1s linear;
}

/* ---------- 代码块增强（语言标签 + 一键复制） ---------- */
.code-block{
  margin:1.4em 0;border-radius:10px;overflow:hidden;
  background:#1e1e1e;border:1px solid rgba(255,255,255,.08);
}
.code-block__head{
  display:flex;align-items:center;justify-content:space-between;
  padding:7px 14px;background:#28282b;border-bottom:1px solid rgba(255,255,255,.07);
  font-family:var(--font-body);font-size:12px;color:#b4b4bb;
}
.code-block__lang{font-weight:700;letter-spacing:.6px;font-size:11px;color:#a8a8b2;}
.code-block__copy{
  background:rgba(255,255,255,.08);color:#e4e4e8;border:1px solid rgba(255,255,255,.14);
  border-radius:6px;padding:3px 10px;font-size:11.5px;font-weight:600;cursor:pointer;
  transition:background .15s,color .15s,border-color .15s;
}
.code-block__copy:hover{background:rgba(255,255,255,.16);color:#fff;}
.code-block__copy.is-copied{background:#1b7a45;border-color:#25a25a;color:#fff;}
.code-block pre{margin:0!important;border-radius:0!important;border:0!important;}

/* ---------- 上一篇 / 下一篇 导航 ---------- */
.post-nav{
  display:grid;grid-template-columns:1fr 1fr;gap:18px;
  max-width:740px;margin:44px 0 16px;padding-top:28px;border-top:1px solid var(--line);
}
.post-nav__item{
  display:flex;flex-direction:column;gap:6px;padding:16px 18px;
  border:1px solid var(--line);border-radius:12px;background:var(--bg);
  transition:border-color .2s,transform .2s,box-shadow .2s;
}
.post-nav__item:hover{
  border-color:var(--accent);transform:translateY(-2px);
  box-shadow:0 10px 24px rgba(0,0,0,.06);
}
.post-nav__item--next{text-align:right;}
.post-nav__label{font-size:12px;font-weight:700;color:var(--body);text-transform:uppercase;letter-spacing:.6px;}
.post-nav__title{font-family:var(--font-head);font-size:16px;color:var(--ink);line-height:1.35;}
@media(max-width:640px){.post-nav{grid-template-columns:1fr;}.post-nav__item--next{text-align:left;}}

/* ---------- 相关文章推荐 ---------- */
.related-posts{max-width:740px;margin:38px 0 10px;padding-top:26px;border-top:1px solid var(--line);}
.related-posts__title{
  font-family:var(--font-head);font-size:20px;font-weight:700;margin-bottom:18px;
  padding-left:14px;position:relative;color:var(--ink);
}
.related-posts__title::before{
  content:"";position:absolute;left:0;top:4px;bottom:4px;width:4px;background:var(--accent);border-radius:2px;
}
.related-posts .card img{height:150px;}
.related-posts .card h3{font-size:16.5px;}

/* ---------- 关于页名片与排版 ---------- */
.about-card{
  max-width:860px;margin:0 auto;background:var(--bg);
  border:1px solid var(--line);border-radius:16px;padding:36px 40px;
  box-shadow:0 12px 32px rgba(0,0,0,.04);
}
.about-profile{
  display:flex;align-items:center;gap:20px;padding-bottom:24px;margin-bottom:26px;
  border-bottom:1px solid var(--line);
}
.about-avatar{
  width:72px;height:72px;border-radius:50%;overflow:hidden;flex:none;
  border:2px solid var(--accent);box-shadow:0 6px 16px rgba(216,46,42,.2);
}
.about-avatar img{width:100%;height:100%;object-fit:cover;}
.about-profile__name{font-family:var(--font-head);font-size:24px;color:var(--ink);margin-bottom:4px;}
.about-profile__tagline{font-size:14px;color:var(--body);}
.about-body{max-width:100%;}
@media(max-width:640px){.about-card{padding:24px 20px;}}
/* 关于页自定义标题栏背景图：铺满内页横幅并居中裁切 */
.hero__bg.hero__bg--custom img{
  width:100%;height:100%;object-fit:cover;object-position:center center;display:block;
}

/* ---------- 返回顶部按钮 ---------- */
.back-to-top{
  position:fixed;right:24px;bottom:28px;z-index:1100;
  width:42px;height:42px;border-radius:50%;border:1px solid var(--line);
  background:var(--bg);color:var(--ink);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 8px 24px rgba(0,0,0,.14);
  opacity:0;transform:translateY(12px);pointer-events:none;
  transition:opacity .2s,transform .2s,background .15s,color .15s;
}
.back-to-top[hidden]{display:none!important;}
.back-to-top.show{opacity:1;transform:translateY(0);pointer-events:auto;}
.back-to-top:hover{background:var(--accent);color:#fff;border-color:var(--accent);}

/* ---------- 正文图片灯箱 (Lightbox) ---------- */
.article__content img.zoomable{cursor:zoom-in;transition:transform .2s;}
.lightbox{
  position:fixed;inset:0;z-index:2500;
  background:rgba(10,10,12,.88);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);
  display:none;flex-direction:column;align-items:center;justify-content:center;
  padding:24px;opacity:0;pointer-events:none;transition:opacity .2s ease;cursor:zoom-out;
}
.lightbox[hidden]{display:none!important;pointer-events:none!important;}
.lightbox.is-open{display:flex;opacity:1;pointer-events:auto;}
.lightbox__img{
  max-width:min(92vw,1400px);max-height:82vh;width:auto;height:auto;
  border-radius:8px;box-shadow:0 20px 60px rgba(0,0,0,.5);object-fit:contain;
}
.lightbox__caption{margin-top:12px;color:#ddd;font-size:13.5px;text-align:center;max-width:80vw;}
.lightbox__close{
  position:absolute;top:20px;right:24px;width:40px;height:40px;border-radius:50%;
  background:rgba(255,255,255,.14);border:0;color:#fff;font-size:18px;cursor:pointer;
}
.lightbox__close:hover{background:var(--accent);}

/* ---------- 导航栏主题切换按钮 ---------- */
.theme-toggle{
  background:none;border:0;cursor:pointer;padding:6px;border-radius:8px;
  display:inline-flex;align-items:center;justify-content:center;
  color:#20242b;transition:background .15s,color .15s;
}
.theme-toggle:hover{background:rgba(0,0,0,.06);color:var(--accent);}
.theme-toggle .ic-sun{display:none;}
html[data-theme="dark"] .theme-toggle .ic-moon{display:none;}
html[data-theme="dark"] .theme-toggle .ic-sun{display:block;}

/* ---------- 全站暗黑模式 (Dark Mode) ---------- */
html[data-theme="dark"]{
  --ink:#ececef;
  --body:#a6a6b0;
  --line:#2a2a30;
  --bg:#121215;
  color-scheme:dark;
}
html[data-theme="dark"] body,
html[data-theme="dark"] .section,
html[data-theme="dark"] .page,
html[data-theme="dark"] .article__body{
  background:var(--bg);
  color:var(--ink);
}
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-header .nav{
  background:rgba(20,20,24,.72) !important;
  border-bottom:1px solid rgba(255,255,255,.08);
  box-shadow:0 4px 22px rgba(0,0,0,.35);
}
html[data-theme="dark"] .site-header .brand span,
html[data-theme="dark"] .site-header .menu a,
html[data-theme="dark"] .site-header .menu a:visited,
html[data-theme="dark"] .site-header .brand,
html[data-theme="dark"] .site-header .nav a,
html[data-theme="dark"] .menu .menu-dd-btn,
html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .lang-switch .lang-link.active,
html[data-theme="dark"] .lang-switch .lang-link:hover{
  color:#f0f0f4 !important;
}
html[data-theme="dark"] .site-header .search svg{stroke:#f0f0f4 !important;}
html[data-theme="dark"] .site-header .burger span{background:#f0f0f4 !important;}
html[data-theme="dark"] .dropdown,
html[data-theme="dark"] .mobile-menu{
  background:rgba(28,28,34,.92) !important;
  border-color:rgba(255,255,255,.1);
  color:#f0f0f4 !important;
}
html[data-theme="dark"] .dropdown a,
html[data-theme="dark"] .mobile-menu a{color:#e2e2e8 !important;}
html[data-theme="dark"] .card,
html[data-theme="dark"] .widget,
html[data-theme="dark"] .about-card,
html[data-theme="dark"] .post-nav__item,
html[data-theme="dark"] .comments{
  background:#1a1a1f;
  border-color:var(--line);
}
html[data-theme="dark"] .widget__title{border-bottom-color:#2a2a30;}
html[data-theme="dark"] .widget__list a{border-bottom-color:#26262c;}
html[data-theme="dark"] .tag{background:#26262e;color:#ccc;}
html[data-theme="dark"] .tag:hover{background:var(--accent);color:#fff;}
html[data-theme="dark"] .article__content{color:#d8d8df;}
html[data-theme="dark"] .article__content blockquote{background:#1c1a1b;color:#bbb;}
html[data-theme="dark"] .article__content th{background:#222228;color:#eee;border-color:#32323a;}
html[data-theme="dark"] .article__content td{border-color:#2c2c34;}
html[data-theme="dark"] .article__content tr:nth-child(even) td{background:#18181d;}
html[data-theme="dark"] .article__content mark{background:#5a4812;color:#fff3b8;}
html[data-theme="dark"] .callout{background:#1c1e26;color:#dcdce2;}
html[data-theme="dark"] .bgm-player{background:linear-gradient(180deg,#222228,#1a1a1f);border-color:#2e2e36;}
html[data-theme="dark"] .bgm-name{color:#eee;}
html[data-theme="dark"] .bgm-time,
html[data-theme="dark"] .card__date{color:#9a9aa4;}
html[data-theme="dark"] .searchbar input{background:#141418;border-color:var(--line);color:var(--ink);}
html[data-theme="dark"] .search-overlay .search-box,
html[data-theme="dark"] .search-results a{background:#1e1e24;color:#eee;}
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] .search-results .st{color:#eee;}
html[data-theme="dark"] .toc.is-open{background:rgba(26,26,32,.97);}
html[data-theme="dark"] .toc.is-open .toc__item a{color:#ddd;border-bottom-color:rgba(255,255,255,.06);}
html[data-theme="dark"] .toc__handle{background:rgba(30,30,36,.75);}
html[data-theme="dark"] .pagination a,
html[data-theme="dark"] .pagination span{
  background:#1a1a1f;border-color:var(--line);color:var(--ink);
}
html[data-theme="dark"] .pagination .active{
  background:var(--accent);border-color:var(--accent);color:#fff;
}
html[data-theme="dark"] .pagination a:hover{
  border-color:var(--accent);color:var(--accent);
}