@font-face {
  font-family: "Libertinus Math";
  src: url("../fonts/LibertinusMath-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

body {
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --fg: #1d2330;
  --fg-muted: #5c6575;
  --border: #e1e5eb;
  --rule: #1d2330;
  --accent: #3451b2;
  --nav-bg: rgba(255, 255, 255, 0.92);
}

body:has(#theme-toggle:checked) {
  --bg: #111418;
  --bg-soft: #1a1e24;
  --fg: #e3e6eb;
  --fg-muted: #9ba3af;
  --border: #2b3139;
  --rule: #c9ced6;
  --accent: #8ea4f0;
  --nav-bg: rgba(17, 20, 24, 0.92);
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 4rem;
}

html, body {
  margin: 0;
}

body {
  color: var(--fg);
  background-color: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
}

.nowrap {
  white-space: nowrap;
}

.main {
  display: flex;
  justify-content: center;
  margin: 0 1rem 4rem;
}

.content {
  width: 100%;
  min-width: 0;
  max-width: 1200px;
  padding: 0 1rem;
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  column-gap: 1.4rem;
  row-gap: 0.3rem;
  margin: 0 -1rem;
  padding: 0.7rem 1rem;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  font-weight: 500;
}

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

.navbar a:hover {
  color: var(--accent);
  text-decoration: none;
}

.theme-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-button {
  display: inline-flex;
  cursor: pointer;
  color: var(--fg-muted);
}

.theme-button:hover {
  color: var(--accent);
}

.theme-button svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.navbar:has(.theme-toggle:focus-visible) .theme-button {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.icon-sun {
  display: none;
}

body:has(#theme-toggle:checked) .icon-sun {
  display: block;
}

body:has(#theme-toggle:checked) .icon-moon {
  display: none;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 2.25rem 0 2rem;
  border-bottom: 1px solid var(--border);
}

.logoleft, .logoright {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.logoleft br, .logoright br {
  display: none;
}

.logoleft > img, .logoright > img {
  height: 72px;
  width: auto;
  margin: 0;
  padding: 5px;
  border-radius: 8px;
  background-color: #ffffff;
}

.title {
  flex: 1 1 auto;
  text-align: center;
}

.content .title h1 {
  margin: 0;
  padding: 0;
  border: none;
  color: var(--accent);
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.author {
  margin-top: 1.1rem;
}

.author p {
  margin: 0.25rem 0;
  font-size: 1.05rem;
  font-weight: 500;
}

.author small {
  color: var(--fg-muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.content h1 {
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.4rem;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--border);
}

.content h1 a, .content h2 a {
  color: inherit;
}

.content h1 a:hover, .content h2 a:hover {
  text-decoration: none;
}

.content h2 {
  margin: 2rem 0 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.content h3 {
  margin: 0.5rem 0;
  font-size: 1rem;
  font-weight: 400;
}

.content h3 strong {
  font-weight: 600;
}

p {
  margin: 0.75rem 0;
}

ul {
  padding-left: 1.3rem;
  margin: 0.7rem 0 1.4rem;
}

ul li {
  margin-bottom: 0.6rem;
}

ul li::marker {
  color: var(--accent);
}

ul li p {
  display: inline;
}

blockquote {
  margin: 1rem 0;
  padding: 0.25rem 1rem;
  color: var(--fg-muted);
  border-left: 3px solid var(--accent);
}

code, pre {
  font-family: ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
}

code {
  font-size: 0.86em;
}

:not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

p code, li code, h3 code {
  overflow-wrap: anywhere;
}

pre {
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
}

div.highlighter-rouge {
  margin: 1rem 0;
}

div.highlighter-rouge pre.highlight {
  margin: 0;
}

math {
  font-family: "Libertinus Math", math;
  font-size: 1.08em;
}

.equation {
  margin: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  margin: 1.25rem auto;
  border-collapse: collapse;
  border-top: 2px solid var(--rule);
  border-bottom: 2px solid var(--rule);
  font-size: 0.9rem;
}

table th {
  padding: 0.5rem 0.85rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
  white-space: nowrap;
}

table td {
  padding: 0.4rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

table tbody tr:last-child td {
  border-bottom: none;
}

table tbody + tbody tr:first-child td {
  border-top: 1px solid var(--rule);
}

table code {
  white-space: nowrap;
}

table.relations {
  font-size: 0.95rem;
}

table.relations td {
  padding: 0.5rem 1rem;
}

table.relations td:nth-child(-n+2) {
  white-space: nowrap;
}

.table-wrapper {
  overflow-x: auto;
  margin: auto;
}

details {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
}

details > summary {
  cursor: pointer;
  padding: 0.6rem 1rem;
  color: var(--accent);
  font-weight: 500;
}

details[open] > summary {
  border-bottom: 1px solid var(--border);
}

details div.highlighter-rouge {
  margin: 0;
}

details pre {
  margin: 0;
  border: none;
  border-radius: 0 0 6px 6px;
}

figure {
  margin: 0;
}

figcaption {
  margin-top: 0.45rem;
  color: var(--fg-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.5rem 1.25rem;
  margin: 1rem 0 1.75rem;
}

.gallery img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: contain;
  margin: 0;
  padding: 4px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.gallery .wide {
  grid-column: span 2;
}

figure.example {
  max-width: 320px;
  margin: 1.25rem auto;
}

figure.example img {
  display: block;
  width: 100%;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
}

figure.pipeline {
  margin: 1.25rem 0;
}

figure.pipeline img {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.digit {
  margin: 0;
}

.heading {
  display: inline-block;
  width: 100%;
  margin-top: 2px;
  padding: 4px 17px 4px 15px;
  font-size: 180%;
  font-weight: 800;
  text-align: center;
  color: white;
}

.blue {
  background-color: rgb(0, 123, 167);
}

.red {
  background-color: rgb(238, 20, 102);
}

footer {
  width: 100%;
  text-align: center;
  color: var(--fg-muted);
}

footer p {
  font-style: italic;
}

@media screen and (max-width: 768px) {
  body {
    font-size: 16px;
  }

  .main {
    margin: 0 0 3rem;
  }

  .navbar {
    justify-content: center;
    column-gap: 0.9rem;
  }

  .header {
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem 0;
  }

  .logoleft, .logoright {
    flex-direction: row;
  }

  .logoleft > img, .logoright > img {
    height: 56px;
  }

  .logoright {
    order: 3;
  }

  .content .title h1 {
    font-size: 1.6rem;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .gallery .wide {
    grid-column: 1 / -1;
  }
}

/* MNIST-style contribution marks next to author names */
img.mnist {
  height: 0.85em;
  width: auto;
  margin-left: 0.12em;
  vertical-align: super;
  border-radius: 2px;
}

.author .contrib small img.mnist {
  vertical-align: -0.1em;
  margin: 0 0.25em 0 0.6em;
}
