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

:root{
  --paper:#fdfbf7;
  --paper2:#f5f5f5;
  --ink:#1a1a1a;
  --rule:#e0e0e0;
  --rule2:#cbc6bb;
  --mute:#6b6660;
  --hand:"Kalam","Patrick Hand","Kaiti SC","STKaiti","KaiTi",serif;
  --read:Georgia,"Songti SC","Noto Serif SC","Times New Roman",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.75;
  text-underline-offset:.18em;
}

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

::selection{background:var(--ink);color:var(--paper)}

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

a{color:inherit}

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

.vh{
  position:absolute;
  width:1px;
  height:1px;
  overflow:hidden;
  clip:rect(0 0 0 0);
  clip-path:inset(50%);
  white-space:nowrap;
}

/* 顶栏 */
.topbar{
  position:sticky;
  top:0;
  z-index:30;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:10px;
  padding:9px clamp(12px,3vw,30px);
  background:rgba(253,251,247,.96);
  border-bottom:1px solid var(--rule);
}

.nav-left{justify-self:end}

.nav p{
  margin:0;
  display:flex;
  flex-wrap:wrap;
  gap:2px;
}

.nav-left p{justify-content:flex-end}

.nav a{
  display:inline-flex;
  align-items:center;
  min-height:40px;
  padding:9px 9px;
  font-size:16px;
  line-height:1.35;
  text-decoration:none;
  border-bottom:1px solid transparent;
}

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

.brand{
  justify-self:center;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:40px;
  padding:6px 10px;
  font-family:var(--hand);
  font-size:1.22rem;
  letter-spacing:.1em;
  text-decoration:none;
  white-space:nowrap;
}

.brand .mark{
  width:32px;
  height:32px;
  display:block;
  border:1px solid var(--ink);
  border-radius:4px;
  object-fit:cover;
}

