:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f7;
  --fg: #1d1d1f;
  --fg-soft: #424245;
  --muted: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --code-bg: #f5f5f7;
  --radius-card: 18px;
  --radius-pill: 980px;
  --maxw: 980px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
    'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
}
h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 21px; }
h4 { font-size: 17px; }

p { margin: 0 0 1em; color: var(--fg-soft); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
}
.site-header .wrap {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 24px; margin-left: auto; }
.nav a { font-size: 13px; color: var(--fg-soft); }
.nav a:hover { color: var(--accent); text-decoration: none; }

/* ---------- Hero ---------- */
.hero { padding: 96px 0 72px; text-align: center; background: var(--bg); }
.hero h1 { font-size: 48px; margin-bottom: 16px; }
.hero p {
  font-size: 21px;
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto;
}

/* ---------- Section ---------- */
.section { padding: 72px 0; }
.section.alt { background: var(--bg-alt); }
.section-head { margin-bottom: 32px; }
.section-head h2 { margin-bottom: 8px; }
.section-head p { color: var(--muted); font-size: 17px; margin: 0; }

/* ---------- Cards ---------- */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.card {
  background: #fff;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-card);
  padding: 24px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: var(--line); transform: translateY(-2px); }
.card h3 { font-size: 19px; margin-bottom: 6px; }
.card h3 a { color: var(--fg); }
.card h3 a:hover { color: var(--accent); text-decoration: none; }
.card p { font-size: 15px; color: var(--muted); margin: 0 0 14px; }

.meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Pills ---------- */
.pill {
  display: inline-block;
  font-size: 12px;
  color: var(--fg-soft);
  background: var(--bg-alt);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-pill);
  padding: 3px 11px;
}
.pill.accent { color: #fff; background: var(--accent); border-color: var(--accent); }
.pill a { color: inherit; }
.pill a:hover { text-decoration: none; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  border-radius: var(--radius-pill);
  padding: 10px 22px;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.ghost:hover { background: rgba(0, 113, 227, 0.06); }

/* ---------- Breadcrumb ---------- */
.crumbs { font-size: 13px; color: var(--muted); padding: 20px 0 0; }
.crumbs a { color: var(--muted); }
.crumbs span { margin: 0 6px; }

/* ---------- Article ---------- */
.article { padding: 24px 0 96px; }
.article-header { padding: 24px 0 32px; border-bottom: 1px solid var(--line-soft); margin-bottom: 40px; }
.article-header h1 { font-size: 44px; margin-bottom: 14px; }
.article-header .lede { font-size: 21px; color: var(--muted); line-height: 1.4; }

.prose { font-size: 17px; }
.prose h2 { margin: 48px 0 16px; padding-top: 8px; }
.prose h3 { margin: 32px 0 12px; }
.prose h2 a, .prose h3 a { color: var(--fg); }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1.1em; }
.prose li { margin-bottom: 8px; color: var(--fg-soft); }
.prose strong { color: var(--fg); font-weight: 600; }
.prose blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.prose img { max-width: 100%; border-radius: 12px; }
.prose hr { border: 0; border-top: 1px solid var(--line-soft); margin: 48px 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 15px; }
.prose th, .prose td { border-bottom: 1px solid var(--line-soft); padding: 10px 12px; text-align: left; }
.prose th { font-weight: 600; color: var(--fg); }

.prose :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border-radius: 5px;
  padding: 2px 6px;
  color: #c7254e;
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 1.4em;
}
.prose pre code { background: none; padding: 0; color: inherit; font-family: var(--mono); }

.callout {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 24px 0;
  font-size: 15px;
  color: var(--fg-soft);
}

/* ---------- TOC ---------- */
.toc {
  font-size: 14px;
  border-left: 1px solid var(--line-soft);
  padding-left: 18px;
}
.toc-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin-bottom: 7px; }
.toc a { color: var(--fg-soft); }
.toc a:hover { color: var(--accent); text-decoration: none; }
.toc .h3 { padding-left: 14px; font-size: 13px; }

/* ---------- Layout ---------- */
.with-toc { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 48px; align-items: start; }
@media (max-width: 860px) {
  .with-toc { grid-template-columns: 1fr; gap: 0; }
  .toc { display: none; }
  h1 { font-size: 32px; }
  .hero h1 { font-size: 36px; }
  .hero p, .article-header .lede { font-size: 18px; }
  .article-header h1 { font-size: 32px; }
  .nav { gap: 16px; }
  .site-header .wrap { gap: 16px; }
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line-soft);
  background: var(--bg-alt);
  padding: 40px 0;
  font-size: 13px;
  color: var(--muted);
}
.site-footer .wrap { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* ---------- Search ---------- */
.search-box {
  width: 100%;
  font-size: 17px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--font);
  outline: none;
}
.search-box:focus { border-color: var(--accent); }
.search-result { padding: 18px 0; border-bottom: 1px solid var(--line-soft); }
.search-result h3 { font-size: 19px; margin-bottom: 6px; }
.search-result p { font-size: 15px; color: var(--muted); margin: 0; }

