/* ============================================================
   xfengyin 个人主页 — 视觉层：明亮现代产品风（bright）
   ------------------------------------------------------------
   设计方向（用户从 4 个方向稿里选定的 bright，见 ui-concepts/bright/NOTE.md）：
   白底、彩色渐变、大圆角、毛玻璃粘性顶栏、胶囊按钮与分类筛选、卡片网格。
   与「中文编辑体例（宋体+朱砂）」和「终端风」都刻意拉开距离。

   本文件同时承担前几轮用实测换来的**不可退化的约束**，改动时请逐条看注释：
     · 触控目标 ≥24×24（WCAG 2.5.8）：容器一律给 min-height，不用绝对定位补丁
     · 浅色/深色文字对比度 AA：--dim 是 5.6:1 那一档，别再调浅
     · 320px 无横向溢出：网格用 minmax(min(Npx,100%),1fr)
     · CLS：封面/头像/横幅都用 aspect-ratio 或 width+height 预留位置
     · 打印：只藏装饰，绝不藏内容（.cloud 曾因被藏导致 /categories/ 打印成白纸）
     · reduced-motion：动画位移全部关停
     · html.js：≤820px 的菜单开关只对 JS 用户显示；无 JS 时顶栏静态化、导航平铺
       （js 类由 base.html 首屏内联脚本加，防止 390px 冷缓存 CLS 0.1765）
     · 文章页 = 方案 B（左吸顶栏 + 右宽正文卡，见 §8）；≤1100px 单列，rail 的两张卡不隐藏
   ============================================================ */

/* ---------- 0. 设计令牌 ---------- */
:root {
  --container: 1200px;
  --radius: 18px;
  --radius-sm: 12px;
  --pill: 999px;
  --nav-h: 66px;

  /* 字体：系统无衬线（本方向全站无衬线，层级靠字重与负字距建立） */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #ffffff;
  --surface: #ffffff;
  --soft: #f6f7fb;
  --ink: #0f172a;
  /* 次要文字：#5b6478 —— 白底 5.94:1、浅底 5.6:1，两处都过 AA。
     别用更浅的 slate-500（#64748b 在 #f6f7fb 上只有 4.49:1，差一点不达标）。 */
  --dim: #5b6478;
  --line: #e8eaf1;
  --line-2: #d7dbe7;
  --p1: #4f46e5;
  --p2: #7c3aed;
  --cyn: #0ea5e9;
  /* 「当文字用」的品牌色：白底 6.29:1，浅底 5.9:1 */
  --brand-text: #4f46e5;
  --brand-soft: rgba(79, 70, 229, .10);
  --grad: linear-gradient(135deg, var(--p1), var(--p2));
  --nav-bg: rgba(255, 255, 255, .86);
  --code-bg: #0d1326;
  --code-ink: #d7def7;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-2: 0 18px 40px rgba(79, 70, 229, .18);

  /* 深浅色开关的图标：内联 SVG 走 mask，用 currentColor 着色（不依赖 emoji 字体） */
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.2 14.7A8.6 8.6 0 0 1 9.3 3.8 8.6 8.6 0 1 0 20.2 14.7z'/%3E%3C/svg%3E");
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4.1'/%3E%3Cpath d='M12 2.6v2.1M12 19.3v2.1M4.7 12H2.6M21.4 12h-2.1M6.6 6.6 5.1 5.1M18.9 18.9l-1.5-1.5M17.4 6.6l1.5-1.5M5.1 18.9l1.5-1.5'/%3E%3C/svg%3E");
}
html.dark {
  --bg: #0b1020;
  --surface: #141a2e;
  --soft: #101731;
  --ink: #e8ecf6;
  --dim: #94a3b8;
  --line: #242c46;
  --line-2: #2f3958;
  --brand-text: #a5b4fc;
  --brand-soft: rgba(165, 180, 252, .14);
  --nav-bg: rgba(11, 16, 32, .86);
  --code-bg: #080c1a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-2: 0 18px 40px rgba(0, 0, 0, .5);
}

/* ---------- 1. 基础 ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 14px); }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 750; letter-spacing: -.02em; }
img, svg, picture, video { max-width: 100%; }
ul, ol { list-style: none; }
.wrap { max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.18em; display: inline-block; }
/* 屏幕阅读器专用：不能改成 display:none（那会把它从可访问树里拿掉） */
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 80; background: var(--p1); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); }

