/*
  wenchang site: ink black with one vermilion seal-red signal and a jade
  secondary. JetBrains Mono carries headings, paths, and labels; IBM Plex Sans
  carries running text; Noto Serif SC supplies the 文昌 glyphs only. East Asian
  touches are restrained: a seal mark, a key-fret (回纹) divider drawn from
  lattice.svg, and a vertical hero watermark. Light mode is a separate palette,
  not an inversion. Code and trace panels stay dark in both themes.
*/

@font-face {
  font-family: "Plex Sans Fallback";
  src: local("Arial"), local("Helvetica Neue");
  size-adjust: 103%;
  ascent-override: 94%;
  descent-override: 25%;
  line-gap-override: 0%;
}

@font-face {
  font-family: "JetBrains Mono Fallback";
  src: local("Menlo"), local("Consolas"), local("Courier New");
  size-adjust: 99%;
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
}

:root {
  --bg: #0b0c0f;
  --panel: #111317;
  --raised: #171a1f;
  --text: #e6e4e0;
  --muted: #9a9ca6;
  --line: #1f2228;
  --line-2: #5b5f6a;
  --accent: #ff5a40;
  --accent-ink: #170503;
  --link: #ff7a62;
  --jade: #3fbf94;
  --focus: #5ec8ff;
  --code-inline: #1a1d23;
  --term: #08090c;
  --term-2: #101216;
  --term-text: #e6e4e0;
  --term-muted: #9a9ca6;
  --term-line: #23262d;
  --term-accent: #ff7a5c;
  --t-stated: #6cb6ff;
  --t-observed: #5fd38d;
  --t-inferred: #b89cff;
  --t-system: #ff7a70;
  --add-bg: #12281d;
  --add-fg: #7be0a1;
  --del-bg: #2b1618;
  --del-fg: #ff9c94;
  --tok-key: #6cb6ff;
  --tok-string: #7be0a1;
  --tok-number: #e0b45c;
  --tok-keyword: #ff9c94;
  --tok-comment: #8c8f9a;
  --dots: #1a1d23;
  --fret: #2b2f38;
  --font-text: "IBM Plex Sans", "Plex Sans Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "JetBrains Mono Fallback", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-cjk: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f6f4;
    --panel: #ffffff;
    --raised: #eeeeeb;
    --text: #15161a;
    --muted: #5a5c66;
    --line: #dcdcd8;
    --line-2: #8a8c94;
    --accent: #c8321e;
    --accent-ink: #ffffff;
    --link: #b02a18;
    --jade: #0d7a5c;
    --focus: #0b62d6;
    --code-inline: #ebebe8;
    --t-stated: #1d5fbf;
    --t-observed: #17703f;
    --t-inferred: #6b3fd0;
    --t-system: #c23a2e;
    --dots: #e3e3df;
    --fret: #cfcfca;
    color-scheme: light;
  }}

:root[data-theme="light"] {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --raised: #eeeeeb;
  --text: #15161a;
  --muted: #5a5c66;
  --line: #dcdcd8;
  --line-2: #8a8c94;
  --accent: #c8321e;
  --accent-ink: #ffffff;
  --link: #b02a18;
  --jade: #0d7a5c;
  --focus: #0b62d6;
  --code-inline: #ebebe8;
  --t-stated: #1d5fbf;
  --t-observed: #17703f;
  --t-inferred: #6b3fd0;
  --t-system: #c23a2e;
  --dots: #e3e3df;
  --fret: #cfcfca;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
}

a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 0.85rem var(--font-mono);
}

.skip-link:focus {
  top: 0.75rem;
  color: var(--accent-ink);
}

/* Header */

.site-header {
  border-bottom: 0;
}

.site-header::after {
  margin-top: -1px;
  opacity: 0.8;
}

.site-header .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-right: auto;
  padding: 0.9rem 0;
  color: var(--text);
  font: 700 1.05rem/1 var(--font-mono);
  letter-spacing: -0.02em;
  text-decoration: none;
}

/* The brand mark is the seal.svg stamp; any inline .seal svg is replaced by it. */

