/* ============================================================
   样式表：阅读优先
   · 浅色 / 深色跟随系统
   · 正文 18px，行高 1.85，最大 44rem
   · 桌面端右侧悬浮目录，移动端隐藏
   ============================================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f6f4;
  --fg: #16181d;
  --fg-soft: #5c626d;
  --fg-faint: #8b919c;
  --line: #e8e5e0;
  --line-strong: #d5d0c8;
  --accent: #1f6b4a;
  --accent-soft: #eaf3ee;
  --code-bg: #f6f4f0;
  --mark: #fff3c4;

  --w-content: 44rem;
  --w-toc: 14rem;
  --pad: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215;
    --bg-soft: #171a1f;
    --fg: #e3e6ea;
    --fg-soft: #a2a9b4;
    --fg-faint: #757c88;
    --line: #262a31;
    --line-strong: #363b44;
    --accent: #79c2a0;
    --accent-soft: #1a2620;
    --code-bg: #191c21;
    --mark: #4a3f10;
  }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 18px;
  line-height: 1.85;
  letter-spacing: .01em;
  font-feature-settings: "kern" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: var(--accent-soft); color: var(--fg); }

/* ---------------------------------------------------------- 页头 */

.site-head {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.6) blur(10px);
}

.site-head-inner {
  max-width: calc(var(--w-content) + var(--w-toc) + 4rem);
  margin: 0 auto;
  padding: .85rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--fg);
  text-decoration: none;
}

.site-title:hover { color: var(--accent); }

.site-nav { display: flex; gap: 1.4rem; }

.site-nav a {
  font-size: .875rem;
  color: var(--fg-soft);
  text-decoration: none;
}

.site-nav a:hover { color: var(--accent); }

/* ---------------------------------------------------------- 通用容器 */

main {
  max-width: calc(var(--w-content) + var(--w-toc) + 4rem);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* ---------------------------------------------------------- 首页 */

.hero {
  max-width: var(--w-content);
  padding: 3.5rem 0 2rem;
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: .005em;
}

.hero-sub {
  margin: .6rem 0 0;
  font-size: .85rem;
  color: var(--fg-faint);
}

.list {
  max-width: var(--w-content);
}

.list-item {
  padding: 2rem 0;
  border-bottom: 1px solid var(--line);
}

.list-item h2 {
  margin: 0 0 .5rem;
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.6;
}

.list-item h2 a {
  color: var(--fg);
  text-decoration: none;
}

.list-item h2 a:hover { color: var(--accent); }

.list-summary {
  margin: 0 0 .7rem;
  color: var(--fg-soft);
  font-size: .95rem;
  line-height: 1.75;
}

.list-meta {
  margin: 0;
  font-size: .8rem;
  color: var(--fg-faint);
  letter-spacing: .02em;
}

.dot { margin: 0 .5rem; opacity: .5; }

.empty { color: var(--fg-faint); padding: 3rem 0; }

/* ---------------------------------------------------------- 文章布局 */

.post-layout {
  display: block;
  padding: 3rem 0 0;
}

.article {
  max-width: var(--w-content);
  min-width: 0;
}

.article-head { margin-bottom: 2.5rem; }

.article-head h1 {
  margin: 0 0 1rem;
  font-size: 1.85rem;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: -.005em;
}

.article-meta {
  margin: 0;
  font-size: .82rem;
  color: var(--fg-faint);
  letter-spacing: .02em;
}

.article-tags {
  margin: .9rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.article-tags span {
  font-size: .75rem;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: .15rem .5rem;
  letter-spacing: .02em;
}

/* ---------------------------------------------------------- 正文排版 */

.article h2 {
  margin: 3.2rem 0 1.1rem;
  font-size: 1.32rem;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: .005em;
  padding-top: .2rem;
}

.article h3 {
  margin: 2.2rem 0 .8rem;
  font-size: 1.08rem;
  font-weight: 650;
  line-height: 1.55;
}

.article h4 {
  margin: 1.8rem 0 .6rem;
  font-size: .98rem;
  font-weight: 650;
}

.article p { margin: 0 0 1.3rem; }

.article a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding-bottom: .5px;
}

.article a:hover { border-bottom-color: var(--accent); }

.article ul,
.article ol {
  margin: 0 0 1.3rem;
  padding-left: 1.4rem;
}

.article li { margin: .45rem 0; }

.article li > ul,
.article li > ol { margin: .45rem 0 .2rem; }

.article li::marker { color: var(--fg-faint); }

.article hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 3rem 0;
}

.article strong { font-weight: 650; }

