@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');

:root{
  --cream:#f5e6c8;
  --cream-2:#fbf3e3;
  --paper:#fdf8ec;
  --tan:#d4a574;
  --ink:#262117;
  --ink-2:#4c4234;
  --line:rgba(38,33,23,.24);
  --mono:'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

html{
  scroll-behavior:smooth;
  scroll-padding-top:86px;
  -webkit-text-size-adjust:100%;
}

body{
  margin:0;
  font-family:var(--mono);
  font-size:17px;
  line-height:1.7;
  letter-spacing:.01em;
  color:var(--ink);
  background:
    radial-gradient(120% 80% at 50% -12%, #fdf7ea 0%, var(--cream) 46%, #efdcb8 100%);
  background-attachment:fixed;
  overflow-x:hidden;
}

a{color:var(--ink);text-decoration:underline;text-decoration-color:var(--tan);text-underline-offset:3px}
a:hover{text-decoration-color:var(--ink)}
img{max-width:100%}
:focus-visible{outline:2px dashed var(--ink);outline-offset:3px}

.off{display:none}

/* —— 胶片颗粒与漏光 —— */
.grain{
  position:fixed;
  inset:0;
  z-index:9;
  pointer-events:none;
  opacity:.30;
  mix-blend-mode:multiply;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='150' height='150' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  animation:grainShift 9s steps(6) infinite;
}

.leak{
  position:fixed;
  inset:0;
  z-index:8;
  pointer-events:none;
  opacity:.55;
  background:
    radial-gradient(36% 42% at 6% 10%, rgba(212,165,116,.6), transparent 72%),
    radial-gradient(30% 38% at 96% 82%, rgba(253,248,236,.65), transparent 70%);
  animation:leakPulse 15s ease-in-out infinite alternate;
}

/* —— 顶栏 —— */
.bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 16px;
  border-bottom:1px dashed var(--line);
}

.mark{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:46px;
  height:46px;
  border:1px solid var(--ink);
  border-radius:12px;
  background:var(--tan);
  box-shadow:3px 3px 0 rgba(38,33,23,.34);
  text-decoration:none;
  overflow:hidden;
  flex:0 0 auto;
}
.mark:hover{transform:translateY(-1px)}
.mark img{width:100%;height:100%;object-fit:cover}
.mark-t{font-size:21px;line-height:1;letter-spacing:0}

.find{margin-left:auto}
.find-in{
  height:44px;
  width:158px;
  max-width:48vw;
  padding:0 16px;
  font:inherit;
  font-size:16px;
  color:var(--ink);
  background:var(--cream-2);
  border:1px solid var(--ink);
  border-radius:999px;
}
.find-in::placeholder{color:var(--ink-2);opacity:.85}

/* —— 粘性锚点条 —— */
.strip{
  position:sticky;
  top:0;
  z-index:30;
  padding:9px 10px;
  background:rgba(245,230,200,.95);
  border-bottom:1px solid var(--ink);
  backdrop-filter:blur(4px);
}
.pills{
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding-bottom:2px;
  scrollbar-width:thin;
}
.pill{
  flex:0 0 auto;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:42px;
  padding:8px 15px;
  border:1px solid var(--ink);
  border-radius:999px;
  background:var(--cream-2);
  text-decoration:none;
  font-size:16px;
  transition:transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.pill-n{font-size:14px;font-style:normal;letter-spacing:.1em;color:var(--ink-2)}
.pill:hover,.pill:focus-visible{
  background:var(--tan);
  transform:translateY(-2px);
  box-shadow:0 3px 0 rgba(38,33,23,.32);
}
.pill.on{background:var(--ink);color:var(--cream);border-color:var(--ink)}
.pill.on .pill-n{color:var(--tan)}

/* —— 首屏 —— */
.hero{
  position:relative;
  overflow:hidden;
  min-height:45vh;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:16px;
  padding:36px 16px 30px;
  text-align:center;
  border-bottom:2px solid var(--ink);
}
.ghost{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:min(30vw,220px);
  font-weight:500;
  line-height:1;
  letter-spacing:.08em;
  white-space:nowrap;
  color:rgba(212,165,116,.34);
  filter:blur(.5px);
  user-select:none;
  pointer-events:none;
}
.h1{
  position:relative;
  margin:0;
  max-width:20ch;
  font-size:clamp(27px,6.6vw,44px);
  line-height:1.28;
  text-shadow:2px 2px 0 rgba(253,248,236,.92);
  animation:track 7.5s steps(30) infinite;
}
.polaroid{
  position:relative;
  margin:6px 0 0;
  padding:9px 9px 26px;
  background:var(--paper);
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:0 9px 22px rgba(38,33,23,.26);
  transform:rotate(-1.4deg);
  animation:shake 6.5s ease-in-out infinite;
}
.polaroid .shot{
  display:block;
  width:100%;
  max-width:330px;
  height:auto;
  border-radius:4px;
  filter:sepia(.3) contrast(1.05) saturate(.82);
}

/* —— 版心 —— */
main{padding:26px 16px 44px}
.wrap{
  max-width:1080px;
  margin:0 auto;
  display:grid;
  grid-template-columns:224px minmax(0,1fr);
  gap:26px;
  align-items:start;
}

.side{
  position:sticky;
  top:70px;
  padding:14px 12px 16px;
  border:1px solid var(--ink);
  border-bottom:4px solid var(--tan);
  border-radius:10px;
  background:rgba(251,243,227,.8);
}
.side-h{
  margin:0 0 10px;
  font-size:16px;
  font-weight:500;
  letter-spacing:.22em;
}
.side-h span{display:inline-block;padding-bottom:2px;border-bottom:2px solid var(--ink)}
.toc{list-style:none;margin:0;padding:0;display:grid;gap:2px}
.toc li{animation:fade .45s ease both}
.toc li:nth-child(1){animation-delay:.03s}
.toc li:nth-child(2){animation-delay:.08s}
.toc li:nth-child(3){animation-delay:.13s}
.toc li:nth-child(4){animation-delay:.18s}
.toc li:nth-child(5){animation-delay:.23s}
.toc li:nth-child(6){animation-delay:.28s}
.toc li:nth-child(7){animation-delay:.33s}
.toc a{
  display:flex;
  align-items:center;
  min-height:42px;
  padding:8px 6px;
  font-size:16px;
  color:var(--ink-2);
  text-decoration:none;
  border-bottom:1px dashed var(--line);
}
.toc a:hover{color:var(--ink);background:rgba(212,165,116,.3)}

/* —— 正文 —— */
.stage{min-width:0}
.doc{font-size:17px}
.doc article{
  margin:0 0 22px;
  padding:20px 18px 22px;
  background:rgba(253,248,236,.72);
  border:1px solid var(--line);
  border-bottom:3px solid var(--tan);
  border-radius:10px;
  scroll-margin-top:86px;
  animation:fade .5s ease both;
}
.doc article:nth-child(even){border-bottom-color:var(--ink)}
.doc article:target{
  background:var(--paper);
  box-shadow:inset 0 0 0 2px var(--tan);
}
.doc h2,.doc h3{
  margin:0 0 12px;
  line-height:1.4;
  font-weight:500;
}
.doc h2{font-size:23px}
.doc h3{font-size:19px}
.doc h2 > span,.doc h3 > span{
  display:inline-block;
  padding:0 2px 3px;
  border-bottom:3px solid var(--tan);
}
.doc p{margin:0 0 14px;color:var(--ink-2)}
.doc p:last-child{margin-bottom:0}
.doc ul,.doc ol{margin:0 0 14px;padding-left:1.3em;color:var(--ink-2)}
.doc li{margin:0 0 6px}
.doc strong{color:var(--ink)}
.doc blockquote{
  margin:0 0 14px;
  padding:10px 14px;
  border-left:4px solid var(--tan);
  background:rgba(212,165,116,.18);
  border-radius:0 10px 10px 0;
}
.doc blockquote p{margin:0}
.doc img{
  display:block;
  height:auto;
  margin:0 0 14px;
  border-radius:8px;
  filter:sepia(.22) contrast(1.04) saturate(.85);
}

/* —— 页脚 —— */
.foot{
  display:flex;
  flex-wrap:wrap;
  gap:22px;
  align-items:flex-start;
  justify-content:space-between;
  padding:28px 16px 30px;
  border-top:2px solid var(--ink);
  background:linear-gradient(180deg, rgba(212,165,116,.26), rgba(245,230,200,.5));
}
.foot-mark{flex:0 0 auto}
.mark-s{width:44px;height:44px}
.foot-nav{flex:1 1 250px;min-width:190px}
.fdl{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:2px 14px;
  margin:0;
  max-width:360px;
}
.fdl dt,.fdl dd{margin:0}
.fdl a{
  display:flex;
  align-items:center;
  min-height:42px;
  padding:4px 2px;
  font-size:16px;
  text-decoration:none;
  color:var(--ink);
  border-bottom:1px dashed var(--line);
}
.fdl a:hover{color:#7a5a2f;background:rgba(253,248,236,.8)}
.foot-cta{
  flex:1 1 230px;
  padding:14px 16px 16px;
  background:var(--cream-2);
  border:1px solid var(--ink);
  border-bottom:5px solid var(--ink);
  border-radius:10px;
}
.cta-h{margin:0 0 10px;font-size:22px;font-weight:500;letter-spacing:.12em}
.cta-h span{display:inline-block;padding-bottom:2px;border-bottom:2px solid var(--tan)}
.cta-a{
  display:inline-flex;
  align-items:center;
  min-height:44px;
  padding:9px 18px;
  border-radius:999px;
  background:var(--ink);
  color:var(--cream);
  font-size:16px;
  text-decoration:none;
  transition:transform .16s ease, background .16s ease;
}
.cta-a:hover{background:#3a3325;transform:translateY(-2px)}
.copy{
  flex:0 0 100%;
  margin:0;
  padding-top:12px;
  border-top:1px dashed var(--line);
  font-size:16px;
  color:var(--ink-2);
}

/* —— 回到顶部 —— */
.totop{
  position:fixed;
  right:14px;
  bottom:16px;
  z-index:40;
  min-height:44px;
  padding:10px 16px;
  font:inherit;
  font-size:16px;
  color:var(--ink);
  background:var(--cream-2);
  border:1px solid var(--ink);
  border-radius:999px;
  cursor:pointer;
  opacity:0;
  pointer-events:none;
  transition:opacity .25s ease;
}
.totop.show{opacity:1;pointer-events:auto}

/* —— 动效 —— */
@keyframes grainShift{
  0%{transform:translate(0,0)}
  20%{transform:translate(-3%,2%)}
  40%{transform:translate(2%,-3%)}
  60%{transform:translate(-2%,-2%)}
  80%{transform:translate(3%,1%)}
  100%{transform:translate(0,0)}
}
@keyframes leakPulse{
  from{opacity:.36}
  to{opacity:.66}
}
@keyframes track{
  0%,86%,100%{transform:none}
  88%{transform:translateY(-1px) skewX(-.7deg)}
  90%{transform:translateY(1px) skewX(.6deg)}
  92%{transform:none}
}
@keyframes fade{
  from{opacity:0;transform:translateY(7px)}
  to{opacity:1;transform:none}
}
@keyframes shake{
  0%,100%{transform:rotate(-1.4deg)}
  50%{transform:rotate(-.5deg) translateY(-2px)}
}

/* —— 窄屏 —— */
@media (max-width:900px){
  .wrap{grid-template-columns:minmax(0,1fr);gap:20px}
  .side{position:static;top:auto}
  .toc{grid-template-columns:1fr 1fr;gap:2px 10px}
  .doc article{border-radius:10px}
}

@media (max-width:560px){
  body{font-size:17px}
  .hero{padding:26px 14px 24px;min-height:42vh}
  .ghost{font-size:34vw}
  main{padding:20px 14px 36px}
  .find-in{width:126px}
  .fdl{grid-template-columns:1fr}
  .foot{gap:16px}
  .doc article{padding:16px 14px 18px}
  .doc h2{font-size:21px}
}

@media (prefers-reduced-motion: reduce){
  html{scroll-behavior:auto}
  *,*::before,*::after{animation:none !important;transition:none !important}
}

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