/* ==========================================================
   个人服务搭建踩坑及排雷记录 — 样式表
   纯静态、无外部依赖、无字体/统计/广告请求
   ========================================================== */

:root {
  color-scheme: light;
  --paper: #fbfaf7;
  --card: #ffffff;
  --ink: #191c21;
  --ink-2: #3d434d;
  --muted: #6f7681;
  --faint: #9aa1ab;
  --line: #e7e3dc;
  --line-soft: #f0ece6;
  --accent: #2f6b5f;
  --accent-ink: #245247;
  --accent-soft: #eaf2ef;
  --accent-2: #6f9d92;
  --code-bg: #f5f3ee;
  --body-ink: #22262c;
  --code-ink: #8a3f2c;
  --code-plain: #2f353d;
  --header-bg: rgba(251, 250, 247, 0.88);
  --callout-bg: #fdf7ef;
  --callout-line: #f0e0c8;
  --callout-bar: #c98a2b;
  --callout-text: #6b4d1d;
  --callout-strong: #8a5d13;
  --next-line: #cfe0da;
  --footer-bg: #f6f4ef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(25, 28, 33, 0.04), 0 8px 24px -12px rgba(25, 28, 33, 0.12);
  --wrap: 1060px;
}

/* ---------- 深色主题 ---------- */
html.dark {
  color-scheme: dark;
  --paper: #101418;
  --card: #161c23;
  --ink: #e8e6e1;
  --ink-2: #c4c9d1;
  --muted: #9aa3ad;
  --faint: #6b7480;
  --line: #2a323d;
  --line-soft: #222a33;
  --accent: #5fae9e;
  --accent-ink: #7cc3b2;
  --accent-soft: #1c2b27;
  --accent-2: #3d5a52;
  --code-bg: #1a2028;
  --body-ink: #ccd1d9;
  --code-ink: #e2a06b;
  --code-plain: #c4c9d1;
  --header-bg: rgba(16, 20, 24, 0.88);
  --callout-bg: #241f16;
  --callout-line: #3d3423;
  --callout-bar: #d9a441;
  --callout-text: #d6bd8d;
  --callout-strong: #eccf96;
  --next-line: #33463f;
  --footer-bg: #14181d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
}

/* ---------- 主题切换按钮（全站固定右上角） ---------- */
.theme-btn {
  position: fixed;
  top: 13px;
  right: 16px;
  z-index: 100;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color .2s, border-color .2s, transform .2s;
}
.theme-btn:hover { color: var(--accent); border-color: var(--accent); transform: scale(1.06); }
.theme-btn svg { width: 18px; height: 18px; display: block; } /* SVG 图标不随按钮撑满 */

/* 主题下拉菜单：亮色 / 暗黑 / 跟随系统（assets/theme.js 动态创建） */
.theme-menu {
  position: fixed;
  top: 59px;
  right: 16px;
  z-index: 100;
  min-width: 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  flex-direction: column;
}
.theme-menu.open { display: flex; }
.theme-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}
.theme-menu-item:hover,
.theme-menu-item.active { background: var(--line-soft); color: var(--ink); }
.theme-menu-item .mi-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--muted);
}
.theme-menu-item.active .mi-icon { color: var(--ink); }
.theme-menu-item .mi-icon svg { width: 16px; height: 16px; display: block; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.serif {
  font-family: "Songti SC", "Source Han Serif SC", "Noto Serif SC", Georgia, serif;
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 72px 0 24px; /* 右侧留出固定主题按钮的位置 */
  height: 62px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand .mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translateY(3px);
  letter-spacing: 0;
}

a.brand { color: inherit; text-decoration: none; }

.brand .name { font-size: 16px; }

.brand .name-short { display: none; }

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 22px;
  font-size: 14px;
  color: var(--muted);
}

.site-nav a { padding: 4px 0; border-bottom: 1px solid transparent; }
.site-nav a:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.site-nav a.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- 导航下拉菜单 ---------- */
.nav-drop { position: relative; display: inline-block; }
.nav-drop summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  user-select: none;
}
.nav-drop summary::-webkit-details-marker { display: none; }
.nav-drop summary::after {
  content: "▾";
  display: inline-block;
  margin-left: 5px;
  font-size: 15px;
  line-height: 1;
  color: var(--faint);
  transition: transform .15s ease;
}
.nav-drop[open] summary::after { transform: rotate(180deg); }
.nav-drop summary:hover { color: var(--accent-ink); border-bottom-color: var(--accent); }
.nav-drop summary.active { color: var(--ink); border-bottom-color: var(--accent); }
.nav-drop[open] summary { color: var(--accent-ink); border-bottom-color: var(--accent); }
.nav-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 176px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: flex;
  flex-direction: column;
  z-index: 80;
}
.nav-menu::before {
  /* 悬浮桥：防止鼠标从 summary 移向菜单时经过空隙导致提前收起 */
  content: "";
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
}
.nav-menu a {
  display: block;
  padding: 8px 12px;
  border-bottom: none;
  border-radius: 7px;
  white-space: nowrap;
  color: var(--ink-2);
  font-size: 13.5px;
}
.nav-menu a:hover {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-bottom-color: transparent;
}

