@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root{
  --paper:#fafaf8;
  --ink:#1a1a1a;
  --gray:#4a4a4a;
  --line:rgba(26,26,26,.22);
  --soft:rgba(26,26,26,.09);
  --rail:176px;
}

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

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

body{
  margin:0;
  overflow-x:hidden;
  font-family:"Noto Sans SC","PingFang SC","Hiragino Sans GB","Microsoft YaHei",system-ui,sans-serif;
  font-size:17px;
  line-height:1.72;
  color:var(--ink);
  background-color:var(--paper);
  background-image:
    radial-gradient(rgba(26,26,26,.055) 1px, transparent 1px),
    repeating-linear-gradient(0deg, rgba(26,26,26,.02) 0 1px, transparent 1px 4px);
  background-size:24px 24px, auto;
}

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

a{
  color:var(--ink);
  text-decoration:none;
  border-bottom:1px solid var(--line);
}

a:hover{border-bottom-color:var(--ink)}

:focus-visible{
  outline:2px dashed var(--ink);
  outline-offset:3px;
}

/* ---- 左侧固定竖排 ---- */

.rail{
  position:fixed;
  inset:0 auto 0 0;
  width:var(--rail);
  display:flex;
  flex-direction:column;
  gap:14px;
  padding:26px 18px 32px;
  border-right:1px dashed var(--line);
  background:rgba(250,250,248,.94);
  overflow-y:auto;
  z-index:30;
}

.rail-head{
  display:flex;
  flex-direction:column;
  gap:8px;
  transform:rotate(-1.7deg);
}

.mark{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:38px;
  height:38px;
  border:2px solid var(--ink);
  border-radius:14px 18px 12px 16px;
  font-weight:700;
  font-size:18px;
  line-height:1;
  background:#fff;
}

.brand{
  font-weight:700;
  font-size:18px;
  letter-spacing:.05em;
  line-height:1.32;
}

.rail-nav{
  display:flex;
  flex-direction:column;
  margin-top:6px;
}

.rail-link{
  display:block;
  padding:10px 2px;
  font-size:16px;
  color:var(--gray);
  border:0;
  border-bottom:1px dashed transparent;
  transform:rotate(0deg);
}

.rail-link:hover,
.rail-link:focus-visible{
  color:var(--ink);
  border-bottom-color:var(--ink);
  transform:translateX(3px) rotate(-.4deg);
}

.rail-link[aria-current]{
  color:var(--ink);
  font-weight:700;
  border-bottom-color:var(--ink);
}

/* ---- 主栅格：aside 在左 ---- */

main{
  margin-left:var(--rail);
  padding:0 40px 72px;
  display:grid;
  grid-template-columns:196px minmax(0,1fr);
  gap:44px;
  max-width:1200px;
}

div{
  grid-column:2;
  grid-row:1;
  min-width:0;
}

/* ---- 首屏 ---- */

.hero{
  position:relative;
  min-height:45vh;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  align-items:flex-end;
  text-align:right;
  padding:60px 0 22px;
  background-image:radial-gradient(rgba(26,26,26,.17) 1px, transparent 1px);
  background-size:18px 18px;
  background-position:right top;
  background-repeat:repeat;
  border-bottom:2px solid var(--ink);
}

.hero-title{
  margin:0;
  max-width:16ch;
  font-size:clamp(30px,4.6vw,52px);
  line-height:1.16;
  letter-spacing:-.012em;
  font-weight:700;
}

.hero-art{
  position:absolute;
  left:0;
  top:28px;
  width:108px;
  transform:rotate(-4.5deg);
}

.hero-art svg,
.hero-art img{
  display:block;
  width:100%;
  height:auto;
}

.hero-photo{
  filter:grayscale(1) contrast(1.08);
  border:1px solid var(--ink);
  border-radius:6px 15px 8px 17px;
  background:#fff;
  padding:5px;
}

/* ---- 正文 ---- */

.paper{padding-top:34px}

.paper > article{
  padding:28px 0 12px;
  border-top:1px dashed var(--line);
  scroll-margin-top:92px;
}

.paper > article:first-child{
  border-top:0;
  padding-top:0;
}

.paper h2{
  margin:0 0 12px;
  font-size:clamp(21px,2.3vw,27px);
  line-height:1.34;
  display:inline-block;
  background-image:linear-gradient(transparent 72%, rgba(26,26,26,.16) 72%);
  background-repeat:no-repeat;
  padding-bottom:1px;
}

.paper h3{
  margin:24px 0 4px;
  font-size:19px;
  line-height:1.45;
  color:var(--gray);
}

.paper p{
  margin:0 0 13px;
  max-width:62ch;
}

.paper ul,
.paper ol{
  margin:0 0 15px;
  padding-left:1.2em;
}

.paper li{margin:0 0 9px}

.paper li::marker{color:var(--gray)}

.paper blockquote{
  margin:18px 0;
  padding:14px 18px;
  background:#fff;
  border-left:3px solid var(--ink);
  border-radius:0 16px 18px 0;
  transform:rotate(-.35deg);
}

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

