:root {
  --bg: #161719;
  --text: #e6e6e3;
  --muted: #a2a4a8;
  --line: #2e3034;
  --accent: #7db6e3;
  --hit: #1f3a52;
  --hit-text: #d4e7f6;
  --stale: #3d2a1f;
  --stale-text: #f0c4a4;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fcfcfb;
  --text: #1f2023;
  --muted: #5b5e63;
  --line: #e3e3e0;
  --accent: #1b5e8f;
  --hit: #dbe8f3;
  --hit-text: #123f60;
  --stale: #f6e3d6;
  --stale-text: #8a3d12;
  color-scheme: light;
}

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

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

body {
  margin: 0 auto;
  max-width: 760px;
  padding: 0 20px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
}

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

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

h1,
h2,
h3 {
  line-height: 1.3;
  font-weight: 600;
  margin: 0;
}

h1 {
  font-size: 2rem;
  margin-bottom: 16px;
}

h2 {
  font-size: 1.375rem;
  margin-bottom: 24px;
}

h3 {
  font-size: 1.0625rem;
}

p {
  margin: 0 0 14px;
}

/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.name {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 0.9375rem;
}

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

.site-header nav a:hover {
  color: var(--accent);
}

/* Sections */
section {
  padding: 48px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 72px;
}

/* Intro */
.intro {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 36px;
  align-items: start;
}

.portrait {
  width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  list-style: none;
  padding: 0;
  margin: 20px 0 0;
  font-weight: 500;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: -6px 0 18px;
}

.keywords li {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--hit);
  color: var(--hit-text);
  font-size: 0.875rem;
  font-weight: 500;
}

/* Projects */
.project + .project {
  margin-top: 44px;
}

.meta {
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  margin: 4px 0 14px;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-weight: 500;
}

.diagram {
  margin: 22px 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.versions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.diagram figcaption {
  font-size: 0.9375rem;
  color: var(--muted);
}

/* Publications */
.pubs {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pubs li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pubs li + li {
  margin-top: 22px;
}

.pub-title {
  font-weight: 600;
}

.venue {
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
}

/* Experience */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
}

.timeline li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 20px;
}

.timeline li + li {
  margin-top: 22px;
}

.timeline h3 {
  margin-bottom: 4px;
}

.when {
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  white-space: nowrap;
}

.timeline .when {
  padding-top: 2px;
}

.tools {
  margin-bottom: 36px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px 40px;
}

.small-heading {
  font-size: 0.9375rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 10px;
}

.plain {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9375rem;
}

.plain li + li {
  margin-top: 8px;
}

.plain .when {
  display: block;
}

/* Footer */
.site-footer {
  padding: 28px 0 40px;
  font-size: 0.875rem;
  color: var(--muted);
}

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

  h1 {
    font-size: 1.75rem;
  }

  section {
    padding: 36px 0;
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .portrait {
    width: 128px;
  }

  .timeline li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .diagram {
    padding: 14px;
  }

}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Internship callout */
.callout {
  margin: 0 0 4px;
  padding: 18px 22px;
  border-left: 3px solid var(--accent);
  background: var(--hit);
  border-radius: 0 8px 8px 0;
  margin-top: -12px;
}

.callout p {
  margin: 0;
}

/* Smaran diagram */
.diagram-hint {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.versions {
  grid-template-columns: repeat(8, 1fr);
}

.versions button {
  appearance: none;
  background: transparent;
  text-align: center;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

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

.versions button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.versions button.hit {
  background: var(--hit);
  border-color: transparent;
  color: var(--hit-text);
}

/* HotSwap diagram */
.groups {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: background-color 0.2s;
}

.group button {
  appearance: none;
  background: transparent;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
}

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

.group button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.group button.hot {
  background: var(--accent);
  border-color: var(--accent);
}

.group.stale {
  background: var(--stale);
  border-color: transparent;
}

.group.stale button:not(.hot) {
  border-color: color-mix(in srgb, var(--stale-text) 35%, transparent);
}

.demo-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.demo-button {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

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


/* Smaller project entries */
.project.small h3 {
  font-size: 1rem;
}

.project.small + .project.small {
  margin-top: 28px;
}

#research > .small-heading {
  margin-top: 48px;
  margin-bottom: 16px;
}

.small-heading.spaced {
  margin-top: 28px;
}

/* Proof size bars */
.bars {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px 12px;
  margin: 4px 0 14px;
  font-size: 0.875rem;
  color: var(--muted);
}

.bar {
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--muted);
  border-radius: 5px;
  transition: width 0.25s;
}

.bar i.fixed {
  width: 25%;
  background: var(--accent);
}

.bar-value {
  font-family: var(--mono);
  min-width: 6.5em;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 24px 0 6px;
}

.pub-note {
  font-size: 0.9375rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  section {
    scroll-margin-top: 110px;
  }

  .groups {
    grid-template-columns: repeat(2, 1fr);
  }

  .versions {
    grid-template-columns: repeat(4, 1fr);
  }
}

.authors {
  font-size: 0.9375rem;
  margin-top: -8px;
}

.authors span {
  color: var(--muted);
}

.abstract {
  margin: 4px 0 18px;
}

.abstract summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
  width: fit-content;
}

.abstract p {
  margin: 10px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--line);
  font-size: 0.9375rem;
  color: var(--muted);
}

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 16px;
  margin-bottom: 10px;
}

.project-head .meta {
  margin: 0;
}

#cry-for-help h3 {
  margin-bottom: 12px;
}

.project-head .project-links {
  margin: 0;
}

/* Theme toggle */
.theme-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 12px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}

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

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