@import url('https://fonts.googleapis.com/css2?family=Cormorant+Infant:wght@300;400;500;600;700&family=Great+Vibes&display=swap');

:root {
  --red: #ff0000;
  --violet: #8b00ff;
  --ink: #261717;
  --paper: #120a10;
  --text: #f4e9ee;
  --dim: #c8b6c0;
  --faint: #a2919b;
  --line: rgba(255, 255, 255, 0.2);
  --line-soft: rgba(255, 255, 255, 0.1);
  --glass: rgba(255, 255, 255, 0.07);
  --serif: 'Cormorant Infant', 'Songti SC', 'Noto Serif SC', Georgia, serif;
  --script: 'Great Vibes', 'Songti SC', cursive;
  --sans: system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --rail: 254px;
}

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

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

body {
  margin: 0;
  padding-left: var(--rail);
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.78;
  color: var(--text);
  background: var(--paper);
}

body::before {
  content: '';
  position: fixed;
  inset: -22% -12%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(36% 40% at 16% 10%, rgba(255, 0, 0, 0.42), transparent 70%),
    radial-gradient(42% 46% at 84% 24%, rgba(139, 0, 255, 0.42), transparent 72%),
    radial-gradient(58% 58% at 46% 98%, rgba(255, 0, 0, 0.16), transparent 72%);
  filter: blur(22px);
  animation: drift 28s ease-in-out infinite alternate;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(18, 10, 16, 0.5), rgba(18, 10, 16, 0.82));
}

@keyframes drift {
  from {
    transform: translate3d(-2%, -1%, 0) scale(1);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.08);
  }
}

.rail,
.shell,
.foot {
  position: relative;
  z-index: 1;
}

/* ---- 左侧固定胶囊导航 ---- */
.rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 32px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 6;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  font-family: var(--script);
  font-size: 44px;
  line-height: 1;
  background: linear-gradient(118deg, var(--red), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-name {
  font-size: 16px;
  letter-spacing: 0.2em;
  color: var(--dim);
}

.rail-nav p {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
}

.rail-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 16px;
  line-height: 1.4;
  color: var(--dim);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}

.rail-nav a:hover,
.rail-nav a:focus-visible {
  color: #fff;
  border-color: rgba(255, 0, 0, 0.62);
  background: linear-gradient(118deg, rgba(255, 0, 0, 0.3), rgba(139, 0, 255, 0.3));
  outline: none;
}

/* ---- 首屏 ---- */
.shell {
  padding-bottom: 40px;
}

.stage {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 45vh;
  padding: 58px 44px 46px;
}

.stage-ghost {
  position: absolute;
  right: 18px;
  top: -18px;
  font-family: var(--script);
  font-size: clamp(120px, 21vw, 290px);
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, 0.18);
  pointer-events: none;
  user-select: none;
  animation: float 16s ease-in-out infinite alternate;
}

@keyframes float {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(14px);
  }
}

.stage-kicker {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.32em;
  color: #ff9a9a;
}

.stage-title {
  margin: 0;
  max-width: 17ch;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.14;
  letter-spacing: 0.01em;
}

.stage-lede {
  margin: 0;
  max-width: 48ch;
  color: var(--dim);
  font-size: 17px;
}

/* ---- 主体骨架 ---- */
.wrap {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 34px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 44px 72px;
  align-items: start;
}