/* ---------- 间距小工具 ---------- */
.mb { margin-bottom: 10px; }
.mb-lg { margin-bottom: 32px; }
.mt { margin-top: 12px; }
.right { text-align: right; }
.muted-text { font-size: 15px; color: var(--muted); }

/* ---------- 首页搜索框 ---------- */
.hero-search { max-width: 560px; margin: 32px auto 0; }

/* ---------- 分类总览 ---------- */
.cat-block { padding: 36px 0; border-bottom: 1px solid var(--line-soft); }
.cat-block:last-child { border-bottom: 0; }
.cat-desc { color: var(--muted); font-size: 15px; margin: 6px 0 20px; }
.sub-card { display: block; color: inherit; }
.sub-card:hover { text-decoration: none; border-color: var(--line); }
.sub-card h3 { font-size: 19px; }
.sub-card p { font-size: 15px; color: var(--muted); min-height: 44px; }

/* ---------- 标签页 ---------- */
.tag-block { padding: 24px 0; border-top: 1px solid var(--line-soft); scroll-margin-top: 64px; }
.tag-block h2 { font-size: 21px; margin-bottom: 12px; }
.tag-block ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tag-block li { display: flex; justify-content: space-between; gap: 20px; font-size: 16px; }
.tag-block time { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- 文章列表 ---------- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: baseline;
  padding: 22px 0;
  border-bottom: 1px solid var(--line-soft);
  color: inherit;
}
.post-row:hover { text-decoration: none; }
.post-row:hover h3 { color: var(--accent); }
.post-row h3 { font-size: 19px; margin-bottom: 4px; }
.post-row p { font-size: 15px; color: var(--muted); margin: 0; }
.post-row time { font-size: 13px; color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) {
  .post-row { flex-direction: column; gap: 6px; }
}

/* ---------- 相关文章 ---------- */
.related { margin-top: 72px; padding-top: 32px; border-top: 1px solid var(--line-soft); }
.related h2 { font-size: 21px; margin-bottom: 18px; }
.related ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.related li { display: flex; flex-direction: column; gap: 2px; }
.related a { font-size: 17px; font-weight: 500; }
.related span { font-size: 14px; color: var(--muted); }

/* ---------- 404 列表 ---------- */
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 17px; }

