@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@400;700&family=Patrick+Hand&display=swap');

:root{
  --paper:#fdfbf7;
  --mute:#f5f5f5;
  --ink:#1a1a1a;
  --line:#e0e0e0;
  --soft:rgba(26,26,26,.58);
  --bar:56px;
  --hand:"Patrick Hand","Kalam","Songti SC","STSong",Georgia,serif;
  --read:"Songti SC","STSong","Noto Serif SC",Georgia,"SimSun",serif;
}

*{box-sizing:border-box}

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

body{
  margin:0;
  background:var(--paper);
  color:var(--ink);
  font-family:var(--read);
  font-size:17px;
  line-height:1.8;
  text-underline-offset:.22em;
}

body::before{
  content:"";
  position:fixed;
  inset:0;
  z-index:90;
  pointer-events:none;
  opacity:.05;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

a{color:var(--ink)}
img{max-width:100%}

/* 顶栏 */
.topbar{
  position:sticky;
  top:0;
  z-index:40;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:6px;
  min-height:var(--bar);
  padding:6px 18px;
  background:var(--paper);
  border-bottom:1px solid var(--line);
}

.tb-nav{display:flex;gap:2px;flex-wrap:wrap}
.tb-l{justify-content:flex-start}
.tb-r{justify-content:flex-end}

.tb-nav a{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:44px;
  padding:6px 9px;
  font-size:16px;
  line-height:1.2;
  text-decoration:none;
  border-radius:4px;
  transition:background .1s linear,color .1s linear;
}

.tb-nav a::before{
  content:"";
  width:6px;
  height:6px;
  flex:0 0 auto;
  border:1px solid var(--ink);
  border-radius:50%;
  transition:background .1s linear;
}

.tb-nav a:hover{background:var(--mute)}
.tb-nav a:hover::before{background:var(--ink)}

.brand{
  display:inline-flex;
  align-items:center;
  gap:8px;
  justify-self:center;
  padding:5px 8px;
  min-height:44px;
  text-decoration:none;
  font-family:var(--hand);
  font-size:20px;
  font-weight:700;
  letter-spacing:.03em;
  white-space:nowrap;
}

.brand-name{border-bottom:1px solid transparent}
.brand:hover .brand-name{border-bottom-color:var(--ink)}

.mark{
  display:inline-grid;
  place-items:center;
  width:28px;
  height:28px;
  border:1px solid var(--ink);
  border-radius:4px;
  font-family:var(--hand);
  font-size:16px;
  line-height:1;
}

.logo{width:28px;height:28px;border-radius:4px;display:block}

/* 二级锚点条 */
.anchors{
  position:sticky;
  top:var(--bar);
  z-index:30;
  background:var(--paper);
  border-bottom:1px solid var(--line);
}

.anchors ol{
  display:flex;
  gap:3px;
  max-width:1220px;
  margin:0 auto;
  padding:7px 14px;
  list-style:none;
  overflow-x:auto;
  scrollbar-width:none;
}

.anchors ol::-webkit-scrollbar{display:none}

.anchors a{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:40px;
  padding:6px 11px;
  white-space:nowrap;
  font-size:16px;
  line-height:1.2;
  text-decoration:none;
  background:var(--mute);
  border-radius:4px;
  transition:background .1s linear,color .1s linear;
}

.anchors a i{
  font-style:normal;
  font-family:var(--hand);
  font-size:14px;
  color:var(--soft);
}

.anchors a:hover,.anchors a.on{background:var(--ink);color:var(--paper)}
.anchors a:hover i,.anchors a.on i{color:rgba(253,251,247,.7)}

/* 主体：左索引 + 右正文 */
main{
  display:grid;
  grid-template-columns:208px minmax(0,1fr);
  max-width:1220px;
  margin:0 auto;
  padding:0 18px;
}

.side{
  align-self:start;
  position:sticky;
  top:calc(var(--bar) + 62px);
  padding:34px 20px 40px 0;
  border-right:1px solid var(--line);
}

.side ol{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  gap:1px;
}

.side a{
  display:flex;
  align-items:baseline;
  gap:9px;
  padding:8px 4px;
  font-size:16px;
  line-height:1.45;
  text-decoration:none;
  color:var(--soft);
  border-radius:4px;
  transition:color .1s linear;
}

.side a i{
  font-style:normal;
  font-family:var(--hand);
  font-size:14px;
  color:var(--soft);
}

.side a:hover,.side a.on{color:var(--ink)}
.side a:hover span,.side a.on span{border-bottom:1px solid var(--ink)}

.doc{min-width:0;padding-bottom:20px}

/* 开篇 */
.hero{
  position:relative;
  display:grid;
  grid-template-columns:1fr 1fr;
  align-items:center;
  gap:32px;
  min-height:70vh;
  padding:44px 0 40px 26px;
  border-bottom:1px solid var(--line);
  overflow:hidden;
}

.hero:has(.hero-media:empty){grid-template-columns:1fr}

.wp{
  position:absolute;
  right:-.06em;
  bottom:-.14em;
  margin:0;
  z-index:0;
  font-family:var(--hand);
  font-size:clamp(6rem,20vw,15rem);
  line-height:.92;
  letter-spacing:-.04em;
  color:rgba(26,26,26,.06);
  pointer-events:none;
}

.hero-media{
  position:relative;
  z-index:1;
  background:var(--mute);
  border-radius:4px;
  overflow:hidden;
  aspect-ratio:4 / 5;
}

.hero-media:empty{display:none}

.hero-img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  filter:grayscale(1) contrast(1.06);
}

