:root {
  --text-color: #1b1b1b;

  /**
   * Vertical typography.
   * Align to a 18/24 px line-height.
   * Scale is 1.25.
   */
  --font-size-title: calc(1rem * 1.25 * 1.25 * 1.25);
  --font-size-header: calc(1rem * 1.25 * 1.25);
  --font-size-body: 1rem;
  --font-size-caption: calc(1rem / 1.25);
  --font-size-tiny: calc(1rem / 1.5);
  --line-height-body: calc(1rem * 1.3333);
  --line-height-caption: 1rem;

  /** https://tailwindcss.com/docs/customizing-colors */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-900: #18181b;
  --zinc-950: #09090b;

  --neutral-50: #fafafa;
  --neutral-100: #f5f5f5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-600: #525252;
  --neutral-700: #404040;
  --neutral-800: #262626;
  --neutral-900: #171717;
  --neutral-950: #0a0a0a;

  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  --stone-950: #0c0a09;

  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-200: #bae6fd;
  --sky-300: #7dd3fc;
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-700: #0369a1;
  --sky-800: #075985;
  --sky-900: #0c4a6e;
  --sky-950: #082f49;

  --yellow-50: #fefce8;
  --yellow-100: #fef9c3;
  --yellow-200: #fef08a;
  --yellow-300: #fde047;
  --yellow-400: #facc15;
  --yellow-500: #eab308;
  --yellow-600: #ca8a04;
  --yellow-700: #a16207;
  --yellow-800: #854d0e;
  --yellow-900: #713f12;
  --yellow-950: #422006;

  /** The highlight color for a reference. */
  --reference-highlight-color: rgba(255, 220, 0, 0.3);

  /* Material design elevation box shadows. The number corresponds to the
     display points of elevation. */
  /* 1 for switch, card (resting elevation), search bar (resting elevation) */
  --box-shadow-elevation-1: 0 2px 1px -1px rgba(0, 0, 0, .2), 0 1px 1px 0 rgba(0, 0, 0, .14), 0 1px 3px 0 rgba(0, 0, 0, .12);
  /* 2 for contained button (resting elevation) */
  --box-shadow-elevation-2: 0 3px 1px -2px rgba(0, 0, 0, .2), 0 2px 2px 0 rgba(0, 0, 0, .14), 0 1px 5px 0 rgba(0, 0, 0, .12);
  /* 4 for top app bar (scrolled stated and optionally resting) */
  --box-shadow-elevation-4: 0 2px 4px -1px rgba(0, 0, 0, .2), 0 4px 5px 0 rgba(0, 0, 0, .14), 0 1px 10px 0 rgba(0, 0, 0, .12);
  /* 8 for card (picked up), contained button (pressed state) bottom nav bar,
     side sheet, bottom sheet, bottom app bar, menu and sub-menus */
  --box-shadow-elevation-8: 0 5px 5px -3px rgba(0, 0, 0, .2), 0 8px 10px 1px rgba(0, 0, 0, .14), 0 3px 14px 2px rgba(0, 0, 0, .12);
  /* 16 for navigation drawer, and modal bottom sheet. */
  --box-shadow-elevation-16: 0 8px 10px -5px rgba(0, 0, 0, .2), 0 16px 24px 2px rgba(0, 0, 0, .14), 0 6px 30px 5px rgba(0, 0, 0, .12);
  /* 24 for dialogs. */
  --box-shadow-elevation-24: 0 11px 15px -7px rgba(0, 0, 0, .2), 0 24px 38px 3px rgba(0, 0, 0, .14), 0 9px 46px 8px rgba(0, 0, 0, .12);

  --max-body-width: 800px;
  --min-margin-width: 300px;

  --gutter-width: 25px;
  --toc-max-width: 250px;
}

html {
  box-sizing: border-box;
  font-size: calc(100% * 18 / 16); /* Set 1rem size to 18px. */
  line-height: var(--line-height-body);
  text-rendering: optimizeLegibility;
  font-variant-numeric: oldstyle-nums;
  font-feature-settings: "onum";
  scroll-behavior: smooth;
}

/* Options if the user hasn't opted for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  /*noinspection CssInvalidAtRule*/
  @view-transition {
    navigation: auto;
  }
}


*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  font-family: -apple-system, system-ui, BlinkMacSystemFont, segoe ui, Roboto,
  helvetica neue, Arial, sans-serif;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-color);
  max-width: var(--max-body-width);
  margin: 0 auto;
  position: relative;
}

