/* ============================================================
   边缘视觉工程实录 · v2 modern minimal light
   手写主题 · 零外部依赖 · 双主题（默认浅色，可切暗色）
   ============================================================ */

:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --panel-2: #f4f3f0;
  --line: #e7e5e4;
  --ink: #1f2328;
  --muted: #6b7280;
  --accent: #3f6212;        /* 深绿：链接/按钮（白底 AA） */
  --accent-hover: #2e4a0c;
  --bright: #76b900;        /* Jetson 绿：点缀 */
  --accent-soft: #eef5e2;   /* 绿的浅底 */
  --amber: #b45309;
  --code-bg: #0f1114;       /* 代码块恒深：terminal card */
  --code-ink: #e8e6e0;
  --shadow: 0 6px 24px rgba(31, 35, 40, .07);
  --head-bg: rgba(251, 250, 248, .86);
}
[data-theme=dark] {
  --bg: #14161a;
  --panel: #1a1e24;
  --panel-2: #20242b;
  --line: #2c3038;
  --ink: #e8e6e0;
  --muted: #9aa1aa;
  --accent: #8fd460;
  --accent-hover: #a9e37e;
  --bright: #76b900;
  --accent-soft: #232b18;
  --amber: #e5a63d;
  --code-bg: #0f1114;
  --code-ink: #e8e6e0;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --head-bg: rgba(20, 22, 26, .86);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.75;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--bright); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(118, 185, 0, .25); }

h1, h2, h3, h4 { line-height: 1.4; margin: 1.2em 0 .5em; font-weight: 700; }

/* ---------- 阅读进度条 ---------- */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--bright), var(--accent));
  z-index: 200; transition: width .12s linear;
}

/* ---------- 顶栏 ---------- */
.site-head {
  position: sticky; top: 0; z-index: 100;
  background: var(--head-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.head-wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand {
  color: var(--ink); font-weight: 800; font-size: 17px; letter-spacing: .5px;
  display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
}
.brand:hover { color: var(--ink); }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--bright);
  box-shadow: 0 0 0 4px rgba(118, 185, 0, .18);
}
.nav-links { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-links > a {
  color: var(--muted); font-size: 15px; padding: 6px 12px; border-radius: 8px;
}
.nav-links > a:hover { color: var(--accent); background: var(--panel-2); }
.head-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
#menu-toggle { display: none; }

/* ---------- 社交 chips ---------- */
.social { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 13px; font-size: 13px; color: var(--muted); background: var(--panel);
  white-space: nowrap;
}
a.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip-dim { border-style: dashed; opacity: .6; }
.chip-rss { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-rss:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.social-nav .chip { font-size: 12px; padding: 2px 10px; }
.social-cta .chip { font-size: 14px; padding: 7px 18px; }

/* ---------- Hero ---------- */
main { padding: 36px 0 72px; }
.hero { padding: 56px 0 40px; }
.hero h1 { font-size: clamp(30px, 4.6vw, 46px); letter-spacing: 1px; margin: 0; }
.hero-sub { color: var(--muted); font-size: 17px; margin-top: 14px; max-width: 760px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.stat-chip {
  border: 1px solid var(--line); background: var(--panel);
  padding: 6px 16px; border-radius: 999px; font-size: 14px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-chip::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--bright); margin-right: 8px; }

/* ---------- 首页分区 ---------- */
.home-sec { margin-top: 48px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sec-head h2 { font-size: 22px; margin: 0; }
.sec-more { font-size: 14px; color: var(--muted); }
.sec-more:hover { color: var(--accent); }

/* ---------- 卡片 ---------- */
.series-wall, .post-grid {
  display: grid; gap: 20px; margin-top: 20px;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
}
.card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--bright);
  color: var(--ink);
}
.card-cover {
  aspect-ratio: 16 / 9; background-size: cover; background-position: center;
  background-color: var(--panel-2); border-bottom: 1px solid var(--line);
}
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.card-title { font-size: 17.5px; line-height: 1.45; margin: 0; }
.card:hover .card-title { color: var(--accent); }
.card-excerpt { font-size: 14px; color: var(--muted); line-height: 1.7; }
.pill {
  display: inline-block; border-radius: 999px; padding: 1px 11px; font-size: 12.5px; font-weight: 600;
}
.pill-green { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(118, 185, 0, .45); }
.tag-mini { border: 1px solid var(--line); border-radius: 999px; padding: 0 9px; font-size: 12px; color: var(--muted); }
.series-count { color: var(--muted); font-size: 13px; }
.series-go { margin-top: auto; font-size: 14px; color: var(--accent); font-weight: 600; }

/* ---------- CTA ---------- */
.cta-bar {
  margin-top: 56px; padding: 26px 30px; border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--accent-soft), var(--panel) 65%);
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.cta-bar h2 { font-size: 20px; margin: 0; }
.cta-bar p { color: var(--muted); font-size: 14.5px; margin-top: 4px; }

