.post-page {
  --type-page-title: 2rem;
  --type-article-title: 1.5rem;
  --type-section-title: 1.125rem;
  --type-brand: 1.25rem;
  --type-body: 0.9375rem;
  --type-supporting: 0.875rem;
  --type-caption: 0.8125rem;
  --type-micro: 0.75rem;
}

.post-layout {
  display: grid;
  grid-template-columns: 30% 70%;
  align-items: start;
  width: min(100%, 960px);
  min-height: 100vh;
  margin: 0 auto;
}

.article-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--canvas);
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.55rem;
  margin: 28px 32px 0;
  font-size: var(--type-brand);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.sidebar-brand img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.3rem 1.25rem 0.6rem 0.5rem;
  color: var(--ink-muted);
  font-size: var(--type-caption);
  font-variant-numeric: tabular-nums;
}

.sidebar-close {
  display: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--control);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  place-items: center;
}

.sidebar-outline {
  min-height: 0;
  padding: 0 0.5rem 2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.sidebar-outline ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-outline a {
  display: grid;
  grid-template-columns: 1.75rem minmax(0, 1fr);
  gap: 0.2rem;
  padding: 0.38rem 0;
  color: var(--ink);
  font-size: var(--type-body);
  font-weight: 600;
  line-height: 1.45;
  text-decoration: none;
  transition: color 120ms ease-out;
}

.sidebar-outline a::before {
  color: var(--ink-muted);
  content: attr(data-number);
  font-size: var(--type-micro);
  font-variant-numeric: tabular-nums;
  line-height: 1.85;
}

.sidebar-outline a:hover,
.sidebar-outline a.active {
  color: var(--active);
}

.sidebar-outline a.active::before {
  color: var(--active);
}

.sidebar-overlay,
.mobile-reader-nav {
  display: none;
}

.issue-column {
  width: min(100%, 670px);
  min-width: 0;
  margin: 0 auto;
  padding: 28px 32px 4rem;
}

.issue-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.issue-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: var(--type-page-title);
  font-weight: 700;
  line-height: 1.2;
}

.issue-heading > p {
  margin: 0.45rem 0 0;
  color: var(--ink-muted);
  font-size: var(--type-supporting);
  font-variant-numeric: tabular-nums;
}

.issue-home {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--control);
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  text-decoration: none;
  place-items: center;
  transition: color 120ms ease-out, background 120ms ease-out;
}

.issue-home:hover {
  background: var(--paper-raised);
  color: var(--link);
}

.issue-caption {
  margin: 1.75rem 0 0;
  color: var(--ink-soft);
  font-size: var(--type-body);
  line-height: 1.75;
  text-align: center;
}

.post-content {
  width: 100%;
  margin: 0;
  padding: 0.4rem 0 0;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.78;
}

.post-content > h2 {
  margin: 3.5rem 0 0.65rem;
  scroll-margin-top: 2rem;
  color: var(--ink);
  font-size: var(--type-article-title);
  font-weight: 700;
  line-height: 1.45;
}

.post-content > h2::before {
  display: block;
  margin-bottom: 0.05rem;
  color: var(--active);
  content: "第 " attr(data-number) " 篇";
  font-size: var(--type-caption);
  font-weight: 600;
  line-height: 1.4;
}

.post-content h3,
.post-content h4 {
  margin: 2.2rem 0 0.65rem;
  color: var(--ink);
  line-height: 1.5;
}

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

.post-content > h2 + p {
  margin-top: -0.2rem;
  color: var(--ink-muted);
  font-size: var(--type-supporting);
  line-height: 1.55;
}

.post-content .article-meta-row {
  font-size: var(--type-body);
  line-height: 1.6;
}

.post-content strong {
  color: var(--ink);
  font-weight: 700;
}

.post-content a {
  color: var(--link);
  overflow-wrap: anywhere;
  text-decoration: none;
}

.post-content a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.post-content .description-heading {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.45rem;
  margin: 0 0 0.4rem;
}

.post-content .description-heading > strong {
  flex: 0 0 auto;
}

.post-content .content-heading {
  font-size: var(--type-section-title);
  line-height: 1.5;
}

.post-content .content-heading > strong {
  font-weight: 750;
  letter-spacing: 0.025em;
}

.post-content .content-detail {
  font-size: var(--type-body);
  line-height: 1.82;
}

.post-content .description-heading:has(.summary-provenance__details[open]) {
  z-index: 12;
}

