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

:root{
  --ink:#1c1726;
  --ink-2:#241c33;
  --violet:#6514ff;
  --fuchsia:#bf00ff;
  --paper:#f5f1ff;
  --muted:#b6a8cd;
  --line:rgba(245,241,255,.15);
  --max:1180px;
}

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

html{
  background:var(--ink);
  scroll-behavior:smooth;
  overflow-x:clip;
  -webkit-text-size-adjust:100%;
}

body{
  margin:0;
  max-width:100%;
  color:var(--paper);
  font-family:"IBM Plex Sans",system-ui,-apple-system,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  font-size:17px;
  line-height:1.7;
  overflow-x:clip;
}

body::before{
  content:"";
  position:fixed;
  inset:-25%;
  z-index:-1;
  pointer-events:none;
  opacity:.55;
  background:
    repeating-linear-gradient(118deg, rgba(101,20,255,.20) 0 24px, rgba(101,20,255,0) 24px 96px),
    repeating-linear-gradient(28deg, rgba(191,0,255,.14) 0 2px, rgba(191,0,255,0) 2px 72px);
  animation:drift 34s linear infinite;
}

@keyframes drift{
  from{transform:translate3d(0,0,0)}
  to{transform:translate3d(-120px,-90px,0)}
}

a{color:inherit}
img,video,iframe,svg{max-width:100%}
img{height:auto}

/* 顶栏 */
.topbar{
  position:sticky;
  top:0;
  z-index:30;
  display:flex;
  flex-wrap:nowrap;
  align-items:center;
  gap:14px;
  justify-content:space-between;
  padding:10px clamp(14px,4vw,34px);
  border-bottom:1px solid var(--line);
  background:rgba(28,23,38,.9);
  backdrop-filter:blur(12px);
}

.brand{
  display:inline-flex;
  align-items:center;
  gap:9px;
  padding:8px 0;
  font-size:20px;
  font-weight:700;
  letter-spacing:.02em;
  text-decoration:none;
  white-space:nowrap;
}

.brand-mark{
  flex:none;
  width:14px;
  height:14px;
  border-radius:2px;
  background:linear-gradient(135deg,var(--violet),var(--fuchsia));
  transform:rotate(12deg);
}

/* 药丸导航 */
.pillbar{
  flex:1 1 auto;
  min-width:0;
  display:flex;
  justify-content:flex-end;
}

.pill-menu{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  max-width:100%;
}

.pill-menu summary{
  list-style:none;
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:44px;
  padding:11px 18px;
  border:1px solid var(--line);
  border-radius:999px;
  font-size:16px;
  cursor:pointer;
  user-select:none;
  white-space:nowrap;
  transition:background .22s ease,border-color .22s ease,color .22s ease;
}

.pill-menu summary::-webkit-details-marker{display:none}

.pill-menu summary::after{
  content:"";
  flex:none;
  width:9px;
  height:9px;
  border-radius:2px;
  background:linear-gradient(135deg,var(--violet),var(--fuchsia));
}

.pill-menu summary:hover{border-color:var(--fuchsia)}
.pill-menu[open] summary{background:var(--violet);border-color:transparent;color:#fff}

.pill-menu menu{
  list-style:none;
  margin:0;
  padding:2px 0;
  display:flex;
  gap:8px;
  min-width:0;
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-x:contain;
  scrollbar-width:none;
  -ms-overflow-style:none;
}

.pill-menu menu::-webkit-scrollbar{display:none}

.pill-menu:not([open]) > menu{display:none}

.pill-menu a{
  display:inline-block;
  min-height:44px;
  padding:11px 16px;
  border:1px solid var(--line);
  border-radius:999px;
  font-size:16px;
  line-height:20px;
  white-space:nowrap;
  text-decoration:none;
  transition:background .22s ease,color .22s ease,border-color .22s ease,transform .22s ease;
}

.pill-menu a:hover,
.pill-menu a:focus-visible{
  background:var(--fuchsia);
  border-color:transparent;
  color:#fff;
  transform:translateY(-2px);
}

/* 首屏 */
.hero{
  display:grid;
  grid-template-columns:minmax(0,1.05fr) minmax(0,.95fr);
  align-items:stretch;
  min-height:70vh;
  border-bottom:1px solid var(--line);
  overflow:hidden;
  position:relative;
}

.hero-art{
  margin:0;
  position:relative;
  min-width:0;
  min-height:100%;
  background:linear-gradient(140deg,var(--violet),var(--fuchsia) 62%,#3a0f70);
  clip-path:polygon(0 0,100% 0,86% 100%,0 100%);
  display:block;
  overflow:hidden;
}

.hero-art--plain{display:flex;align-items:center;justify-content:center}

.hero-shard{
  width:56%;
  max-width:280px;
  aspect-ratio:1;
  border:2px solid rgba(255,255,255,.55);
  border-radius:6px;
  transform:rotate(18deg);
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.22) 0 10px, rgba(255,255,255,0) 10px 30px);
}

