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

:root {
  --ink: #000000;
  --paper: #ffffff;
  --line: #e2e2e2;
  --soft: #8d8d8d;
  --mute: #3c3c3c;
  --gut: clamp(1.1rem, 3vw, 2.6rem);
  --radius: 28px;
  --rail: 196px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Lato', -apple-system, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 17px;
  line-height: 1.75;
  font-weight: 400;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--ink); }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

section { scroll-margin-top: 84px; }

small {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  color: var(--soft);
  margin-bottom: 0.5rem;
  font-weight: 400;
}

/* 左侧固定竖排导航 */
.rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail);
  padding: 1.6rem 1.25rem 2rem;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2.2rem;
  overflow-y: auto;
  z-index: 30;
}

.rail-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--ink);
  text-decoration: none;
  color: var(--ink);
  background: var(--paper);
  transition: background 0.22s ease, color 0.22s ease;
}

.rail-mark:hover { background: var(--ink); color: var(--paper); }
.rail-mark img { width: 34px; height: 34px; }
.mark-txt {
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
}

.rail-nav ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: navn;
}

.rail-nav li { counter-increment: navn; }

.rail-nav li:nth-child(2) {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.rail-nav a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.6rem 0;
  min-height: 40px;
  font-size: 16px;
  line-height: 1.5;
  text-decoration: none;
  color: var(--mute);
  transition: color 0.22s ease;
}

.rail-nav a::before {
  content: counter(navn, decimal-leading-zero);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #a5a5a5;
}

.rail-nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

main { margin-left: var(--rail); }

/* 首屏 */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: calc(var(--gut) + 1.4rem) var(--gut) var(--gut);
  background-image: radial-gradient(#d9d9d9 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: 0 0;
  border-bottom: 1px solid var(--line);
}

.hero-inner { max-width: 900px; will-change: transform; }

.hero h1 {
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-weight: 600;
  font-size: clamp(2.2rem, 6vw, 4.6rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0;
  max-width: 18ch;
}

.hero-desc {
  margin: 1.2rem 0 0;
  max-width: 46ch;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--mute);
}

.hero-fig {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}

.hero-fig img { width: 100%; }

/* 正文 + 右侧栏 */
.wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: clamp(2rem, 5vw, 5rem);
  padding: 4.5rem var(--gut) 5.5rem;
  border-top: 1px solid var(--ink);
}

.body { min-width: 0; }

.prose { max-width: 68ch; }

.prose h2,
.prose h3 {
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: 0;
}

.prose h2 {
  font-size: clamp(1.5rem, 2.6vw, 2.05rem);
  margin: 0 0 1rem;
}

.prose h3 {
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  margin: 1.8rem 0 0.7rem;
}

.prose section + section {
  margin-top: 2.8rem;
  padding-top: 2.6rem;
  border-top: 1px solid var(--line);
}

.prose > section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.prose p { margin: 0 0 1.15rem; }

.prose a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose a:hover { background: var(--ink); color: var(--paper); }

.prose ul,
.prose ol { margin: 0 0 1.3rem; padding-left: 1.3rem; }
.prose li { margin-bottom: 0.45rem; }

.prose blockquote {
  margin: 1.7rem 0;
  padding: 0.15rem 0 0.15rem 1.2rem;
  border-left: 2px solid var(--ink);
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-size: 1.1rem;
  color: #1a1a1a;
}

.prose img {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 1.3rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 1.3rem 0;
}

.prose th,
.prose td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.prose th { font-weight: 700; }
.prose code { font-size: 0.95em; }

/* 侧栏 */
.side {
  position: sticky;
  top: 2rem;
  align-self: start;
  padding-left: 1.4rem;
  border-left: 1px solid var(--line);
}

.side h2 {
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.3;
  margin: 0 0 1rem;
}

.side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: siden;
}

.side-list li { counter-increment: siden; }

.side-list a {
  display: block;
  padding: 0.55rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  text-decoration: none;
  color: var(--mute);
  border-bottom: 1px solid var(--line);
  transition: color 0.2s ease, padding-left 0.2s ease;
}

.side-list a::before {
  content: counter(siden, decimal-leading-zero) '\00a0\00a0';
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #a5a5a5;
}

.side-list a:hover { color: var(--ink); padding-left: 0.3rem; }

/* 页脚 */
.foot {
  border-top: 1px solid var(--ink);
  margin-left: var(--rail);
  padding: 3.6rem var(--gut) 1.8rem;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: clamp(2rem, 5vw, 5rem);
}

.foot-name {
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.25;
  margin: 0 0 0.6rem;
}

.foot-desc {
  margin: 0 0 1.7rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--mute);
  max-width: 42ch;
}

.sub label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--soft);
  margin-bottom: 0.5rem;
}

.sub-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.sub input {
  flex: 1 1 160px;
  min-width: 0;
  min-height: 46px;
  padding: 0.7rem 0.9rem;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
}

.sub button {
  min-height: 46px;
  padding: 0.7rem 1.5rem;
  font: inherit;
  font-size: 16px;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease;
}

.sub button:hover { background: var(--paper); color: var(--ink); }

.foot-links h2 {
  font-family: 'EB Garamond', Georgia, 'Songti SC', serif;
  font-weight: 600;
  font-size: 1.08rem;
  margin: 0 0 1rem;
}

.foot-links ul { list-style: none; margin: 0; padding: 0; }

.foot-links a {
  display: block;
  padding: 0.6rem 0;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--mute);
  border-bottom: 1px solid var(--line);
  transition: color 0.22s ease;
}

.foot-links a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.foot-bar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--mute);
}

.foot-bar p { margin: 0; }

.to-top {
  display: inline-block;
  padding: 0.65rem 0;
  min-height: 40px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}

.to-top:hover { background: var(--ink); color: var(--paper); }

/* 动效 */
.js .st {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.js .st.in { opacity: 1; transform: none; }

/* 移动端 */
@media (max-width: 900px) {
  .rail {
    position: sticky;
    top: 0;
    left: auto;
    bottom: auto;
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
    padding: 0.45rem 0.9rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
    z-index: 40;
  }

  .rail-mark { width: 44px; height: 44px; flex: 0 0 auto; }

  .rail-nav {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .rail-nav ol { display: flex; gap: 0; }

  .rail-nav li:nth-child(2) {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--line);
  }

  .rail-nav a {
    padding: 1rem 0.6rem;
    white-space: nowrap;
    font-size: 16px;
    min-height: 44px;
  }

  .rail-nav a::before { font-size: 0.65rem; }

  main { margin-left: 0; }

  .hero { padding-top: 2.2rem; }

  .wrap {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    padding: 2.8rem var(--gut) 3.2rem;
  }

  .side {
    position: static;
    padding-left: 0;
    padding-top: 1.5rem;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .foot {
    margin-left: 0;
    grid-template-columns: 1fr;
    padding: 2.6rem var(--gut) 1.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .st { opacity: 1; transform: none; transition: none; }
  * { transition-duration: 0.01ms !important; }
}

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