.post-content .summary-provenance {
  margin: 0;
  padding: 0;
  color: var(--ink-muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.post-content .summary-provenance__status {
  color: var(--provenance-link);
  font-style: italic;
  font-weight: 520;
}

.summary-provenance__details {
  display: block;
  width: fit-content;
  max-width: 100%;
}

.summary-provenance__details summary {
  display: block;
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
  list-style: none;
}

.summary-provenance__action {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, currentColor 40%, transparent);
  text-underline-offset: 0.18em;
}

.summary-provenance__details summary::-webkit-details-marker {
  display: none;
}

.summary-provenance__action::after {
  margin-left: 0.22rem;
  font-size: 0.72em;
  content: "▾";
  transition: transform 160ms ease-out;
}

.summary-provenance__details[open] .summary-provenance__action::after {
  transform: rotate(180deg);
}

.summary-provenance__details summary:hover .summary-provenance__status {
  color: var(--provenance-ink);
}

.summary-provenance__details summary:hover .summary-provenance__action {
  text-decoration-color: currentColor;
}

.summary-provenance__details summary:focus-visible {
  outline: none;
}

.summary-provenance__details summary:focus-visible .summary-provenance__action {
  border-radius: 2px;
  background: color-mix(in oklch, var(--focus) 12%, transparent);
  color: var(--provenance-ink);
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

.summary-provenance__sources {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  display: grid;
  gap: 0.12rem;
  box-sizing: border-box;
  width: min(25rem, calc(100vw - 2rem));
  max-height: min(22rem, 60vh);
  margin: 0;
  padding: 0.35rem;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow-hover);
  line-height: 1.3;
  list-style: none;
}

.post-content .summary-provenance__sources li {
  display: block;
  margin: 0;
}

.post-content .summary-provenance__sources a {
  display: block;
  padding: 0.42rem 0.5rem;
  border-radius: 6px;
  color: var(--ink-soft);
  font-style: normal;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.post-content .summary-provenance__sources a:hover {
  background: var(--control);
  color: var(--ink);
  text-decoration: none;
}

.summary-provenance__source-name {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--provenance-link);
  font-size: 0.8rem;
  font-weight: 650;
}

.summary-provenance__source-description {
  display: -webkit-box;
  margin-top: 0.08rem;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 0.72rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.post-content .hn-discussion-row {
  margin: 1.15rem 0 0;
}

.hn-discussion-label {
  font-style: normal;
}

.post-content a.hn-discussion-link {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  min-height: auto;
  padding: 0.2rem 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--type-caption);
  font-weight: 550;
  line-height: 1.4;
  text-decoration: none;
  transition: color 120ms ease-out;
}

.post-content a.hn-discussion-link::before {
  display: inline-block;
  min-width: auto;
  height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--active);
  content: "HN";
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.post-content a.hn-discussion-link::after {
  color: var(--ink-muted);
  content: "↗";
  font-size: 0.9em;
}

.post-content a.hn-discussion-link:hover {
  background: transparent;
  color: var(--ink-soft);
  text-decoration: underline;
  text-decoration-color: color-mix(in oklch, currentColor 45%, transparent);
}

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 0.55rem 0.85rem;
  border-left: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink-soft);
}

.post-content ul,
.post-content ol {
  padding-left: 1.35rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

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

.post-content > hr:last-child {
  display: none;
}

.post-content code {
  padding: 0.12em 0.32em;
  border-radius: 4px;
  background: var(--paper-raised);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
}

.post-content pre {
  max-width: 100%;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 8px;
  background: var(--paper-raised);
  line-height: 1.6;
}

.post-content pre code {
  padding: 0;
  background: transparent;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-card);
}

.post-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: var(--type-caption);
}

.post-footer a {
  color: var(--link);
  text-decoration: none;
}

.post-footer > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.post-footer .footer-credit {
  margin: 0;
}

.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 40;
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--control);
  box-shadow: var(--shadow-card);
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  place-items: center;
  transform: translateY(0.5rem);
  transition: opacity 150ms ease-out, transform 150ms ease-out, color 150ms ease-out;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  color: var(--link);
}

@media (max-width: 900px) {
  .post-page {
    --type-page-title: 1.75rem;
    --type-article-title: 1.4375rem;
  }

  .post-layout {
    display: block;
  }

  .article-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 70;
    width: min(calc(100vw - 4.5rem), 320px);
    height: 100dvh;
    box-shadow: 16px 0 28px -12px oklch(8% 0.006 250 / 0.35);
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
  }

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

  .sidebar-brand {
    width: calc(100% - 4.75rem);
    min-width: 0;
    margin: 22px 20px 0;
    font-size: var(--type-brand);
  }

  .sidebar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-meta {
    margin-right: 4rem;
    margin-left: 0.75rem;
  }

  .sidebar-close {
    position: absolute;
    top: 20px;
    right: 16px;
    display: grid;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: block;
    border: 0;
    background: rgb(12 18 24 / 0.34);
    -webkit-backdrop-filter: blur(1.5px);
    backdrop-filter: blur(1.5px);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease-out;
  }

  .sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .post-page.has-sidebar-open {
    overflow: hidden;
  }

  .issue-column {
    width: 100%;
    padding: 0 1rem 3rem;
  }

  .mobile-reader-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 68px;
    margin: 0 -1rem;
    padding: 0.65rem 1rem;
    background: color-mix(in oklch, var(--canvas) 94%, transparent);
  }

  .mobile-brand {
    flex: 0 0 auto;
    height: 32px;
  }

  .mobile-brand img {
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 7px;
  }

  .current-chapter {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    align-items: baseline;
    gap: 0.55rem;
  }

  .current-position {
    flex: 0 0 auto;
    color: var(--active);
    font-size: var(--type-micro);
    font-variant-numeric: tabular-nums;
  }

  .current-title {
    overflow: hidden;
    color: var(--ink);
    font-size: var(--type-supporting);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-open {
    display: grid;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--control);
    color: var(--ink);
    cursor: pointer;
    font-size: var(--type-supporting);
    place-items: center;
  }

  .issue-heading {
    padding-top: 0.75rem;
  }

  .issue-home {
    display: none;
  }

  .issue-heading h1 {
    font-size: var(--type-page-title);
  }

  .post-content > h2 {
    scroll-margin-top: 5rem;
  }
}

@media (max-width: 640px) {
  .post-page {
    --type-page-title: 1.625rem;
    --type-article-title: 1.375rem;
  }

  .issue-caption {
    text-align: left;
  }

  .post-content > h2 {
    margin-top: 3rem;
    font-size: var(--type-article-title);
  }

  .post-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