.brand::before {
  content: "";
  width: 1.6rem;
  height: 1.6rem;
  flex: none;
  background: url("seal.svg") center / contain no-repeat;
}

.seal {
  display: none;
}

/* Key-fret (回纹) strip, drawn as a mask so it follows the theme. */

.site-header::after,
.site-footer::before,
.section + .section::before,
.sec + .sec::before,
.page-nav::before {
  content: "";
  display: block;
  height: 10px;
  background: var(--fret);
  -webkit-mask: url("lattice.svg") repeat-x left center;
  mask: url("lattice.svg") repeat-x left center;
}

.site-nav {
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.site-nav ul {
  display: flex;
  gap: 0.15rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav li {
  margin: 0;
}

.site-nav a {
  display: block;
  padding: 1.15rem 0.65rem 1rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: 500 0.8rem/1.2 var(--font-mono);
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text);
}

.site-nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--text);
}

.theme-toggle {
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font: 500 0.72rem var(--font-mono);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

@media (max-width: 48rem) {
  .brand {
    padding: 0.8rem 0 0.4rem;
  }

  .theme-toggle {
    margin-top: 0.4rem;
  }

  .site-nav {
    order: 3;
    width: calc(100% + 1rem);
    margin-right: -1rem;
    overflow-x: auto;
    scrollbar-width: none;
  }

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

  .site-nav ul {
    padding-right: 1rem;
  }

  .site-nav a {
    padding: 0.6rem 0.8rem 0.55rem;
  }

  .site-nav li:first-child a {
    padding-left: 0;
  }}

/* Page layout */

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 78rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 5rem;
}

.content {
  min-width: 0;
  max-width: 47rem;
}

.content > p,
.content > ul,
.content > ol {
  max-width: 42rem;
}

.md-link {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font: 400 0.75rem/1.6 var(--font-mono);
}

.md-link .path {
  margin-right: 0.8rem;
  color: var(--text);
}

.content > p.md-link {
  max-width: none;
}

.toc-side {
  display: none;
}

.toc-inline {
  margin: 0 0 2rem;
  border: 1px solid var(--line-2);
  background: var(--panel);
}

.toc-inline summary {
  padding: 0.6rem 1rem;
  font: 500 0.78rem var(--font-mono);
  cursor: pointer;
}

.toc-inline ul {
  padding: 0 1rem 0.8rem;
}

.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc li {
  margin: 0;
}

.toc ul ul {
  margin-left: 0.9rem;
}

.toc a {
  display: block;
  padding: 0.22rem 0;
  color: var(--muted);
  font: 400 0.75rem/1.45 var(--font-mono);
  text-decoration: none;
}

.toc a:hover {
  color: var(--text);
}

@media (min-width: 62rem) {
  .page.has-toc {
    display: grid;
    grid-template-columns: 14rem minmax(0, 47rem);
    column-gap: 4.5rem;
    justify-content: center;
    align-items: start;
  }

  .page.has-toc > .toc-side {
    grid-column: 1;
    grid-row: 1;
  }

  .page.has-toc > .content {
    grid-column: 2;
    grid-row: 1;
  }

  .toc-inline {
    display: none;
  }

  .toc-side {
    display: block;
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    padding-top: 0.2rem;
  }

  .toc-side .toc-title {
    margin: 0 0 0.7rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font: 500 0.68rem var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }

  .toc-side > ul > li > a {
    padding-left: 0.8rem;
    border-left: 1px solid var(--line);
  }

  .toc-side > ul > li > a:hover {
    border-left-color: var(--accent);
  }}

/* Type */

