:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --code-bg: #f1efe9;
  --text: #1c1d21;
  --muted: #565a61;
  --border: #dcd8cf;
  --rule: #1c1d21;
  --accent: #1f4e8c;
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style", Georgia, "Noto Serif", "Liberation Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171b;
    --surface: #1c1f24;
    --code-bg: #1e2127;
    --text: #e5e4e0;
    --muted: #a7aab0;
    --border: #30343b;
    --rule: #c9c8c4;
    --accent: #93b6ec;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15171b;
  --surface: #1c1f24;
  --code-bg: #1e2127;
  --text: #e5e4e0;
  --muted: #a7aab0;
  --border: #30343b;
  --rule: #c9c8c4;
  --accent: #93b6ec;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: 42rem;
  padding: 0 1.25rem;
  background: var(--bg);
  color: var(--text);
  font: 1.125rem/1.6 var(--serif);
  font-kerning: normal;
  font-variant-numeric: oldstyle-nums proportional-nums;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.9rem;
}

.skip-link:focus {
  top: 1rem;
}

/* Header and footer */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.site-name {
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
}

.site-header nav {
  margin-left: auto;
}

.site-header ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

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

.site-header nav a:hover,
.site-header nav a[aria-current="page"] {
  color: var(--text);
}

.site-header nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 0.35em;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.theme-toggle[hidden] {
  display: none;
}

.site-footer {
  margin-top: 1rem;
  padding: 1.25rem 0 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.7;
}

.site-footer p {
  margin: 0;
}

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

.site-footer a:hover {
  color: var(--text);
}

/* General text */

main {
  padding: 2.5rem 0 3rem;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  letter-spacing: -0.01em;
}

h2 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.3rem;
}

h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

p,
ul,
ol {
  margin: 0 0 1rem;
}

.post-body li + li {
  margin-top: 0.35rem;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.15rem;
}

code {
  padding: 0.05em 0.25em;
  border-radius: 3px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.85em;
  font-variant-numeric: normal;
}

pre {
  margin: 0 0 1.25rem;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--code-bg);
  line-height: 1.5;
}

pre code {
  padding: 0;
  background: none;
  font-size: 0.85rem;
}

/* Section labels used on index pages */

.section-label {
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.masthead {
  padding-bottom: 0.25rem;
}

.post-meta,
.meta {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-variant-numeric: lining-nums;
}

/* Post lists */

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

.post-list > li + li {
  margin-top: 1.75rem;
}

.post-item .post-meta {
  margin: 0 0 0.25rem;
}

.post-item h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-item h3 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.post-item p:last-child {
  margin: 0;
}

.more {
  margin: 1.5rem 0 0;
  font-family: var(--sans);
  font-size: 0.9rem;
}

/* Software and CV-style definition lists */

.software,
.cv-list {
  margin: 0;
}

.software > div + div,
.cv-list > div + div {
  margin-top: 1.25rem;
}

.software dt,
.cv-list dt {
  font-weight: 600;
}

.software dt .meta {
  margin-left: 0.5rem;
  font-weight: 400;
}

.software dd,
.cv-list dd {
  margin: 0.2rem 0 0;
}

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

/* Contact */

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

.contact li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0.4rem 0;
}

.contact .label {
  min-width: 4.5rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
}

.reveal {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.9rem;
  cursor: pointer;
}

.reveal:hover {
  text-decoration: underline;
}

/* Articles */

.post-header {
  margin-bottom: 2rem;
}

.post-header h1 {
  font-size: 2.1rem;
}

.post-header .post-meta {
  margin: 0;
}

.abstract {
  margin: 0 0 2.5rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--border);
  background: var(--surface);
  font-size: 1rem;
}

.abstract h2 {
  margin: 0 0 0.4rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.abstract p {
  margin: 0;
}

.post-body {
  counter-reset: section;
}

.post-body h2:not(.unnumbered) {
  counter-increment: section;
}

.post-body h2:not(.unnumbered)::before {
  content: counter(section) ".";
  display: inline-block;
  min-width: 1.6em;
  color: var(--muted);
  font-variant-numeric: lining-nums;
}

.post-body ol,
.post-body ul {
  padding-left: 1.5rem;
}

sup {
  line-height: 0;
}

sup a {
  font-family: var(--sans);
  font-size: 0.75em;
  text-decoration: none;
}

.table-wrap {
  margin: 1.5rem 0;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-top: 2px solid var(--rule);
  border-bottom: 2px solid var(--rule);
  font-size: 0.95rem;
  line-height: 1.45;
  font-variant-numeric: lining-nums tabular-nums;
}

caption {
  padding-bottom: 0.5rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85rem;
  text-align: left;
  caption-side: top;
}

th,
td {
  padding: 0.4rem 0.75rem 0.4rem 0;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  padding-right: 0;
}

thead th {
  border-bottom: 1px solid var(--rule);
  font-weight: 600;
}

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

.num {
  text-align: right;
  white-space: nowrap;
}

.references {
  padding-left: 1.75rem;
  font-size: 0.95rem;
}

.references li {
  padding-left: 0.25rem;
  overflow-wrap: anywhere;
}

.references li::marker {
  content: "[" counter(list-item) "] ";
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.85em;
}

:target {
  scroll-margin-top: 1rem;
}

.references li:target {
  background: var(--code-bg);
}

@media (max-width: 30rem) {
  body {
    font-size: 1.0625rem;
  }

  h1,
  .post-header h1 {
    font-size: 1.7rem;
  }

  .site-header nav {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .abstract {
    padding: 0.75rem 1rem;
  }

  .software dt .meta {
    display: block;
    margin-left: 0;
  }
}

@media print {
  .site-header nav,
  .theme-toggle,
  .skip-link {
    display: none;
  }

  body {
    max-width: none;
    background: #fff;
    color: #000;
  }

  a {
    color: inherit;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
