@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');

:root {
  --paper: #fdfbf7;
  --paper2: #f5f5f5;
  --ink: #1a1a1a;
  --rule: #e3dfd7;
  --rule2: #c8c3b9;
  --muted: #56524b;
  --rail: 9.5rem;
  --r: 28px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.75rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='2' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { display: block; max-width: 100%; }
p { margin: 0 0 1rem; }

/* 顶部导航（移动优先：粘顶横排） */
.site-head {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--ink);
  border-radius: 10px;
  line-height: 1;
  overflow: hidden;
}
.brand:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.brand-ch { font-size: 1rem; font-weight: 500; }
.brand-img { width: 100%; height: 100%; object-fit: contain; filter: grayscale(1); }

.rail-nav {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.rail-nav::-webkit-scrollbar { display: none; }
.rail-nav p { display: flex; gap: 0.1rem; margin: 0; }
.rail-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.6rem 0.55rem;
  white-space: nowrap;
  font-size: 1rem;
  border-radius: 8px;
}
.rail-nav a:hover { background: var(--paper2); text-decoration: none; }
.rail-nav a[aria-current] { background: var(--ink); color: var(--paper); }

/* 主体 */
main {
  padding: 1rem 1rem 2rem;
  max-width: 68rem;
  position: relative;
  z-index: 1;
}

main > section {
  position: relative;
  margin: 0 0 1.1rem;
  padding: 1.5rem 1.35rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: 0 1px 0 var(--rule), 0 14px 28px -22px rgba(26, 26, 26, 0.55);
  scroll-margin-top: 5rem;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  min-height: 45vh;
  padding: 3rem 1.25rem 1.25rem;
  text-align: right;
}
.hero h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3rem);
  line-height: 1.22;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.hero .badge {
  position: absolute;
  left: 1rem;
  top: 1rem;
  margin: 0;
  padding: 0.28rem 0.85rem;
  border: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
}
.hero .hero-sub {
  margin: 0 0 0 auto;
  max-width: 46ch;
  color: var(--muted);
  font-family: Georgia, 'Songti SC', 'Noto Serif SC', serif;
  font-size: 1.0625rem;
  line-height: 1.85;
}
.hero-fig {
  margin: 0;
  height: 20vh;
  min-height: 118px;
  border: 1px solid var(--rule);
  border-radius: 18px;
  overflow: hidden;
  background: var(--paper2);
}
.hero-fig img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.04); }
.hero-fig .plate {
  display: block;
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(90deg, transparent 0 9px, rgba(26, 26, 26, 0.07) 9px 10px);
}

/* 目录侧栏 */
aside.toc {
  position: relative;
  z-index: 1;
  margin: 0 0 1.1rem;
  padding: 1.1rem 1.15rem;
  background: var(--paper2);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
aside.toc h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  line-height: 1.6;
}
aside.toc ul { list-style: none; margin: 0; padding: 0; }
aside.toc a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0.35rem 0.2rem;
  border-bottom: 1px dashed var(--rule2);
}
aside.toc a:hover { background: #fff; text-decoration: none; }
aside.toc li:last-child a { border-bottom: 0; }
aside.toc .idx {
  flex: 0 0 2rem;
  color: var(--rule2);
  font-size: 1rem;
}

/* 正文版式 */
main > section h2,
main > section h3 {
  margin: 1.7rem 0 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--rule);
  font-size: 1.28rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
}
main > section h2 > span,
main > section h3 > span { display: inline-block; }
main > section h2:first-child,
main > section h3:first-child { margin-top: 0; }

main > section p {
  font-family: Georgia, 'Songti SC', 'Noto Serif SC', serif;
  font-size: 1.0625rem;
  line-height: 1.9;
}
main > div ul,
main > div ol { margin: 0 0 1rem; padding-left: 1.4rem; }
main > div li { margin: 0.35rem 0; }
main > div a { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
main > div a:hover { background: var(--paper2); }
main > div strong { font-weight: 500; border-bottom: 1px solid var(--ink); }
main > div blockquote {
  margin: 1rem 0;
  padding: 0.35rem 0 0.35rem 1rem;
  border-left: 2px solid var(--ink);
  color: var(--muted);
}
main > div blockquote p { margin: 0; }
main > div table { width: 100%; border-collapse: collapse; margin: 0 0 1rem; font-size: 1rem; }
main > div th,
main > div td { border: 1px solid var(--rule); padding: 0.5rem 0.6rem; text-align: left; }
main > div th { background: var(--paper2); font-weight: 500; }
main > div hr { border: 0; border-top: 1px solid var(--rule); margin: 1.5rem 0; }

/* 页脚 */
.site-foot {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
  padding: 1.5rem 1rem 3rem;
  border-top: 1px solid var(--ink);
}
.site-foot p { margin: 0; }
.site-foot .to-top a {
  display: inline-block;
  padding: 0.7rem 1.6rem;
  min-height: 48px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 1.125rem;
  line-height: 1.6;
}
.site-foot .to-top a:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.site-foot small { font-size: 1rem; color: var(--muted); }

/* 进场（Stagger List，瞬时过渡） */
.js main > div { opacity: 0; transform: translateY(10px); }
.js main > div.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.18s linear, transform 0.18s linear;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js main > div { opacity: 1; transform: none; }
  .js main > div.in { transition: none; }
}

/* 桌面：左侧固定竖排 */
@media (min-width: 900px) {
  html { scroll-padding-top: 2rem; }

  body { padding-left: var(--rail); }

  .site-head {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--rail);
    flex-direction: column;
    align-items: stretch;
    gap: 1.6rem;
    padding: 1.1rem 0.85rem 1.4rem;
    border-bottom: 0;
    border-right: 1px solid var(--ink);
  }
  .brand { align-self: flex-start; }
  .rail-nav { flex: 1 1 auto; overflow: visible; }
  .rail-nav p { flex-direction: column; gap: 0.1rem; }
  .rail-nav a { padding: 0.55rem 0.45rem; white-space: normal; line-height: 1.45; }

  main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 15rem;
    column-gap: 2.5rem;
    padding: 2rem 2rem 2.5rem 2.5rem;
  }
  main > div { grid-column: 1; }
  aside.toc {
    grid-column: 2;
    grid-row: 1 / span 60;
    align-self: start;
    position: sticky;
    top: 2rem;
    margin: 0;
  }
  .hero { padding: 3.25rem 1.75rem 1.5rem; }
  .site-foot { padding: 1.75rem 2rem 3.5rem 2.5rem; }
}

@media (min-width: 1200px) {
  main { max-width: 74rem; padding-left: 3.5rem; }
  .site-foot { padding-left: 3.5rem; }
}

button[aria-expanded]{min-width:44px;min-height:44px}