h1,
h2,
h3,
h4 {
  font-family: var(--font-mono);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

h2 {
  margin: 4rem 0 1.1rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: 1.5rem;
  font-weight: 600;
}

h2::before {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 0.55em;
  vertical-align: 0.08em;
  background: var(--accent);
}

h3::before {
  content: "### ";
  content: "### " / "";
  color: var(--link);
  font-weight: 500;
}

h3 {
  margin: 2.5rem 0 0.6rem;
  font-size: 1.1rem;
  font-weight: 600;
}

h3::before {
  content: "### ";
  content: "### " / "";
  color: var(--muted);
}

.cjk,
:lang(zh) {
  font-family: var(--font-cjk);
}

h4 {
  margin: 1.75rem 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.headerlink {
  margin-left: 0.5rem;
  color: var(--muted);
  font: 400 0.9rem var(--font-mono);
  text-decoration: none;
  opacity: 0;
}

h2:hover .headerlink,
h3:hover .headerlink,
h4:hover .headerlink,
.headerlink:focus {
  opacity: 1;
}

p,
ul,
ol,
pre,
blockquote,
figure {
  margin: 0 0 1.15rem;
}

ul,
ol {
  padding-left: 1.4rem;
}

li {
  margin: 0.35rem 0;
}

li::marker {
  color: var(--muted);
}

ol li::marker {
  font: 500 0.85em var(--font-mono);
}

li > ul,
li > ol {
  margin: 0.35rem 0;
}

strong {
  font-weight: 600;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

blockquote {
  margin: 0 0 1.25rem;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 2px solid var(--line-2);
  color: var(--muted);
}

blockquote p:last-child {
  margin-bottom: 0;
}

code,
pre {
  font-family: var(--font-mono);
}

code {
  font-size: 0.84em;
}

:not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 3px;
  background: var(--code-inline);
  overflow-wrap: anywhere;
}

/* Code and trace panels */

pre {
  padding: 1rem 1.1rem;
  overflow-x: auto;
  border: 1px solid var(--term-line);
  border-radius: 4px;
  background: var(--term);
  color: var(--term-text);
  font-size: 0.8rem;
  line-height: 1.6;
  tab-size: 4;
}

pre code {
  padding: 0;
  background: none;
  font-size: inherit;
  overflow-wrap: normal;
}

.code-wrap {
  position: relative;
  margin: 0 0 1.25rem;
}

.code-wrap pre {
  margin: 0;
}

.copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--term-line);
  border-radius: 3px;
  background: var(--term-2);
  color: var(--term-muted);
  font: 500 0.68rem var(--font-mono);
  cursor: pointer;
}

.copy-btn:hover {
  color: var(--term-text);
}

@media (max-width: 40rem) {
  .code-wrap pre {
    padding-top: 2.4rem;
  }}

.highlight {
  background: none;
}

.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cs,
.highlight .cp,
.highlight .ch {
  color: var(--tok-comment);
  font-style: italic;
}

.highlight .k,
.highlight .kn,
.highlight .kd,
.highlight .kc,
.highlight .kr,
.highlight .kp,
.highlight .ow,
.highlight .kt,
.highlight .nd {
  color: var(--tok-keyword);
}

.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sa,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .si,
.highlight .sx {
  color: var(--tok-string);
}

.highlight .m,
.highlight .mi,
.highlight .mh,
.highlight .il {
  color: var(--tok-number);
}

.highlight .nb,
.highlight .nc,
.highlight .nf,
.highlight .fm,
.highlight .nn,
.highlight .bp,
.highlight .nt {
  color: var(--tok-key);
}

.highlight .err {
  color: inherit;
  background: none;
  border: 0;
}

/* Tables */

.table-wrap {
  margin: 0 0 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}

.table-wrap table {
  min-width: 34rem;
}

th,
td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--raised);
  color: var(--muted);
  font: 500 0.68rem var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

td code {
  font-size: 0.8em;
}

td:first-child code {
  overflow-wrap: normal;
  white-space: nowrap;
}

/* Tags and labels */

.tag {
  font-family: var(--font-mono);
  font-weight: 500;
}

.tag-stated {
  color: var(--t-stated);
}

.tag-system {
  color: var(--t-system);
}