body > header a,
body > footer a {
  font-weight: 500;
  text-decoration: none;
  color: var(--slate-500);
  padding: 0.45rem 0;
  display: block;
}

body > header a:hover,
body > footer a:hover {
  color: var(--slate-800);
}

.small-caps {
  font-variant-caps: all-small-caps;
}

body > footer {
  margin-top: 0.75rem;
}

body > main {
  background-color: #fff;
  padding-top: 1.5rem;
  padding-bottom: 6rem;
}

@media screen and (max-width: 681px) {
  html {
    font-size: calc(100% * 16 / 16); /* Set 1rem size to 16px. */
  }

  body {
    margin: 0 16px;
  }

  body > main {
    padding-top: 0;
    padding-bottom: 1.5rem;
  }

  /** Don't float the toc on mobile. Use article > to increase specificity. */
  article > .toc {
    float: none;
    max-width: max-content;
  }
}

@media screen and (min-width: 682px) {
  html {
    background-color: var(--zinc-200);
  }

  body > header,
  body > footer {
    margin-left: 16px;
    margin-right: 16px;
    margin-bottom: 0.75rem;
  }

  body > main {
    box-shadow: var(--box-shadow-elevation-4);
  }

  .main-inner-container {
    margin: 0 auto;
    width: 650px;
  }

  .article-split {
    position: relative;
    width: calc(100vw - 2 * 16px);
    max-width: 768px;
    left: 50%;
    transform: translateX(-50%);
  }
}

.article-split {
  height: 1px;
  color: #aaa;
  border: none;
  background-color: #aaa;
  margin-top: 36px;
}

body > main {
  flex: 1;
}

body > footer a {
  display: inline-block;
}

a.site-title {
  display: block;
  font-weight: 500;
}

.site-nav {
  display: flex;
  justify-content: space-between;
}

.site-nav ul {
  display: flex;
  list-style-type: none;
  justify-content: space-between;
  margin: 0;
  padding: 0;
}

.site-nav li {
  display: block;
  padding: 0 0 0 0.8em;
  margin: 0;
}

a {
  color: var(--text-color);
  text-decoration: underline;
}

a:hover {
  color: var(--slate-500);
}

h1 {
  font-size: var(--font-size-title);
  font-weight: normal;
  margin-top: 3rem;
  margin-bottom: 0.15rem;
  line-height: 1;
}

h1.title {
  margin-top: 0.45rem;
}

article > header {
  margin-top: 2em;
}

header > time {
  display: block;
  margin-top: 0.45rem;
  color: var(--gray-500);
  font-size: var(--font-size-caption);
  font-weight: 700;
  transition: color 3.5s ease;
}

header:hover > time {
  color: var(--slate-800);
  transition: color 0.35s ease;
}

h2 {
  font-size: var(--font-size-header);
  font-weight: 400;
  line-height: 1.5rem;
  margin-top: 1.8rem;
  margin-bottom: -0.3rem;
}

h3 {
  font-size: var(--font-size-body);
  font-weight: 600;
  line-height: 2.4rem;
  margin-top: 1.8rem;
  margin-bottom: -1.2rem;
}

h1 > a {
  color: #1b1b1b;
  text-decoration: none;
}

strong {
  font-weight: 600;
}

/** Highlight the header when scrolling from the TOC. */
h2:target, h3:target, h4:target, h5:target, h6:target {
  animation: reference-highlight 4s;
}

/** An <a> tag at the end of every heading. */
.heading-anchor {
  display: none;
}

/** Show the <a> tag at the end of every heading that links to the anchor
    of this heading. */
h2:hover .heading-anchor, h3:hover .heading-anchor {
  display: inline-block;
  text-decoration: none;
}

article.index-post {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  min-height: 4rem;
}

.index-post > a {
  flex: 1;
  text-decoration: none;
  padding: 0.75rem 0;
}

.index-post > time {
  padding: 0.75rem 0;
  white-space: nowrap;
  color: #767676;
  font-size: var(--font-size-caption);
}

.toc {
  float: left;
  max-width: var(--toc-max-width);
  margin-right: 32px;
  margin-top: 0.9rem;
  border: 1px solid #ccc;
  box-shadow: var(--box-shadow-elevation-2);
  padding: 4px 6px 0 12px;
  font-size: var(--font-size-caption);
}

.toc-list {
  list-style: none;
  padding-left: 12px;
  margin-top: 0;
}

.toc-list a {
  text-decoration: none; /* underlines are too heavy in a TOC */
}

/** Level 2 is the first level we show because H1 is the title. */
.toc-level-2 {
  padding-left: 0;
  margin: 0;
}