/* ---------- 搜索结果 ---------- */
.results { margin-top: 8px; }
.results .search-result {
  display: block;
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
  color: inherit;
}
.results .search-result:hover { text-decoration: none; }
.results .search-result:hover h3 { color: var(--accent); }
.results h3 { font-size: 19px; margin-bottom: 6px; }
.results p { font-size: 15px; color: var(--muted); margin: 0 0 8px; }
mark { background: rgba(0, 113, 227, 0.14); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- 代码着色（极简） ---------- */
.tok-c { color: #6a737d; }
.tok-s { color: #0a7c42; }

/* ============================================================
 * 深色模式（跟随系统 + 手动切换）
 * ========================================================== */
:root[data-theme='dark'] {
  --bg: #000000;
  --bg-alt: #0a0a0a;
  --fg: #f5f5f7;
  --fg-soft: #e8e8ed;
  --muted: #86868b;
  --line: #2d2d2f;
  --line-soft: #1d1d1f;
  --accent: #2997ff;
  --accent-text: #2997ff;
  --code-bg: #161617;
}
:root[data-theme='dark'] .card { background: #111113; }
:root[data-theme='dark'] .site-header,
:root[data-theme='dark'] .site-footer { background: rgba(0, 0, 0, 0.72); }
:root[data-theme='dark'] .search-box { background: #161617; color: var(--fg); }
:root[data-theme='dark'] code { background: #1d1d1f; }
:root[data-theme='dark'] pre.code { background: #161617; }
:root[data-theme='dark'] table th { background: #161617; }
:root[data-theme='dark'] .x-callout { background: #111113; }
:root[data-theme='dark'] .tok-c { color: #7d8590; }
:root[data-theme='dark'] .tok-s { color: #7ee787; }
:root[data-theme='dark'] .tok-n { color: #79c0ff; }
:root[data-theme='dark'] .tok-k { color: #ff7b72; }
:root[data-theme='dark'] .tok-f { color: #d2a8ff; }
:root[data-theme='dark'] mark { background: rgba(41, 151, 255, 0.28); }
:root[data-theme='dark'] .x-github { background: #161617; border-color: #2d2d2f; }
:root[data-theme='dark'] .x-figure img { background: #161617; }

/* 切换按钮 */
.theme-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex: none;
}
.theme-toggle::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--fg);
  box-shadow: 8px -4px 0 0 var(--fg);
  transform: scale(0.62);
  transition: transform 0.25s ease;
}
:root[data-theme='dark'] .theme-toggle::before {
  background: transparent;
  box-shadow: none;
  border: 2px solid var(--fg);
  transform: scale(1);
}

/* ============================================================
 * 阅读进度条
 * ========================================================== */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--accent);
  z-index: 100;
  transition: width 0.08s linear;
}

/* ============================================================
 * 代码块 + 复制按钮
 * ========================================================== */
.code-block {
  position: relative;
  margin: 22px 0;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg, #fafafa);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-alt);
}
.code-lang {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.code-copy {
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 980px;
  padding: 3px 12px;
  cursor: pointer;
}
.code-copy:hover { color: var(--fg); border-color: var(--accent); }
.code-copy.copied { color: #0a7c42; border-color: #0a7c42; }
.code-block pre.code {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

/* 代码着色 */
.tok-c { color: #6a737d; font-style: italic; }
.tok-s { color: #0a7c42; }
.tok-n { color: #0550ae; }
.tok-k { color: #cf222e; }
.tok-f { color: #8250df; }

/* ============================================================
 * 内嵌组件
 * ========================================================== */
/* 提示框 */
.x-callout {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 22px 0;
  background: var(--bg-alt);
}
.x-callout-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  color: var(--accent-text);
}
.x-callout-body > :first-child { margin-top: 0; }
.x-callout-body > :last-child { margin-bottom: 0; }
.x-tip { border-left-color: #0a7c42; }
.x-tip .x-callout-label { color: #0a7c42; }
.x-warn { border-left-color: #bf8700; }
.x-warn .x-callout-label { color: #bf8700; }

/* 折叠块 */
.x-details {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  margin: 22px 0;
  overflow: hidden;
}
.x-details > summary {
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 500;
  font-size: 16px;
  background: var(--bg-alt);
  list-style: none;
}
.x-details > summary::-webkit-details-marker { display: none; }
.x-details > summary::after { content: '＋'; float: right; color: var(--muted); }
.x-details[open] > summary::after { content: '－'; }
.x-details-body { padding: 4px 18px 16px; }
.x-details-body > :first-child { margin-top: 0; }

/* 站内卡片 */
.x-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 20px 0;
  color: inherit;
  background: var(--bg-alt);
}
.x-card:hover { text-decoration: none; border-color: var(--accent); }
.x-card-title { font-size: 17px; font-weight: 600; }
.x-card-desc { font-size: 14px; color: var(--muted); margin-top: 4px; }
.x-card-arrow { color: var(--accent); flex: none; font-size: 18px; }

/* 按钮 */
.x-btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 980px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  margin: 8px 0;
}
.x-btn:hover { text-decoration: none; opacity: 0.88; }
.x-btn-ext { margin-left: 4px; opacity: 0.8; }

/* 视频 */
.x-video { margin: 24px 0; }
.x-video-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line-soft);
}
.x-video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.x-video video {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  display: block;
}
.x-video-title { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* 图片 */
.x-figure { margin: 24px 0; }
.x-figure img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  display: block;
}
.x-figure figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; text-align: center; }

/* 徽标 */
.x-badge {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 980px;
  margin: 0 6px 6px 0;
  border: 1px solid transparent;
  vertical-align: middle;
}
.x-badge-tech { background: rgba(0, 113, 227, 0.1); color: #0066cc; border-color: rgba(0, 113, 227, 0.25); }
.x-badge-ok { background: rgba(10, 124, 66, 0.1); color: #0a7c42; border-color: rgba(10, 124, 66, 0.25); }
.x-badge-ver { background: rgba(134, 134, 139, 0.12); color: #6e6e73; border-color: rgba(134, 134, 139, 0.3); }
:root[data-theme='dark'] .x-badge-tech { color: #2997ff; background: rgba(41, 151, 255, 0.15); }
:root[data-theme='dark'] .x-badge-ok { color: #7ee787; background: rgba(126, 231, 135, 0.15); }
:root[data-theme='dark'] .x-badge-ver { color: #a1a1a6; background: rgba(161, 161, 166, 0.15); }

/* GitHub 卡片 */
.x-github {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 980px;
  font-size: 15px;
  color: inherit;
  margin: 8px 0;
  background: var(--bg);
}
.x-github:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }

/* ============================================================
 * 文章元信息 / 上下篇
 * ========================================================== */
.read-time { font-size: 13px; color: var(--muted); }

.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--line-soft);
}
.pn-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  color: inherit;
  min-height: 74px;
}
.pn-item:hover { text-decoration: none; border-color: var(--accent); }
.pn-item:hover .pn-title { color: var(--accent); }
.pn-item.empty { border: 0; }
.pn-label { font-size: 12px; color: var(--muted); }
.pn-title { font-size: 16px; font-weight: 500; line-height: 1.35; }
@media (max-width: 640px) {
  .prev-next { grid-template-columns: 1fr; }
}

/* 目录高亮 */
.toc a.active { color: var(--accent); font-weight: 600; }

/* 表格横向滚动 */
.table-wrap { overflow-x: auto; margin: 22px 0; -webkit-overflow-scrolling: touch; }
.table-wrap table { margin: 0; min-width: 420px; }

/* ============================================================
 * 移动端导航：更紧凑
 * ========================================================== */
@media (max-width: 640px) {
  .site-header .wrap { height: 44px; gap: 10px; }
  .brand { font-size: 16px; }
  .nav { gap: 14px; font-size: 14px; margin-left: auto; }
  .nav a { padding: 4px 0; }
  .theme-toggle { width: 26px; height: 26px; }
  body { font-size: 16px; }
  .section { padding: 56px 0; }
  .hero { padding: 72px 0 56px; }
}