.pill {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  font: 500 0.66rem/1.6 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill-red {
  color: var(--t-system);
}

.pill-muted {
  color: var(--muted);
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Memory files as listings and diffs. Always a dark panel. */

.memfile {
  margin: 0 0 1.5rem;
  overflow: hidden;
  border: 1px solid var(--term-line);
  border-radius: 4px;
  background: var(--term);
  color: var(--term-text);
  font-family: var(--font-mono);
}

.mf-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.2rem 0.8rem;
  margin: 0;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--term-line);
  background: var(--term-2);
  font-size: 0.78rem;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.mf-path .stat {
  color: var(--term-muted);
  font-size: 0.7rem;
}

.mf-path .plus {
  color: #7be0a1;
}

.mf-path .minus {
  color: #ff9c94;
}

.mf-lines {
  margin: 0;
  padding: 0.4rem 0;
  list-style: none;
}

.mf-lines li {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  margin: 0;
  padding: 0 1rem 0 0;
  font-size: 0.78rem;
  line-height: 1.7;
}

.mf-lines .gutter {
  padding-right: 0.6rem;
  color: var(--term-muted);
  text-align: right;
  user-select: none;
}

.mf-lines .k {
  color: var(--term-muted);
}

.mf-lines .rule {
  color: var(--term-muted);
}

.mf-lines .added {
  background: #12281d;
}

.mf-lines .added .gutter {
  color: #7be0a1;
}

.mf-lines .removed {
  background: #2b1618;
}

.mf-lines .removed .gutter,
.mf-lines .removed .fact,
.mf-lines .removed .k {
  color: #ff9c94;
}

.mf-lines .removed .tag {
  color: inherit;
}

.memfile .tag-stated {
  color: #6cb6ff;
}

.memfile .tag-system {
  color: #ff7a70;
}

.mf-label {
  margin: 1.6rem 0 0.5rem;
  color: var(--muted);
  font: 500 0.7rem/1.4 var(--font-mono);
  letter-spacing: 0.04em;
}

.mf-label strong {
  color: var(--text);
  font-weight: 500;
}

/* Walkthrough story */

.msg {
  max-width: 38rem;
  margin: 0 0 1.25rem;
  font-style: normal;
}

.msg p {
  margin: 0;
}

.msg strong {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--muted);
  font: 500 0.66rem var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

blockquote.msg-user {
  padding: 0.6rem 1rem;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  background: var(--panel);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1.5;
}

blockquote.msg-agent {
  padding: 0.2rem 0 0.2rem 1rem;
  border: 0;
  border-left: 2px solid var(--line-2);
  color: var(--text);
}

.toolcall {
  margin: 0 0 1.25rem;
  overflow: hidden;
  border: 1px solid var(--term-line);
  border-radius: 4px;
  background: var(--term);
  color: var(--term-text);
}

.tc-head,
.tc-rhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  padding: 0.5rem 1rem;
  background: var(--term-2);
  color: var(--term-muted);
  font: 400 0.72rem/1.4 var(--font-mono);
}

.tc-head .arrow {
  color: var(--term-accent);
  font-weight: 700;
}

.tc-rhead .arrow {
  color: #7be0a1;
  font-weight: 700;
}

.tc-head code {
  color: var(--term-text);
  font-size: 0.82rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.toolcall :not(pre) > code {
  padding: 0;
  background: none;
}

.toolcall pre {
  margin: 0;
  padding: 0.8rem 1.1rem;
  border: 0;
  border-radius: 0;
}

.toolcall .code-wrap {
  margin: 0;
}

.tc-rhead {
  border-top: 1px solid var(--term-line);
  background: transparent;
}

.tc-err .tc-rhead,
.tc-err .tc-rhead .arrow {
  color: #ff9c94;
}

.tc-err pre {
  box-shadow: inset 2px 0 0 #ff9c94;
}

.session {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.2rem 0 1rem;
  color: var(--muted);
  font: 500 0.7rem var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.session::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

/* Tool reference entries: signature blocks */

.tool-card {
  margin: 0 0 1.5rem;
}

.tool-card > h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.8rem;
  margin: 3rem 0 0.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-size: 1.15rem;
}

.tool-card > h3 > span:first-child {
  margin-right: auto;
}

.tool-card .sig {
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--term-line);
  border-radius: 4px;
  background: var(--term);
  color: var(--term-text);
  font: 400 0.8rem/1.6 var(--font-mono);
  white-space: pre-wrap;
}