.toc-list > li {
  line-height: 1.2;
  display: flex;
}

/* The prefix like 3.2.1 before a TOC list item. */
.toc-ordering {
  margin-right: 0.6ch;
}

p, blockquote, li {
  hyphens: auto;
  hyphenate-limit-chars: 10 4 4;
  hyphenate-limit-lines: 2;
  hanging-punctuation: first last;
}

p, blockquote, .cite-reference {
  line-height: 1.5rem;
  margin-top: 0.9rem;
  margin-bottom: 0;
}

/* Indent top level paragraphs, not nested paragraphs, like those in lists. */
article > p + p {
  text-indent: 1em;
}

blockquote {
  border-left: solid 3px rgba(0, 0, 0, 0.1980392);
  padding-left: 16px;
  margin: 0;
}

@media print {
  html {
    font-size: 16px;
    line-height: 1.2rem;
  }
}

sup,
sub {
  font-size: 0.75rem;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  vertical-align: baseline;
  position: relative;
  bottom: -0.25em;
}

sup {
  vertical-align: baseline;
  position: relative;
  top: -0.4em;
}

dl,
ul,
ol {
  margin-top: 1rem;
  padding-left: 20px;
}

li > ul,
li > ol {
  margin-top: 0.45rem;
}

li, li > p {
  line-height: 1.5rem;
  margin: 0.225rem 0;
}

figure {
  margin: 24px auto 24px;
}

figure > img,
figure > picture > img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

figcaption {
  margin: 0.5em auto 0;
  padding: 0 2em;
  font-size: 16px;
}

.caption-label {
  font-weight: 500;
}

table {
  border-spacing: 0;
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  margin: 1rem auto;
}

table th {
  border-bottom: 1px solid #333;
  padding: 0.3em 0.5em 0;
}

table th:nth-child(1) {
  padding-left: 0;
}

table th:last-child {
  padding-right: 0;
}

/* Give the first row a bit of breathing room */
table tbody > tr:first-child > td {
  padding-top: 0.65ex;
}

table tbody > tr > td {
  vertical-align: top;
  padding-left: 0.5em;
  padding-right: 0.5em;
}

table tbody > tr > td:nth-child(1) {
  padding-left: 0;
}

table tbody > tr > td:last-child {
  padding-right: 0;
}

table > caption {
  text-align: left;
  caption-side: top;
  font-weight: 500;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.continue-reading {
  display: inline-flex;
  justify-content: space-between;
  text-decoration: none;
  align-items: center;
  font-size: 14px;
  margin-top: 12px;
  padding: 4px 8px 4px 10px;
  border: 1px solid #818181;
  border-radius: 2px;
  color: #686767;
  box-shadow: var(--box-shadow-elevation-2);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.continue-reading-text {
  padding-left: 5px;
}

.continue-reading svg {
  position: relative;
  left: 0;
  width: 14px;
  fill: #818181;
  transition: left 0.1s ease;
}

.continue-reading:hover {
  color: #fff;
  border-color: #3574ff;
  background-color: #3574ff;
  box-shadow: var(--box-shadow-elevation-8);
}

.continue-reading:hover svg {
  fill: #fff;
  transition: fill 0.2s ease-out;
}

thead th {
  text-align: left;
  border-bottom: 1px solid #aaa;
  font-weight: 400;
}

.code-block-container {
  position: relative;
  margin-top: .75rem;
  border: none; /* disable fieldset automatic border */
  border-top: 1px solid var(--stone-300);
  border-bottom: 1px solid var(--stone-300);
  background-color: var(--stone-50);
}

.code-block-lang {
  float: right;
  font-size: var(--font-size-tiny);
  margin-top: calc(-1.1 * var(--font-size-tiny));
  margin-right: 0.5rem;
  background-color: white;
  padding-left: 3px;
  padding-right: 3px;
  font-variant-caps: all-small-caps;
  color: var(--gray-400);
}

.code-block-info {
  display: flex;
  justify-content: flex-end;
  margin-top: -2px;
  font-size: var(--font-size-tiny);
  color: var(--gray-400);
}

.code-block-name + .code-block-description::before {
  content: ", ";
}

.code-block {
  overflow-x: visible;
  line-height: 20px;
  margin: 0;
  tab-size: 2;
  padding-left: 0;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: 15px;
  font-family: SFMono-Regular, Consolas, liberation mono, Menlo, Courier,
  monospace;
  font-variant-numeric: normal; /** don't use old style numbers for code */
  font-feature-settings: normal;
}

code {
  font-size: 15px;
  font-family: SFMono-Regular, Consolas, liberation mono, Menlo, Courier,
  monospace;
}

code-hl {
  border-left: 2px solid var(--sky-300);
  background-color: var(--sky-100);
  display: block;
}

code-kw {
  color: #d73a49;
}

code-comment {
  color: #6a737d;
}

code-str {
  color: #032f62;
}

code-fn {
  color: #6f42c1;
}

/** Previews */
#preview-box {
  position: absolute;
  border: 1px solid #ccc;
  opacity: 1;
}

#preview-box.preview-disabled {
  visibility: hidden;
}