.hero-txt{
  position:relative;
  z-index:2;
  text-align:right;
}

.hero-txt h1{
  margin:0 0 18px;
  font-family:var(--hand);
  font-weight:700;
  font-size:clamp(2rem,5.6vw,3.5rem);
  line-height:1.18;
  letter-spacing:.01em;
}

.lead{
  margin:0;
  max-width:34ch;
  margin-left:auto;
  font-size:17px;
  line-height:1.75;
  color:var(--soft);
}

/* 正文 */
.prose{padding-top:6px}

.prose div{
  padding:36px 0 30px;
  border-bottom:1px solid var(--line);
  scroll-margin-top:calc(var(--bar) + 70px);
}

.prose div:last-child{border-bottom:0}

.prose h2,.prose h3{
  font-family:var(--hand);
  letter-spacing:.01em;
  line-height:1.25;
}

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

.prose h3{
  font-size:clamp(1.2rem,2.6vw,1.45rem);
  margin:30px 0 0;
}

.prose hr{
  border:0;
  border-top:1px solid var(--line);
  margin:16px 0 24px;
}

.prose h2 + hr,.prose h3 + hr{margin:14px 0 20px}

.prose p{margin:0 0 16px;max-width:68ch}
.prose ul,.prose ol{margin:0 0 18px;padding-left:1.25em;max-width:68ch}
.prose li{margin:0 0 8px}
.prose a{text-decoration:underline}
.prose a:hover{background:var(--mute)}
.prose blockquote{
  margin:22px 0;
  padding:14px 18px;
  background:var(--mute);
  border-radius:4px;
}
.prose blockquote p:last-child{margin:0}
.prose img{border-radius:4px;height:auto;display:block;margin:18px 0}
.prose table{width:100%;border-collapse:collapse;margin:0 0 18px;font-size:16px}
.prose th,.prose td{border-bottom:1px solid var(--line);padding:9px 10px;text-align:left}
.prose code{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:15px;background:var(--mute);padding:1px 5px;border-radius:3px}
.prose figure{margin:18px 0}
.prose figcaption{font-size:16px;color:var(--soft)}

/* 页脚 */
.foot{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:16px 22px;
  max-width:1220px;
  margin:0 auto;
  padding:30px 18px 40px;
  border-top:1px solid var(--line);
}

.foot-brand{
  display:inline-flex;
  align-items:center;
  gap:9px;
  padding:6px 0;
  min-height:44px;
  text-decoration:none;
  font-family:var(--hand);
  font-size:clamp(1.35rem,3vw,1.9rem);
  font-weight:700;
  letter-spacing:.02em;
}

.foot-brand span{border-bottom:1px solid transparent}
.foot-brand:hover span{border-bottom-color:var(--ink)}

.foot-nav dl{
  display:flex;
  flex-wrap:wrap;
  gap:0 4px;
  margin:0;
}

.foot-nav dt,.foot-nav dd{margin:0}

.foot-nav a{
  display:inline-flex;
  align-items:center;
  min-height:44px;
  padding:6px 8px;
  font-size:16px;
  line-height:1.2;
  text-decoration:none;
  border-radius:4px;
  transition:background .1s linear;
}

.foot-nav a:hover{background:var(--mute)}

.foot-copy{
  margin:0;
  font-size:16px;
  color:var(--soft);
}

/* 滚动出现 */
html.js .rv{opacity:0;transform:translateY(10px)}
html.js .rv.in{
  opacity:1;
  transform:none;
  transition:opacity .3s linear,transform .3s linear;
}

/* 窄屏 */
@media (max-width:1000px){
  :root{--bar:52px}
  .topbar{grid-template-columns:auto 1fr;min-height:var(--bar);padding:4px 14px}
  .tb-nav{display:none}
  .brand{justify-self:start;font-size:19px}
  main{grid-template-columns:1fr;padding:0 15px}
  .side{display:none}
  .hero{
    grid-template-columns:1fr;
    gap:22px;
    min-height:0;
    padding:30px 0 34px;
  }
  .hero:has(.hero-media:empty){grid-template-columns:1fr}
  .hero-media{aspect-ratio:16 / 10}
  .hero-txt{text-align:left}
  .lead{margin-left:0;max-width:none}
  .wp{font-size:clamp(5rem,26vw,9rem);right:-.08em;bottom:-.1em}
  .prose div{padding:30px 0 26px;scroll-margin-top:calc(var(--bar) + 62px)}
  .foot{flex-direction:column;align-items:center;text-align:center;padding:28px 15px 38px}
  .foot-nav dl{justify-content:center}
}

@media (max-width:420px){
  body{font-size:16.5px}
  .brand{font-size:18px}
  .anchors ol{padding:6px 11px}
}

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

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