.sig .fn {
  color: var(--term-accent);
  font-weight: 600;
}

.sig .opt {
  color: var(--term-muted);
}

/* Index: hero */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  margin: 0 0 4.5rem;
}

.hero-text {
  min-width: 0;
}

.hero h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.035em;
}

.btn {
  display: inline-block;
  padding: 0.65rem 1.3rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 0.82rem var(--font-mono);
  text-decoration: none;
}

.btn:hover {
  background: transparent;
  color: var(--link);
}

.hero pre.install {
  margin: 0;
  padding-right: 4.5rem;
  font-size: 0.72rem;
}

/* The session panel */

/* Index: sections */

.sec {
  margin-top: 4.5rem;
}

.sec > h2 {
  margin: 0 0 1.5rem;
}

.sec p,
.sec ol,
.sec ul {
  max-width: 44rem;
}

/* The memory index as a table */

/* Agent instructions */

/* How it works: the pipeline */

/* See it work: two traces side by side */

/* Key properties: a spec matrix */

/* 404 */

.content.notfound {
  max-width: none;
}

.nf-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 34rem;
}

.nf-grid .memfile {
  margin: 0;
}

.nf-grid .memfile a {
  color: var(--term-accent);
}

/* Footer */

.site-footer {
  margin-top: auto;
  border-top: 0;
  color: var(--muted);
  font: 400 0.72rem/1.5 var(--font-mono);
}

.site-footer .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--text);
  text-decoration-thickness: 1px;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}

.site-footer li {
  margin: 0;
}

@media (max-width: 40rem) {
  .site-footer ul {
    margin-left: 0;
  }

  .page {
    padding-top: 1.75rem;
  }

  h2 {
    margin-top: 3rem;
  }

  .sec {
    margin-top: 3.5rem;
  }}

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

@media print {
  .site-header,
.site-footer,
.toc,
.copy-btn,
.skip-link {
    display: none;
  }}

.page-index .content {
  max-width: none;
}

/* Sections */

.section,
.sec {
  position: relative;
  margin-top: 4.5rem;
}

.section + .section::before,
.sec + .sec::before {
  margin-bottom: 3rem;
}

.section > h2:first-child,
.section-label + h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.6rem;
  color: var(--link);
  font: 600 0.7rem/1.4 var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-label::before {
  content: "";
  width: 1.4rem;
  border-top: 2px solid var(--accent);
}

.section p,
.section ol,
.section ul {
  max-width: 44rem;
}

.section .card-grid,
.section .steps,
.section .diagram {
  max-width: none;
}

/* Hero */

.hero {
  position: relative;
  display: block;
  padding: 1.5rem 0 0;
}

.hero > * {
  position: relative;
  min-width: 0;
}

.hero-text {
  max-width: 46rem;
}

.hero::after {
  content: "文昌" / "";
  position: absolute;
  top: -0.5rem;
  right: 0;
  z-index: 0;
  color: var(--line);
  font: 700 clamp(5rem, 22vw, 11rem) / 1 var(--font-cjk);
  letter-spacing: 0.1em;
  opacity: 0.55;
  pointer-events: none;
  user-select: none;
  writing-mode: vertical-rl;
}

@media (max-width: 62rem) {
  .hero::after {
    display: none;
  }}

.hero-lede {
  max-width: 36rem;
  margin: 0 0 1.5rem;
  color: var(--text);
  font-size: clamp(1.1rem, 2.4vw, 1.3rem);
  line-height: 1.55;
}

.hero-lede strong {
  box-shadow: inset 0 -0.35em 0 color-mix(in srgb, var(--accent) 28%, transparent);
  font-weight: 600;
}

.install {
  display: block;
  max-width: 100%;
  margin: 0 0 1.25rem;
  padding: 0.6rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--term-line);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  background: var(--term);
  color: var(--term-text);
  font: 400 0.8rem/1.6 var(--font-mono);
  white-space: pre;
}

