:root {
  --paper: #fcfbf8;
  --surface: #ffffff;
  --ink: #20262e;
  --muted: #68717d;
  --line: #e3e5e7;
  --soft-line: #ece8e1;
  --accent: #e77500;
  --accent-dark: #a94f00;
  --accent-soft: #fff3e4;
  --green: #147d64;
  --code: #f4f2ed;
  --shadow: 0 18px 50px rgba(33, 38, 45, 0.07);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif: Georgia, "Songti SC", "STSong", "Noto Serif CJK SC", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 243, 228, 0.42), transparent 280px),
    var(--paper);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent-dark);
  text-decoration-color: rgba(169, 79, 0, 0.32);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 66px;
  border-bottom: 1px solid rgba(219, 215, 208, 0.88);
  background: rgba(252, 251, 248, 0.92);
  backdrop-filter: blur(13px);
}

.masthead__inner {
  width: min(1142px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.masthead nav {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 14px;
}

.masthead nav a {
  color: #4e5661;
  text-decoration: none;
}

.masthead nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 650;
}

.preview-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid #f2c58f;
  border-radius: 999px;
  color: #8b4606;
  background: #fff8ee;
  font-size: 12px;
  font-weight: 650;
}

.preview-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.page-grid {
  width: min(1142px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0 96px;
  display: grid;
  grid-template-columns: minmax(0, 880px) 220px;
  gap: 42px;
  align-items: start;
  justify-content: center;
}

.author-card,
.toc {
  position: sticky;
  top: 104px;
}

.author-card {
  padding-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.author-card img {
  width: 116px;
  height: 116px;
  object-fit: cover;
  border: 4px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 5px 24px rgba(31, 37, 44, 0.13);
}

.author-card h2 {
  margin: 18px 0 5px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
}

.author-card p {
  margin: 4px 0;
}

.author-card .author-links {
  margin-top: 16px;
  display: grid;
  gap: 7px;
}

.author-card .author-links a {
  color: #58616d;
  text-decoration: none;
}

.article-shell {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--soft-line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.article-header {
  padding: 54px 62px 38px;
  border-bottom: 1px solid var(--soft-line);
  background:
    radial-gradient(circle at 100% 0, rgba(231, 117, 0, 0.12), transparent 35%),
    var(--surface);
}

.kicker {
  margin-bottom: 18px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.article-header h1 {
  max-width: 750px;
  margin: 0;
  color: #18202a;
  font-family: var(--serif);
  font-size: clamp(34px, 4.2vw, 50px);
  font-weight: 720;
  letter-spacing: -0.035em;
  line-height: 1.22;
}

.article-deck {
  max-width: 710px;
  margin: 20px 0 0;
  color: #59626d;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.68;
}

.article-meta {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 18px;
  color: #747d88;
  font-size: 12.5px;
}

.article-body {
  padding: 44px 62px 66px;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.92;
}

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

.article-body p {
  margin: 1.05em 0;
}

.article-body h2,
.article-body h3 {
  scroll-margin-top: 92px;
  color: #17212b;
  font-family: var(--sans);
  letter-spacing: -0.02em;
}

.article-body h2 {
  margin: 2.45em 0 0.78em;
  padding-top: 0.35em;
  border-top: 1px solid var(--soft-line);
  font-size: 27px;
  line-height: 1.35;
}

.article-body h3 {
  margin: 2em 0 0.62em;
  font-size: 20px;
  line-height: 1.45;
}

.article-body h2 + h3 {
  margin-top: 1.2em;
}

.article-body strong {
  color: #151b22;
}

.article-body code {
  padding: 0.13em 0.36em;
  border-radius: 4px;
  background: var(--code);
  color: #843d00;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
}

.article-body blockquote {
  margin: 1.7em 0;
  padding: 16px 20px;
  border: 1px solid #f0d1ac;
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: #4d4339;
  background: var(--accent-soft);
}

.article-body pre {
  margin: 1.4em 0 2em;
  padding: 24px 26px;
  border: 1px solid #ded6ca;
  border-radius: 8px;
  background: #faf7f2;
  font-size: 0.85em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
  tab-size: 2;
}

.article-body pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #30302b;
  font-size: inherit;
}

.article-body .reference-entry {
  padding-left: 1.5em;
  text-indent: -1.5em;
  font-size: 0.88em;
  overflow-wrap: anywhere;
}

.article-body blockquote p {
  margin: 0.25em 0;
}

.article-body ol,
.article-body ul {
  margin: 1em 0;
  padding-left: 1.45em;
}

.article-body li {
  margin: 0.42em 0;
  padding-left: 0.16em;
}

.math-block {
  max-width: 100%;
  margin: 1.4em 0;
  padding: 6px 4px;
  overflow-x: auto;
  text-align: center;
}

mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

figure {
  margin: 2.25em -34px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 5px;
}

figcaption {
  margin: 12px 6px 1px;
  color: #68717d;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.55;
  text-align: center;
}

figure.geometry-figure {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.geometry-figure img {
  border-radius: 0;
}

.geometry-figure figcaption {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 13px;
  text-align: left;
}

.table-wrap {
  margin: 1.55em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.5;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: #343c45;
  background: #f7f6f3;
  font-weight: 700;
}

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

tbody tr:hover {
  background: #fffaf3;
}

details {
  margin: 1.4em 0;
  padding: 0 18px;
  border: 1px solid #dddfe2;
  border-radius: 9px;
  background: #fafafa;
}

details[open] {
  padding-bottom: 10px;
  background: #fdfdfc;
}

summary {
  margin: 0 -18px;
  padding: 13px 18px;
  cursor: pointer;
  color: #37404a;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

summary:hover {
  color: var(--accent-dark);
}

.toc {
  max-height: calc(100vh - 128px);
  overflow-y: auto;
  padding: 14px 0 14px 18px;
  border-left: 1px solid #dadde0;
  font-size: 12.5px;
  line-height: 1.42;
}

.toc__title {
  margin: 0 0 12px;
  color: #29313a;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.toc a {
  display: block;
  margin: 0 0 8px;
  color: #6b7480;
  text-decoration: none;
}

.toc a:hover,
.toc a.is-active {
  color: var(--accent-dark);
}

.toc a.is-active {
  font-weight: 700;
}

.toc a[data-level="3"] {
  margin-left: 10px;
  color: #858c95;
  font-size: 11.5px;
}

.site-footer {
  padding: 30px 20px 48px;
  border-top: 1px solid var(--soft-line);
  color: #7b838c;
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1220px) {
  .page-grid {
    grid-template-columns: minmax(0, 880px) 210px;
  }

  .author-card {
    display: none;
  }
}

@media (max-width: 980px) {
  .page-grid {
    grid-template-columns: minmax(0, 880px);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 680px) {
  .masthead__inner,
  .page-grid {
    width: min(100% - 24px, 880px);
  }

  .masthead nav a:not([aria-current="page"]),
  .preview-pill span {
    display: none;
  }

  .page-grid {
    padding-top: 20px;
  }

  .article-shell {
    border-radius: 11px;
  }

  .article-header {
    padding: 36px 24px 28px;
  }

  .article-header h1 {
    font-size: 34px;
  }

  .article-deck {
    font-size: 16px;
  }

  .article-body {
    padding: 32px 24px 48px;
    font-size: 16px;
    line-height: 1.86;
  }

  .article-body h2 {
    font-size: 23px;
  }

  figure {
    margin-right: -12px;
    margin-left: -12px;
    padding: 8px;
  }
}

@media print {
  .masthead,
  .author-card,
  .toc,
  .site-footer {
    display: none;
  }

  body {
    background: #fff;
  }

  .page-grid {
    display: block;
    width: 100%;
    padding: 0;
  }

  .article-shell {
    border: 0;
    box-shadow: none;
  }
}