/* ---------- 通用页头 ---------- */
.page-head { padding: 28px 0 8px; }
.page-head h1 { font-size: 30px; margin: 0 0 8px; }
.page-sub { color: var(--muted); }
.page-head-content { color: var(--muted); margin-top: 12px; max-width: 760px; }
.tag-wall { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.tag-wall .tag { font-size: 14px; padding: 4px 14px; }
.tag-n { opacity: .6; margin-left: 6px; font-size: 12px; }

/* ---------- 专题页头（term） ---------- */
.series-head { margin-top: 20px; }
.series-banner {
  aspect-ratio: 16 / 5; max-height: 260px; border-radius: 16px;
  background-size: cover; background-position: center;
  background-color: var(--panel-2); border: 1px solid var(--line);
}
.series-head-text { padding: 22px 4px 6px; max-width: 780px; }
.series-head-text h1 { font-size: 30px; margin: 10px 0 6px; }
.series-tagline { color: var(--muted); font-size: 16.5px; }
.series-intro { margin-top: 14px; color: var(--ink); }
.series-intro p { margin: .6em 0; }
.series-head-text .series-count { display: inline-block; margin-top: 14px; }

/* ---------- 文章三列布局 ---------- */
.post-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 230px;
  gap: 44px;
  align-items: start;
}
.post { max-width: 740px; width: 100%; justify-self: center; }

/* 左栏：系列浮标 */
.rail { position: sticky; top: 92px; }
.rail-card {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  padding: 16px; display: flex; flex-direction: column; gap: 7px;
}
.rail-label { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.rail-series { font-weight: 700; font-size: 15px; line-height: 1.5; }
.rail-pos { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rail-card::before { content: ""; display: block; width: 26px; height: 3px; border-radius: 2px; background: var(--bright); }

/* 右栏：目录 */
.toc { position: sticky; top: 92px; max-height: calc(100vh - 130px); overflow-y: auto; }
.toc-inner { border-left: 2px solid var(--line); padding-left: 16px; }
.toc-label { font-size: 12px; color: var(--muted); letter-spacing: 2px; display: block; margin-bottom: 8px; }
#TableOfContents ul { list-style: none; margin: 0; padding-left: 12px; }
#TableOfContents > ul { padding-left: 0; }
#TableOfContents li { margin: 3px 0; }
#TableOfContents a {
  display: block; color: var(--muted); font-size: 13px; line-height: 1.5;
  padding: 2px 0 2px 10px; border-left: 2px solid transparent; margin-left: -18px;
}
#TableOfContents a:hover { color: var(--accent); }
#TableOfContents a.current {
  color: var(--accent); border-left-color: var(--bright); font-weight: 600;
}
.toc-empty { display: none; }

/* 面包屑 */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 18px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs span:last-child { color: var(--ink); }

/* 文章头 */
.post-head h1 { font-size: clamp(24px, 3.4vw, 33px); margin: 0; }
.meta { color: var(--muted); font-size: 14px; margin: 14px 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tag {
  display: inline-block; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 99px; padding: 1px 12px; font-size: 13px; color: var(--muted);
}
.lead {
  color: var(--muted); border-left: 3px solid var(--bright);
  padding: 12px 18px; background: var(--panel-2); border-radius: 0 10px 10px 0;
  margin: 20px 0 8px; font-size: 15px;
}

/* 移动端目录折叠 */
.toc-mobile {
  display: none; margin: 18px 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); padding: 0;
}
.toc-mobile summary {
  cursor: pointer; padding: 12px 16px; font-size: 14px; font-weight: 600; color: var(--ink);
  list-style: none;
}
.toc-mobile summary::before { content: "☰ "; color: var(--accent); }
.toc-mobile[open] summary { border-bottom: 1px solid var(--line); }
.toc-mobile #TableOfContents { padding: 12px 16px; }

