/* Blog detail content + TOC (layout from design; body styles from ippeak; H2/H3 from design tokens) */

.blog-detail-wrap {
  width: 1280px;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 16px 80px;
  box-sizing: border-box;
}

.blog-detail-body {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  width: 100%;
}

.blog-detail-main {
  width: 780px;
  max-width: 100%;
  flex-shrink: 0;
  min-width: 0;
}

.blog-detail-main .cover-img {
  width: 100%;
  height: auto;
  max-height: 520px;
  object-fit: cover;
  margin-bottom: 40px;
  display: block;
}

.blog-detail-divider {
  width: 100%;
  height: 1px;
  background: #ebedf3;
}

/* ---------- article body ---------- */
.htmlblog {
  width: 100%;
  color: #042040;
  background: #fff;
  letter-spacing: 0;
  vertical-align: baseline;
  text-align: left;
}

.htmlblog * {
  text-wrap: wrap !important;
  color: #042040;
  text-align: left;
}

.htmlblog p,
.htmlblog span,
.htmlblog a,
.htmlblog strong,
.htmlblog b,
.htmlblog em,
.htmlblog i,
.htmlblog u,
.htmlblog s,
.htmlblog label,
.htmlblog li {
  font-size: 18px;
  line-height: 27px;
}

.htmlblog p {
  margin: 0 0 16px;
}

.htmlblog a {
  color: #007aff;
  text-decoration: underline;
  word-break: break-all;
}

.htmlblog a:hover {
  color: #1663d4;
}

/* 覆盖 Tailwind Preflight 对 ul/ol 的 list-style:none / padding:0 */
.htmlblog ul,
.htmlblog ol {
  margin: 0 0 16px !important;
  padding-left: 28px !important;
  list-style-position: outside !important;
}

.htmlblog ul {
  list-style-type: disc !important;
}

.htmlblog ol {
  list-style-type: decimal !important;
}

.htmlblog ul ul {
  list-style-type: circle !important;
  margin-bottom: 0 !important;
}

.htmlblog ul ul ul {
  list-style-type: square !important;
}

.htmlblog ol ol {
  list-style-type: lower-alpha !important;
  margin-bottom: 0 !important;
}

.htmlblog li {
  margin: 6px 0;
  padding-left: 4px;
  display: list-item !important;
  list-style: inherit !important;
}

.htmlblog li > p {
  margin-bottom: 0;
}

.htmlblog pre {
  margin: 16px 0;
  padding: 16px 20px;
  overflow-x: auto;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 14px;
  line-height: 22px;
  color: #16191c;
  text-wrap: nowrap !important;
  box-sizing: border-box;
}

.htmlblog pre,
.htmlblog pre * {
  color: #16191c !important;
  font-size: 14px !important;
  line-height: 22px !important;
  font-family: Consolas, Monaco, "Courier New", monospace !important;
}

.htmlblog pre code {
  display: block;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  white-space: pre;
}

.htmlblog code {
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 14px;
  line-height: 22px;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 2px 6px;
  color: #16191c;
}

.htmlblog h2,
.htmlblog h3 {
  scroll-margin-top: var(--blog-header-offset, 134px);
  text-align: left;
}

/* 标题含内部 span：压过 .htmlblog span 默认 18px，以及编辑器残留的 inline 16px */
.htmlblog h1,
.htmlblog h1 span {
  font-size: 32px !important;
  line-height: 42px !important;
  font-weight: 600;
  color: #042040;
  margin-top: 32px;
  margin-bottom: 16px;
}

.htmlblog h1 span {
  margin: 0;
}

/* Figure 2 */
.htmlblog h2,
.htmlblog h2 span {
  font-weight: 600;
  font-size: 24px !important;
  color: #042040;
  line-height: 33px !important;
  margin-top: 32px;
  margin-bottom: 16px;
}

.htmlblog h2 span {
  margin: 0;
}

/* Figure 3 */
.htmlblog h3,
.htmlblog h3 span {
  font-weight: 600;
  font-size: 20px !important;
  color: #042040;
  line-height: 28px !important;
  margin-top: 16px;
  margin-bottom: 8px;
}

.htmlblog h3 span {
  margin: 0;
}

.htmlblog strong,
.htmlblog b {
  font-size: inherit;
}

.htmlblog table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  display: table;
}

.htmlblog th,
.htmlblog td {
  border: 1px solid #d1d5db;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 28px;
  vertical-align: middle;
  word-break: break-word;
}

.htmlblog th {
  font-weight: 600;
  background: #f9fafb;
  text-align: center;
}

.htmlblog td {
  text-align: left;
}

.htmlblog blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid #007aff;
  background: #f9fafb;
  color: #55687d;
}

.htmlblog img {
  max-width: 100%;
  height: auto;
}
.htmlblog pre,
.htmlblog code {
  background-color: #f5f5f7 !important;
}
/* ---------- TOC (Figure 1) ---------- */
.toc-aside {
  width: 300px;
  max-width: 100%;
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: sticky;
  top: var(--blog-header-offset, 134px);
  max-height: calc(100vh - var(--blog-header-offset, 134px) - 24px);
  display: none;
  flex-direction: column;
  align-self: flex-start;
  z-index: 2;
}

.toc-aside.is-ready {
  display: flex;
}

.toc-title {
  font-family: PingFangSC, "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  color: #042040;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.toc-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-left: 5px;
  margin-left: -5px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.toc-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

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

.toc-list {
  position: relative;
  border-left: 1px solid #ebedf3;
}

.toc-link {
  display: block;
  position: relative;
  padding: 6px 12px 6px 16px;
  font-size: 14px;
  line-height: 22px;
  color: #042040 !important;
  text-decoration: none;
  transition: color 0.2s ease, background-color 0.2s ease;
  word-break: break-word;
  cursor: pointer;
}

.toc-link.is-h3 {
  padding-left: 28px;
  color: #55687d !important;
}

.toc-link:hover {
  color: #007aff;
}

.toc-link.active {
  color: #007aff;
  background: #f0f7ff;
}

.toc-link.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #007aff;
}

@media (min-width: 1024px) {
  .toc-aside.is-ready {
    display: flex;
  }
}

@media (max-width: 1023px) {
  .blog-detail-wrap {
    width: 100%;
    padding: 0 16px 60px;
  }

  .blog-detail-body {
    flex-direction: column;
  }

  .blog-detail-main {
    width: 100%;
  }

  .toc-aside {
    display: none !important;
  }

  .htmlblog p,
  .htmlblog span,
  .htmlblog a,
  .htmlblog strong,
  .htmlblog b,
  .htmlblog em,
  .htmlblog i,
  .htmlblog u,
  .htmlblog s,
  .htmlblog label,
  .htmlblog li {
    font-size: 16px;
    line-height: 26px;
  }

  .htmlblog h2,
  .htmlblog h2 span {
    font-size: 22px !important;
    line-height: 30px !important;
    margin-top: 24px;
    margin-bottom: 12px;
  }

  .htmlblog h2 span {
    margin: 0;
  }

  .htmlblog h3,
  .htmlblog h3 span {
    font-size: 18px !important;
    line-height: 26px !important;
  }

  .htmlblog h3 span {
    margin: 0;
  }

  .htmlblog table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
