@font-face {
  font-family: "Consolas Web";
  src: url("../fonts/consolas-regular.ttf")
    format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "SimSun Web";
  src: url("../fonts/simsun-regular.woff2")
    format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

.post-page > .site-header,
.post-page > .site-footer {
  width: min(calc(100% - 2.5rem), var(--wide-width));
}

.reading-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, var(--content-width));
  gap: 3rem;
  width: min(calc(100% - 2.5rem), var(--wide-width));
  margin-inline: auto;
}

.reading-layout > main {
  min-width: 0;
}

.sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

.article-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  padding-block: 2rem;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.article-sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-title,
.sidebar-heading {
  color: var(--text-strong);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.sidebar-title {
  text-decoration: none;
}

.sidebar-section {
  display: grid;
  gap: 0.65rem;
  margin-top: 2rem;
}

.sidebar-archive {
  margin-top: 0;
}

.sidebar-toc-section {
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.sidebar-heading {
  margin: 0;
}

.sidebar-year-group summary {
  display: flex;
  align-items: center;
  padding-block: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  letter-spacing: 0.08em;
  cursor: pointer;
  list-style: none;
}

.sidebar-archive .sidebar-year-group:first-child summary {
  padding-top: 0.65rem;
}

.sidebar-year-group summary::-webkit-details-marker {
  display: none;
}

.sidebar-year-group summary::before {
  content: "+";
  width: 1rem;
  color: inherit;
}

.sidebar-year-group[open] summary::before {
  content: "−";
}

.sidebar-year-group[open] summary {
  margin-bottom: 0.65rem;
}

.sidebar-year-group summary span:first-child {
  margin-right: auto;
}

.sidebar-year-group summary span:last-child {
  color: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.sidebar-year-group summary:hover,
.sidebar-year-group summary:focus-visible,
.sidebar-year-group summary:active {
  color: var(--special-color);
}

.sidebar-posts {
  display: grid;
  gap: 0.65rem;
  padding: 0 0 0 1rem;
}

.sidebar-posts a {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.sidebar-posts a[aria-current="page"] {
  color: var(--text-strong);
}

.article-toc {
  display: grid;
  gap: 0.65rem;
}

.article-toc a {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  text-decoration: none;
  transition: color 160ms ease;
  overflow-wrap: anywhere;
}

.article-toc a[aria-current="location"] {
  color: var(--special-color);
}

.article-toc .toc-level-2 {
  padding-left: 1rem;
}

.article-toc .toc-level-3 {
  padding-left: 2rem;
  font-size: 0.82rem;
}

.article-toc .toc-level-4 {
  padding-left: 3rem;
  font-size: 0.78rem;
}

.post {
  padding-block: 2rem;
}

.post > header {
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post > header h1 {
  max-width: 16em;
  margin-block: 1rem 1.5rem;
  font-size: clamp(2.25rem, 7vw, 3.8rem);
}

.post > header > p:not(.meta) {
  max-width: 36em;
  margin-bottom: 1rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.post-tags a {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.post-content {
  padding-top: 2rem;
}

.post-content hr {
  margin-block: 2rem;
  border: 0;
  border-top: 1px solid var(--border);
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  color: var(--text-strong);
  font-weight: 400;
  line-height: 1.35;
  scroll-margin-top: max(0px, calc(min(160px, 25vh) - 0.5rem));
}

.post-content h1 {
  max-width: none;
  margin-block: 3rem 1.2rem;
  font-size: 2rem;
  letter-spacing: normal;
}

.post-content h2 {
  margin-block: 2.75rem 1rem;
  font-size: 1.75rem;
}

.post-content h3 {
  margin-block: 2rem 0.8rem;
  font-size: 1.55rem;
}

.post-content h4 {
  margin-block: 1.75rem 0.7rem;
  font-size: 1.4rem;
}

.post-content h5 {
  margin-block: 1.5rem 0.6rem;
  font-size: 1.3rem;
}

.post-content h6 {
  margin-block: 1.5rem 0.6rem;
  font-size: 1.2rem;
}

.post-content ul,
.post-content ol,
.post-content blockquote,
.post-content pre {
  margin-bottom: 1.5rem;
}

.post-content p {
  margin-bottom: 1rem;
}

.post-content li > p:only-child {
  margin-bottom: 0;
}

.post-content .list-item-spaced {
  margin-top: 1rem;
}

.post-content p,
.post-content li,
.post-content blockquote {
  overflow-wrap: anywhere;
}

.post-content strong {
  font-weight: 700;
  -webkit-text-stroke: 0.012em currentColor;
}

.post-content s {
  color: var(--muted);
  text-decoration-thickness: 1px;
}

.post-content mark,
.post-content mark :where(*) {
  color: var(--article-highlight-color, var(--special-color));
}

.post-content mark {
  background: transparent;
}

.post-content .task-list-item {
  list-style: none;
}

.post-content .task-list-item-checkbox {
  width: 0.95em;
  height: 0.95em;
  margin: 0 0.5em 0 -1.45em;
  vertical-align: -0.05em;
  accent-color: var(--special-color);
  opacity: 1;
}

.post-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-block: 2rem;
}

.post-content .markdown-image {
  display: block;
  width: var(--markdown-image-width, 100%);
  margin-block: 0;
  margin-inline: auto;
  overflow: hidden;
}

.post-content .markdown-image-after-text {
  margin-top: calc(0.5em - 5px);
}

.post-content .markdown-image-after-blank-line {
  padding-top: calc(0.5lh - 0.5em);
}

.post-content .markdown-image-frame {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  aspect-ratio: var(--markdown-image-aspect-ratio, auto);
}

.post-content .markdown-image img {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0 auto;
}

.post-content .markdown-image-fallback {
  display: block;
  grid-column: 1;
  grid-row: 1;
  z-index: 0;
  place-self: center;
  width: min(100%, clamp(9rem, 24vw, 13.5rem));
  aspect-ratio: 1;
  background: var(--surface);
}

/* Match the placeholder behind partially painted images during loading. */
.post-content .markdown-image-has-dimensions:not(.is-loaded):not(.is-error) .markdown-image-frame,
.post-content .markdown-image-has-dimensions:not(.is-loaded):not(.is-error) img {
  background-color: var(--surface);
}

.post-content .markdown-image-has-dimensions:not(.is-error) .markdown-image-fallback {
  place-self: stretch;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.post-content .markdown-image.is-loaded .markdown-image-fallback {
  visibility: hidden;
}

.post-content .markdown-image.is-error .markdown-image-frame {
  aspect-ratio: auto;
}

.post-content .markdown-image.is-error img {
  display: none;
}

.post-content .markdown-image-caption {
  display: block;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: inherit;
  text-align: center;
}

.table-wrapper {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto 1.5rem;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.table-scroll::-webkit-scrollbar {
  display: none;
}

.table-scroll-hint {
  position: absolute;
  top: 50%;
  display: grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--special-color);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  transform: translateY(-50%);
  place-items: center;
}

.table-scroll-hint:hover,
.table-scroll-hint:focus-visible,
.table-scroll-hint:active {
  color: var(--special-color);
}

.table-scroll-hint[hidden] {
  display: none;
}

.table-scroll-left {
  left: 0.5rem;
}

.table-scroll-right {
  right: 0.5rem;
}

.post-content table {
  width: auto;
  margin-inline: auto;
  border-collapse: collapse;
}

.post-content th,
.post-content td {
  padding: 0.65rem 0.8rem;
  text-align: center;
  vertical-align: middle;
  white-space: normal;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
}

.table-cell {
  white-space: normal;
  overflow-wrap: anywhere;
}

.post-content th {
  color: var(--text-strong);
  font-weight: 400;
}

.post-content blockquote {
  margin-inline: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  border-left: 2px solid var(--special-color);
}

.post-content pre,
.post-content pre code {
  font-family:
    "Consolas Web",
    "SimSun Web",
    "LXGW Zhuque Fangsong",
    monospace;
  line-height: 1.6;
}

.post-content pre {
  padding: 1.25rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
}

.post-content code {
  font-size: 0.85em;
}

.post-content a {
  overflow-wrap: anywhere;
}

.post-content .footnotes-sep {
  margin-block: 2.5rem 1.5rem;
  border: 0;
  border-top: 1px solid var(--border);
}

.post-content .footnotes {
  color: var(--muted);
  font-size: 0.9em;
}

.post-content .footnote-backref {
  white-space: nowrap;
}

.post-content .katex {
  font-size: 1em;
}

.post-content eq {
  display: inline-block;
}

.post-content eqn {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

.post-content section.eqno {
  display: flex;
  align-items: center;
}

.post-content section.eqno > eqn {
  width: 100%;
  margin-left: 3em;
}

.post-content section.eqno > span {
  width: 3em;
  flex-shrink: 0;
  text-align: right;
}

.post-navigation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-top: 3rem;
  font-size: 0.9rem;
}

.post-navigation > span:last-child {
  text-align: right;
}

.post-navigation > span {
  min-width: 0;
}

.post-navigation a {
  color: var(--muted);
  text-decoration: none;
}

.post-navigation > span a {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  max-width: 100%;
}

.post-navigation > span:last-child a {
  justify-content: flex-end;
}

.post-navigation-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-posts a:hover,
.sidebar-posts a:focus-visible,
.sidebar-posts a:active,
.sidebar-posts a[aria-current="page"],
.article-toc a:hover,
.article-toc a:focus-visible,
.article-toc a:active,
.post-tags a:hover,
.post-tags a:focus-visible,
.post-tags a:active,
.post-navigation a:hover,
.post-navigation a:focus-visible,
.post-navigation a:active,
.back-link:hover,
.back-link:focus-visible,
.back-link:active {
  color: var(--special-color);
}

.comments {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.comments h2 {
  margin-bottom: 0.5rem;
}

.comments-note {
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.giscus {
  width: 100%;
  background: var(--background);
}

.giscus-frame {
  display: block;
  width: 100%;
  visibility: hidden;
  background: var(--background);
}

.giscus-frame.is-loaded {
  visibility: visible;
}

@media (max-width: 860px) {
  .reading-layout {
    display: block;
  }

  .sidebar-toggle {
    position: fixed;
    z-index: 31;
    top: var(--sidebar-toggle-top, calc(50dvh - 1.75rem));
    left: 0;
    display: grid;
    gap: 4px;
    place-content: center;
    width: 2.25rem;
    height: 3.5rem;
    padding: 0;
    color: var(--special-color);
    background: var(--background);
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 0.35rem 0.35rem 0;
    box-shadow: 0 4px 18px rgb(0 0 0 / 10%);
    cursor: pointer;
    touch-action: none;
    user-select: none;
    transition:
      left 220ms ease,
      background-color 160ms ease;
  }

  .sidebar-toggle.is-dragging {
    cursor: grabbing;
    transition: none;
  }

  .sidebar-toggle span {
    display: block;
    width: 0.9rem;
    height: 1px;
    background: currentColor;
    transition:
      transform 220ms ease,
      opacity 160ms ease;
  }

  .sidebar-toggle:hover,
  .sidebar-toggle:focus-visible {
    filter: brightness(1.18);
  }

  .sidebar-toggle[aria-expanded="true"] {
    left: min(19rem, calc(100vw - 3rem));
  }

  .sidebar-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(5px) rotate(45deg);
  }

  .sidebar-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
  }

  .sidebar-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-5px) rotate(-45deg);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 29;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    display: block;
    padding: 0;
    visibility: hidden;
    background: rgb(0 0 0 / 32%);
    border: 0;
    opacity: 0;
    transition:
      opacity 220ms ease,
      visibility 0s linear 220ms;
  }

  .reading-layout.sidebar-is-open .sidebar-backdrop {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
  }

  .article-sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    display: block;
    width: min(19rem, calc(100vw - 3rem));
    height: 100vh;
    height: 100dvh;
    max-height: none;
    padding:
      max(2rem, env(safe-area-inset-top))
      1.5rem
      max(2rem, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--background);
    border-right: 1px solid var(--border);
    box-shadow: 8px 0 28px rgb(0 0 0 / 10%);
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }

  .reading-layout.sidebar-is-open .article-sidebar {
    transform: translateX(0);
  }

  .sidebar-title,
  .sidebar-section {
    display: initial;
  }

  .sidebar-section {
    display: grid;
    gap: 0.65rem;
    margin-top: 2rem;
  }

  .sidebar-year-group {
    display: block;
  }

  .article-toc {
    display: grid;
    gap: 0.65rem;
  }

  .article-toc a {
    white-space: normal;
  }

  .article-toc .toc-level-2 {
    padding-left: 1rem;
  }

  .article-toc .toc-level-3 {
    padding-left: 2rem;
  }

  .article-toc .toc-level-4 {
    padding-left: 3rem;
  }

  .post {
    padding-top: 2rem;
  }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .sidebar-toggle,
  .sidebar-toggle span,
  .sidebar-backdrop,
  .article-sidebar {
    transition: none;
  }
}