.hero-img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
  filter:contrast(1.06) saturate(1.05);
  mix-blend-mode:luminosity;
}

.hero-copy{
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  padding:clamp(26px,4.5vw,68px) clamp(18px,4vw,56px);
  text-align:right;
  position:relative;
}

.hero-copy::after{
  content:"";
  position:absolute;
  right:clamp(18px,4vw,56px);
  bottom:clamp(26px,4.5vw,54px);
  width:78px;
  height:8px;
  border-radius:2px;
  background:linear-gradient(90deg,var(--violet),var(--fuchsia));
}

.hero h1{
  margin:0;
  max-width:15ch;
  font-size:clamp(34px,5vw,64px);
  line-height:1.08;
  font-weight:700;
  letter-spacing:-.03em;
  overflow-wrap:break-word;
}

/* 阅读区 */
.reader{
  max-width:var(--max);
  margin:0 auto;
  padding:clamp(30px,5vw,68px) clamp(16px,4vw,32px);
  display:grid;
  grid-template-columns:minmax(0,1fr) 292px;
  gap:clamp(26px,4vw,54px);
  align-items:start;
}

.reader > *{min-width:0}

.prose{
  min-width:0;
  overflow-wrap:break-word;
  word-break:break-word;
}

.prose > div{
  position:relative;
  padding:36px clamp(18px,3vw,26px);
  margin:0 0 20px;
  border:1px solid var(--line);
  border-radius:4px;
  background:rgba(36,28,51,.6);
  scroll-margin-top:96px;
}

.prose > div::before{
  content:"";
  position:absolute;
  left:-1px;
  top:-1px;
  width:8px;
  height:58px;
  border-radius:4px 0 4px 0;
  background:linear-gradient(180deg,var(--violet),var(--fuchsia));
}

.prose > div:nth-child(even){background:rgba(101,20,255,.13)}

.prose h2{
  margin:0 0 12px;
  font-size:clamp(24px,3.2vw,32px);
  line-height:1.2;
  font-weight:700;
  letter-spacing:-.02em;
  overflow-wrap:break-word;
}

.prose h2 + p.subtitle,
.prose h2 + p.subhead,
.prose h2 + p.desc,
.prose h2 + p.lead{
  margin-top:-6px;
  color:var(--muted);
}

.prose h3{
  margin:26px 0 8px;
  font-size:20px;
  line-height:1.3;
  letter-spacing:-.01em;
}

.prose p{margin:0 0 14px}
.prose p:last-child{margin-bottom:0}

.prose a{
  color:#dccdff;
  text-decoration:underline;
  text-decoration-color:var(--fuchsia);
  text-underline-offset:3px;
  transition:color .2s ease,background .2s ease;
}