/* ---------- 2. 顶栏（粘性 + 毛玻璃；in-flow，所以不产生 CLS） ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav-bg);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .2s ease;
}
.nav.enter { box-shadow: var(--shadow-1); }
.nav-in { display: flex; align-items: center; gap: 12px; height: var(--nav-h); }
.logo { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; font-weight: 750; letter-spacing: -.01em; }
.logo i { width: 28px; height: 28px; border-radius: 9px; background: var(--grad); display: block; flex: none; }
.links { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.links a { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 12px; border-radius: var(--pill); font-size: 14px; color: var(--dim); transition: color .18s, background .18s; }
.links .i { width: 17px; height: 17px; }
.links a:hover, .links a:focus-visible, .links a[aria-current="page"] { color: var(--ink); background: var(--soft); }
.subscribe { margin-left: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border: 0; border-radius: var(--pill);
  background: var(--grad); color: #fff;
  font: inherit; font-size: 14px; font-weight: 650;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .22);
  transition: transform .18s, box-shadow .18s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(79, 70, 229, .3); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; font-weight: 550; }
.btn.ghost:hover { border-color: var(--p1); color: var(--brand-text); }
/* 深浅色开关：按钮内容仍由 site.js 写成 emoji，但字号压成 0、真正显示的是 mask 图标 */
.dark-toggle {
  display: none; place-items: center;
  width: 42px; height: 42px; margin-left: 6px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--dim);
  font-size: 0; line-height: 0; cursor: pointer;
  transition: color .18s, border-color .18s;
}
html.js .dark-toggle { display: grid; }
.dark-toggle::before {
  content: ""; width: 19px; height: 19px; background-color: currentColor;
  -webkit-mask-image: var(--icon-moon); mask-image: var(--icon-moon);
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
}
.dark-toggle[aria-pressed="true"]::before { -webkit-mask-image: var(--icon-sun); mask-image: var(--icon-sun); }
.dark-toggle:hover { color: var(--p1); border-color: var(--p1); }
.menu-toggle {
  display: none; align-items: center; gap: 6px;
  min-height: 42px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; cursor: pointer;
}
.menu-toggle .i { width: 18px; height: 18px; }
/* 按钮里的图标/文字必须让点击穿透到按钮本身：
   site.js 的「点外部关闭菜单」判断是 e.target === menuToggle ——
   如果点到按钮里的 <svg>/<span>，e.target 就是那个子元素，
   于是刚展开的菜单会被同一个点击立刻关掉（实测：点图标中的文字区域「菜单」＝ 菜单闪一下就没）。
   pointer-events:none 让点击始终落在按钮上，纯 CSS 修复，不需要改 static/js/site.js。 */
.menu-toggle > * { pointer-events: none; }

/* ---------- 3. 页头（首页） ---------- */
/* 全页统一到**一条左轴**：hero、搜索、分类筛选、区块标题、卡片网格都从同一个左边距起排。
     原本是「居中 hero + 左对齐卡片流」，视觉动线在中轴与左轴之间跳一次
     （另一位只看概念图的评审也指出了这一点）。左轴版更像产品页，也让中文标题的起排更稳。 */