/* ---- 左侧目录 ---- */
.side {
  position: sticky;
  top: 24px;
  padding: 20px 18px 18px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.side-title {
  margin: 0 0 12px;
  padding-bottom: 10px;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}

.side-title > span {
  background: linear-gradient(118deg, #ffffff, #ffc4c4 45%, #d5b3ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.side-list li {
  counter-increment: toc;
}

.side-list a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 0;
  font-size: 16px;
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
  transition: color 0.2s;
}

.side-list a::before {
  content: counter(toc, decimal-leading-zero);
  margin-right: 10px;
  font-family: var(--serif);
  font-size: 15px;
  color: rgba(255, 255, 255, 0.42);
}

.side-list a:hover,
.side-list a:focus-visible,
.side-list a[aria-current] {
  color: #fff;
}

.side-list a[aria-current]::before {
  color: #ff8a8a;
}

.side-note {
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.6;
  color: var(--faint);
}

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

.prose {
  padding: 32px 34px 42px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.prose > section {
  padding-top: 6px;
}

.prose > section + section {
  margin-top: 36px;
  padding-top: 26px;
  border-top: 1px solid var(--line-soft);
}

.prose section[id] {
  scroll-margin-top: 26px;
}

.prose h2 {
  margin: 1.6em 0 0.6em;
  padding-bottom: 0.36em;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(25px, 2.6vw, 33px);
  line-height: 1.32;
  border-bottom: 1px solid var(--line);
}

.prose h3 {
  margin: 1.5em 0 0.5em;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(20px, 2vw, 25px);
  line-height: 1.4;
  color: #ffdcdc;
}

.prose h2 > span,
.prose h3 > span {
  background: linear-gradient(118deg, #ffffff, #ffc9c9 42%, #d5b3ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.prose h4 {
  margin: 1.3em 0 0.4em;
  font-size: 18px;
  color: #ffdcdc;
}

.prose p {
  margin: 0 0 1.05em;
}

.prose a {
  color: #ff9d9d;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.prose a:hover {
  color: #fff;
}

.prose ul,
.prose ol {
  margin: 0 0 1.1em;
  padding-left: 1.35em;
}

.prose li {
  margin: 0.42em 0;
}

.prose li::marker {
  color: #ff8a8a;
}

.prose strong {
  color: #fff;
  font-weight: 600;
}

.prose blockquote {
  margin: 1.4em 0;
  padding: 4px 0 4px 18px;
  border-left: 2px solid var(--red);
  color: var(--dim);
  background: linear-gradient(90deg, rgba(255, 0, 0, 0.1), transparent 70%);
}

.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
}

.prose figure {
  margin: 1.4em 0;
}

.prose figcaption {
  font-size: 16px;
  color: var(--faint);
  margin-top: 6px;
}

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

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

.prose th {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  padding: 1px 5px;
  border: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.28);
}

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

/* ---- 页脚 ---- */
.foot {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 26px 34px;
  padding: 46px 44px 26px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.foot-head {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 21px;
  letter-spacing: 0.08em;
}

.foot-head > span {
  background: linear-gradient(118deg, #ffffff, #ffc9c9 45%, #d5b3ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.foot-desc {
  margin: 0;
  max-width: 46ch;
  font-size: 16px;
  color: var(--dim);
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 20px;
  margin: 0;
}

.foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 0;
  font-size: 16px;
  color: var(--dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.foot-links a:hover,
.foot-links a:focus-visible {
  color: #fff;
  border-bottom-color: rgba(255, 0, 0, 0.6);
}

.foot-base {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 16px;
  color: var(--faint);
}

.foot-base p {
  margin: 0;
}

.foot-base a {
  display: inline-block;
  min-height: 40px;
  padding: 6px 0;
  color: var(--faint);
  text-decoration: none;
}

.foot-base a:hover {
  color: #fff;
}

/* ---- 滚动揭示 ---- */
.js .prose > section {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* ---- 移动端 ---- */
@media (max-width: 900px) {
  body {
    padding-left: 0;
    padding-top: 128px;
  }

  .rail {
    right: 0;
    bottom: auto;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
    flex: none;
  }

  .brand-mark {
    font-size: 28px;
  }

  .brand-name {
    font-size: 16px;
    letter-spacing: 0.08em;
  }

  .rail-nav {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .rail-nav::-webkit-scrollbar {
    display: none;
  }

  .rail-nav p {
    flex-direction: row;
    gap: 8px;
    width: max-content;
  }

  .rail-nav a {
    white-space: nowrap;
    padding: 10px 14px;
    min-height: 42px;
    font-size: 16px;
  }

  .stage {
    min-height: 42vh;
    padding: 34px 18px 28px;
  }

  .stage-ghost {
    font-size: clamp(92px, 30vw, 150px);
    right: 6px;
    top: -6px;
    opacity: 0.85;
  }

  .wrap {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 8px 18px 56px;
  }

  .side {
    position: static;
  }

  .prose {
    padding: 22px 18px 32px;
  }

  .prose section[id] {
    scroll-margin-top: 132px;
  }

  .foot {
    grid-template-columns: minmax(0, 1fr);
    padding: 34px 18px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  body::before,
  .stage-ghost {
    animation: none;
  }

  .js .prose > section {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

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