:root {
  color-scheme: light;
  --bg: #f4efe8;
  --text: #2a241d;
  --muted: #6f665c;
  --line: #d9d0c4;
  --soft: #887d70;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Source Sans 3", "Avenir Next", Avenir, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--soft);
}

.page {
  width: min(820px, calc(100vw - 24px));
  margin: 0 auto;
}

.blog-page {
  padding: 64px 0 56px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 36px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.intro h1,
.post-header h1,
.post-entry h2,
.post-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.intro h1 {
  max-width: 15ch;
  font-size: clamp(2.25rem, 4.7vw, 4rem);
}

.intro-text {
  margin: 14px 0 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 1rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.views,
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.views svg,
.like-btn svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  flex: 0 0 auto;
}

.like-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.like-btn.liked {
  color: #8c1f31;
}

.profile-wrap {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.profile-circle {
  display: block;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 1px solid var(--line);
  object-fit: cover;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.75), transparent 24%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.46), rgba(223, 214, 202, 0.92));
}

.posts {
  margin-top: 56px;
}

.section-title {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.post-entry {
  max-width: 100%;
}

.post-entry + .post-entry {
  margin-top: 22px;
}

.post-entry h2 {
  margin-top: 4px;
  font-size: clamp(1.22rem, 2.3vw, 1.65rem);
}

.post-meta {
  color: var(--muted);
  font-size: 0.94rem;
  margin-bottom: 6px;
}

.post-entry p {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 58ch;
}

hr {
  margin: 22px 0;
  border: 0;
  border-top: 1px solid var(--line);
  max-width: 100%;
}

.post-page {
  width: min(1320px, calc(100vw - 40px));
  padding: 64px 0 56px;
}

.back-link {
  display: inline-block;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.post-header {
  display: grid;
  gap: 12px;
  justify-items: start;
  margin-bottom: 26px;
}

.post-title {
  font-size: clamp(2.2rem, 4.6vw, 3.6rem);
  max-width: 14ch;
}

.article-meta {
  color: var(--muted);
  font-size: 0.95rem;
}

.post-meta-row {
  margin-top: 2px;
}

.post-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}

.toc-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
}

.toc-card {
  padding: 20px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.28));
  box-shadow: 0 1px 2px rgba(42, 36, 29, 0.05);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.toc-title {
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.toc-nav {
  display: grid;
  gap: 3px;
}

.toc-nav a {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  text-decoration: none;
  padding: 6px 0 6px 13px;
  border-left: 2px solid var(--line);
  transition: color 0.15s ease, border-color 0.15s ease, padding-left 0.15s ease;
}

.toc-nav a:hover {
  color: var(--text);
  border-left-color: var(--soft);
  padding-left: 16px;
}

.toc-card::-webkit-scrollbar {
  width: 6px;
}

.toc-card::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 6px;
}

.post-body {
  max-width: 76ch;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1.07rem;
}

.kv-post > .post-title {
  margin-bottom: 1rem;
}

.kv-intro {
  margin-bottom: 1.4rem;
}

.kv-intro p:last-child,
.kv-section p:last-child,
.kv-post blockquote p:last-child {
  margin-bottom: 0;
}

.kv-section {
  margin-top: 1.8rem;
  padding-top: 1.6rem;
  border-top: 1px solid rgba(217, 208, 196, 0.42);
}

.kv-section > h2:first-child {
  margin-top: 0;
}

.post-body p,
.post-body ul,
.post-body ol,
.post-body blockquote,
.post-body figure,
.post-body hr {
  margin: 0 0 1.05rem;
}

.post-body h2,
.post-body h3,
.post-body h4 {
  margin: 1.8rem 0 0.8rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.post-body h2 {
  font-size: 1.72rem;
}

.post-body h3 {
  font-size: 1.34rem;
}

.post-body h4 {
  font-size: 1.15rem;
}

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

.post-body blockquote {
  margin-left: 0;
  padding-left: 14px;
  border-left: 2px solid rgba(111, 102, 92, 0.26);
  color: var(--muted);
}

.post-body ul {
  padding-left: 1.25rem;
}

.post-body li + li {
  margin-top: 0.35rem;
}

.post-body figure {
  margin-left: 0;
  margin-right: 0;
}

.post-figure {
  margin: 1.35rem auto;
  text-align: center;
}

.post-figure img {
  margin: 0 auto;
  border: 1px solid rgba(217, 208, 196, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.post-body figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.post-body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.math-block,
.math-inline {
  color: #51463e;
}

.flow-diagram {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 8px 0;
}

.flow-node,
.flow-cell {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
}

.flow-node {
  min-width: min(320px, 100%);
}

.flow-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

.flow-row .flow-cell small {
  display: block;
  color: var(--muted);
}

.flow-arrows {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: min(420px, 100%);
  color: var(--muted);
  font-size: 1.05rem;
}

.heat-table-wrap {
  overflow-x: auto;
}

.heat-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.92rem;
}

.heat-table th,
.heat-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

.heat-table .row-label,
.heat-table .sum {
  background: rgba(255, 255, 255, 0.45);
  font-weight: 600;
}

.heat-1 { background: #f6efe5; }
.heat-2 { background: #eddbc5; }
.heat-3 { background: #e4c398; }
.heat-4 { background: #d9ab70; }
.heat-5 { background: #c78b42; color: #fff; }
.heat-masked { background: #e6ddd0; color: #74685c; }

.faint {
  color: var(--muted);
}

.step-list {
  padding-left: 1.1rem;
}

.step-list li + li {
  margin-top: 0.95rem;
}

.site-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 780px) {
  .intro {
    grid-template-columns: 1fr;
  }

  .profile-wrap {
    justify-content: flex-start;
  }

  .profile-circle {
    width: 180px;
    height: 180px;
  }

  .post-title {
    max-width: 100%;
  }

  .post-header {
    justify-items: start;
  }

  .post-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .toc-sidebar {
    position: static;
    order: -1;
    max-height: none;
  }

  .toc-card {
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100vw - 16px, 960px);
  }

  .blog-page,
  .post-page {
    padding-top: 24px;
  }

  .post-page {
    width: min(100vw - 16px, 960px);
  }

  .intro h1 {
    font-size: 2.05rem;
  }

  .post-body {
    font-size: 1rem;
  }

  .profile-circle {
    width: 150px;
    height: 150px;
  }

  .toc-card {
    padding: 14px;
  }
}