/* ---------- 通用容器 ---------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }

/* ---------- 首页 Hero ---------- */
.hero {
  padding: 58px 0 40px;
  border-bottom: 1px solid var(--line-soft);
}

.hero h1 {
  margin: 0 0 14px;
  font-size: 34px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.hero p {
  margin: 0;
  max-width: 620px;
  color: var(--ink-2);
  font-size: 16px;
}

.hero-meta {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  font-size: 12.5px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  line-height: 1.6;
}

.chip.ghost {
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

/* ---------- 主体两栏 ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 56px;
  padding: 42px 0 72px;
}

.section-label {
  font-size: 12.5px;
  letter-spacing: 2px;
  color: var(--faint);
  text-transform: uppercase;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- 文章列表 ---------- */
.post-list { display: flex; flex-direction: column; gap: 2px; }

.post-item {
  position: relative;
  display: block;
  padding: 22px 20px 22px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.post-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 26px;
  bottom: 26px;
  width: 2px;
  border-radius: 2px;
  background: transparent;
  transition: background 0.18s ease;
}

.post-item:hover {
  background: var(--card);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.post-item:hover::before { background: var(--accent); }

.post-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--faint);
  margin-bottom: 7px;
  font-variant-numeric: tabular-nums;
}

.post-meta .tag {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 12px;
}

.post-item h2 {
  margin: 0 0 6px;
  font-size: 19.5px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.2px;
}

.post-item p {
  margin: 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.75;
}

.post-item.draft { cursor: default; }
.post-item.draft:hover { background: transparent; border-color: transparent; box-shadow: none; }
.post-item.draft:hover::before { background: transparent; }
.post-item.draft h2 { color: var(--faint); font-weight: 500; }

/* ---------- 侧栏 ---------- */
.side { display: flex; flex-direction: column; gap: 30px; padding-top: 6px; }

.side-box h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: var(--faint);
}

.side-box p { margin: 0 0 10px; font-size: 13.5px; color: var(--muted); line-height: 1.8; }
.side-box p:last-child { margin-bottom: 0; }

.cat-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.cat-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  color: var(--ink-2);
}
.cat-list li:last-child { border-bottom: 0; }
.cat-list span { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.note-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.85;
}

/* ---------- 文章页 ---------- */
.article-head {
  padding: 54px 0 26px;
  border-bottom: 1px solid var(--line-soft);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--next-line);
  border-radius: 999px;
  padding: 7px 16px;
  margin-bottom: 18px;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.back-link:hover {
  background: var(--next-line);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.article-head h1 {
  margin: 0 0 14px;
  font-size: 30px;
  line-height: 1.45;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.article-head .lede {
  margin: 0 0 18px;
  color: var(--ink-2);
  font-size: 15.5px;
  max-width: 720px;
}

.article-body {
  max-width: 720px;
  padding: 38px 0 60px;
  font-size: 16px;
  line-height: 1.95;
  color: var(--body-ink);
}

.article-body h2 {
  margin: 40px 0 14px;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.3px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.article-body h3 { margin: 28px 0 10px; font-size: 17px; font-weight: 600; }

.article-body p { margin: 0 0 16px; }

.article-body ul, .article-body ol { margin: 0 0 16px; padding-left: 22px; }
.article-body li { margin-bottom: 7px; }

.article-body strong { font-weight: 600; }

.article-body code {
  font-family: "JetBrains Mono", "Cascadia Code", ui-monospace, Consolas, Menlo, monospace;
  font-size: 13.5px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--code-ink);
}

.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  line-height: 1.7;
}

.article-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--code-plain);
  font-size: 13px;
}

.callout {
  background: var(--callout-bg);
  border: 1px solid var(--callout-line);
  border-left: 3px solid var(--callout-bar);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 0 0 20px;
  font-size: 14.5px;
  color: var(--callout-text);
  line-height: 1.85;
}

.callout strong { color: var(--callout-strong); }

.article-end {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--faint);
  line-height: 1.9;
}