.paper img{
  border:1px solid var(--line);
  border-radius:10px 16px 11px 18px;
  filter:grayscale(1) contrast(1.05);
  margin:6px 0 14px;
}

.paper pre{
  margin:0 0 16px;
  padding:14px 16px;
  overflow-x:auto;
  background:#fff;
  border:1px dashed var(--line);
  border-radius:12px 16px 10px 14px;
  font-size:16px;
  line-height:1.6;
}

.paper code{
  font-family:ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace;
  font-size:.94em;
  background:rgba(26,26,26,.06);
  padding:1px 4px;
  border-radius:4px;
}

.paper pre code{background:none;padding:0}

.paper hr{
  border:0;
  border-top:1px dashed var(--line);
  margin:26px 0;
}

.subtitle{
  margin:0 0 16px;
  color:var(--gray);
  font-size:16px;
  line-height:1.6;
}

/* ---- 侧栏 ---- */

.side{
  grid-column:1;
  grid-row:1;
  align-self:start;
  position:sticky;
  top:34px;
  border-top:2px solid var(--ink);
  padding-top:12px;
  transform:rotate(-.5deg);
}

.side-h{
  margin:0 0 4px;
  font-size:17px;
  letter-spacing:.09em;
  line-height:1.4;
}

.side .subtitle{
  font-size:16px;
  margin-bottom:10px;
}

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

.side-list a{
  display:block;
  padding:11px 0;
  font-size:16px;
  color:var(--gray);
  border-bottom:1px dashed var(--line);
}

.side-list a:hover{
  color:var(--ink);
  border-bottom-color:var(--ink);
}

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

.foot{
  margin-left:var(--rail);
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:12px 26px;
  padding:26px 40px 34px;
  border-top:2px solid var(--ink);
  background:#fff;
  font-size:16px;
}

.foot-logo{
  display:inline-flex;
  align-items:center;
  gap:9px;
  border:0;
  font-weight:700;
  padding:6px 0;
}

.foot-logo .mark{
  width:30px;
  height:30px;
  font-size:16px;
  border-width:2px;
  border-radius:11px 14px 9px 13px;
}

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

.foot-nav dt{margin:0}
.foot-nav dd{margin:0;display:none}

.foot-nav a{
  display:inline-block;
  padding:10px 0;
  color:var(--gray);
  border-bottom:1px dashed var(--line);
}

.foot-nav a:hover{
  color:var(--ink);
  border-bottom-color:var(--ink);
}

.foot-copy{
  display:flex;
  align-items:center;
  gap:18px;
  margin-left:auto;
}

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

.to-top{
  display:inline-block;
  padding:11px 16px;
  border:1px solid var(--ink);
  border-radius:15px 19px 13px 17px;
  background:var(--paper);
  transform:rotate(-1.2deg);
}

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

/* ---- 动效 ---- */

.rv{
  opacity:0;
  transform:translateY(10px);
  transition:opacity .3s steps(4,end), transform .3s steps(4,end);
}

.rv.in{
  opacity:1;
  transform:none;
}

/* ---- 窄屏 ---- */

@media (max-width:860px){
  .rail{
    position:sticky;
    inset:auto;
    top:0;
    width:auto;
    height:auto;
    flex-direction:row;
    align-items:center;
    gap:10px;
    padding:8px 14px;
    border-right:0;
    border-bottom:1px dashed var(--line);
    overflow-x:auto;
    overflow-y:hidden;
  }

  .rail-head{
    flex-direction:row;
    align-items:center;
    gap:8px;
    transform:none;
    flex:0 0 auto;
  }

  .mark{
    width:30px;
    height:30px;
    font-size:16px;
    border-radius:11px 14px 9px 13px;
  }

  .brand{font-size:16px;white-space:nowrap}

  .rail-nav{
    flex-direction:row;
    margin:0;
    flex:0 0 auto;
  }

  .rail-link{
    padding:13px 9px;
    white-space:nowrap;
    border-bottom:0;
  }

  .rail-link[aria-current]{border-bottom:0;text-decoration:underline;text-underline-offset:5px}

  main{
    margin-left:0;
    padding:0 18px 48px;
    display:flex;
    flex-direction:column;
    gap:0;
    max-width:none;
  }

  div{order:1}
  .side{order:2;position:static;margin-top:38px}

  .hero{
    min-height:0;
    padding:24px 0 18px;
    justify-content:flex-start;
    align-items:flex-start;
    text-align:left;
    background-position:left top;
  }

  .hero-art{
    position:static;
    width:66px;
    margin-bottom:12px;
    transform:rotate(-5deg);
  }

  .hero-title{
    max-width:100%;
    font-size:clamp(26px,7.4vw,36px);
    line-height:1.22;
  }

  .paper > article{scroll-margin-top:110px}

  .paper p{max-width:none}

  .foot{
    margin-left:0;
    padding:20px 18px 30px;
    gap:10px 18px;
  }

  .foot-copy{margin-left:0}
}

@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  .rv{opacity:1;transform:none;transition:none}
  .rail-link,
  .side,
  .to-top,
  .hero-art{transition:none}
}

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