/* ---------- 正文排版 ---------- */
.content { font-size: 16.5px; }
.content p { margin: .85em 0; }
.content h2 {
  font-size: 23px; margin-top: 2.1em; padding-top: .75em;
  border-top: 1px solid var(--line);
}
.content h3 { font-size: 19px; margin-top: 1.8em; }
.content figure { margin: 20px 0; }
.content img {
  max-width: 100%; height: auto; border-radius: 12px;
  border: 1px solid var(--line); display: block; cursor: zoom-in;
}
.content figcaption { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px; line-height: 1.6; }
.content blockquote {
  border-left: 3px solid var(--amber); background: var(--panel-2);
  padding: 12px 18px; border-radius: 0 10px 10px 0; color: var(--muted); margin: 16px 0;
  font-size: 15px;
}
.content blockquote strong { color: var(--ink); }
.content code {
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; font-size: .88em; color: var(--ink);
}
.content pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 16px 18px; overflow-x: auto; margin: 18px 0; line-height: 1.6;
}
.content pre code { background: none; border: none; padding: 0; font-size: 13.5px; color: var(--code-ink); }
.content table {
  border-collapse: collapse; width: 100%; margin: 18px 0; font-size: 14.5px;
  display: block; overflow-x: auto;
}
.content th, .content td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.content th { background: var(--panel-2); }
.content tr:nth-child(even) td { background: color-mix(in srgb, var(--panel-2) 45%, transparent); }
.content hr { border: none; border-top: 1px dashed var(--line); margin: 30px 0; }
.content em { color: var(--amber); font-style: normal; }
.content ul, .content ol { padding-left: 1.5em; margin: .8em 0; }

/* ---------- 文末 ---------- */
.post-foot { margin-top: 48px; }
.post-nav { display: flex; gap: 14px; }
.post-nav a {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; color: var(--ink); font-size: 14.5px; line-height: 1.5;
  display: flex; flex-direction: column; gap: 3px;
}
.post-nav a:hover { border-color: var(--bright); color: var(--accent); }
.post-nav a span { font-size: 12px; color: var(--muted); letter-spacing: 1px; }
.post-nav .next { text-align: right; }
.post-nav .dim { visibility: hidden; }
.cta-mini {
  margin-top: 18px; padding: 16px 20px; border: 1px dashed var(--line); border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  color: var(--muted); font-size: 14px;
}

/* ---------- 页脚 ---------- */
.site-foot { border-top: 1px solid var(--line); background: var(--panel-2); padding: 30px 0 26px; margin-top: 40px; }
.foot-wrap { display: flex; justify-content: space-between; gap: 30px; flex-wrap: wrap; }
.foot-brand p { color: var(--muted); font-size: 13.5px; margin-top: 8px; max-width: 420px; }
.foot-links { display: flex; flex-direction: column; gap: 7px; font-size: 14px; }
.foot-links a { color: var(--muted); }
.foot-links a:hover { color: var(--accent); }
.foot-note { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 300; background: rgba(10, 12, 14, .86);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px;
}
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 10px; }
.lightbox[hidden] { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 1280px) {
  .post-layout { grid-template-columns: minmax(0, 1fr) 230px; }
  .rail { display: none; }
}
@media (max-width: 1024px) {
  .post-layout { display: block; }
  .toc { display: none; }
  .toc-mobile { display: block; }
  .post { margin: 0 auto; }
}
@media (max-width: 860px) {
  #menu-toggle { display: inline-flex; }
  .nav-links {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    background: var(--panel); border-bottom: 1px solid var(--line);
    padding: 12px 24px 16px; flex-direction: column; align-items: flex-start; gap: 8px;
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links > a { padding: 8px 4px; width: 100%; }
  .social-nav { margin-top: 8px; }
  .hero { padding: 36px 0 24px; }
  .hero-stats { gap: 8px; }
  .cta-bar { flex-direction: column; align-items: flex-start; }
  .post-nav { flex-direction: column; }
  .foot-wrap { flex-direction: column; }
  .series-banner { aspect-ratio: 16 / 7; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .series-wall, .post-grid { grid-template-columns: 1fr; }
  .content { font-size: 15.5px; }
}