.next-links { margin-top: 26px; display: flex; flex-direction: column; gap: 10px; }
.next-links a {
  font-size: 14px;
  color: var(--accent-ink);
  border-bottom: 1px solid var(--next-line);
  align-self: flex-start;
}
.next-links a:hover { border-bottom-color: var(--accent); }
.next-links .next-post.none { font-size: 14px; color: var(--faint); align-self: flex-start; }

/* ---------- 关于页 ---------- */
.page-body { max-width: 720px; padding: 40px 0 70px; }
.page-body h2 {
  margin: 36px 0 12px;
  font-size: 19px;
  font-weight: 600;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}
.page-body h2:first-child { margin-top: 0; }
.page-body p { margin: 0 0 14px; color: var(--ink-2); }
.page-body ul { margin: 0 0 14px; padding-left: 22px; color: var(--ink-2); }
.page-body li { margin-bottom: 6px; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--footer-bg);
  padding: 30px 0 34px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9;
}

.footer-inner {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: flex-start;
  justify-content: space-between;
}

.footer-inner p { margin: 0; }

.icp-link { color: var(--muted); }
.icp-link:hover { color: var(--accent-ink); }

.footer-note { color: var(--faint); font-size: 12.5px; }

/* ---------- 实用工具列表 ---------- */
.tool-list { list-style: none; }
.tool-list li { padding: 7px 0; border-bottom: 1px dashed var(--line-soft); }
.tool-list li:last-child { border-bottom: none; }
.tool-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--ink, inherit); font-size: 14px; }
.tool-list a span { color: var(--faint); font-size: 12px; }
.tool-list a:hover { color: var(--accent-ink); }
.tool-note { margin-top: 8px; font-size: 12px; color: var(--faint); }

.police-link { display: inline-flex; align-items: center; gap: 5px; }
.police-icon { width: 14px; height: 14px; display: block; flex: none; }

/* ---------- 返回顶部（全站固定右下角） ---------- */
.back-top {
  position: fixed;
  right: 18px;
  bottom: 24px;
  z-index: 90;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .2s, visibility .2s, transform .2s, color .2s, border-color .2s;
}
.back-top.show { opacity: 1; visibility: visible; transform: none; }
.back-top:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .side { padding-top: 0; border-top: 1px solid var(--line-soft); }
  .hero { padding: 40px 0 30px; }
  .hero h1 { font-size: 27px; }
  .article-head h1 { font-size: 24px; }
  .article-head { padding: 36px 0 22px; }
  .brand .name { display: none; }
  .brand .name-short { display: inline; }
  .site-nav { gap: 16px; }
  /* 右侧给主题按钮留 56px 即可，不再吃掉 72px */
  .header-inner { padding: 0 56px 0 16px; }
}

/* ---------- 移动端（≤640px） ---------- */
@media (max-width: 640px) {
  .header-inner { height: 54px; gap: 10px; }
  .brand .mark { width: 20px; height: 20px; transform: translateY(2px); }
  .brand .name-short { font-size: 14.5px; }
  .site-nav { gap: 14px; font-size: 13.5px; }
  /* 下拉菜单靠右展开，防止小屏上伸出屏幕右缘 */
  .nav-menu { left: auto; right: 0; transform: none; }
  .wrap { padding: 0 16px; }
  .hero { padding: 30px 0 24px; }
  .hero h1 { font-size: 23px; }
  .hero p { font-size: 15px; }
  .hero-meta { margin-top: 16px; }
  .layout { padding: 26px 0 52px; }
  .post-item { padding: 15px 13px 15px 16px; }
  .post-item h2 { font-size: 17px; }
  .post-item p { font-size: 13.5px; }
  .article-head h1 { font-size: 21.5px; }
  .article-head .lede { font-size: 14.5px; }
  .article-body { font-size: 15.5px; padding: 30px 0 48px; }
  .article-body h2 { font-size: 19px; }
  .back-link { margin-bottom: 14px; padding: 6px 13px; font-size: 13px; }
  /* 悬浮按钮在手机上略缩小、贴近边缘 */
  .theme-btn { top: 10px; right: 10px; width: 34px; height: 34px; }
  .theme-menu { top: 50px; right: 10px; }
  .back-top { right: 12px; bottom: 16px; width: 40px; height: 40px; font-size: 16px; }
  .footer-inner { padding: 0 16px; }
}

/* ---------- 文章内表格 ---------- */
.article-body table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; line-height: 1.7; }
.article-body th { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; white-space: nowrap; }
.article-body tr:nth-child(even) td { background: var(--line-soft); }
