.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-1) var(--space-4);
  align-items: start;
  padding: var(--space-3) 0;
  border-bottom: var(--line-width) solid var(--line);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.page-back {
  justify-self: start;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-decoration: none;
}

.page-back:hover {
  color: var(--ink);
  text-decoration: underline;
}

.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.page-badge {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* The title with a step either side of it, the title centred between. */
.page-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  text-align: center;
}

.page-context {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Bottom-aligned, so a button lines up with a labelled select's control. */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

/* The title keeps a readable width beside its actions: a head with more
   actions than the row holds wraps the actions, never the title to a word
   a line. */
@media (min-width: 40rem) {
  .page-head {
    grid-template-columns: minmax(16rem, 1fr) auto;
    /* Actions taller than the head's lines leave their extra height in the
       third row, under the lines or at the last of them, not between a
       title and its context. */
    grid-template-rows: auto auto 1fr;
  }

  .page-back {
    grid-column: 1;
  }

  .page-title {
    grid-column: 1;
  }

  .page-heading {
    grid-column: 1;
  }

  /* Room enough: the steps sit beside the title rather than at the
     screen's edges, where a phone's thumbs want them. */
  .page-stepper {
    grid-column: 1;
    justify-content: flex-start;
    text-align: left;
  }

  .page-context {
    grid-column: 1;
  }

  .page-actions {
    grid-column: 2;
    grid-row: 1 / span 3;
    justify-content: flex-end;
    margin-top: 0;
  }
}
