:root {
  --text: #111;
  --muted: #555;
  --line: #ddd;
  --line-strong: #bbb;
  --link: #0033aa;
  --bg: #fff;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --serif: "EB Garamond", Garamond, "Adobe Garamond Pro", "Times New Roman", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-optical-sizing: auto;
  line-height: 1.75;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

code,
pre,
.mono {
  font-family: var(--mono);
}

code {
  font-size: 0.92em;
}

pre {
  overflow-x: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  background: #fafafa;
}

pre code {
  background: transparent;
}

.page-shell {
  width: min(52rem, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.site-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-strong);
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.site-title,
.page-title,
.post-title,
.year-group-header h2 {
  margin: 0;
  line-height: 1.25;
  font-weight: 600;
}

.site-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.site-title a,
.entry-body a {
  color: inherit;
}

.site-title a {
  text-decoration: none;
}

.site-title a:hover {
  text-decoration: none;
}

.site-about-link {
  margin: 0;
  flex: 0 0 auto;
}

.site-about-link a {
  color: var(--muted);
  text-decoration: none;
}

.site-about-link a:hover {
  color: var(--text);
  text-decoration: underline;
}

.entry-date,
.entry-meta,
.footnotes {
  margin: 0;
}

.entry-meta {
  color: var(--muted);
}

.page-header,
.post-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.post-title {
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
}

.post-content,
.page-content {
  font-size: 1rem;
}

.post-content > :first-child,
.page-content > :first-child {
  margin-top: 0;
}

.post-content > :last-child,
.page-content > :last-child {
  margin-bottom: 0;
}

.post-content h1,
.post-content h2,
.post-content h3,
.page-content h1,
.page-content h2,
.page-content h3 {
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

.post-content p,
.page-content p,
.post-content ul,
.page-content ul,
.post-content ol,
.page-content ol,
.post-content blockquote,
.page-content blockquote {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.post-content blockquote,
.page-content blockquote {
  padding-left: 1rem;
  border-left: 2px solid var(--line-strong);
}

.post-content blockquote cite,
.page-content blockquote cite {
  display: block;
  margin-top: 0.45rem;
  color: var(--muted);
  text-align: right;
}

.post-content blockquote cite a,
.page-content blockquote cite a {
  color: inherit;
}

.post-content figure,
.page-content figure {
  margin: 1.5rem 0;
}

.post-figure figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.embed-card {
  margin: 1.25rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--line-strong);
}

.embed-card-link {
  color: inherit;
  text-decoration: none;
}

.embed-card-link:hover {
  text-decoration: none;
}

.embed-card-site,
.embed-card-url,
.embed-card-description {
  display: block;
}

.embed-card-site,
.embed-card-url {
  color: var(--muted);
  font-size: 0.88rem;
}

.embed-card-title {
  display: block;
  font-weight: 600;
}

.embed-card-description {
  margin-top: 0.2rem;
}

.embed-video {
  margin: 1.25rem 0;
}

.embed-video iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
}

.twitter-tweet {
  margin: 1.25rem 0;
}

.year-group + .year-group {
  margin-top: 2rem;
}

.year-group-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: baseline;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.entry-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.entry-item {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.entry-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.footnotes {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}

.katex-display {
  margin: 1.2rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100vw - 1rem, 52rem);
    padding-top: 1.25rem;
  }

  .masthead {
    display: block;
  }

  .site-about-link {
    margin-top: 0.5rem;
  }

  .entry-item {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
}
