@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500;600;700&family=Lato:wght@300;400;700&display=swap');

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

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

body {
  margin: 0;
  padding-left: 112px;
  background: #fff;
  color: #000;
  font-family: 'Lato', 'Helvetica Neue', Helvetica, Arial, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 17px;
  line-height: 1.75;
  overflow-x: hidden;
}

[id] { scroll-margin-top: 24px; }

img { max-width: 100%; }
a { color: #000; }

::selection { background: #000; color: #fff; }

/* ---------- 左侧竖排栏 ---------- */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 0 22px;
  background: #fff;
  border-right: 1px solid #000;
  z-index: 30;
}

.rail-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 58px;
  text-decoration: none;
  color: #000;
  font-family: 'EB Garamond', 'Songti SC', Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .08em;
}
.rail-mark img { display: block; border-radius: 6px; }

.rail nav { margin: auto 0; }
.rail nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rail nav li { animation: railIn .45s ease both; }
.rail nav li:nth-child(1) { animation-delay: .02s; }
.rail nav li:nth-child(2) { animation-delay: .06s; }
.rail nav li:nth-child(3) { animation-delay: .1s; }
.rail nav li:nth-child(4) { animation-delay: .14s; }
.rail nav li:nth-child(5) { animation-delay: .18s; }
.rail nav li:nth-child(6) { animation-delay: .22s; }
.rail nav li:nth-child(7) { animation-delay: .26s; }

@keyframes railIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}

.rail nav a {
  display: block;
  padding: 10px 12px;
  font-size: 15px;
  line-height: 1.4;
  color: #000;
  text-decoration: none;
  border-left: 2px solid transparent;
}
.rail nav a:hover,
.rail nav a:focus-visible {
  border-left-color: #000;
  background: #f4f4f4;
}
.rail nav .num {
  display: block;
  font-size: 11px;
  letter-spacing: .14em;
  color: #8c8c8c;
}

.rail-foot {
  padding: 0 12px;
  border-top: 1px solid #e6e6e6;
  padding-top: 12px;
}
.rail-k {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: .18em;
  color: #8c8c8c;
}
.rail-c {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  text-decoration: none;
  border-bottom: 1px solid #000;
  padding-bottom: 2px;
}

/* ---------- 栅格 ---------- */
.page {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px 24px;
}

.page > div { grid-column: 1 / 10; min-width: 0; }
.page > aside {
  grid-column: 10 / 13;
  grid-row: 1 / span 2;
  align-self: start;
  position: sticky;
  top: 22px;
  min-width: 0;
}