#preview-shadow {
  position: absolute;
  opacity: 1;
  width: 100%;
  height: 100%;
  z-index: -1;
  box-shadow: var(--box-shadow-elevation-8);
  transform: translateY(-100%); /* Why do we need this? */
  transition: opacity 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

#preview-content {
  background: white;
  padding: 8px 10px;
  width: 580px;
  scroll-padding-bottom: 20px;
}

#preview-content > p:first-child {
  margin-top: 0;
}

.preview-disabled #preview-shadow {
  opacity: 0;
  transition: opacity 0s; /* Instant transition when disabling. */
}

#preview-box, #preview-box p {
  font-size: 16px;
  line-height: 22px;
}

.preview-title {
  font-weight: 500;
  margin-top: 0;
}

.footnote-body {
  font-size: var(--font-size-caption);
  padding: 5px 25px;
  border-top: solid 1px #f0e9db;
  border-bottom: solid 1px #f0e9db;
}

.footnote-body p {
  line-height: var(--line-height-caption);
}

.footnote-body > p:first-child {
  margin-top: 0;
}

@media screen and (max-width: 1399px) {
  .footnote-body {
    /*
     * We're using important because we hardcode vertical offset of the style
     * when we render the footnote using inline styles. This vertical offset
     * only applies when we have enough room to use margin notes so always
     * disable if the viewport isn't big enough for margin notes.
     */
    margin-top: var(--line-height-body) !important;
    margin-bottom: var(--line-height-body);
  }

  /**
   * Don't show citation bodies inline with text. Only show citation bodies if
   * we have enough room on the side.
   */
  .footnote-body-cite {
    display: none;
  }
}

/**
 * Add side notes if we have the max-body-width (800px) plus two margins
 * (300px). 800 + 2 * 300 = 1400.
 */
@media screen and (min-width: 1400px) {
  .footnote-body {
    position: absolute;
    left: calc(100% + var(--gutter-width));
    /*
     * Compute width from left over space after removing the body. The body is
     * at max size because we're above the breakpoint where the body stops
     * growing as the viewport width increases. Divide by 2 since there's 2
     * margins.
     */
    width: calc((100vw - var(--max-body-width)) / 2 - 50px);
    max-width: 450px;
    padding: 10px;
    background: white;
    box-shadow: var(--box-shadow-elevation-4);
  }

  .toc {
    background: white;
    position: absolute;
    left: calc(-1 * var(--toc-max-width) - var(--gutter-width));
    box-shadow: var(--box-shadow-elevation-4);
    padding: 10px;
  }
}

cite {
  display: inline-block;
  font-style: normal;
  font-variant-caps: all-small-caps;
  vertical-align: 0.1ex;
}

/** Cite node in the paragraph text of a side-note body. */
cite.cite-inline {
  margin-right: 0.8ch;
}

.cite-reference {
  padding-left: 2em;
}

@keyframes reference-highlight {
  0% {
    background: var(--reference-highlight-color);
  }
  80% {
    background: var(--reference-highlight-color);
  }
  100% {
    background: none;
  }
}

/** Highlight the reference when scrolling to it after clicking a citation. */
.cite-reference:target, cite:target {
  animation: reference-highlight 7s;
}

/** Dedent the cite numbers. */
.cite-reference > cite {
  display: inline-block;
  position: absolute;
  margin-left: -2em;
}

.cite-backlinks {
  list-style: none;
}

/** The <a> link that scrolls to the citation anchor. */
.cite-backlink-back {
  display: inline-block;
  padding-right: 0.3em;
}

/** The parent paragraph that contains the citations. */
.cite-backlink-preview {
  display: inline-block;
}

/** The citation, e.g. [1], inside a preview box. */
.cite-backlink-target {
  background: var(--reference-highlight-color);
}

.katex {
  font-size: 1.1em !important; /** default is a bit too big */
}