.hero { padding: clamp(44px, 6vw, 76px) 0 clamp(28px, 4vw, 44px); text-align: left; }
.hero-id { display: inline-flex; align-items: center; gap: 12px; padding: 7px 16px 7px 7px; border: 1px solid var(--line); border-radius: var(--pill); background: var(--surface); box-shadow: var(--shadow-1); }
.hero-id .avatar { width: 34px; height: 34px; border-radius: var(--pill); object-fit: cover; background: var(--soft); flex: none; }
.hero-id .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.35; text-align: left; }
.hero-id .who b { font-size: 14px; font-weight: 700; }
.hero-id .who span { font-size: 12px; color: var(--dim); }
.hero h1 {
  margin: 22px 0 0; max-width: 20em;
  font-size: clamp(32px, 4.6vw, 58px);
  font-weight: 800;
  line-height: 1.16;
  letter-spacing: -.028em;
  text-wrap: balance;
}
/* ---------- 渐变标题（主页 + 文章页共用同一套） ----------
   用 @supports 包住：不支持的浏览器不写 color:transparent，
   否则整句标题会不可见（宁可退化成普通墨色标题）。
   最浅一端 #7c3aed 在白底 5.7:1、深底更高 —— 大字号只要 3:1，富余很多。 */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero h1, .page-head h1 {
    background-image: linear-gradient(115deg, var(--ink) 0%, var(--ink) 34%, var(--p1) 62%, var(--p2) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  html.dark .hero h1, html.dark .page-head h1 {
    background-image: linear-gradient(115deg, #f2f4fb 0%, #d9dcf7 30%, var(--brand-text) 70%, #c4b5fd 100%);
  }
}
.lede { margin: 18px 0 0; max-width: 38em; color: var(--dim); font-size: 16.5px; }
.cta { display: flex; justify-content: flex-start; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 34px 0 0; max-width: 760px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-1); }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.stat span { color: var(--dim); font-size: 13px; }

/* ---------- 4. 搜索 + 分类筛选 ---------- */
.find { padding: clamp(22px, 3vw, 34px) 24px 6px; }
.search-box { position: relative; display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0; }
.search-field { position: relative; display: flex; align-items: center; flex: 1 1 auto; min-width: 0; }
.search-field .i { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--dim); pointer-events: none; }
.search-box input {
  width: 100%; height: 46px; padding: 0 16px 0 44px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px;
}
.search-box input::placeholder { color: var(--dim); }
.search-box input:focus { outline: none; border-color: var(--p1); box-shadow: 0 0 0 4px var(--brand-soft); }
.search-box button {
  flex: none; height: 46px; padding: 0 22px;
  border: 0; border-radius: var(--pill);
  background: var(--grad); color: #fff;
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
}
.search-results {
  display: none; position: absolute; top: 54px; left: 0; right: 0; z-index: 40;
  text-align: left; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-2); overflow: hidden;
}
.search-results a.search-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 46px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.search-results a.search-item:last-child { border-bottom: 0; }
.search-results a.search-item:hover { background: var(--soft); }
.search-results a.search-item em { font-style: normal; flex: none; font-size: 12px; color: var(--dim); }
.search-results a.search-item .search-text { min-width: 0; }
.search-empty { padding: 14px 18px; color: var(--dim); font-size: 13px; }

/* 分类胶囊（.cloud 这个类名沿用，仓库里的 nav-verify 会找首页 .cloud a） */
.cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.cloud.filters { justify-content: flex-start; margin-top: 18px; }
.cloud a {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--dim);
  font-size: 13.5px; transition: color .18s, border-color .18s, background .18s;
}
.cloud a em { font-style: normal; font-size: 11.5px; color: var(--dim); }
.cloud a:hover, .cloud a[aria-current="page"] { color: var(--brand-text); border-color: var(--p1); background: var(--brand-soft); }
.cloud a:hover em, .cloud a[aria-current="page"] em { color: var(--brand-text); }

/* ---------- 5. 区块标题 ---------- */
.sect { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: clamp(26px, 3.4vw, 40px) 0 4px; }
.sect h2 { font-size: 22px; font-weight: 750; }
.sect .more { display: inline-flex; align-items: center; min-height: 28px; font-size: 14px; font-weight: 650; color: var(--brand-text); }
.sect .more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 6. 卡片网格 ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 24px; padding: 20px 0 8px; }
.post-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 24px; padding: 20px 0 8px; }
/* 词条页稀疏常态：≤2 篇时收成一条居中单列（89 个词条页大多是 1 篇） */
.post-list--single { grid-template-columns: minmax(0, 1fr); max-width: 720px; margin: 0 auto; }
.post-card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: transparent; }
/* 封面：CSS 生成（按 data-cat 分类色相 + data-v 4 个稳定变体）
   —— 那 17 张烤字 SVG 已废弃：图内标题 12/17 与 front matter 不符，且怎么裁都会露字。 */
/* 封面图形：文章卡片（.post-cover）与推荐阅读卡片（.rel-cover）共用同一套
   分类色相 + 纹理 + 变体角度；颜色定义是属性选择器，元素叫什么名字都能用上。 */