.prose a:hover{color:#fff;background:rgba(191,0,255,.24)}

.prose ul,.prose ol{margin:0 0 16px;padding-left:22px}
.prose li{margin:0 0 8px}
.prose li::marker{color:var(--fuchsia)}

.prose img{
  display:block;
  width:auto;
  max-width:100%;
  height:auto;
  margin:16px 0;
  border:1px solid var(--line);
  border-radius:4px;
}

.prose figure{margin:16px 0;max-width:100%}

.prose blockquote{
  margin:16px 0;
  padding:12px 16px;
  border-left:4px solid var(--violet);
  background:rgba(101,20,255,.14);
  border-radius:0 4px 4px 0;
}

.prose table{
  display:block;
  width:100%;
  max-width:100%;
  overflow-x:auto;
  border-collapse:collapse;
  font-size:16px;
  margin:0 0 16px;
}

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

.prose th{background:rgba(191,0,255,.18)}

.prose pre{
  max-width:100%;
  overflow-x:auto;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:4px;
  background:rgba(28,23,38,.7);
}

.prose code{font-size:15px;overflow-wrap:anywhere}

/* 侧栏 */
.rail{
  position:sticky;
  top:92px;
  min-width:0;
  border:1px solid var(--line);
  border-radius:4px;
  background:var(--ink-2);
  padding:20px 18px;
}

.rail-title{
  margin:0 0 6px;
  font-size:19px;
  line-height:1.3;
  letter-spacing:.01em;
}

.rail .subtitle{
  margin:0 0 14px;
  font-size:16px;
  color:var(--muted);
}

.rail-list{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  gap:2px;
}

.rail-list a{
  display:flex;
  align-items:center;
  min-height:42px;
  padding:9px 4px;
  border-bottom:1px dashed var(--line);
  font-size:16px;
  text-decoration:none;
  transition:color .2s ease,padding-left .2s ease;
}

.rail-list a:hover{color:#fff;padding-left:10px}
.rail-list li:last-child a{border-bottom:0}

/* 页脚 */
.foot{
  margin-top:26px;
  border-top:1px solid var(--line);
  background:linear-gradient(165deg,rgba(101,20,255,.24),rgba(28,23,38,0) 70%);
}

.foot-cta{
  max-width:var(--max);
  margin:0 auto;
  padding:clamp(30px,5.5vw,60px) clamp(16px,4vw,32px);
  border-bottom:1px solid var(--line);
}

.foot-cta a{
  display:inline-flex;
  align-items:center;
  gap:16px;
  min-height:48px;
  font-size:clamp(26px,4.4vw,46px);
  font-weight:700;
  letter-spacing:-.03em;
  text-decoration:none;
  transition:color .2s ease;
}

.foot-cta a::after{
  content:"↑";
  flex:none;
  display:inline-grid;
  place-items:center;
  width:44px;
  height:44px;
  border:1px solid var(--line);
  border-radius:4px;
  font-size:22px;
  transition:background .22s ease,transform .22s ease;
}

.foot-cta a:hover{color:#fff}
.foot-cta a:hover::after{background:var(--fuchsia);transform:translateY(-3px)}

.foot-bar{
  max-width:var(--max);
  margin:0 auto;
  padding:16px clamp(16px,4vw,32px) 22px;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  gap:10px 18px;
  align-items:center;
  font-size:16px;
}

.foot-brand{
  justify-self:start;
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:9px 0;
  font-weight:700;
  text-decoration:none;
}

.foot-copy{
  margin:0;
  text-align:center;
  color:var(--muted);
}

.foot-nav{justify-self:end;min-width:0}

.foot-nav menu{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-wrap:wrap;
  gap:0 8px;
  justify-content:flex-end;
}

.foot-nav a{
  display:inline-block;
  min-height:40px;
  padding:9px 2px;
  font-size:16px;
  color:var(--muted);
  text-decoration:none;
  transition:color .2s ease;
}

.foot-nav a:hover{color:#fff}

/* 进场动画 */
.js .prose > div{
  opacity:0;
  transform:translateY(18px);
  transition:opacity .42s ease,transform .42s cubic-bezier(.2,.7,.2,1);
}

.js .prose > div.is-in{opacity:1;transform:none}

/* 窄屏：导航改为浮层面板，杜绝横向溢出 */
@media (max-width:960px){
  .pill-menu{
    position:relative;
    align-items:center;
  }

  .pill-menu[open] > menu{
    display:grid;
    gap:4px;
    position:absolute;
    top:calc(100% + 8px);
    right:0;
    width:max-content;
    min-width:184px;
    max-width:calc(100vw - 24px);
    max-height:64vh;
    overflow-y:auto;
    overflow-x:hidden;
    padding:8px;
    border:1px solid var(--line);
    border-radius:8px;
    background:#241c33;
    box-shadow:0 18px 40px rgba(10,6,18,.55);
    z-index:40;
  }

  .pill-menu[open] > menu > li > a{
    display:flex;
    align-items:center;
    min-height:44px;
    padding:10px 14px;
    border:0;
    border-radius:4px;
    font-size:16px;
    white-space:normal;
  }

  .pill-menu[open] > menu > li > a:hover,
  .pill-menu[open] > menu > li > a:focus-visible{
    background:rgba(191,0,255,.28);
    transform:none;
  }
}

/* 响应式 */
@media (max-width:900px){
  .reader{grid-template-columns:minmax(0,1fr)}
  .rail{position:static;order:2}
  .foot-bar{grid-template-columns:minmax(0,1fr);justify-items:center;text-align:center}
  .foot-brand,.foot-nav{justify-self:center}
  .foot-nav menu{justify-content:center}
}

@media (max-width:760px){
  .topbar{padding:9px 14px;gap:10px}
  .brand{font-size:18px}
  .hero{grid-template-columns:minmax(0,1fr);min-height:0}
  .hero-art{min-height:36vh;clip-path:polygon(0 0,100% 0,100% 84%,0 100%)}
  .hero-copy{padding:26px 18px 34px;justify-content:flex-start;text-align:right}
  .hero-copy::after{display:none}
  .hero h1{max-width:100%}
  .prose > div{padding:28px 16px}
  .prose > div::before{height:44px}
  .foot-cta a{font-size:clamp(24px,7vw,32px);gap:12px}
}

@media (prefers-reduced-motion:reduce){
  html{scroll-behavior:auto}
  body::before{animation:none}
  *,*::before,*::after{transition-duration:.01ms !important;animation-duration:.01ms !important}
  .js .prose > div{opacity:1;transform:none}
}

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