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

:root {
  --ink: #1f1f1f;
  --paper: #ffffff;
  --mist: #f5f5f5;
  --line: #e3e3e3;
  --line-2: #cfcfcf;
  --dim: rgba(31, 31, 31, 0.62);
  --r: 10px;
  --r-lg: 22px;
  --gap: clamp(14px, 2.4vw, 32px);
}

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

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

body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font-family: "Open Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, .brand, .pill, .totop {
  font-family: "Poppins", "Open Sans", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
}

a { color: var(--ink); }

/* 顶栏 */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px clamp(12px, 2.4vw, 32px);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.3s ease;
}

.top.is-stuck { box-shadow: 0 6px 18px rgba(31, 31, 31, 0.06); }

.nav ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-l ol { justify-content: flex-end; }
.nav-r ol { justify-content: flex-start; }

.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 16px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.nav a:hover {
  background: var(--mist);
  border-color: var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-decoration: none;
}

.brand .logo {
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

/* 骨架 */
.frame {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: var(--gap);
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--gap) clamp(14px, 2.6vw, 40px) clamp(28px, 5vw, 64px);
}

/* 侧栏 */
.rail {
  position: sticky;
  top: 92px;
  align-self: start;
  padding: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 16px;
}

.rail h2 {
  margin: 2px 4px 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.rail h2 > span {
  display: inline-block;
  padding-bottom: 2px;
  border-bottom: 4px solid var(--mist);
}

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

.rail-list a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s ease;
}

.rail-list a:hover { background: var(--mist); }

.totop {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 12px;
  padding: 0 10px;
  font-size: 16px;
  color: var(--dim);
  text-decoration: none;
}

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

/* 首屏 */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  min-height: 70vh;
  padding: clamp(24px, 4vw, 64px);
  text-align: right;
  overflow: hidden;
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(31, 31, 31, 0.16) 1px, transparent 1px),
    radial-gradient(rgba(31, 31, 31, 0.05) 1px, transparent 1px);
  background-size: 18px 18px, 72px 72px;
  background-position: 0 0, 0 0;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.hero h1 {
  max-width: 22ch;
  margin: 0;
  font-size: clamp(34px, 6.4vw, 78px);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -0.035em;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 22px;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.pill:hover {
  background: var(--ink);
  color: var(--paper);
  transform: scale(1.02);
}

/* 正文 */
.prose > div {
  margin-top: var(--gap);
  padding: clamp(20px, 3vw, 40px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  scroll-margin-top: 108px;
  transition: transform 0.35s ease, border-color 0.35s ease;
}

.prose > div:hover {
  transform: translateY(-2px);
  border-color: var(--line-2);
}

.prose p,
.prose li { max-width: 66ch; }

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

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

.prose li { margin: 0.35em 0; }

.prose h2 {
  margin: 0 0 0.6em;
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.prose h2 > span {
  display: inline-block;
  padding-bottom: 2px;
  border-bottom: 5px solid var(--mist);
}

.prose h3 {
  margin: 1.5em 0 0.6em;
  font-size: clamp(19px, 2.2vw, 23px);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.prose h3 > span {
  display: inline-block;
  padding-bottom: 1px;
  border-bottom: 3px solid var(--mist);
}

.prose :first-child { margin-top: 0; }

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

.prose a:hover { background: var(--mist); }

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.2em 0;
  border-radius: var(--r);
}

.prose blockquote {
  margin: 1.2em 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--ink);
  color: var(--dim);
}

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

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

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

.prose pre {
  padding: 14px;
  overflow-x: auto;
  background: #111;
  color: var(--mist);
  border-radius: var(--r);
  font-size: 15px;
  line-height: 1.6;
}

.prose code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.95em; }

/* 页脚 */
.base {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px clamp(14px, 2.6vw, 40px) 40px;
  font-size: 16px;
  color: var(--dim);
}

.base p { margin: 0; }
.base .fmark { color: var(--ink); font-weight: 600; }
.base .fcopy { text-align: center; color: var(--ink); }
.base small { text-align: right; }

/* 窄屏 */
@media (max-width: 900px) {
  .frame {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 12px;
  }

  .flow { order: 1; }
  .rail { order: 2; position: static; }

  .top {
    grid-template-columns: 1fr;
    justify-items: center;
    padding-bottom: 6px;
  }

  .brand { order: -1; }
  .nav-l ol,
  .nav-r ol { justify-content: center; }

  .hero {
    min-height: 52vh;
    border-radius: 16px;
  }

  .prose > div { scroll-margin-top: 176px; }

  .base {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 6px;
    text-align: center;
  }

  .base small { text-align: center; }
}

@media (max-width: 520px) {
  .hero { padding: 22px 18px; }
  .prose > div { padding: 20px 18px; }
  .nav a { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .prose > div,
  .pill,
  .nav a,
  .rail-list a { transition: none; }
  .prose > div:hover,
  .pill:hover { transform: none; }
}

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