/* ---------- 首屏 ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 20px;
  align-items: center;
  min-height: 70vh;
  padding: 54px 0 46px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  right: -6px;
  bottom: -22px;
  font-family: 'EB Garamond', 'Songti SC', Georgia, serif;
  font-size: clamp(110px, 17vw, 250px);
  line-height: .8;
  letter-spacing: -.03em;
  color: transparent;
  -webkit-text-stroke: 1px #e2e2e2;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 0;
}

.hero-fig {
  grid-column: 1 / 7;
  margin: 0;
  height: clamp(320px, 56vh, 600px);
  border-radius: 10px;
  overflow: hidden;
  background: #f1f1f1;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .12);
  position: relative;
  z-index: 1;
}
.hero-fig img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero-fig .ph {
  display: block;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(135deg, #f4f4f4 0 12px, #eaeaea 12px 24px);
}

.hero-txt {
  grid-column: 7 / 13;
  text-align: right;
  position: relative;
  z-index: 1;
}
.hero-txt h1 {
  margin: 0 0 16px;
  font-family: 'EB Garamond', 'Songti SC', Georgia, serif;
  font-weight: 600;
  font-size: clamp(34px, 4.6vw, 60px);
  line-height: 1.1;
  letter-spacing: -.015em;
}
.hero-txt .lede {
  margin: 0 0 0 auto;
  max-width: 34ch;
  font-size: 16px;
  line-height: 1.8;
  color: #333;
}

/* ---------- 右侧aside ---------- */
.toc {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 58px;
}
.toc-box {
  border: 1px solid #000;
  border-radius: 10px;
  padding: 14px 16px 16px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .07);
}
.toc-box h2 {
  margin: 0 0 10px;
  font-family: 'Lato', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .18em;
}
.toc-box h2 > span {
  display: inline-block;
  padding-bottom: 3px;
  border-bottom: 1px solid #000;
}
.toc-box ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-box li + li { border-top: 1px solid #ebebeb; }
.toc-box a {
  display: block;
  padding: 9px 0;
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
}
.toc-box a:hover { text-decoration: underline; }
.toc-host {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #555;
  word-break: break-all;
}
.toc-link {
  display: inline-block;
  font-size: 15px;
  padding-bottom: 2px;
  border-bottom: 1px solid #000;
  text-decoration: none;
}

/* ---------- 正文区块 ---------- */
.page > div:not(.hero) {
  padding: 42px 0;
  border-top: 1px solid #e6e6e6;
}
.page > div:first-of-type:not(.hero) { border-top: 1px solid #000; }

.page h2 {
  margin: 0 0 18px;
  font-family: 'EB Garamond', 'Songti SC', Georgia, serif;
  font-weight: 600;
  font-size: clamp(24px, 2.8vw, 34px);
  line-height: 1.25;
  letter-spacing: -.01em;
}
.page h2 > span {
  display: inline-block;
  padding-bottom: 5px;
  border-bottom: 2px solid #000;
}
.page h3 {
  margin: 30px 0 12px;
  font-family: 'EB Garamond', 'Songti SC', Georgia, serif;
  font-weight: 600;
  font-size: clamp(19px, 2vw, 23px);
  line-height: 1.35;
}
.page h3 > span {
  display: inline-block;
  padding-bottom: 3px;
  border-bottom: 1px solid #000;
}
.page p {
  margin: 0 0 16px;
  max-width: 68ch;
}
.page ul, .page ol {
  margin: 0 0 18px;
  padding-left: 22px;
  max-width: 68ch;
}
.page li { margin-bottom: 8px; }
.page a {
  text-decoration: none;
  border-bottom: 1px solid #000;
}
.page a:hover { background: #000; color: #fff; }
.page strong { font-weight: 700; }
.page blockquote {
  margin: 24px 0;
  padding: 4px 0 4px 18px;
  border-left: 3px solid #000;
  font-family: 'EB Garamond', 'Songti SC', Georgia, serif;
  font-size: 19px;
  color: #222;
}
.page figure {
  margin: 24px 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .1);
}
.page figure img { display: block; width: 100%; height: auto; }
.page figcaption {
  padding: 10px 14px;
  font-size: 13px;
  color: #555;
  background: #fafafa;
}
.page img { border-radius: 10px; }
.page table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 15px;
}
.page th, .page td {
  border-bottom: 1px solid #ddd;
  padding: 9px 8px;
  text-align: left;
}
.page th { border-bottom: 1px solid #000; font-weight: 700; }
.page code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .92em;
  background: #f2f2f2;
  padding: 1px 5px;
  border-radius: 3px;
}
.page hr {
  border: 0;
  border-top: 1px solid #e6e6e6;
  margin: 30px 0;
}

/* ---------- 页脚 ---------- */
.foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 28px 40px;
  border-top: 1px solid #000;
}
.foot p {
  margin: 0;
  font-size: 14px;
  letter-spacing: .04em;
}
.foot small {
  font-size: 13px;
  color: #666;
  word-break: break-all;
}

/* ---------- 动效 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .6s ease, transform .6s ease;
}
.reveal.in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rail nav li { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 940px) {
  body {
    padding-left: 0;
    font-size: 16px;
  }
  [id] { scroll-margin-top: 78px; }

  .rail {
    position: sticky;
    inset: 0 0 auto 0;
    width: auto;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    border-right: 0;
    border-bottom: 1px solid #000;
  }
  .rail-mark {
    flex: 0 0 auto;
    height: 52px;
    padding: 0 6px;
    font-size: 18px;
  }
  .rail nav {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .rail nav ul {
    display: flex;
    flex-direction: row;
  }
  .rail nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    white-space: nowrap;
    border-left: 0;
    border-bottom: 2px solid transparent;
    font-size: 16px;
  }
  .rail nav a:hover,
  .rail nav a:focus-visible {
    border-left-color: transparent;
    border-bottom-color: #000;
    background: transparent;
  }
  .rail nav .num { display: none; }
  .rail-foot { display: none; }

  .page {
    display: block;
    padding: 0 16px 20px;
  }
  .hero {
    display: block;
    min-height: 0;
    padding: 26px 0 30px;
  }
  .hero-bg {
    font-size: 88px;
    bottom: -10px;
  }
  .hero-fig {
    height: auto;
    aspect-ratio: 16 / 10;
    margin-bottom: 20px;
  }
  .hero-txt { text-align: left; }
  .hero-txt h1 { font-size: clamp(30px, 8vw, 42px); }
  .hero-txt .lede {
    margin: 0;
    max-width: none;
  }

  .toc {
    display: block;
    padding: 22px 0 6px;
    position: static;
  }
  .toc-box { margin-bottom: 14px; }
  .toc-box a { padding: 11px 0; }

  .page > div:not(.hero) { padding: 32px 0; }

  .foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 18px 16px 34px;
  }
}

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