.post-cover, .rel-cover {
  background-color: var(--cover-a, #4f46e5);
  background-image:
    radial-gradient(120% 100% at 80% 6%, rgba(255, 255, 255, .34), rgba(255, 255, 255, 0) 58%),
    linear-gradient(var(--cover-angle, 135deg), var(--cover-a, #4f46e5) 0%, var(--cover-b, #7c3aed) 100%);
  background-repeat: no-repeat;
}
.post-cover { position: relative; aspect-ratio: 16 / 10; overflow: hidden; }
[data-v="1"] { --cover-angle: 108deg; }
[data-v="2"] { --cover-angle: 160deg; }
[data-v="3"] { --cover-angle: 122deg; }
/* 分类色相（25 个真实分类；未列出的落到默认靛紫） */
[data-cat="硬件测试"] { --cover-a: #4f46e5; --cover-b: #7c3aed; }
[data-cat="硬件基础"] { --cover-a: #4f46e5; --cover-b: #0ea5e9; }
[data-cat="洗地机测试"] { --cover-a: #6366f1; --cover-b: #8b5cf6; }
[data-cat="测试仪器"] { --cover-a: #0ea5e9; --cover-b: #2563eb; }
[data-cat="电路设计"] { --cover-a: #06b6d4; --cover-b: #3b82f6; }
[data-cat="PCB设计"] { --cover-a: #0891b2; --cover-b: #22d3ee; }
[data-cat="传感器"] { --cover-a: #14b8a6; --cover-b: #0891b2; }
[data-cat="电源"] { --cover-a: #f59e0b; --cover-b: #ea580c; }
[data-cat="电源设计"] { --cover-a: #f59e0b; --cover-b: #ea580c; }
[data-cat="嵌入式开发"] { --cover-a: #10b981; --cover-b: #059669; }
[data-cat="ESP32"] { --cover-a: #22c55e; --cover-b: #0ea5e9; }
[data-cat="开发工具"] { --cover-a: #64748b; --cover-b: #475569; }
[data-cat="Git"] { --cover-a: #f97316; --cover-b: #ef4444; }
[data-cat="后端开发"] { --cover-a: #10b981; --cover-b: #0ea5e9; }
[data-cat="微服务"] { --cover-a: #14b8a6; --cover-b: #6366f1; }
[data-cat="架构设计"] { --cover-a: #6366f1; --cover-b: #0ea5e9; }
[data-cat="技术实践"] { --cover-a: #ec4899; --cover-b: #8b5cf6; }
[data-cat="Rust"] { --cover-a: #f97316; --cover-b: #b45309; }
[data-cat="前端开发"] { --cover-a: #8b5cf6; --cover-b: #ec4899; }
[data-cat="UI设计"] { --cover-a: #ec4899; --cover-b: #f43f5e; }
[data-cat="博客建设"] { --cover-a: #f43f5e; --cover-b: #f59e0b; }
[data-cat="Python"] { --cover-a: #f59e0b; --cover-b: #f97316; }
[data-cat="项目实战"] { --cover-a: #0ea5e9; --cover-b: #14b8a6; }
[data-cat="新能源"] { --cover-a: #22c55e; --cover-b: #84cc16; }
[data-cat="行业应用"] { --cover-a: #64748b; --cover-b: #0ea5e9; }
.post-cover img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; transition: transform .5s ease; }
.post-card:hover .post-cover img { transform: scale(1.03); }
.cbody { display: flex; flex-direction: column; gap: 9px; flex: 1; padding: 18px 20px 20px; }
.chip { align-self: flex-start; font-size: 12px; font-weight: 650; color: var(--brand-text); background: var(--brand-soft); border-radius: var(--pill); padding: 3px 11px; }
.post-title { font-size: 17px; font-weight: 700; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-desc { font-size: 13.5px; color: var(--dim); line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-meta { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--dim); }

/* ---------- 7. 内页页头（section / taxonomy） ---------- */
.page-head { max-width: var(--container); margin: 0 auto; padding: clamp(34px, 4.6vw, 54px) 24px 0; }
.page-head h1 { font-size: clamp(28px, 3.4vw, 42px); }
.page-head .sub { margin-top: 10px; color: var(--dim); font-size: 15px; }
.page-head .crumb { margin-bottom: 14px; }

/* ---------- 8. 文章页（布局方案 B：左吸顶栏 + 右宽正文卡片） ----------
   用户从三稿里选定的方案 B。骨架与关键数值照搬已验证的方案稿
   （ui-layouts/b/article.html）：
     .wrap.wide   通栏容器 1340（.wrap 本身仍是 1200）
     .hero        面包屑 → 渐变 h1 → 分类/标签胶囊 → 可选封面
     .layout      grid 264px + minmax(0,1fr)，gap 44，align-items:start
     .rail        sticky top: calc(--nav-h + 20px)：目录卡 + 作者/标签卡
     .main-card   padding clamp(20px,3vw,42px)，正文 max-width 78ch
   上一轮的「正文 820px + 右侧 sticky 目录（.article-card 的 grid 820+250）」整段撤掉。
   ≤1100px 收成单列：rail 的两张卡按「目录卡 → 作者卡」回到正文上方，不隐藏、不换序。
   改这里要留意的三件事：sticky 的祖先不能有 overflow 裁剪；吸顶高度必须让开粘性顶栏
   （--nav-h = 66px）；rail 与正文卡的宽度/间距不能让 320px 出现横向溢出。 */
.progress-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 999; background: linear-gradient(90deg, var(--p1), var(--cyn)); }

/* 卡片基元（方案稿的 .card）：rail 两张卡与正文卡共用。颜色全走令牌，深色自动适配 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }

/* 通栏容器：hero 与两栏骨架比普通 .wrap（1200）宽一档，正文列才放得下 78ch */
.wrap.wide { max-width: 1340px; }

/* 页头：顶 42px、底 0 —— 下面的 .layout 自带 40px 上边距 */
.hero--article { padding: 42px 0 0; }
.hero--article h1 {
  margin: 14px 0 0;
  max-width: 24em;
  font-size: clamp(30px, 4vw, 50px);
  line-height: 1.16;
  letter-spacing: -.028em;
  text-wrap: balance;
  /* 超长不可断串（URL / 型号）也不撑破容器；中文照常逐字断行 */
  overflow-wrap: break-word;
}
.hero--article .cover { aspect-ratio: 16 / 9; max-width: 820px; margin-top: 28px; }
/* 封面只在文章真有照片时输出（17 篇里 3 篇）。16/9 与 1200×675 源图一致 ⇒ 图表一点不裁；
   位置由 aspect-ratio 预留（CLS=0），模板里另有 width/height 属性 */
.cover { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--soft); }
.cover img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }

.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }
.crumb .i { width: 15px; height: 15px; }
.crumb a { color: var(--brand-text); min-height: 24px; display: inline-flex; align-items: center; }
.crumb a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* 分类 / 标签胶囊。类名沿用 .article-meta + kbd —— docs/link-semantics.py 按 .article-meta 取 chip、
   docs/hit-area.cjs 与 interactive-all-pages.cjs 按 .article-meta kbd 量可点区，别改名。
   外观是方案稿的 .chip（32px 高胶囊）；标签用品牌软底与分类区分开。 */
.article-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; font-size: 12.5px; color: var(--dim); }
.article-meta kbd {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--dim);
  font: inherit; font-size: 12.5px;
  transition: color .18s, border-color .18s, background .18s;
}
.article-meta a[href*="/tags/"] kbd { color: var(--brand-text); background: var(--brand-soft); border-color: transparent; font-weight: 650; }
.article-meta a:hover kbd { color: var(--brand-text); border-color: var(--p1); background: var(--brand-soft); }

/* 两栏骨架（方案稿数值：264 + gap 44 + 自适应正文列） */
.layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 44px; align-items: start; margin-top: 40px; }
/* 左栏吸顶。用 sticky 而不是 fixed：in-flow ⇒ 不产生布局偏移（CLS）。
   .wrap.wide / .layout 都没有 overflow 裁剪，吸顶栏才能贴着网格区域一路滚到底。 */
.rail { position: sticky; top: calc(var(--nav-h) + 20px); display: flex; flex-direction: column; gap: 16px; }
.rail .card { padding: 18px 16px; }
.rail h2 { font-size: 12.5px; font-weight: 650; letter-spacing: .08em; color: var(--dim); text-transform: uppercase; margin-bottom: 10px; }
/* 作者 / 标签卡 */
.who { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.who .av { width: 36px; height: 36px; border-radius: var(--pill); background: var(--soft); display: block; flex: none; object-fit: cover; }
.who b { display: block; font-size: 14px; font-weight: 700; color: var(--ink); }
.who .meta { font-size: 12px; color: var(--dim); }
.rail .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rail .chips .chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; font-size: 12.5px; border: 1px solid transparent; transition: color .18s, border-color .18s, background .18s; }
.rail .chips .chip:hover { color: var(--brand-text); border-color: var(--p1); background: var(--brand-soft); }
/* 目录：单列、32px 行高的胶囊链接（方案稿）。长标题自然换行，不会横向溢出 */
.toc ul { display: flex; flex-direction: column; gap: 2px; }
.toc ul li a { display: flex; align-items: center; min-height: 32px; padding: 0 10px; border-radius: var(--pill); font-size: 13.5px; color: var(--ink); }
.toc ul li a:hover { color: var(--brand-text); background: var(--brand-soft); }
/* 当前章节高亮：class 由 page.html 内联的 scrollspy 加（无 JS 时只是没有高亮，目录照常可点） */
.toc ul li a.is-active { color: var(--brand-text); background: var(--brand-soft); }

/* 右栏正文卡 */
.main-card { padding: clamp(20px, 3vw, 42px); min-width: 0; }
.main-card .article-content { max-width: 78ch; margin-top: 0; }
.main-card .article-content > :first-child { margin-top: 0; }

/* ≤1100px 收成单列：rail 的两张卡回到正文上方（DOM 顺序就是「目录卡 → 作者卡」） */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .rail .card { flex: 1 1 260px; min-width: 0; }
}
/* 正文 */
.article-content { margin-top: 26px; font-size: 16.5px; line-height: 1.85; }
.article-content h1, .article-content h2, .article-content h3 { letter-spacing: -.02em; }
.article-content h2 { margin: 2.1em 0 .6em; font-size: 24px; }
.article-content h3 { margin: 1.6em 0 .5em; font-size: 18px; }
.article-content p { margin: .9em 0; }
.article-content ul, .article-content ol { margin: .9em 0; padding-left: 1.5em; list-style: disc; }
.article-content ol { list-style: decimal; }
.article-content li { margin: .4em 0; }
.article-content strong { font-weight: 700; }
.article-content code { font-family: var(--font-mono); font-size: .875em; background: var(--brand-soft); color: var(--brand-text); border-radius: 6px; padding: 2px 6px; }
.article-content pre { margin: 1.4em 0; border-radius: var(--radius-sm); background: var(--code-bg); border: 1px solid var(--line); overflow-x: auto; }
.article-content pre code { display: block; padding: 16px 18px; background: transparent; color: var(--code-ink); border: 0; border-radius: 0; font-size: 13px; line-height: 1.75; }
.article-content pre:focus-visible { outline: 2px solid var(--p1); outline-offset: 2px; }
.article-content blockquote { margin: 1.4em 0; padding: 14px 20px; border-radius: var(--radius-sm); background: var(--brand-soft); border-left: 4px solid var(--p1); color: var(--ink); }
.article-content table { display: block; width: 100%; max-width: 100%; margin: 1.4em 0; border-collapse: collapse; font-size: 14.5px; overflow-x: auto; }
.article-content table > thead, .article-content table > tbody { display: table-row-group; }
.article-content th, .article-content td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.article-content th { background: var(--soft); font-size: 13px; color: var(--dim); font-weight: 650; }
.article-content img { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.article-content hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* 深色模式下的正文示意图。
   问题：static/assets/diagrams/*.svg 这 17 张图**自己烤了浅底**（#faf8f4，外加 #f7f9fe / #f0faf9 / #fff7ed
   几块浅色面板），于是深色文章里会突然出现一大块刺眼白光 —— 独立视觉复核把它列为唯一的「严重刺眼」项。
   为什么不能在 SVG 内部适配：图是用 <img> 引入的，它内部的 prefers-color-scheme 跟的是**操作系统**，
   而本站深色是 html.dark 这个 class（站点开关控制）—— 两者会不一致，靠不住。
   为什么用 invert + hue-rotate(180deg)：这是处理「浅底线条图 / 代码截图」的标准手法 ——
   先反相把明度翻过来（浅底变深、深字变浅），再转 180° 色相把颜色转回原处（朱红点缀不会变成青色）。
   只作用于正文里的示意图，不碰真实照片、封面与卡片。 */
html.dark .article-content img[src*="/diagrams/"] {
  filter: invert(1) hue-rotate(180deg);
  border-color: rgba(255, 255, 255, .14);
}
/* 构建时统计表（page.extra.guide 开关控制，必须保留） */
.guide-stats {
  margin: 0 0 26px; padding: 6px 20px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.guide-stats table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.guide-stats th, .guide-stats td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
.guide-stats th { font-size: 12.5px; font-weight: 650; color: var(--dim); }
.guide-note { margin-top: 10px; font-size: 12.5px; color: var(--dim); }
.main-card > h2.title { display: flex; align-items: center; gap: 9px; margin: 2em 0 .8em; font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.main-card > h2.title .i { width: 20px; height: 20px; color: var(--brand-text); }
/* 上下篇：改成主页同一套「线框胶囊按钮」的语言（原来是纯文字下划线链接） */
.article-nav { display: flex; gap: 12px; margin-top: 42px; padding-top: 20px; border-top: 1px solid var(--line); }
.article-nav a, .article-nav .disabled {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; max-width: 48%; padding: 9px 18px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--ink);
  font-size: 13.5px; line-height: 1.5;
  transition: color .18s, border-color .18s, background .18s, transform .18s;
}
.article-nav .next { margin-left: auto; text-align: right; }
.article-nav a:hover { color: var(--brand-text); border-color: var(--p1); background: var(--brand-soft); transform: translateY(-1px); }
/* 占位文本不是控件：虚线边框 + 次级文字色（--dim 白底 5.94:1），既达 AA 又不像可点链接 */
.article-nav .disabled { color: var(--dim); border-style: dashed; }
/* 推荐阅读：与主页 .post-card 同一套卡片 —— 同圆角、同边框、同阴影、同上浮位移，
   并复用同一套「按分类色相生成」的封面（.rel-cover 与 .post-cover 共用一个图形定义）。 */
.related { margin-top: 44px; }
.related-title { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.related-title .i { width: 20px; height: 20px; color: var(--brand-text); }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 20px; }
.related-item {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.related-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: transparent; }
.rel-cover { display: block; aspect-ratio: 16 / 6; }
.rel-body { display: flex; flex-direction: column; gap: 7px; padding: 14px 16px 16px; }
.related-item .rel-title {
  font-size: 14.5px; font-weight: 650; line-height: 1.5; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* 只展示前 4 条（模板多渲染候选、由 CSS 裁到 4 条；重复项由 site.js 去重） */
.related-grid > .related-item:nth-child(n+5) { display: none; }
.article-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.article-footer a {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 18px;
  border: 1px solid var(--line-2); border-radius: var(--pill);
  background: var(--surface); color: var(--ink); font-size: 13.5px;
  transition: color .18s, border-color .18s, background .18s;
}
.article-footer a:hover { color: var(--brand-text); border-color: var(--p1); background: var(--brand-soft); }

/* ---------- 9. 页脚 ---------- */
.footer { margin-top: clamp(40px, 5vw, 64px); border-top: 1px solid var(--line); background: var(--soft); }
.footer-in { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 28px; padding: 40px 0 26px; }
.footer h2 { font-size: 12.5px; font-weight: 650; letter-spacing: .06em; color: var(--dim); text-transform: uppercase; }
.footer .brandline { display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 750; }
.footer .brandline i { width: 26px; height: 26px; border-radius: 8px; background: var(--grad); display: block; flex: none; }
.footer .about { margin-top: 12px; font-size: 13.5px; color: var(--dim); }
.footer-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.footer-nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; font-size: 14px; color: var(--ink); }
.footer-nav a:hover { color: var(--brand-text); }
.footer-nav .i { width: 15px; height: 15px; }
.footer-copy { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 16px 0 34px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--dim); }
.footer-copy a { display: inline-flex; align-items: center; min-height: 26px; color: var(--brand-text); }
.footer-copy a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 10. 404 ---------- */
.hero--full { min-height: calc(100vh - var(--nav-h)); display: flex; align-items: center; justify-content: center; padding: 72px 20px; text-align: center; background: linear-gradient(180deg, var(--soft), var(--bg)); }
.hero--full .hero-inner { max-width: 520px; }
.sig { display: inline-grid; place-items: center; width: 62px; height: 62px; border-radius: 18px; background: var(--grad); color: #fff; font-size: 24px; font-weight: 750; box-shadow: var(--shadow-2); }
.hero--full .hero-title { margin-top: 22px; font-size: clamp(26px, 3.4vw, 36px); background: none; -webkit-background-clip: initial; background-clip: initial; color: var(--ink); }
.hero--full .hero-role { margin-top: 12px; color: var(--dim); font-size: 15px; }
.hero--full .hero-back { margin-top: 24px; font-size: 15px; }
.back-home { display: inline-flex; align-items: center; min-height: 34px; color: var(--brand-text); font-weight: 650; }
.back-home:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 11. 焦点态（键盘可用性） ---------- */
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--p1); outline-offset: 2px; }
.nav a:focus-visible, .nav button:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; box-shadow: 0 0 0 4px var(--brand-soft); }
.search-results a.search-item:focus-visible { outline-offset: -2px; }

/* ---------- 12. 减弱动态效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .post-card:hover, .related-item:hover, .btn:hover { transform: none; }
  .post-card:hover .post-cover img { transform: none; }
}

/* ---------- 13. 响应式 ---------- */
@media (max-width: 980px) {
  .footer-in { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 820px) {
  html.js .menu-toggle { display: inline-flex; }
  .subscribe { display: none; }
  html.js .links {
    display: none;
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px; margin: 0;
    padding: 8px; background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-2);
  }
  html.js .links.open { display: flex; }
  html.js .links a { min-height: 48px; border-radius: var(--radius-sm); }
  /* 无 JS 降级：菜单项不能藏在「点了没反应」的开关后面。
     没有 JS 时顶栏改为静态、导航平铺 —— 不死控件，flex-wrap 也不会撑破 320px。 */
  html:not(.js) .nav-in { height: auto; flex-wrap: wrap; justify-content: center; gap: 6px 12px; padding: 10px 0; }
  html:not(.js) .links { position: static; display: flex; flex-wrap: wrap; justify-content: center; width: 100%; gap: 4px; }
  html:not(.js) .links a { min-height: 40px; }
  .hero { padding-top: 34px; }
  /* 移动端统计卡保持一排三个（堆叠会白占掉 ~200px 首屏）。
     320px 下每格约 90px，「篇文章」这类标签仍然放得下。 */
  .stats { gap: 8px; margin-top: 24px; }
  .stat { padding: 13px 10px; }
  .stat b { font-size: 22px; }
  .stat span { font-size: 11.5px; }
  .related-grid { grid-template-columns: minmax(0, 1fr); }
  .footer-in { grid-template-columns: minmax(0, 1fr); gap: 22px; padding-bottom: 20px; }
  .article-nav { flex-direction: column; }
  .article-nav a, .article-nav .disabled { max-width: 100%; }
}
@media (max-width: 420px) {
  .wrap, .page-head, .find { padding-left: 18px; padding-right: 18px; }
  .search-box { flex-wrap: wrap; }
  .search-box button { width: 100%; }
}

/* ---------- 14. 打印 ----------
   只藏装饰，绝不藏内容 —— .cloud/.filters 曾经被藏过，结果 /categories/ 与 /tags/
   两页打印成白纸（实测 printText=0，验收当场 FAIL）。 */
@media print {
  .nav, .menu-toggle, .dark-toggle, .subscribe, .cta, .footer-in,
  .progress-bar, .post-cover, .cover, .rail, .related,
  .article-nav, .search-box, .sect .more, .crumb {
    display: none !important;
  }
  html, body { background: #fff !important; color: #000 !important; }
  .hero, .page-head, .main-card, .post-card, .footer, .wrap {
    background: #fff !important; box-shadow: none !important; border: none !important;
    margin: 0 !important; padding: 0 !important; max-width: 100% !important; width: 100% !important;
  }
  .layout { display: block !important; margin: 0 !important; }
  .hero h1, .page-head h1 { background: none !important; -webkit-background-clip: initial !important; background-clip: initial !important; color: #000 !important; }
  .article-footer a, .article-meta kbd { border: 0 !important; padding: 0 !important; background: none !important; color: #000 !important; }
  .lede, .post-desc, .post-meta, .article-meta, .footer-copy, .stat span, .page-head .sub { color: #333 !important; }
  .chip, .cloud a, .article-meta kbd { border: 1px solid #bbb !important; color: #000 !important; background: #fff !important; }
  .cloud a em { color: #555 !important; }
  .stats { display: block !important; }
  .stat, .post-card { page-break-inside: avoid; }
  .hero-id { border: 0 !important; padding: 0 !important; }
  .hero-id .avatar { width: 40px !important; height: 40px !important; }
  .hero--full { min-height: auto !important; padding: 0 !important; }
  .sig { background: #eee !important; color: #000 !important; box-shadow: none !important; }
  .guide-stats { margin: 0 0 14px !important; padding: 0 0 8px !important; border: 0 !important; box-shadow: none !important; }
  .article-content { font-size: 11.5pt; line-height: 1.55; }
  .article-content pre, .article-content pre code, .article-content code {
    background: #f6f6f6 !important; color: #1a1a1a !important; border: 1px solid #ccc !important; box-shadow: none !important;
  }
  .article-content pre span { color: #1a1a1a !important; }
  .article-content a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444; word-break: break-all; }
  .article-content a { color: #000 !important; text-decoration: underline; }
  .article-content table { display: table; page-break-inside: auto; }
  .article-content th { background: #eee !important; color: #000 !important; }
  .article-content tr { page-break-inside: avoid; }
  .article-content th, .article-content td { border: 1px solid #999 !important; }
  .article-content img { max-width: 100% !important; page-break-inside: avoid; }
  .article-content blockquote { background: none !important; border-left: 3px solid #999 !important; color: #333 !important; }
  h1, h2, h3 { page-break-after: avoid; color: #000 !important; }
}
/* 语法高亮的内联注释色覆盖：Zola 把 github-dark 的注释色 #6a737d 内联在 span 上，
   在代码块底色 #24292e 上只有 3.05:1（浅/深色两模式都不达 AA，实测浅色 9 页、深色 162 处）。
   只覆盖这一档，其余语法色不动。 */
.article-content pre span[style*="#6a737d"] { color: #8b949e !important; }
