:root {
  --ink: #3c3228;
  --title: #4a3424;
  --link: #8a1c2a;
  --link-hover: #4e1214;
  --cream: #eee4d2;
  --paper: #f6efe4;
  --muted: #6e6256;
  --border: #ddcfb6;
  --code-text: #3d2a1c;
  --selection: #e5d3b4;
  color-scheme: light;
}

html[data-theme="dark"] {
  --ink: #e8dfd0;
  --title: #f3eadc;
  --link: #e09088;
  --link-hover: #f0c4bc;
  --cream: #2a241c;
  --paper: #1c1814;
  --muted: #a89880;
  --border: #3d3428;
  --code-text: #edd9b8;
  --selection: #4a3a28;
  color-scheme: dark;
}

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--selection);
  color: var(--ink);
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
  background-color: transparent;
}

.title,
.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6,
.post-title,
.post-item__title,
h1 {
  color: var(--title);
}

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

.post-title.subtitle {
  color: var(--title);
}

.container {
  --page-pad: clamp(1.35rem, 5.5vw, 1.75rem);
  width: 100% !important;
  max-width: min(52rem, 100%) !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: max(var(--page-pad), env(safe-area-inset-left)) !important;
  padding-right: max(var(--page-pad), env(safe-area-inset-right)) !important;
  box-sizing: border-box;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  padding: 1.75rem 0 1.15rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.site-nav__brand {
  font-size: clamp(1.2rem, 4.2vw, 1.45rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--title);
  min-width: 0;
}

.site-nav__brand:hover {
  color: var(--link);
}

.site-nav__links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.15rem 0.35rem;
}

.site-nav__links a,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.4rem;
}

.theme-toggle {
  justify-content: center;
  width: 2.5rem;
  margin: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--link);
  background-color: transparent;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html[data-theme="light"] .theme-toggle__sun,
html[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

.viz-ball {
  fill: var(--link);
}

.site-footer {
  margin-top: 4.5rem;
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

html.is-home .site-nav {
  margin-bottom: 0;
}

.home-scene {
  position: relative;
  height: 13.75rem;
  margin: 0.85rem 0 1.75rem;
  overflow: hidden;
  background: var(--paper);
}

.home-scene picture,
.home-scene img,
.home-scene canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.home-scene img {
  opacity: 0;
  object-fit: cover;
  object-position: 28% 42%;
}

.home-scene canvas {
  image-rendering: auto;
}

html[data-theme="dark"] .home-scene img,
html[data-theme="dark"] .home-scene canvas {
  filter: invert(0.9) sepia(0.15) hue-rotate(350deg);
  mix-blend-mode: screen;
}

@media (prefers-reduced-motion: reduce) {
  .home-scene img {
    opacity: 1;
  }

  .home-scene canvas {
    display: none;
  }
}

.home-intro {
  margin-bottom: 2.25rem;
}

.home-intro p + p {
  margin-top: 0.75rem;
}

.home-more {
  margin-top: 2rem;
}

.post-title {
  margin-bottom: 0.5rem;
}

.post-content {
  margin-top: 1.5rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.post-title,
.post-item__title {
  overflow-wrap: anywhere;
}

.post-content a:hover {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.post-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.75rem;
  padding-bottom: 0.25rem;
}

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

.post-item__date,
.post-item__meta,
.post-meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.post-item__date {
  white-space: nowrap;
}

.post-item__title {
  margin-top: 0.35rem;
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--title);
}

.content img,
.content video,
.content svg,
.post-item__image {
  max-width: 100%;
  object-fit: contain;
}

.content img,
.content video,
.content svg {
  height: auto;
}

.post-item__image {
  width: 10.5rem;
  height: 7rem;
  border-radius: 6px;
  background: var(--cream);
}

.tag-list {
  color: var(--muted);
}

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

.tags__tag + .tags__tag:before {
  content: "| ";
}

.tags__tag a {
  color: var(--muted);
}

.tags__tag a:hover {
  color: var(--link);
}

code.has-jax {
  -webkit-font-smoothing: antialiased;
  background: inherit !important;
  border: none !important;
  color: inherit !important;
  font-size: 100%;
  padding: 0 !important;
}

.content :not(pre) > code {
  background: var(--cream) !important;
  color: var(--code-text) !important;
  border-radius: 4px;
  padding: 0.15em 0.4em;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

mjx-container {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.content .highlight {
  background: var(--cream) !important;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1.5rem 0;
  padding: 1.1rem 1.6rem !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.content .highlight pre,
.content pre {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.content .highlight code,
.content pre code {
  background: transparent !important;
  color: inherit;
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  line-height: 1.55;
  padding: 0 !important;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.series {
  margin-top: 0.5rem;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

.pager__link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.pager__link--disabled {
  color: var(--muted);
  pointer-events: none;
}

.notfound {
  padding: 3rem 0;
  text-align: center;
}

.content h2 {
  margin-top: 3rem;
  margin-bottom: 1.25rem;
}

.content h3 {
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.content h3:first-of-type {
  margin-top: 1rem;
}

.content blockquote {
  margin: 1.75rem 0 2rem;
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
}

.media-video {
  margin: 1.25rem 0 2.25rem;
  max-width: 40rem;
}

.media-video__frame {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  background: var(--cream);
  border-radius: 6px;
}

.media-video__frame iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.media-video__caption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.tag-filter {
  margin: 1.5rem 0;
}

.tag-filter__current {
  color: var(--muted);
  font-size: 0.92rem;
  margin: -0.5rem 0 1.5rem;
}

.post-year {
  margin: 2.25rem 0 1rem;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.post-year:first-child {
  margin-top: 0.25rem;
}

.fade-word {
  opacity: 0;
}

.title.is-3 {
  font-size: clamp(1.25rem, 3.5vw, 1.75rem);
  overflow-wrap: anywhere;
}

.pager {
  flex-wrap: wrap;
}

@media screen and (max-width: 640px) {
  .site-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    padding-top: 1.25rem;
    margin-bottom: 1.5rem;
  }

  html.is-home .site-nav {
    margin-bottom: 0;
  }

  .home-scene {
    height: 9rem;
    margin: 0.65rem 0 1.25rem;
  }

  .home-scene img {
    object-position: 50% 45%;
  }

  .site-nav__links {
    justify-content: flex-start;
    margin-left: -0.4rem;
  }

  .post-item {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .post-item__image {
    order: -1;
    width: 100%;
    height: 10.5rem;
  }

  .content .highlight {
    padding: 0.9rem 1rem !important;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
  }

  .content .highlight code,
  .content pre code {
    font-size: 0.82em;
  }

  .post-title {
    font-size: 1.45rem;
    line-height: 1.25;
  }

  .content h2 {
    margin-top: 2.25rem;
  }

  .content h3 {
    margin-top: 1.75rem;
  }

  .content table,
  mjx-container,
  .media-video {
    max-width: 100%;
  }

  .pager {
    gap: 0.5rem;
  }

  .site-footer {
    margin-top: 3rem;
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }
}
