:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #111827;
  --sub: #6b7280;
  --line: #e5e7eb;
  --primary: #5b5bd6;
  --primary-2: #19b7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #eef2ff 0%, var(--bg) 45%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Inter", Arial, sans-serif;
  line-height: 1.65;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
  background: rgba(246, 248, 251, 0.86);
  border-bottom: 1px solid var(--line);
}

.site-nav {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--text);
  text-decoration: none;
}

.site-nav-links {
  display: flex;
  gap: 10px;
}

.site-nav-links a {
  color: #334155;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 999px;
  transition: background 0.2s ease;
}

.site-nav-links a:hover {
  background: #e2e8f0;
}

.site-main {
  max-width: 1240px;
  margin: 28px auto 20px;
  padding: 0 20px;
}

.hero-section,
.list-section,
.post-article,
.readmore-box,
.thoughts-section,
.about-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.04);
}

.hero-section {
  margin-bottom: 18px;
}

.hero-section h1 {
  margin: 0 0 8px;
  font-size: 36px;
  line-height: 1.2;
}

.hero-section p {
  margin: 0;
  color: var(--sub);
}

.hero-cta {
  display: inline-block;
  margin-top: 14px;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 600;
}

.list-section h2,
.thoughts-section h1,
.about-section h1,
.post-article h1,
.readmore-box h2 {
  margin-top: 0;
}

.latest-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  content-visibility: auto;
  contain-intrinsic-size: 800px;
}

.latest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
}

.latest-main h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.latest-main a {
  color: #0f172a;
  text-decoration: none;
}

.latest-main a:hover {
  color: var(--primary);
}

.latest-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.latest-author,
.latest-main time {
  color: var(--sub);
  font-size: 13px;
}

.latest-thumb {
  flex: 0 0 88px;
  width: 88px;
  height: 56px;
  border-radius: 8px;
  background: #e2e8f0;
  overflow: hidden;
  display: block;
}

.latest-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thoughts-section,
.about-section,
.post-article {
  max-width: 980px;
  margin: 0 auto 16px;
}

.post-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
}

.post-main {
  min-width: 0;
}

.post-toc {
  position: sticky;
  top: 82px;
  align-self: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  max-height: calc(100vh - 98px);
  overflow-y: auto;
}

.post-toc h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

#post-toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

#post-toc-list li {
  margin: 0;
}

#post-toc-list a {
  display: block;
  text-decoration: none;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
  padding: 6px 8px;
  border-radius: 8px;
}

#post-toc-list a:hover {
  background: #f1f5f9;
  color: #0f172a;
}

#post-toc-list a.active {
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
  border-left: 3px solid #2563eb;
}

#post-toc-list a.toc-h2 {
  padding-left: 16px;
}

#post-toc-list a.toc-h3 {
  padding-left: 26px;
}

.thoughts-section {
  content-visibility: auto;
  contain-intrinsic-size: 1000px;
}

.thought-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  overflow: hidden;
}

.thought-item * {
  max-width: 100%;
}

.thought-item .katex,
.thought-item .katex * {
  max-width: none !important;
}

.thought-item p,
.thought-item li,
.thought-item a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.thought-item img,
.thought-item video,
.thought-item iframe {
  max-width: 100%;
  height: auto;
}

.thought-item pre {
  max-width: 100%;
  overflow-x: auto;
}

.thought-item table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.katex {
  font-size: 1.02em;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

.thoughts-section hr {
  border: 0;
  border-top: 1px dashed #d1d5db;
  margin: 12px 0;
}

.post-content {
  color: #1f2937;
}

/* Markdown / Ghost: never stretch — width caps to column, height follows aspect ratio */
.post-content img,
.post-content picture img,
.post-content .kg-image-card img,
.post-content .kg-image-card .kg-image,
.post-content figure.kg-image-card img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

.post-content .kg-image-card img,
.post-content figure.kg-image-card img {
  display: block;
}

.post-content .kg-image-card a {
  display: block;
  max-width: 100%;
}

.post-content figure {
  margin: 1em 0;
}

.post-content figure.kg-image-card {
  display: block;
}

.post-article {
  position: relative;
}

.post-font-switcher {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  z-index: 2;
}

.post-font-switcher span {
  color: var(--sub);
  font-size: 12px;
}

.post-font-switcher button {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
}

.post-font-switcher button.active {
  border-color: #4f46e5;
  color: #312e81;
  background: #e0e7ff;
  font-weight: 600;
}

.post-content.post-font-sm {
  font-size: 15px;
}

.post-content.post-font-md {
  font-size: 17px;
}

.post-content.post-font-lg {
  font-size: 20px;
}

.post-content.post-font-xl {
  font-size: 24px;
}

.readmore-box {
  max-width: 980px;
  margin: 0 auto;
}

.readmore-list p {
  margin: 10px 0;
}

.readmore-list a {
  color: #334155;
  text-decoration: none;
}

.readmore-list a:hover {
  color: var(--primary);
}

.about-section p {
  color: #374151;
}

.site-footer {
  text-align: center;
  color: var(--sub);
  font-size: 13px;
  padding: 18px 0 28px;
}

@media (max-width: 980px) {
  .post-layout {
    grid-template-columns: 1fr;
  }

  .post-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .site-main {
    padding: 0 14px;
    margin-top: 20px;
  }

  .hero-section,
  .list-section,
  .post-article,
  .readmore-box,
  .thoughts-section,
  .about-section {
    padding: 18px;
    border-radius: 14px;
  }

  .hero-section h1 {
    font-size: 30px;
  }

  .latest-item {
    align-items: flex-start;
  }
}

@media (max-width: 760px) {
  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .site-nav-links {
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
  }

  .site-nav-links a {
    display: inline-block;
  }

  .hero-section h1 {
    font-size: 26px;
  }

  .latest-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 10px;
  }

  .latest-main h3 {
    font-size: 16px;
  }

  .latest-meta {
    flex-wrap: wrap;
    gap: 6px 10px;
  }

  .post-article h1 {
    font-size: 24px;
    line-height: 1.25;
    margin-top: 34px;
  }

  .post-content {
    font-size: 16px;
  }

  .post-font-switcher {
    position: static;
    margin-bottom: 8px;
    width: fit-content;
  }

  .thought-item {
    padding: 12px;
  }
}

@media (max-width: 480px) {
  .site-nav {
    padding: 12px 14px;
  }

  .site-main {
    padding: 0 10px;
    margin-top: 14px;
  }

  .hero-section,
  .list-section,
  .post-article,
  .readmore-box,
  .thoughts-section,
  .about-section {
    padding: 14px;
    border-radius: 12px;
  }

  .hero-section h1 {
    font-size: 22px;
  }

  .hero-cta {
    width: 100%;
    text-align: center;
  }

  .latest-item {
    grid-template-columns: 1fr;
  }

  .latest-thumb {
    width: 100%;
    height: 160px;
  }

  .post-toc {
    padding: 10px;
  }

  .post-font-switcher {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    border-radius: 12px;
  }

  #post-toc-list a {
    font-size: 12px;
    padding: 5px 6px;
  }
}