.right{
  justify-self:stretch;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.search{
  display:flex;
  align-items:center;
  border:1px solid var(--rule2);
  border-radius:4px;
  overflow:hidden;
}

.search input{
  width:130px;
  min-height:40px;
  padding:8px 10px;
  border:0;
  background:transparent;
  font:inherit;
  font-size:16px;
  color:inherit;
}

.search button{
  min-height:40px;
  padding:8px 12px;
  border:0;
  border-left:1px solid var(--rule2);
  background:transparent;
  font:inherit;
  font-size:16px;
  color:inherit;
  cursor:pointer;
}

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

.menu-btn{
  min-height:40px;
  padding:8px 14px;
  border:1px solid var(--ink);
  border-radius:4px;
  background:transparent;
  font:inherit;
  font-size:16px;
  color:inherit;
  cursor:pointer;
}

.menu-btn:hover{
  background:var(--ink);
  color:var(--paper);
}

/* 全屏菜单 */
.drawer{
  position:fixed;
  inset:0;
  z-index:60;
  overflow:auto;
  padding:clamp(18px,5vw,56px);
  background:var(--ink);
  color:var(--paper);
}

.drawer[hidden]{display:none}

.drawer-in{
  display:grid;
  gap:24px;
  max-width:720px;
  margin:0 auto;
}

.drawer-close{
  justify-self:start;
  min-height:44px;
  padding:10px 16px;
  border:1px solid #4d4d4d;
  border-radius:4px;
  background:transparent;
  color:var(--paper);
  font:inherit;
  font-size:16px;
  cursor:pointer;
}

.drawer-close:hover{background:var(--paper);color:var(--ink)}

.drawer-nav p{
  margin:0;
  display:grid;
  gap:2px;
}

.drawer-nav a{
  display:block;
  min-height:46px;
  padding:10px 0;
  border-bottom:1px solid #3a3a3a;
  color:var(--paper);
  text-decoration:none;
  font-family:var(--hand);
  font-size:clamp(1.3rem,4.6vw,1.9rem);
}

.drawer-nav a:hover{color:#c8c3b8;padding-left:6px}

.search-wide{
  max-width:430px;
  border-color:#4d4d4d;
}

.search-wide input{
  flex:1;
  width:auto;
  min-height:44px;
  color:var(--paper);
}

.search-wide button{
  min-height:44px;
  color:var(--paper);
  background:transparent;
  border-left:1px solid #4d4d4d;
}

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

/* 首屏 */
.hero{
  position:relative;
  overflow:hidden;
  min-height:100vh;
  min-height:100svh;
  display:flex;
  align-items:flex-end;
  justify-content:flex-end;
  padding:calc(56px + 8vh) clamp(16px,5vw,60px) clamp(36px,9vh,80px);
  border-bottom:1px solid var(--ink);
}

.hero-num{
  position:absolute;
  left:clamp(-14px,-1vw,0px);
  top:50%;
  transform:translateY(calc(-50% - var(--py,0px)));
  font-family:var(--hand);
  font-size:min(46vw,400px);
  line-height:.8;
  letter-spacing:-.04em;
  color:var(--ink);
  opacity:.07;
  pointer-events:none;
  user-select:none;
}

.hero h1{
  margin:0;
  max-width:20ch;
  font-family:var(--hand);
  font-weight:700;
  font-size:clamp(2.1rem,8vw,5.4rem);
  line-height:1.12;
  letter-spacing:.01em;
  text-align:right;
  overflow-wrap:anywhere;
}

/* 主体分栏：aside 在左 */
.wrap{
  display:grid;
  grid-template-columns:216px minmax(0,1fr);
  gap:clamp(20px,4vw,54px);
  max-width:1120px;
  margin:0 auto;
  padding:clamp(28px,5vw,58px) clamp(16px,4vw,30px);
}

.side{
  position:sticky;
  top:86px;
  align-self:start;
  max-height:calc(100vh - 110px);
  overflow:auto;
  padding-right:16px;
  border-right:1px solid var(--rule2);
}

.side h2{
  margin:0 0 2px;
  font-family:var(--hand);
  font-size:1.12rem;
  letter-spacing:.12em;
}

.subtitle{
  margin:0 0 14px;
  font-size:16px;
  letter-spacing:.14em;
  color:var(--mute);
}

.side-links{display:grid;gap:1px}

.side-links a{
  display:block;
  min-height:40px;
  padding:8px 0;
  font-size:16px;
  line-height:1.5;
  text-decoration:none;
  border-bottom:1px dotted var(--rule2);
}

.side-links a:hover{
  transform:translateX(4px);
  background:var(--ink);
  color:var(--paper);
  padding-left:6px;
}

.side-desc{
  margin:16px 0 0;
  font-size:16px;
  line-height:1.7;
  color:var(--mute);
}

/* 正文 */
.content{min-width:0}

.prose{
  counter-reset:sec;
  max-width:70ch;
}

.prose > section{
  padding:clamp(26px,4.6vw,52px) 0;
  border-top:1px solid var(--rule2);
  scroll-margin-top:96px;
}

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

.prose > section::before{
  counter-increment:sec;
  content:counter(sec,decimal-leading-zero);
  display:block;
  margin-bottom:.32em;
  font-family:var(--hand);
  font-size:2.3rem;
  line-height:1;
  letter-spacing:.06em;
  color:#cec8bc;
}

.prose h2{
  margin:0 0 .5em;
  font-family:var(--hand);
  font-size:clamp(1.45rem,3.4vw,2rem);
  line-height:1.3;
}

.prose h3{
  margin:1.7em 0 .4em;
  font-family:var(--hand);
  font-size:1.2rem;
  line-height:1.4;
}

.prose p{margin:0 0 1.1em}

.prose p.subtitle,
.prose .subtitle{margin-top:-.2em}

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

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

.prose ul,
.prose ol{
  margin:0 0 1.2em;
  padding-left:1.3em;
}

.prose li{margin:.35em 0}

.prose blockquote{
  margin:1.4em 0;
  padding:4px 0 4px 18px;
  border-left:2px solid var(--ink);
  font-family:var(--hand);
  font-size:1.08rem;
}

.prose blockquote p:last-child{margin:0}

.prose figure{margin:1.4em 0}

.prose img{
  border:1px solid var(--rule);
  border-radius:4px;
}

.prose figcaption{
  margin-top:.5em;
  font-size:16px;
  color:var(--mute);
}

.prose hr{
  margin:2.2em 0;
  border:0;
  border-top:1px solid var(--rule2);
}

.prose table{
  width:100%;
  margin:0 0 1.3em;
  border-collapse:collapse;
  font-size:16px;
}

.prose th,
.prose td{
  padding:8px 10px;
  border:1px solid var(--rule2);
  text-align:left;
  vertical-align:top;
}

.prose th{font-family:var(--hand);letter-spacing:.06em}

.prose pre{
  margin:0 0 1.3em;
  padding:14px;
  overflow:auto;
  border:1px solid var(--rule2);
  border-radius:4px;
  background:var(--paper2);
  font-size:16px;
  line-height:1.6;
}

.prose code{font-size:.95em}

.prose > section > article{
  border:1px solid var(--rule);
  border-radius:4px;
  padding:14px 16px;
}

.prose > section > article > p:last-child{margin-bottom:0}

/* 页脚：仅 p + small */
.foot{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
  max-width:1120px;
  margin:44px auto 0;
  padding:clamp(22px,4vw,42px) clamp(16px,4vw,30px) 40px;
  border-top:1px solid var(--ink);
}

.foot p{
  margin:0;
  font-size:16px;
  line-height:1.8;
}

.foot .f-brand{
  font-family:var(--hand);
  font-size:1.1rem;
  letter-spacing:.1em;
}

.foot small{
  grid-column:1 / -1;
  margin-top:12px;
  padding-top:14px;
  border-top:1px solid var(--rule);
  font-size:16px;
  letter-spacing:.08em;
  text-align:center;
  color:var(--mute);
}

.totop{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:40;
  min-height:44px;
  padding:10px 14px;
  border:1px solid var(--ink);
  border-radius:4px;
  background:var(--paper);
  color:var(--ink);
  font:inherit;
  font-size:16px;
  cursor:pointer;
}

.totop[hidden]{display:none}

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

@media (max-width:900px){
  .nav{display:none}
  .search:not(.search-wide){display:none}
  .right{justify-self:end;justify-content:flex-end}
}

@media (max-width:820px){
  body{font-size:17px}
  .topbar{padding:8px 12px}
  .hero{min-height:92svh;padding:78px 16px 40px}
  .hero h1{font-size:clamp(1.95rem,10.5vw,3.1rem);max-width:100%}
  .wrap{
    grid-template-columns:minmax(0,1fr);
    gap:22px;
    padding:22px 16px 32px;
  }
  .side{
    position:static;
    max-height:none;
    padding:0 0 14px;
    border-right:0;
    border-bottom:1px solid var(--rule2);
  }
  .side-links{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:0 14px;
  }
  .side-links a:hover{transform:none}
  .prose > section{padding:26px 0}
  .foot{grid-template-columns:1fr 1fr;padding-left:16px;padding-right:16px}
  .prose table{font-size:16px}
}

@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  *{transition:none !important;animation:none !important}
  .side-links a:hover{transform:none}
}

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