.article mark {
  background: var(--mark);
  color: inherit;
  padding: .05em .25em;
  border-radius: 3px;
}

/* 引用 */

.article blockquote {
  margin: 0 0 1.4rem;
  padding: .9rem 1.15rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 6px 6px 0;
  color: var(--fg-soft);
  font-size: .95rem;
}

.article blockquote p:last-child { margin-bottom: 0; }

/* 代码 */

.article code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
  font-size: .875em;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .1em .35em;
}

.article pre {
  position: relative;
  margin: 0 0 1.5rem;
  padding: 1.1rem 1.15rem;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.65;
  font-size: .85rem;
  tab-size: 2;
}

.article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}

/* 代码块语言标签 */
.article pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: .5rem;
  right: .7rem;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* 表格 */

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.6rem;
  font-size: .9rem;
  line-height: 1.6;
  display: block;
  overflow-x: auto;
}

.article thead { background: var(--bg-soft); }

.article th,
.article td {
  border: 1px solid var(--line);
  padding: .55rem .75rem;
  text-align: left;
  vertical-align: top;
}

.article th { font-weight: 650; }

.article tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-soft) 45%, transparent); }

/* 图片与图注 */

.article img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.8rem auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* ---------------------------------------------------------- 目录 */

.toc { display: none; }

.toc-title {
  margin: 0 0 .6rem;
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.toc li { margin: 0; }

.toc a {
  display: block;
  padding: .28rem 0 .28rem .8rem;
  font-size: .82rem;
  line-height: 1.5;
  color: var(--fg-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -1px;
}

.toc a:hover { color: var(--accent); border-left-color: var(--accent); }

.toc ul ul a { padding-left: 1.5rem; font-size: .79rem; color: var(--fg-faint); }

.toc-empty { color: var(--fg-faint); font-size: .8rem; }

/* ---------------------------------------------------------- 上一篇/下一篇 */

.article-nav {
  display: grid;
  grid-template-columns: 1fr;
  gap: .8rem;
  margin: 4rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.article-nav a {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color .15s;
}

.article-nav a:hover { border-color: var(--line-strong); }

.nav-label {
  display: block;
  font-size: .72rem;
  letter-spacing: .1em;
  color: var(--fg-faint);
  margin-bottom: .3rem;
}

.nav-title {
  display: block;
  font-size: .95rem;
  color: var(--fg);
  line-height: 1.5;
}

.nav-next { text-align: right; }

/* ---------------------------------------------------------- 页脚 */

.site-foot {
  margin-top: 6rem;
  border-top: 1px solid var(--line);
}

.site-foot-inner {
  max-width: calc(var(--w-content) + var(--w-toc) + 4rem);
  margin: 0 auto;
  padding: 2rem var(--pad) 3.5rem;
  font-size: .8rem;
  color: var(--fg-faint);
}

/* ---------------------------------------------------------- 关于页 */

.about { padding-top: 3rem; }

/* ---------------------------------------------------------- 宽屏：目录悬浮 */

@media (min-width: 1080px) {
  .post-layout {
    display: grid;
    grid-template-columns: minmax(0, var(--w-content)) var(--w-toc);
    column-gap: 4rem;
    align-items: start;
  }

  .toc {
    display: block;
    position: sticky;
    top: 4.5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    padding-top: .5rem;
  }

  .toc::-webkit-scrollbar { width: 4px; }
  .toc::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }
}

/* ---------------------------------------------------------- 移动端 */

@media (max-width: 720px) {
  body { font-size: 17px; line-height: 1.8; }

  :root { --pad: 1.15rem; }

  .site-head-inner { padding: .7rem var(--pad); }

  .site-nav { gap: 1rem; }

  .hero { padding: 2.2rem 0 1.5rem; }

  .hero h1 { font-size: 1.25rem; }

  .post-layout { padding-top: 1.8rem; }

  .article-head h1 { font-size: 1.5rem; line-height: 1.45; }

  .article h2 { margin: 2.4rem 0 .9rem; font-size: 1.18rem; }

  .article h3 { margin: 1.8rem 0 .7rem; font-size: 1.02rem; }

  .article pre { font-size: .78rem; padding: .9rem .95rem; }

  .article table { font-size: .83rem; }

  .article-nav { margin-top: 3rem; }

  .site-foot { margin-top: 4rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

@media print {
  .site-head, .site-foot, .toc, .article-nav { display: none !important; }
  body { font-size: 11.5pt; color: #000; background: #fff; }
  .article { max-width: none; }
  .article pre { border: 1px solid #ccc; }
}