.install code {
  padding: 0;
  background: none;
  font-size: inherit;
}

/* Steps */

.steps {
  max-width: none;
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  margin: 0;
  padding: 0 0 1.5rem 3.2rem;
  counter-increment: step;
}

.steps > li:last-child {
  padding-bottom: 0;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--accent);
  border-radius: 3px;
  background: var(--bg);
  color: var(--link);
  font: 700 0.85rem/1 var(--font-mono);
}

.steps > li::after {
  content: "";
  position: absolute;
  left: calc(1rem - 1px);
  top: 2.3rem;
  bottom: 0.3rem;
  border-left: 1px dashed var(--line-2);
}

.steps > li:last-child::after {
  display: none;
}

.steps > li > :first-child {
  margin-top: 0.2rem;
}

.steps > li > :last-child {
  margin-bottom: 0;
}

.steps h3,
.steps h4 {
  margin: 0.2rem 0 0.4rem;
}

.steps h3::before {
  content: none;
}

/* Cards */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
  max-width: none;
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
}

.card-grid > li {
  display: flex;
  margin: 0;
}

.card {
  position: relative;
  display: block;
  min-width: 0;
  padding: 1.1rem 1.1rem 1.15rem;
  border: 1px solid var(--line-2);
  border-top: 2px solid var(--accent);
  border-radius: 3px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.card-grid > li > .card {
  flex: 1;
}

.card::after {
  content: "";
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--line-2);
  border-bottom: 2px solid var(--line-2);
}

a.card:hover {
  border-color: var(--accent);
  background: var(--raised);
  color: var(--text);
}

a.card:hover::after {
  border-color: var(--accent);
}

.card h3,
.card h4 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  line-height: 1.3;
}

.card h3::before,
.card h4::before {
  content: none;
}

.card > :last-child {
  margin-bottom: 0;
}

.card p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* Callouts */

.callout {
  max-width: 44rem;
  margin: 0 0 1.5rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line-2);
  border-left: 4px solid var(--jade);
  border-radius: 0 3px 3px 0;
  background: var(--panel);
}

.callout > :first-child {
  margin-top: 0;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout > strong:first-child,
.callout-title {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--jade);
  font: 600 0.68rem/1.5 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.callout-warn,
.callout.warn {
  border-left-color: var(--accent);
}

.callout-warn > strong:first-child,
.callout.warn > strong:first-child {
  color: var(--link);
}

/* Diagrams */

.diagram {
  max-width: none;
  margin: 0 0 1.75rem;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--panel);
}

.diagram pre {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  line-height: 1.4;
}

.diagram svg,
.diagram img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.diagram figcaption,
.diagram .caption {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font: 400 0.75rem/1.5 var(--font-mono);
}

/* Section sub-nav: a landing page and its children */

.subnav {
  max-width: 44rem;
  margin: 0 0 2rem;
}

.subnav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.subnav li {
  margin: 0;
}

.subnav a {
  display: block;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--panel);
  color: var(--muted);
  font: 500 0.75rem/1.3 var(--font-mono);
  text-decoration: none;
}

.subnav a:hover {
  border-color: var(--accent);
  color: var(--text);
}

.subnav a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--raised);
  color: var(--text);
}

/* Prev / next */

.page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 44rem;
  margin: 4rem 0 0;
}

.page-nav::before {
  flex: 0 0 100%;
  margin-bottom: 0.5rem;
}

.page-nav a {
  display: block;
  flex: 1 1 14rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: var(--panel);
  color: var(--text);
  font: 600 0.92rem/1.35 var(--font-mono);
  text-decoration: none;
}

.page-nav a:hover {
  border-color: var(--accent);
  background: var(--raised);
}

.page-nav a:only-of-type,
.page-nav a[rel="next"] {
  text-align: right;
}

.page-nav a[rel="next"]:only-of-type {
  margin-left: auto;
}

.page-nav small,
.page-nav .dir {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--muted);
  font: 500 0.66rem/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

@media print {
  .hero::after,
.page-nav {
    display: none;
  }}