:root {
  --fg: #1a1a1a;
  --bg: #fafafa;
  --muted: #6a6a6a;
  --rule: #d8d8d8;
  --accent: #1a1a1a;
  --code-bg: #f0eee8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: Charter, "Iowan Old Style", "Iowan Old Style BT", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  max-width: 1160px;
  margin: 0 auto;
  padding: 2rem 240px 0 240px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

@media (max-width: 900px) {
  header {
    max-width: 680px;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

header a {
  color: var(--muted);
  text-decoration: none;
}

header a:hover {
  color: var(--fg);
}

article {
  max-width: 1160px;
  margin: 0 auto;
  padding: 2rem 240px 6rem 240px;
}

article h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 1.5rem 0 0.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

article > time {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.subtitle {
  font-style: italic;
  color: #555;
  font-size: 1.1em;
  margin: 0.25em 0 1.5em 0;
  line-height: 1.4;
}

article figure { margin: 1.5em 0; }
article figcaption,
article .image-caption {
  font-style: italic;
  font-size: 0.9em;
  color: #555;
  text-align: center;
  margin-top: 0.5em;
  line-height: 1.4;
}

.captioned-image-container { text-align: center; }
.captioned-image-container figure { display: inline-block; max-width: 100%; }
.captioned-image-container .image-link,
.captioned-image-container picture,
.captioned-image-container img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

article h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.75rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

article h3 {
  font-size: 1.15rem;
  margin: 2rem 0 0.5rem;
  font-weight: 600;
}

article h4 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
  font-weight: 600;
}

article p {
  margin: 1rem 0;
}

article a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

article a:hover {
  text-decoration-thickness: 2px;
}

article ul, article ol {
  padding-left: 1.5rem;
}

article li {
  margin: 0.25rem 0;
}

article blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}

article code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

article pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

article pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

article table {
  border-collapse: collapse;
  margin: 1.5rem 0;
  width: 100%;
  font-size: 0.95rem;
}

article th, article td {
  border: 1px solid var(--rule);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

article th {
  background: var(--code-bg);
  font-weight: 600;
}

article hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

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

article .footnote {
  font-size: 0.875rem;
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 3rem;
  padding-top: 1rem;
}

.archive ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive li {
  margin: 1.25rem 0;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.archive li:last-child {
  border-bottom: none;
}

.archive .post-title {
  font-size: 1.15rem;
  font-weight: 600;
  display: block;
}

.archive .post-date {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.15rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.archive .post-subtitle {
  display: block;
  color: var(--muted);
  margin-top: 0.35rem;
  font-style: italic;
}

.footnote-ref {
  font-size: 0.75em;
  line-height: 0;
}

.footnote-ref a {
  color: #888;
  text-decoration: none;
  padding: 0 0.1em;
}

.footnote-ref a:hover {
  color: var(--fg);
  text-decoration: underline;
}

.margin-note {
  float: right;
  clear: right;
  width: 220px;
  margin-right: -240px;
  margin-top: 0.2em;
  margin-bottom: 0.5em;
  font-size: 0.8em;
  line-height: 1.4;
  color: #555;
  font-style: italic;
}

.margin-note .margin-note-ref {
  margin-right: 0.25em;
  font-style: normal;
  color: #888;
}

.margin-note .math-inline {
  white-space: nowrap;
  display: inline-block;
}

.margin-note iframe {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  display: block;
  margin-top: 0.5em;
  border: 0;
}

.margin-note .youtube-wrap,
.margin-note .youtube-inner {
  width: 100%;
  max-width: 100%;
}

.footnotes { display: none; }
.footnotes ol { padding-left: 1.5em; }
.footnotes li {
  font-size: 0.9em;
  line-height: 1.5;
  margin-bottom: 0.5em;
  color: #333;
}
.footnotes li:target { background: #fff8c8; }
.footnote-backlink {
  text-decoration: none;
  color: #888;
  margin-left: 0.25em;
}

@media (max-width: 900px) {
  article {
    max-width: 680px;
    padding: 2rem 1.25rem 6rem 1.25rem;
  }
  .margin-note { display: none; }
  .footnotes { display: block; }
  .footnotes::before {
    content: "";
    display: block;
    border-top: 1px solid #ddd;
    margin: 3em 0 1em;
  }
}
