:root {
  color-scheme: dark;
  --bg: #07150e;
  --frame: #0d2116;
  --panel: #142c1d;
  --panel-hover: #1d3b29;
  --line: #30513a;
  --text: #f0f8ef;
  --muted: #b6cdb9;
  --soft: #8eac94;
  --accent: #82d996;
  --font: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 75% 0, #174d2a 0, transparent 47%), var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }
img { display: block; max-width: 100%; }
::selection { background: #3b8150; color: white; }
:focus-visible { outline: 2px solid #9de6a8; outline-offset: 4px; }
.skip-link { position: absolute; z-index: 20; top: -100px; left: 16px; padding: 10px 14px; background: white; color: #111; }
.skip-link:focus { top: 12px; }
.site-frame {
  display: flex;
  flex-direction: column;
  width: calc(100% - 48px);
  min-height: calc(100svh - 48px);
  margin: 24px auto;
  border: 1px solid #31533b;
  background: linear-gradient(130deg, #12331f, var(--frame) 52%, #0a1b12);
  box-shadow: 0 25px 90px #0005;
}
.site-header {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 36px;
  min-height: 82px;
  padding: 0 clamp(28px, 5vw, 70px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 25px; font-weight: 800; letter-spacing: -.085em; }
.brand span { color: #8ddd9b; }
.site-nav { display: flex; justify-content: center; align-items: center; }
.site-nav a {
  padding: 4px clamp(10px, 1.5vw, 22px);
  border-right: 1px solid #31513b;
  color: #b5cdb8;
  font-size: 13px;
  white-space: nowrap;
  transition: color .2s ease;
}
.site-nav a:first-child { border-left: 1px solid #31513b; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }
.nav-toggle { display: none; }
.star-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 37px;
  padding: 0 10px;
  border: 1px solid #40664b;
  color: #d6efda;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .2s ease, border-color .2s ease;
}
.star-link:hover { border-color: var(--accent); background: #21432d; color: var(--accent); }
.star-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
/* One-screen homepage */
.home-main {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: clamp(55px, 8vw, 130px);
  flex: 1;
  padding: 55px clamp(52px, 8vw, 115px);
}
.home-photo { display: flex; flex-direction: column; align-items: center; justify-self: center; width: min(100%, 322px); }
.avatar-ring { width: 100%; aspect-ratio: 1; padding: 15px; border: 1px solid #568363; border-radius: 50%; box-shadow: 0 0 0 13px #ffffff09, 0 0 0 14px #ffffff12; }
.avatar-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; filter: grayscale(1) contrast(1.1) brightness(.82); }
.home-intro { max-width: 650px; }
.home-intro h1 { margin: 0 0 25px; font-size: clamp(43px, 4.8vw, 68px); line-height: 1.18; letter-spacing: -.07em; }
.home-intro h1 span { color: #90d59c; }
.intro-divider { width: 68px; height: 2px; margin: 0 0 38px; background: #75cf8d; }
.home-intro section + section { margin-top: 31px; }
.home-intro h2 { margin: 0 0 9px; color: #e5f6e7; font-size: 16px; letter-spacing: .03em; }
.home-intro p { margin: 0; color: #bed3c1; font-size: 15px; line-height: 1.9; }
.home-contact { display: flex; align-items: baseline; flex-wrap: wrap; gap: 16px; margin-top: 40px; padding-top: 23px; border-top: 1px solid var(--line); font-size: 13px; }
.home-contact > span { color: var(--soft); }
.home-contact a { border-bottom: 1px solid #659a72; padding-bottom: 5px; }
.home-contact a:hover { color: white; border-color: white; }

/* AI Infra catalog */
.catalog-main { flex: 1; padding: 68px clamp(42px, 7vw, 95px) 100px; }
.page-heading { margin-bottom: 43px; }
.page-heading h1 { margin: 0; font-size: clamp(46px, 5.5vw, 70px); line-height: 1.13; letter-spacing: -.07em; }
.catalog-box { padding: 27px; border: 1px solid #3b6547; background: #0b1d13; }
.topic-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.topic-card { display: flex; flex-direction: column; justify-content: center; min-height: 175px; padding: 24px; border: 1px solid #365b41; background: var(--panel); }
.topic-card { transition: transform .2s ease, border-color .2s ease, background .2s ease; }
.topic-card:hover { transform: translateY(-4px); border-color: #82d596; background: var(--panel-hover); }
.topic-card h2 { margin: 0 0 10px; font-size: clamp(22px, 2.4vw, 31px); letter-spacing: -.04em; }
.topic-card p { min-height: 43px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.catalog-note { margin: 28px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* Chapter directory and article */
.reader-main { flex: 1; padding: 46px clamp(35px, 5vw, 70px) 90px; }
.breadcrumb { display: flex; align-items: center; gap: 11px; color: #a7c5ad; font-size: 12px; }
.breadcrumb a:hover { color: white; }
.breadcrumb span { color: #618d6c; }
.reader-heading { margin: 35px 0 40px; }
.reader-heading h1 { margin: 0; font-size: clamp(42px, 4.8vw, 64px); letter-spacing: -.06em; }
.reader-grid { display: grid; grid-template-columns: minmax(220px, 255px) minmax(0, 1fr); min-height: 620px; border: 1px solid #3b6547; background: #0b1d13; }
.chapter-sidebar { border-right: 1px solid var(--line); background: #10251a; }
.chapter-panel { position: sticky; top: 0; }
.chapter-panel summary { display: flex; justify-content: space-between; gap: 14px; padding: 25px 22px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; font-weight: 700; list-style: none; }
.chapter-panel summary::-webkit-details-marker { display: none; }
.chapter-panel summary::after { content: "−"; color: #a4deb0; }
.chapter-panel:not([open]) summary::after { content: "+"; }
.chapter-list { margin: 0; padding: 15px 0 22px; list-style: none; }
.chapter-list li a { display: flex; align-items: baseline; gap: 12px; padding: 12px 22px; color: #b1cbb7; font-size: 13px; line-height: 1.5; transition: color .2s ease, background .2s ease; }
.chapter-list li a:hover, .chapter-list li a.is-current { background: #21432d; color: white; }
.reader-content { min-width: 0; padding: 43px clamp(28px, 5vw, 70px) 80px; }
.reader-content h2 { margin: 22px 0 14px; font-size: 28px; letter-spacing: -.04em; }
.reader-content > p, .reader-content section p { color: #bfd2c1; font-size: 14px; line-height: 1.9; }
.reader-content section { padding-top: 32px; margin-top: 37px; border-top: 1px solid var(--line); scroll-margin-top: 30px; }
.reader-content > section:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
.reader-content section h3 { margin: 0 0 13px; font-size: 21px; letter-spacing: -.03em; }
.reader-content section p { margin: 0; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 55px; }
.reader-actions a { display: inline-block; padding-bottom: 7px; border-bottom: 1px solid #679c73; color: #d8ecda; font-size: 13px; }
.reader-actions a:hover { color: white; border-color: white; }

/* ------------------------- 文章正文：正文元素 ------------------------- */
.reader-content section h4 { margin: 24px 0 10px; font-size: 16px; letter-spacing: -.01em; color: #e5f6e7; }
.reader-content section ul, .reader-content section ol { margin: 12px 0; padding-left: 22px; color: #bfd2c1; font-size: 14px; line-height: 1.9; }
.reader-content section li { margin-bottom: 5px; }
.reader-content section li::marker { color: #8cae94; }
.reader-content code {
  padding: 1px 5px;
  border: 1px solid #365b41;
  background: #173323;
  color: #a9e9b2;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: .88em;
  word-break: break-word;
}
.reader-content section p + p { margin-top: 12px; }
.reader-content a.inline-link { color: #a6e9b2; border-bottom: 1px solid #659a72; }
.reader-content a.inline-link:hover { color: white; border-color: white; }

/* 代码块：文件名条 + 可横向滚动的正文 */
.code-block { margin: 18px 0; border: 1px solid #365b41; background: #0a1b15; }
.code-block > figcaption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 14px;
  border-bottom: 1px solid #30513a;
  background: #142a1e;
  color: #a7c9ac;
  font-size: 11px;
  letter-spacing: .04em;
}
.code-block > figcaption .code-lang { color: #8cae94; letter-spacing: .12em; }
.code-block pre {
  margin: 0;
  padding: 15px 16px;
  overflow-x: auto;
  background: #0a1b15;
}
.code-block code {
  padding: 0;
  border: 0;
  background: none;
  color: #dcebdd;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.72;
  white-space: pre;
  word-break: normal;
}
.code-block .tok-comment { color: #8ca995; }
.code-block .tok-keyword { color: #d9a7ee; }
.code-block .tok-type { color: #8ad8e5; }
.code-block .tok-string { color: #c4e38a; }
.code-block .tok-number { color: #f0bd7b; }
.code-block .tok-function { color: #9fc6ff; }
.code-block .tok-preprocessor { color: #e7a3ac; }
.code-block.is-long pre { max-height: 30rem; overflow-y: auto; }
.code-note { margin: -8px 0 18px; color: #9fbaa5; font-size: 12px; line-height: 1.7; }

/* 性能与数据表格 */
.reader-content table { width: 100%; margin: 18px 0; border-collapse: collapse; font-size: 13px; }
.reader-content thead th {
  padding: 10px 12px;
  border-bottom: 1px solid #3b6347;
  color: #d6d8da;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}
.reader-content tbody td { padding: 9px 12px; border-bottom: 1px solid #294934; color: #bfd2c1; }
.reader-content tbody tr:hover td { background: #142a1e; }
.reader-content tbody tr.is-best td { color: #f0f8ef; }
.reader-content tbody tr.is-best td:first-child { box-shadow: inset 2px 0 0 #81d996; }
.reader-content td.num, .reader-content th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; margin: 18px 0; }
.table-scroll table { margin: 0; min-width: 30rem; }

/* 提示框 */
.callout { margin: 18px 0; padding: 14px 16px; border: 1px solid #365b41; border-left: 3px solid #a7c9ac; background: #12291c; }
.callout p { color: #c4d8c6; font-size: 13.5px; line-height: 1.85; margin: 0; }
.callout p + p { margin-top: 9px; }
.callout .callout-title { display: block; margin-bottom: 7px; color: #e5f6e7; font-size: 12px; font-weight: 700; letter-spacing: .1em; }

/* 公式 / 算例方块 */
.formula { margin: 18px 0; padding: 15px 17px; border: 1px dashed #427451; background: #10251a; color: #a6e9b2; font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace; font-size: 13px; line-height: 1.9; overflow-x: auto; white-space: pre; }

/* 算子目录卡片补充 */
.topic-list.is-operator { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Placeholder pages */
.placeholder-main { display: flex; align-items: center; flex: 1; padding: 80px clamp(50px, 10vw, 145px); }
.placeholder-main > div { max-width: 650px; }
.placeholder-main h1 { margin: 0 0 15px; font-size: clamp(44px, 5vw, 68px); letter-spacing: -.06em; }
.placeholder-main p { color: var(--muted); font-size: 15px; line-height: 1.85; }
.placeholder-main a { display: inline-block; margin-top: 28px; padding-bottom: 7px; border-bottom: 1px solid #8cdaa0; font-size: 13px; }

@media (min-width: 1600px) {
  .home-main { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); padding-inline: clamp(90px, 7vw, 180px); }
  .home-photo { width: clamp(322px, 20vw, 430px); }
  .home-intro { max-width: 880px; }
  .home-intro h1 { font-size: clamp(68px, 5vw, 96px); }
  .home-intro p { font-size: 17px; }
  .reader-grid { grid-template-columns: clamp(260px, 17vw, 360px) minmax(0, 1fr); }
  .reader-content > section, .reader-content > h2, .reader-content > p, .reader-content > .reader-actions {
    max-width: 1500px;
    margin-inline: auto;
  }
  .topic-list.is-operator { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1030px) {
  .site-header { grid-template-columns: auto 1fr auto; gap: 18px; padding-inline: 28px; }
  .site-nav a { padding-inline: 10px; }
  .home-main { gap: 60px; padding-inline: 65px; }
}
@media (max-width: 850px) {
  .site-header { grid-template-columns: auto 1fr auto; min-height: 70px; }
  .nav-toggle { display: inline-flex; justify-self: end; gap: 9px; padding: 8px; border: 0; background: none; color: white; cursor: pointer; font-size: 13px; }
  .site-nav { position: absolute; top: 70px; right: 0; left: 0; display: none; flex-direction: column; align-items: stretch; padding: 12px 28px 20px; border-bottom: 1px solid var(--line); background: #142a1e; box-shadow: 0 20px 30px #0006; }
  .site-nav[data-open="true"] { display: flex; }
  .site-nav a, .site-nav a:first-child { padding: 13px 0; border: 0; }
  .home-main { grid-template-columns: 1fr; gap: 54px; padding: 65px 65px 85px; }
  .home-photo { width: min(65vw, 295px); }
  .home-intro { justify-self: center; width: 100%; }
  .topic-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-grid { grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); }
}
@media (max-width: 650px) {
  .site-frame { width: 100%; min-height: 100svh; margin: 0; border: 0; }
  .site-header { gap: 10px; padding-inline: 19px; }
  .brand { font-size: 23px; }
  .star-link { gap: 5px; min-height: 34px; padding: 0 7px; font-size: 10px; }
  .home-main { gap: 52px; padding: 68px 26px 75px; }
  .home-photo { width: min(70vw, 270px); }
  .home-intro h1 { font-size: clamp(41px, 11vw, 60px); }
  .home-intro p { font-size: 14px; }
  .catalog-main { padding: 55px 22px 85px; }
  .catalog-box { min-height: 0; padding: 18px; }
  .topic-list { grid-template-columns: 1fr; }
  .topic-card { min-height: 155px; }
  .reader-main { padding: 36px 18px 75px; }
  .reader-heading { margin-block: 30px; }
  .reader-grid { display: block; }
  .chapter-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .reader-content { padding: 36px 18px 65px; }
  .code-block pre { padding: 12px; }
  .code-block code { font-size: 11.5px; }
  .code-block.is-long pre { max-height: 24rem; }
  .reader-content table { font-size: 12px; }
  .reader-content thead th, .reader-content tbody td { padding: 8px 9px; }
  .formula { font-size: 11.5px; padding: 12px; }
  .topic-list.is-operator { grid-template-columns: 1fr; }
  .placeholder-main { padding: 80px 30px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
